@aztec/bot 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

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 (46) hide show
  1. package/dest/amm_bot.d.ts +9 -9
  2. package/dest/amm_bot.d.ts.map +1 -1
  3. package/dest/amm_bot.js +23 -20
  4. package/dest/base_bot.d.ts +11 -8
  5. package/dest/base_bot.d.ts.map +1 -1
  6. package/dest/base_bot.js +18 -18
  7. package/dest/bot.d.ts +8 -9
  8. package/dest/bot.d.ts.map +1 -1
  9. package/dest/bot.js +11 -12
  10. package/dest/config.d.ts +53 -50
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +27 -25
  13. package/dest/factory.d.ts +14 -32
  14. package/dest/factory.d.ts.map +1 -1
  15. package/dest/factory.js +137 -115
  16. package/dest/index.d.ts +2 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -0
  19. package/dest/interface.d.ts +2 -2
  20. package/dest/interface.d.ts.map +1 -1
  21. package/dest/interface.js +1 -1
  22. package/dest/rpc.d.ts +1 -1
  23. package/dest/runner.d.ts +12 -13
  24. package/dest/runner.d.ts.map +1 -1
  25. package/dest/runner.js +429 -61
  26. package/dest/store/bot_store.d.ts +44 -0
  27. package/dest/store/bot_store.d.ts.map +1 -0
  28. package/dest/store/bot_store.js +107 -0
  29. package/dest/store/index.d.ts +2 -0
  30. package/dest/store/index.d.ts.map +1 -0
  31. package/dest/store/index.js +1 -0
  32. package/dest/utils.d.ts +4 -4
  33. package/dest/utils.d.ts.map +1 -1
  34. package/dest/utils.js +5 -5
  35. package/package.json +16 -13
  36. package/src/amm_bot.ts +39 -31
  37. package/src/base_bot.ts +24 -22
  38. package/src/bot.ts +25 -14
  39. package/src/config.ts +64 -64
  40. package/src/factory.ts +172 -157
  41. package/src/index.ts +1 -0
  42. package/src/interface.ts +1 -1
  43. package/src/runner.ts +19 -23
  44. package/src/store/bot_store.ts +141 -0
  45. package/src/store/index.ts +1 -0
  46. package/src/utils.ts +10 -5
package/dest/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { Bot } from './bot.js';
2
2
  export { AmmBot } from './amm_bot.js';
3
3
  export { BotRunner } from './runner.js';
4
+ export { BotStore } from './store/bot_store.js';
4
5
  export { type BotConfig, getBotConfigFromEnv, getBotDefaultConfig, botConfigMappings, SupportedTokenContracts, } from './config.js';
5
6
  export { getBotRunnerApiHandler } from './rpc.js';
6
7
  export * from './interface.js';
7
- //# sourceMappingURL=index.d.ts.map
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBQy9CLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFDdEMsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUN4QyxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDaEQsT0FBTyxFQUNMLEtBQUssU0FBUyxFQUNkLG1CQUFtQixFQUNuQixtQkFBbUIsRUFDbkIsaUJBQWlCLEVBQ2pCLHVCQUF1QixHQUN4QixNQUFNLGFBQWEsQ0FBQztBQUNyQixPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxVQUFVLENBQUM7QUFDbEQsY0FBYyxnQkFBZ0IsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,KAAK,SAAS,EACd,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACL,KAAK,SAAS,EACd,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,cAAc,gBAAgB,CAAC"}
package/dest/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { Bot } from './bot.js';
2
2
  export { AmmBot } from './amm_bot.js';
3
3
  export { BotRunner } from './runner.js';
4
+ export { BotStore } from './store/bot_store.js';
4
5
  export { getBotConfigFromEnv, getBotDefaultConfig, botConfigMappings, SupportedTokenContracts } from './config.js';
5
6
  export { getBotRunnerApiHandler } from './rpc.js';
6
7
  export * from './interface.js';
@@ -1,4 +1,4 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
3
3
  import { z } from 'zod';
4
4
  import { type BotConfig } from './config.js';
@@ -20,4 +20,4 @@ export interface BotRunnerApi {
20
20
  update(config: BotConfig): Promise<void>;
21
21
  }
