enum TokenType {
InternalBurnable,
InternalBurnableFrom,
External
}
bytes32 PREFIX_COMMAND_EXECUTED
bytes32 PREFIX_TOKEN_ADDRESS
bytes32 PREFIX_TOKEN_TYPE
bytes32 PREFIX_CONTRACT_CALL_APPROVED
bytes32 PREFIX_CONTRACT_CALL_APPROVED_WITH_MINT
mapping(bytes32 => bool) bools
mapping(bytes32 => address) addresses
mapping(bytes32 => uint256) uints
mapping(bytes32 => string) strings
mapping(bytes32 => bytes32) bytes32s
event ContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, bytes32 sourceTxHash, uint256 sourceEventIndex)
function sendToken(string destinationChain, string destinationAddress, string symbol, uint256 amount) external
Sends tokens to another chain.
Initiates a cross-chain token transfer through the gateway to the specified destination chain and recipient.
Name | Type | Description |
---|---|---|
destinationChain | string | The name of the destination chain. |
destinationAddress | string | The address of the recipient on the destination chain. |
symbol | string | The symbol of the token being transferred. |
amount | uint256 | The amount of the tokens being transferred. |
function callContract(string destinationChain, string destinationContractAddress, bytes payload) external
function callContractWithToken(string destinationChain, string destinationContractAddress, bytes payload, string symbol, uint256 amount) external
function isContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) external view returns (bool)
Checks if a contract call is approved.
Determines whether a given contract call, identified by the commandId and payloadHash, is approved.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to check. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
contractAddress | address | The address of the contract where the call will be executed. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the contract call is approved, false otherwise. |
function isContractCallAndMintApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount) external view returns (bool)
Checks if a contract call with token minting is approved.
Determines whether a given contract call, identified by the commandId and payloadHash, involving token minting is approved.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to check. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
contractAddress | address | The address of the contract where the call will be executed. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
symbol | string | The symbol of the token associated with the minting. |
amount | uint256 | The amount of the tokens to be minted. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the contract call with token minting is approved, false otherwise. |
function validateContractCall(bytes32 commandId, string sourceChain, string sourceAddress, bytes32 payloadHash) external returns (bool valid)
Validates and approves a contract call.
Validates the given contract call information and marks it as approved if valid.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to validate. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
Name | Type | Description |
---|---|---|
valid | bool | True if the contract call is validated and approved, false otherwise. |
function validateContractCallAndMint(bytes32 commandId, string sourceChain, string sourceAddress, bytes32 payloadHash, string symbol, uint256 amount) external returns (bool valid)
Validates and approves a contract call with token minting.
Validates the given contract call information and marks it as approved if valid. It also involves the minting of tokens.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to validate. |
sourceChain | string | The name of the source chain. |
sourceAddress | string | The address of the sender on the source chain. |
payloadHash | bytes32 | The keccak256 hash of the payload data. |
symbol | string | The symbol of the token associated with the minting. |
amount | uint256 | The amount of the tokens to be minted. |
Name | Type | Description |
---|---|---|
valid | bool | True if the contract call with token minting is validated and approved, false otherwise. |
function tokenAddresses(string symbol) public view returns (address)
Retrieves the address of a token given its symbol.
Gets the contract address of the token registered with the given symbol.
Name | Type | Description |
---|---|---|
symbol | string | The symbol of the token to retrieve the address for. |
Name | Type | Description |
---|---|---|
[0] | address | The contract address of the token corresponding to the given symbol. |
function isCommandExecuted(bytes32 commandId) public view returns (bool)
Checks if a command has been executed.
Determines whether a command, identified by the commandId, has been executed.
Name | Type | Description |
---|---|---|
commandId | bytes32 | The identifier of the command to check. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the command has been executed, false otherwise. |
function deployToken(bytes params, bytes32 commandId) external
function mintToken(bytes params, bytes32 commandId) external
function approveContractCall(bytes params, bytes32 commandId) external
function approveContractCallWithMint(bytes params, bytes32 commandId) external
function _callERC20Token(address tokenAddress, bytes callData) internal returns (bool)
function _deployToken(string name, string symbol, uint8 decimals, uint256, bytes32 salt) internal returns (address tokenAddress)
function _mintToken(string symbol, address account, uint256 amount) internal
function _burnTokenFrom(address sender, string symbol, uint256 amount) internal
function _getTokenTypeKey(string symbol) internal pure returns (bytes32)
function _getTokenAddressKey(string symbol) internal pure returns (bytes32)
function _getIsCommandExecutedKey(bytes32 commandId) internal pure returns (bytes32)
function _getIsContractCallApprovedKey(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal pure returns (bytes32)
function _getIsContractCallApprovedWithMintKey(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount) internal pure returns (bytes32)
function _getTokenType(string symbol) internal view returns (enum MockGateway.TokenType)
function _setTokenType(string symbol, enum MockGateway.TokenType tokenType) internal
function _setTokenAddress(string symbol, address tokenAddress) internal
function _setCommandExecuted(bytes32 commandId, bool executed) internal
function _setContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal
function _setContractCallApprovedWithMint(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount) internal