From 06b26949f4822b6d88ed7fa8bdc5973bccde3487 Mon Sep 17 00:00:00 2001 From: Oleksii Matiiasevych Date: Fri, 20 Sep 2024 16:21:39 +0700 Subject: [PATCH] Add docs --- contracts/handlers/DefaultMessageReceiver.sol | 26 ++++++++++++++----- contracts/handlers/ERC20Handler.sol | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/contracts/handlers/DefaultMessageReceiver.sol b/contracts/handlers/DefaultMessageReceiver.sol index 70537d01..22665d1c 100644 --- a/contracts/handlers/DefaultMessageReceiver.sol +++ b/contracts/handlers/DefaultMessageReceiver.sol @@ -8,6 +8,10 @@ import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import "../utils/AccessControl.sol"; import "../interfaces/ISygmaMessageReceiver.sol"; +/** + @title Optinal Message Call made as part of other handlers proposal execution. + @author ChainSafe Systems. + */ contract DefaultMessageReceiver is ISygmaMessageReceiver, AccessControl, ERC721Holder, ERC1155Holder { bytes32 public constant SYGMA_HANDLER_ROLE = keccak256("SYGMA_HANDLER_ROLE"); @@ -45,10 +49,10 @@ contract DefaultMessageReceiver is ISygmaMessageReceiver, AccessControl, ERC721H uint256 amount ); - /// Constructor /// - - /// @param sygmaHandlers The contract addresses with access to message processing. - /// @param recoverGas The amount of gas needed to forward the original amount to receiver. + /** + @param sygmaHandlers The contract addresses with access to message processing. + @param recoverGas The amount of gas needed to forward the original amount to receiver. + */ constructor(address[] memory sygmaHandlers, uint256 recoverGas) { _recoverGas = recoverGas; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); @@ -68,6 +72,12 @@ contract DefaultMessageReceiver is ISygmaMessageReceiver, AccessControl, ERC721H specified in this particular Action.tokenReceive property. In such a case it is a users responsibility to either send it all with a transferBalanceAction() Action or to include an extra action[s] with tokenReceive set to each of the tokens received. + @param tokenSent Optional address of the token sent along or prior to calling this function. + @param amount Amount of the token sent along or prior to calling this function. + @param message User generated execution command which consists of + {transactionId} an arbitrary identifier. + {actions} array of Action items that allow generic logic execution. + {receiver} a fallback address that will receive any leftovers after either success of fail. */ function handleSygmaMessage( address tokenSent, @@ -183,8 +193,12 @@ contract DefaultMessageReceiver is ISygmaMessageReceiver, AccessControl, ERC721H } } - /// @notice Helper function that could be used as an Action to itself to transfer whole - /// @notice balance of a particular token. + /** + @notice Helper function that could be used as an Action to itself to transfer whole + balance of a particular token. + @param token Address of the ERC20 token or 0x0 for native token. + @param receiver Address that should receive the whole balance. + */ function transferBalanceAction(address token, address receiver) external { if (msg.sender != address(this)) revert InsufficientPermission(); if (token != zeroAddress) { diff --git a/contracts/handlers/ERC20Handler.sol b/contracts/handlers/ERC20Handler.sol index d9ffc350..73cb070a 100644 --- a/contracts/handlers/ERC20Handler.sol +++ b/contracts/handlers/ERC20Handler.sol @@ -21,6 +21,7 @@ contract ERC20Handler is IHandler, ERCHandlerHelpers, DepositDataHelper, ERC20Sa /** @param bridgeAddress Contract address of previously deployed Bridge. + @param defaultMessageReceiver Contract address of previously deployed DefaultMessageReceiver. */ constructor( address bridgeAddress,