Skip to main content

Bridge

Bridge#

Functions#

constructor(uint8 chainID, address[] initialRelayers, uint256 initialRelayerThreshold, uint256 fee, uint256 expiry) (public)

Initializes Bridge, creates and grants {msg.sender} the admin role, creates and grants {initialRelayers} the relayer role. @param chainID ID of chain the Bridge contract exists on. @param initialRelayers Addresses that should be initially granted the relayer role. @param initialRelayerThreshold Number of votes needed for a deposit proposal to be considered passed.

isRelayer(address relayer) โ†’ bool (external)

Returns true if {relayer} has the relayer role. @param relayer Address to check.

renounceAdmin(address newAdmin) (external)

Removes admin role from {msg.sender} and grants it to {newAdmin}. @notice Only callable by an address that currently has the admin role. @param newAdmin Address that admin role will be granted to.

adminPauseTransfers() (external)

Pauses deposits, proposal creation and voting, and deposit executions. @notice Only callable by an address that currently has the admin role.

adminUnpauseTransfers() (external)

Unpauses deposits, proposal creation and voting, and deposit executions. @notice Only callable by an address that currently has the admin role.

adminChangeRelayerThreshold(uint256 newThreshold) (external)

Modifies the number of votes required for a proposal to be considered passed. @notice Only callable by an address that currently has the admin role. @param newThreshold Value {_relayerThreshold} will be changed to. @notice Emits {RelayerThresholdChanged} event.

adminAddRelayer(address relayerAddress) (external)

Grants {relayerAddress} the relayer role and increases {_totalRelayer} count. @notice Only callable by an address that currently has the admin role. @param relayerAddress Address of relayer to be added. @notice Emits {RelayerAdded} event.

adminRemoveRelayer(address relayerAddress) (external)

Removes relayer role for {relayerAddress} and decreases {_totalRelayer} count. @notice Only callable by an address that currently has the admin role. @param relayerAddress Address of relayer to be removed. @notice Emits {RelayerRemoved} event.

adminSetResource(address handlerAddress, bytes32 resourceID, address tokenAddress) (external)

Sets a new resource for handler contracts that use the IERCHandler interface, and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}. @notice Only callable by an address that currently has the admin role. @param handlerAddress Address of handler resource will be set for. @param resourceID ResourceID to be used when making deposits. @param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.

adminSetGenericResource(address handlerAddress, bytes32 resourceID, address contractAddress, bytes4 depositFunctionSig, bytes4 executeFunctionSig) (external)

Sets a new resource for handler contracts that use the IGenericHandler interface, and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}. @notice Only callable by an address that currently has the admin role. @param handlerAddress Address of handler resource will be set for. @param resourceID ResourceID to be used when making deposits. @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.

adminSetBurnable(address handlerAddress, address tokenAddress) (external)

Sets a resource as burnable for handler contracts that use the IERCHandler interface. @notice Only callable by an address that currently has the admin role. @param handlerAddress Address of handler resource will be set for. @param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.

getProposal(uint8 originChainID, uint64 depositNonce, bytes32 dataHash) โ†’ struct Bridge.Proposal (external)

Returns a proposal. @param originChainID Chain ID deposit originated from. @param depositNonce ID of proposal generated by proposal's origin Bridge contract. @param dataHash Hash of data to be provided when deposit proposal is executed. @return Proposal which consists of:

    - _dataHash Hash of data to be provided when deposit proposal is executed.    - _yesVotes Number of votes in favor of proposal.    - _noVotes Number of votes against proposal.    - _status Current status of proposal.
adminChangeFee(uint256 newFee) (external)

Changes deposit fee. @notice Only callable by admin. @param newFee Value {_fee} will be updated to.

adminWithdraw(address handlerAddress, address tokenAddress, address recipient, uint256 amountOrTokenID) (external)

Used to manually withdraw funds from ERC safes. @param handlerAddress Address of handler to withdraw from. @param tokenAddress Address of token to withdraw. @param recipient Address to withdraw tokens to. @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to withdraw.

deposit(uint8 destinationChainID, bytes32 resourceID, bytes data) (external)

Initiates a transfer using a specified handler contract. @notice Only callable when Bridge is not paused. @param destinationChainID ID of chain deposit will be bridged to. @param resourceID ResourceID used to find address of handler to be used for deposit. @param data Additional data to be passed to specified handler. @notice Emits {Deposit} event.

voteProposal(uint8 chainID, uint64 depositNonce, bytes32 resourceID, bytes32 dataHash) (external)

When called, {msg.sender} will be marked as voting in favor of proposal. @notice Only callable by relayers when Bridge is not paused. @param chainID ID of chain deposit originated from. @param depositNonce ID of deposited generated by origin Bridge contract. @param dataHash Hash of data provided when deposit was made. @notice Proposal must not have already been passed or executed. @notice {msg.sender} must not have already voted on proposal. @notice Emits {ProposalEvent} event with status indicating the proposal status. @notice Emits {ProposalVote} event.