22
22
  export declare const BotRunnerApiSchema: ApiS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NQUFNLGtCQUFrQixFQUFFLFlBQVksQ0FBQyxZQUFZLENBUXpELENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,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;;;;;;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"}
package/dest/interface.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import { z } from 'zod';
3
3
  import { BotConfigSchema } from './config.js';
4
4
  export const BotInfoSchema = z.object({
package/dest/rpc.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { ApiHandler } from '@aztec/foundation/json-rpc/server';
2
2
  import type { BotRunner } from './runner.js';
3
3
  export declare function getBotRunnerApiHandler(botRunner: BotRunner): ApiHandler;
4
- //# sourceMappingURL=rpc.d.ts.map
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnBjLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcnBjLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBR3BFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUU3Qyx3QkFBZ0Isc0JBQXNCLENBQUMsU0FBUyxFQUFFLFNBQVMsR0FBRyxVQUFVLENBRXZFIn0=
package/dest/runner.d.ts CHANGED
@@ -1,26 +1,25 @@
1
- import { type AztecNode, type PXE } from '@aztec/aztec.js';
2
- import { type AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
3
3
  import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
4
- import { type BotConfig } from './config.js';
4
+ import type { TestWallet } from '@aztec/test-wallet/server';
5
+ import type { BotConfig } from './config.js';
5
6
  import type { BotInfo, BotRunnerApi } from './interface.js';
7
+ import { BotStore } from './store/index.js';
6
8
  export declare class BotRunner implements BotRunnerApi, Traceable {
7
9
  #private;
8
10
  private config;
11
+ private readonly wallet;
12
+ private readonly aztecNode;
13
+ private readonly telemetry;
14
+ private readonly aztecNodeAdmin;
15
+ private readonly store;
9
16
  private log;
10
17
  private bot?;
11
- private pxe?;
12
- private node;
13
- private nodeAdmin?;
14
18
  private runningPromise;
15
19
  private consecutiveErrors;
16
20
  private healthy;
17
21
  readonly tracer: Tracer;
18
- constructor(config: BotConfig, dependencies: {
19
- pxe?: PXE;
20
- node?: AztecNode;
21
- nodeAdmin?: AztecNodeAdmin;
22
- telemetry: TelemetryClient;
23
- });
22
+ constructor(config: BotConfig, wallet: TestWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin: AztecNodeAdmin | undefined, store: BotStore);
24
23
  /** Initializes the bot if needed. Blocks until the bot setup is finished. */
25
24
  setup(): Promise<void>;
26
25
  private doSetup;
@@ -51,4 +50,4 @@ export declare class BotRunner implements BotRunnerApi, Traceable {
51
50
  /** Returns the bot sender address. */
52
51
  getInfo(): Promise<BotInfo>;
53
52
  }
54
- //# sourceMappingURL=runner.d.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F"}
package/dest/runner.js CHANGED
@@ -1,46 +1,443 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1
+ function applyDecs2203RFactory() {
2
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
3
+ return function addInitializer(initializer) {
4
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
5
+ assertCallable(initializer, "An initializer");
6
+ initializers.push(initializer);
7
+ };
8
+ }
9
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
10
+ var kindStr;
11
+ switch(kind){
12
+ case 1:
13
+ kindStr = "accessor";
14
+ break;
15
+ case 2:
16
+ kindStr = "method";
17
+ break;
18
+ case 3:
19
+ kindStr = "getter";
20
+ break;
21
+ case 4:
22
+ kindStr = "setter";
23
+ break;
24
+ default:
25
+ kindStr = "field";
26
+ }
27
+ var ctx = {
28
+ kind: kindStr,
29
+ name: isPrivate ? "#" + name : name,
30
+ static: isStatic,
31
+ private: isPrivate,
32
+ metadata: metadata
33
+ };
34
+ var decoratorFinishedRef = {
35
+ v: false
36
+ };
37
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
38
+ var get, set;
39
+ if (kind === 0) {
40
+ if (isPrivate) {
41
+ get = desc.get;
42
+ set = desc.set;
43
+ } else {
44
+ get = function() {
45
+ return this[name];
46
+ };
47
+ set = function(v) {
48
+ this[name] = v;
49
+ };
50
+ }
51
+ } else if (kind === 2) {
52
+ get = function() {
53
+ return desc.value;
54
+ };
55
+ } else {
56
+ if (kind === 1 || kind === 3) {
57
+ get = function() {
58
+ return desc.get.call(this);
59
+ };
60
+ }
61
+ if (kind === 1 || kind === 4) {
62
+ set = function(v) {
63
+ desc.set.call(this, v);
64
+ };
65
+ }
66
+ }
67
+ ctx.access = get && set ? {
68
+ get: get,
69
+ set: set
70
+ } : get ? {
71
+ get: get
72
+ } : {
73
+ set: set
74
+ };
75
+ try {
76
+ return dec(value, ctx);
77
+ } finally{
78
+ decoratorFinishedRef.v = true;
79
+ }
80
+ }
81
+ function assertNotFinished(decoratorFinishedRef, fnName) {
82
+ if (decoratorFinishedRef.v) {
83
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
84
+ }
85
+ }
86
+ function assertCallable(fn, hint) {
87
+ if (typeof fn !== "function") {
88
+ throw new TypeError(hint + " must be a function");
89
+ }
90
+ }
91
+ function assertValidReturnValue(kind, value) {
92
+ var type = typeof value;
93
+ if (kind === 1) {
94
+ if (type !== "object" || value === null) {
95
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
96
+ }
97
+ if (value.get !== undefined) {
98
+ assertCallable(value.get, "accessor.get");
99
+ }
100
+ if (value.set !== undefined) {
101
+ assertCallable(value.set, "accessor.set");
102
+ }
103
+ if (value.init !== undefined) {
104
+ assertCallable(value.init, "accessor.init");
105
+ }
106
+ } else if (type !== "function") {
107
+ var hint;
108
+ if (kind === 0) {
109
+ hint = "field";
110
+ } else if (kind === 10) {
111
+ hint = "class";
112
+ } else {
113
+ hint = "method";
114
+ }
115
+ throw new TypeError(hint + " decorators must return a function or void 0");
116
+ }
117
+ }
118
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
119
+ var decs = decInfo[0];
120
+ var desc, init, value;
121
+ if (isPrivate) {
122
+ if (kind === 0 || kind === 1) {
123
+ desc = {
124
+ get: decInfo[3],
125
+ set: decInfo[4]
126
+ };
127
+ } else if (kind === 3) {
128
+ desc = {
129
+ get: decInfo[3]
130
+ };
131
+ } else if (kind === 4) {
132
+ desc = {
133
+ set: decInfo[3]
134
+ };
135
+ } else {
136
+ desc = {
137
+ value: decInfo[3]
138
+ };
139
+ }
140
+ } else if (kind !== 0) {
141
+ desc = Object.getOwnPropertyDescriptor(base, name);
142
+ }
143
+ if (kind === 1) {
144
+ value = {
145
+ get: desc.get,
146
+ set: desc.set
147
+ };
148
+ } else if (kind === 2) {
149
+ value = desc.value;
150
+ } else if (kind === 3) {
151
+ value = desc.get;
152
+ } else if (kind === 4) {
153
+ value = desc.set;
154
+ }
155
+ var newValue, get, set;
156
+ if (typeof decs === "function") {
157
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
158
+ if (newValue !== void 0) {
159
+ assertValidReturnValue(kind, newValue);
160
+ if (kind === 0) {
161
+ init = newValue;
162
+ } else if (kind === 1) {
163
+ init = newValue.init;
164
+ get = newValue.get || value.get;
165
+ set = newValue.set || value.set;
166
+ value = {
167
+ get: get,
168
+ set: set
169
+ };
170
+ } else {
171
+ value = newValue;
172
+ }
173
+ }
174
+ } else {
175
+ for(var i = decs.length - 1; i >= 0; i--){
176
+ var dec = decs[i];
177
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
178
+ if (newValue !== void 0) {
179
+ assertValidReturnValue(kind, newValue);
180
+ var newInit;
181
+ if (kind === 0) {
182
+ newInit = newValue;
183
+ } else if (kind === 1) {
184
+ newInit = newValue.init;
185
+ get = newValue.get || value.get;
186
+ set = newValue.set || value.set;
187
+ value = {
188
+ get: get,
189
+ set: set
190
+ };
191
+ } else {
192
+ value = newValue;
193
+ }
194
+ if (newInit !== void 0) {
195
+ if (init === void 0) {
196
+ init = newInit;
197
+ } else if (typeof init === "function") {
198
+ init = [
199
+ init,
200
+ newInit
201
+ ];
202
+ } else {
203
+ init.push(newInit);
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (kind === 0 || kind === 1) {
210
+ if (init === void 0) {
211
+ init = function(instance, init) {
212
+ return init;
213
+ };
214
+ } else if (typeof init !== "function") {
215
+ var ownInitializers = init;
216
+ init = function(instance, init) {
217
+ var value = init;
218
+ for(var i = 0; i < ownInitializers.length; i++){
219
+ value = ownInitializers[i].call(instance, value);
220
+ }
221
+ return value;
222
+ };
223
+ } else {
224
+ var originalInitializer = init;
225
+ init = function(instance, init) {
226
+ return originalInitializer.call(instance, init);
227
+ };
228
+ }
229
+ ret.push(init);
230
+ }
231
+ if (kind !== 0) {
232
+ if (kind === 1) {
233
+ desc.get = value.get;
234
+ desc.set = value.set;
235
+ } else if (kind === 2) {
236
+ desc.value = value;
237
+ } else if (kind === 3) {
238
+ desc.get = value;
239
+ } else if (kind === 4) {
240
+ desc.set = value;
241
+ }
242
+ if (isPrivate) {
243
+ if (kind === 1) {
244
+ ret.push(function(instance, args) {
245
+ return value.get.call(instance, args);
246
+ });
247
+ ret.push(function(instance, args) {
248
+ return value.set.call(instance, args);
249
+ });
250
+ } else if (kind === 2) {
251
+ ret.push(value);
252
+ } else {
253
+ ret.push(function(instance, args) {
254
+ return value.call(instance, args);
255
+ });
256
+ }
257
+ } else {
258
+ Object.defineProperty(base, name, desc);
259
+ }
260
+ }
261
+ }
262
+ function applyMemberDecs(Class, decInfos, metadata) {
263
+ var ret = [];
264
+ var protoInitializers;
265
+ var staticInitializers;
266
+ var existingProtoNonFields = new Map();
267
+ var existingStaticNonFields = new Map();
268
+ for(var i = 0; i < decInfos.length; i++){
269
+ var decInfo = decInfos[i];
270
+ if (!Array.isArray(decInfo)) continue;
271
+ var kind = decInfo[1];
272
+ var name = decInfo[2];
273
+ var isPrivate = decInfo.length > 3;
274
+ var isStatic = kind >= 5;
275
+ var base;
276
+ var initializers;
277
+ if (isStatic) {
278
+ base = Class;
279
+ kind = kind - 5;
280
+ staticInitializers = staticInitializers || [];
281
+ initializers = staticInitializers;
282
+ } else {
283
+ base = Class.prototype;
284
+ protoInitializers = protoInitializers || [];
285
+ initializers = protoInitializers;
286
+ }
287
+ if (kind !== 0 && !isPrivate) {
288
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
289
+ var existingKind = existingNonFields.get(name) || 0;
290
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
291
+ throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
292
+ } else if (!existingKind && kind > 2) {
293
+ existingNonFields.set(name, kind);
294
+ } else {
295
+ existingNonFields.set(name, true);
296
+ }
297
+ }
298
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
299
+ }
300
+ pushInitializers(ret, protoInitializers);
301
+ pushInitializers(ret, staticInitializers);
302
+ return ret;
303
+ }
304
+ function pushInitializers(ret, initializers) {
305
+ if (initializers) {
306
+ ret.push(function(instance) {
307
+ for(var i = 0; i < initializers.length; i++){
308
+ initializers[i].call(instance);
309
+ }
310
+ return instance;
311
+ });
312
+ }
313
+ }
314
+ function applyClassDecs(targetClass, classDecs, metadata) {
315
+ if (classDecs.length > 0) {
316
+ var initializers = [];
317
+ var newClass = targetClass;
318
+ var name = targetClass.name;
319
+ for(var i = classDecs.length - 1; i >= 0; i--){
320
+ var decoratorFinishedRef = {
321
+ v: false
322
+ };
323
+ try {
324
+ var nextNewClass = classDecs[i](newClass, {
325
+ kind: "class",
326
+ name: name,
327
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
328
+ metadata
329
+ });
330
+ } finally{
331
+ decoratorFinishedRef.v = true;
332
+ }
333
+ if (nextNewClass !== undefined) {
334
+ assertValidReturnValue(10, nextNewClass);
335
+ newClass = nextNewClass;
336
+ }
337
+ }
338
+ return [
339
+ defineMetadata(newClass, metadata),
340
+ function() {
341
+ for(var i = 0; i < initializers.length; i++){
342
+ initializers[i].call(newClass);
343
+ }
344
+ }
345
+ ];
346
+ }
347
+ }
348
+ function defineMetadata(Class, metadata) {
349
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
350
+ configurable: true,
351
+ enumerable: true,
352
+ value: metadata
353
+ });
354
+ }
355
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
356
+ if (parentClass !== void 0) {
357
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
358
+ }
359
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
360
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
361
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
362
+ return {
363
+ e: e,
364
+ get c () {
365
+ return applyClassDecs(targetClass, classDecs, metadata);
366
+ }
367
+ };
368
+ };
6
369
  }
7
- import { createAztecNodeClient, createLogger } from '@aztec/aztec.js';
370
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
371
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
372
+ }
373
+ var _dec, _dec1, _call_work, _initProto;
374
+ import { createLogger } from '@aztec/aztec.js/log';
8
375
  import { omit } from '@aztec/foundation/collection';
9
376
  import { RunningPromise } from '@aztec/foundation/running-promise';
10
- import { createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client';
11
- import { makeTracedFetch, trackSpan } from '@aztec/telemetry-client';
377
+ import { trackSpan } from '@aztec/telemetry-client';
12
378
  import { AmmBot } from './amm_bot.js';
13
379
  import { Bot } from './bot.js';
14
- import { getVersions } from './config.js';
380
+ _dec = trackSpan('Bot.setup'), _dec1 = trackSpan('Bot.work');
15
381
  export class BotRunner {
16
382
  config;
383
+ wallet;
384
+ aztecNode;
385
+ telemetry;
386
+ aztecNodeAdmin;
387
+ store;
388
+ static{
389
+ ({ e: [_call_work, _initProto] } = _apply_decs_2203_r(this, [
390
+ [
391
+ _dec,
392
+ 2,
393
+ "doSetup"
394
+ ],
395
+ [
396
+ _dec1,
397
+ 2,
398
+ "work",
399
+ async function() {
400
+ if (this.config.maxPendingTxs > 0) {
401
+ const pendingTxCount = await this.aztecNode.getPendingTxCount();
402
+ if (pendingTxCount >= this.config.maxPendingTxs) {
403
+ this.log.verbose(`Not sending bot tx since node has ${pendingTxCount} pending txs`);
404
+ return;
405
+ }
406
+ }
407
+ try {
408
+ await this.run();
409
+ } catch {
410
+ // Already logged in run()
411
+ if (this.config.maxConsecutiveErrors > 0 && this.consecutiveErrors >= this.config.maxConsecutiveErrors) {
412
+ this.log.error(`Too many errors bot is unhealthy`);
413
+ this.healthy = false;
414
+ }
415
+ }
416
+ if (!this.healthy && this.config.stopWhenUnhealthy) {
417
+ this.log.fatal(`Stopping bot due to errors`);
418
+ process.exit(1); // workaround docker not restarting the container if its unhealthy. We have to exit instead
419
+ }
420
+ }
421
+ ]
422
+ ], []));
423
+ }
17
424
  log;
18
425
  bot;
19
- pxe;
20
- node;
21
- nodeAdmin;
22
426
  runningPromise;
23
427
  consecutiveErrors;
24
428
  healthy;
25
429
  tracer;
26
- constructor(config, dependencies){
430
+ constructor(config, wallet, aztecNode, telemetry, aztecNodeAdmin, store){
27
431
  this.config = config;
28
- this.log = createLogger('bot');
432
+ this.wallet = wallet;
433
+ this.aztecNode = aztecNode;
434
+ this.telemetry = telemetry;
435
+ this.aztecNodeAdmin = aztecNodeAdmin;
436
+ this.store = store;
437
+ this.log = (_initProto(this), createLogger('bot'));
29
438
  this.consecutiveErrors = 0;
30
439
  this.healthy = true;
31
- this.tracer = dependencies.telemetry.getTracer('Bot');
32
- this.pxe = dependencies.pxe;
33
- if (!dependencies.node && !config.nodeUrl) {
34
- throw new Error(`Missing node URL in config or dependencies`);
35
- }
36
- const versions = getVersions();
37
- const fetch = makeTracedFetch([
38
- 1,
39
- 2,
40
- 3
41
- ], true);
42
- this.node = dependencies.node ?? createAztecNodeClient(config.nodeUrl, versions, fetch);
43
- this.nodeAdmin = dependencies.nodeAdmin ?? (config.nodeAdminUrl ? createAztecNodeAdminClient(config.nodeAdminUrl, versions, fetch) : undefined);
440
+ this.tracer = telemetry.getTracer('Bot');
44
441
  this.runningPromise = new RunningPromise(()=>this.#work(), this.log, config.txIntervalSeconds * 1000);
45
442
  }
46
443
  /** Initializes the bot if needed. Blocks until the bot setup is finished. */ async setup() {
@@ -70,6 +467,7 @@ export class BotRunner {
70
467
  this.log.verbose(`Stopping bot`);
71
468
  await this.runningPromise.stop();
72
469
  }
470
+ await this.store.close();
73
471
  this.log.info(`Stopped bot`);
74
472
  }
75
473
  isHealthy() {
@@ -130,51 +528,21 @@ export class BotRunner {
130
528
  if (!this.bot) {
131
529
  throw new Error(`Bot is not initialized`);
132
530
  }
133
- const botAddress = await this.bot.then((b)=>b.wallet.getAddress());
531
+ const botAddress = await this.bot.then((b)=>b.defaultAccountAddress);
134
532
  return {
135
533
  botAddress
136
534
  };
137
535
  }
138
536
  async #createBot() {
139
537
  try {
140
- this.bot = this.config.ammTxs ? AmmBot.create(this.config, {
141
- pxe: this.pxe,
142
- node: this.node,
143
- nodeAdmin: this.nodeAdmin
144
- }) : Bot.create(this.config, {
145
- pxe: this.pxe,
146
- node: this.node,
147
- nodeAdmin: this.nodeAdmin
148
- });
538
+ this.bot = this.config.ammTxs ? AmmBot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store) : Bot.create(this.config, this.wallet, this.aztecNode, this.aztecNodeAdmin, this.store);
149
539
  await this.bot;
150
540
  } catch (err) {
151
541
  this.log.error(`Error setting up bot: ${err}`);
152
542
  throw err;
153
543
  }
154
544
  }
155
- async #work() {
156
- if (this.config.maxPendingTxs > 0) {
157
- const pendingTxCount = await this.node.getPendingTxCount();
158
- if (pendingTxCount >= this.config.maxPendingTxs) {
159
- this.log.verbose(`Not sending bot tx since node has ${pendingTxCount} pending txs`);
160
- return;
161
- }
162
- }
163
- try {
164
- await this.run();
165
- } catch {
166
- // Already logged in run()
167
- if (this.config.maxConsecutiveErrors > 0 && this.consecutiveErrors >= this.config.maxConsecutiveErrors) {
168
- this.log.error(`Too many errors bot is unhealthy`);
169
- this.healthy = false;
170
- }
171
- }
172
- if (!this.healthy && this.config.stopWhenUnhealthy) {
173
- this.log.fatal(`Stopping bot due to errors`);
174
- process.exit(1); // workaround docker not restarting the container if its unhealthy. We have to exit instead
175
- }
545
+ get #work() {
546
+ return _call_work;
176
547
  }
177
548
  }
178
- _ts_decorate([
179
- trackSpan('Bot.setup')
180
- ], BotRunner.prototype, "doSetup", null);