Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Latest commit

 

History

History
124 lines (81 loc) · 2.87 KB

File metadata and controls

124 lines (81 loc) · 2.87 KB

GasRouter

Git Source

Inherits: Router

State Variables

destinationGas

mapping(uint32 => uint256) public destinationGas;

Functions

setDestinationGas

Sets the gas amount dispatched for each configured domain.

function setDestinationGas(GasRouterConfig[] calldata gasConfigs) external onlyOwner;

Parameters

Name Type Description
gasConfigs GasRouterConfig[] The array of GasRouterConfig structs

quoteGasPayment

Returns the gas payment required to dispatch a message to the given domain's router.

function quoteGasPayment(uint32 _destinationDomain) external view returns (uint256 _gasPayment);

Parameters

Name Type Description
_destinationDomain uint32 The domain of the router.

Returns

Name Type Description
_gasPayment uint256 Payment computed by the registered InterchainGasPaymaster.

_setDestinationGas

function _setDestinationGas(uint32 domain, uint256 gas) internal;

_dispatchWithGas

Dispatches a message to an enrolled router via the local router's Mailbox and pays for it to be relayed to the destination.

Uses the destinationGas mapping to populate the gas amount for the message.

Reverts if there is no enrolled router for _destinationDomain.

function _dispatchWithGas(
    uint32 _destinationDomain,
    bytes memory _messageBody,
    uint256 _gasPayment,
    address _gasPaymentRefundAddress
) internal returns (bytes32 _messageId);

Parameters

Name Type Description
_destinationDomain uint32 The domain of the chain to which to send the message.
_messageBody bytes Raw bytes content of message.
_gasPayment uint256 The amount of native tokens to pay for the message to be relayed.
_gasPaymentRefundAddress address The address to refund any gas overpayment to.

_dispatchWithGas

Passes msg.value as gas payment and msg.sender as gas payment refund address.

Uses the destinationGas mapping to populate the gas amount for the message.

function _dispatchWithGas(uint32 _destinationDomain, bytes memory _messageBody) internal returns (bytes32 _messageId);

Parameters

Name Type Description
_destinationDomain uint32 The domain of the chain to send the message.
_messageBody bytes Raw bytes content of message.

Events

DestinationGasSet

Emitted when a domain's destination gas is set.

event DestinationGasSet(uint32 indexed domain, uint256 gas);

Structs

GasRouterConfig

struct GasRouterConfig {
    uint32 domain;
    uint256 gas;
}