cancelProposal(uint8 chainID, uint64 depositNonce, bytes32 dataHash) (public)

Executes a deposit proposal that is considered passed using a specified handler contract. @notice Only callable by relayers when Bridge is not paused. @param chainID ID of chain deposit originated from. @param depositNonce ID of deposited generated by origin Bridge contract. @param dataHash Hash of data originally provided when deposit was made. @notice Proposal must be past expiry threshold. @notice Emits {ProposalEvent} event with status {Cancelled}.

executeProposal(uint8 chainID, uint64 depositNonce, bytes data, bytes32 resourceID) (external)

Executes a deposit proposal that is considered passed using a specified handler contract. @notice Only callable by relayers when Bridge is not paused. @param chainID ID of chain deposit originated from. @param resourceID ResourceID to be used when making deposits. @param depositNonce ID of deposited generated by origin Bridge contract. @param data Data originally provided when deposit was made. @notice Proposal must have Passed status. @notice Hash of {data} must equal proposal's {dataHash}. @notice Emits {ProposalEvent} event with status {Executed}.

transferFunds(address payable[] addrs, uint256[] amounts) (external)

Transfers eth in the contract to the specified addresses. The parameters addrs and amounts are mapped 1-1. This means that the address at index 0 for addrs will receive the amount (in WEI) from amounts at index 0. @param addrs Array of addresses to transfer {amounts} to. @param amounts Array of amonuts to transfer to {addrs}.

supportsInterface(bytes4 interfaceId) โ†’ bool (public)

See {IERC165-supportsInterface}.

hasRole(bytes32 role, address account) โ†’ bool (public)

Returns true if account has been granted role.

_checkRole(bytes32 role, address account) (internal)

Revert with a standard message if account is missing role. The format of the revert reason is given by the following regular expression: /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/

getRoleAdmin(bytes32 role) โ†’ bytes32 (public)

Returns the admin role that controls role. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.

grantRole(bytes32 role, address account) (public)

Grants role to account. If account had not been already granted role, emits a {RoleGranted} event. Requirements:

  • the caller must have role's admin role.
revokeRole(bytes32 role, address account) (public)

Revokes role from account. If account had been granted role, emits a {RoleRevoked} event. Requirements:

  • the caller must have role's admin role.
renounceRole(bytes32 role, address account) (public)

Revokes role from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted role, emits a {RoleRevoked} event. Requirements:

  • the caller must be account.
_setupRole(bytes32 role, address account) (internal)

Grants role to account. If account had not been already granted role, emits a {RoleGranted} event. Note that unlike {grantRole}, this function doesn't perform any checks on the calling account.

[WARNING]

This function should only be called from the constructor when setting up the initial roles for the system. Using this function in any other way is effectively circumventing the admin

system imposed by {AccessControl}.

_setRoleAdmin(bytes32 role, bytes32 adminRole) (internal)

Sets adminRole as role's admin role. Emits a {RoleAdminChanged} event.

paused() โ†’ bool (public)

Returns true if the contract is paused, and false otherwise.

_pause() (internal)

Triggers stopped state. Requirements:

  • The contract must not be paused.
_unpause() (internal)

Returns to normal state. Requirements:

  • The contract must be paused.
_msgSender() โ†’ address (internal)
_msgData() โ†’ bytes (internal)

Events#

RelayerThresholdChanged(uint256 newThreshold)
RelayerAdded(address relayer)
RelayerRemoved(address relayer)
Deposit(uint8 destinationChainID, bytes32 resourceID, uint64 depositNonce)
ProposalEvent(uint8 originChainID, uint64 depositNonce, enum Bridge.ProposalStatus status, bytes32 resourceID, bytes32 dataHash)
ProposalVote(uint8 originChainID, uint64 depositNonce, enum Bridge.ProposalStatus status, bytes32 resourceID)
RoleAdminChanged(bytes32 role, bytes32 previousAdminRole, bytes32 newAdminRole)

Emitted when newAdminRole is set as role's admin role, replacing previousAdminRole DEFAULT_ADMIN_ROLE is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this. Available since v3.1.

RoleGranted(bytes32 role, address account, address sender)

Emitted when account is granted role. sender is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.

RoleRevoked(bytes32 role, address account, address sender)

Emitted when account is revoked role. sender is the account that originated the contract call:

  • if using revokeRole, it is the admin role bearer
  • if using renounceRole, it is the role bearer (i.e. account)
Paused(address account)

Emitted when the pause is triggered by account.

Unpaused(address account)

Emitted when the pause is lifted by account.

Modifiers#

onlyAdmin()
onlyAdminOrRelayer()
onlyRelayers()
onlyRole(bytes32 role)

Modifier that checks that an account has a specific role. Reverts with a standardized message including the required role. The format of the revert reason is given by the following regular expression: /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ Available since v4.1.

whenNotPaused()

Modifier to make a function callable only when the contract is not paused. Requirements:

  • The contract must not be paused.
whenPaused()

Modifier to make a function callable only when the contract is paused. Requirements:

  • The contract must be paused.