@aztec/bot 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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.
Files changed (52) hide show
  1. package/dest/amm_bot.d.ts +7 -7
  2. package/dest/amm_bot.d.ts.map +1 -1
  3. package/dest/amm_bot.js +30 -19
  4. package/dest/base_bot.d.ts +8 -8
  5. package/dest/base_bot.d.ts.map +1 -1
  6. package/dest/base_bot.js +26 -37
  7. package/dest/bot.d.ts +7 -6
  8. package/dest/bot.d.ts.map +1 -1
  9. package/dest/bot.js +11 -11
  10. package/dest/config.d.ts +63 -99
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +48 -21
  13. package/dest/cross_chain_bot.d.ts +56 -0
  14. package/dest/cross_chain_bot.d.ts.map +1 -0
  15. package/dest/cross_chain_bot.js +138 -0
  16. package/dest/factory.d.ts +23 -27
  17. package/dest/factory.d.ts.map +1 -1
  18. package/dest/factory.js +252 -141
  19. package/dest/index.d.ts +2 -1
  20. package/dest/index.d.ts.map +1 -1
  21. package/dest/index.js +1 -0
  22. package/dest/interface.d.ts +2 -6
  23. package/dest/interface.d.ts.map +1 -1
  24. package/dest/interface.js +30 -7
  25. package/dest/l1_to_l2_seeding.d.ts +8 -0
  26. package/dest/l1_to_l2_seeding.d.ts.map +1 -0
  27. package/dest/l1_to_l2_seeding.js +63 -0
  28. package/dest/rpc.d.ts +1 -1
  29. package/dest/runner.d.ts +4 -3
  30. package/dest/runner.d.ts.map +1 -1
  31. package/dest/runner.js +432 -32
  32. package/dest/store/bot_store.d.ts +30 -5
  33. package/dest/store/bot_store.d.ts.map +1 -1
  34. package/dest/store/bot_store.js +38 -7
  35. package/dest/store/index.d.ts +2 -2
  36. package/dest/store/index.d.ts.map +1 -1
  37. package/dest/utils.d.ts +1 -1
  38. package/dest/utils.js +3 -3
  39. package/package.json +20 -16
  40. package/src/amm_bot.ts +30 -22
  41. package/src/base_bot.ts +23 -44
  42. package/src/bot.ts +14 -12
  43. package/src/config.ts +96 -65
  44. package/src/cross_chain_bot.ts +208 -0
  45. package/src/factory.ts +302 -129
  46. package/src/index.ts +1 -0
  47. package/src/interface.ts +7 -7
  48. package/src/l1_to_l2_seeding.ts +79 -0
  49. package/src/runner.ts +41 -5
  50. package/src/store/bot_store.ts +61 -6
  51. package/src/store/index.ts +1 -1
  52. package/src/utils.ts +3 -3
@@ -1,21 +1,40 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { L2AmountClaim } from '@aztec/aztec.js/ethereum';
3
3
  import { type Logger } from '@aztec/foundation/log';
4
+ import { DateProvider } from '@aztec/foundation/timer';
4
5
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
6
  export interface BridgeClaimData {
6
7
  claim: L2AmountClaim;
7
8
  timestamp: number;
8
9
  recipient: string;
9
10
  }
11
+ export interface PendingL1ToL2Message {
12
+ /** Random content field sent in the message. */
13
+ content: string;
14
+ /** Secret for consuming the message. */
15
+ secret: string;
16
+ /** Hash of the secret. */
17
+ secretHash: string;
18
+ /** Hash of the L1→L2 message. */
19
+ msgHash: string;
20
+ /** L1 sender address (hex). */
21
+ sender: string;
22
+ /** Global leaf index in the L1→L2 message tree. */
23
+ globalLeafIndex: string;
24
+ /** Timestamp when the message was seeded. */
25
+ timestamp: number;
26
+ }
10
27
  /**
11
28
  * Simple data store for the bot to persist L1 bridge claims.
12
29
  */
