MockAxelarGateway
Inherits: IAxelarGatewayWithToken
Title: AxelarGateway Contract
This contract serves as the gateway for cross-chain contract calls, and token transfers within the Axelar network. It includes functions for sending tokens, calling contracts, and validating contract calls. The contract is managed via the decentralized governance mechanism on the Axelar network.
EternalStorage is used to simplify storage for upgradability, and InterchainGovernance module is used for governance.
State Variables
tokenMapping
mapping(string => address) tokenMapping
Functions
constructor
constructor() ;
sendToken
Sends tokens to another chain.
Initiates a cross-chain token transfer through the gateway to the specified destination chain and recipient.
function sendToken(
string calldata destinationChain,
string calldata destinationAddress,
string calldata symbol,
uint256 amount
) external;
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. |
callContractWithToken
Makes a contract call on another chain with an associated token transfer.
Initiates a cross-chain contract call through the gateway that includes a token transfer to the specified contract on the destination chain.
function callContractWithToken(
string calldata destinationChain,
string calldata contractAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount
) external;
Parameters
| Name | Type | Description |
|---|---|---|
destinationChain | string | The name of the destination chain. |
contractAddress | string | The address of the contract on the destination chain. |
payload | bytes | The payload data to be used in the contract call. |
symbol | string | The symbol of the token being transferred. |
amount | uint256 | The amount of the tokens being transferred. |
isContractCallAndMintApproved
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.
function isContractCallAndMintApproved(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
address contractAddress,
bytes32 payloadHash,
string calldata symbol,
uint256 amount
) external view returns (bool);
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. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the contract call with token minting is approved, false otherwise. |
validateContractCallAndMint
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.
function validateContractCallAndMint(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes32 payloadHash,
string calldata symbol,
uint256 amount
) external returns (bool);
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. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the contract call with token minting is validated and approved, false otherwise. |
tokenAddresses
Retrieves the address of a token given its symbol.
Gets the contract address of the token registered with the given symbol.
function tokenAddresses(string memory symbol) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | The symbol of the token to retrieve the address for. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The contract address of the token corresponding to the given symbol. |
setTokenAddress
Sets the address of a token given its symbol.
Sets the contract address of the token registered with the given symbol.
function setTokenAddress(string memory symbol, address tokenAddress) external;
Parameters
| Name | Type | Description |
|---|---|---|
symbol | string | The symbol of the token. |
tokenAddress | address | The address of the token. |
callContract
Sends a contract call to another chain.
Initiates a cross-chain contract call through the gateway to the specified destination chain and contract.
function callContract(string calldata destinationChain, string calldata contractAddress, bytes calldata payload)
external;
Parameters
| Name | Type | Description |
|---|---|---|
destinationChain | string | The name of the destination chain. |
contractAddress | string | The address of the contract on the destination chain. |
payload | bytes | The payload data to be used in the contract call. |
isContractCallApproved
Checks if a contract call is approved.
Determines whether a given contract call, identified by the commandId and payloadHash, is approved.
function isContractCallApproved(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
address contractAddress,
bytes32 payloadHash
) external view returns (bool);
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. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the contract call is approved, false otherwise. |
validateContractCall
Validates and approves a contract call.
Validates the given contract call information and marks it as approved if valid.
function validateContractCall(
bytes32 commandId,
string calldata sourceChain,
string calldata sourceAddress,
bytes32 payloadHash
) external returns (bool);
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. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the contract call is validated and approved, false otherwise. |
isCommandExecuted
Checks if a command has been executed.
Determines whether a command, identified by the commandId, has been executed.
function isCommandExecuted(bytes32 commandId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
commandId | bytes32 | The identifier of the command to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the command has been executed, false otherwise. |