AppChainGateway

Git Source

Inherits: IAppChainGateway, Migratable, Initializable

The AppChainGateway exposes the ability to receive parameters from the settlement chain gateway, and set them at the parameter registry on this same app chain. Currently, it is a receiver-only contract.

State Variables

_ARB_SYS

The Arbitrum system precompile address.

address internal constant _ARB_SYS = 0x0000000000000000000000000000000000000064;

parameterRegistry

The address of the parameter registry.

address public immutable parameterRegistry;

settlementChainGateway

The address of the settlement chain gateway.

address public immutable settlementChainGateway;

settlementChainGatewayAlias

The L3 alias address of the settlement chain gateway (i.e. the expected caller of the receiveParameters function).

address public immutable settlementChainGatewayAlias;

_APP_CHAIN_GATEWAY_STORAGE_LOCATION

bytes32 internal constant _APP_CHAIN_GATEWAY_STORAGE_LOCATION =
    0xf7630100a9c96f7b07fb982ff1e6dad8abbb961bacff2e820fac4ea93b280300;

Functions

_getAppChainGatewayStorage

function _getAppChainGatewayStorage() internal pure returns (AppChainGatewayStorage storage $);

onlySettlementChainGateway

Modifier to ensure the caller is the settlement chain gateway (i.e. its L3 alias address).

modifier onlySettlementChainGateway();

whenNotPaused

modifier whenNotPaused();

constructor

Constructor for the implementation contract, such that the implementation cannot be initialized.

The parameter registry and settlement chain gateway must not be the zero address.

The parameter registry, settlement chain gateway, and the settlement chain gateway alias are immutable so that they are inlined in the contract code, and have minimal gas cost.

constructor(address parameterRegistry_, address settlementChainGateway_);

Parameters

NameTypeDescription
parameterRegistry_addressThe address of the parameter registry.
settlementChainGateway_addressThe address of the settlement chain gateway.

initialize

Initializes the parameter registry, as used by a proxy contract.

function initialize() external initializer;

withdraw

Withdraws funds from the app chain to the settlement chain.

function withdraw(address recipient_) external payable whenNotPaused;

Parameters

NameTypeDescription
recipient_addressThe address to which the funds will be delivered to on the settlement chain.

withdrawIntoUnderlying

Withdraws funds from the app chain to the settlement chain, unwrapped as underlying fee token.

function withdrawIntoUnderlying(address recipient_) external payable whenNotPaused;

Parameters

NameTypeDescription
recipient_addressThe address to which the funds will be delivered to on the settlement chain.

receiveDeposit

Receives funds from the settlement chain.

The recipient will receive the forwarded amount attached as payable.

function receiveDeposit(address recipient_) external payable;

Parameters

NameTypeDescription
recipient_addressThe address to which the funds will be delivered to.

receiveParameters

Receives parameters from the settlement chain.

The caller must be the settlement chain gateway's L3 alias address.

function receiveParameters(uint256 nonce_, string[] calldata keys_, bytes32[] calldata values_)
    external
    onlySettlementChainGateway;

Parameters

NameTypeDescription
nonce_uint256The nonce of the parameter transmission (to prevent out-of-sequence resets).
keys_string[]The keys of the parameters.
values_bytes32[]The values of each parameter.

updatePauseStatus

Updates the pause status.

Ensures the new pause status is not equal to the old pause status.

function updatePauseStatus() external;

migrate

Initiates a migration of the proxy, in a way defined by the implementation.

Normally, the implementation has a way of determining the migrator that needs to be delegatecalled.

function migrate() external;

migratorParameterKey

The parameter registry key used to fetch the migrator.

function migratorParameterKey() public pure returns (string memory key_);

pausedParameterKey

The parameter registry key used to fetch the paused status.

function pausedParameterKey() public pure returns (string memory key_);

paused

The pause status.

function paused() external view returns (bool paused_);

_withdraw

function _withdraw(address recipient_, bytes4 selector_) internal;

_isZero

function _isZero(address input_) internal pure returns (bool isZero_);

_revertIfNotSettlementChainGateway

function _revertIfNotSettlementChainGateway() internal view;

_revertIfPaused

function _revertIfPaused() internal view;

Structs

AppChainGatewayStorage

The UUPS storage for the app chain gateway.

Note: storage-location: erc7201:xmtp.storage.AppChainGateway

struct AppChainGatewayStorage {
    bool paused;
    mapping(string key => uint256 nonce) keyNonces;
}

Properties

NameTypeDescription
pausedbool
keyNoncesmapping(string key => uint256 nonce)A mapping of keys and their corresponding nonces, to track order of parameter receptions.