Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update l1/2 name for dataEntities #340

Merged
merged 13 commits into from
Nov 2, 2023
6 changes: 2 additions & 4 deletions scripts/instantiate_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ export const instantiateBridge = (
}

const l2Network = l2Networks[l2NetworkID]
const l1Network = l1Networks[l2Network.partnerChainID]
const l1Network = l1Networks[l2Network.parentChainId]

if (!l1Network) {
throw new Error(
`Unrecognised partner chain id: ${l2Network.partnerChainID}`
)
throw new Error(`Unrecognised parent chain id: ${l2Network.parentChainId}`)
}

const l1Rpc = (() => {
Expand Down
20 changes: 10 additions & 10 deletions scripts/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { Wallet } from '@ethersproject/wallet'
import dotenv from 'dotenv'
import { EthBridger, InboxTools, Erc20Bridger } from '../src'
import {
L1Network,
L2Network,
getL1Network,
getL2Network,
ParentChain as L1Network,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the usages of the neworks in the imported files be renamed in a separate pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ser

ChildChain as L2Network,
getParentChain as getL1Network,
getChildChain as getL2Network,
addCustomNetwork,
} from '../src/lib/dataEntities/networks'
import { Signer } from 'ethers'
Expand Down Expand Up @@ -104,7 +104,7 @@ export const getCustomNetworks = async (
explorerUrl: '',
isCustom: true,
name: 'EthLocal',
partnerChainIDs: [l2NetworkInfo.chainId],
childChainIds: [l2NetworkInfo.chainId],
isArbitrum: false,
}

Expand All @@ -122,7 +122,7 @@ export const getCustomNetworks = async (
isArbitrum: true,
isCustom: true,
name: 'ArbLocal',
partnerChainID: l1NetworkInfo.chainId,
parentChainId: l1NetworkInfo.chainId,
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
nitroGenesisBlock: 0,
nitroGenesisL1Block: 0,
Expand Down Expand Up @@ -171,8 +171,8 @@ export const setupNetworks = async (
}

addCustomNetwork({
customL1Network: l1Network,
customL2Network: l2Network,
customParentChain: l1Network,
customChildChain: l2Network,
})

// also register the weth gateway
Expand Down Expand Up @@ -244,8 +244,8 @@ export const testSetup = async (): Promise<{
l2Network: L2Network
}
addCustomNetwork({
customL1Network: l1Network,
customL2Network: l2Network,
customParentChain: l1Network,
customChildChain: l2Network,
})
setL1Network = l1Network
setL2Network = l2Network
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export { L1ToL2MessageGasEstimator } from './lib/message/L1ToL2MessageGasEstimat
export { argSerializerConstructor } from './lib/utils/byte_serialize_params'
export { CallInput, MultiCaller } from './lib/utils/multicall'
export {
L1Networks,
L2Networks,
L1Network,
L2Network,
getL1Network,
getL2Network,
ParentChains as L1Networks,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also export these parent/child versions? Will we get rid of the old L1Network variant and bump a major?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the import/export aliases that are used during this renaming process will eventually be removed.

We're using them to reduce the number of changes in each PR.

These changes are targeting a major bump release.

Copy link
Contributor Author

@douglance douglance Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will also be a big file renaming PR at the end.

ChildChains as L2Networks,
ParentChain as L1Network,
ChildChain as L2Network,
getParentChain as getL1Network,
getChildChain as getL2Network,
addCustomNetwork,
addDefaultLocalNetwork,
} from './lib/dataEntities/networks'
Expand Down
10 changes: 7 additions & 3 deletions src/lib/assetBridger/assetBridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { ArbSdkError } from '../dataEntities/errors'
import { L1ContractTransaction } from '../message/L1Transaction'
import { L2ContractTransaction } from '../message/L2Transaction'

import { l1Networks, L1Network, L2Network } from '../dataEntities/networks'
import {
parentChains as l1Networks,
ParentChain as L1Network,
ChildChain as L2Network,
} from '../dataEntities/networks'
import {
SignerOrProvider,
SignerProviderUtils,
Expand All @@ -33,10 +37,10 @@ export abstract class AssetBridger<DepositParams, WithdrawParams> {
public readonly l1Network: L1Network

public constructor(public readonly l2Network: L2Network) {
this.l1Network = l1Networks[l2Network.partnerChainID]
this.l1Network = l1Networks[l2Network.parentChainId]
if (!this.l1Network) {
throw new ArbSdkError(
`Unknown l1 network chain id: ${l2Network.partnerChainID}`
`Unknown l1 network chain id: ${l2Network.parentChainId}`
)
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/assetBridger/erc20Bridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ import {
L1ToL2MessageGasEstimator,
} from '../message/L1ToL2MessageGasEstimator'
import { SignerProviderUtils } from '../dataEntities/signerOrProvider'
import { L2Network, getL2Network } from '../dataEntities/networks'
import {
ChildChain as L2Network,
getChildChain as getL2Network,
} from '../dataEntities/networks'
import { ArbSdkError, MissingProviderArbSdkError } from '../dataEntities/errors'
import { DISABLED_GATEWAY } from '../dataEntities/constants'
import { EventFetcher } from '../utils/eventFetcher'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/assetBridger/ethBridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
import { OmitTyped } from '../utils/types'
import { SignerProviderUtils } from '../dataEntities/signerOrProvider'
import { MissingProviderArbSdkError } from '../dataEntities/errors'
import { getL2Network } from '../dataEntities/networks'
import { getChildChain as getL2Network } from '../dataEntities/networks'

export interface EthWithdrawParams {
/**
Expand Down
Loading