diff --git a/src/index.ts b/src/index.ts index ef4ee931e..112f038d8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,8 +17,14 @@ 'use strict' export { - Erc20L1L3Bridger, EthL1L3Bridger, + EthL1L3DepositStatus, + EthL1L3DepositRequestParams, + Erc20L1L3Bridger, + Erc20L1L3DepositStatus, + Erc20L1L3DepositRequestParams, + Erc20L1L3DepositRequestRetryableOverrides, + GetL1L3DepositStatusParams, } from './lib/assetBridger/l1l3Bridger' export { EthBridger } from './lib/assetBridger/ethBridger' export { Erc20Bridger } from './lib/assetBridger/erc20Bridger' @@ -30,6 +36,8 @@ export { ChildToParentMessage, ChildToParentMessageWriter, ChildToParentMessageReader, + ChildToParentMessageReaderOrWriter, + ChildToParentTransactionEvent, } from './lib/message/ChildToParentMessage' export { ParentEthDepositTransaction, diff --git a/src/lib/assetBridger/l1l3Bridger.ts b/src/lib/assetBridger/l1l3Bridger.ts index 5173e543a..e488d4961 100644 --- a/src/lib/assetBridger/l1l3Bridger.ts +++ b/src/lib/assetBridger/l1l3Bridger.ts @@ -110,7 +110,7 @@ export type TokenApproveParams = { amount?: BigNumber } -export type Erc20DepositRequestRetryableOverrides = { +export type Erc20L1L3DepositRequestRetryableOverrides = { /** * Optional L1 gas price override. Used to estimate submission fees. */ @@ -141,7 +141,7 @@ export type Erc20DepositRequestRetryableOverrides = { l2l3TokenBridgeRetryableGas?: TeleporterRetryableGasOverride } -export type Erc20DepositRequestParams = { +export type Erc20L1L3DepositRequestParams = { /** * Address of L1 token */ @@ -173,7 +173,7 @@ export type Erc20DepositRequestParams = { /** * Optional overrides for retryable gas parameters */ - retryableOverrides?: Erc20DepositRequestRetryableOverrides + retryableOverrides?: Erc20L1L3DepositRequestRetryableOverrides } export type TxReference = @@ -181,13 +181,13 @@ export type TxReference = | { tx: ParentContractCallTransaction } | { txReceipt: ParentContractCallTransactionReceipt } -export type GetDepositStatusParams = { +export type GetL1L3DepositStatusParams = { l1Provider: Provider l2Provider: Provider l3Provider: Provider } & TxReference -export type Erc20DepositStatus = { +export type Erc20L1L3DepositStatus = { /** * L1 to L2 token bridge message */ @@ -224,7 +224,7 @@ export type Erc20DepositStatus = { completed: boolean } -export type EthDepositRequestParams = { +export type EthL1L3DepositRequestParams = { /** * Amount of ETH to send to L3 */ @@ -255,7 +255,7 @@ export type EthDepositRequestParams = { l3TicketGasOverrides?: Omit } -export type EthDepositStatus = { +export type EthL1L3DepositStatus = { /** * L1 to L2 message */ @@ -730,7 +730,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger { * Also returns the amount of fee tokens required for teleportation. */ public async getDepositRequest( - params: Erc20DepositRequestParams & + params: Erc20L1L3DepositRequestParams & ( | { from: string @@ -810,7 +810,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger { */ public async deposit( params: - | (Erc20DepositRequestParams & { + | (Erc20L1L3DepositRequestParams & { l1Signer: Signer overrides?: PayableOverrides }) @@ -876,8 +876,8 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger { * Can provide either the txHash, the tx, or the txReceipt */ public async getDepositStatus( - params: GetDepositStatusParams - ): Promise { + params: GetL1L3DepositStatusParams + ): Promise { await this._checkL1Network(params.l1Provider) await this._checkL2Network(params.l2Provider) await this._checkL3Network(params.l3Provider) @@ -1196,7 +1196,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger { IL1Teleporter.TeleportParamsStruct, 'gasParams' >, - retryableOverrides: Erc20DepositRequestRetryableOverrides, + retryableOverrides: Erc20L1L3DepositRequestRetryableOverrides, l1Provider: Provider, l2Provider: Provider, l3Provider: Provider @@ -1461,7 +1461,7 @@ export class EthL1L3Bridger extends BaseL1L3Bridger { * Get a tx request to deposit ETH to L3 via a double retryable ticket */ public async getDepositRequest( - params: EthDepositRequestParams & + params: EthL1L3DepositRequestParams & ( | { from: string @@ -1520,7 +1520,7 @@ export class EthL1L3Bridger extends BaseL1L3Bridger { */ public async deposit( params: - | (EthDepositRequestParams & { + | (EthL1L3DepositRequestParams & { l1Signer: Signer overrides?: PayableOverrides }) @@ -1572,11 +1572,11 @@ export class EthL1L3Bridger extends BaseL1L3Bridger { * Get the status of a deposit given an L1 tx receipt. Does not check if the tx is actually a deposit tx. * * @return Information regarding each step of the deposit - * and `EthDepositStatus.completed` which indicates whether the deposit has fully completed. + * and `EthL1L3DepositStatus.completed` which indicates whether the deposit has fully completed. */ public async getDepositStatus( - params: GetDepositStatusParams - ): Promise { + params: GetL1L3DepositStatusParams + ): Promise { await this._checkL1Network(params.l1Provider) await this._checkL2Network(params.l2Provider) await this._checkL3Network(params.l3Provider) diff --git a/tests/integration/l1l3Bridger.test.ts b/tests/integration/l1l3Bridger.test.ts index 84302a0ea..c669eeb8d 100644 --- a/tests/integration/l1l3Bridger.test.ts +++ b/tests/integration/l1l3Bridger.test.ts @@ -19,8 +19,8 @@ import { L1Teleporter__factory } from '../../src/lib/abi/factories/L1Teleporter_ import { fundParentSigner, fundChildSigner, skipIfMainnet } from './testHelpers' import { BigNumber, Signer, Wallet, ethers, providers, utils } from 'ethers' import { - Erc20DepositRequestParams, EthL1L3Bridger, + Erc20L1L3DepositRequestParams, } from '../../src/lib/assetBridger/l1l3Bridger' import { assert, expect } from 'chai' import { isArbitrumNetworkWithCustomFeeToken } from './custom-fee-token/customFeeTokenTestHelpers' @@ -766,7 +766,7 @@ describe('L1 to L3 Bridging', () => { itOnlyWhenCustomGasToken('happy path skip fee token', async () => { const l3Recipient = ethers.utils.hexlify(ethers.utils.randomBytes(20)) - const depositParams: Erc20DepositRequestParams = { + const depositParams: Erc20L1L3DepositRequestParams = { erc20L1Address: l1Token.address, destinationAddress: l3Recipient, amount, @@ -837,7 +837,7 @@ describe('L1 to L3 Bridging', () => { }) async function testHappyPathNonFeeOrStandard( - depositParams: Erc20DepositRequestParams + depositParams: Erc20L1L3DepositRequestParams ) { const depositTxRequest = await l1l3Bridger.getDepositRequest({ ...depositParams, @@ -902,7 +902,7 @@ describe('L1 to L3 Bridging', () => { it('happy path non fee token or standard', async () => { const l3Recipient = ethers.utils.hexlify(ethers.utils.randomBytes(20)) - const depositParams: Erc20DepositRequestParams = { + const depositParams: Erc20L1L3DepositRequestParams = { erc20L1Address: l1Token.address, destinationAddress: l3Recipient, amount, @@ -933,7 +933,7 @@ describe('L1 to L3 Bridging', () => { await weth.approve(l1l3Bridger.teleporter.l1Teleporter, amount) ).wait() - const depositParams: Erc20DepositRequestParams = { + const depositParams: Erc20L1L3DepositRequestParams = { erc20L1Address: l2Network.tokenBridge.parentWeth, destinationAddress: l3Recipient, amount, @@ -951,7 +951,7 @@ describe('L1 to L3 Bridging', () => { l2Signer.provider! ))! - const depositParams: Erc20DepositRequestParams = { + const depositParams: Erc20L1L3DepositRequestParams = { erc20L1Address: l1FeeToken, destinationAddress: l3Recipient, amount: ethers.utils.parseEther('0.1'),