Skip to content

Commit

Permalink
feat: rename and export L1-L3 utils (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Jul 10, 2024
1 parent 210ac84 commit 49ed39c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -30,6 +36,8 @@ export {
ChildToParentMessage,
ChildToParentMessageWriter,
ChildToParentMessageReader,
ChildToParentMessageReaderOrWriter,
ChildToParentTransactionEvent,
} from './lib/message/ChildToParentMessage'
export {
ParentEthDepositTransaction,
Expand Down
34 changes: 17 additions & 17 deletions src/lib/assetBridger/l1l3Bridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -141,7 +141,7 @@ export type Erc20DepositRequestRetryableOverrides = {
l2l3TokenBridgeRetryableGas?: TeleporterRetryableGasOverride
}

export type Erc20DepositRequestParams = {
export type Erc20L1L3DepositRequestParams = {
/**
* Address of L1 token
*/
Expand Down Expand Up @@ -173,21 +173,21 @@ export type Erc20DepositRequestParams = {
/**
* Optional overrides for retryable gas parameters
*/
retryableOverrides?: Erc20DepositRequestRetryableOverrides
retryableOverrides?: Erc20L1L3DepositRequestRetryableOverrides
}

export type TxReference =
| { txHash: string }
| { 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
*/
Expand Down Expand Up @@ -224,7 +224,7 @@ export type Erc20DepositStatus = {
completed: boolean
}

export type EthDepositRequestParams = {
export type EthL1L3DepositRequestParams = {
/**
* Amount of ETH to send to L3
*/
Expand Down Expand Up @@ -255,7 +255,7 @@ export type EthDepositRequestParams = {
l3TicketGasOverrides?: Omit<GasOverrides, 'deposit'>
}

export type EthDepositStatus = {
export type EthL1L3DepositStatus = {
/**
* L1 to L2 message
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -810,7 +810,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger {
*/
public async deposit(
params:
| (Erc20DepositRequestParams & {
| (Erc20L1L3DepositRequestParams & {
l1Signer: Signer
overrides?: PayableOverrides
})
Expand Down Expand Up @@ -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<Erc20DepositStatus> {
params: GetL1L3DepositStatusParams
): Promise<Erc20L1L3DepositStatus> {
await this._checkL1Network(params.l1Provider)
await this._checkL2Network(params.l2Provider)
await this._checkL3Network(params.l3Provider)
Expand Down Expand Up @@ -1196,7 +1196,7 @@ export class Erc20L1L3Bridger extends BaseL1L3Bridger {
IL1Teleporter.TeleportParamsStruct,
'gasParams'
>,
retryableOverrides: Erc20DepositRequestRetryableOverrides,
retryableOverrides: Erc20L1L3DepositRequestRetryableOverrides,
l1Provider: Provider,
l2Provider: Provider,
l3Provider: Provider
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1520,7 +1520,7 @@ export class EthL1L3Bridger extends BaseL1L3Bridger {
*/
public async deposit(
params:
| (EthDepositRequestParams & {
| (EthL1L3DepositRequestParams & {
l1Signer: Signer
overrides?: PayableOverrides
})
Expand Down Expand Up @@ -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<EthDepositStatus> {
params: GetL1L3DepositStatusParams
): Promise<EthL1L3DepositStatus> {
await this._checkL1Network(params.l1Provider)
await this._checkL2Network(params.l2Provider)
await this._checkL3Network(params.l3Provider)
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/l1l3Bridger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -837,7 +837,7 @@ describe('L1 to L3 Bridging', () => {
})

async function testHappyPathNonFeeOrStandard(
depositParams: Erc20DepositRequestParams
depositParams: Erc20L1L3DepositRequestParams
) {
const depositTxRequest = await l1l3Bridger.getDepositRequest({
...depositParams,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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'),
Expand Down

0 comments on commit 49ed39c

Please sign in to comment.