Skip to main content

@morph-l2/sdkDocs


@morph-l2/sdk / StandardBridgeAdapter

Class: StandardBridgeAdapter

Bridge adapter for any token bridge that uses the standard token bridge interface.

Extended by

Implements

Constructors

new StandardBridgeAdapter()

new StandardBridgeAdapter(opts): StandardBridgeAdapter

Creates a StandardBridgeAdapter instance.

Parameters

opts

Options for the adapter.

opts.l1Bridge: AddressLike

L1 bridge contract.

opts.l2Bridge: AddressLike

L2 bridge contract.

opts.messenger: CrossChainMessenger

Provider used to make queries related to cross-chain interactions.

Returns

StandardBridgeAdapter

Source

src/adapters/standard-bridge.ts:52

Properties

estimateGas

estimateGas: object

Object that holds the functions that estimates the gas required for a given transaction. Follows the pattern used by ethers.js.

approve()

approve: (l1Token, l2Token, amount, opts?) => Promise<BigNumber>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<BigNumber>

deposit()

deposit: (l1Token, l2Token, amount, opts?) => Promise<BigNumber>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<BigNumber>

withdraw()

withdraw: (l1Token, l2Token, amount, opts?) => Promise<BigNumber>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<BigNumber>

Implementation of

IBridgeAdapter.estimateGas

Source

src/adapters/standard-bridge.ts:405


l1Bridge

l1Bridge: Contract

L1 bridge contract.

Implementation of

IBridgeAdapter.l1Bridge

Source

src/adapters/standard-bridge.ts:41


l2Bridge

l2Bridge: Contract

L2 bridge contract.

Implementation of

IBridgeAdapter.l2Bridge

Source

src/adapters/standard-bridge.ts:42


messenger

messenger: CrossChainMessenger

Provider used to make queries related to cross-chain interactions.

Implementation of

IBridgeAdapter.messenger

Source

src/adapters/standard-bridge.ts:40


populateTransaction

populateTransaction: object

Object that holds the functions that generate transactions to be signed by the user. Follows the pattern used by ethers.js.

approve()

approve: (l1Token, l2Token, amount, opts?) => Promise<TransactionRequest>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<TransactionRequest>

deposit()

deposit: (l1Token, l2Token, amount, opts?) => Promise<TransactionRequest>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<TransactionRequest>

withdraw()

withdraw: (l1Token, l2Token, amount, opts?) => Promise<TransactionRequest>

Parameters

l1Token: AddressLike

l2Token: AddressLike

amount: NumberLike

opts?: IActionOptions

Returns

Promise<TransactionRequest>

Implementation of

IBridgeAdapter.populateTransaction

Source

src/adapters/standard-bridge.ts:286

Methods

approval()

approval(l1Token, l2Token, opts): Promise<BigNumber>

Queries the account's approval amount for a given L1 token.

Parameters

l1Token: AddressLike

The L1 token address.

l2Token: AddressLike

The L2 token address.

opts: IActionOptions

Additional options.

Returns

Promise<BigNumber>

Amount of tokens approved for deposits from the account.

Implementation of

IBridgeAdapter.approval

Source

src/adapters/standard-bridge.ts:209


approve()

approve(l1Token, l2Token, amount, signer, opts?): Promise<TransactionResponse>

Approves a deposit into the L2 chain.

Parameters

l1Token: AddressLike

The L1 token address.

l2Token: AddressLike

The L2 token address.

amount: NumberLike

Amount of the token to approve.

signer: Signer

Signer used to sign and send the transaction.

opts?: IActionOptions

Additional options.

Returns

Promise<TransactionResponse>

Transaction response for the approval transaction.

Implementation of

IBridgeAdapter.approve

Source

src/adapters/standard-bridge.ts:250


deposit()

deposit(l1Token, l2Token, amount, signer, opts?): Promise<TransactionResponse>

Deposits some tokens into the L2 chain.

Parameters

l1Token: AddressLike

The L1 token address.

l2Token: AddressLike

The L2 token address.

amount: NumberLike

Amount of the token to deposit.

signer: Signer

Signer used to sign and send the transaction.

opts?: IActionOptions

Additional options.

Returns

Promise<TransactionResponse>

Transaction response for the deposit transaction.

Implementation of

IBridgeAdapter.deposit

Source

src/adapters/standard-bridge.ts:262


getDepositsByAddress()

getDepositsByAddress(address, opts?): Promise<TokenBridgeMessage[]>

Gets all deposits for a given address.

Parameters

address: AddressLike

Address to search for messages from.

opts?

Options object.

opts.fromBlock?: BlockTag

opts.toBlock?: BlockTag

Returns

Promise<TokenBridgeMessage[]>

All deposit token bridge messages sent by the given address.

Implementation of

IBridgeAdapter.getDepositsByAddress

Source

src/adapters/standard-bridge.ts:75


getWithdrawalsByAddress()

getWithdrawalsByAddress(address, opts?): Promise<TokenBridgeMessage[]>

Gets all withdrawals for a given address.

Parameters

address: AddressLike

Address to search for messages from.

opts?

Options object.

opts.fromBlock?: BlockTag

opts.toBlock?: BlockTag

Returns

Promise<TokenBridgeMessage[]>

All withdrawal token bridge messages sent by the given address.

Implementation of

IBridgeAdapter.getWithdrawalsByAddress

Source

src/adapters/standard-bridge.ts:122


supportsTokenPair()

supportsTokenPair(l1Token, l2Token): Promise<boolean>

Checks whether the given token pair is supported by the bridge.

Parameters

l1Token: AddressLike

The L1 token address.

l2Token: AddressLike

The L2 token address.

Returns

Promise<boolean>

Whether the given token pair is supported by the bridge.

Implementation of

IBridgeAdapter.supportsTokenPair

Source

src/adapters/standard-bridge.ts:165


withdraw()

withdraw(l1Token, l2Token, amount, signer, opts?): Promise<TransactionResponse>

Withdraws some tokens back to the L1 chain.

Parameters

l1Token: AddressLike

The L1 token address.

l2Token: AddressLike

The L2 token address.

amount: NumberLike

Amount of the token to withdraw.

signer: Signer

Signer used to sign and send the transaction.

opts?: IActionOptions

Additional options.

Returns

Promise<TransactionResponse>

Transaction response for the withdraw transaction.

Implementation of

IBridgeAdapter.withdraw

Source

src/adapters/standard-bridge.ts:274