ICrossbellGateway

Git Source

This is the interface for the crossbell bridge gateway contract. You'll find all the events and external functions.

Functions

initialize

Initializes the CrossbellGateway.

function initialize(
    address validator,
    address admin,
    address[] calldata crossbellTokens,
    uint256[] calldata chainIds,
    address[] calldata mainchainTokens,
    uint8[] calldata mainchainTokenDecimals
) external;

Parameters

NameTypeDescription
validatoraddressAddress of validator contract.
adminaddressAddress of gateway admin.
crossbellTokensaddress[]Addresses of crossbell tokens.
chainIdsuint256[]The chain IDs of mainchain networks.
mainchainTokensaddress[]Addresses of mainchain tokens.
mainchainTokenDecimalsuint8[]Decimals of mainchain tokens.

pause

Pauses interaction with the gateway contract

function pause() external;

unpause

Resumes interaction with the gateway contract

function unpause() external;

mapTokens

Maps mainchain tokens to Crossbell network.

function mapTokens(
    address[] calldata crossbellTokens,
    uint256[] calldata chainIds,
    address[] calldata mainchainTokens,
    uint8[] calldata mainchainTokenDecimals
) external;

Parameters

NameTypeDescription
crossbellTokensaddress[]Addresses of crossbell tokens.
chainIdsuint256[]The chain IDs of mainchain networks.
mainchainTokensaddress[]Addresses of mainchain tokens.
mainchainTokenDecimalsuint8[]Decimals of mainchain tokens.

batchAckDeposit

Tries bulk deposit.

function batchAckDeposit(
    uint256[] calldata chainIds,
    uint256[] calldata depositIds,
    address[] calldata recipients,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata depositHashes
) external;

batchSubmitWithdrawalSignatures

Tries bulk submit withdrawal signatures. Note that the caller must be a validator.

function batchSubmitWithdrawalSignatures(
    uint256[] calldata chainIds,
    uint256[] calldata withdrawalIds,
    bytes[] calldata sigs
) external;

ackDeposit

Acknowledges a deposit. Note that the caller must be a validator.

function ackDeposit(
    uint256 chainId,
    uint256 depositId,
    address recipient,
    address token,
    uint256 amount,
    bytes32 depositHash
) external;

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
depositIduint256Deposit identifier id.
recipientaddressAddress to receive deposit on crossbell network.
tokenaddressToken address to deposit on crossbell network.
amountuint256Token amount to deposit on crossbell network.
depositHashbytes32Hash of deposit info.

requestWithdrawal

Locks the assets and request withdrawal.

function requestWithdrawal(uint256 chainId, address recipient, address token, uint256 amount, uint256 fee)
    external
    returns (uint256 withdrawalId);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
recipientaddressAddress to receive withdrawal on mainchain network.
tokenaddressToken address to lock from crossbell network.
amountuint256Token amount to lock from crossbell network.
feeuint256Fee amount to pay. This is subtracted from the amount.

Returns

NameTypeDescription
withdrawalIduint256The newly generated withdrawalId.

submitWithdrawalSignature

Submits validator signature for withdrawal. Note that the caller must be a validator.

function submitWithdrawalSignature(uint256 chainId, uint256 withdrawalId, bytes calldata sig) external;

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
withdrawalIduint256WithdrawalId.
sigbytesValidator signature for the withdrawal.

getMainchainToken

Returns mapped token on mainchain.

function getMainchainToken(uint256 chainId, address crossbellToken)
    external
    view
    returns (DataTypes.MappedToken memory token);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
crossbellTokenaddressToken address on crossbell.

Returns

NameTypeDescription
tokenDataTypes.MappedTokenMapped token on mainchain chain.

getValidatorAcknowledgementHash

Returns the acknowledge depositHash by validator.

function getValidatorAcknowledgementHash(uint256 chainId, uint256 id, address validator)
    external
    view
    returns (bytes32);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
iduint256DepositId.
validatoraddressValidator address.

Returns

NameTypeDescription
<none>bytes32bytes32 depositHash if validator has acknowledged, otherwise 0.

getAcknowledgementStatus

Returns the acknowledge status of deposit by validators.

function getAcknowledgementStatus(uint256 chainId, uint256 id, bytes32 hash) external view returns (DataTypes.Status);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
iduint256DepositId.
hashbytes32depositHash.

Returns

NameTypeDescription
<none>DataTypes.StatusDataTypes.Status Acknowledgement status.

