@@ -14,7 +14,13 @@ import { ethers } from 'ethers';
1414
1515import { arbOwnerABI , arbOwnerAddress } from '../contracts/ArbOwner' ;
1616import { testConstants } from './constants' ;
17- import { dockerAsync , getNitroContractsImage } from './dockerHelpers' ;
17+ import {
18+ dockerAsync ,
19+ getNitroContractsImage ,
20+ getRollupCreatorDockerArgs ,
21+ getTokenBridgeContractsImage ,
22+ getTokenBridgeCreatorDockerArgs ,
23+ } from './dockerHelpers' ;
1824import type { PrivateKeyAccountWithPrivateKey } from '../testHelpers' ;
1925
2026export type ContractArtifact = {
@@ -41,6 +47,14 @@ type DeployRollupCreatorParams = {
4147 chainId : number ;
4248} ;
4349
50+ type DeployTokenBridgeCreatorParams = {
51+ networkName : string ;
52+ rpcUrl : string ;
53+ deployerPrivateKey : `0x${string } `;
54+ wethAddress : Address ;
55+ gasLimitForL2FactoryDeployment ?: bigint ;
56+ } ;
57+
4458function sleep ( ms : number ) {
4559 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
4660}
@@ -68,41 +82,6 @@ async function getRequiredRetryableFunding(
6882 } ;
6983}
7084
71- function getRollupCreatorDockerArgs (
72- params : Omit < DeployRollupCreatorParams , 'blockAdvancer' > ,
73- nitroContractsImage : string ,
74- ) {
75- return [
76- 'run' ,
77- '--rm' ,
78- '--network' ,
79- params . networkName ,
80- '-e' ,
81- `CUSTOM_RPC_URL=${ params . rpcUrl } ` ,
82- '-e' ,
83- `CUSTOM_PRIVKEY=${ params . deployerPrivateKey } ` ,
84- '-e' ,
85- `CUSTOM_CHAINID=${ params . chainId } ` ,
86- '-e' ,
87- `FACTORY_OWNER=${ params . factoryOwner } ` ,
88- '-e' ,
89- `MAX_DATA_SIZE=${ params . maxDataSize } ` ,
90- '-e' ,
91- `POLLING_INTERVAL=${ testConstants . NITRO_DEPLOY_POLLING_INTERVAL_MS } ` ,
92- '-e' ,
93- 'DISABLE_VERIFICATION=true' ,
94- '-e' ,
95- 'IGNORE_MAX_DATA_SIZE_WARNING=true' ,
96- nitroContractsImage ,
97- 'hardhat' ,
98- 'run' ,
99- '--no-compile' ,
100- 'scripts/deployment.ts' ,
101- '--network' ,
102- 'custom' ,
103- ] ;
104- }
105-
10685function parseRollupCreatorAddress ( stdout : string ) : Address {
10786 const match = stdout . match ( / \* R o l l u p C r e a t o r c r e a t e d a t a d d r e s s : ( 0 x [ 0 - 9 a - f A - F ] { 40 } ) / ) ;
10887 if ( ! match ) {
@@ -112,6 +91,17 @@ function parseRollupCreatorAddress(stdout: string): Address {
11291 return match [ 1 ] as Address ;
11392}
11493
94+ function parseTokenBridgeCreatorAddress ( stdout : string ) : Address {
95+ const match = stdout . match ( / L 1 T o k e n B r i d g e C r e a t o r : \s * ( 0 x [ 0 - 9 a - f A - F ] { 40 } ) / ) ;
96+ if ( ! match ) {
97+ throw new Error (
98+ `Failed to parse TokenBridgeCreator address from token bridge deploy output:\n${ stdout } ` ,
99+ ) ;
100+ }
101+
102+ return match [ 1 ] as Address ;
103+ }
104+
115105export function createAccount ( privateKey ?: Hex ) : PrivateKeyAccountWithPrivateKey {
116106 const normalizedPrivateKey = privateKey ?? generatePrivateKey ( ) ;
117107 return {
@@ -345,7 +335,6 @@ export async function deployRollupCreator(
345335 blockAdvancer : BlockAdvancer ,
346336) : Promise < Address > {
347337 const nitroContractsImage = getNitroContractsImage ( ) ;
348- const dockerRunStartedAt = Date . now ( ) ;
349338 const stdout = await withBackgroundBlockAdvancing ( blockAdvancer , ( ) =>
350339 dockerAsync (
351340 getRollupCreatorDockerArgs (
@@ -361,11 +350,17 @@ export async function deployRollupCreator(
361350 ) ,
362351 ) ,
363352 ) ;
364- console . log (
365- `[${ new Date ( ) . toISOString ( ) } ] rollup creator docker run finished after ${
366- Date . now ( ) - dockerRunStartedAt
367- } ms`,
368- ) ;
369353
370354 return parseRollupCreatorAddress ( stdout ) ;
371355}
356+
357+ export async function deployTokenBridgeCreator (
358+ params : DeployTokenBridgeCreatorParams ,
359+ blockAdvancer : BlockAdvancer ,
360+ ) : Promise < Address > {
361+ const tokenBridgeContractsImage = getTokenBridgeContractsImage ( ) ;
362+ const stdout = await withBackgroundBlockAdvancing ( blockAdvancer , ( ) =>
363+ dockerAsync ( getTokenBridgeCreatorDockerArgs ( params , tokenBridgeContractsImage ) ) ,
364+ ) ;
365+ return parseTokenBridgeCreatorAddress ( stdout ) ;
366+ }
0 commit comments