Skip to content

Commit 55ff04e

Browse files
authored
Change all doc comments in Solidity to use ///, update Governable with relayable force change. (#337)
1 parent e4d58da commit 55ff04e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1262
-1168
lines changed

packages/contracts/contracts/DeterministicDeployFactory.sol

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright 2021-2023 Webb Technologies
33
* SPDX-License-Identifier: MIT OR Apache-2.0
44
*/
5+
56
pragma solidity ^0.8.18;
67

78
contract DeterministicDeployFactory {
@@ -20,16 +21,14 @@ contract DeterministicDeployFactory {
2021
return addr;
2122
}
2223

23-
/**
24-
@notice Deploy a fungible token
25-
@param bytecode The bytecode of the contract
26-
@param _salt The salt for the contract
27-
@param _feePercentage The fee percentage for wrapping
28-
@param _feeRecipient The recipient for fees from wrapping.
29-
@param _handler The address of the handler
30-
@param _limit The maximum amount of tokens that can be wrapped
31-
@param _isNativeAllowed Whether or not native tokens are allowed to be wrapped
32-
*/
24+
/// @notice Deploy a fungible token
25+
/// @param bytecode The bytecode of the contract
26+
/// @param _salt The salt for the contract
27+
/// @param _feePercentage The fee percentage for wrapping
28+
/// @param _feeRecipient The recipient for fees from wrapping.
29+
/// @param _handler The address of the handler
30+
/// @param _limit The maximum amount of tokens that can be wrapped
31+
/// @param _isNativeAllowed Whether or not native tokens are allowed to be wrapped
3332
function deployFungibleToken(
3433
bytes memory bytecode,
3534
uint _salt,
@@ -54,13 +53,11 @@ contract DeterministicDeployFactory {
5453
require(success, string(data));
5554
}
5655

57-
/**
58-
@notice Deploy a VAnchor
59-
@param bytecode The bytecode of the contract
60-
@param _salt The salt for the contract
61-
@param _minimalWithdrawalAmount The minimal withdrawal amount
62-
@param _maximumDepositAmount The maximum deposit amount
63-
*/
56+
/// @notice Deploy a VAnchor
57+
/// @param bytecode The bytecode of the contract
58+
/// @param _salt The salt for the contract
59+
/// @param _minimalWithdrawalAmount The minimal withdrawal amount
60+
/// @param _maximumDepositAmount The maximum deposit amount
6461
function deployVAnchor(
6562
bytes memory bytecode,
6663
uint _salt,

packages/contracts/contracts/SignatureBridge.sol

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@ import "./utils/ChainIdWithType.sol";
1111
import "./utils/ProposalNonceTracker.sol";
1212
import "./interfaces/IExecutor.sol";
1313

14-
/**
15-
@title Facilitates proposals execution and resource ID additions/updates
16-
@author ChainSafe Systems & Webb Technologies.
17-
*/
14+
/// @title Facilitates proposals execution and resource ID additions/updates
15+
/// @author ChainSafe Systems & Webb Technologies.
1816
contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
1917
// resourceID => handler address
2018
mapping(bytes32 => address) public _resourceIdToHandlerAddress;
2119

22-
/**
23-
Verifying signature of governor over some data
24-
*/
20+
/// @notice Verifying signature of governor over some data
2521
modifier signedByGovernor(bytes memory data, bytes memory sig) {
2622
require(isSignatureFromGovernor(data, sig), "SignatureBridge: Not valid sig from governor");
2723
_;
2824
}
2925

30-
/**
31-
Verifying signature of governor over some datahash
32-
*/
26+
/// @notice Verifying signature of governor over some datahash
3327
modifier signedByGovernorPrehashed(bytes32 hashedData, bytes memory sig) {
3428
require(
3529
isSignatureFromGovernorPrehashed(hashedData, sig),
@@ -38,9 +32,7 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
3832
_;
3933
}
4034

41-
/**
42-
Verifying many signatures from a governor over some datahash
43-
*/
35+
/// @notice Verifying many signatures from a governor over some datahash
4436
modifier manySignedByGovernor(bytes[] memory data, bytes[] memory sig) {
4537
require(data.length == sig.length, "SignatureBridge: Data and sig lengths must match");
4638
for (uint256 i = 0; i < data.length; i++) {
@@ -52,23 +44,19 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
5244
_;
5345
}
5446

55-
/**
56-
@notice Initializes SignatureBridge with a governor
57-
@param initialGovernor Addresses that should be initially granted the relayer role.
58-
*/
47+
/// @notice Initializes SignatureBridge with a governor
48+
/// @param initialGovernor Addresses that should be initially granted the relayer role.
5949
constructor(address initialGovernor, uint32 nonce) Governable(initialGovernor, nonce) {}
6050

61-
/**
62-
@notice Sets a new resource for handler contracts that use the IExecutor interface,
63-
and maps the {handlerAddress} to {newResourceID} in {_resourceIdToHandlerAddress}.
64-
@notice Only callable by an address that currently has the admin role.
65-
@param resourceID Target resource ID of the proposal header.
66-
@param functionSig Function signature of the proposal header.
67-
@param nonce Nonce of the proposal header.
68-
@param newResourceID Secondary resourceID begin mapped to a handler address.
69-
@param handlerAddress Address of handler resource will be set for.
70-
@param sig The signature from the governor of the encoded set resource proposal.
71-
*/
51+
/// @notice Sets a new resource for handler contracts that use the IExecutor interface,
52+
/// and maps the {handlerAddress} to {newResourceID} in {_resourceIdToHandlerAddress}.
53+
/// @notice Only callable by an address that currently has the admin role.
54+
/// @param resourceID Target resource ID of the proposal header.
55+
/// @param functionSig Function signature of the proposal header.
56+
/// @param nonce Nonce of the proposal header.
57+
/// @param newResourceID Secondary resourceID begin mapped to a handler address.
58+
/// @param handlerAddress Address of handler resource will be set for.
59+
/// @param sig The signature from the governor of the encoded set resource proposal.
7260
function adminSetResourceWithSignature(
7361
bytes32 resourceID,
7462
bytes4 functionSig,
@@ -84,21 +72,19 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
8472
sig
8573
)
8674
{
87-
_handleSetResource(resourceID, functionSig, nonce, newResourceID, handlerAddress);
75+
_handleSetResource(resourceID, functionSig, newResourceID, handlerAddress);
8876
}
8977

90-
/**
91-
@notice Sets a batch new resources for handler contracts that use the IExecutor interface,
92-
and maps the {handlerAddress} to {newResourceID} in {_resourceIdToHandlerAddress}.
93-
@notice Only callable by an address that currently has the admin role.
94-
@param resourceID Target resource ID of the proposal header.
95-
@param functionSig Function signature of the proposal header.
96-
@param nonces Nonces of the proposal headers.
97-
@param newResourceIDs Secondary resourceIDs begin mapped to a handler address.
98-
@param handlerAddresses Addresses of handler resource will be set for.
99-
@param hashedData The encoded data of all proposals to be used for easy checking.
100-
@param sig The signature from the governor of the encoded set resource proposal.
101-
*/
78+
/// @notice Sets a batch new resources for handler contracts that use the IExecutor interface,
79+
/// and maps the {handlerAddress} to {newResourceID} in {_resourceIdToHandlerAddress}.
80+
/// @notice Only callable by an address that currently has the admin role.
81+
/// @param resourceID Target resource ID of the proposal header.
82+
/// @param functionSig Function signature of the proposal header.
83+
/// @param nonces Nonces of the proposal headers.
84+
/// @param newResourceIDs Secondary resourceIDs begin mapped to a handler address.
85+
/// @param handlerAddresses Addresses of handler resource will be set for.
86+
/// @param hashedData The encoded data of all proposals to be used for easy checking.
87+
/// @param sig The signature from the governor of the encoded set resource proposal.
10288
function batchAdminSetResourceWithSignature(
10389
bytes32 resourceID,
10490
bytes4 functionSig,
@@ -131,31 +117,21 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
131117
);
132118

133119
for (uint i = 0; i < nonces.length; i++) {
134-
_handleSetResource(
135-
resourceID,
136-
functionSig,
137-
nonces[i],
138-
newResourceIDs[i],
139-
handlerAddresses[i]
140-
);
120+
_handleSetResource(resourceID, functionSig, newResourceIDs[i], handlerAddresses[i]);
141121
}
142122
}
143123

144-
/**
145-
@notice Executes a proposal signed by the governor.
146-
@param data Data meant for execution by execution handlers.
147-
*/
124+
/// @notice Executes a proposal signed by the governor.
125+
/// @param data Data meant for execution by execution handlers.
148126
function executeProposalWithSignature(
149127
bytes calldata data,
150128
bytes memory sig
151129
) external signedByGovernor(data, sig) {
152130
_handleExecuteProposal(data);
153131
}
154132

155-
/**
156-
@notice Executes a many of proposals signed by the governor in a single tx.
157-
@param data Data meant for execution by execution handlers.
158-
*/
133+
/// @notice Executes a many of proposals signed by the governor in a single tx.
134+
/// @param data Data meant for execution by execution handlers.
159135
function executeManyProposalsWithSignature(
160136
bytes[] calldata data,
161137
bytes[] memory sig
@@ -165,10 +141,8 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
165141
}
166142
}
167143

168-
/**
169-
@notice Executes a batch of proposals signed by the governor in a single tx.
170-
@param data Data meant for execution by execution handlers.
171-
*/
144+
/// @notice Executes a batch of proposals signed by the governor in a single tx.
145+
/// @param data Data meant for execution by execution handlers.
172146
function batchExecuteProposalsWithSignature(
173147
bytes[] calldata data,
174148
bytes memory sig
@@ -193,7 +167,6 @@ contract SignatureBridge is Governable, ChainIdWithType, ProposalNonceTracker {
193167
function _handleSetResource(
194168
bytes32 resourceID,
195169
bytes4 functionSig,
196-
uint32 nonce,
197170
bytes32 newResourceID,
198171
address handlerAddress
199172
) internal {

packages/contracts/contracts/Treasury.sol

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
1111
import "./interfaces/ITreasury.sol";
1212
import "./utils/ProposalNonceTracker.sol";
1313

14+
/// @title Treasury contract
15+
/// @author Webb Technologies.
16+
/// @notice This contract is used to store funds and recover them.
1417
contract Treasury is ITreasury, ProposalNonceTracker {
1518
using SafeERC20 for IERC20;
1619
address treasuryHandler;
1720

1821
event TreasuryHandlerUpdated(address _handler);
1922

2023
constructor(address _treasuryHandler) {
21-
require(_treasuryHandler != address(0), "Treasury Handler can't be 0");
24+
require(_treasuryHandler != address(0), "Treasury: Treasury Handler can't be 0");
2225
treasuryHandler = _treasuryHandler;
2326
}
2427

2528
modifier onlyHandler() {
26-
require(msg.sender == treasuryHandler, "Function can only be called by treasury handler");
29+
require(
30+
msg.sender == treasuryHandler,
31+
"Treasury: Function can only be called by treasury handler"
32+
);
2733
_;
2834
}
2935

@@ -33,8 +39,8 @@ contract Treasury is ITreasury, ProposalNonceTracker {
3339
uint256 amountToRescue,
3440
uint32 nonce
3541
) external override onlyHandler onlyIncrementingByOne(nonce) {
36-
require(to != address(0), "Cannot send liquidity to zero address");
37-
require(tokenAddress != address(this), "Cannot rescue wrapped asset");
42+
require(to != address(0), "Treasury: Cannot send liquidity to zero address");
43+
require(tokenAddress != address(this), "Treasury: Cannot rescue wrapped asset");
3844

3945
if (tokenAddress == address(0)) {
4046
// Native Ether
@@ -59,7 +65,7 @@ contract Treasury is ITreasury, ProposalNonceTracker {
5965
address newHandler,
6066
uint32 nonce
6167
) external override onlyHandler onlyIncrementingByOne(nonce) {
62-
require(newHandler != address(0), "Handler cannot be 0");
68+
require(newHandler != address(0), "Treasury: Handler cannot be 0");
6369
treasuryHandler = newHandler;
6470
emit TreasuryHandlerUpdated(treasuryHandler);
6571
}

packages/contracts/contracts/handlers/AnchorHandler.sol

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,37 @@ import "../interfaces/IExecutor.sol";
1111
import "../interfaces/verifiers/ISetVerifier.sol";
1212
import "../interfaces/ILinkableAnchor.sol";
1313

14-
/**
15-
@title Handles Anchor edge list merkle root updates
16-
@author Webb Technologies.
17-
@notice This contract is intended to be used with the Bridge contract.
18-
*/
14+
/// @title Handles Anchor edge list merkle root updates
15+
/// @author Webb Technologies.
16+
/// @notice This contract is intended to be used with the Bridge contract.
1917
contract AnchorHandler is IExecutor, HandlerHelpers {
20-
/**
21-
@param bridgeAddress Contract address of previously deployed Bridge.
22-
@param initialResourceIDs Resource IDs are used to identify a specific contract address.
23-
These are the Resource IDs this contract will initially support.
24-
@param initialContractAddresses These are the addresses the {initialResourceIDs} will point to, and are the contracts that will be
25-
called to perform various deposit calls.
26-
@dev {initialResourceIDs} and {initialContractAddresses} must have the same length (one resourceID for every address).
27-
Also, these arrays must be ordered in the way that {initialResourceIDs}[0] is the intended resourceID for {initialContractAddresses}[0].
28-
*/
18+
/// @param bridgeAddress Contract address of previously deployed Bridge.
19+
/// @param initialResourceIDs Resource IDs are used to identify a specific contract address.
20+
/// These are the Resource IDs this contract will initially support.
21+
/// @param initialContractAddresses These are the addresses the {initialResourceIDs} will point to, and are the contracts that will be
22+
/// called to perform various deposit calls.
23+
/// @dev {initialResourceIDs} and {initialContractAddresses} must have the same length (one resourceID for every address).
24+
/// Also, these arrays must be ordered in the way that {initialResourceIDs}[0] is the intended resourceID for {initialContractAddresses}[0].
2925
constructor(
3026
address bridgeAddress,
3127
bytes32[] memory initialResourceIDs,
3228
address[] memory initialContractAddresses
3329
) {
3430
require(
3531
initialResourceIDs.length == initialContractAddresses.length,
36-
"initialResourceIDs and initialContractAddresses len mismatch"
32+
"AnchorHandler: initialResourceIDs and initialContractAddresses len mismatch"
3733
);
38-
require(bridgeAddress != address(0), "Bridge Address can't be 0");
34+
require(bridgeAddress != address(0), "AnchorHandler: Bridge Address can't be 0");
3935
_bridgeAddress = bridgeAddress;
4036

4137
for (uint256 i = 0; i < initialResourceIDs.length; i++) {
4238
_setResource(initialResourceIDs[i], initialContractAddresses[i]);
4339
}
4440
}
4541

46-
/**
47-
@notice Proposal execution should be initiated when a proposal is signed and executed by the `SignatureBridge`
48-
@param resourceID ResourceID corresponding to a particular executing anchor contract.
49-
@param data Consists of a specific proposal data structure for each finer-grained anchor proposal
50-
*/
42+
/// @notice Proposal execution should be initiated when a proposal is signed and executed by the `SignatureBridge`
43+
/// @param resourceID ResourceID corresponding to a particular executing anchor contract.
44+
/// @param data Consists of a specific proposal data structure for each finer-grained anchor proposal
5145
function executeProposal(bytes32 resourceID, bytes calldata data) external override onlyBridge {
5246
bytes32 resourceId;
5347
bytes4 functionSig;
@@ -59,7 +53,10 @@ contract AnchorHandler is IExecutor, HandlerHelpers {
5953

6054
address anchorAddress = _resourceIDToContractAddress[resourceID];
6155

62-
require(_contractWhitelist[anchorAddress], "provided tokenAddress is not whitelisted");
56+
require(
57+
_contractWhitelist[anchorAddress],
58+
"AnchorHandler: provided tokenAddress is not whitelisted"
59+
);
6360

6461
if (functionSig == bytes4(keccak256("setHandler(address,uint32)"))) {
6562
uint32 nonce = uint32(bytes4(arguments[0:4]));
@@ -93,7 +90,7 @@ contract AnchorHandler is IExecutor, HandlerHelpers {
9390
nonce
9491
);
9592
} else {
96-
revert("Invalid function sig");
93+
revert("AnchorHandler: Invalid function sig");
9794
}
9895
}
9996
}

0 commit comments

Comments
 (0)