@aztec/bot 0.0.1-commit.96dac018d → 0.0.1-commit.9a89641

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,aAAa,CAAC;AAE9D,eAAO,MAAM,aAAa;;;;;;EAExB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,YAAY,CAQzD,CAAC"}
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,aAAa,CAAC;AAE9D,eAAO,MAAM,aAAa;;iBAExB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,YAAY,CAQzD,CAAC"}
package/dest/interface.js CHANGED
@@ -5,11 +5,34 @@ export const BotInfoSchema = z.object({
5
5
  botAddress: AztecAddress.schema
6
6
  });
7
7
  export const BotRunnerApiSchema = {
8
- start: z.function().args().returns(z.void()),
9
- stop: z.function().args().returns(z.void()),
10
- run: z.function().args().returns(z.void()),
11
- setup: z.function().args().returns(z.void()),
12
- getInfo: z.function().args().returns(BotInfoSchema),
13
- getConfig: z.function().args().returns(BotConfigSchema),
14
- update: z.function().args(BotConfigSchema).returns(z.void())
8
+ start: z.function({
9
+ input: z.tuple([]),
10
+ output: z.void()
11
+ }),
12
+ stop: z.function({
13
+ input: z.tuple([]),
14
+ output: z.void()
15
+ }),
16
+ run: z.function({
17
+ input: z.tuple([]),
18
+ output: z.void()
19
+ }),
20
+ setup: z.function({
21
+ input: z.tuple([]),
22
+ output: z.void()
23
+ }),
24
+ getInfo: z.function({
25
+ input: z.tuple([]),
26
+ output: BotInfoSchema
27
+ }),
28
+ getConfig: z.function({
29
+ input: z.tuple([]),
30
+ output: BotConfigSchema
31
+ }),
32
+ update: z.function({
33
+ input: z.tuple([
34
+ BotConfigSchema
35
+ ]),
36
+ output: z.void()
37
+ })
15
38
  };
package/dest/runner.d.ts CHANGED
@@ -13,13 +13,14 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
13
13
  private readonly telemetry;
14
14
  private readonly aztecNodeAdmin;
15
15
  private readonly store;
16
+ private readonly syncChainTip?;
16
17
  private log;
17
18
  private bot?;
18
19
  private runningPromise;
19
20
  private consecutiveErrors;
20
21
  private healthy;
21
22
  readonly tracer: Tracer;
22
- constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore);
23
+ constructor(config: BotConfig, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore, syncChainTip?: "checkpointed" | "finalized" | "latest" | "proposed" | "proven" | undefined);
23
24
  /** Initializes the bot if needed. Blocks until the bot setup is finished. */
24
25
  setup(): Promise<void>;
25
26
  private doSetup;
@@ -50,4 +51,4 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
50
51
  /** Returns the bot sender address. */
51
52
  getInfo(): Promise<BotInfo>;
52
53
  }
