11import { execFile , execFileSync } from 'node:child_process' ;
2- import { mkdtempSync , rmSync } from 'node:fs' ;
3- import { tmpdir } from 'node:os' ;
2+ import { rmSync } from 'node:fs' ;
43import { join } from 'node:path' ;
54
65import { createPublicClient , http } from 'viem' ;
76
87import { testConstants } from './constants' ;
98
10- const cachedNitroContractsImageByTag : Record < string , string > = { } ;
11-
129function sleep ( ms : number ) {
1310 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
1411}
@@ -47,43 +44,19 @@ export function getNitroContractsImage(): string {
4744 const imageTag = `chain-sdk-nitro-contracts:${ sanitizeDockerTagPart (
4845 testConstants . DEFAULT_NITRO_CONTRACTS_REF ,
4946 ) } `;
50- const cachedImage = cachedNitroContractsImageByTag [ imageTag ] ;
51- if ( cachedImage ) {
52- return cachedImage ;
53- }
5447
5548 try {
5649 docker ( [ 'image' , 'inspect' , imageTag ] ) ;
5750 } catch {
58- const tempDir = mkdtempSync ( join ( tmpdir ( ) , 'chain-sdk-nitro-contracts-' ) ) ;
59- const repoDir = join ( tempDir , 'repo' ) ;
51+ const nitroContractsDir = join ( process . cwd ( ) , 'nitro-contracts' ) ;
6052 const dockerfilePath = join ( process . cwd ( ) , 'nitro-contracts' , 'Dockerfile' ) ;
61-
62- try {
63- runCommand ( 'git' , [
64- 'clone' ,
65- '--recurse-submodules' ,
66- '--shallow-submodules' ,
67- '--depth' ,
68- '1' ,
69- '--branch' ,
70- testConstants . DEFAULT_NITRO_CONTRACTS_BRANCH ,
71- '--single-branch' ,
72- testConstants . DEFAULT_NITRO_CONTRACTS_REPO_URL ,
73- repoDir ,
74- ] ) ;
75-
76- docker ( [ 'build' , '-f' , dockerfilePath , '-t' , imageTag , repoDir ] ) ;
77- } finally {
78- rmSync ( tempDir , { recursive : true , force : true } ) ;
79- }
53+ docker ( [ 'build' , '-f' , dockerfilePath , '-t' , imageTag , nitroContractsDir ] ) ;
8054 }
8155
82- cachedNitroContractsImageByTag [ imageTag ] = imageTag ;
8356 return imageTag ;
8457}
8558
86- export function createSourceDockerNetwork ( networkName : string ) {
59+ export function createDockerNetwork ( networkName : string ) {
8760 docker ( [ 'network' , 'create' , networkName ] ) ;
8861}
8962
@@ -237,7 +210,7 @@ export function cleanupStaleHarnessNetworks() {
237210 }
238211}
239212
240- export function startSourceL1AnvilContainer ( params : {
213+ export function startL1AnvilContainer ( params : {
241214 containerName : string ;
242215 networkName : string ;
243216 l1RpcPort : number ;
@@ -275,7 +248,7 @@ export function startSourceL1AnvilContainer(params: {
275248 ] ) ;
276249}
277250
278- export function startSourceL2NitroContainer ( params : {
251+ export function startL2NitroContainer ( params : {
279252 containerName : string ;
280253 networkName : string ;
281254 l2RpcPort : number ;
@@ -295,7 +268,7 @@ export function startSourceL2NitroContainer(params: {
295268 `${ params . runtimeDir } :/runtime` ,
296269 params . nitroImage ,
297270 '--conf.file' ,
298- '/runtime/source- l2-node-config.json' ,
271+ '/runtime/l2-node-config.json' ,
299272 '--persistent.chain' ,
300273 '/runtime/nitro-data' ,
301274 '--ensure-rollup-deployment=false' ,
0 commit comments