1
1
#!/usr/bin/env -S node --no-warnings
2
2
import { type AztecNodeConfig , AztecNodeService , getConfigEnvVars } from '@aztec/aztec-node' ;
3
- import { SignerlessWallet } from '@aztec/aztec.js' ;
3
+ import { EthCheatCodes , SignerlessWallet , Watcher } from '@aztec/aztec.js' ;
4
4
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint' ;
5
5
import { type AztecNode } from '@aztec/circuit-types' ;
6
6
import { deployCanonicalAuthRegistry , deployCanonicalKeyRegistry , deployCanonicalL2FeeJuice } from '@aztec/cli/misc' ;
@@ -166,8 +166,21 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
166
166
aztecNodeConfig . validatorPrivateKey = `0x${ Buffer . from ( privKey ! ) . toString ( 'hex' ) } ` ;
167
167
}
168
168
169
+ let watcher : Watcher | undefined = undefined ;
169
170
if ( ! aztecNodeConfig . p2pEnabled ) {
170
- await deployContractsToL1 ( aztecNodeConfig , hdAccount ) ;
171
+ const l1ContractAddresses = await deployContractsToL1 ( aztecNodeConfig , hdAccount ) ;
172
+
173
+ const chain = aztecNodeConfig . l1RpcUrl
174
+ ? createEthereumChain ( aztecNodeConfig . l1RpcUrl , aztecNodeConfig . l1ChainId )
175
+ : { chainInfo : localAnvil } ;
176
+
177
+ const publicClient = createPublicClient ( {
178
+ chain : chain . chainInfo ,
179
+ transport : httpViemTransport ( aztecNodeConfig . l1RpcUrl ) ,
180
+ } ) ;
181
+
182
+ watcher = new Watcher ( new EthCheatCodes ( aztecNodeConfig . l1RpcUrl ) , l1ContractAddresses . rollupAddress , publicClient ) ;
183
+ await watcher . start ( ) ;
171
184
}
172
185
173
186
const client = await createAndStartTelemetryClient ( getTelemetryClientConfig ( ) ) ;
@@ -191,6 +204,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}) {
191
204
const stop = async ( ) => {
192
205
await pxe . stop ( ) ;
193
206
await node . stop ( ) ;
207
+ await watcher ?. stop ( ) ;
194
208
} ;
195
209
196
210
return { node, pxe, aztecNodeConfig, stop } ;
0 commit comments