53
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcnVubmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBR3RELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBRSxLQUFLLFNBQVMsRUFBRSxL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B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAfhC,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,GAAG,CAAC,CAAmB;IAC/B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,OAAO,CAAQ;IAEvB,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,YACU,MAAM,EAAE,SAAS,EACR,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,eAAe,EAC1B,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,KAAK,EAAE,QAAQ,EACf,YAAY,CAAC,6EAAU,EAKzC;IAED,6EAA6E;IAChE,KAAK,kBAIjB;YAGa,OAAO;IAMrB;;;OAGG;IACU,KAAK,kBAMjB;IAED;;OAEG;IACU,IAAI,kBAOhB;IAEM,SAAS,YAEf;IAED,0CAA0C;IACnC,SAAS,YAEf;IAED;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,SAAS,iBAapC;IAED;;;OAGG;IACU,GAAG,kBAsBf;IAED,qDAAqD;IAC9C,SAAS,uBAGf;IAED,sCAAsC;IACzB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAMvC;CAwEF"}
package/dest/runner.js CHANGED
@@ -386,6 +386,7 @@ export class BotRunner {
386
386
  telemetry;
387
387
  aztecNodeAdmin;
388
388
  store;
389
+ syncChainTip;
389
390
  static{
390
391
  ({ e: [_call_work, _initProto] } = _apply_decs_2203_r(this, [
391
392
  [
@@ -428,13 +429,14 @@ export class BotRunner {
428
429
  consecutiveErrors;
429
430
  healthy;
430
431
  tracer;
431
- constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store){
432
+ constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store, syncChainTip){
432
433
  this.config = config;
433
434
  this.wallet = wallet;
434
435
  this.aztecNode = aztecNode;
435
436
  this.telemetry = telemetry;
436
437
  this.aztecNodeAdmin = aztecNodeAdmin;
437
438
  this.store = store;
439
+ this.syncChainTip = syncChainTip;
438
440
  this.log = (_initProto(this), createLogger('bot'));
439
441
  this.consecutiveErrors = 0;
440
442
  this.healthy = true;
@@ -538,13 +540,13 @@ export class BotRunner {
538
540
  try {
539
541
  switch(this.config.botMode){
540
542
  case 'crosschain':
541
- this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
543
+ this.bot = CrossChainBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
542
544
  break;
543
545
  case 'amm':
544
- this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
546
+ this.bot = AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
545
547
  break;
546
548
  case 'transfer':
547
- this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
549
+ this.bot = Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store, this.syncChainTip);
548
550
  break;
549
551
  default:
550
552
  {
package/dest/utils.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * @param who - Address to get the balance for.
5
5
  * @returns - Private and public token balances as bigints.
6
6
  */ export async function getBalances(token, who, from) {
7
- const privateBalance = await token.methods.balance_of_private(who).simulate({
7
+ const { result: privateBalance } = await token.methods.balance_of_private(who).simulate({
8
8
  from: from ?? who
9
9
  });
10
- const publicBalance = await token.methods.balance_of_public(who).simulate({
10
+ const { result: publicBalance } = await token.methods.balance_of_public(who).simulate({
11
11
  from: from ?? who
12
12
  });
13
13
  return {
@@ -16,7 +16,7 @@
16
16
  };
17
17
  }
18
18
  export async function getPrivateBalance(token, who, from) {
19
- const privateBalance = await token.methods.get_balance(who).simulate({
19
+ const { result: privateBalance } = await token.methods.get_balance(who).simulate({
20
20
  from: from ?? who
21
21
  });
22
22
  return privateBalance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/bot",
3
- "version": "0.0.1-commit.96dac018d",
3
+ "version": "0.0.1-commit.9a89641",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -54,24 +54,24 @@
54
54
  ]
55
55
  },
56
56
  "dependencies": {
57
- "@aztec/accounts": "0.0.1-commit.96dac018d",
58
- "@aztec/aztec.js": "0.0.1-commit.96dac018d",
59
- "@aztec/entrypoints": "0.0.1-commit.96dac018d",
60
- "@aztec/ethereum": "0.0.1-commit.96dac018d",
61
- "@aztec/foundation": "0.0.1-commit.96dac018d",
62
- "@aztec/kv-store": "0.0.1-commit.96dac018d",
63
- "@aztec/l1-artifacts": "0.0.1-commit.96dac018d",
64
- "@aztec/noir-contracts.js": "0.0.1-commit.96dac018d",
65
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.96dac018d",
66
- "@aztec/noir-test-contracts.js": "0.0.1-commit.96dac018d",
67
- "@aztec/protocol-contracts": "0.0.1-commit.96dac018d",
68
- "@aztec/stdlib": "0.0.1-commit.96dac018d",
69
- "@aztec/telemetry-client": "0.0.1-commit.96dac018d",
70
- "@aztec/wallets": "0.0.1-commit.96dac018d",
57
+ "@aztec/accounts": "0.0.1-commit.9a89641",
58
+ "@aztec/aztec.js": "0.0.1-commit.9a89641",
59
+ "@aztec/entrypoints": "0.0.1-commit.9a89641",
60
+ "@aztec/ethereum": "0.0.1-commit.9a89641",
61
+ "@aztec/foundation": "0.0.1-commit.9a89641",
62
+ "@aztec/kv-store": "0.0.1-commit.9a89641",
63
+ "@aztec/l1-artifacts": "6.0.0-nightly.20260807",
64
+ "@aztec/noir-contracts.js": "0.0.1-commit.9a89641",
65
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.9a89641",
66
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.9a89641",
67
+ "@aztec/protocol-contracts": "0.0.1-commit.9a89641",
68
+ "@aztec/stdlib": "0.0.1-commit.9a89641",
69
+ "@aztec/telemetry-client": "0.0.1-commit.9a89641",
70
+ "@aztec/wallets": "0.0.1-commit.9a89641",
71
71
  "source-map-support": "^0.5.21",
72
72
  "tslib": "^2.4.0",
73
73
  "viem": "npm:@aztec/viem@2.38.2",
74
- "zod": "^3.23.8"
74
+ "zod": "^4"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@jest/globals": "^30.0.0",
package/src/amm_bot.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
- import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
4
+ import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
5
5
  import { jsonStringify } from '@aztec/foundation/json-rpc';
6
6
  import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
7
7
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
8
+ import type { BlockTag } from '@aztec/stdlib/block';
8
9
  import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
9
10
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
10
11
 
@@ -37,6 +38,7 @@ export class AmmBot extends BaseBot {
37
38
  aztecNode: AztecNode,
38
39
  aztecNodeAdmin: AztecNodeAdmin | undefined,
39
40
  store: BotStore,
41
+ syncChainTip?: BlockTag,
40
42
  ): Promise<AmmBot> {
41
43
  const { defaultAccountAddress, token0, token1, amm } = await new BotFactory(
42
44
  config,
@@ -44,6 +46,7 @@ export class AmmBot extends BaseBot {
44
46
  store,
45
47
  aztecNode,
46
48
  aztecNodeAdmin,
49
+ syncChainTip,
47
50
  ).setupAmm();
48
51
  return new AmmBot(aztecNode, wallet, defaultAccountAddress, amm, token0, token1, config);
49
52
  }
@@ -71,12 +74,14 @@ export class AmmBot extends BaseBot {
71
74
  .getFunctionCall(),
72
75
  });
73
76
 
74
- const amountOutMin = await amm.methods
75
- .get_amount_out_for_exact_in(
76
- await tokenIn.methods.balance_of_public(amm.address).simulate({ from: this.defaultAccountAddress }),
77
- await tokenOut.methods.balance_of_public(amm.address).simulate({ from: this.defaultAccountAddress }),
78
- amountIn,
79
- )
77
+ const { result: tokenInBalance } = await tokenIn.methods
78
+ .balance_of_public(amm.address)
79
+ .simulate({ from: this.defaultAccountAddress });
80
+ const { result: tokenOutBalance } = await tokenOut.methods
81
+ .balance_of_public(amm.address)
82
+ .simulate({ from: this.defaultAccountAddress });
83
+ const { result: amountOutMin } = await amm.methods
84
+ .get_amount_out_for_exact_in(tokenInBalance, tokenOutBalance, amountIn)
80
85
  .simulate({ from: this.defaultAccountAddress });
81
86
 
82
87
  const swapExactTokensInteraction = amm.methods
@@ -85,11 +90,12 @@ export class AmmBot extends BaseBot {
85
90
  authWitnesses: [swapAuthwit],
86
91
  });
87
92
 
88
- const opts = await this.getSendMethodOpts(swapExactTokensInteraction);
93
+ const opts = this.getSendMethodOpts();
89
94
 
90
95
  this.log.verbose(`Sending transaction`, logCtx);
91
96
  this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
92
- return swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
97
+ const { txHash } = await swapExactTokensInteraction.send({ ...opts, wait: NO_WAIT });
98
+ return txHash;
93
99
  }
94
100
 
95
101
  protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
@@ -110,15 +116,17 @@ export class AmmBot extends BaseBot {
110
116
  }
111
117
 
112
118
  private async getPublicBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
113
- return {
114
- token0: await this.token0.methods.balance_of_public(address).simulate({ from: from ?? address }),
115
- token1: await this.token1.methods.balance_of_public(address).simulate({ from: from ?? address }),
116
- };
119
+ const { result: token0 } = await this.token0.methods.balance_of_public(address).simulate({ from: from ?? address });
120
+ const { result: token1 } = await this.token1.methods.balance_of_public(address).simulate({ from: from ?? address });
121
+ return { token0, token1 };
117
122
  }
118
123
  private async getPrivateBalanceFor(address: AztecAddress, from?: AztecAddress): Promise<Balances> {
119
- return {
120
- token0: await this.token0.methods.balance_of_private(address).simulate({ from: from ?? address }),
121
- token1: await this.token1.methods.balance_of_private(address).simulate({ from: from ?? address }),
122
- };
124
+ const { result: token0 } = await this.token0.methods
125
+ .balance_of_private(address)
126
+ .simulate({ from: from ?? address });
127
+ const { result: token1 } = await this.token1.methods
128
+ .balance_of_private(address)
129
+ .simulate({ from: from ?? address });
130
+ return { token0, token1 };
123
131
  }
124
132
  }
package/src/base_bot.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { BatchCall, ContractFunctionInteraction, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
2
+ import type { SendInteractionOptions } from '@aztec/aztec.js/contracts';
3
3
  import { createLogger } from '@aztec/aztec.js/log';
4
4
  import { waitForTx } from '@aztec/aztec.js/node';
5
- import { TxHash, TxReceipt, TxStatus } from '@aztec/aztec.js/tx';
5
+ import { TxStatus } from '@aztec/aztec.js/tx';
6
+ import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
6
7
  import { Gas } from '@aztec/stdlib/gas';
7
8
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
9
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
@@ -56,27 +57,19 @@ export abstract class BaseBot {
56
57
  return Promise.resolve();
57
58
  }
58
59
 
59
- protected async getSendMethodOpts(
60
- interaction: ContractFunctionInteraction | BatchCall,
61
- ): Promise<SendInteractionOptions> {
60
+ protected getSendMethodOpts(): SendInteractionOptions {
62
61
  const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
63
62
 
64
63
  this.wallet.setMinFeePadding(minFeePadding);
65
64
 
66
- let gasSettings;
67
- if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
68
- gasSettings = { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) };
69
- this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
70
- } else {
71
- this.log.verbose(`Estimating gas for transaction`);
72
- ({ estimatedGas: gasSettings } = await interaction.simulate({
73
- fee: { estimateGas: true },
74
- from: this.defaultAccountAddress,
75
- }));
76
- }
65
+ const gasSettings =
66
+ l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0
67
+ ? { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) }
68
+ : undefined;
69
+
77
70
  return {
78
71
  from: this.defaultAccountAddress,
79
- fee: { gasSettings },
72
+ ...(gasSettings ? { fee: { gasSettings } } : {}),
80
73
  };
81
74
  }
82
75
  }
package/src/bot.ts CHANGED
@@ -4,6 +4,7 @@ import { TxHash } from '@aztec/aztec.js/tx';
4
4
  import { times } from '@aztec/foundation/collection';
5
5
  import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
6
6
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
7
+ import type { BlockTag } from '@aztec/stdlib/block';
7
8
  import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
8
9
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
9
10
 
@@ -33,6 +34,7 @@ export class Bot extends BaseBot {
33
34
  aztecNode: AztecNode,
34
35
  aztecNodeAdmin: AztecNodeAdmin | undefined,
35
36
  store: BotStore,
37
+ syncChainTip?: BlockTag,
36
38
  ): Promise<Bot> {
37
39
  const { defaultAccountAddress, token, recipient } = await new BotFactory(
38
40
  config,
@@ -40,6 +42,7 @@ export class Bot extends BaseBot {
40
42
  store,
41
43
  aztecNode,
42
44
  aztecNodeAdmin,
45
+ syncChainTip,
43
46
  ).setup();
44
47
  return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
45
48
  }
@@ -70,13 +73,11 @@ export class Bot extends BaseBot {
70
73
  );
71
74
 
72
75
  const batch = new BatchCall(wallet, calls);
73
- const opts = await this.getSendMethodOpts(batch);
74
-
75
- this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
76
- await batch.simulate({ from: this.defaultAccountAddress });
76
+ const opts = this.getSendMethodOpts();
77
77
 
78
78
  this.log.verbose(`Sending transaction`, logCtx);
79
- return batch.send({ ...opts, wait: NO_WAIT });
79
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
80
+ return txHash;
80
81
  }
81
82
 
82
83
  public async getBalances() {
package/src/config.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  type ConfigMappingsType,
3
3
  SecretValue,
4
4
  booleanConfigHelper,
5
+ floatConfigHelper,
5
6
  getConfigFromMappings,
6
7
  getDefaultConfig,
7
8
  numberConfigHelper,
@@ -11,9 +12,9 @@ import {
11
12
  secretStringConfigHelper,
12
13
  } from '@aztec/foundation/config';
13
14
  import { Fr } from '@aztec/foundation/curves/bn254';
14
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
15
15
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
16
16
  import { protocolContractsHash } from '@aztec/protocol-contracts';
17
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
17
18
  import { schemas, zodFor } from '@aztec/stdlib/schemas';
18
19
  import type { ComponentsVersions } from '@aztec/stdlib/versioning';
19
20
 
@@ -69,9 +70,9 @@ export type BotConfig = {
69
70
  maxPendingTxs: number;
70
71
  /** Whether to flush after sending each 'setup' transaction */
71
72
  flushSetupTransactions: boolean;
72
- /** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
73
+ /** L2 gas limit for the tx (empty to let the bot's wallet estimate). */
73
74
  l2GasLimit: number | undefined;
74
- /** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
75
+ /** DA gas limit for the tx (empty to let the bot's wallet estimate). */
75
76
  daGasLimit: number | undefined;
76
77
  /** Token contract to use */
77
78
  contract: SupportedTokenContracts;
@@ -103,7 +104,7 @@ export const BotConfigSchema = zodFor<BotConfig>()(
103
104
  privateTransfersPerTx: z.number().int().nonnegative(),
104
105
  publicTransfersPerTx: z.number().int().nonnegative(),
105
106
  feePaymentMethod: z.literal('fee_juice'),
106
- minFeePadding: z.number().int().nonnegative(),
107
+ minFeePadding: z.number().nonnegative(),
107
108
  noStart: z.boolean(),
108
109
  txMinedWaitSeconds: z.number(),
109
110
  followChain: z.enum(BotFollowChain),
@@ -130,7 +131,6 @@ export const BotConfigSchema = zodFor<BotConfig>()(
130
131
  l1Mnemonic: undefined,
131
132
  l1PrivateKey: undefined,
132
133
  senderPrivateKey: undefined,
133
- dataDirectory: undefined,
134
134
  dataStoreMapSizeKb: 1_024 * 1_024,
135
135
  ...config,
136
136
  })),
@@ -205,7 +205,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
205
205
  minFeePadding: {
206
206
  env: 'BOT_MIN_FEE_PADDING',
207
207
  description: 'How much is the bot willing to overpay vs. the current base fee',
208
- ...numberConfigHelper(3),
208
+ ...floatConfigHelper(3),
209
209
  },
210
210
  noStart: {
211
211
  env: 'BOT_NO_START',
@@ -244,12 +244,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
244
244
  },
245
245
  l2GasLimit: {
246
246
  env: 'BOT_L2_GAS_LIMIT',
247
- description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
247
+ description: "L2 gas limit for the tx (empty to let the bot's wallet estimate).",
248
248
  ...optionalNumberConfigHelper(),
249
249
  },
250
250
  daGasLimit: {
251
251
  env: 'BOT_DA_GAS_LIMIT',
252
- description: 'DA gas limit for the tx (empty to have the bot trigger an estimate gas).',
252
+ description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
253
253
  ...optionalNumberConfigHelper(),
254
254
  },
255
255
  contract: {
@@ -26,11 +26,12 @@
26
26
  import { AztecAddress } from '@aztec/aztec.js/addresses';
27
27
  import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
28
28
  import { isL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
29
- import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
29
+ import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
30
30
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
31
31
  import { Fr } from '@aztec/foundation/curves/bn254';
32
32
  import { EthAddress } from '@aztec/foundation/eth-address';
33
33
  import type { TestContract } from '@aztec/noir-test-contracts.js/Test';
34
+ import type { BlockTag } from '@aztec/stdlib/block';
34
35
  import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
35
36
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
36
37
 
@@ -60,6 +61,7 @@ export class CrossChainBot extends BaseBot {
60
61
  private readonly rollupVersion: bigint,
61
62
  private readonly store: BotStore,
62
63
  config: BotConfig,
64
+ private readonly syncChainTip?: BlockTag,
63
65
  ) {
64
66
  super(node, wallet, defaultAccountAddress, config);
65
67
  }
@@ -70,11 +72,12 @@ export class CrossChainBot extends BaseBot {
70
72
  aztecNode: AztecNode,
71
73
  aztecNodeAdmin: AztecNodeAdmin | undefined,
72
74
  store: BotStore,
75
+ syncChainTip?: BlockTag,
73
76
  ): Promise<CrossChainBot> {
74
77
  if (config.followChain === 'NONE') {
75
78
  throw new Error(`CrossChainBot requires followChain to be set (got NONE)`);
76
79
  }
77
- const factory = new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin);
80
+ const factory = new BotFactory(config, wallet, store, aztecNode, aztecNodeAdmin, syncChainTip);
78
81
  const { defaultAccountAddress, contract, l1Client, rollupVersion } = await factory.setupCrossChain();
79
82
  const l1Recipient = EthAddress.fromString(l1Client.account!.address);
80
83
  const { l1ContractAddresses } = await aztecNode.getNodeInfo();
@@ -90,6 +93,7 @@ export class CrossChainBot extends BaseBot {
90
93
  rollupVersion,
91
94
  store,
92
95
  config,
96
+ syncChainTip,
93
97
  );
94
98
  }
95
99
 
@@ -137,17 +141,19 @@ export class CrossChainBot extends BaseBot {
137
141
  }
138
142
 
139
143
  const batch = new BatchCall(this.wallet, calls);
140
- const opts = await this.getSendMethodOpts(batch);
144
+ const opts = this.getSendMethodOpts();
141
145
 
142
146
  this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
143
- return batch.send({ ...opts, wait: NO_WAIT });
147
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
148
+ return txHash;
144
149
  }
145
150
 
146
151
  protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
147
152
  // Verify L2→L1 messages appeared in this tx's effects
148
- const indexed = await this.node.getTxEffect(receipt.txHash);
149
- if (indexed) {
150
- const l2ToL1Msgs = indexed.data.l2ToL1Msgs.filter(m => !m.isZero());
153
+ const minedReceipt = await this.node.getTxReceipt(receipt.txHash, { includeTxEffect: true });
154
+ const l2ToL1MsgsRaw = minedReceipt.txEffect?.l2ToL1Msgs;
155
+ if (l2ToL1MsgsRaw) {
156
+ const l2ToL1Msgs = l2ToL1MsgsRaw.filter(m => !m.isZero());
151
157
  if (l2ToL1Msgs.length >= this.config.l2ToL1MessagesPerTx) {
152
158
  this.l2ToL1Sent += l2ToL1Msgs.length;
153
159
  } else {
@@ -174,14 +180,7 @@ export class CrossChainBot extends BaseBot {
174
180
  ): Promise<PendingL1ToL2Message | undefined> {
175
181
  const now = Date.now();
176
182
  for (const msg of pendingMessages) {
177
- const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash), {
178
- // Use forPublicConsumption: false so we wait until blockNumber >= messageBlockNumber.
179
- // With forPublicConsumption: true, the check returns true one block early (the sequencer
180
- // includes L1→L2 messages before executing the block's txs), but gas estimation simulates
181
- // against the current world state which doesn't yet have the message.
182
- // See https://linear.app/aztec-labs/issue/A-548 for details.
183
- forPublicConsumption: false,
184
- });
183
+ const ready = await isL1ToL2MessageReady(this.node, Fr.fromHexString(msg.msgHash), this.syncChainTip);
185
184
  if (ready) {
186
185
  return msg;
187
186
  }