From 9bcfa8d9f8dff336b594ae6b6ddf51db70a0d349 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 30 Oct 2023 16:03:26 +0100 Subject: [PATCH] Add option to get RPCs as env vars --- .../deployCreatorAndCreateTokenBridge.ts | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts b/scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts index 9666064314..d72c534119 100644 --- a/scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts +++ b/scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts @@ -11,6 +11,9 @@ import { } from '../atomicTokenBridgeDeployer' import { l2Networks } from '@arbitrum/sdk/dist/lib/dataEntities/networks' +const LOCALHOST_L2_RPC = 'http://localhost:8547' +const LOCALHOST_L3_RPC = 'http://localhost:3347' + /** * Steps: * - read network info from local container and register networks @@ -18,37 +21,39 @@ import { l2Networks } from '@arbitrum/sdk/dist/lib/dataEntities/networks' * - do single TX deployment of token bridge * - populate network objects with new addresses and return it * - * @param l1Deployer - * @param l2Deployer + * @param parentDeployer + * @param childDeployer * @param l1Url * @param l2Url * @returns */ export const setupTokenBridgeInLocalEnv = async () => { - /// setup deployers, load local networks - /// L1 URL = parent chain = L2 - /// L2 URL = child chain = L3 - const config = { - l1Url: 'http://localhost:8547', - l2Url: 'http://localhost:3347', + // set RPCs either from env vars or use defaults + let parentRpc = process.env['PARENT_RPC'] as string + let childRpc = process.env['CHILD_RPC'] as string + if (parentRpc === undefined || childRpc === undefined) { + parentRpc = LOCALHOST_L2_RPC + childRpc = LOCALHOST_L3_RPC } + // if no ROLLUP_ADDRESS is defined, it will be pulled from local container const rollupAddress = process.env['ROLLUP_ADDRESS'] as string - const l1Deployer = new ethers.Wallet( + // use test-node.bash funded account + const parentDeployer = new ethers.Wallet( ethers.utils.sha256(ethers.utils.toUtf8Bytes('user_token_bridge_deployer')), - new ethers.providers.JsonRpcProvider(config.l1Url) + new ethers.providers.JsonRpcProvider(parentRpc) ) - const l2Deployer = new ethers.Wallet( + const childDeployer = new ethers.Wallet( ethers.utils.sha256(ethers.utils.toUtf8Bytes('user_token_bridge_deployer')), - new ethers.providers.JsonRpcProvider(config.l2Url) + new ethers.providers.JsonRpcProvider(childRpc) ) // docker-compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n' const orbitOwner = '0x863c904166E801527125D8672442D736194A3362' const { l1Network, l2Network: coreL2Network } = await getLocalNetworks( - config.l1Url, - config.l2Url, + parentRpc, + childRpc, rollupAddress ) @@ -85,15 +90,19 @@ export const setupTokenBridgeInLocalEnv = async () => { // a random address for l1Weth const l1Weth = '0x05EcEffc7CBA4e43a410340E849052AD43815aCA' const { l1TokenBridgeCreator, retryableSender } = - await deployL1TokenBridgeCreator(l1Deployer, l2Deployer.provider!, l1Weth) + await deployL1TokenBridgeCreator( + parentDeployer, + childDeployer.provider!, + l1Weth + ) console.log('L1TokenBridgeCreator', l1TokenBridgeCreator.address) console.log('L1TokenBridgeRetryableSender', retryableSender.address) // create token bridge console.log('Creating token bridge') const deployedContracts = await createTokenBridge( - l1Deployer, - l2Deployer.provider!, + parentDeployer, + childDeployer.provider!, l1TokenBridgeCreator, coreL2Network.ethBridge.rollup, orbitOwner