Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lastperson committed Sep 20, 2024
1 parent b166d41 commit 06b2694
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
26 changes: 20 additions & 6 deletions contracts/handlers/DefaultMessageReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions contracts/handlers/ERC20Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 06b2694

Please sign in to comment.