@aztec/cli-wallet 0.81.0 → 0.82.1-alpha-testnet.1
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/cmds/cancel_tx.d.ts.map +1 -1
- package/dest/cmds/cancel_tx.js +2 -3
- package/dest/cmds/create_account.js +2 -2
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +1 -1
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +3 -3
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +30 -26
- package/dest/cmds/profile.d.ts +4 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +47 -0
- package/dest/cmds/send.d.ts +2 -2
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +10 -10
- package/dest/cmds/simulate.d.ts +2 -2
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +5 -19
- package/dest/utils/accounts.d.ts +1 -3
- package/dest/utils/accounts.d.ts.map +1 -1
- package/dest/utils/accounts.js +0 -33
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +2 -1
- package/dest/utils/options/options.d.ts +5 -3
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +12 -3
- package/package.json +13 -10
- package/src/cmds/cancel_tx.ts +3 -4
- package/src/cmds/create_account.ts +2 -2
- package/src/cmds/deploy.ts +3 -3
- package/src/cmds/deploy_account.ts +3 -2
- package/src/cmds/index.ts +66 -43
- package/src/cmds/profile.ts +71 -0
- package/src/cmds/send.ts +20 -4
- package/src/cmds/simulate.ts +4 -24
- package/src/utils/accounts.ts +1 -31
- package/src/utils/options/fees.ts +2 -1
- package/src/utils/options/options.ts +18 -7
- package/dest/cmds/add_authwit.d.ts +0 -4
- package/dest/cmds/add_authwit.d.ts.map +0 -1
- package/dest/cmds/add_authwit.js +0 -4
- package/dest/utils/sponsored_fee_payment.d.ts +0 -19
- package/dest/utils/sponsored_fee_payment.d.ts.map +0 -1
- package/dest/utils/sponsored_fee_payment.js +0 -26
- package/src/cmds/add_authwit.ts +0 -13
- package/src/utils/sponsored_fee_payment.ts +0 -29
package/src/cmds/cancel_tx.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AccountWalletWithSecretKey, type FeePaymentMethod, SentTx, type TxHash, TxStatus } from '@aztec/aztec.js';
|
|
2
|
-
import type { FeeOptions } from '@aztec/
|
|
2
|
+
import type { FeeOptions } from '@aztec/entrypoints/interfaces';
|
|
3
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
6
|
import { GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -37,9 +38,7 @@ export async function cancelTx(
|
|
|
37
38
|
}),
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
const txRequest = await wallet.createTxExecutionRequest({
|
|
41
|
-
calls: [],
|
|
42
|
-
fee,
|
|
41
|
+
const txRequest = await wallet.createTxExecutionRequest(ExecutionPayload.empty(), fee, {
|
|
43
42
|
nonce,
|
|
44
43
|
cancellable: true,
|
|
45
44
|
});
|
|
@@ -32,7 +32,7 @@ export async function createAccount(
|
|
|
32
32
|
Fr.ZERO,
|
|
33
33
|
publicKey,
|
|
34
34
|
);
|
|
35
|
-
const salt = account.getInstance()
|
|
35
|
+
const { salt } = account.getInstance();
|
|
36
36
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
37
37
|
|
|
38
38
|
const out: Record<string, any> = {};
|
|
@@ -72,7 +72,7 @@ export async function createAccount(
|
|
|
72
72
|
...(await feeOpts.toDeployAccountOpts(wallet)),
|
|
73
73
|
};
|
|
74
74
|
if (feeOpts.estimateOnly) {
|
|
75
|
-
const gas = await
|
|
75
|
+
const gas = await account.estimateDeploymentGas(deployOpts);
|
|
76
76
|
if (json) {
|
|
77
77
|
out.fee = {
|
|
78
78
|
gasLimits: {
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AccountWalletWithSecretKey, ContractDeployer, type
|
|
1
|
+
import { type AccountWalletWithSecretKey, ContractDeployer, type DeployOptions, Fr, type PXE } from '@aztec/aztec.js';
|
|
2
2
|
import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
|
|
3
3
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { getInitializer } from '@aztec/stdlib/abi';
|
|
@@ -44,8 +44,8 @@ export async function deploy(
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const deploy = deployer.deploy(...args);
|
|
47
|
-
const deployOpts:
|
|
48
|
-
...(await feeOpts.
|
|
47
|
+
const deployOpts: DeployOptions = {
|
|
48
|
+
...(await feeOpts.toDeployAccountOpts(wallet)),
|
|
49
49
|
contractAddressSalt: salt,
|
|
50
50
|
universalDeploy,
|
|
51
51
|
skipClassRegistration,
|
|
@@ -41,11 +41,12 @@ export async function deployAccount(
|
|
|
41
41
|
let txReceipt;
|
|
42
42
|
|
|
43
43
|
const deployOpts: DeployAccountOptions = {
|
|
44
|
-
...(await feeOpts.toDeployAccountOpts(wallet)),
|
|
45
44
|
skipInitialization: false,
|
|
45
|
+
...(await feeOpts.toDeployAccountOpts(wallet)),
|
|
46
46
|
};
|
|
47
|
+
|
|
47
48
|
if (feeOpts.estimateOnly) {
|
|
48
|
-
const gas = await
|
|
49
|
+
const gas = await account.estimateDeploymentGas(deployOpts);
|
|
49
50
|
if (json) {
|
|
50
51
|
out.fee = {
|
|
51
52
|
gasLimits: {
|
package/src/cmds/index.ts
CHANGED
|
@@ -21,22 +21,23 @@ import { type Command, Option } from 'commander';
|
|
|
21
21
|
import inquirer from 'inquirer';
|
|
22
22
|
|
|
23
23
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
24
|
-
import { type AccountType,
|
|
24
|
+
import { type AccountType, createOrRetrieveAccount } from '../utils/accounts.js';
|
|
25
25
|
import { FeeOpts, FeeOptsWithFeePayer } from '../utils/options/fees.js';
|
|
26
26
|
import {
|
|
27
27
|
ARTIFACT_DESCRIPTION,
|
|
28
28
|
aliasedAddressParser,
|
|
29
|
-
aliasedAuthWitParser,
|
|
30
29
|
aliasedSecretKeyParser,
|
|
31
30
|
aliasedTxHashParser,
|
|
32
31
|
artifactPathFromPromiseOrAlias,
|
|
33
32
|
artifactPathParser,
|
|
33
|
+
cleanupAuthWitnesses,
|
|
34
34
|
createAccountOption,
|
|
35
35
|
createAliasOption,
|
|
36
36
|
createArgsOption,
|
|
37
37
|
createArtifactOption,
|
|
38
|
+
createAuthwitnessOption,
|
|
38
39
|
createContractAddressOption,
|
|
39
|
-
|
|
40
|
+
createDebugExecutionStepsDirOption,
|
|
40
41
|
createTypeOption,
|
|
41
42
|
integerArgParser,
|
|
42
43
|
parseGasFees,
|
|
@@ -219,7 +220,7 @@ export function injectCommands(
|
|
|
219
220
|
} = options;
|
|
220
221
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
221
222
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
222
|
-
const wallet = await
|
|
223
|
+
const wallet = await account.getWallet();
|
|
223
224
|
const artifactPath = await artifactPathPromise;
|
|
224
225
|
|
|
225
226
|
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
@@ -262,6 +263,7 @@ export function injectCommands(
|
|
|
262
263
|
.addOption(
|
|
263
264
|
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
264
265
|
)
|
|
266
|
+
.addOption(createAuthwitnessOption('Authorization witness to use for the transaction', !db, db))
|
|
265
267
|
.addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db))
|
|
266
268
|
.option('--no-wait', 'Print transaction hash without waiting for it to be mined')
|
|
267
269
|
.option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.');
|
|
@@ -279,14 +281,16 @@ export function injectCommands(
|
|
|
279
281
|
secretKey,
|
|
280
282
|
alias,
|
|
281
283
|
cancel,
|
|
284
|
+
authWitness,
|
|
282
285
|
} = options;
|
|
283
286
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
284
287
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
285
|
-
const wallet = await
|
|
288
|
+
const wallet = await account.getWallet();
|
|
286
289
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
287
290
|
|
|
288
291
|
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
289
292
|
|
|
293
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
290
294
|
const sentTx = await send(
|
|
291
295
|
wallet,
|
|
292
296
|
functionName,
|
|
@@ -296,6 +300,7 @@ export function injectCommands(
|
|
|
296
300
|
wait,
|
|
297
301
|
cancel,
|
|
298
302
|
await FeeOpts.fromCli(options, client, log, db),
|
|
303
|
+
authWitnesses,
|
|
299
304
|
log,
|
|
300
305
|
);
|
|
301
306
|
if (db && sentTx) {
|
|
@@ -315,8 +320,8 @@ export function injectCommands(
|
|
|
315
320
|
.addOption(
|
|
316
321
|
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
317
322
|
)
|
|
323
|
+
.addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
|
|
318
324
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
319
|
-
.addOption(createProfileOption())
|
|
320
325
|
.action(async (functionName, _options, command) => {
|
|
321
326
|
const { simulate } = await import('./simulate.js');
|
|
322
327
|
const options = command.optsWithGlobals();
|
|
@@ -327,14 +332,60 @@ export function injectCommands(
|
|
|
327
332
|
from: parsedFromAddress,
|
|
328
333
|
rpcUrl,
|
|
329
334
|
secretKey,
|
|
330
|
-
|
|
335
|
+
authWitness,
|
|
331
336
|
} = options;
|
|
332
337
|
|
|
333
338
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
334
339
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
335
|
-
const wallet = await
|
|
340
|
+
const wallet = await account.getWallet();
|
|
336
341
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
337
|
-
|
|
342
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
343
|
+
await simulate(wallet, functionName, args, artifactPath, contractAddress, authWitnesses, log);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
program
|
|
347
|
+
.command('profile')
|
|
348
|
+
.description('Profiles a private function by counting the unconditional operations in its execution steps')
|
|
349
|
+
.argument('<functionName>', 'Name of function to simulate')
|
|
350
|
+
.addOption(pxeOption)
|
|
351
|
+
.addOption(createArgsOption(false, db))
|
|
352
|
+
.addOption(createContractAddressOption(db))
|
|
353
|
+
.addOption(createArtifactOption(db))
|
|
354
|
+
.addOption(createDebugExecutionStepsDirOption())
|
|
355
|
+
.addOption(
|
|
356
|
+
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
357
|
+
)
|
|
358
|
+
.addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
|
|
359
|
+
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
360
|
+
.action(async (functionName, _options, command) => {
|
|
361
|
+
const { profile } = await import('./profile.js');
|
|
362
|
+
const options = command.optsWithGlobals();
|
|
363
|
+
const {
|
|
364
|
+
args,
|
|
365
|
+
contractArtifact: artifactPathPromise,
|
|
366
|
+
contractAddress,
|
|
367
|
+
from: parsedFromAddress,
|
|
368
|
+
rpcUrl,
|
|
369
|
+
secretKey,
|
|
370
|
+
debugExecutionStepsDir,
|
|
371
|
+
authWitness,
|
|
372
|
+
} = options;
|
|
373
|
+
|
|
374
|
+
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
375
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
376
|
+
const wallet = await account.getWallet();
|
|
377
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
378
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
379
|
+
await profile(
|
|
380
|
+
wallet,
|
|
381
|
+
functionName,
|
|
382
|
+
args,
|
|
383
|
+
artifactPath,
|
|
384
|
+
contractAddress,
|
|
385
|
+
debugExecutionStepsDir,
|
|
386
|
+
authWitnesses,
|
|
387
|
+
log,
|
|
388
|
+
);
|
|
338
389
|
});
|
|
339
390
|
|
|
340
391
|
program
|
|
@@ -372,6 +423,7 @@ export function injectCommands(
|
|
|
372
423
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
373
424
|
const { rpcUrl, l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
374
425
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
426
|
+
log(`Minting ${amount} fee juice on L1 and pushing to L2`);
|
|
375
427
|
|
|
376
428
|
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(
|
|
377
429
|
amount,
|
|
@@ -428,7 +480,7 @@ export function injectCommands(
|
|
|
428
480
|
|
|
429
481
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
430
482
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
431
|
-
const wallet = await
|
|
483
|
+
const wallet = await account.getWallet();
|
|
432
484
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
433
485
|
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
434
486
|
|
|
@@ -468,40 +520,11 @@ export function injectCommands(
|
|
|
468
520
|
|
|
469
521
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
470
522
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
471
|
-
const wallet = await
|
|
523
|
+
const wallet = await account.getWallet();
|
|
472
524
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
473
525
|
await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
474
526
|
});
|
|
475
527
|
|
|
476
|
-
program
|
|
477
|
-
.command('add-authwit')
|
|
478
|
-
.description(
|
|
479
|
-
'Adds an authorization witness to the provided account, granting PXE access to the notes of the authorizer so that it can be verified',
|
|
480
|
-
)
|
|
481
|
-
.argument('<authwit>', 'Authorization witness to add to the account', witness => aliasedAuthWitParser(witness, db))
|
|
482
|
-
.argument('<authorizer>', 'Account that provides the authorization to perform the action', address =>
|
|
483
|
-
aliasedAddressParser('accounts', address, db),
|
|
484
|
-
)
|
|
485
|
-
.addOption(pxeOption)
|
|
486
|
-
.addOption(
|
|
487
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
488
|
-
)
|
|
489
|
-
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
490
|
-
.addOption(
|
|
491
|
-
createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db),
|
|
492
|
-
)
|
|
493
|
-
.action(async (authwit, authorizer, _options, command) => {
|
|
494
|
-
const { addAuthwit } = await import('./add_authwit.js');
|
|
495
|
-
const options = command.optsWithGlobals();
|
|
496
|
-
const { from: parsedFromAddress, rpcUrl, secretKey } = options;
|
|
497
|
-
|
|
498
|
-
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
499
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
500
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
501
|
-
await addAuthwit(wallet, authwit, authorizer, log);
|
|
502
|
-
await addScopeToWallet(wallet, authorizer, db);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
528
|
program
|
|
506
529
|
.command('get-tx')
|
|
507
530
|
.description('Gets the status of the recent txs, or a detailed view if a specific transaction hash is provided')
|
|
@@ -572,7 +595,7 @@ export function injectCommands(
|
|
|
572
595
|
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
573
596
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
574
597
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
575
|
-
const wallet = await
|
|
598
|
+
const wallet = await account.getWallet();
|
|
576
599
|
|
|
577
600
|
const txData = await db?.retrieveTxData(txHash);
|
|
578
601
|
if (!txData) {
|
|
@@ -600,7 +623,7 @@ export function injectCommands(
|
|
|
600
623
|
const { from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
601
624
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
602
625
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
603
|
-
const wallet = await
|
|
626
|
+
const wallet = await account.getWallet();
|
|
604
627
|
|
|
605
628
|
await registerSender(wallet, address, log);
|
|
606
629
|
|
|
@@ -626,7 +649,7 @@ export function injectCommands(
|
|
|
626
649
|
const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
627
650
|
const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
|
|
628
651
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
629
|
-
const wallet = await
|
|
652
|
+
const wallet = await account.getWallet();
|
|
630
653
|
|
|
631
654
|
const artifactPath = await artifactPathPromise;
|
|
632
655
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress, Contract } from '@aztec/aztec.js';
|
|
2
|
+
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
6
|
+
import type { TxProfileResult } from '@aztec/stdlib/tx';
|
|
7
|
+
|
|
8
|
+
import { encode } from '@msgpack/msgpack';
|
|
9
|
+
import { promises as fs } from 'fs';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { format } from 'util';
|
|
12
|
+
|
|
13
|
+
function printProfileResult(result: TxProfileResult, log: LogFn) {
|
|
14
|
+
// TODO(AD): this is a bit misleading - the maximum gate count of any piece is as important
|
|
15
|
+
// as the total gate count. We should probably print both.
|
|
16
|
+
log(format('\nGate count per circuit:'));
|
|
17
|
+
let acc = 0;
|
|
18
|
+
result.executionSteps.forEach(r => {
|
|
19
|
+
acc += r.gateCount!;
|
|
20
|
+
log(
|
|
21
|
+
format(
|
|
22
|
+
' ',
|
|
23
|
+
r.functionName.padEnd(50),
|
|
24
|
+
'Gates:',
|
|
25
|
+
r.gateCount!.toLocaleString(),
|
|
26
|
+
'\tSubtotal:',
|
|
27
|
+
acc.toLocaleString(),
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
log(format('\nTotal gates:', acc.toLocaleString()));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// TODO(#7371): This is duplicated.
|
|
35
|
+
// Longer term we won't use this hacked together msgpack format
|
|
36
|
+
// Leaving duplicated as this eventually bb will provide a serialization
|
|
37
|
+
// helper for passing to a generic msgpack RPC endpoint.
|
|
38
|
+
async function _createClientIvcProofFiles(directory: string, executionSteps: PrivateExecutionStep[]) {
|
|
39
|
+
const acirPath = path.join(directory, 'acir.msgpack');
|
|
40
|
+
const witnessPath = path.join(directory, 'witnesses.msgpack');
|
|
41
|
+
await fs.writeFile(acirPath, encode(executionSteps.map(map => map.bytecode)));
|
|
42
|
+
await fs.writeFile(witnessPath, encode(executionSteps.map(map => serializeWitness(map.witness))));
|
|
43
|
+
return {
|
|
44
|
+
acirPath,
|
|
45
|
+
witnessPath,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function profile(
|
|
50
|
+
wallet: AccountWalletWithSecretKey,
|
|
51
|
+
functionName: string,
|
|
52
|
+
functionArgsIn: any[],
|
|
53
|
+
contractArtifactPath: string,
|
|
54
|
+
contractAddress: AztecAddress,
|
|
55
|
+
debugOutputPath: string | undefined,
|
|
56
|
+
authWitnesses: AuthWitness[],
|
|
57
|
+
log: LogFn,
|
|
58
|
+
) {
|
|
59
|
+
const profileMode = debugOutputPath ? ('full' as const) : ('gates' as const);
|
|
60
|
+
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
61
|
+
|
|
62
|
+
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
63
|
+
const call = contract.methods[functionName](...functionArgs);
|
|
64
|
+
|
|
65
|
+
const result = await call.profile({ profileMode, authWitnesses });
|
|
66
|
+
printProfileResult(result, log);
|
|
67
|
+
if (debugOutputPath) {
|
|
68
|
+
log(`Debug output written to ${debugOutputPath} (witnesses.msgpack and acir.msgpack)`);
|
|
69
|
+
await _createClientIvcProofFiles(debugOutputPath, result.executionSteps);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/cmds/send.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type AccountWalletWithSecretKey,
|
|
3
|
+
AuthWitness,
|
|
4
|
+
type AztecAddress,
|
|
5
|
+
Contract,
|
|
6
|
+
Fr,
|
|
7
|
+
type SendMethodOptions,
|
|
8
|
+
} from '@aztec/aztec.js';
|
|
2
9
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
10
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -14,6 +21,7 @@ export async function send(
|
|
|
14
21
|
wait: boolean,
|
|
15
22
|
cancellable: boolean,
|
|
16
23
|
feeOpts: IFeeOpts,
|
|
24
|
+
authWitnesses: AuthWitness[],
|
|
17
25
|
log: LogFn,
|
|
18
26
|
) {
|
|
19
27
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
@@ -21,15 +29,23 @@ export async function send(
|
|
|
21
29
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
22
30
|
const call = contract.methods[functionName](...functionArgs);
|
|
23
31
|
|
|
24
|
-
const
|
|
32
|
+
const nonce = Fr.random();
|
|
33
|
+
|
|
34
|
+
const sendOptions: SendMethodOptions = {
|
|
35
|
+
...(await feeOpts.toSendOpts(wallet)),
|
|
36
|
+
authWitnesses,
|
|
37
|
+
cancellable,
|
|
38
|
+
nonce,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const gasLimits = await call.estimateGas(sendOptions);
|
|
25
42
|
printGasEstimates(feeOpts, gasLimits, log);
|
|
26
43
|
|
|
27
44
|
if (feeOpts.estimateOnly) {
|
|
28
45
|
return;
|
|
29
46
|
}
|
|
30
47
|
|
|
31
|
-
const
|
|
32
|
-
const tx = call.send({ ...(await feeOpts.toSendOpts(wallet)), nonce, cancellable });
|
|
48
|
+
const tx = call.send(sendOptions);
|
|
33
49
|
const txHash = await tx.getTxHash();
|
|
34
50
|
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
35
51
|
if (wait) {
|
package/src/cmds/simulate.ts
CHANGED
|
@@ -1,42 +1,22 @@
|
|
|
1
|
-
import { type AccountWalletWithSecretKey, type AztecAddress, Contract
|
|
1
|
+
import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress, Contract } from '@aztec/aztec.js';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
import { format } from 'util';
|
|
6
6
|
|
|
7
|
-
function printProfileResult(result: ProfileResult, log: LogFn) {
|
|
8
|
-
log(format('\nSimulation result:'));
|
|
9
|
-
log(format('Return value:', JSON.stringify(result.returnValues, null, 2)));
|
|
10
|
-
|
|
11
|
-
log(format('\nGate count per circuit:'));
|
|
12
|
-
let acc = 0;
|
|
13
|
-
result.gateCounts.forEach(r => {
|
|
14
|
-
acc += r.gateCount;
|
|
15
|
-
log(format(' ', r.circuitName.padEnd(50), 'Gates:', r.gateCount.toLocaleString(), '\tAcc:', acc.toLocaleString()));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
log(format('\nTotal gates:', acc.toLocaleString()));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
7
|
export async function simulate(
|
|
22
8
|
wallet: AccountWalletWithSecretKey,
|
|
23
9
|
functionName: string,
|
|
24
10
|
functionArgsIn: any[],
|
|
25
11
|
contractArtifactPath: string,
|
|
26
12
|
contractAddress: AztecAddress,
|
|
27
|
-
|
|
13
|
+
authWitnesses: AuthWitness[],
|
|
28
14
|
log: LogFn,
|
|
29
15
|
) {
|
|
30
16
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
31
17
|
|
|
32
18
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
33
19
|
const call = contract.methods[functionName](...functionArgs);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const result = await call.simulateWithProfile();
|
|
37
|
-
printProfileResult(result, log);
|
|
38
|
-
} else {
|
|
39
|
-
const result = await call.simulate();
|
|
40
|
-
log(format('\nSimulation result: ', result, '\n'));
|
|
41
|
-
}
|
|
20
|
+
const result = await call.simulate({ authWitnesses });
|
|
21
|
+
log(format('\nSimulation result: ', result, '\n'));
|
|
42
22
|
}
|
package/src/utils/accounts.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
|
-
import type { AccountManager
|
|
2
|
+
import type { AccountManager } from '@aztec/aztec.js';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
@@ -70,33 +70,3 @@ export async function createOrRetrieveAccount(
|
|
|
70
70
|
|
|
71
71
|
return account;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
export async function addScopeToWallet(wallet: AccountWalletWithSecretKey, scope: AztecAddress, db?: WalletDB) {
|
|
75
|
-
const address = wallet.getAddress().toString();
|
|
76
|
-
const currentScopes = wallet.getScopes() ?? [];
|
|
77
|
-
const deduplicatedScopes = Array.from(
|
|
78
|
-
new Set([address, ...currentScopes, scope].map(scope => scope.toString())).values(),
|
|
79
|
-
);
|
|
80
|
-
if (db) {
|
|
81
|
-
await db.storeAccountMetadata(wallet.getAddress(), 'scopes', Buffer.from(deduplicatedScopes.join(',')));
|
|
82
|
-
}
|
|
83
|
-
wallet.setScopes(deduplicatedScopes.map(scope => AztecAddress.fromString(scope)));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function getWalletWithScopes(account: AccountManager, db?: WalletDB) {
|
|
87
|
-
const wallet = await account.getWallet();
|
|
88
|
-
if (db) {
|
|
89
|
-
const address = wallet.getAddress().toString();
|
|
90
|
-
let storedScopes: string[] = [];
|
|
91
|
-
try {
|
|
92
|
-
storedScopes = ((await db.retrieveAccountMetadata(wallet.getAddress(), 'scopes')) ?? '').toString().split(',');
|
|
93
|
-
// eslint-disable-next-line no-empty
|
|
94
|
-
} catch {}
|
|
95
|
-
const currentScopes = wallet.getScopes()?.map(scopes => scopes.toString()) ?? [];
|
|
96
|
-
const deduplicatedScopes = Array.from(new Set([address, ...currentScopes, ...storedScopes]).values()).map(scope =>
|
|
97
|
-
AztecAddress.fromString(scope),
|
|
98
|
-
);
|
|
99
|
-
wallet.setScopes(deduplicatedScopes);
|
|
100
|
-
}
|
|
101
|
-
return wallet;
|
|
102
|
-
}
|
|
@@ -15,7 +15,6 @@ import { Option } from 'commander';
|
|
|
15
15
|
|
|
16
16
|
import type { WalletDB } from '../../storage/wallet_db.js';
|
|
17
17
|
import { createOrRetrieveAccount } from '../accounts.js';
|
|
18
|
-
import { SponsoredFeePaymentMethod } from '../sponsored_fee_payment.js';
|
|
19
18
|
import { aliasedAddressParser } from './options.js';
|
|
20
19
|
|
|
21
20
|
export type CliFeeArgs = {
|
|
@@ -325,6 +324,8 @@ export function parsePaymentMethod(
|
|
|
325
324
|
}
|
|
326
325
|
case 'fpc-sponsored': {
|
|
327
326
|
const sponsor = getFpc();
|
|
327
|
+
log(`Using sponsored fee payment with sponsor ${sponsor}`);
|
|
328
|
+
const { SponsoredFeePaymentMethod } = await import('@aztec/aztec.js/fee/testing');
|
|
328
329
|
return new SponsoredFeePaymentMethod(sponsor);
|
|
329
330
|
}
|
|
330
331
|
case undefined:
|
|
@@ -79,6 +79,12 @@ export function createAccountOption(description: string, hide: boolean, db?: Wal
|
|
|
79
79
|
.argParser(address => aliasedAddressParser('accounts', address, db));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export function createAuthwitnessOption(description: string, hide: boolean, db?: WalletDB) {
|
|
83
|
+
return new Option('-aw, --auth-witness <string>', description)
|
|
84
|
+
.hideHelp(hide)
|
|
85
|
+
.argParser(witness => aliasedAuthWitParser(witness, db));
|
|
86
|
+
}
|
|
87
|
+
|
|
82
88
|
export function createTypeOption(mandatory: boolean) {
|
|
83
89
|
return new Option('-t, --type <string>', 'Type of account to create')
|
|
84
90
|
.choices(AccountTypes)
|
|
@@ -103,6 +109,13 @@ export function createContractAddressOption(db?: WalletDB) {
|
|
|
103
109
|
.makeOptionMandatory(true);
|
|
104
110
|
}
|
|
105
111
|
|
|
112
|
+
export function createDebugExecutionStepsDirOption() {
|
|
113
|
+
return new Option(
|
|
114
|
+
'--debug-execution-steps-dir <address>',
|
|
115
|
+
'Directory to write execution step artifacts for bb profiling/debugging.',
|
|
116
|
+
).makeOptionMandatory(false);
|
|
117
|
+
}
|
|
118
|
+
|
|
106
119
|
export function artifactPathParser(filePath: string, db?: WalletDB) {
|
|
107
120
|
if (filePath.includes('@')) {
|
|
108
121
|
const [pkg, contractName] = filePath.split('@');
|
|
@@ -140,13 +153,6 @@ export function createArtifactOption(db?: WalletDB) {
|
|
|
140
153
|
.makeOptionMandatory(false);
|
|
141
154
|
}
|
|
142
155
|
|
|
143
|
-
export function createProfileOption() {
|
|
144
|
-
return new Option(
|
|
145
|
-
'-p, --profile',
|
|
146
|
-
'Run the real prover and get the gate count for each function in the transaction.',
|
|
147
|
-
).default(false);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
156
|
async function contractArtifactFromWorkspace(pkg?: string, contractName?: string) {
|
|
151
157
|
const cwd = process.cwd();
|
|
152
158
|
try {
|
|
@@ -173,3 +179,8 @@ async function contractArtifactFromWorkspace(pkg?: string, contractName?: string
|
|
|
173
179
|
}
|
|
174
180
|
return `${cwd}/${TARGET_DIR}/${bestMatch[0]}`;
|
|
175
181
|
}
|
|
182
|
+
|
|
183
|
+
export function cleanupAuthWitnesses(authWitnesses: AuthWitness | AuthWitness[]): AuthWitness[] {
|
|
184
|
+
const authWitnessArray = Array.isArray(authWitnesses) ? authWitnesses : [authWitnesses];
|
|
185
|
+
return authWitnessArray.filter(w => w !== undefined);
|
|
186
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AccountWalletWithSecretKey, AuthWitness, AztecAddress } from '@aztec/aztec.js';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function addAuthwit(wallet: AccountWalletWithSecretKey, authwit: AuthWitness, authorizer: AztecAddress, log: LogFn): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=add_authwit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/add_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,YAAY,EACxB,GAAG,EAAE,KAAK,iBAKX"}
|
package/dest/cmds/add_authwit.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
2
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
export declare class SponsoredFeePaymentMethod implements FeePaymentMethod {
|
|
5
|
-
private paymentContract;
|
|
6
|
-
constructor(paymentContract: AztecAddress);
|
|
7
|
-
getAsset(): Promise<AztecAddress>;
|
|
8
|
-
getFeePayer(): Promise<AztecAddress>;
|
|
9
|
-
getFunctionCalls(): Promise<{
|
|
10
|
-
name: string;
|
|
11
|
-
to: AztecAddress;
|
|
12
|
-
selector: FunctionSelector;
|
|
13
|
-
type: FunctionType;
|
|
14
|
-
isStatic: boolean;
|
|
15
|
-
args: never[];
|
|
16
|
-
returnTypes: never[];
|
|
17
|
-
}[]>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=sponsored_fee_payment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sponsored_fee_payment.d.ts","sourceRoot":"","sources":["../../src/utils/sponsored_fee_payment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,qBAAa,yBAA0B,YAAW,gBAAgB;IACpD,OAAO,CAAC,eAAe;gBAAf,eAAe,EAAE,YAAY;IAEjD,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW;IAIL,gBAAgB;;;;;;;;;CAavB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
2
|
-
export class SponsoredFeePaymentMethod {
|
|
3
|
-
paymentContract;
|
|
4
|
-
constructor(paymentContract){
|
|
5
|
-
this.paymentContract = paymentContract;
|
|
6
|
-
}
|
|
7
|
-
getAsset() {
|
|
8
|
-
throw new Error('Asset is not required for sponsored fpc.');
|
|
9
|
-
}
|
|
10
|
-
getFeePayer() {
|
|
11
|
-
return Promise.resolve(this.paymentContract);
|
|
12
|
-
}
|
|
13
|
-
async getFunctionCalls() {
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
name: 'sponsor_unconditionally',
|
|
17
|
-
to: this.paymentContract,
|
|
18
|
-
selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
|
|
19
|
-
type: FunctionType.PRIVATE,
|
|
20
|
-
isStatic: false,
|
|
21
|
-
args: [],
|
|
22
|
-
returnTypes: []
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/cmds/add_authwit.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AccountWalletWithSecretKey, AuthWitness, AztecAddress } from '@aztec/aztec.js';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
|
|
4
|
-
export async function addAuthwit(
|
|
5
|
-
wallet: AccountWalletWithSecretKey,
|
|
6
|
-
authwit: AuthWitness,
|
|
7
|
-
authorizer: AztecAddress,
|
|
8
|
-
log: LogFn,
|
|
9
|
-
) {
|
|
10
|
-
await wallet.addAuthWitness(authwit);
|
|
11
|
-
|
|
12
|
-
log(`Added authorization witness from ${authorizer}`);
|
|
13
|
-
}
|