@aztec/cli-wallet 0.86.0 → 0.87.0
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/bin/index.js +7 -9
- package/dest/cmds/create_account.d.ts +1 -1
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +25 -15
- package/dest/cmds/deploy.d.ts +1 -1
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +7 -2
- package/dest/cmds/deploy_account.d.ts +1 -1
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +26 -17
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +34 -32
- package/dest/cmds/profile.d.ts +2 -1
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +7 -17
- package/dest/cmds/register_contract.d.ts +1 -1
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +1 -1
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +7 -2
- package/dest/cmds/simulate.d.ts +2 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +10 -4
- package/dest/storage/wallet_db.d.ts +1 -3
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +1 -1
- package/dest/utils/accounts.d.ts +1 -1
- package/dest/utils/accounts.d.ts.map +1 -1
- package/dest/utils/ecdsa.d.ts +0 -2
- package/dest/utils/ecdsa.d.ts.map +1 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +1 -1
- package/dest/utils/options/options.d.ts +1 -0
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +6 -3
- package/dest/utils/profiling.d.ts +5 -0
- package/dest/utils/profiling.d.ts.map +1 -0
- package/dest/utils/profiling.js +32 -0
- package/dest/utils/pxe_wrapper.d.ts +3 -2
- package/dest/utils/pxe_wrapper.d.ts.map +1 -1
- package/dest/utils/pxe_wrapper.js +7 -3
- package/package.json +15 -15
- package/src/bin/index.ts +7 -9
- package/src/cmds/create_account.ts +24 -14
- package/src/cmds/deploy.ts +8 -1
- package/src/cmds/deploy_account.ts +26 -16
- package/src/cmds/index.ts +98 -69
- package/src/cmds/profile.ts +10 -25
- package/src/cmds/register_contract.ts +1 -1
- package/src/cmds/send.ts +8 -1
- package/src/cmds/simulate.ts +14 -2
- package/src/storage/wallet_db.ts +1 -1
- package/src/utils/accounts.ts +1 -1
- package/src/utils/options/fees.ts +25 -16
- package/src/utils/options/options.ts +10 -3
- package/src/utils/profiling.ts +87 -0
- package/src/utils/pxe_wrapper.ts +7 -3
package/src/cmds/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
createContractAddressOption,
|
|
40
40
|
createDebugExecutionStepsDirOption,
|
|
41
41
|
createTypeOption,
|
|
42
|
+
createVerboseOption,
|
|
42
43
|
integerArgParser,
|
|
43
44
|
parseGasFees,
|
|
44
45
|
parsePaymentMethod,
|
|
@@ -65,7 +66,7 @@ export function injectCommands(
|
|
|
65
66
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
66
67
|
const { rpcUrl, json } = options;
|
|
67
68
|
|
|
68
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
69
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
69
70
|
await importTestAccounts(client, db, json, log);
|
|
70
71
|
});
|
|
71
72
|
|
|
@@ -99,12 +100,14 @@ export function injectCommands(
|
|
|
99
100
|
.option('--json', 'Emit output as json')
|
|
100
101
|
// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
101
102
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
102
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
103
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
104
|
+
.addOption(createVerboseOption());
|
|
103
105
|
|
|
104
106
|
addOptions(createAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command) => {
|
|
105
107
|
const { createAccount } = await import('./create_account.js');
|
|
106
108
|
const options = command.optsWithGlobals();
|
|
107
|
-
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy, rpcUrl, alias, json } =
|
|
109
|
+
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy, rpcUrl, alias, json, verbose } =
|
|
110
|
+
options;
|
|
108
111
|
let { publicKey } = options;
|
|
109
112
|
if ((type as AccountType) === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
110
113
|
const identities = await getIdentities();
|
|
@@ -119,7 +122,7 @@ export function injectCommands(
|
|
|
119
122
|
]);
|
|
120
123
|
publicKey = answers.identity.split(' ')[1];
|
|
121
124
|
}
|
|
122
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
125
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
123
126
|
const accountCreationResult = await createAccount(
|
|
124
127
|
client,
|
|
125
128
|
type,
|
|
@@ -132,6 +135,7 @@ export function injectCommands(
|
|
|
132
135
|
wait,
|
|
133
136
|
await FeeOptsWithFeePayer.fromCli(options, client, log, db),
|
|
134
137
|
json,
|
|
138
|
+
verbose,
|
|
135
139
|
debugLogger,
|
|
136
140
|
log,
|
|
137
141
|
);
|
|
@@ -153,22 +157,26 @@ export function injectCommands(
|
|
|
153
157
|
.option(
|
|
154
158
|
'--register-class',
|
|
155
159
|
'Register the contract class (useful for when the contract class has not been deployed yet).',
|
|
156
|
-
)
|
|
160
|
+
)
|
|
161
|
+
.option('--public-deploy', 'Publicly deploy this account contract (only useful if it contains public functions')
|
|
162
|
+
.addOption(createVerboseOption());
|
|
157
163
|
|
|
158
164
|
addOptions(deployAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command) => {
|
|
159
165
|
const { deployAccount } = await import('./deploy_account.js');
|
|
160
166
|
const options = command.optsWithGlobals();
|
|
161
|
-
const { rpcUrl, wait, from: parsedFromAddress, json, registerClass } = options;
|
|
167
|
+
const { rpcUrl, wait, from: parsedFromAddress, json, registerClass, publicDeploy, verbose } = options;
|
|
162
168
|
|
|
163
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
169
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
164
170
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db);
|
|
165
171
|
|
|
166
172
|
await deployAccount(
|
|
167
173
|
account,
|
|
168
174
|
wait,
|
|
169
175
|
registerClass,
|
|
176
|
+
publicDeploy,
|
|
170
177
|
await FeeOptsWithFeePayer.fromCli(options, client, log, db),
|
|
171
178
|
json,
|
|
179
|
+
verbose,
|
|
172
180
|
debugLogger,
|
|
173
181
|
log,
|
|
174
182
|
);
|
|
@@ -203,7 +211,8 @@ export function injectCommands(
|
|
|
203
211
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
204
212
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
205
213
|
.option('--no-class-registration', "Don't register this contract class")
|
|
206
|
-
.option('--no-public-deployment', "Don't emit this contract's public bytecode")
|
|
214
|
+
.option('--no-public-deployment', "Don't emit this contract's public bytecode")
|
|
215
|
+
.addOption(createVerboseOption());
|
|
207
216
|
|
|
208
217
|
addOptions(deployCommand, FeeOpts.getOptions()).action(async (artifactPathPromise, _options, command) => {
|
|
209
218
|
const { deploy } = await import('./deploy.js');
|
|
@@ -222,8 +231,9 @@ export function injectCommands(
|
|
|
222
231
|
rpcUrl,
|
|
223
232
|
from: parsedFromAddress,
|
|
224
233
|
alias,
|
|
234
|
+
verbose,
|
|
225
235
|
} = options;
|
|
226
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
236
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
227
237
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
228
238
|
const wallet = await account.getWallet();
|
|
229
239
|
const artifactPath = await artifactPathPromise;
|
|
@@ -244,6 +254,7 @@ export function injectCommands(
|
|
|
244
254
|
universal,
|
|
245
255
|
wait,
|
|
246
256
|
await FeeOpts.fromCli(options, client, log, db),
|
|
257
|
+
verbose,
|
|
247
258
|
debugLogger,
|
|
248
259
|
log,
|
|
249
260
|
logJson(log),
|
|
@@ -276,7 +287,8 @@ export function injectCommands(
|
|
|
276
287
|
)
|
|
277
288
|
.addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db))
|
|
278
289
|
.option('--no-wait', 'Print transaction hash without waiting for it to be mined')
|
|
279
|
-
.option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.')
|
|
290
|
+
.option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.')
|
|
291
|
+
.addOption(createVerboseOption());
|
|
280
292
|
|
|
281
293
|
addOptions(sendCommand, FeeOpts.getOptions()).action(async (functionName, _options, command) => {
|
|
282
294
|
const { send } = await import('./send.js');
|
|
@@ -292,8 +304,9 @@ export function injectCommands(
|
|
|
292
304
|
alias,
|
|
293
305
|
cancel,
|
|
294
306
|
authWitness: authWitnessArray,
|
|
307
|
+
verbose,
|
|
295
308
|
} = options;
|
|
296
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
309
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
297
310
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
298
311
|
const wallet = await account.getWallet();
|
|
299
312
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
@@ -311,6 +324,7 @@ export function injectCommands(
|
|
|
311
324
|
cancel,
|
|
312
325
|
await FeeOpts.fromCli(options, client, log, db),
|
|
313
326
|
authWitnesses,
|
|
327
|
+
verbose,
|
|
314
328
|
log,
|
|
315
329
|
);
|
|
316
330
|
if (db && sentTx) {
|
|
@@ -319,7 +333,7 @@ export function injectCommands(
|
|
|
319
333
|
}
|
|
320
334
|
});
|
|
321
335
|
|
|
322
|
-
program
|
|
336
|
+
const simulateCommand = program
|
|
323
337
|
.command('simulate')
|
|
324
338
|
.description('Simulates the execution of a function on an Aztec contract.')
|
|
325
339
|
.argument('<functionName>', 'Name of function to simulate')
|
|
@@ -332,28 +346,41 @@ export function injectCommands(
|
|
|
332
346
|
)
|
|
333
347
|
.addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
|
|
334
348
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
335
|
-
.
|
|
336
|
-
const { simulate } = await import('./simulate.js');
|
|
337
|
-
const options = command.optsWithGlobals();
|
|
338
|
-
const {
|
|
339
|
-
args,
|
|
340
|
-
contractArtifact: artifactPathPromise,
|
|
341
|
-
contractAddress,
|
|
342
|
-
from: parsedFromAddress,
|
|
343
|
-
rpcUrl,
|
|
344
|
-
secretKey,
|
|
345
|
-
authWitness,
|
|
346
|
-
} = options;
|
|
349
|
+
.addOption(createVerboseOption());
|
|
347
350
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
addOptions(simulateCommand, FeeOpts.getOptions()).action(async (functionName, _options, command) => {
|
|
352
|
+
const { simulate } = await import('./simulate.js');
|
|
353
|
+
const options = command.optsWithGlobals();
|
|
354
|
+
const {
|
|
355
|
+
args,
|
|
356
|
+
contractArtifact: artifactPathPromise,
|
|
357
|
+
contractAddress,
|
|
358
|
+
from: parsedFromAddress,
|
|
359
|
+
rpcUrl,
|
|
360
|
+
secretKey,
|
|
361
|
+
verbose,
|
|
362
|
+
authWitness,
|
|
363
|
+
} = options;
|
|
355
364
|
|
|
356
|
-
|
|
365
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
366
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
367
|
+
const wallet = await account.getWallet();
|
|
368
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
369
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
370
|
+
await simulate(
|
|
371
|
+
wallet,
|
|
372
|
+
functionName,
|
|
373
|
+
args,
|
|
374
|
+
artifactPath,
|
|
375
|
+
contractAddress,
|
|
376
|
+
await FeeOpts.fromCli(options, client, log, db),
|
|
377
|
+
authWitnesses,
|
|
378
|
+
verbose,
|
|
379
|
+
log,
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const profileCommand = program
|
|
357
384
|
.command('profile')
|
|
358
385
|
.description('Profiles a private function by counting the unconditional operations in its execution steps')
|
|
359
386
|
.argument('<functionName>', 'Name of function to simulate')
|
|
@@ -366,37 +393,39 @@ export function injectCommands(
|
|
|
366
393
|
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
367
394
|
)
|
|
368
395
|
.addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
|
|
369
|
-
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
370
|
-
.action(async (functionName, _options, command) => {
|
|
371
|
-
const { profile } = await import('./profile.js');
|
|
372
|
-
const options = command.optsWithGlobals();
|
|
373
|
-
const {
|
|
374
|
-
args,
|
|
375
|
-
contractArtifact: artifactPathPromise,
|
|
376
|
-
contractAddress,
|
|
377
|
-
from: parsedFromAddress,
|
|
378
|
-
rpcUrl,
|
|
379
|
-
secretKey,
|
|
380
|
-
debugExecutionStepsDir,
|
|
381
|
-
authWitness,
|
|
382
|
-
} = options;
|
|
396
|
+
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db));
|
|
383
397
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
addOptions(profileCommand, FeeOpts.getOptions()).action(async (functionName, _options, command) => {
|
|
399
|
+
const { profile } = await import('./profile.js');
|
|
400
|
+
const options = command.optsWithGlobals();
|
|
401
|
+
const {
|
|
402
|
+
args,
|
|
403
|
+
contractArtifact: artifactPathPromise,
|
|
404
|
+
contractAddress,
|
|
405
|
+
from: parsedFromAddress,
|
|
406
|
+
rpcUrl,
|
|
407
|
+
secretKey,
|
|
408
|
+
debugExecutionStepsDir,
|
|
409
|
+
authWitness,
|
|
410
|
+
} = options;
|
|
411
|
+
|
|
412
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
413
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
414
|
+
const wallet = await account.getWallet();
|
|
415
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
416
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
417
|
+
await profile(
|
|
418
|
+
wallet,
|
|
419
|
+
functionName,
|
|
420
|
+
args,
|
|
421
|
+
artifactPath,
|
|
422
|
+
contractAddress,
|
|
423
|
+
debugExecutionStepsDir,
|
|
424
|
+
await FeeOptsWithFeePayer.fromCli(options, client, log, db),
|
|
425
|
+
authWitnesses,
|
|
426
|
+
log,
|
|
427
|
+
);
|
|
428
|
+
});
|
|
400
429
|
|
|
401
430
|
program
|
|
402
431
|
.command('bridge-fee-juice')
|
|
@@ -432,7 +461,7 @@ export function injectCommands(
|
|
|
432
461
|
.action(async (amount, recipient, options) => {
|
|
433
462
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
434
463
|
const { rpcUrl, l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
435
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
464
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
436
465
|
|
|
437
466
|
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(
|
|
438
467
|
amount,
|
|
@@ -487,7 +516,7 @@ export function injectCommands(
|
|
|
487
516
|
alias,
|
|
488
517
|
} = options;
|
|
489
518
|
|
|
490
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
519
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
491
520
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
492
521
|
const wallet = await account.getWallet();
|
|
493
522
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
@@ -527,7 +556,7 @@ export function injectCommands(
|
|
|
527
556
|
secretKey,
|
|
528
557
|
} = options;
|
|
529
558
|
|
|
530
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
559
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
531
560
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
532
561
|
const wallet = await account.getWallet();
|
|
533
562
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
@@ -550,7 +579,7 @@ export function injectCommands(
|
|
|
550
579
|
const { checkTx } = await import('./check_tx.js');
|
|
551
580
|
const { rpcUrl, pageSize } = options;
|
|
552
581
|
let { page } = options;
|
|
553
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
582
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
554
583
|
|
|
555
584
|
if (txHash) {
|
|
556
585
|
await checkTx(client, txHash, false, log);
|
|
@@ -602,7 +631,7 @@ export function injectCommands(
|
|
|
602
631
|
.action(async (txHash, options) => {
|
|
603
632
|
const { cancelTx } = await import('./cancel_tx.js');
|
|
604
633
|
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
605
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
634
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
606
635
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
607
636
|
const wallet = await account.getWallet();
|
|
608
637
|
|
|
@@ -630,7 +659,7 @@ export function injectCommands(
|
|
|
630
659
|
.action(async (address, options) => {
|
|
631
660
|
const { registerSender } = await import('./register_sender.js');
|
|
632
661
|
const { from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
633
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
662
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
634
663
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
635
664
|
const wallet = await account.getWallet();
|
|
636
665
|
|
|
@@ -680,7 +709,7 @@ export function injectCommands(
|
|
|
680
709
|
deployer,
|
|
681
710
|
args,
|
|
682
711
|
} = command.optsWithGlobals();
|
|
683
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
712
|
+
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
684
713
|
const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
|
|
685
714
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
686
715
|
const wallet = await account.getWallet();
|
package/src/cmds/profile.ts
CHANGED
|
@@ -2,32 +2,12 @@ import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress, Contra
|
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
5
|
-
import type { TxProfileResult } from '@aztec/stdlib/tx';
|
|
6
5
|
|
|
7
6
|
import { promises as fs } from 'fs';
|
|
8
7
|
import path from 'path';
|
|
9
|
-
import { format } from 'util';
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// as the total gate count. We should probably print both.
|
|
14
|
-
log(format('\nGate count per circuit:'));
|
|
15
|
-
let acc = 0;
|
|
16
|
-
result.executionSteps.forEach(r => {
|
|
17
|
-
acc += r.gateCount!;
|
|
18
|
-
log(
|
|
19
|
-
format(
|
|
20
|
-
' ',
|
|
21
|
-
r.functionName.padEnd(50),
|
|
22
|
-
'Gates:',
|
|
23
|
-
r.gateCount!.toLocaleString(),
|
|
24
|
-
'\tSubtotal:',
|
|
25
|
-
acc.toLocaleString(),
|
|
26
|
-
),
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
log(format('\nTotal gates:', acc.toLocaleString()));
|
|
30
|
-
}
|
|
9
|
+
import type { IFeeOpts } from '../utils/options/fees.js';
|
|
10
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
31
11
|
|
|
32
12
|
export async function profile(
|
|
33
13
|
wallet: AccountWalletWithSecretKey,
|
|
@@ -36,17 +16,22 @@ export async function profile(
|
|
|
36
16
|
contractArtifactPath: string,
|
|
37
17
|
contractAddress: AztecAddress,
|
|
38
18
|
debugOutputPath: string | undefined,
|
|
19
|
+
feeOpts: IFeeOpts,
|
|
39
20
|
authWitnesses: AuthWitness[],
|
|
40
21
|
log: LogFn,
|
|
41
22
|
) {
|
|
42
|
-
const profileMode = debugOutputPath ? ('full' as const) : ('gates' as const);
|
|
43
23
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
44
24
|
|
|
45
25
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
46
26
|
const call = contract.methods[functionName](...functionArgs);
|
|
47
27
|
|
|
48
|
-
const result = await call.profile({
|
|
49
|
-
|
|
28
|
+
const result = await call.profile({
|
|
29
|
+
...(await feeOpts.toSendOpts(wallet)),
|
|
30
|
+
profileMode: 'full',
|
|
31
|
+
authWitnesses,
|
|
32
|
+
skipProofGeneration: false,
|
|
33
|
+
});
|
|
34
|
+
printProfileResult(result.timings, log, result.executionSteps);
|
|
50
35
|
if (debugOutputPath) {
|
|
51
36
|
const ivcInputsPath = path.join(debugOutputPath, 'ivc-inputs.msgpack');
|
|
52
37
|
log(`Debug output written to ${ivcInputsPath}.`);
|
|
@@ -20,7 +20,7 @@ export async function registerContract(
|
|
|
20
20
|
publicKeys?: PublicKeys,
|
|
21
21
|
rawArgs?: any[],
|
|
22
22
|
salt?: Fr,
|
|
23
|
-
deployer?: AztecAddress
|
|
23
|
+
deployer?: AztecAddress,
|
|
24
24
|
) {
|
|
25
25
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
26
26
|
const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
|
package/src/cmds/send.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
11
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
12
12
|
|
|
13
13
|
import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
|
|
14
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
14
15
|
|
|
15
16
|
export async function send(
|
|
16
17
|
wallet: AccountWalletWithSecretKey,
|
|
@@ -22,6 +23,7 @@ export async function send(
|
|
|
22
23
|
cancellable: boolean,
|
|
23
24
|
feeOpts: IFeeOpts,
|
|
24
25
|
authWitnesses: AuthWitness[],
|
|
26
|
+
verbose: boolean,
|
|
25
27
|
log: LogFn,
|
|
26
28
|
) {
|
|
27
29
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
@@ -45,7 +47,12 @@ export async function send(
|
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
const
|
|
50
|
+
const provenTx = await call.prove(sendOptions);
|
|
51
|
+
if (verbose) {
|
|
52
|
+
printProfileResult(provenTx.timings!, log);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const tx = provenTx.send();
|
|
49
56
|
const txHash = await tx.getTxHash();
|
|
50
57
|
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
51
58
|
if (wait) {
|
package/src/cmds/simulate.ts
CHANGED
|
@@ -4,19 +4,31 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
4
4
|
|
|
5
5
|
import { format } from 'util';
|
|
6
6
|
|
|
7
|
+
import type { IFeeOpts } from '../utils/options/fees.js';
|
|
8
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
9
|
+
|
|
7
10
|
export async function simulate(
|
|
8
11
|
wallet: AccountWalletWithSecretKey,
|
|
9
12
|
functionName: string,
|
|
10
13
|
functionArgsIn: any[],
|
|
11
14
|
contractArtifactPath: string,
|
|
12
15
|
contractAddress: AztecAddress,
|
|
16
|
+
feeOpts: IFeeOpts,
|
|
13
17
|
authWitnesses: AuthWitness[],
|
|
18
|
+
verbose: boolean,
|
|
14
19
|
log: LogFn,
|
|
15
20
|
) {
|
|
16
21
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
17
22
|
|
|
18
23
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
19
24
|
const call = contract.methods[functionName](...functionArgs);
|
|
20
|
-
const
|
|
21
|
-
|
|
25
|
+
const simulationResult = await call.simulate({
|
|
26
|
+
...(await feeOpts.toSendOpts(wallet)),
|
|
27
|
+
authWitnesses,
|
|
28
|
+
includeMetadata: true,
|
|
29
|
+
});
|
|
30
|
+
if (verbose) {
|
|
31
|
+
printProfileResult(simulationResult.meta.timings!, log);
|
|
32
|
+
}
|
|
33
|
+
log(format('\nSimulation result: ', simulationResult.result, '\n'));
|
|
22
34
|
}
|
package/src/storage/wallet_db.ts
CHANGED
package/src/utils/accounts.ts
CHANGED
|
@@ -138,7 +138,7 @@ function getFeeOptions(allowCustomFeePayer: boolean) {
|
|
|
138
138
|
'--max-priority-fees-per-gas <da=0,l2=0>',
|
|
139
139
|
'Maximum priority fees per gas unit for DA and L2 computation.',
|
|
140
140
|
),
|
|
141
|
-
new Option('--
|
|
141
|
+
new Option('--estimate-gas', 'Whether to automatically estimate gas limits for the tx.'),
|
|
142
142
|
new Option('--estimate-gas-only', 'Only report gas estimation for the tx, do not send it.'),
|
|
143
143
|
];
|
|
144
144
|
}
|
|
@@ -254,11 +254,14 @@ export function parsePaymentMethod(
|
|
|
254
254
|
log: LogFn,
|
|
255
255
|
db?: WalletDB,
|
|
256
256
|
): (sender: AccountWallet) => Promise<FeePaymentMethod> {
|
|
257
|
-
const parsed = payment.split(',').reduce(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
const parsed = payment.split(',').reduce(
|
|
258
|
+
(acc, item) => {
|
|
259
|
+
const [dimension, value] = item.split('=');
|
|
260
|
+
acc[dimension] = value ?? 1;
|
|
261
|
+
return acc;
|
|
262
|
+
},
|
|
263
|
+
{} as Record<string, string>,
|
|
264
|
+
);
|
|
262
265
|
|
|
263
266
|
const getFpc = () => {
|
|
264
267
|
if (!parsed.fpc) {
|
|
@@ -337,11 +340,14 @@ export function parsePaymentMethod(
|
|
|
337
340
|
}
|
|
338
341
|
|
|
339
342
|
function parseGasLimits(gasLimits: string): { gasLimits: Gas; teardownGasLimits: Gas } {
|
|
340
|
-
const parsed = gasLimits.split(',').reduce(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
const parsed = gasLimits.split(',').reduce(
|
|
344
|
+
(acc, limit) => {
|
|
345
|
+
const [dimension, value] = limit.split('=');
|
|
346
|
+
acc[dimension] = parseInt(value, 10);
|
|
347
|
+
return acc;
|
|
348
|
+
},
|
|
349
|
+
{} as Record<string, number>,
|
|
350
|
+
);
|
|
345
351
|
|
|
346
352
|
const expected = ['da', 'l2', 'teardownDA', 'teardownL2'];
|
|
347
353
|
for (const dimension of expected) {
|
|
@@ -357,11 +363,14 @@ function parseGasLimits(gasLimits: string): { gasLimits: Gas; teardownGasLimits:
|
|
|
357
363
|
}
|
|
358
364
|
|
|
359
365
|
export function parseGasFees(gasFees: string): GasFees {
|
|
360
|
-
const parsed = gasFees.split(',').reduce(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
366
|
+
const parsed = gasFees.split(',').reduce(
|
|
367
|
+
(acc, fee) => {
|
|
368
|
+
const [dimension, value] = fee.split('=');
|
|
369
|
+
acc[dimension] = parseInt(value, 10);
|
|
370
|
+
return acc;
|
|
371
|
+
},
|
|
372
|
+
{} as Record<string, number>,
|
|
373
|
+
);
|
|
365
374
|
|
|
366
375
|
const expected = ['da', 'l2'];
|
|
367
376
|
for (const dimension of expected) {
|
|
@@ -32,7 +32,7 @@ export function integerArgParser(
|
|
|
32
32
|
export function aliasedTxHashParser(txHash: string, db?: WalletDB) {
|
|
33
33
|
try {
|
|
34
34
|
return parseTxHash(txHash);
|
|
35
|
-
} catch
|
|
35
|
+
} catch {
|
|
36
36
|
const prefixed = txHash.includes(':') ? txHash : `transactions:${txHash}`;
|
|
37
37
|
const rawTxHash = db ? db.tryRetrieveAlias(prefixed) : txHash;
|
|
38
38
|
return parseTxHash(rawTxHash);
|
|
@@ -43,7 +43,7 @@ export function aliasedAuthWitParser(witnesses: string, db?: WalletDB) {
|
|
|
43
43
|
const parsedWitnesses = witnesses.split(',').map(witness => {
|
|
44
44
|
try {
|
|
45
45
|
return AuthWitness.fromString(witness);
|
|
46
|
-
} catch
|
|
46
|
+
} catch {
|
|
47
47
|
const prefixed = witness.includes(':') ? witness : `authwits:${witness}`;
|
|
48
48
|
const rawAuthWitness = db ? db.tryRetrieveAlias(prefixed) : witness;
|
|
49
49
|
return AuthWitness.fromString(rawAuthWitness);
|
|
@@ -120,6 +120,13 @@ export function createDebugExecutionStepsDirOption() {
|
|
|
120
120
|
).makeOptionMandatory(false);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
export function createVerboseOption() {
|
|
124
|
+
return new Option(
|
|
125
|
+
'-v, --verbose',
|
|
126
|
+
'Provide timings on all executed operations (synching, simulating, proving)',
|
|
127
|
+
).default(false);
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
export function artifactPathParser(filePath: string, db?: WalletDB) {
|
|
124
131
|
if (filePath.includes('@')) {
|
|
125
132
|
const [pkg, contractName] = filePath.split('@');
|
|
@@ -161,7 +168,7 @@ async function contractArtifactFromWorkspace(pkg?: string, contractName?: string
|
|
|
161
168
|
const cwd = process.cwd();
|
|
162
169
|
try {
|
|
163
170
|
await stat(`${cwd}/Nargo.toml`);
|
|
164
|
-
} catch
|
|
171
|
+
} catch {
|
|
165
172
|
throw new Error(
|
|
166
173
|
'Invalid contract artifact argument provided. To use this option, command should be called from a nargo workspace',
|
|
167
174
|
);
|