getAcknowledgementCount

Returns the acknowledge count of deposit by validators.

function getAcknowledgementCount(uint256 chainId, uint256 id, bytes32 hash) external view returns (uint256);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
iduint256DepositId.
hashbytes32depositHash.

Returns

NameTypeDescription
<none>uint256uint256 Acknowledgement count.

getWithdrawalSignatures

Returns withdrawal signatures.

function getWithdrawalSignatures(uint256 chainId, uint256 withdrawalId)
    external
    view
    returns (address[] memory signers, bytes[] memory sigs);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
withdrawalIduint256Withdrawal Id to query.

Returns

NameTypeDescription
signersaddress[]Signer addresses.
sigsbytes[]Signer signatures.

getValidatorContract

Returns the address of the validator contract.

function getValidatorContract() external view returns (address);

Returns

NameTypeDescription
<none>addressThe validator contract address.

getDepositEntry

Returns the deposit entry.

function getDepositEntry(uint256 chainId, uint256 depositId) external view returns (DataTypes.DepositEntry memory);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
depositIduint256Deposit Id to query.

Returns

NameTypeDescription
<none>DataTypes.DepositEntryDataTypes.DepositEntry Deposit entry.

getWithdrawalCount

Returns the withdrawal count of different mainchain networks.

function getWithdrawalCount(uint256 chainId) external view returns (uint256);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.

Returns

NameTypeDescription
<none>uint256Withdrawal count.

getWithdrawalEntry

Returns the withdrawal entry.

function getWithdrawalEntry(uint256 chainId, uint256 withdrawalId)
    external
    view
    returns (DataTypes.WithdrawalEntry memory);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
withdrawalIduint256Withdrawal Id to query.

Returns

NameTypeDescription
<none>DataTypes.WithdrawalEntryDataTypes.WithdrawalEntry Withdrawal entry.

Events

TokenMapped

Emitted when the tokens are mapped.

event TokenMapped(
    address[] crossbellTokens, uint256[] chainIds, address[] mainchainTokens, uint8[] mainchainTokenDecimals
);

Parameters

NameTypeDescription
crossbellTokensaddress[]Addresses of crossbell tokens.
chainIdsuint256[]The chain IDs of mainchain networks.
mainchainTokensaddress[]Addresses of mainchain tokens.
mainchainTokenDecimalsuint8[]Decimals of mainchain tokens.

Deposited

Emitted when the assets are deposited.

event Deposited(
    uint256 indexed chainId, uint256 indexed depositId, address indexed recipient, address token, uint256 amount
);

Parameters

NameTypeDescription
chainIduint256The chain ID of mainchain network.
depositIduint256Deposit identifier id.
recipientaddressThe address of account to receive the deposit.
tokenaddressThe address of token to deposit.
amountuint256The amount of token to deposit.

AckDeposit

Emitted when the deposit is acknowledged by a validator.

event AckDeposit(
    uint256 indexed chainId,
    uint256 indexed depositId,
    address indexed validator,
    address recipient,
    address token,
    uint256 amount
);

Parameters

NameTypeDescription
chainIduint256The ChainId of mainchain network.
depositIduint256Deposit identifier id.
validatoraddress
recipientaddressThe address of account to receive the deposit.
tokenaddressThe address of token to deposit.
amountuint256The amount of token to deposit.

RequestWithdrawal

Emitted when the withdrawal is requested.

event RequestWithdrawal(
    uint256 indexed chainId,
    uint256 indexed withdrawalId,
    address indexed recipient,
    address token,
    uint256 amount,
    uint256 fee
);

Parameters

NameTypeDescription
chainIduint256The ChainId of mainchain network.
withdrawalIduint256Withdrawal identifier id.
recipientaddressThe address of account to receive the withdrawal.
tokenaddressThe address of token to withdraw on mainchain network.
amountuint256The amount of token to withdraw on mainchain network. Note that validator should use this `amount' for submitting signature.
feeuint256The fee amount to pay for the withdrawal tx sender on mainchain network.

SubmitWithdrawalSignature

Emitted when a withdrawal signature is submitted by validator.

event SubmitWithdrawalSignature(
    uint256 indexed chainId, uint256 indexed withdrawalId, address indexed validator, bytes signature
);

Parameters

NameTypeDescription
chainIduint256The ChainId of mainchain network.
withdrawalIduint256Withdrawal identifier id.
validatoraddressThe address of validator who submitted the signature.
signaturebytesThe submitted signature.