Skip to content

Commit

Permalink
Add option to get RPCs as env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Oct 30, 2023
1 parent 31caf5f commit 9bcfa8d
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions scripts/local-deployment/deployCreatorAndCreateTokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,49 @@ 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
* - deploy L1 bridge creator and set templates
* - 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
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9bcfa8d

Please sign in to comment.