13
30
  export declare class BotStore {
14
31
  private readonly store;
15
32
  private readonly log;
33
+ private readonly dateProvider;
16
34
  static readonly SCHEMA_VERSION = 1;
17
35
  private readonly bridgeClaims;
18
- constructor(store: AztecAsyncKVStore, log?: Logger);
36
+ private readonly pendingL1ToL2;
37
+ constructor(store: AztecAsyncKVStore, log?: Logger, dateProvider?: DateProvider);
19
38
  /**
20
39
  * Saves a bridge claim for a recipient.
21
40
  */
@@ -36,9 +55,15 @@ export declare class BotStore {
36
55
  * Cleans up old bridge claims (older than 24 hours).
37
56
  */
38
57
  cleanupOldClaims(maxAgeMs?: number): Promise<number>;
39
- /**
40
- * Closes the store.
41
- */
58
+ /** Saves a pending L1→L2 message keyed by msgHash. */
59
+ savePendingL1ToL2Message(msg: PendingL1ToL2Message): Promise<void>;
60
+ /** Returns all unconsumed pending L1→L2 messages. */
61
+ getUnconsumedL1ToL2Messages(): Promise<PendingL1ToL2Message[]>;
62
+ /** Deletes a consumed L1→L2 message from the store. */
63
+ deleteL1ToL2Message(msgHash: string): Promise<void>;
64
+ /** Cleans up pending L1→L2 messages older than maxAgeMs. */
65
+ cleanupOldPendingMessages(maxAgeMs?: number): Promise<number>;
66
+ /** Closes the store. */
42
67
  close(): Promise<void>;
43
68
  }
44
- //# sourceMappingURL=bot_store.d.ts.map
69
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmUvYm90X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBRXhFLE1BQU0sV0FBVyxlQUFlO0lBQzlCLEtBQUssRUFBRSxhQUFhLENBQUM7SUFDckIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixTQUFTLEVBQUUsTUFBTSxDQUFDO0NBQ25CO0FBRUQsTUFBTSx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BAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;IAED,uDAAqD;IACxC,2BAA2B,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAM1E;IAED,yDAAuD;IAC1C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/D;IAED,8DAA4D;IAC/C,yBAAyB,CAAC,QAAQ,GAAE,MAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9F;IAED,wBAAwB;IACX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlC;CACF"}
@@ -1,16 +1,21 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { DateProvider } from '@aztec/foundation/timer';
3
4
  /**
4
5
  * Simple data store for the bot to persist L1 bridge claims.
5
6
  */ export class BotStore {
6
7
  store;
7
8
  log;
9
+ dateProvider;
8
10
  static SCHEMA_VERSION = 1;
9
11
  bridgeClaims;
10
- constructor(store, log = createLogger('bot:store')){
12
+ pendingL1ToL2;
13
+ constructor(store, log = createLogger('bot:store'), dateProvider = new DateProvider()){
11
14
  this.store = store;
12
15
  this.log = log;
16
+ this.dateProvider = dateProvider;
13
17
  this.bridgeClaims = store.openMap('bridge_claims');
18
+ this.pendingL1ToL2 = store.openMap('pending_l1_to_l2');
14
19
  }
15
20
  /**
16
21
  * Saves a bridge claim for a recipient.
@@ -25,7 +30,7 @@ import { createLogger } from '@aztec/foundation/log';
25
30
  };
26
31
  const data = {
27
32
  claim: serializableClaim,
28
- timestamp: Date.now(),
33
+ timestamp: this.dateProvider.now(),
29
34
  recipient: recipient.toString()
30
35
  };
31
36
  await this.bridgeClaims.set(recipient.toString(), JSON.stringify(data));
@@ -85,7 +90,7 @@ import { createLogger } from '@aztec/foundation/log';
85
90
  /**
86
91
  * Cleans up old bridge claims (older than 24 hours).
87
92
  */ async cleanupOldClaims(maxAgeMs = 24 * 60 * 60 * 1000) {
88
- const now = Date.now();
93
+ const now = this.dateProvider.now();
89
94
  let cleanedCount = 0;
90
95
  const entries = this.bridgeClaims.entriesAsync();
91
96
  for await (const [key, data] of entries){
@@ -98,9 +103,35 @@ import { createLogger } from '@aztec/foundation/log';
98
103
  }
99
104
  return cleanedCount;
100
105
  }
101
- /**
102
- * Closes the store.
103
- */ async close() {
106
+ /** Saves a pending L1→L2 message keyed by msgHash. */ async savePendingL1ToL2Message(msg) {
107
+ await this.pendingL1ToL2.set(msg.msgHash, JSON.stringify(msg));
108
+ this.log.info(`Saved pending L1→L2 message ${msg.msgHash}`);
109
+ }
110
+ /** Returns all unconsumed pending L1→L2 messages. */ async getUnconsumedL1ToL2Messages() {
111
+ const messages = [];
112
+ for await (const [_, data] of this.pendingL1ToL2.entriesAsync()){
113
+ messages.push(JSON.parse(data));
114
+ }
115
+ return messages;
116
+ }
117
+ /** Deletes a consumed L1→L2 message from the store. */ async deleteL1ToL2Message(msgHash) {
118
+ await this.pendingL1ToL2.delete(msgHash);
119
+ this.log.info(`Deleted consumed L1→L2 message ${msgHash}`);
120
+ }
121
+ /** Cleans up pending L1→L2 messages older than maxAgeMs. */ async cleanupOldPendingMessages(maxAgeMs = 24 * 60 * 60 * 1000) {
122
+ const now = this.dateProvider.now();
123
+ let cleanedCount = 0;
124
+ for await (const [key, data] of this.pendingL1ToL2.entriesAsync()){
125
+ const parsed = JSON.parse(data);
126
+ if (now - parsed.timestamp > maxAgeMs) {
127
+ await this.pendingL1ToL2.delete(key);
128
+ cleanedCount++;
129
+ this.log.info(`Cleaned up old pending L1→L2 message ${key}`);
130
+ }
131
+ }
132
+ return cleanedCount;
133
+ }
134
+ /** Closes the store. */ async close() {
104
135
  await this.store.close();
105
136
  this.log.info('Closed bot data store');
106
137
  }
@@ -1,2 +1,2 @@
1
- export { BotStore, type BridgeClaimData } from './bot_store.js';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export { BotStore, type BridgeClaimData, type PendingL1ToL2Message } from './bot_store.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLEtBQUssZUFBZSxFQUFFLEtBQUssb0JBQW9CLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
package/dest/utils.d.ts CHANGED
@@ -16,4 +16,4 @@ export declare function getBalances(token: TokenContract, who: AztecAddress, fro
16
16
  export declare function getPrivateBalance(token: PrivateTokenContract, who: AztecAddress, from?: AztecAddress): Promise<bigint>;
17
17
  export declare function isStandardTokenContract(token: ContractBase): token is TokenContract;
18
18
  export declare function isAMMContract(contract: ContractBase): contract is AMMContract;
19
- //# sourceMappingURL=utils.d.ts.map
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUNsRixPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRTs7Ozs7R0FLRztBQUNILHdCQUFzQixXQUFXLENBQy9CLEtBQUssRUFBRSxhQUFhLEVBQ3BCLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLElBQUksQ0FBQyxFQUFFLFlBQVksR0FDbEIsT0FBTyxDQUFDO0lBQUUsY0FBYyxFQUFFLE1BQU0sQ0FBQztJQUFDLGFBQWEsRUFBRSxNQUFNLENBQUE7Q0FBRSxDQUFDLENBSTVEO0FBRUQsd0JBQXNCLGlCQUFpQixDQUNyQyxLQUFLLEVBQUUsb0JBQW9CLEVBQzNCLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLElBQUksQ0FBQyxFQUFFLFlBQVksR0FDbEIsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUdqQjtBQUVELHdCQUFnQix1QkFBdUIsQ0FBQyxLQUFLLEVBQUUsWUFBWSxHQUFHLEtBQUssSUFBSSxhQUFhLENBRW5GO0FBRUQsd0JBQWdCLGFBQWEsQ0FBQyxRQUFRLEVBQUUsWUFBWSxHQUFHLFFBQVEsSUFBSSxXQUFXLENBRTdFIn0=
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.b655e406",
3
+ "version": "0.0.1-commit.b8a057fa",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -10,8 +10,8 @@
10
10
  "../package.common.json"
11
11
  ],
12
12
  "scripts": {
13
- "build": "yarn clean && tsc -b",
14
- "build:dev": "tsc -b --watch",
13
+ "build": "yarn clean && ../scripts/tsc.sh",
14
+ "build:dev": "../scripts/tsc.sh --watch",
15
15
  "clean": "rm -rf ./dest .tsbuildinfo",
16
16
  "bb": "node --no-warnings ./dest/bb/index.js",
17
17
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
@@ -54,27 +54,31 @@
54
54
  ]
55
55
  },
56
56
  "dependencies": {
57
- "@aztec/accounts": "0.0.1-commit.b655e406",
58
- "@aztec/aztec.js": "0.0.1-commit.b655e406",
59
- "@aztec/entrypoints": "0.0.1-commit.b655e406",
60
- "@aztec/ethereum": "0.0.1-commit.b655e406",
61
- "@aztec/foundation": "0.0.1-commit.b655e406",
62
- "@aztec/kv-store": "0.0.1-commit.b655e406",
63
- "@aztec/noir-contracts.js": "0.0.1-commit.b655e406",
64
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b655e406",
65
- "@aztec/protocol-contracts": "0.0.1-commit.b655e406",
66
- "@aztec/stdlib": "0.0.1-commit.b655e406",
67
- "@aztec/telemetry-client": "0.0.1-commit.b655e406",
68
- "@aztec/test-wallet": "0.0.1-commit.b655e406",
57
+ "@aztec/accounts": "0.0.1-commit.b8a057fa",
58
+ "@aztec/aztec.js": "0.0.1-commit.b8a057fa",
59
+ "@aztec/entrypoints": "0.0.1-commit.b8a057fa",
60
+ "@aztec/ethereum": "0.0.1-commit.b8a057fa",
61
+ "@aztec/foundation": "0.0.1-commit.b8a057fa",
62
+ "@aztec/kv-store": "0.0.1-commit.b8a057fa",
63
+ "@aztec/l1-artifacts": "0.0.1-commit.b8a057fa",
64
+ "@aztec/noir-contracts.js": "0.0.1-commit.b8a057fa",
65
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b8a057fa",
66
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.b8a057fa",
67
+ "@aztec/protocol-contracts": "0.0.1-commit.b8a057fa",
68
+ "@aztec/stdlib": "0.0.1-commit.b8a057fa",
69
+ "@aztec/telemetry-client": "0.0.1-commit.b8a057fa",
70
+ "@aztec/wallets": "0.0.1-commit.b8a057fa",
69
71
  "source-map-support": "^0.5.21",
70
72
  "tslib": "^2.4.0",
71
- "zod": "^3.23.8"
73
+ "viem": "npm:@aztec/viem@2.38.2",
74
+ "zod": "^4"
72
75
  },
73
76
  "devDependencies": {
74
77
  "@jest/globals": "^30.0.0",
75
78
  "@types/jest": "^30.0.0",
76
79
  "@types/node": "^22.15.17",
77
80
  "@types/source-map-support": "^0.5.10",
81
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
78
82
  "jest": "^30.0.0",
79
83
  "jest-mock-extended": "^4.0.0",
80
84
  "ts-node": "^10.9.1",
package/src/amm_bot.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { SentTx } from '@aztec/aztec.js/contracts';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
- import { 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
- import type { TestWallet } from '@aztec/test-wallet/server';
10
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
10
11
 
11
12
  import { BaseBot } from './base_bot.js';
12
13
  import type { BotConfig } from './config.js';
@@ -21,7 +22,7 @@ type Balances = { token0: bigint; token1: bigint };
21
22
  export class AmmBot extends BaseBot {
22
23
  protected constructor(
23
24
  node: AztecNode,
24
- wallet: TestWallet,
25
+ wallet: EmbeddedWallet,
25
26
  defaultAccountAddress: AztecAddress,
26
27
  public readonly amm: AMMContract,
27
28
  public readonly token0: TokenContract,
@@ -33,10 +34,11 @@ export class AmmBot extends BaseBot {
33
34
 
34
35
  static async create(
35
36
  config: BotConfig,
36
- wallet: TestWallet,
37
+ wallet: EmbeddedWallet,
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,11 +46,12 @@ 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
  }
50
53
 
51
- protected async createAndSendTx(logCtx: object): Promise<SentTx> {
54
+ protected async createAndSendTx(logCtx: object): Promise<TxHash> {
52
55
  const { feePaymentMethod } = this.config;
53
56
  const { wallet, amm, token0, token1 } = this;
54
57
 
@@ -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);
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,16 +1,12 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import {
3
- BatchCall,
4
- ContractFunctionInteraction,
5
- type SendInteractionOptions,
6
- SentTx,
7
- waitForProven,
8
- } from '@aztec/aztec.js/contracts';
2
+ import type { SendInteractionOptions } from '@aztec/aztec.js/contracts';
9
3
  import { createLogger } from '@aztec/aztec.js/log';
10
- import { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
4
+ import { waitForTx } from '@aztec/aztec.js/node';
5
+ import { TxStatus } from '@aztec/aztec.js/tx';
6
+ import type { TxHash, TxReceipt } from '@aztec/aztec.js/tx';
11
7
  import { Gas } from '@aztec/stdlib/gas';
12
8
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
13
- import type { TestWallet } from '@aztec/test-wallet/server';
9
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
14
10
 
15
11
  import type { BotConfig } from './config.js';
16
12
 
@@ -22,36 +18,27 @@ export abstract class BaseBot {
22
18
 
23
19
  protected constructor(
24
20
  public readonly node: AztecNode,
25
- public readonly wallet: TestWallet,
21
+ public readonly wallet: EmbeddedWallet,
26
22
  public readonly defaultAccountAddress: AztecAddress,
27
23
  public config: BotConfig,
28
24
  ) {}
29
25
 
30
26
  public async run(): Promise<TxReceipt | TxHash> {
31
27
  this.attempts++;
32
- const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000) };
33
28
  const { followChain, txMinedWaitSeconds } = this.config;
29
+ const logCtx = { runId: Date.now() * 1000 + Math.floor(Math.random() * 1000), followChain, txMinedWaitSeconds };
34
30
 
35
31
  this.log.verbose(`Creating tx`, logCtx);
36
- const tx = await this.createAndSendTx(logCtx);
37
-
38
- const txHash = await tx.getTxHash();
32
+ const txHash = await this.createAndSendTx(logCtx);
39
33
 
40
34
  if (followChain === 'NONE') {
41
35
  this.log.info(`Transaction ${txHash.toString()} sent, not waiting for it to be mined`);
42
36
  return txHash;
43
37
  }
44
38
 
45
- this.log.verbose(
46
- `Awaiting tx ${txHash.toString()} to be on the ${followChain} chain (timeout ${txMinedWaitSeconds}s)`,
47
- logCtx,
48
- );
49
- const receipt = await tx.wait({
50
- timeout: txMinedWaitSeconds,
51
- });
52
- if (followChain === 'PROVEN') {
53
- await waitForProven(this.node, receipt, { provenTimeout: txMinedWaitSeconds });
54
- }
39
+ const waitForStatus = TxStatus[followChain];
40
+ this.log.verbose(`Awaiting tx ${txHash.toString()} to be on the ${followChain} chain`, logCtx);
41
+ const receipt = await waitForTx(this.node, txHash, { timeout: txMinedWaitSeconds, waitForStatus });
55
42
  this.successes++;
56
43
  this.log.info(
57
44
  `Tx #${this.attempts} ${receipt.txHash} successfully mined in block ${receipt.blockNumber} (stats: ${this.successes}/${this.attempts} success)`,
@@ -63,34 +50,26 @@ export abstract class BaseBot {
63
50
  return receipt;
64
51
  }
65
52
 
66
- protected abstract createAndSendTx(logCtx: object): Promise<SentTx>;
53
+ protected abstract createAndSendTx(logCtx: object): Promise<TxHash>;
67
54
 
68
55
  protected onTxMined(_receipt: TxReceipt, _logCtx: object): Promise<void> {
69
56
  // no-op
70
57
  return Promise.resolve();
71
58
  }
72
59
 
73
- protected async getSendMethodOpts(
74
- interaction: ContractFunctionInteraction | BatchCall,
75
- ): Promise<SendInteractionOptions> {
76
- const { l2GasLimit, daGasLimit, baseFeePadding } = this.config;
77
-
78
- this.wallet.setBaseFeePadding(baseFeePadding);
79
-
80
- let gasSettings;
81
- if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
82
- gasSettings = { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) };
83
- this.log.verbose(`Using gas limits ${l2GasLimit} L2 gas ${daGasLimit} DA gas`);
84
- } else {
85
- this.log.verbose(`Estimating gas for transaction`);
86
- ({ estimatedGas: gasSettings } = await interaction.simulate({
87
- fee: { estimateGas: true },
88
- from: this.defaultAccountAddress,
89
- }));
90
- }
60
+ protected getSendMethodOpts(): SendInteractionOptions {
61
+ const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
62
+
63
+ this.wallet.setMinFeePadding(minFeePadding);
64
+
65
+ const gasSettings =
66
+ l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0
67
+ ? { gasLimits: Gas.from({ l2Gas: l2GasLimit, daGas: daGasLimit }) }
68
+ : undefined;
69
+
91
70
  return {
92
71
  from: this.defaultAccountAddress,
93
- fee: { gasSettings },
72
+ ...(gasSettings ? { fee: { gasSettings } } : {}),
94
73
  };
95
74
  }
96
75
  }
package/src/bot.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import { BatchCall, SentTx } from '@aztec/aztec.js/contracts';
2
+ import { BatchCall, NO_WAIT } from '@aztec/aztec.js/contracts';
3
+ import { TxHash } from '@aztec/aztec.js/tx';
3
4
  import { times } from '@aztec/foundation/collection';
4
5
  import type { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
5
6
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
7
+ import type { BlockTag } from '@aztec/stdlib/block';
6
8
  import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
7
- import type { TestWallet } from '@aztec/test-wallet/server';
9
+ import type { EmbeddedWallet } from '@aztec/wallets/embedded';
8
10
 
9
11
  import { BaseBot } from './base_bot.js';
10
12
  import type { BotConfig } from './config.js';
@@ -17,7 +19,7 @@ const TRANSFER_AMOUNT = 1;
17
19
  export class Bot extends BaseBot {
18
20
  protected constructor(
19
21
  node: AztecNode,
20
- wallet: TestWallet,
22
+ wallet: EmbeddedWallet,
21
23
  defaultAccountAddress: AztecAddress,
22
24
  public readonly token: TokenContract | PrivateTokenContract,
23
25
  public readonly recipient: AztecAddress,
@@ -28,10 +30,11 @@ export class Bot extends BaseBot {
28
30
 
29
31
  static async create(
30
32
  config: BotConfig,
31
- wallet: TestWallet,
33
+ wallet: EmbeddedWallet,
32
34
  aztecNode: AztecNode,
33
35
  aztecNodeAdmin: AztecNodeAdmin | undefined,
34
36
  store: BotStore,
37
+ syncChainTip?: BlockTag,
35
38
  ): Promise<Bot> {
36
39
  const { defaultAccountAddress, token, recipient } = await new BotFactory(
37
40
  config,
@@ -39,6 +42,7 @@ export class Bot extends BaseBot {
39
42
  store,
40
43
  aztecNode,
41
44
  aztecNodeAdmin,
45
+ syncChainTip,
42
46
  ).setup();
43
47
  return new Bot(aztecNode, wallet, defaultAccountAddress, token, recipient, config);
44
48
  }
@@ -48,7 +52,7 @@ export class Bot extends BaseBot {
48
52
  this.config = { ...this.config, ...config };
49
53
  }
50
54
 
51
- protected async createAndSendTx(logCtx: object): Promise<SentTx> {
55
+ protected async createAndSendTx(logCtx: object): Promise<TxHash> {
52
56
  const { privateTransfersPerTx, publicTransfersPerTx, feePaymentMethod } = this.config;
53
57
  const { token, recipient, wallet } = this;
54
58
 
@@ -69,20 +73,18 @@ export class Bot extends BaseBot {
69
73
  );
70
74
 
71
75
  const batch = new BatchCall(wallet, calls);
72
- const opts = await this.getSendMethodOpts(batch);
73
-
74
- this.log.verbose(`Simulating transaction with ${calls.length}`, logCtx);
75
- await batch.simulate({ from: this.defaultAccountAddress });
76
+ const opts = this.getSendMethodOpts();
76
77
 
77
78
  this.log.verbose(`Sending transaction`, logCtx);
78
- return batch.send(opts);
79
+ const { txHash } = await batch.send({ ...opts, wait: NO_WAIT });
80
+ return txHash;
79
81
  }
80
82
 
81
83
  public async getBalances() {
82
84
  if (isStandardTokenContract(this.token)) {
83
85
  return {
84
86
  sender: await getBalances(this.token, this.defaultAccountAddress),
85
- recipient: await getBalances(this.token, this.recipient, this.defaultAccountAddress),
87
+ recipient: await getBalances(this.token, this.recipient),
86
88
  };
87
89
  } else {
88
90
  return {
@@ -91,7 +93,7 @@ export class Bot extends BaseBot {
91
93
  publicBalance: 0n,
92
94
  },
93
95
  recipient: {
94
- privateBalance: await getPrivateBalance(this.token, this.recipient, this.defaultAccountAddress),
96
+ privateBalance: await getPrivateBalance(this.token, this.recipient),
95
97
  publicBalance: 0n,
96
98
  },
97
99
  };