@aztec/bot 0.0.1-commit.b6e433891 → 0.0.1-commit.b9865e97

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/bot",
3
- "version": "0.0.1-commit.b6e433891",
3
+ "version": "0.0.1-commit.b9865e97",
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.b6e433891",
58
- "@aztec/aztec.js": "0.0.1-commit.b6e433891",
59
- "@aztec/entrypoints": "0.0.1-commit.b6e433891",
60
- "@aztec/ethereum": "0.0.1-commit.b6e433891",
61
- "@aztec/foundation": "0.0.1-commit.b6e433891",
62
- "@aztec/kv-store": "0.0.1-commit.b6e433891",
63
- "@aztec/l1-artifacts": "0.0.1-commit.b6e433891",
64
- "@aztec/noir-contracts.js": "0.0.1-commit.b6e433891",
65
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b6e433891",
66
- "@aztec/noir-test-contracts.js": "0.0.1-commit.b6e433891",
67
- "@aztec/protocol-contracts": "0.0.1-commit.b6e433891",
68
- "@aztec/stdlib": "0.0.1-commit.b6e433891",
69
- "@aztec/telemetry-client": "0.0.1-commit.b6e433891",
70
- "@aztec/wallets": "0.0.1-commit.b6e433891",
57
+ "@aztec/accounts": "0.0.1-commit.b9865e97",
58
+ "@aztec/aztec.js": "0.0.1-commit.b9865e97",
59
+ "@aztec/entrypoints": "0.0.1-commit.b9865e97",
60
+ "@aztec/ethereum": "0.0.1-commit.b9865e97",
61
+ "@aztec/foundation": "0.0.1-commit.b9865e97",
62
+ "@aztec/kv-store": "0.0.1-commit.b9865e97",
63
+ "@aztec/l1-artifacts": "0.0.1-commit.b9865e97",
64
+ "@aztec/noir-contracts.js": "0.0.1-commit.b9865e97",
65
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b9865e97",
66
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.b9865e97",
67
+ "@aztec/protocol-contracts": "0.0.1-commit.b9865e97",
68
+ "@aztec/stdlib": "0.0.1-commit.b9865e97",
69
+ "@aztec/telemetry-client": "0.0.1-commit.b9865e97",
70
+ "@aztec/wallets": "0.0.1-commit.b9865e97",
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,7 +1,7 @@
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';
@@ -87,7 +87,7 @@ export class AmmBot extends BaseBot {
87
87
  authWitnesses: [swapAuthwit],
88
88
  });
89
89
 
90
- const opts = await this.getSendMethodOpts(swapExactTokensInteraction);
90
+ const opts = this.getSendMethodOpts();
91
91
 
92
92
  this.log.verbose(`Sending transaction`, logCtx);
93
93
  this.log.info(`Tx. Balances: ${jsonStringify(balances)}`, { ...logCtx, balances });
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
@@ -70,10 +70,7 @@ export class Bot extends BaseBot {
70
70
  );
71
71
 
72
72
  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 });
73
+ const opts = this.getSendMethodOpts();
77
74
 
78
75
  this.log.verbose(`Sending transaction`, logCtx);
79
76
  const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
package/src/config.ts CHANGED
@@ -69,9 +69,9 @@ export type BotConfig = {
69
69
  maxPendingTxs: number;
70
70
  /** Whether to flush after sending each 'setup' transaction */
71
71
  flushSetupTransactions: boolean;
72
- /** L2 gas limit for the tx (empty to have the bot trigger an estimate gas). */
72
+ /** L2 gas limit for the tx (empty to let the bot's wallet estimate). */
73
73
  l2GasLimit: number | undefined;
74
- /** DA gas limit for the tx (empty to have the bot trigger an estimate gas). */
74
+ /** DA gas limit for the tx (empty to let the bot's wallet estimate). */
75
75
  daGasLimit: number | undefined;
76
76
  /** Token contract to use */
77
77
  contract: SupportedTokenContracts;
@@ -243,12 +243,12 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
243
243
  },
244
244
  l2GasLimit: {
245
245
  env: 'BOT_L2_GAS_LIMIT',
246
- description: 'L2 gas limit for the tx (empty to have the bot trigger an estimate gas).',
246
+ description: "L2 gas limit for the tx (empty to let the bot's wallet estimate).",
247
247
  ...optionalNumberConfigHelper(),
248
248
  },
249
249
  daGasLimit: {
250
250
  env: 'BOT_DA_GAS_LIMIT',
251
- description: 'DA gas limit for the tx (empty to have the bot trigger an estimate gas).',
251
+ description: "DA gas limit for the tx (empty to let the bot's wallet estimate).",
252
252
  ...optionalNumberConfigHelper(),
253
253
  },
254
254
  contract: {
@@ -26,7 +26,7 @@
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';
@@ -137,7 +137,7 @@ export class CrossChainBot extends BaseBot {
137
137
  }
138
138
 
139
139
  const batch = new BatchCall(this.wallet, calls);
140
- const opts = await this.getSendMethodOpts(batch);
140
+ const opts = this.getSendMethodOpts();
141
141
 
142
142
  this.log.verbose(`Sending cross-chain batch with ${calls.length} calls`, logCtx);
143
143
  const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
@@ -146,9 +146,10 @@ export class CrossChainBot extends BaseBot {
146
146
 
147
147
  protected override async onTxMined(receipt: TxReceipt, logCtx: object): Promise<void> {
148
148
  // Verify L2→L1 messages appeared in this tx's effects
149
- const indexed = await this.node.getTxEffect(receipt.txHash);
150
- if (indexed) {
151
- const l2ToL1Msgs = indexed.data.l2ToL1Msgs.filter(m => !m.isZero());
149
+ const minedReceipt = await this.node.getTxReceipt(receipt.txHash, { includeTxEffect: true });
150
+ const l2ToL1MsgsRaw = minedReceipt.txEffect?.l2ToL1Msgs;
151
+ if (l2ToL1MsgsRaw) {
152
+ const l2ToL1Msgs = l2ToL1MsgsRaw.filter(m => !m.isZero());
152
153
  if (l2ToL1Msgs.length >= this.config.l2ToL1MessagesPerTx) {
153
154
  this.l2ToL1Sent += l2ToL1Msgs.length;
154
155
  } else {