diff --git a/yarn-project/bot/src/factory.ts b/yarn-project/bot/src/factory.ts index 2a72653005a..d41ddf174ff 100644 --- a/yarn-project/bot/src/factory.ts +++ b/yarn-project/bot/src/factory.ts @@ -6,6 +6,7 @@ import { type DeployOptions, createDebugLogger, createPXEClient, + retryUntil, } from '@aztec/aztec.js'; import { type AztecNode, type FunctionCall, type PXE } from '@aztec/circuit-types'; import { Fr, deriveSigningKey } from '@aztec/circuits.js'; @@ -65,7 +66,18 @@ export class BotFactory { const isInit = await this.pxe.isContractInitialized(account.getAddress()); if (isInit) { this.log.info(`Account at ${account.getAddress().toString()} already initialized`); - return account.register(); + const wallet = await account.register(); + const blockNumber = await this.pxe.getBlockNumber(); + await retryUntil( + async () => { + const status = await this.pxe.getSyncStatus(); + return blockNumber <= status.blocks; + }, + 'pxe synch', + 3600, + 1, + ); + return wallet; } else { this.log.info(`Initializing account at ${account.getAddress().toString()}`); const sentTx = account.deploy();