Commit 464f9669 authored by smartcontracts's avatar smartcontracts Committed by GitHub

Merge pull request #2092 from ethereum-optimism/sc/sdk-override-cleanup

fix(sdk): clean up tx override api
parents f8f00eee 05a5be98
...@@ -10,7 +10,6 @@ import { ...@@ -10,7 +10,6 @@ import {
CrossChainMessageRequest, CrossChainMessageRequest,
ICrossChainMessenger, ICrossChainMessenger,
ICrossChainProvider, ICrossChainProvider,
L1ToL2Overrides,
MessageLike, MessageLike,
NumberLike, NumberLike,
MessageDirection, MessageDirection,
...@@ -42,9 +41,12 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -42,9 +41,12 @@ export class CrossChainMessenger implements ICrossChainMessenger {
public async sendMessage( public async sendMessage(
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> { ): Promise<TransactionResponse> {
const tx = await this.populateTransaction.sendMessage(message, overrides) const tx = await this.populateTransaction.sendMessage(message, opts)
if (message.direction === MessageDirection.L1_TO_L2) { if (message.direction === MessageDirection.L1_TO_L2) {
return this.l1Signer.sendTransaction(tx) return this.l1Signer.sendTransaction(tx)
} else { } else {
...@@ -55,46 +57,58 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -55,46 +57,58 @@ export class CrossChainMessenger implements ICrossChainMessenger {
public async resendMessage( public async resendMessage(
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> { ): Promise<TransactionResponse> {
return this.l1Signer.sendTransaction( return this.l1Signer.sendTransaction(
await this.populateTransaction.resendMessage( await this.populateTransaction.resendMessage(
message, message,
messageGasLimit, messageGasLimit,
overrides opts
) )
) )
} }
public async finalizeMessage( public async finalizeMessage(
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> { ): Promise<TransactionResponse> {
throw new Error('Not implemented') throw new Error('Not implemented')
} }
public async depositETH( public async depositETH(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> { ): Promise<TransactionResponse> {
return this.l1Signer.sendTransaction( return this.l1Signer.sendTransaction(
await this.populateTransaction.depositETH(amount, overrides) await this.populateTransaction.depositETH(amount, opts)
) )
} }
public async withdrawETH( public async withdrawETH(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> { ): Promise<TransactionResponse> {
return this.l2Signer.sendTransaction( return this.l2Signer.sendTransaction(
await this.populateTransaction.withdrawETH(amount, overrides) await this.populateTransaction.withdrawETH(amount, opts)
) )
} }
populateTransaction = { populateTransaction = {
sendMessage: async ( sendMessage: async (
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionRequest> => { ): Promise<TransactionRequest> => {
if (message.direction === MessageDirection.L1_TO_L2) { if (message.direction === MessageDirection.L1_TO_L2) {
return this.provider.contracts.l1.L1CrossDomainMessenger.connect( return this.provider.contracts.l1.L1CrossDomainMessenger.connect(
...@@ -102,9 +116,9 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -102,9 +116,9 @@ export class CrossChainMessenger implements ICrossChainMessenger {
).populateTransaction.sendMessage( ).populateTransaction.sendMessage(
message.target, message.target,
message.message, message.message,
overrides?.l2GasLimit || opts?.l2GasLimit ||
(await this.provider.estimateL2MessageGasLimit(message)), (await this.provider.estimateL2MessageGasLimit(message)),
omit(overrides || {}, 'l2GasLimit') omit(opts?.overrides || {}, 'l2GasLimit')
) )
} else { } else {
return this.provider.contracts.l2.L2CrossDomainMessenger.connect( return this.provider.contracts.l2.L2CrossDomainMessenger.connect(
...@@ -113,7 +127,7 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -113,7 +127,7 @@ export class CrossChainMessenger implements ICrossChainMessenger {
message.target, message.target,
message.message, message.message,
0, // Gas limit goes unused when sending from L2 to L1 0, // Gas limit goes unused when sending from L2 to L1
omit(overrides || {}, 'l2GasLimit') omit(opts?.overrides || {}, 'l2GasLimit')
) )
} }
}, },
...@@ -121,7 +135,9 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -121,7 +135,9 @@ export class CrossChainMessenger implements ICrossChainMessenger {
resendMessage: async ( resendMessage: async (
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> => { ): Promise<TransactionRequest> => {
const resolved = await this.provider.toCrossChainMessage(message) const resolved = await this.provider.toCrossChainMessage(message)
if (resolved.direction === MessageDirection.L2_TO_L1) { if (resolved.direction === MessageDirection.L2_TO_L1) {
...@@ -137,26 +153,31 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -137,26 +153,31 @@ export class CrossChainMessenger implements ICrossChainMessenger {
resolved.messageNonce, resolved.messageNonce,
resolved.gasLimit, resolved.gasLimit,
messageGasLimit, messageGasLimit,
overrides || {} opts?.overrides || {}
) )
}, },
finalizeMessage: async ( finalizeMessage: async (
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> => { ): Promise<TransactionRequest> => {
throw new Error('Not implemented') throw new Error('Not implemented')
}, },
depositETH: async ( depositETH: async (
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionRequest> => { ): Promise<TransactionRequest> => {
return this.provider.contracts.l1.L1StandardBridge.populateTransaction.depositETH( return this.provider.contracts.l1.L1StandardBridge.populateTransaction.depositETH(
overrides?.l2GasLimit || 200000, // 200k gas is fine as a default opts?.l2GasLimit || 200000, // 200k gas is fine as a default
'0x', // No data '0x', // No data
{ {
...omit(overrides || {}, 'l2GasLimit', 'value'), ...omit(opts?.overrides || {}, 'l2GasLimit', 'value'),
value: amount, value: amount,
} }
) )
...@@ -164,14 +185,16 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -164,14 +185,16 @@ export class CrossChainMessenger implements ICrossChainMessenger {
withdrawETH: async ( withdrawETH: async (
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> => { ): Promise<TransactionRequest> => {
return this.provider.contracts.l2.L2StandardBridge.populateTransaction.withdraw( return this.provider.contracts.l2.L2StandardBridge.populateTransaction.withdraw(
predeploys.OVM_ETH, predeploys.OVM_ETH,
amount, amount,
0, // No need to supply gas here 0, // No need to supply gas here
'0x', // No data, '0x', // No data,
overrides || {} opts?.overrides || {}
) )
}, },
} }
...@@ -179,9 +202,12 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -179,9 +202,12 @@ export class CrossChainMessenger implements ICrossChainMessenger {
estimateGas = { estimateGas = {
sendMessage: async ( sendMessage: async (
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<BigNumber> => { ): Promise<BigNumber> => {
const tx = await this.populateTransaction.sendMessage(message, overrides) const tx = await this.populateTransaction.sendMessage(message, opts)
if (message.direction === MessageDirection.L1_TO_L2) { if (message.direction === MessageDirection.L1_TO_L2) {
return this.provider.l1Provider.estimateGas(tx) return this.provider.l1Provider.estimateGas(tx)
} else { } else {
...@@ -192,36 +218,45 @@ export class CrossChainMessenger implements ICrossChainMessenger { ...@@ -192,36 +218,45 @@ export class CrossChainMessenger implements ICrossChainMessenger {
resendMessage: async ( resendMessage: async (
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<BigNumber> => { ): Promise<BigNumber> => {
const tx = await this.populateTransaction.resendMessage( const tx = await this.populateTransaction.resendMessage(
message, message,
messageGasLimit, messageGasLimit,
overrides opts
) )
return this.provider.l1Provider.estimateGas(tx) return this.provider.l1Provider.estimateGas(tx)
}, },
finalizeMessage: async ( finalizeMessage: async (
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<BigNumber> => { ): Promise<BigNumber> => {
throw new Error('Not implemented') throw new Error('Not implemented')
}, },
depositETH: async ( depositETH: async (
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<BigNumber> => { ): Promise<BigNumber> => {
const tx = await this.populateTransaction.depositETH(amount, overrides) const tx = await this.populateTransaction.depositETH(amount, opts)
return this.provider.l1Provider.estimateGas(tx) return this.provider.l1Provider.estimateGas(tx)
}, },
withdrawETH: async ( withdrawETH: async (
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<BigNumber> => { ): Promise<BigNumber> => {
const tx = await this.populateTransaction.withdrawETH(amount, overrides) const tx = await this.populateTransaction.withdrawETH(amount, opts)
return this.provider.l2Provider.estimateGas(tx) return this.provider.l2Provider.estimateGas(tx)
}, },
} }
......
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
TransactionResponse, TransactionResponse,
} from '@ethersproject/abstract-provider' } from '@ethersproject/abstract-provider'
import { NumberLike, L1ToL2Overrides } from './types' import { NumberLike } from './types'
import { ICrossChainMessenger } from './cross-chain-messenger' import { ICrossChainMessenger } from './cross-chain-messenger'
/** /**
...@@ -30,24 +30,32 @@ export interface ICrossChainERC20Pair { ...@@ -30,24 +30,32 @@ export interface ICrossChainERC20Pair {
* Deposits some tokens into the L2 chain. * Deposits some tokens into the L2 chain.
* *
* @param amount Amount of the token to deposit. * @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction. * @returns Transaction response for the deposit transaction.
*/ */
deposit( deposit(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
* Withdraws some tokens back to the L1 chain. * Withdraws some tokens back to the L1 chain.
* *
* @param amount Amount of the token to withdraw. * @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction. * @returns Transaction response for the withdraw transaction.
*/ */
withdraw( withdraw(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
...@@ -59,24 +67,32 @@ export interface ICrossChainERC20Pair { ...@@ -59,24 +67,32 @@ export interface ICrossChainERC20Pair {
* Generates a transaction for depositing some tokens into the L2 chain. * Generates a transaction for depositing some tokens into the L2 chain.
* *
* @param amount Amount of the token to deposit. * @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens. * @returns Transaction that can be signed and executed to deposit the tokens.
*/ */
deposit( deposit(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
* Generates a transaction for withdrawing some tokens back to the L1 chain. * Generates a transaction for withdrawing some tokens back to the L1 chain.
* *
* @param amount Amount of the token to withdraw. * @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens. * @returns Transaction that can be signed and executed to withdraw the tokens.
*/ */
withdraw( withdraw(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
} }
...@@ -89,24 +105,32 @@ export interface ICrossChainERC20Pair { ...@@ -89,24 +105,32 @@ export interface ICrossChainERC20Pair {
* Estimates gas required to deposit some tokens into the L2 chain. * Estimates gas required to deposit some tokens into the L2 chain.
* *
* @param amount Amount of the token to deposit. * @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens. * @returns Transaction that can be signed and executed to deposit the tokens.
*/ */
deposit( deposit(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
* Estimates gas required to withdraw some tokens back to the L1 chain. * Estimates gas required to withdraw some tokens back to the L1 chain.
* *
* @param amount Amount of the token to withdraw. * @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens. * @returns Transaction that can be signed and executed to withdraw the tokens.
*/ */
withdraw( withdraw(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
} }
} }
...@@ -4,12 +4,7 @@ import { ...@@ -4,12 +4,7 @@ import {
TransactionResponse, TransactionResponse,
} from '@ethersproject/abstract-provider' } from '@ethersproject/abstract-provider'
import { import { MessageLike, NumberLike, CrossChainMessageRequest } from './types'
MessageLike,
NumberLike,
CrossChainMessageRequest,
L1ToL2Overrides,
} from './types'
import { ICrossChainProvider } from './cross-chain-provider' import { ICrossChainProvider } from './cross-chain-provider'
/** /**
...@@ -36,12 +31,17 @@ export interface ICrossChainMessenger { ...@@ -36,12 +31,17 @@ export interface ICrossChainMessenger {
* to the message itself. * to the message itself.
* *
* @param message Cross chain message to send. * @param message Cross chain message to send.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the message sending transaction. * @returns Transaction response for the message sending transaction.
*/ */
sendMessage( sendMessage(
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
...@@ -50,13 +50,16 @@ export interface ICrossChainMessenger { ...@@ -50,13 +50,16 @@ export interface ICrossChainMessenger {
* *
* @param message Cross chain message to resend. * @param message Cross chain message to resend.
* @param messageGasLimit New gas limit to use for the message. * @param messageGasLimit New gas limit to use for the message.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the message resending transaction. * @returns Transaction response for the message resending transaction.
*/ */
resendMessage( resendMessage(
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
...@@ -64,36 +67,47 @@ export interface ICrossChainMessenger { ...@@ -64,36 +67,47 @@ export interface ICrossChainMessenger {
* messages. Will throw an error if the message has not completed its challenge period yet. * messages. Will throw an error if the message has not completed its challenge period yet.
* *
* @param message Message to finalize. * @param message Message to finalize.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the finalization transaction. * @returns Transaction response for the finalization transaction.
*/ */
finalizeMessage( finalizeMessage(
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
* Deposits some ETH into the L2 chain. * Deposits some ETH into the L2 chain.
* *
* @param amount Amount of ETH to deposit (in wei). * @param amount Amount of ETH to deposit (in wei).
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction. * @returns Transaction response for the deposit transaction.
*/ */
depositETH( depositETH(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
* Withdraws some ETH back to the L1 chain. * Withdraws some ETH back to the L1 chain.
* *
* @param amount Amount of ETH to withdraw. * @param amount Amount of ETH to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction. * @returns Transaction response for the withdraw transaction.
*/ */
withdrawETH( withdrawETH(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/** /**
...@@ -106,12 +120,17 @@ export interface ICrossChainMessenger { ...@@ -106,12 +120,17 @@ export interface ICrossChainMessenger {
* and executed by a signer. * and executed by a signer.
* *
* @param message Cross chain message to send. * @param message Cross chain message to send.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to send the message. * @returns Transaction that can be signed and executed to send the message.
*/ */
sendMessage: ( sendMessage: (
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
) => Promise<TransactionRequest> ) => Promise<TransactionRequest>
/** /**
...@@ -120,13 +139,16 @@ export interface ICrossChainMessenger { ...@@ -120,13 +139,16 @@ export interface ICrossChainMessenger {
* *
* @param message Cross chain message to resend. * @param message Cross chain message to resend.
* @param messageGasLimit New gas limit to use for the message. * @param messageGasLimit New gas limit to use for the message.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to resend the message. * @returns Transaction that can be signed and executed to resend the message.
*/ */
resendMessage( resendMessage(
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/** /**
...@@ -135,36 +157,47 @@ export interface ICrossChainMessenger { ...@@ -135,36 +157,47 @@ export interface ICrossChainMessenger {
* its challenge period yet. * its challenge period yet.
* *
* @param message Message to generate the finalization transaction for. * @param message Message to generate the finalization transaction for.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to finalize the message. * @returns Transaction that can be signed and executed to finalize the message.
*/ */
finalizeMessage( finalizeMessage(
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/** /**
* Generates a transaction for depositing some ETH into the L2 chain. * Generates a transaction for depositing some ETH into the L2 chain.
* *
* @param amount Amount of ETH to deposit. * @param amount Amount of ETH to deposit.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the ETH. * @returns Transaction that can be signed and executed to deposit the ETH.
*/ */
depositETH( depositETH(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/** /**
* Generates a transaction for withdrawing some ETH back to the L1 chain. * Generates a transaction for withdrawing some ETH back to the L1 chain.
* *
* @param amount Amount of ETH to withdraw. * @param amount Amount of ETH to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens. * @returns Transaction that can be signed and executed to withdraw the tokens.
*/ */
withdrawETH( withdrawETH(
amount: NumberLike, amount: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<TransactionRequest> ): Promise<TransactionRequest>
} }
...@@ -177,12 +210,17 @@ export interface ICrossChainMessenger { ...@@ -177,12 +210,17 @@ export interface ICrossChainMessenger {
* Estimates gas required to send a cross chain message. * Estimates gas required to send a cross chain message.
* *
* @param message Cross chain message to send. * @param message Cross chain message to send.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to send the message. * @returns Transaction that can be signed and executed to send the message.
*/ */
sendMessage: ( sendMessage: (
message: CrossChainMessageRequest, message: CrossChainMessageRequest,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
) => Promise<BigNumber> ) => Promise<BigNumber>
/** /**
...@@ -190,46 +228,63 @@ export interface ICrossChainMessenger { ...@@ -190,46 +228,63 @@ export interface ICrossChainMessenger {
* *
* @param message Cross chain message to resend. * @param message Cross chain message to resend.
* @param messageGasLimit New gas limit to use for the message. * @param messageGasLimit New gas limit to use for the message.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to resend the message. * @returns Transaction that can be signed and executed to resend the message.
*/ */
resendMessage( resendMessage(
message: MessageLike, message: MessageLike,
messageGasLimit: NumberLike, messageGasLimit: NumberLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<BigNumber> ): Promise<BigNumber>
/** /**
* Estimates gas required to finalize a cross chain message. Only applies to L2 to L1 messages. * Estimates gas required to finalize a cross chain message. Only applies to L2 to L1 messages.
* *
* @param message Message to generate the finalization transaction for. * @param message Message to generate the finalization transaction for.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to finalize the message. * @returns Transaction that can be signed and executed to finalize the message.
*/ */
finalizeMessage( finalizeMessage(
message: MessageLike, message: MessageLike,
overrides?: Overrides opts?: {
overrides?: Overrides
}
): Promise<BigNumber> ): Promise<BigNumber>
/** /**
* Estimates gas required to deposit some ETH into the L2 chain. * Estimates gas required to deposit some ETH into the L2 chain.
* *
* @param amount Amount of ETH to deposit. * @param amount Amount of ETH to deposit.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.l2GasLimit Optional gas limit to use for the transaction on L2.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the ETH. * @returns Transaction that can be signed and executed to deposit the ETH.
*/ */
depositETH( depositETH(
amount: NumberLike, amount: NumberLike,
overrides?: L1ToL2Overrides opts?: {
l2GasLimit?: NumberLike
overrides?: Overrides
}
): Promise<BigNumber> ): Promise<BigNumber>
/** /**
* Estimates gas required to withdraw some ETH back to the L1 chain. * Estimates gas required to withdraw some ETH back to the L1 chain.
* *
* @param amount Amount of ETH to withdraw. * @param amount Amount of ETH to withdraw.
* @param overrides Optional transaction overrides. * @param opts Additional options.
* @param opts.overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens. * @returns Transaction that can be signed and executed to withdraw the tokens.
*/ */
withdrawETH(amount: NumberLike, overrides?: Overrides): Promise<BigNumber> withdrawETH(
amount: NumberLike,
opts?: {
overrides?: Overrides
}
): Promise<BigNumber>
} }
} }
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
TransactionResponse, TransactionResponse,
} from '@ethersproject/abstract-provider' } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer' import { Signer } from '@ethersproject/abstract-signer'
import { Contract, BigNumber, Overrides } from 'ethers' import { Contract, BigNumber } from 'ethers'
/** /**
* L1 contract references. * L1 contract references.
...@@ -229,15 +229,6 @@ export interface StateRootBatch { ...@@ -229,15 +229,6 @@ export interface StateRootBatch {
stateRoots: string[] stateRoots: string[]
} }
/**
* Extended Ethers overrides object with an l2GasLimit field.
* Only meant to be used for L1 to L2 messages, since L2 to L1 messages don't have a specified gas
* limit field (gas used depends on the amount of gas provided).
*/
export type L1ToL2Overrides = Overrides & {
l2GasLimit?: NumberLike
}
/** /**
* Stuff that can be coerced into a transaction. * Stuff that can be coerced into a transaction.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment