@aztec/bot 0.0.1-commit.d3ec352c → 0.0.1-commit.d431d1c
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/dest/base_bot.js +2 -2
- package/dest/config.d.ts +11 -12
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +7 -7
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +21 -10
- package/dest/runner.js +412 -30
- package/dest/store/bot_store.d.ts +2 -2
- package/dest/store/bot_store.d.ts.map +1 -1
- package/dest/store/bot_store.js +1 -1
- package/package.json +14 -14
- package/src/base_bot.ts +2 -2
- package/src/config.ts +52 -50
- package/src/factory.ts +23 -10
- package/src/store/bot_store.ts +1 -1
package/dest/base_bot.js
CHANGED
|
@@ -50,8 +50,8 @@ export class BaseBot {
|
|
|
50
50
|
return Promise.resolve();
|
|
51
51
|
}
|
|
52
52
|
async getSendMethodOpts(interaction) {
|
|
53
|
-
const { l2GasLimit, daGasLimit,
|
|
54
|
-
this.wallet.
|
|
53
|
+
const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
|
|
54
|
+
this.wallet.setMinFeePadding(minFeePadding);
|
|
55
55
|
let gasSettings;
|
|
56
56
|
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
|
57
57
|
gasSettings = {
|
package/dest/config.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ConfigMappingsType, SecretValue } from '@aztec/foundation/config';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
|
-
import { type ZodFor } from '@aztec/stdlib/schemas';
|
|
5
4
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
6
5
|
import { z } from 'zod';
|
|
7
6
|
declare const BotFollowChain: readonly ["NONE", "PENDING", "PROVEN"];
|
|
@@ -37,8 +36,8 @@ export type BotConfig = {
|
|
|
37
36
|
publicTransfersPerTx: number;
|
|
38
37
|
/** How to handle fee payments. */
|
|
39
38
|
feePaymentMethod: 'fee_juice';
|
|
40
|
-
/** 'How much is the bot willing to overpay vs. the current
|
|
41
|
-
|
|
39
|
+
/** 'How much is the bot willing to overpay vs. the current min fee' */
|
|
40
|
+
minFeePadding: number;
|
|
42
41
|
/** True to not automatically setup or start the bot on initialization. */
|
|
43
42
|
noStart: boolean;
|
|
44
43
|
/** How long to wait for a tx to be mined before reporting an error. */
|
|
@@ -70,13 +69,13 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
70
69
|
l1PrivateKey: z.ZodOptional<z.ZodType<SecretValue<string>, any, any>>;
|
|
71
70
|
l1ToL2MessageTimeoutSeconds: z.ZodNumber;
|
|
72
71
|
senderPrivateKey: z.ZodOptional<z.ZodType<SecretValue<Fr>, any, any>>;
|
|
73
|
-
senderSalt: z.ZodOptional<ZodFor<Fr>>;
|
|
74
|
-
tokenSalt: ZodFor<Fr>;
|
|
72
|
+
senderSalt: z.ZodOptional<import("@aztec/stdlib/schemas").ZodFor<Fr>>;
|
|
73
|
+
tokenSalt: import("@aztec/stdlib/schemas").ZodFor<Fr>;
|
|
75
74
|
txIntervalSeconds: z.ZodNumber;
|
|
76
75
|
privateTransfersPerTx: z.ZodNumber;
|
|
77
76
|
publicTransfersPerTx: z.ZodNumber;
|
|
78
77
|
feePaymentMethod: z.ZodLiteral<"fee_juice">;
|
|
79
|
-
|
|
78
|
+
minFeePadding: z.ZodNumber;
|
|
80
79
|
noStart: z.ZodBoolean;
|
|
81
80
|
txMinedWaitSeconds: z.ZodNumber;
|
|
82
81
|
followChain: z.ZodEnum<["NONE", "PENDING", "PROVEN"]>;
|
|
@@ -104,7 +103,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
104
103
|
privateTransfersPerTx: number;
|
|
105
104
|
publicTransfersPerTx: number;
|
|
106
105
|
feePaymentMethod: "fee_juice";
|
|
107
|
-
|
|
106
|
+
minFeePadding: number;
|
|
108
107
|
noStart: boolean;
|
|
109
108
|
txMinedWaitSeconds: number;
|
|
110
109
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -132,7 +131,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
132
131
|
privateTransfersPerTx: number;
|
|
133
132
|
publicTransfersPerTx: number;
|
|
134
133
|
feePaymentMethod: "fee_juice";
|
|
135
|
-
|
|
134
|
+
minFeePadding: number;
|
|
136
135
|
noStart: boolean;
|
|
137
136
|
txMinedWaitSeconds: number;
|
|
138
137
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -153,7 +152,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
153
152
|
privateTransfersPerTx: number;
|
|
154
153
|
publicTransfersPerTx: number;
|
|
155
154
|
feePaymentMethod: "fee_juice";
|
|
156
|
-
|
|
155
|
+
minFeePadding: number;
|
|
157
156
|
noStart: boolean;
|
|
158
157
|
txMinedWaitSeconds: number;
|
|
159
158
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -188,7 +187,7 @@ export declare const BotConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
188
187
|
privateTransfersPerTx: number;
|
|
189
188
|
publicTransfersPerTx: number;
|
|
190
189
|
feePaymentMethod: "fee_juice";
|
|
191
|
-
|
|
190
|
+
minFeePadding: number;
|
|
192
191
|
noStart: boolean;
|
|
193
192
|
txMinedWaitSeconds: number;
|
|
194
193
|
followChain: "NONE" | "PENDING" | "PROVEN";
|
|
@@ -208,4 +207,4 @@ export declare function getBotConfigFromEnv(): BotConfig;
|
|
|
208
207
|
export declare function getBotDefaultConfig(): BotConfig;
|
|
209
208
|
export declare function getVersions(): Partial<ComponentsVersions>;
|
|
210
209
|
export {};
|
|
211
|
-
//# sourceMappingURL=data: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AW,CAAC;IAC9B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,WAAW,EAAE,cAAc,CAAC;IAC5B,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,sBAAsB,EAAE,OAAO,CAAC;IAChC,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,+EAA+E;IAC/E,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4BAA4B;IAC5B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,yEAAyE;IACzE,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,iBAAiB,EAAE,OAAO,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6C3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CA+I3D,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKzD"}
|
package/dest/config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { booleanConfigHelper, getConfigFromMappings, getDefaultConfig, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretFrConfigHelper, secretStringConfigHelper } from '@aztec/foundation/config';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
4
4
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
5
5
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
6
|
-
import { schemas } from '@aztec/stdlib/schemas';
|
|
6
|
+
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
const BotFollowChain = [
|
|
9
9
|
'NONE',
|
|
@@ -15,7 +15,7 @@ export var SupportedTokenContracts = /*#__PURE__*/ function(SupportedTokenContra
|
|
|
15
15
|
SupportedTokenContracts["PrivateTokenContract"] = "PrivateTokenContract";
|
|
16
16
|
return SupportedTokenContracts;
|
|
17
17
|
}({});
|
|
18
|
-
export const BotConfigSchema = z.object({
|
|
18
|
+
export const BotConfigSchema = zodFor()(z.object({
|
|
19
19
|
nodeUrl: z.string().optional(),
|
|
20
20
|
nodeAdminUrl: z.string().optional(),
|
|
21
21
|
l1RpcUrls: z.array(z.string()).optional(),
|
|
@@ -29,7 +29,7 @@ export const BotConfigSchema = z.object({
|
|
|
29
29
|
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
30
30
|
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
31
31
|
feePaymentMethod: z.literal('fee_juice'),
|
|
32
|
-
|
|
32
|
+
minFeePadding: z.number().int().nonnegative(),
|
|
33
33
|
noStart: z.boolean(),
|
|
34
34
|
txMinedWaitSeconds: z.number(),
|
|
35
35
|
followChain: z.enum(BotFollowChain),
|
|
@@ -56,7 +56,7 @@ export const BotConfigSchema = z.object({
|
|
|
56
56
|
dataDirectory: undefined,
|
|
57
57
|
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
58
58
|
...config
|
|
59
|
-
}));
|
|
59
|
+
})));
|
|
60
60
|
export const botConfigMappings = {
|
|
61
61
|
nodeUrl: {
|
|
62
62
|
env: 'AZTEC_NODE_URL',
|
|
@@ -123,8 +123,8 @@ export const botConfigMappings = {
|
|
|
123
123
|
parseEnv: (val)=>val || undefined,
|
|
124
124
|
defaultValue: 'fee_juice'
|
|
125
125
|
},
|
|
126
|
-
|
|
127
|
-
env: '
|
|
126
|
+
minFeePadding: {
|
|
127
|
+
env: 'BOT_MIN_FEE_PADDING',
|
|
128
128
|
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
129
129
|
...numberConfigHelper(3)
|
|
130
130
|
},
|
package/dest/factory.d.ts
CHANGED
|
@@ -51,4 +51,4 @@ export declare class BotFactory {
|
|
|
51
51
|
private bridgeL1FeeJuice;
|
|
52
52
|
private withNoMinTxsPerBlock;
|
|
53
53
|
}
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBa0J6RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDM0QsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFDN0UsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRy9ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxjQUFjLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFFdkQsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUEyQixNQUFNL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sWUFBWTtZQVdaLDBCQUEwQjtZQXdDMUIsZ0JBQWdCO1lBZ0JoQixVQUFVO0lBd0N4Qjs7OztPQUlHO0lBQ0gsT0FBTyxDQUFDLGtCQUFrQjtZQVlaLGdCQUFnQjtZQW9CaEIsT0FBTztZQThFUCx3QkFBd0I7WUF1QnhCLFVBQVU7WUF3Q1Ysc0JBQXNCO1lBNEJ0QixnQkFBZ0I7WUFnQ2hCLG9CQUFvQjtDQWVuQyJ9
|
package/dest/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAkBzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMjD,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAPlC,OAAO,CAAC,GAAG,CAAuB;IAElC,YACmB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,4BAAgB,EAC9C;IAEJ;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC;QAC5B,MAAM,EAAE,UAAU,CAAC;QACnB,qBAAqB,EAAE,YAAY,CAAC;QACpC,KAAK,EAAE,aAAa,GAAG,oBAAoB,CAAC;QAC5C,IAAI,EAAE,SAAS,CAAC;QAChB,SAAS,EAAE,YAAY,CAAC;KACzB,CAAC,CAMD;IAEY,QAAQ,IAAI,OAAO,CAAC;QAC/B,MAAM,EAAE,UAAU,CAAC;QACnB,qBAAqB,EAAE,YAAY,CAAC;QACpC,GAAG,EAAE,WAAW,CAAC;QACjB,MAAM,EAAE,aAAa,CAAC;QACtB,MAAM,EAAE,aAAa,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC;KACjB,CAAC,CAsBD;YAMa,YAAY;YAWZ,0BAA0B;YAwC1B,gBAAgB;YAgBhB,UAAU;IAwCxB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;YAYZ,gBAAgB;YAoBhB,OAAO;YA8EP,wBAAwB;YAuBxB,UAAU;YAwCV,sBAAsB;YA4BtB,gBAAgB;YAgChB,oBAAoB;CAenC"}
|
package/dest/factory.js
CHANGED
|
@@ -4,10 +4,12 @@ import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
|
4
4
|
import { BatchCall } from '@aztec/aztec.js/contracts';
|
|
5
5
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
6
6
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
7
|
+
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
7
8
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
8
9
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
9
|
-
import { createEthereumChain
|
|
10
|
-
import {
|
|
10
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
13
|
import { Timer } from '@aztec/foundation/timer';
|
|
12
14
|
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
13
15
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
@@ -37,8 +39,8 @@ export class BotFactory {
|
|
|
37
39
|
* Initializes a new bot by setting up the sender account, registering the recipient,
|
|
38
40
|
* deploying the token contract, and minting tokens if necessary.
|
|
39
41
|
*/ async setup() {
|
|
40
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
41
42
|
const defaultAccountAddress = await this.setupAccount();
|
|
43
|
+
const recipient = (await this.wallet.createAccount()).address;
|
|
42
44
|
const token = await this.setupToken(defaultAccountAddress);
|
|
43
45
|
await this.mintTokens(token, defaultAccountAddress);
|
|
44
46
|
return {
|
|
@@ -88,8 +90,8 @@ export class BotFactory {
|
|
|
88
90
|
contract: new SchnorrAccountContract(signingKey)
|
|
89
91
|
};
|
|
90
92
|
const accountManager = await this.wallet.createAccount(accountData);
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
94
|
+
if (metadata.isContractInitialized) {
|
|
93
95
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
94
96
|
const timer = new Timer();
|
|
95
97
|
const address = accountManager.address;
|
|
@@ -102,7 +104,7 @@ export class BotFactory {
|
|
|
102
104
|
const claim = await this.getOrCreateBridgeClaim(address);
|
|
103
105
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
104
106
|
const deployMethod = await accountManager.getDeployMethod();
|
|
105
|
-
const maxFeesPerGas = (await this.aztecNode.
|
|
107
|
+
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
106
108
|
const gasSettings = GasSettings.default({
|
|
107
109
|
maxFeesPerGas
|
|
108
110
|
});
|
|
@@ -140,6 +142,7 @@ export class BotFactory {
|
|
|
140
142
|
* @returns The TokenContract instance.
|
|
141
143
|
*/ async setupToken(sender) {
|
|
142
144
|
let deploy;
|
|
145
|
+
let tokenInstance;
|
|
143
146
|
const deployOpts = {
|
|
144
147
|
from: sender,
|
|
145
148
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -148,15 +151,22 @@ export class BotFactory {
|
|
|
148
151
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
149
152
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
150
153
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
151
|
-
|
|
154
|
+
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
155
|
+
const tokenSecretKey = Fr.random();
|
|
156
|
+
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
157
|
+
deploy = PrivateTokenContract.deployWithPublicKeys(tokenPublicKeys, this.wallet, MINT_BALANCE, sender);
|
|
152
158
|
deployOpts.skipInstancePublication = true;
|
|
153
159
|
deployOpts.skipClassPublication = true;
|
|
154
160
|
deployOpts.skipInitialization = false;
|
|
161
|
+
// Register the contract with the secret key before deployment
|
|
162
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
163
|
+
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
155
164
|
} else {
|
|
156
165
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
157
166
|
}
|
|
158
|
-
const address = (await deploy.getInstance(deployOpts)).address;
|
|
159
|
-
|
|
167
|
+
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
168
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
169
|
+
if (metadata.isContractPublished) {
|
|
160
170
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
161
171
|
return deploy.register();
|
|
162
172
|
} else {
|
|
@@ -257,7 +267,8 @@ export class BotFactory {
|
|
|
257
267
|
}
|
|
258
268
|
async registerOrDeployContract(name, deploy, deployOpts) {
|
|
259
269
|
const address = (await deploy.getInstance(deployOpts)).address;
|
|
260
|
-
|
|
270
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
271
|
+
if (metadata.isContractPublished) {
|
|
261
272
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
262
273
|
return deploy.register();
|
|
263
274
|
} else {
|
package/dest/runner.js
CHANGED
|
@@ -1,15 +1,383 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
6
372
|
}
|
|
373
|
+
var _dec, _dec1, _call_work, _initProto;
|
|
7
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
377
|
import { trackSpan } from '@aztec/telemetry-client';
|
|
11
378
|
import { AmmBot } from './amm_bot.js';
|
|
12
379
|
import { Bot } from './bot.js';
|
|
380
|
+
_dec = trackSpan('Bot.setup'), _dec1 = trackSpan('Bot.work');
|
|
13
381
|
export class BotRunner {
|
|
14
382
|
config;
|
|
15
383
|
wallet;
|
|
@@ -17,6 +385,42 @@ export class BotRunner {
|
|
|
17
385
|
telemetry;
|
|
18
386
|
aztecNodeAdmin;
|
|
19
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
|
+
}
|
|
20
424
|
log;
|
|
21
425
|
bot;
|
|
22
426
|
runningPromise;
|
|
@@ -30,7 +434,7 @@ export class BotRunner {
|
|
|
30
434
|
this.telemetry = telemetry;
|
|
31
435
|
this.aztecNodeAdmin = aztecNodeAdmin;
|
|
32
436
|
this.store = store;
|
|
33
|
-
this.log = createLogger('bot');
|
|
437
|
+
this.log = (_initProto(this), createLogger('bot'));
|
|
34
438
|
this.consecutiveErrors = 0;
|
|
35
439
|
this.healthy = true;
|
|
36
440
|
this.tracer = telemetry.getTracer('Bot');
|
|
@@ -138,29 +542,7 @@ export class BotRunner {
|
|
|
138
542
|
throw err;
|
|
139
543
|
}
|
|
140
544
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const pendingTxCount = await this.aztecNode.getPendingTxCount();
|
|
144
|
-
if (pendingTxCount >= this.config.maxPendingTxs) {
|
|
145
|
-
this.log.verbose(`Not sending bot tx since node has ${pendingTxCount} pending txs`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
await this.run();
|
|
151
|
-
} catch {
|
|
152
|
-
// Already logged in run()
|
|
153
|
-
if (this.config.maxConsecutiveErrors > 0 && this.consecutiveErrors >= this.config.maxConsecutiveErrors) {
|
|
154
|
-
this.log.error(`Too many errors bot is unhealthy`);
|
|
155
|
-
this.healthy = false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (!this.healthy && this.config.stopWhenUnhealthy) {
|
|
159
|
-
this.log.fatal(`Stopping bot due to errors`);
|
|
160
|
-
process.exit(1); // workaround docker not restarting the container if its unhealthy. We have to exit instead
|
|
161
|
-
}
|
|
545
|
+
get #work() {
|
|
546
|
+
return _call_work;
|
|
162
547
|
}
|
|
163
548
|
}
|
|
164
|
-
_ts_decorate([
|
|
165
|
-
trackSpan('Bot.setup')
|
|
166
|
-
], BotRunner.prototype, "doSetup", null);
|
|
@@ -13,7 +13,7 @@ export interface BridgeClaimData {
|
|
|
13
13
|
export declare class BotStore {
|
|
14
14
|
private readonly store;
|
|
15
15
|
private readonly log;
|
|
16
|
-
static readonly SCHEMA_VERSION
|
|
16
|
+
static readonly SCHEMA_VERSION = 1;
|
|
17
17
|
private readonly bridgeClaims;
|
|
18
18
|
constructor(store: AztecAsyncKVStore, log?: Logger);
|
|
19
19
|
/**
|
|
@@ -41,4 +41,4 @@ export declare class BotStore {
|
|
|
41
41
|
*/
|
|
42
42
|
close(): Promise<void>;
|
|
43
43
|
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm90X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmUvYm90X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFFeEUsTUFBTSxXQUFXLGVBQWU7SUFDOUIsS0FBSyxFQUFFLGFBQWEsQ0FBQztJQUNyQixTQUFTLEVBQUUsTUFBTSxDQUFDO0lBQ2xCLFNBQVMsRUFBRSxNQUFNLENBQUM7Q0FDbkI7QUFFRDs7R0FFRztBQUNILHFCQUFhLFFBQVE7SUFLakIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBQ3RCLE9BQU8sQ0FBQyxRQUFRLENBQUMsR0FBRztJQUx0QixnQkFBdUIsY0FBYyxLQUFLO0lBQzFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFnQztJQUU3RCxZQUNtQixLQUFLLEVBQUUsaUJBQWlCLEVBQ3hCLEdBQUcsR0FBRSxNQUFrQyxFQUd6RDtJQUVEOztPQUVHO0lBQ1UsZUFBZSxDQUFDLFNBQVMsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGFBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBa0J6RjtJQUVEOztPQUVHO0lBQ1UsY0FBYyxDQUFDLFNBQVMsRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FzQnpGO0lBRUQ7O09BRUc7SUFDVSxpQkFBaUIsQ0FBQyxTQUFTLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FHckU7SUFFRDs7T0FFRztJQUNVLGtCQUFrQixJQUFJLE9BQU8sQ0FBQyxlQUFlLEVBQUUsQ0FBQyxDQXdCNUQ7SUFFRDs7T0FFRztJQUNVLGdCQUFnQixDQUFDLFFBQVEsR0FBRSxNQUE0QixHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FlckY7SUFFRDs7T0FFRztJQUNVLEtBQUssSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBR2xDO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot_store.d.ts","sourceRoot":"","sources":["../../src/store/bot_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,QAAQ;IAKjB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,gBAAuB,cAAc,
|
|
1
|
+
{"version":3,"file":"bot_store.d.ts","sourceRoot":"","sources":["../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
"name": "@aztec/bot",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d431d1c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
58
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
59
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
60
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
61
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
62
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
63
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
64
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
65
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
66
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
67
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
68
|
-
"@aztec/test-wallet": "0.0.1-commit.
|
|
57
|
+
"@aztec/accounts": "0.0.1-commit.d431d1c",
|
|
58
|
+
"@aztec/aztec.js": "0.0.1-commit.d431d1c",
|
|
59
|
+
"@aztec/entrypoints": "0.0.1-commit.d431d1c",
|
|
60
|
+
"@aztec/ethereum": "0.0.1-commit.d431d1c",
|
|
61
|
+
"@aztec/foundation": "0.0.1-commit.d431d1c",
|
|
62
|
+
"@aztec/kv-store": "0.0.1-commit.d431d1c",
|
|
63
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d431d1c",
|
|
64
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d431d1c",
|
|
65
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d431d1c",
|
|
66
|
+
"@aztec/stdlib": "0.0.1-commit.d431d1c",
|
|
67
|
+
"@aztec/telemetry-client": "0.0.1-commit.d431d1c",
|
|
68
|
+
"@aztec/test-wallet": "0.0.1-commit.d431d1c",
|
|
69
69
|
"source-map-support": "^0.5.21",
|
|
70
70
|
"tslib": "^2.4.0",
|
|
71
71
|
"zod": "^3.23.8"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/jest": "^30.0.0",
|
|
76
76
|
"@types/node": "^22.15.17",
|
|
77
77
|
"@types/source-map-support": "^0.5.10",
|
|
78
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
79
79
|
"jest": "^30.0.0",
|
|
80
80
|
"jest-mock-extended": "^4.0.0",
|
|
81
81
|
"ts-node": "^10.9.1",
|
package/src/base_bot.ts
CHANGED
|
@@ -73,9 +73,9 @@ export abstract class BaseBot {
|
|
|
73
73
|
protected async getSendMethodOpts(
|
|
74
74
|
interaction: ContractFunctionInteraction | BatchCall,
|
|
75
75
|
): Promise<SendInteractionOptions> {
|
|
76
|
-
const { l2GasLimit, daGasLimit,
|
|
76
|
+
const { l2GasLimit, daGasLimit, minFeePadding } = this.config;
|
|
77
77
|
|
|
78
|
-
this.wallet.
|
|
78
|
+
this.wallet.setMinFeePadding(minFeePadding);
|
|
79
79
|
|
|
80
80
|
let gasSettings;
|
|
81
81
|
if (l2GasLimit !== undefined && l2GasLimit > 0 && daGasLimit !== undefined && daGasLimit > 0) {
|
package/src/config.ts
CHANGED
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
secretFrConfigHelper,
|
|
11
11
|
secretStringConfigHelper,
|
|
12
12
|
} from '@aztec/foundation/config';
|
|
13
|
-
import { Fr } from '@aztec/foundation/
|
|
13
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
14
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 {
|
|
17
|
+
import { schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
18
18
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
19
19
|
|
|
20
20
|
import { z } from 'zod';
|
|
@@ -54,8 +54,8 @@ export type BotConfig = {
|
|
|
54
54
|
publicTransfersPerTx: number;
|
|
55
55
|
/** How to handle fee payments. */
|
|
56
56
|
feePaymentMethod: 'fee_juice';
|
|
57
|
-
/** 'How much is the bot willing to overpay vs. the current
|
|
58
|
-
|
|
57
|
+
/** 'How much is the bot willing to overpay vs. the current min fee' */
|
|
58
|
+
minFeePadding: number;
|
|
59
59
|
/** True to not automatically setup or start the bot on initialization. */
|
|
60
60
|
noStart: boolean;
|
|
61
61
|
/** How long to wait for a tx to be mined before reporting an error. */
|
|
@@ -80,50 +80,52 @@ export type BotConfig = {
|
|
|
80
80
|
ammTxs: boolean;
|
|
81
81
|
} & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'>;
|
|
82
82
|
|
|
83
|
-
export const BotConfigSchema =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
83
|
+
export const BotConfigSchema = zodFor<BotConfig>()(
|
|
84
|
+
z
|
|
85
|
+
.object({
|
|
86
|
+
nodeUrl: z.string().optional(),
|
|
87
|
+
nodeAdminUrl: z.string().optional(),
|
|
88
|
+
l1RpcUrls: z.array(z.string()).optional(),
|
|
89
|
+
l1Mnemonic: schemas.SecretValue(z.string()).optional(),
|
|
90
|
+
l1PrivateKey: schemas.SecretValue(z.string()).optional(),
|
|
91
|
+
l1ToL2MessageTimeoutSeconds: z.number(),
|
|
92
|
+
senderPrivateKey: schemas.SecretValue(schemas.Fr).optional(),
|
|
93
|
+
senderSalt: schemas.Fr.optional(),
|
|
94
|
+
tokenSalt: schemas.Fr,
|
|
95
|
+
txIntervalSeconds: z.number(),
|
|
96
|
+
privateTransfersPerTx: z.number().int().nonnegative(),
|
|
97
|
+
publicTransfersPerTx: z.number().int().nonnegative(),
|
|
98
|
+
feePaymentMethod: z.literal('fee_juice'),
|
|
99
|
+
minFeePadding: z.number().int().nonnegative(),
|
|
100
|
+
noStart: z.boolean(),
|
|
101
|
+
txMinedWaitSeconds: z.number(),
|
|
102
|
+
followChain: z.enum(BotFollowChain),
|
|
103
|
+
maxPendingTxs: z.number().int().nonnegative(),
|
|
104
|
+
flushSetupTransactions: z.boolean(),
|
|
105
|
+
l2GasLimit: z.number().int().nonnegative().optional(),
|
|
106
|
+
daGasLimit: z.number().int().nonnegative().optional(),
|
|
107
|
+
contract: z.nativeEnum(SupportedTokenContracts),
|
|
108
|
+
maxConsecutiveErrors: z.number().int().nonnegative(),
|
|
109
|
+
stopWhenUnhealthy: z.boolean(),
|
|
110
|
+
ammTxs: z.boolean().default(false),
|
|
111
|
+
dataDirectory: z.string().optional(),
|
|
112
|
+
dataStoreMapSizeKb: z.number().optional(),
|
|
113
|
+
})
|
|
114
|
+
.transform(config => ({
|
|
115
|
+
nodeUrl: undefined,
|
|
116
|
+
nodeAdminUrl: undefined,
|
|
117
|
+
l1RpcUrls: undefined,
|
|
118
|
+
senderSalt: undefined,
|
|
119
|
+
l2GasLimit: undefined,
|
|
120
|
+
daGasLimit: undefined,
|
|
121
|
+
l1Mnemonic: undefined,
|
|
122
|
+
l1PrivateKey: undefined,
|
|
123
|
+
senderPrivateKey: undefined,
|
|
124
|
+
dataDirectory: undefined,
|
|
125
|
+
dataStoreMapSizeKb: 1_024 * 1_024,
|
|
126
|
+
...config,
|
|
127
|
+
})),
|
|
128
|
+
);
|
|
127
129
|
|
|
128
130
|
export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
129
131
|
nodeUrl: {
|
|
@@ -191,8 +193,8 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
|
|
|
191
193
|
parseEnv: val => (val as 'fee_juice') || undefined,
|
|
192
194
|
defaultValue: 'fee_juice',
|
|
193
195
|
},
|
|
194
|
-
|
|
195
|
-
env: '
|
|
196
|
+
minFeePadding: {
|
|
197
|
+
env: 'BOT_MIN_FEE_PADDING',
|
|
196
198
|
description: 'How much is the bot willing to overpay vs. the current base fee',
|
|
197
199
|
...numberConfigHelper(3),
|
|
198
200
|
},
|
package/src/factory.ts
CHANGED
|
@@ -11,14 +11,17 @@ import {
|
|
|
11
11
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
12
12
|
import type { L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
13
13
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
14
|
+
import { deriveKeys } from '@aztec/aztec.js/keys';
|
|
14
15
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
15
16
|
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
16
|
-
import { createEthereumChain
|
|
17
|
-
import {
|
|
17
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
18
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
19
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
18
20
|
import { Timer } from '@aztec/foundation/timer';
|
|
19
21
|
import { AMMContract } from '@aztec/noir-contracts.js/AMM';
|
|
20
22
|
import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
|
|
21
23
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
24
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
22
25
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
23
26
|
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
24
27
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
@@ -53,8 +56,8 @@ export class BotFactory {
|
|
|
53
56
|
node: AztecNode;
|
|
54
57
|
recipient: AztecAddress;
|
|
55
58
|
}> {
|
|
56
|
-
const recipient = (await this.wallet.createAccount()).address;
|
|
57
59
|
const defaultAccountAddress = await this.setupAccount();
|
|
60
|
+
const recipient = (await this.wallet.createAccount()).address;
|
|
58
61
|
const token = await this.setupToken(defaultAccountAddress);
|
|
59
62
|
await this.mintTokens(token, defaultAccountAddress);
|
|
60
63
|
return { wallet: this.wallet, defaultAccountAddress, token, node: this.aztecNode, recipient };
|
|
@@ -115,8 +118,8 @@ export class BotFactory {
|
|
|
115
118
|
contract: new SchnorrAccountContract(signingKey!),
|
|
116
119
|
};
|
|
117
120
|
const accountManager = await this.wallet.createAccount(accountData);
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
121
|
+
const metadata = await this.wallet.getContractMetadata(accountManager.address);
|
|
122
|
+
if (metadata.isContractInitialized) {
|
|
120
123
|
this.log.info(`Account at ${accountManager.address.toString()} already initialized`);
|
|
121
124
|
const timer = new Timer();
|
|
122
125
|
const address = accountManager.address;
|
|
@@ -131,7 +134,7 @@ export class BotFactory {
|
|
|
131
134
|
|
|
132
135
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
|
|
133
136
|
const deployMethod = await accountManager.getDeployMethod();
|
|
134
|
-
const maxFeesPerGas = (await this.aztecNode.
|
|
137
|
+
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
|
|
135
138
|
const gasSettings = GasSettings.default({ maxFeesPerGas });
|
|
136
139
|
const sentTx = deployMethod.send({ from: AztecAddress.ZERO, fee: { gasSettings, paymentMethod } });
|
|
137
140
|
const txHash = await sentTx.getTxHash();
|
|
@@ -164,6 +167,7 @@ export class BotFactory {
|
|
|
164
167
|
*/
|
|
165
168
|
private async setupToken(sender: AztecAddress): Promise<TokenContract | PrivateTokenContract> {
|
|
166
169
|
let deploy: DeployMethod<TokenContract | PrivateTokenContract>;
|
|
170
|
+
let tokenInstance: ContractInstanceWithAddress | undefined;
|
|
167
171
|
const deployOpts: DeployOptions = {
|
|
168
172
|
from: sender,
|
|
169
173
|
contractAddressSalt: this.config.tokenSalt,
|
|
@@ -172,16 +176,24 @@ export class BotFactory {
|
|
|
172
176
|
if (this.config.contract === SupportedTokenContracts.TokenContract) {
|
|
173
177
|
deploy = TokenContract.deploy(this.wallet, sender, 'BotToken', 'BOT', 18);
|
|
174
178
|
} else if (this.config.contract === SupportedTokenContracts.PrivateTokenContract) {
|
|
175
|
-
|
|
179
|
+
// Generate keys for the contract since PrivateToken uses SinglePrivateMutable which requires keys
|
|
180
|
+
const tokenSecretKey = Fr.random();
|
|
181
|
+
const tokenPublicKeys = (await deriveKeys(tokenSecretKey)).publicKeys;
|
|
182
|
+
deploy = PrivateTokenContract.deployWithPublicKeys(tokenPublicKeys, this.wallet, MINT_BALANCE, sender);
|
|
176
183
|
deployOpts.skipInstancePublication = true;
|
|
177
184
|
deployOpts.skipClassPublication = true;
|
|
178
185
|
deployOpts.skipInitialization = false;
|
|
186
|
+
|
|
187
|
+
// Register the contract with the secret key before deployment
|
|
188
|
+
tokenInstance = await deploy.getInstance(deployOpts);
|
|
189
|
+
await this.wallet.registerContract(tokenInstance, PrivateTokenContract.artifact, tokenSecretKey);
|
|
179
190
|
} else {
|
|
180
191
|
throw new Error(`Unsupported token contract type: ${this.config.contract}`);
|
|
181
192
|
}
|
|
182
193
|
|
|
183
|
-
const address = (await deploy.getInstance(deployOpts)).address;
|
|
184
|
-
|
|
194
|
+
const address = tokenInstance?.address ?? (await deploy.getInstance(deployOpts)).address;
|
|
195
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
196
|
+
if (metadata.isContractPublished) {
|
|
185
197
|
this.log.info(`Token at ${address.toString()} already deployed`);
|
|
186
198
|
return deploy.register();
|
|
187
199
|
} else {
|
|
@@ -314,7 +326,8 @@ export class BotFactory {
|
|
|
314
326
|
deployOpts: DeployOptions,
|
|
315
327
|
): Promise<T> {
|
|
316
328
|
const address = (await deploy.getInstance(deployOpts)).address;
|
|
317
|
-
|
|
329
|
+
const metadata = await this.wallet.getContractMetadata(address);
|
|
330
|
+
if (metadata.isContractPublished) {
|
|
318
331
|
this.log.info(`Contract ${name} at ${address.toString()} already deployed`);
|
|
319
332
|
return deploy.register();
|
|
320
333
|
} else {
|
package/src/store/bot_store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { L2AmountClaim } from '@aztec/aztec.js/ethereum';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
6
|
|