axelar-gmp-sdk-solidity

Solidity API

BaseWeightedMultisig

BASE_WEIGHTED_MULTISIG_SLOT

bytes32 BASE_WEIGHTED_MULTISIG_SLOT

BaseWeightedMultisigStorage

struct BaseWeightedMultisigStorage {
  uint256 epoch;
  uint256 lastRotationTimestamp;
  mapping(uint256 => bytes32) signersHashByEpoch;
  mapping(bytes32 => uint256) epochBySignersHash;
}

previousSignersRetention

uint256 previousSignersRetention

Previous signers retention. 0 means only the current signers are valid

domainSeparator

bytes32 domainSeparator

The domain separator for the signer proof

minimumRotationDelay

uint256 minimumRotationDelay

The minimum delay required between rotations

constructor

constructor(uint256 previousSignersRetention_, bytes32 domainSeparator_, uint256 minimumRotationDelay_) internal

Initializes the contract. Ownership of this contract should be transferred to the Gateway contract after deployment.

Parameters

Name Type Description
previousSignersRetention_ uint256 The number of previous signers to retain
domainSeparator_ bytes32 The domain separator for the signer proof
minimumRotationDelay_ uint256 The minimum delay required between rotations

epoch

function epoch() external view returns (uint256)

This function returns the current signers epoch

Return Values

Name Type Description
[0] uint256 uint256 The current signers epoch

signersHashByEpoch

function signersHashByEpoch(uint256 signerEpoch) external view returns (bytes32)

This function returns the signers hash for a given epoch

Parameters

Name Type Description
signerEpoch uint256 The given epoch

Return Values

Name Type Description
[0] bytes32 bytes32 The signers hash for the given epoch

epochBySignersHash

function epochBySignersHash(bytes32 signersHash) external view returns (uint256)

This function returns the epoch for a given signers hash

Parameters

Name Type Description
signersHash bytes32 The signers hash

Return Values

Name Type Description
[0] uint256 uint256 The epoch for the given signers hash

lastRotationTimestamp

function lastRotationTimestamp() external view returns (uint256)

This function returns the timestamp for the last signer rotation

Return Values

Name Type Description
[0] uint256 uint256 The last rotation timestamp

timeSinceRotation

function timeSinceRotation() external view returns (uint256)

This function returns the time elapsed (in secs) since the last rotation

Return Values

Name Type Description
[0] uint256 uint256 The time since the last rotation

_validateProof

function _validateProof(bytes32 dataHash, struct Proof proof) internal view returns (bool isLatestSigners)

This function takes dataHash and proof data and reverts if proof is invalid

The proof data should have signers, weights, threshold and signatures encoded The proof is only valid if the signers weight crosses the threshold and there are no redundant signatures The signers and signatures should be sorted by signer address in ascending order Example: abi.encode([0x11…, 0x22…, 0x33…], [1, 1, 1], 2, [signature1, signature3])

Parameters

Name Type Description
dataHash bytes32 The hash of the message that was signed
proof struct Proof The multisig proof data

Return Values

Name Type Description
isLatestSigners bool True if the proof is from the latest signer set

_rotateSigners

function _rotateSigners(struct WeightedSigners newSigners, bool enforceRotationDelay) internal

This function rotates the current signers with a new set of signers

Rotation to repeated signers is not allowed. While the individual signer addresses and weights can be repeated, the nonce must be different. The signers should be sorted by signer address in ascending order

Parameters

Name Type Description
newSigners struct WeightedSigners The new weighted signers data
enforceRotationDelay bool If true, the minimum rotation delay will be enforced

_updateRotationTimestamp

function _updateRotationTimestamp(bool enforceRotationDelay) internal

Updates the last rotation timestamp, and enforces the minimum rotation delay if specified

_validateSignatures

function _validateSignatures(bytes32 messageHash, struct WeightedSigners weightedSigners, bytes[] signatures) internal pure

This function takes messageHash and proof data and reverts if proof is invalid

The signers and signatures should be sorted by signer address in ascending order

Parameters

Name Type Description
messageHash bytes32 The hash of the message that was signed
weightedSigners struct WeightedSigners The weighted signers data
signatures bytes[] The sorted signatures data

messageHashToSign

function messageHashToSign(bytes32 signersHash, bytes32 dataHash) public view returns (bytes32)

Compute the message hash that is signed by the weighted signers

_Returns an Ethereum Signed Message, created from domainSeparator, signersHash, and dataHash. This replicates the behavior of the https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[eth_sign] JSON-RPC method.

See {recover}._

Parameters

Name Type Description
signersHash bytes32 The hash of the weighted signers that sign off on the data
dataHash bytes32 The hash of the data

Return Values

Name Type Description
[0] bytes32 The message hash to be signed

_validateSigners

function _validateSigners(struct WeightedSigners weightedSigners) internal pure

This function checks if the provided signers are valid, i.e sorted and contain no duplicates, with valid weights and threshold

If signers are invalid, the method will revert

Parameters

Name Type Description
weightedSigners struct WeightedSigners The weighted signers

_baseWeightedMultisigStorage

function _baseWeightedMultisigStorage() internal pure returns (struct BaseWeightedMultisig.BaseWeightedMultisigStorage slot)

Gets the specific storage location for preventing upgrade collisions

Return Values

Name Type Description
slot struct BaseWeightedMultisig.BaseWeightedMultisigStorage containing the BaseWeightedMultisigStorage struct