Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 1f15e88

Browse files
Documentation update (#626)
* update documentation for 721 and 1155 safes * minor docs addition * fix multiple typos * refactor typo depositer to depositor * describe difference generic vs erc handlers on fail * rename depositer to depositor * change fee percent desc * add erc1155 data description * Update data definition for erc1155 Co-authored-by: Oleksii Matiiasevych <lastperson@gmail.com> * Update data definition for erc1155 Co-authored-by: Oleksii Matiiasevych <lastperson@gmail.com> Co-authored-by: Oleksii Matiiasevych <lastperson@gmail.com>
1 parent d97190c commit 1f15e88

Some content is hidden

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

44 files changed

+490
-450
lines changed

contracts/Bridge.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,21 @@ contract Bridge is Pausable, Context {
146146
@param handlerAddress Address of handler resource will be set for.
147147
@param resourceID ResourceID to be used when making deposits.
148148
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
149+
@param depositFunctionSig Function signature of method to be called in {contractAddress} when a deposit is made.
150+
@param depositFunctionDepositorOffset Depositor address position offset in the metadata, in bytes.
151+
@param executeFunctionSig Function signature of method to be called in {contractAddress} when a deposit is executed.
149152
*/
150153
function adminSetGenericResource(
151154
address handlerAddress,
152155
bytes32 resourceID,
153156
address contractAddress,
154157
bytes4 depositFunctionSig,
155-
uint256 depositFunctionDepositerOffset,
158+
uint256 depositFunctionDepositorOffset,
156159
bytes4 executeFunctionSig
157160
) external onlyAllowed {
158161
_resourceIDToHandlerAddress[resourceID] = handlerAddress;
159162
IGenericHandler handler = IGenericHandler(handlerAddress);
160-
handler.setResource(resourceID, contractAddress, depositFunctionSig, depositFunctionDepositerOffset, executeFunctionSig);
163+
handler.setResource(resourceID, contractAddress, depositFunctionSig, depositFunctionDepositorOffset, executeFunctionSig);
161164
}
162165

163166
/**
@@ -274,6 +277,9 @@ contract Bridge is Pausable, Context {
274277
@param data Data originally provided when deposit was made.
275278
@param signature bytes memory signature composed of MPC key shares
276279
@notice Emits {ProposalExecution} event.
280+
@notice Behaviour of this function is different for {GenericHandler} and other specific ERC handlers.
281+
In the case of ERC handler, when execution fails, the handler will terminate the function with revert.
282+
In the case of {GenericHandler}, when execution fails, the handler will emit a failure event and terminate the function normally.
277283
*/
278284
function executeProposal(uint8 originDomainID, uint64 depositNonce, bytes calldata data, bytes32 resourceID, bytes calldata signature) public whenNotPaused {
279285
require(isProposalExecuted(originDomainID, depositNonce) != true, "Deposit with provided nonce already executed");
@@ -303,6 +309,9 @@ contract Bridge is Pausable, Context {
303309
- data Data originally provided when deposit was made.
304310
@param signature bytes memory signature for the whole array composed of MPC key shares
305311
@notice Emits {ProposalExecution} event for each proposal in the batch.
312+
@notice Behaviour of this function is different for {GenericHandler} and other specific ERC handlers.
313+
In the case of ERC handler, when execution fails, the handler will terminate the function with revert.
314+
In the case of {GenericHandler}, when execution fails, the handler will emit a failure event and terminate the function normally.
306315
*/
307316
function executeProposals(Proposal[] memory proposals, bytes memory signature) public whenNotPaused {
308317
require(proposals.length > 0, "Proposals can't be an empty array");
@@ -373,6 +382,7 @@ contract Bridge is Pausable, Context {
373382
/**
374383
@notice This method is used to trigger the process for retrying failed deposits on the MPC side.
375384
@param txHash Transaction hash which contains deposit that should be retried
385+
@notice This is not applicable for failed executions on {GenericHandler}
376386
*/
377387
function retry(string memory txHash) external {
378388
emit Retry(txHash);

contracts/ERC1155Safe.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ contract ERC1155Safe {
5656
/**
5757
@notice Used to burn ERC1155s with batching.
5858
@param tokenAddress Address of ERC1155 to burn.
59+
@param owner Owner of tokens to burn.
5960
@param tokenIDs IDs of tokens to burn.
6061
@param amounts Amounts of tokens to burn.
6162
*/

contracts/ERC721Safe.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import "./ERC721MinterBurnerPauser.sol";
1212
contract ERC721Safe {
1313

1414
/**
15-
@notice Used to gain custoday of deposited token.
15+
@notice Used to gain custody of deposited token.
1616
@param tokenAddress Address of ERC721 to transfer.
1717
@param owner Address of current token owner.
1818
@param recipient Address to transfer token to.
@@ -51,6 +51,7 @@ contract ERC721Safe {
5151
/**
5252
@notice Used to burn ERC721s.
5353
@param tokenAddress Address of ERC721 to burn.
54+
@param owner Owner of token to burn.
5455
@param tokenID ID of token to burn.
5556
*/
5657
function burnERC721(address tokenAddress, address owner, uint256 tokenID) internal {

contracts/TestContracts.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ contract ThreeArguments {
3535
}
3636
}
3737

38-
contract WithDepositer {
39-
event WithDepositerCalled(address argumentOne, uint256 argumentTwo);
38+
contract WithDepositor {
39+
event WithDepositorCalled(address argumentOne, uint256 argumentTwo);
4040

41-
function withDepositer(address argumentOne, uint256 argumentTwo) external {
42-
emit WithDepositerCalled(argumentOne, argumentTwo);
41+
function withDepositor(address argumentOne, uint256 argumentTwo) external {
42+
emit WithDepositorCalled(argumentOne, argumentTwo);
4343
}
4444
}
4545

contracts/handlers/ERC1155Handler.sol

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ contract ERC1155Handler is IDepositExecute, HandlerHelpers, ERC1155Safe, ERC1155
2323
}
2424

2525
/**
26-
@notice A deposit is initiatied by making a deposit in the Bridge contract.
26+
@notice A deposit is initiated by making a deposit in the Bridge contract.
2727
@param resourceID ResourceID used to find address of token to be used for deposit.
28-
@param depositer Address of account making the deposit in the Bridge contract.
28+
@param depositor Address of account making the deposit in the Bridge contract.
2929
@param data Consists of ABI-encoded arrays of tokenIDs and amounts.
30+
@notice Data passed into the function should be constructed as ABI encoding of:
31+
tokenIDs uint256[] bytes
32+
amounts uint256[] bytes
33+
destinationRecipientAddress bytes bytes
34+
transferData bytes bytes
3035
*/
31-
function deposit(bytes32 resourceID, address depositer, bytes calldata data) external override onlyBridge returns (bytes memory metaData) {
36+
function deposit(bytes32 resourceID, address depositor, bytes calldata data) external override onlyBridge returns (bytes memory metaData) {
3237
uint[] memory tokenIDs;
3338
uint[] memory amounts;
3439

@@ -38,17 +43,23 @@ contract ERC1155Handler is IDepositExecute, HandlerHelpers, ERC1155Safe, ERC1155
3843
require(tokenAddress != address(0), "provided resourceID does not exist");
3944

4045
if (_burnList[tokenAddress]) {
41-
burnBatchERC1155(tokenAddress, depositer, tokenIDs, amounts);
46+
burnBatchERC1155(tokenAddress, depositor, tokenIDs, amounts);
4247
} else {
43-
lockBatchERC1155(tokenAddress, depositer, address(this), tokenIDs, amounts, EMPTY_BYTES);
48+
lockBatchERC1155(tokenAddress, depositor, address(this), tokenIDs, amounts, EMPTY_BYTES);
4449
}
4550
}
4651

4752
/**
4853
@notice Proposal execution should be initiated when a proposal is finalized in the Bridge contract.
4954
by a relayer on the deposit's destination chain.
55+
@param resourceID ResourceID to be used when making deposits.
5056
@param data Consists of ABI-encoded {tokenIDs}, {amounts}, {recipient},
5157
and {transferData} of types uint[], uint[], bytes, bytes.
58+
@notice Data passed into the function should be constructed as ABI encoding of:
59+
tokenIDs uint256[] bytes
60+
amounts uint256[] bytes
61+
destinationRecipientAddress bytes bytes
62+
transferData bytes bytes
5263
*/
5364
function executeProposal(bytes32 resourceID, bytes calldata data) external override onlyBridge {
5465
uint[] memory tokenIDs;

contracts/handlers/ERC20Handler.sol

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ contract ERC20Handler is IDepositExecute, HandlerHelpers, ERC20Safe {
2020
}
2121

2222
/**
23-
@notice A deposit is initiatied by making a deposit in the Bridge contract.
23+
@notice A deposit is initiated by making a deposit in the Bridge contract.
2424
@param resourceID ResourceID used to find address of token to be used for deposit.
25-
@param depositer Address of account making the deposit in the Bridge contract.
25+
@param depositor Address of account making the deposit in the Bridge contract.
2626
@param data Consists of {amount} padded to 32 bytes.
2727
@notice Data passed into the function should be constructed as follows:
28-
amount uint256 bytes 0 - 32
28+
amount uint256 bytes 0 - 32
29+
destinationRecipientAddress length uint256 bytes 32 - 64
30+
destinationRecipientAddress bytes bytes 64 - END
2931
@dev Depending if the corresponding {tokenAddress} for the parsed {resourceID} is
3032
marked true in {_burnList}, deposited tokens will be burned, if not, they will be locked.
3133
@return an empty data.
3234
*/
3335
function deposit(
3436
bytes32 resourceID,
35-
address depositer,
37+
address depositor,
3638
bytes calldata data
3739
) external override onlyBridge returns (bytes memory) {
3840
uint256 amount;
@@ -42,15 +44,16 @@ contract ERC20Handler is IDepositExecute, HandlerHelpers, ERC20Safe {
4244
require(_contractWhitelist[tokenAddress], "provided tokenAddress is not whitelisted");
4345

4446
if (_burnList[tokenAddress]) {
45-
burnERC20(tokenAddress, depositer, amount);
47+
burnERC20(tokenAddress, depositor, amount);
4648
} else {
47-
lockERC20(tokenAddress, depositer, address(this), amount);
49+
lockERC20(tokenAddress, depositor, address(this), amount);
4850
}
4951
}
5052

5153
/**
5254
@notice Proposal execution should be initiated when a proposal is finalized in the Bridge contract.
5355
by a relayer on the deposit's destination chain.
56+
@param resourceID ResourceID to be used when making deposits.
5457
@param data Consists of {resourceID}, {amount}, {lenDestinationRecipientAddress},
5558
and {destinationRecipientAddress} all padded to 32 bytes.
5659
@notice Data passed into the function should be constructed as follows:

contracts/handlers/ERC721Handler.sol

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ contract ERC721Handler is IDepositExecute, HandlerHelpers, ERC721Safe {
2727
}
2828

2929
/**
30-
@notice A deposit is initiatied by making a deposit in the Bridge contract.
30+
@notice A deposit is initiated by making a deposit in the Bridge contract.
3131
@param resourceID ResourceID used to find address of token to be used for deposit.
32-
@param depositer Address of account making the deposit in the Bridge contract.
32+
@param depositor Address of account making the deposit in the Bridge contract.
3333
@param data Consists of {tokenID} padded to 32 bytes.
3434
@notice Data passed into the function should be constructed as follows:
3535
tokenID uint256 bytes 0 - 32
36+
destinationRecipientAddress length uint256 bytes 32 - 64
37+
destinationRecipientAddress bytes bytes 64 - (64 + len(destinationRecipientAddress))
38+
metadata length uint256 bytes (64 + len(destinationRecipientAddress)) - (64 + len(destinationRecipientAddress) + 32)
39+
metadata bytes bytes (64 + len(destinationRecipientAddress) + 32) - END
3640
@notice If the corresponding {tokenAddress} for the parsed {resourceID} supports {_INTERFACE_ERC721_METADATA},
3741
then {metaData} will be set according to the {tokenURI} method in the token contract.
3842
@dev Depending if the corresponding {tokenAddress} for the parsed {resourceID} is
3943
marked true in {_burnList}, deposited tokens will be burned, if not, they will be locked.
4044
@return metaData : the deposited token metadata acquired by calling a {tokenURI} method in the token contract.
4145
*/
4246
function deposit(bytes32 resourceID,
43-
address depositer,
47+
address depositor,
4448
bytes calldata data
4549
) external override onlyBridge returns (bytes memory metaData) {
4650
uint tokenID;
@@ -57,15 +61,16 @@ contract ERC721Handler is IDepositExecute, HandlerHelpers, ERC721Safe {
5761
}
5862

5963
if (_burnList[tokenAddress]) {
60-
burnERC721(tokenAddress, depositer, tokenID);
64+
burnERC721(tokenAddress, depositor, tokenID);
6165
} else {
62-
lockERC721(tokenAddress, depositer, address(this), tokenID);
66+
lockERC721(tokenAddress, depositor, address(this), tokenID);
6367
}
6468
}
6569

6670
/**
6771
@notice Proposal execution should be initiated when a proposal is finalized in the Bridge contract.
6872
by a relayer on the deposit's destination chain.
73+
@param resourceID ResourceID to be used when making deposits.
6974
@param data Consists of {tokenID}, {resourceID}, {lenDestinationRecipientAddress},
7075
{destinationRecipientAddress}, {lenMeta}, and {metaData} all padded to 32 bytes.
7176
@notice Data passed into the function should be constructed as follows:

contracts/handlers/FeeHandlerRouter.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ contract FeeHandlerRouter is IFeeHandler, AccessControl {
5959
/**
6060
@notice Initiates collecting fee with corresponding fee handler contract using IFeeHandler interface.
6161
@param sender Sender of the deposit.
62+
@param fromDomainID ID of the source chain.
6263
@param destinationDomainID ID of chain deposit will be bridged to.
6364
@param resourceID ResourceID to be used when making deposits.
6465
@param depositData Additional data to be passed to specified handler.
@@ -72,6 +73,7 @@ contract FeeHandlerRouter is IFeeHandler, AccessControl {
7273
/**
7374
@notice Initiates calculating fee with corresponding fee handler contract using IFeeHandler interface.
7475
@param sender Sender of the deposit.
76+
@param fromDomainID ID of the source chain.
7577
@param destinationDomainID ID of chain deposit will be bridged to.
7678
@param resourceID ResourceID to be used when making deposits.
7779
@param depositData Additional data to be passed to specified handler.

0 commit comments

Comments
 (0)