axelar-gmp-sdk-solidity

Solidity API

MockGateway

TokenType

enum TokenType {
  InternalBurnable,
  InternalBurnableFrom,
  External
}

PREFIX_COMMAND_EXECUTED

bytes32 PREFIX_COMMAND_EXECUTED

PREFIX_TOKEN_ADDRESS

bytes32 PREFIX_TOKEN_ADDRESS

PREFIX_TOKEN_TYPE

bytes32 PREFIX_TOKEN_TYPE

PREFIX_CONTRACT_CALL_APPROVED

bytes32 PREFIX_CONTRACT_CALL_APPROVED

PREFIX_CONTRACT_CALL_APPROVED_WITH_MINT

bytes32 PREFIX_CONTRACT_CALL_APPROVED_WITH_MINT

bools

mapping(bytes32 => bool) bools

addresses

mapping(bytes32 => address) addresses

uints

mapping(bytes32 => uint256) uints

strings

mapping(bytes32 => string) strings

bytes32s

mapping(bytes32 => bytes32) bytes32s

ContractCallApproved

event ContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, bytes32 sourceTxHash, uint256 sourceEventIndex)

sendToken

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.

Parameters

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.

callContract

function callContract(string destinationChain, string destinationContractAddress, bytes payload) external

callContractWithToken

function callContractWithToken(string destinationChain, string destinationContractAddress, bytes payload, string symbol, uint256 amount) external

isContractCallApproved

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.

Parameters

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.

Return Values

Name Type Description
[0] bool True if the contract call is approved, false otherwise.

isContractCallAndMintApproved

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.

Parameters

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.

Return Values

Name Type Description
[0] bool True if the contract call with token minting is approved, false otherwise.

validateContractCall

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.

Parameters

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.

Return Values

Name Type Description
valid bool True if the contract call is validated and approved, false otherwise.

validateContractCallAndMint

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.

Parameters

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.

Return Values

Name Type Description
valid bool True if the contract call with token minting is validated and approved, false otherwise.

tokenAddresses

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.

Parameters

Name Type Description
symbol string The symbol of the token to retrieve the address for.

Return Values

Name Type Description
[0] address The contract address of the token corresponding to the given symbol.

isCommandExecuted

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.

Parameters

Name Type Description
commandId bytes32 The identifier of the command to check.

Return Values

Name Type Description
[0] bool True if the command has been executed, false otherwise.

deployToken

function deployToken(bytes params, bytes32 commandId) external

mintToken

function mintToken(bytes params, bytes32 commandId) external

approveContractCall

function approveContractCall(bytes params, bytes32 commandId) external

approveContractCallWithMint

function approveContractCallWithMint(bytes params, bytes32 commandId) external

_callERC20Token

function _callERC20Token(address tokenAddress, bytes callData) internal returns (bool)

_deployToken

function _deployToken(string name, string symbol, uint8 decimals, uint256, bytes32 salt) internal returns (address tokenAddress)

_mintToken

function _mintToken(string symbol, address account, uint256 amount) internal

_burnTokenFrom

function _burnTokenFrom(address sender, string symbol, uint256 amount) internal

_getTokenTypeKey

function _getTokenTypeKey(string symbol) internal pure returns (bytes32)

_getTokenAddressKey

function _getTokenAddressKey(string symbol) internal pure returns (bytes32)

_getIsCommandExecutedKey

function _getIsCommandExecutedKey(bytes32 commandId) internal pure returns (bytes32)

_getIsContractCallApprovedKey

function _getIsContractCallApprovedKey(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal pure returns (bytes32)

_getIsContractCallApprovedWithMintKey

function _getIsContractCallApprovedWithMintKey(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount) internal pure returns (bytes32)

_getTokenType

function _getTokenType(string symbol) internal view returns (enum MockGateway.TokenType)

_setTokenType

function _setTokenType(string symbol, enum MockGateway.TokenType tokenType) internal

_setTokenAddress

function _setTokenAddress(string symbol, address tokenAddress) internal

_setCommandExecuted

function _setCommandExecuted(bytes32 commandId, bool executed) internal

_setContractCallApproved

function _setContractCallApproved(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash) internal

_setContractCallApprovedWithMint

function _setContractCallApprovedWithMint(bytes32 commandId, string sourceChain, string sourceAddress, address contractAddress, bytes32 payloadHash, string symbol, uint256 amount) internal