Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add optional message call docs #276

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Please email us a description of the flaw and any related information (e.g. repr
[[email protected]](mailto:[email protected]).

## Audits
You can find audit reports inside [`/audits`](./audits/)
You can find audit reports inside [`/audits`](./audits/)
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
Loading