This contract handles cross-chain governance actions. It includes functionality to create, cancel, and execute governance proposals.
enum GovernanceCommand {
ScheduleTimeLockProposal,
CancelTimeLockProposal
}
string governanceChain
Returns the name of the governance chain.
| Name | Type | Description | | —- | —- | ———– |
string governanceAddress
Returns the address of the governance address.
| Name | Type | Description | | —- | —- | ———– |
bytes32 governanceChainHash
Returns the hash of the governance chain.
| Name | Type | Description | | —- | —- | ———– |
bytes32 governanceAddressHash
Returns the hash of the governance address.
| Name | Type | Description | | —- | —- | ———– |
constructor(address gateway_, string governanceChain_, string governanceAddress_, uint256 minimumTimeDelay) public
Initializes the contract
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 |
modifier onlyGovernance(string sourceChain, string sourceAddress)
Modifier to check if the caller is the governance contract
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 |
modifier onlySelf()
Modifier to check if the caller is the contract itself
function getProposalEta(address target, bytes callData, uint256 nativeValue) external view returns (uint256)
Returns the ETA of a proposal
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 |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 The ETA of the proposal |
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.
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 |
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
Name | Type | Description |
---|---|---|
recipient | address | The address to send the native token to |
amount | uint256 | The amount of native token to send |
function _execute(bytes32, string sourceChain, string sourceAddress, bytes payload) internal
Internal function to execute a proposal action
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 |
function _processCommand(uint256 commandType, address target, bytes callData, uint256 nativeValue, uint256 eta) internal virtual
Internal function to process a governance command
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 |
function _getProposalHash(address target, bytes callData, uint256 nativeValue) internal pure returns (bytes32)
Get proposal hash using the target, callData, and nativeValue
receive() external payable
Allow contract to receive native gas token