axelar-gmp-sdk-solidity

Solidity API

InterchainGovernance

This contract handles cross-chain governance actions. It includes functionality to create, cancel, and execute governance proposals.

GovernanceCommand

enum GovernanceCommand {
  ScheduleTimeLockProposal,
  CancelTimeLockProposal
}

governanceChain

string governanceChain

Returns the name of the governance chain.

Return Values

| Name | Type | Description | | —- | —- | ———– |

governanceAddress

string governanceAddress

Returns the address of the governance address.

Return Values

| Name | Type | Description | | —- | —- | ———– |

governanceChainHash

bytes32 governanceChainHash

Returns the hash of the governance chain.

Return Values

| Name | Type | Description | | —- | —- | ———– |

governanceAddressHash

bytes32 governanceAddressHash

Returns the hash of the governance address.

Return Values

| Name | Type | Description | | —- | —- | ———– |

constructor

constructor(address gateway_, string governanceChain_, string governanceAddress_, uint256 minimumTimeDelay) public

Initializes the contract

Parameters

Name Type Description
gateway_ address The address of the Axelar gateway contract
governanceChain_ string The name of the governance chain
governanceAddress_ string The address of the governance contract
minimumTimeDelay uint256 The minimum time delay for timelock operations

onlyGovernance

modifier onlyGovernance(string sourceChain, string sourceAddress)

Modifier to check if the caller is the governance contract

Parameters

Name Type Description
sourceChain string The source chain of the proposal, must equal the governance chain
sourceAddress string The source address of the proposal, must equal the governance address

onlySelf

modifier onlySelf()

Modifier to check if the caller is the contract itself

getProposalEta

function getProposalEta(address target, bytes callData, uint256 nativeValue) external view returns (uint256)

Returns the ETA of a proposal

Parameters

Name Type Description
target address The address of the contract targeted by the proposal
callData bytes The call data to be sent to the target contract
nativeValue uint256 The amount of native tokens to be sent to the target contract

Return Values

Name Type Description
[0] uint256 uint256 The ETA of the proposal

executeProposal

function executeProposal(address target, bytes callData, uint256 nativeValue) external payable

Executes a proposal

The proposal is executed by calling the target contract with calldata. Native value is transferred with the call to the target contract.

Parameters

Name Type Description
target address The target address of the contract to call
callData bytes The data containing the function and arguments for the contract to call
nativeValue uint256 The amount of native token to send to the target contract

withdraw

function withdraw(address recipient, uint256 amount) external

Withdraws native token from the contract

This function is only callable by the contract itself after passing according proposal

Parameters

Name Type Description
recipient address The address to send the native token to
amount uint256 The amount of native token to send

_execute

function _execute(bytes32, string sourceChain, string sourceAddress, bytes payload) internal

Internal function to execute a proposal action

Parameters

Name Type Description
  bytes32  
sourceChain string The source chain of the proposal, must equal the governance chain
sourceAddress string The source address of the proposal, must equal the governance address
payload bytes The payload of the proposal

_processCommand

function _processCommand(uint256 commandType, address target, bytes callData, uint256 nativeValue, uint256 eta) internal virtual

Internal function to process a governance command

Parameters

Name Type Description
commandType uint256 The type of the command, 0 for proposal creation and 1 for proposal cancellation
target address The target address the proposal will call
callData bytes The data the encodes the function and arguments to call on the target contract
nativeValue uint256 The nativeValue of native token to be sent to the target contract
eta uint256 The time after which the proposal can be executed

_getProposalHash

function _getProposalHash(address target, bytes callData, uint256 nativeValue) internal pure returns (bytes32)

Get proposal hash using the target, callData, and nativeValue

receive

receive() external payable

Allow contract to receive native gas token