Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@
"@ethersproject/address": "^5.0.8",
"@ethersproject/bignumber": "^5.1.1",
"@ethersproject/bytes": "^5.0.8",
"@typechain/ethers-v5": "9.0.0",
"@types/prompts": "^2.0.14",
"@types/yargs": "^17.0.9",
"dotenv": "^10.0.0",
"ethers": "^5.1.0",
"ts-node": "^10.2.1",
"typechain": "7.0.0"
"ethers": "^5.1.0"
},
"devDependencies": {
"ts-node": "^10.2.1",
"dotenv": "^10.0.0",
"@typechain/ethers-v5": "9.0.0",
"@types/yargs": "^17.0.9",
"typechain": "7.0.0",
"@arbitrum/nitro-contracts": "1.0.0-beta.5",
"arb-bridge-peripherals": "1.0.10",
"@nomiclabs/hardhat-ethers": "^2.0.4",
Expand Down
44 changes: 28 additions & 16 deletions scripts/instantiate_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ export const instantiateBridge = (
throw new Error('need ARB_KEY var')
}

let networkID = args.networkID
if (!networkID) {
let l2NetworkID = args.networkID
if (!l2NetworkID) {
console.log(
'No networkID command line arg provided; using network',
defaultNetworkId
)

networkID = defaultNetworkId
l2NetworkID = defaultNetworkId
}
const isL1 = isDefined(l1Networks[networkID])
const isL2 = isDefined(l2Networks[networkID])
const isL1 = isDefined(l1Networks[l2NetworkID])
const isL2 = isDefined(l2Networks[l2NetworkID])
if (!isL1 && !isL2) {
throw new Error(`Unrecognized network ID: ${networkID}`)
throw new Error(`Unrecognized network ID: ${l2NetworkID}`)
}
if (!isL2) {
throw new Error(`Tests must specify an L2 network ID: ${networkID}`)
throw new Error(`Tests must specify an L2 network ID: ${l2NetworkID}`)
}

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

if (!l1Network) {
Expand All @@ -86,14 +86,26 @@ export const instantiateBridge = (
)
}

if (!l1Network.rpcURL) {
throw new Error('L1 rpc url not set (see .env.sample or networks.ts)')
}
if (!l2Network.rpcURL) {
throw new Error('L2 rpc url not set (see .env.sample or utils/networks.ts)')
}
const ethProvider = new JsonRpcProvider(l1Network.rpcURL)
const arbProvider = new JsonRpcProvider(l2Network.rpcURL)
const l1Rpc = (() => {
if (l2NetworkID === 42161) return process.env['MAINNET_RPC'] as string
if (l2NetworkID === 421611) return process.env['RINKEBY_RPC'] as string
if (l2NetworkID === 1338) return 'http://127.0.0.1:8545/'
throw new Error(
'L1 rpc url not set (see .env.sample or networks.ts) or chain id not supported'
)
})()
const l2Rpc = (() => {
if (l2NetworkID === 42161)
return process.env['ARB_ONE_RPC'] || 'https://arb1.arbitrum.io/rpc'
if (l2NetworkID === 421611)
return process.env['RINKARBY_RPC'] || 'https://rinkeby.arbitrum.io/rpc'
throw new Error(
'L2 rpc url not set (see .env.sample or networks.ts) or chain id not supported'
)
})()

const ethProvider = new JsonRpcProvider(l1Rpc)
const arbProvider = new JsonRpcProvider(l2Rpc)

const l1Signer = (() => {
if (l1PkParam) {
Expand Down
2 changes: 0 additions & 2 deletions scripts/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export const getCustomNetworks = async (
isCustom: true,
name: 'EthLocal',
partnerChainIDs: [l2NetworkInfo.chainId],
rpcURL: l1Url,
}

const l2Network: Omit<L2Network, 'tokenBridge'> = {
Expand All @@ -106,7 +105,6 @@ export const getCustomNetworks = async (
isCustom: true,
name: 'ArbLocal',
partnerChainID: l1NetworkInfo.chainId,
rpcURL: l2Url,
retryableLifetimeSeconds: 7 * 24 * 60 * 60,
}
return {
Expand Down
9 changes: 0 additions & 9 deletions src/lib/dataEntities/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
/* eslint-env node */
'use strict'

import dotenv from 'dotenv'
import { SignerOrProvider, SignerProviderUtils } from './signerOrProvider'
import { ArbSdkError } from '../dataEntities/errors'
import { SEVEN_DAYS_IN_SECONDS } from './constants'

dotenv.config()

export interface L1Network extends Network {
partnerChainIDs: number[]
blockTime: number //seconds
Expand All @@ -40,7 +37,6 @@ export interface Network {
chainID: number
name: string
explorerUrl: string
rpcURL: string
gif?: string
isCustom: boolean
}
Expand Down Expand Up @@ -135,7 +131,6 @@ export const l1Networks: L1Networks = {
explorerUrl: 'https://etherscan.io',
partnerChainIDs: [42161],
blockTime: 14,
rpcURL: process.env['MAINNET_RPC'] as string,
isCustom: false,
},
1338: {
Expand All @@ -144,7 +139,6 @@ export const l1Networks: L1Networks = {
explorerUrl: 'https://etherscan.io',
partnerChainIDs: [42161],
blockTime: 1,
rpcURL: 'http://127.0.0.1:8545/',
isCustom: false,
},
4: {
Expand All @@ -153,7 +147,6 @@ export const l1Networks: L1Networks = {
explorerUrl: 'https://rinkeby.etherscan.io',
partnerChainIDs: [421611],
blockTime: 15,
rpcURL: process.env['RINKEBY_RPC'] as string,
isCustom: false,
},
}
Expand All @@ -168,7 +161,6 @@ export const l2Networks: L2Networks = {
tokenBridge: mainnetTokenBridge,
ethBridge: mainnetETHBridge,
confirmPeriodBlocks: 45818,
rpcURL: process.env['ARB_ONE_RPC'] || 'https://arb1.arbitrum.io/rpc',
isCustom: false,
retryableLifetimeSeconds: SEVEN_DAYS_IN_SECONDS,
},
Expand All @@ -181,7 +173,6 @@ export const l2Networks: L2Networks = {
tokenBridge: rinkebyTokenBridge,
ethBridge: rinkebyETHBridge,
confirmPeriodBlocks: 6545, // TODO
rpcURL: process.env['RINKARBY_RPC'] || 'https://rinkeby.arbitrum.io/rpc',
isCustom: false,
retryableLifetimeSeconds: SEVEN_DAYS_IN_SECONDS,
},
Expand Down