11import { type BotConfig , BotRunner , botConfigMappings , getBotRunnerApiHandler } from '@aztec/bot' ;
22import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server' ;
33import type { LogFn } from '@aztec/foundation/log' ;
4- import { type AztecNode , type PXE , createAztecNodeClient } from '@aztec/stdlib/interfaces/client' ;
4+ import { type AztecNode , type AztecNodeAdmin , createAztecNodeClient } from '@aztec/stdlib/interfaces/client' ;
55import type { TelemetryClient } from '@aztec/telemetry-client' ;
66import {
77 getConfigEnvVars as getTelemetryClientConfig ,
88 initTelemetryClient ,
99 makeTracedFetch ,
1010} from '@aztec/telemetry-client' ;
11+ import { TestWallet } from '@aztec/test-wallet' ;
1112
1213import { extractRelevantOptions } from '../util.js' ;
1314import { getVersions } from '../versioning.js' ;
@@ -32,28 +33,28 @@ export async function startBot(
3233 throw new Error ( 'The bot requires access to a Node' ) ;
3334 }
3435
35- const node = createAztecNodeClient ( config . nodeUrl , getVersions ( ) , fetch ) ;
36+ const aztecNode = createAztecNodeClient ( config . nodeUrl , getVersions ( ) , fetch ) ;
3637
37- // Start a PXE client that is used by the bot if required
38- let pxe : PXE | undefined ;
39- if ( options . pxe ) {
40- const { addPXE } = await import ( './start_pxe.js' ) ;
41- ( { pxe } = await addPXE ( options , signalHandlers , services , userLog , { node } ) ) ;
42- }
38+ // Start a PXE client and get a wallet that is used by the bot if required
39+ const { startPXEServiceGetWallet } = await import ( './start_pxe.js' ) ;
40+ const { wallet } = await startPXEServiceGetWallet ( options , services , userLog , { node : aztecNode } ) ;
4341
4442 const telemetry = initTelemetryClient ( getTelemetryClientConfig ( ) ) ;
45- await addBot ( options , signalHandlers , services , { pxe , telemetry, node } ) ;
43+ await addBot ( options , signalHandlers , services , wallet , aztecNode , telemetry , undefined ) ;
4644}
4745
4846export function addBot (
4947 options : any ,
5048 signalHandlers : ( ( ) => Promise < void > ) [ ] ,
5149 services : NamespacedApiHandlers ,
52- deps : { pxe ?: PXE ; node ?: AztecNode ; telemetry : TelemetryClient } ,
50+ wallet : TestWallet ,
51+ aztecNode : AztecNode ,
52+ telemetry : TelemetryClient ,
53+ aztecNodeAdmin ?: AztecNodeAdmin ,
5354) {
5455 const config = extractRelevantOptions < BotConfig > ( options , botConfigMappings , 'bot' ) ;
5556
56- const botRunner = new BotRunner ( config , deps ) ;
57+ const botRunner = new BotRunner ( config , wallet , aztecNode , telemetry , aztecNodeAdmin ) ;
5758 if ( ! config . noStart ) {
5859 void botRunner . start ( ) ; // Do not block since bot setup takes time
5960 }
0 commit comments