From 09a6eb0ae4e717212f3b60b85b8292fbcd5c2b8a Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 2 Nov 2023 11:44:00 -0400 Subject: [PATCH] chore: update l1/2 name for dataEntities (#340) * chore: renames L1/2 to parentChain/chain in inbox * update to use new childChain name with ArbitrumChain type * updates name of methods on inbox to use childChain * Update childChainTransactionRequest * remove `network` * update names with from pr feedback * chore: update l1/2 name for dataEntities * removes network * fix child renaming * fix getChildChain * fix integration test * renames partner to parent/child --- scripts/instantiate_bridge.ts | 6 +- scripts/testSetup.ts | 20 +-- src/index.ts | 12 +- src/lib/assetBridger/assetBridger.ts | 10 +- src/lib/assetBridger/erc20Bridger.ts | 5 +- src/lib/assetBridger/ethBridger.ts | 2 +- src/lib/dataEntities/networks.ts | 123 ++++++++++--------- src/lib/inbox/inbox.ts | 9 +- src/lib/message/L1ToL2Message.ts | 2 +- src/lib/message/L1ToL2MessageCreator.ts | 2 +- src/lib/message/L1ToL2MessageGasEstimator.ts | 2 +- src/lib/message/L1Transaction.ts | 2 +- src/lib/message/L2ToL1Message.ts | 2 +- src/lib/message/L2ToL1MessageClassic.ts | 2 +- src/lib/message/L2ToL1MessageNitro.ts | 2 +- src/lib/utils/lib.ts | 4 +- src/lib/utils/multicall.ts | 14 +-- tests/fork/inbox.test.ts | 5 +- tests/integration/ethBridgeAddresses.test.ts | 2 +- tests/integration/sendL2msg.test.ts | 5 +- tests/integration/testHelpers.ts | 2 +- tests/unit/l2toL1MessageEvents.test.ts | 2 +- tests/unit/multicall.test.ts | 2 +- 23 files changed, 124 insertions(+), 113 deletions(-) diff --git a/scripts/instantiate_bridge.ts b/scripts/instantiate_bridge.ts index 7d5887ef61..1c8b91ecf4 100644 --- a/scripts/instantiate_bridge.ts +++ b/scripts/instantiate_bridge.ts @@ -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 = (() => { diff --git a/scripts/testSetup.ts b/scripts/testSetup.ts index 5558054297..e53b06d0c4 100644 --- a/scripts/testSetup.ts +++ b/scripts/testSetup.ts @@ -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, + ChildChain as L2Network, + getParentChain as getL1Network, + getChildChain as getL2Network, addCustomNetwork, } from '../src/lib/dataEntities/networks' import { Signer } from 'ethers' @@ -104,7 +104,7 @@ export const getCustomNetworks = async ( explorerUrl: '', isCustom: true, name: 'EthLocal', - partnerChainIDs: [l2NetworkInfo.chainId], + childChainIds: [l2NetworkInfo.chainId], isArbitrum: false, } @@ -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, @@ -171,8 +171,8 @@ export const setupNetworks = async ( } addCustomNetwork({ - customL1Network: l1Network, - customL2Network: l2Network, + customParentChain: l1Network, + customChildChain: l2Network, }) // also register the weth gateway @@ -244,8 +244,8 @@ export const testSetup = async (): Promise<{ l2Network: L2Network } addCustomNetwork({ - customL1Network: l1Network, - customL2Network: l2Network, + customParentChain: l1Network, + customChildChain: l2Network, }) setL1Network = l1Network setL2Network = l2Network diff --git a/src/index.ts b/src/index.ts index 99056afc27..5b5ec58fad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, + ChildChains as L2Networks, + ParentChain as L1Network, + ChildChain as L2Network, + getParentChain as getL1Network, + getChildChain as getL2Network, addCustomNetwork, addDefaultLocalNetwork, } from './lib/dataEntities/networks' diff --git a/src/lib/assetBridger/assetBridger.ts b/src/lib/assetBridger/assetBridger.ts index ea3f72162b..6895b8ecb3 100644 --- a/src/lib/assetBridger/assetBridger.ts +++ b/src/lib/assetBridger/assetBridger.ts @@ -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, @@ -33,10 +37,10 @@ export abstract class AssetBridger { 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}` ) } } diff --git a/src/lib/assetBridger/erc20Bridger.ts b/src/lib/assetBridger/erc20Bridger.ts index d4883ac22f..1504a03420 100644 --- a/src/lib/assetBridger/erc20Bridger.ts +++ b/src/lib/assetBridger/erc20Bridger.ts @@ -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' diff --git a/src/lib/assetBridger/ethBridger.ts b/src/lib/assetBridger/ethBridger.ts index 4441f3d7f6..204b22fee4 100644 --- a/src/lib/assetBridger/ethBridger.ts +++ b/src/lib/assetBridger/ethBridger.ts @@ -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 { /** diff --git a/src/lib/dataEntities/networks.ts b/src/lib/dataEntities/networks.ts index 8199dae1b8..ce0bb72f41 100644 --- a/src/lib/dataEntities/networks.ts +++ b/src/lib/dataEntities/networks.ts @@ -21,16 +21,16 @@ import { ArbSdkError } from '../dataEntities/errors' import { SEVEN_DAYS_IN_SECONDS } from './constants' import { RollupAdminLogic__factory } from '../abi/factories/RollupAdminLogic__factory' -export interface L1Network extends Network { - partnerChainIDs: number[] +export interface ParentChain extends Network { + childChainIds: number[] blockTime: number //seconds isArbitrum: false } -export interface L2Network extends Network { +export interface ChildChain extends Network { tokenBridge: TokenBridge ethBridge: EthBridge - partnerChainID: number + parentChainId: number isArbitrum: true confirmPeriodBlocks: number retryableLifetimeSeconds: number @@ -77,12 +77,12 @@ export interface EthBridge { } } -export interface L1Networks { - [id: string]: L1Network +export interface ParentChains { + [id: string]: ParentChain } -export interface L2Networks { - [id: string]: L2Network +export interface ChildChains { + [id: string]: ChildChain } const mainnetTokenBridge: TokenBridge = { @@ -114,12 +114,12 @@ const mainnetETHBridge: EthBridge = { }, } -export const l1Networks: L1Networks = { +export const parentChains: ParentChains = { 1: { chainID: 1, name: 'Mainnet', explorerUrl: 'https://etherscan.io', - partnerChainIDs: [42161, 42170], + childChainIds: [42161, 42170], blockTime: 14, isCustom: false, isArbitrum: false, @@ -128,7 +128,7 @@ export const l1Networks: L1Networks = { chainID: 1338, name: 'Hardhat_Mainnet_Fork', explorerUrl: 'https://etherscan.io', - partnerChainIDs: [42161], + childChainIds: [42161], blockTime: 1, isCustom: false, isArbitrum: false, @@ -139,26 +139,26 @@ export const l1Networks: L1Networks = { explorerUrl: 'https://goerli.etherscan.io', isCustom: false, name: 'Goerli', - partnerChainIDs: [421613], + childChainIds: [421613], isArbitrum: false, }, 11155111: { chainID: 11155111, name: 'Sepolia', explorerUrl: 'https://sepolia.etherscan.io', - partnerChainIDs: [421614], + childChainIds: [421614], blockTime: 12, isCustom: false, isArbitrum: false, }, } -export const l2Networks: L2Networks = { +export const childChains: ChildChains = { 42161: { chainID: 42161, name: 'Arbitrum One', explorerUrl: 'https://arbiscan.io', - partnerChainID: 1, + parentChainId: 1, isArbitrum: true, tokenBridge: mainnetTokenBridge, ethBridge: mainnetETHBridge, @@ -189,7 +189,7 @@ export const l2Networks: L2Networks = { isArbitrum: true, isCustom: false, name: 'Arbitrum Rollup Goerli Testnet', - partnerChainID: 5, + parentChainId: 5, tokenBridge: { l1CustomGateway: '0x9fDD1C4E4AA24EEc1d913FABea925594a20d43C7', l1ERC20Gateway: '0x715D99480b77A8d9D603638e593a539E21345FdF', @@ -228,7 +228,7 @@ export const l2Networks: L2Networks = { isArbitrum: true, isCustom: false, name: 'Arbitrum Nova', - partnerChainID: 1, + parentChainId: 1, retryableLifetimeSeconds: SEVEN_DAYS_IN_SECONDS, tokenBridge: { l1CustomGateway: '0x23122da8C581AA7E0d07A36Ff1f16F799650232f', @@ -269,7 +269,7 @@ export const l2Networks: L2Networks = { isArbitrum: true, isCustom: false, name: 'Arbitrum Rollup Sepolia Testnet', - partnerChainID: 11155111, + parentChainId: 11155111, retryableLifetimeSeconds: SEVEN_DAYS_IN_SECONDS, tokenBridge: { l1CustomGateway: '0xba2F7B6eAe1F9d174199C5E4867b563E0eaC40F3', @@ -305,7 +305,7 @@ export const l2Networks: L2Networks = { isArbitrum: true, isCustom: false, name: 'Stylus Testnet', - partnerChainID: 421614, + parentChainId: 421614, retryableLifetimeSeconds: SEVEN_DAYS_IN_SECONDS, tokenBridge: { l1CustomGateway: '0xd624D491A5Bc32de52a2e1481846752213bF7415', @@ -345,7 +345,7 @@ const getNetwork = async ( return chainId })() - const networks = layer === 1 ? l1Networks : l2Networks + const networks = layer === 1 ? parentChains : childChains if (networks[chainID]) { return networks[chainID] } else { @@ -353,15 +353,15 @@ const getNetwork = async ( } } -export const getL1Network = ( +export const getParentChain = ( signerOrProviderOrChainID: SignerOrProvider | number -): Promise => { - return getNetwork(signerOrProviderOrChainID, 1) as Promise +): Promise => { + return getNetwork(signerOrProviderOrChainID, 1) as Promise } -export const getL2Network = ( +export const getChildChain = ( signerOrProviderOrChainID: SignerOrProvider | number -): Promise => { - return getNetwork(signerOrProviderOrChainID, 2) as Promise +): Promise => { + return getNetwork(signerOrProviderOrChainID, 2) as Promise } /** @@ -396,44 +396,47 @@ export const getEthBridgeInformation = async ( } export const addCustomNetwork = ({ - customL1Network, - customL2Network, + customParentChain, + customChildChain, }: { - customL1Network?: L1Network - customL2Network: L2Network + customParentChain?: ParentChain + customChildChain: ChildChain }): void => { - if (customL1Network) { - if (l1Networks[customL1Network.chainID]) { + console.log({ customChildChain }) + if (customParentChain) { + if (parentChains[customParentChain.chainID]) { throw new ArbSdkError( - `Network ${customL1Network.chainID} already included` + `Network ${customParentChain.chainID} already included` ) - } else if (!customL1Network.isCustom) { + } else if (!customParentChain.isCustom) { throw new ArbSdkError( - `Custom network ${customL1Network.chainID} must have isCustom flag set to true` + `Custom network ${customParentChain.chainID} must have isCustom flag set to true` ) } else { - l1Networks[customL1Network.chainID] = customL1Network + parentChains[customParentChain.chainID] = customParentChain } } - if (l2Networks[customL2Network.chainID]) - throw new ArbSdkError(`Network ${customL2Network.chainID} already included`) - else if (!customL2Network.isCustom) { + if (childChains[customChildChain.chainID]) throw new ArbSdkError( - `Custom network ${customL2Network.chainID} must have isCustom flag set to true` + `Network ${customChildChain.chainID} already included` + ) + else if (!customChildChain.isCustom) { + throw new ArbSdkError( + `Custom network ${customChildChain.chainID} must have isCustom flag set to true` ) } - l2Networks[customL2Network.chainID] = customL2Network + childChains[customChildChain.chainID] = customChildChain - const l1PartnerChain = l1Networks[customL2Network.partnerChainID] - if (!l1PartnerChain) + const parentChainChildChain = parentChains[customChildChain.parentChainId] + if (!parentChainChildChain) throw new ArbSdkError( - `Network ${customL2Network.chainID}'s partner network, ${customL2Network.partnerChainID}, not recognized` + `Network ${customChildChain.chainID}'s parent chain, ${customChildChain.parentChainId}, not recognized` ) - if (!l1PartnerChain.partnerChainIDs.includes(customL2Network.chainID)) { - l1PartnerChain.partnerChainIDs.push(customL2Network.chainID) + if (!parentChainChildChain.childChainIds.includes(customChildChain.chainID)) { + parentChainChildChain.childChainIds.push(customChildChain.chainID) } } @@ -443,20 +446,20 @@ export const addCustomNetwork = ({ * @see {@link https://github.com/OffchainLabs/nitro} */ export const addDefaultLocalNetwork = (): { - l1Network: L1Network - l2Network: L2Network + parentChain: ParentChain + chain: ChildChain } => { - const defaultLocalL1Network: L1Network = { + const defaultLocalParentChain: ParentChain = { blockTime: 10, chainID: 1337, explorerUrl: '', isCustom: true, name: 'EthLocal', - partnerChainIDs: [412346], + childChainIds: [412346], isArbitrum: false, } - const defaultLocalL2Network: L2Network = { + const defaultLocalChain: ChildChain = { chainID: 412346, confirmPeriodBlocks: 20, ethBridge: { @@ -470,7 +473,7 @@ export const addDefaultLocalNetwork = (): { isArbitrum: true, isCustom: true, name: 'ArbLocal', - partnerChainID: 1337, + parentChainId: 1337, retryableLifetimeSeconds: 604800, nitroGenesisBlock: 0, nitroGenesisL1Block: 0, @@ -494,19 +497,19 @@ export const addDefaultLocalNetwork = (): { } addCustomNetwork({ - customL1Network: defaultLocalL1Network, - customL2Network: defaultLocalL2Network, + customParentChain: defaultLocalParentChain, + customChildChain: defaultLocalChain, }) return { - l1Network: defaultLocalL1Network, - l2Network: defaultLocalL2Network, + parentChain: defaultLocalParentChain, + chain: defaultLocalChain, } } -export const isL1Network = ( - network: L1Network | L2Network -): network is L1Network => { - if ((network as L1Network).partnerChainIDs) return true +export const isParentChain = ( + network: ParentChain | ChildChain +): network is ParentChain => { + if ((network as ParentChain).childChainIds) return true else return false } diff --git a/src/lib/inbox/inbox.ts b/src/lib/inbox/inbox.ts index 5f2759164c..3e629b2c21 100644 --- a/src/lib/inbox/inbox.ts +++ b/src/lib/inbox/inbox.ts @@ -28,10 +28,7 @@ import { SequencerInbox__factory } from '../abi/factories/SequencerInbox__factor import { IInbox__factory } from '../abi/factories/IInbox__factory' import { RequiredPick } from '../utils/types' import { MessageDeliveredEvent } from '../abi/Bridge' -import { - l1Networks as parentChains, - L2Network as ChildChain, -} from '../dataEntities/networks' +import { parentChains, ChildChain } from '../dataEntities/networks' import { SignerProviderUtils } from '../dataEntities/signerOrProvider' import { FetchedEvent, EventFetcher } from '../utils/eventFetcher' import { MultiCaller, CallInput } from '../utils/multicall' @@ -70,10 +67,10 @@ export class InboxTools { this.parentChainProvider = SignerProviderUtils.getProviderOrThrow( this.parentChainSigner ) - this.parentChain = parentChains[childChain.partnerChainID] + this.parentChain = parentChains[childChain.parentChainId] if (!this.parentChain) throw new ArbSdkError( - `ParentChainNetwork not found for chain id: ${childChain.partnerChainID}.` + `ParentChain not found for chain id: ${childChain.parentChainId}.` ) } diff --git a/src/lib/message/L1ToL2Message.ts b/src/lib/message/L1ToL2Message.ts index 2339c77576..7fcc3adabb 100644 --- a/src/lib/message/L1ToL2Message.ts +++ b/src/lib/message/L1ToL2Message.ts @@ -34,7 +34,7 @@ import { import { ArbSdkError } from '../dataEntities/errors' import { ethers, Overrides } from 'ethers' import { L2TransactionReceipt, RedeemTransaction } from './L2Transaction' -import { getL2Network } from '../../lib/dataEntities/networks' +import { getChildChain as getL2Network } from '../../lib/dataEntities/networks' import { RetryableMessageParams } from '../dataEntities/message' import { getTransactionReceipt, isDefined } from '../utils/lib' import { EventFetcher } from '../utils/eventFetcher' diff --git a/src/lib/message/L1ToL2MessageCreator.ts b/src/lib/message/L1ToL2MessageCreator.ts index d930e2b22f..7823cc9aae 100644 --- a/src/lib/message/L1ToL2MessageCreator.ts +++ b/src/lib/message/L1ToL2MessageCreator.ts @@ -7,7 +7,7 @@ import { } from './L1ToL2MessageGasEstimator' import { L1ContractTransaction, L1TransactionReceipt } from './L1Transaction' import { Inbox__factory } from '../abi/factories/Inbox__factory' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' import { PayableOverrides } from '@ethersproject/contracts' import { SignerProviderUtils } from '../dataEntities/signerOrProvider' import { MissingProviderArbSdkError } from '../dataEntities/errors' diff --git a/src/lib/message/L1ToL2MessageGasEstimator.ts b/src/lib/message/L1ToL2MessageGasEstimator.ts index 99c7686fc1..128ecb9e59 100644 --- a/src/lib/message/L1ToL2MessageGasEstimator.ts +++ b/src/lib/message/L1ToL2MessageGasEstimator.ts @@ -5,7 +5,7 @@ import { Inbox__factory } from '../abi/factories/Inbox__factory' import { NodeInterface__factory } from '../abi/factories/NodeInterface__factory' import { NODE_INTERFACE_ADDRESS } from '../dataEntities/constants' import { ArbSdkError } from '../dataEntities/errors' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' import { RetryableData, RetryableDataTools, diff --git a/src/lib/message/L1Transaction.ts b/src/lib/message/L1Transaction.ts index d2b79b3e4b..d2ab95eb0f 100644 --- a/src/lib/message/L1Transaction.ts +++ b/src/lib/message/L1Transaction.ts @@ -46,7 +46,7 @@ import { MessageDeliveredEvent } from '../abi/Bridge' import { EventArgs, parseTypedLogs } from '../dataEntities/event' import { isDefined } from '../utils/lib' import { SubmitRetryableMessageDataParser } from './messageDataParser' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' export interface L1ContractTransaction< TReceipt extends L1TransactionReceipt = L1TransactionReceipt diff --git a/src/lib/message/L2ToL1Message.ts b/src/lib/message/L2ToL1Message.ts index 1b3d1a4bce..fcde6086c6 100644 --- a/src/lib/message/L2ToL1Message.ts +++ b/src/lib/message/L2ToL1Message.ts @@ -35,7 +35,7 @@ import { import { isDefined } from '../utils/lib' import { EventArgs } from '../dataEntities/event' import { L2ToL1MessageStatus } from '../dataEntities/message' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' import { ArbSdkError } from '../dataEntities/errors' export type L2ToL1TransactionEvent = diff --git a/src/lib/message/L2ToL1MessageClassic.ts b/src/lib/message/L2ToL1MessageClassic.ts index 1edba7fc1d..e04c050a27 100644 --- a/src/lib/message/L2ToL1MessageClassic.ts +++ b/src/lib/message/L2ToL1MessageClassic.ts @@ -40,7 +40,7 @@ import { isDefined, wait } from '../utils/lib' import { ArbSdkError } from '../dataEntities/errors' import { EventArgs } from '../dataEntities/event' import { L2ToL1MessageStatus } from '../dataEntities/message' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' export interface MessageBatchProofInfo { /** diff --git a/src/lib/message/L2ToL1MessageNitro.ts b/src/lib/message/L2ToL1MessageNitro.ts index a744061ec8..4e8892e5cf 100644 --- a/src/lib/message/L2ToL1MessageNitro.ts +++ b/src/lib/message/L2ToL1MessageNitro.ts @@ -40,7 +40,7 @@ import { SignerOrProvider, } from '../dataEntities/signerOrProvider' import { getBlockRangesForL1Block, isArbitrumChain, wait } from '../utils/lib' -import { getL2Network } from '../dataEntities/networks' +import { getChildChain as getL2Network } from '../dataEntities/networks' import { NodeCreatedEvent, RollupUserLogic } from '../abi/RollupUserLogic' import { ArbitrumProvider } from '../utils/arbProvider' import { ArbBlock } from '../dataEntities/rpc' diff --git a/src/lib/utils/lib.ts b/src/lib/utils/lib.ts index c40341e1e6..40bf2b26cc 100644 --- a/src/lib/utils/lib.ts +++ b/src/lib/utils/lib.ts @@ -2,7 +2,7 @@ import { Provider } from '@ethersproject/abstract-provider' import { TransactionReceipt, JsonRpcProvider } from '@ethersproject/providers' import { ArbSdkError } from '../dataEntities/errors' import { ArbitrumProvider } from './arbProvider' -import { l2Networks } from '../dataEntities/networks' +import { childChains } from '../dataEntities/networks' import { ArbSys__factory } from '../abi/factories/ArbSys__factory' import { ARB_SYS_ADDRESS } from '../dataEntities/constants' @@ -100,7 +100,7 @@ export async function getFirstBlockForL1Block({ const arbProvider = new ArbitrumProvider(provider) const currentArbBlock = await arbProvider.getBlockNumber() const arbitrumChainId = (await arbProvider.getNetwork()).chainId - const { nitroGenesisBlock } = l2Networks[arbitrumChainId] + const { nitroGenesisBlock } = childChains[arbitrumChainId] async function getL1Block(forL2Block: number) { const { l1BlockNumber } = await arbProvider.getBlock(forL2Block) diff --git a/src/lib/utils/multicall.ts b/src/lib/utils/multicall.ts index 187b170c1f..b100b74b85 100644 --- a/src/lib/utils/multicall.ts +++ b/src/lib/utils/multicall.ts @@ -24,11 +24,11 @@ import { Multicall2 } from '../abi/Multicall2' import { Multicall2__factory } from '../abi/factories/Multicall2__factory' import { ArbSdkError } from '../dataEntities/errors' import { - isL1Network, - L1Network, - l1Networks, - L2Network, - l2Networks, + isParentChain as isL1Network, + ParentChain as L1Network, + parentChains as l1Networks, + ChildChain as L2Network, + childChains as l2Networks, } from '../dataEntities/networks' /** @@ -143,10 +143,10 @@ export class MultiCaller { let multiCallAddr: string if (isL1Network(network)) { - const firstL2 = l2Networks[network.partnerChainIDs[0]] + const firstL2 = l2Networks[network.childChainIds[0]] if (!firstL2) throw new ArbSdkError( - `No partner chain found l1 network: ${network.chainID} : partner chain ids ${network.partnerChainIDs}` + `No child chain found l1 network: ${network.chainID} : child chain ids ${network.childChainIds}` ) multiCallAddr = firstL2.tokenBridge.l1MultiCall } else { diff --git a/tests/fork/inbox.test.ts b/tests/fork/inbox.test.ts index d91c238ee2..7ed76a4790 100644 --- a/tests/fork/inbox.test.ts +++ b/tests/fork/inbox.test.ts @@ -30,7 +30,10 @@ import { InboxTools } from '../../src' import { ethers, network } from 'hardhat' import { hexZeroPad } from '@ethersproject/bytes' -import { L2Network, getL2Network } from '../../src/lib/dataEntities/networks' +import { + ChildChain as L2Network, + getChildChain as getL2Network, +} from '../../src/lib/dataEntities/networks' import { solidityKeccak256 } from 'ethers/lib/utils' import { ContractTransaction, Signer } from 'ethers' diff --git a/tests/integration/ethBridgeAddresses.test.ts b/tests/integration/ethBridgeAddresses.test.ts index 5d9db19974..57c9eb8b62 100644 --- a/tests/integration/ethBridgeAddresses.test.ts +++ b/tests/integration/ethBridgeAddresses.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai' import { EthBridge, getEthBridgeInformation, - getL2Network, + getChildChain as getL2Network, } from '../../src/lib/dataEntities/networks' import dotenv from 'dotenv' dotenv.config() diff --git a/tests/integration/sendL2msg.test.ts b/tests/integration/sendL2msg.test.ts index e9bcdd97ae..591d4f994c 100644 --- a/tests/integration/sendL2msg.test.ts +++ b/tests/integration/sendL2msg.test.ts @@ -19,7 +19,10 @@ import { BigNumber, ethers, Signer } from 'ethers' import { InboxTools } from '../../src/lib/inbox/inbox' -import { getL2Network, L2Network } from '../../src/lib/dataEntities/networks' +import { + getChildChain as getL2Network, + ChildChain as L2Network, +} from '../../src/lib/dataEntities/networks' import { testSetup } from '../../scripts/testSetup' import { greeter } from './helper/greeter' import { expect } from 'chai' diff --git a/tests/integration/testHelpers.ts b/tests/integration/testHelpers.ts index a258c96daf..dea1b93d19 100644 --- a/tests/integration/testHelpers.ts +++ b/tests/integration/testHelpers.ts @@ -31,7 +31,7 @@ import { L1ToL2MessageStatus, L2ToL1MessageStatus, } from '../../src' -import { L2Network } from '../../src/lib/dataEntities/networks' +import { ChildChain as L2Network } from '../../src/lib/dataEntities/networks' import { GasOverrides } from '../../src/lib/message/L1ToL2MessageGasEstimator' import { ArbSdkError } from '../../src/lib/dataEntities/errors' import { ERC20 } from '../../src/lib/abi/ERC20' diff --git a/tests/unit/l2toL1MessageEvents.test.ts b/tests/unit/l2toL1MessageEvents.test.ts index 8fff9e597b..d17bc71018 100644 --- a/tests/unit/l2toL1MessageEvents.test.ts +++ b/tests/unit/l2toL1MessageEvents.test.ts @@ -19,7 +19,7 @@ import { Logger, LogLevel } from '@ethersproject/logger' Logger.setLogLevel(LogLevel.ERROR) import { L2ToL1Message } from '../../src' -import { getL2Network } from '../../src/lib/dataEntities/networks' +import { getChildChain as getL2Network } from '../../src/lib/dataEntities/networks' import { providers } from 'ethers' import { anything, deepEqual, instance, mock, verify, when } from 'ts-mockito' diff --git a/tests/unit/multicall.test.ts b/tests/unit/multicall.test.ts index 8db7e1dd6a..94b8cdf22d 100644 --- a/tests/unit/multicall.test.ts +++ b/tests/unit/multicall.test.ts @@ -1,6 +1,6 @@ 'use strict' -import { getL2Network } from '../../src/lib/dataEntities/networks' +import { getChildChain as getL2Network } from '../../src/lib/dataEntities/networks' import { providers } from 'ethers' import { mock, when, anything, instance, deepEqual } from 'ts-mockito' import { expect } from 'chai'