@aztec/cli-wallet 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +38 -23
- package/dest/cmds/authorize_action.d.ts +4 -3
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +6 -7
- package/dest/cmds/bridge_fee_juice.d.ts +4 -4
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +9 -7
- package/dest/cmds/check_tx.d.ts +5 -3
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +144 -6
- package/dest/cmds/create_account.d.ts +7 -6
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +36 -48
- package/dest/cmds/create_authwit.d.ts +4 -3
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +6 -6
- package/dest/cmds/deploy.d.ts +7 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +57 -46
- package/dest/cmds/deploy_account.d.ts +6 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +36 -51
- package/dest/cmds/import_test_accounts.d.ts +3 -3
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +6 -9
- package/dest/cmds/index.d.ts +3 -3
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +73 -112
- package/dest/cmds/profile.d.ts +7 -4
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +9 -4
- package/dest/cmds/register_contract.d.ts +7 -3
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +5 -6
- package/dest/cmds/register_sender.d.ts +4 -3
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +8 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -24
- package/dest/cmds/simulate.d.ts +7 -4
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +9 -4
- package/dest/storage/wallet_db.d.ts +6 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +2 -23
- package/dest/utils/authorizations.d.ts +3 -2
- package/dest/utils/authorizations.d.ts.map +1 -1
- package/dest/utils/authorizations.js +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/ecdsa.d.ts +1 -1
- package/dest/utils/options/fees.d.ts +22 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +66 -133
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +4 -3
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/wallet.d.ts +36 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +195 -0
- package/package.json +17 -14
- package/src/bin/index.ts +38 -31
- package/src/cmds/authorize_action.ts +14 -6
- package/src/cmds/bridge_fee_juice.ts +15 -11
- package/src/cmds/check_tx.ts +181 -5
- package/src/cmds/create_account.ts +43 -53
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +58 -56
- package/src/cmds/deploy_account.ts +43 -51
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +120 -206
- package/src/cmds/profile.ts +14 -6
- package/src/cmds/register_contract.ts +9 -11
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +22 -32
- package/src/cmds/simulate.ts +14 -6
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +3 -1
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +88 -178
- package/src/utils/options/options.ts +3 -2
- package/src/utils/wallet.ts +266 -0
- package/dest/cmds/cancel_tx.d.ts +0 -11
- package/dest/cmds/cancel_tx.d.ts.map +0 -1
- package/dest/cmds/cancel_tx.js +0 -43
- package/dest/utils/accounts.d.ts +0 -9
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -61
- package/dest/utils/pxe_wrapper.d.ts +0 -12
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -26
- package/src/cmds/cancel_tx.ts +0 -66
- package/src/utils/accounts.ts +0 -77
- package/src/utils/pxe_wrapper.ts +0 -32
package/src/cmds/index.ts
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import { CopyCatAccountWallet } from '@aztec/accounts/copy-cat';
|
|
2
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
3
|
-
import {
|
|
4
|
-
import { TxHash } from '@aztec/aztec.js/tx_hash';
|
|
2
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
5
3
|
import {
|
|
6
4
|
ETHEREUM_HOSTS,
|
|
7
5
|
PRIVATE_KEY,
|
|
8
6
|
addOptions,
|
|
9
7
|
createSecretKeyOption,
|
|
10
8
|
l1ChainIdOption,
|
|
11
|
-
logJson,
|
|
12
9
|
parseBigint,
|
|
13
10
|
parseFieldFromHexString,
|
|
14
11
|
parsePublicKey,
|
|
15
|
-
pxeOption,
|
|
16
12
|
} from '@aztec/cli/utils';
|
|
13
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
17
14
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
18
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
19
|
-
import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
20
15
|
|
|
21
16
|
import { type Command, Option } from 'commander';
|
|
22
17
|
import inquirer from 'inquirer';
|
|
23
18
|
|
|
24
19
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
25
|
-
import
|
|
26
|
-
import { FeeOpts, FeeOptsWithFeePayer } from '../utils/options/fees.js';
|
|
20
|
+
import type { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
27
21
|
import {
|
|
28
22
|
ARTIFACT_DESCRIPTION,
|
|
23
|
+
CLIFeeArgs,
|
|
29
24
|
aliasedAddressParser,
|
|
30
25
|
aliasedSecretKeyParser,
|
|
31
26
|
aliasedTxHashParser,
|
|
@@ -42,33 +37,27 @@ import {
|
|
|
42
37
|
createTypeOption,
|
|
43
38
|
createVerboseOption,
|
|
44
39
|
integerArgParser,
|
|
45
|
-
parseGasFees,
|
|
46
|
-
parsePaymentMethod,
|
|
47
40
|
} from '../utils/options/index.js';
|
|
48
|
-
import type {
|
|
41
|
+
import type { AccountType } from '../utils/wallet.js';
|
|
49
42
|
|
|
43
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
50
44
|
export function injectCommands(
|
|
51
45
|
program: Command,
|
|
52
46
|
log: LogFn,
|
|
53
47
|
debugLogger: Logger,
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
walletAndNodeWrapper: CliWalletAndNodeWrapper,
|
|
49
|
+
db: WalletDB,
|
|
56
50
|
) {
|
|
57
51
|
program
|
|
58
52
|
.command('import-test-accounts')
|
|
59
53
|
.description('Import test accounts from pxe.')
|
|
60
|
-
.addOption(pxeOption)
|
|
61
54
|
.option('--json', 'Emit output as json')
|
|
62
55
|
.action(async options => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
56
|
+
const { json } = options;
|
|
57
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
67
58
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
68
|
-
const { rpcUrl, json } = options;
|
|
69
59
|
|
|
70
|
-
|
|
71
|
-
await importTestAccounts(client, db, json, log);
|
|
60
|
+
await importTestAccounts(wallet, db, json, log);
|
|
72
61
|
});
|
|
73
62
|
|
|
74
63
|
const createAccountCommand = program
|
|
@@ -77,6 +66,7 @@ export function injectCommands(
|
|
|
77
66
|
'Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).',
|
|
78
67
|
)
|
|
79
68
|
.summary('Creates an aztec account that can be used for sending transactions.')
|
|
69
|
+
.addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db))
|
|
80
70
|
.option(
|
|
81
71
|
'--skip-initialization',
|
|
82
72
|
'Skip initializing the account contract. Useful for publicly deploying an existing account.',
|
|
@@ -85,11 +75,14 @@ export function injectCommands(
|
|
|
85
75
|
'--public-deploy',
|
|
86
76
|
'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.',
|
|
87
77
|
)
|
|
78
|
+
.option(
|
|
79
|
+
'--register-class',
|
|
80
|
+
'Register the contract class (useful for when the contract class has not been deployed yet).',
|
|
81
|
+
)
|
|
88
82
|
.option(
|
|
89
83
|
'-p, --public-key <string>',
|
|
90
84
|
'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.',
|
|
91
85
|
)
|
|
92
|
-
.addOption(pxeOption)
|
|
93
86
|
.addOption(
|
|
94
87
|
createSecretKeyOption('Secret key for account. Uses random by default.', false, sk =>
|
|
95
88
|
aliasedSecretKeyParser(sk, db),
|
|
@@ -99,7 +92,7 @@ export function injectCommands(
|
|
|
99
92
|
.addOption(createTypeOption(true))
|
|
100
93
|
.option(
|
|
101
94
|
'--register-only',
|
|
102
|
-
'Just register the account on the
|
|
95
|
+
'Just register the account on the Wallet. Do not deploy or initialize the account contract.',
|
|
103
96
|
)
|
|
104
97
|
.option('--json', 'Emit output as json')
|
|
105
98
|
// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
@@ -107,11 +100,22 @@ export function injectCommands(
|
|
|
107
100
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
108
101
|
.addOption(createVerboseOption());
|
|
109
102
|
|
|
110
|
-
addOptions(createAccountCommand,
|
|
103
|
+
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command) => {
|
|
111
104
|
const { createAccount } = await import('./create_account.js');
|
|
112
105
|
const options = command.optsWithGlobals();
|
|
113
|
-
const {
|
|
114
|
-
|
|
106
|
+
const {
|
|
107
|
+
type,
|
|
108
|
+
from: parsedFromAddress,
|
|
109
|
+
secretKey,
|
|
110
|
+
wait,
|
|
111
|
+
registerOnly,
|
|
112
|
+
skipInitialization,
|
|
113
|
+
publicDeploy,
|
|
114
|
+
registerClass,
|
|
115
|
+
alias,
|
|
116
|
+
json,
|
|
117
|
+
verbose,
|
|
118
|
+
} = options;
|
|
115
119
|
let { publicKey } = options;
|
|
116
120
|
if ((type as AccountType) === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
117
121
|
const identities = await getIdentities();
|
|
@@ -126,18 +130,22 @@ export function injectCommands(
|
|
|
126
130
|
]);
|
|
127
131
|
publicKey = answers.identity.split(' ')[1];
|
|
128
132
|
}
|
|
129
|
-
|
|
133
|
+
|
|
134
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
130
135
|
const accountCreationResult = await createAccount(
|
|
131
|
-
|
|
136
|
+
wallet,
|
|
137
|
+
node,
|
|
132
138
|
type,
|
|
133
139
|
secretKey,
|
|
134
140
|
publicKey,
|
|
135
141
|
alias,
|
|
142
|
+
parsedFromAddress,
|
|
136
143
|
registerOnly,
|
|
137
144
|
skipInitialization,
|
|
138
145
|
publicDeploy,
|
|
146
|
+
registerClass,
|
|
139
147
|
wait,
|
|
140
|
-
|
|
148
|
+
CLIFeeArgs.parse(options, log, db),
|
|
141
149
|
json,
|
|
142
150
|
verbose,
|
|
143
151
|
debugLogger,
|
|
@@ -152,8 +160,10 @@ export function injectCommands(
|
|
|
152
160
|
const deployAccountCommand = program
|
|
153
161
|
.command('deploy-account')
|
|
154
162
|
.description('Deploys an already registered aztec account that can be used for sending transactions.')
|
|
155
|
-
.
|
|
156
|
-
|
|
163
|
+
.argument('<address>', 'The address of the contract to register', address =>
|
|
164
|
+
aliasedAddressParser('accounts', address, db),
|
|
165
|
+
)
|
|
166
|
+
.addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db))
|
|
157
167
|
.option('--json', 'Emit output as json')
|
|
158
168
|
// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
159
169
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
@@ -166,22 +176,29 @@ export function injectCommands(
|
|
|
166
176
|
'--public-deploy',
|
|
167
177
|
'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.',
|
|
168
178
|
)
|
|
179
|
+
.option(
|
|
180
|
+
'--skip-initialization',
|
|
181
|
+
'Skip initializing the account contract. Useful for publicly deploying an existing account.',
|
|
182
|
+
)
|
|
169
183
|
.addOption(createVerboseOption());
|
|
170
184
|
|
|
171
|
-
addOptions(deployAccountCommand,
|
|
185
|
+
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command) => {
|
|
172
186
|
const { deployAccount } = await import('./deploy_account.js');
|
|
173
187
|
const options = command.optsWithGlobals();
|
|
174
|
-
const {
|
|
188
|
+
const { wait, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
175
189
|
|
|
176
|
-
const
|
|
177
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db);
|
|
190
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
178
191
|
|
|
179
192
|
await deployAccount(
|
|
180
|
-
|
|
193
|
+
wallet,
|
|
194
|
+
node,
|
|
195
|
+
parsedAccount,
|
|
181
196
|
wait,
|
|
197
|
+
parsedFromAddress,
|
|
182
198
|
registerClass,
|
|
183
199
|
publicDeploy,
|
|
184
|
-
|
|
200
|
+
skipInitialization,
|
|
201
|
+
CLIFeeArgs.parse(options, log, db),
|
|
185
202
|
json,
|
|
186
203
|
verbose,
|
|
187
204
|
debugLogger,
|
|
@@ -206,11 +223,7 @@ export function injectCommands(
|
|
|
206
223
|
parseFieldFromHexString,
|
|
207
224
|
)
|
|
208
225
|
.option('--universal', 'Do not mix the sender address into the deployment.')
|
|
209
|
-
.addOption(pxeOption)
|
|
210
226
|
.addOption(createArgsOption(true, db))
|
|
211
|
-
.addOption(
|
|
212
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
213
|
-
)
|
|
214
227
|
.addOption(createAccountOption('Alias or address of the account to deploy from', !db, db))
|
|
215
228
|
.addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db))
|
|
216
229
|
.option('--json', 'Emit output as json')
|
|
@@ -227,7 +240,7 @@ export function injectCommands(
|
|
|
227
240
|
)
|
|
228
241
|
.addOption(createVerboseOption());
|
|
229
242
|
|
|
230
|
-
addOptions(deployCommand,
|
|
243
|
+
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command) => {
|
|
231
244
|
const { deploy } = await import('./deploy.js');
|
|
232
245
|
const options = command.optsWithGlobals();
|
|
233
246
|
const {
|
|
@@ -236,27 +249,25 @@ export function injectCommands(
|
|
|
236
249
|
args,
|
|
237
250
|
salt,
|
|
238
251
|
wait,
|
|
239
|
-
secretKey,
|
|
240
252
|
classRegistration,
|
|
241
253
|
init,
|
|
242
254
|
publicDeployment,
|
|
243
255
|
universal,
|
|
244
|
-
rpcUrl,
|
|
245
256
|
from: parsedFromAddress,
|
|
246
257
|
alias,
|
|
247
258
|
timeout,
|
|
248
259
|
verbose,
|
|
249
260
|
} = options;
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
const wallet = await account.getWallet();
|
|
261
|
+
|
|
262
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
253
263
|
const artifactPath = await artifactPathPromise;
|
|
254
264
|
|
|
255
|
-
debugLogger.info(`Using wallet with address ${
|
|
265
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
256
266
|
|
|
257
267
|
const address = await deploy(
|
|
258
268
|
wallet,
|
|
259
|
-
|
|
269
|
+
node,
|
|
270
|
+
universal ? undefined : parsedFromAddress,
|
|
260
271
|
artifactPath,
|
|
261
272
|
json,
|
|
262
273
|
publicKey,
|
|
@@ -267,12 +278,11 @@ export function injectCommands(
|
|
|
267
278
|
!classRegistration,
|
|
268
279
|
typeof init === 'string' ? false : init,
|
|
269
280
|
wait,
|
|
270
|
-
|
|
281
|
+
CLIFeeArgs.parse(options, log, db),
|
|
271
282
|
timeout,
|
|
272
283
|
verbose,
|
|
273
284
|
debugLogger,
|
|
274
285
|
log,
|
|
275
|
-
logJson(log),
|
|
276
286
|
);
|
|
277
287
|
if (db && address) {
|
|
278
288
|
await db.storeContract(address, artifactPath, log, alias);
|
|
@@ -283,16 +293,12 @@ export function injectCommands(
|
|
|
283
293
|
.command('send')
|
|
284
294
|
.description('Calls a function on an Aztec contract.')
|
|
285
295
|
.argument('<functionName>', 'Name of function to execute')
|
|
286
|
-
.addOption(pxeOption)
|
|
287
296
|
.addOption(createArgsOption(false, db))
|
|
288
297
|
.addOption(createArtifactOption(db))
|
|
289
298
|
.addOption(createContractAddressOption(db))
|
|
290
299
|
.addOption(
|
|
291
300
|
createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db),
|
|
292
301
|
)
|
|
293
|
-
.addOption(
|
|
294
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
295
|
-
)
|
|
296
302
|
.addOption(
|
|
297
303
|
createAuthwitnessOption(
|
|
298
304
|
'Authorization witness to use for the transaction. If using multiple, pass a comma separated string',
|
|
@@ -302,10 +308,9 @@ export function injectCommands(
|
|
|
302
308
|
)
|
|
303
309
|
.addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db))
|
|
304
310
|
.option('--no-wait', 'Print transaction hash without waiting for it to be mined')
|
|
305
|
-
.option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.')
|
|
306
311
|
.addOption(createVerboseOption());
|
|
307
312
|
|
|
308
|
-
addOptions(sendCommand,
|
|
313
|
+
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command) => {
|
|
309
314
|
const { send } = await import('./send.js');
|
|
310
315
|
const options = command.optsWithGlobals();
|
|
311
316
|
const {
|
|
@@ -314,36 +319,34 @@ export function injectCommands(
|
|
|
314
319
|
contractAddress,
|
|
315
320
|
from: parsedFromAddress,
|
|
316
321
|
wait,
|
|
317
|
-
rpcUrl,
|
|
318
|
-
secretKey,
|
|
319
322
|
alias,
|
|
320
|
-
cancel,
|
|
321
323
|
authWitness: authWitnessArray,
|
|
322
324
|
verbose,
|
|
323
325
|
} = options;
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
const wallet = await account.getWallet();
|
|
326
|
+
|
|
327
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
327
328
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
328
329
|
|
|
329
|
-
debugLogger.info(`Using wallet with address ${
|
|
330
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
330
331
|
|
|
331
332
|
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
332
333
|
const sentTx = await send(
|
|
333
334
|
wallet,
|
|
335
|
+
node,
|
|
336
|
+
parsedFromAddress,
|
|
334
337
|
functionName,
|
|
335
338
|
args,
|
|
336
339
|
artifactPath,
|
|
337
340
|
contractAddress,
|
|
338
341
|
wait,
|
|
339
|
-
|
|
340
|
-
|
|
342
|
+
alias,
|
|
343
|
+
CLIFeeArgs.parse(options, log, db),
|
|
341
344
|
authWitnesses,
|
|
342
345
|
verbose,
|
|
343
346
|
log,
|
|
344
347
|
);
|
|
345
348
|
if (db && sentTx) {
|
|
346
|
-
const txAlias = alias ? alias : `${functionName}-${
|
|
349
|
+
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
347
350
|
await db.storeTx(sentTx, log, txAlias);
|
|
348
351
|
}
|
|
349
352
|
});
|
|
@@ -352,7 +355,6 @@ export function injectCommands(
|
|
|
352
355
|
.command('simulate')
|
|
353
356
|
.description('Simulates the execution of a function on an Aztec contract.')
|
|
354
357
|
.argument('<functionName>', 'Name of function to simulate')
|
|
355
|
-
.addOption(pxeOption)
|
|
356
358
|
.addOption(createArgsOption(false, db))
|
|
357
359
|
.addOption(createContractAddressOption(db))
|
|
358
360
|
.addOption(createArtifactOption(db))
|
|
@@ -363,7 +365,7 @@ export function injectCommands(
|
|
|
363
365
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
364
366
|
.addOption(createVerboseOption());
|
|
365
367
|
|
|
366
|
-
addOptions(simulateCommand,
|
|
368
|
+
addOptions(simulateCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command) => {
|
|
367
369
|
const { simulate } = await import('./simulate.js');
|
|
368
370
|
const options = command.optsWithGlobals();
|
|
369
371
|
const {
|
|
@@ -371,25 +373,23 @@ export function injectCommands(
|
|
|
371
373
|
contractArtifact: artifactPathPromise,
|
|
372
374
|
contractAddress,
|
|
373
375
|
from: parsedFromAddress,
|
|
374
|
-
rpcUrl,
|
|
375
|
-
secretKey,
|
|
376
376
|
verbose,
|
|
377
377
|
authWitness,
|
|
378
378
|
} = options;
|
|
379
379
|
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
const originalWallet = await account.getWallet();
|
|
383
|
-
const wallet = await CopyCatAccountWallet.create(client, originalWallet);
|
|
380
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
381
|
+
|
|
384
382
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
385
383
|
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
386
384
|
await simulate(
|
|
387
385
|
wallet,
|
|
386
|
+
node,
|
|
387
|
+
parsedFromAddress,
|
|
388
388
|
functionName,
|
|
389
389
|
args,
|
|
390
390
|
artifactPath,
|
|
391
391
|
contractAddress,
|
|
392
|
-
|
|
392
|
+
CLIFeeArgs.parse(options, log, db),
|
|
393
393
|
authWitnesses,
|
|
394
394
|
verbose,
|
|
395
395
|
log,
|
|
@@ -400,18 +400,14 @@ export function injectCommands(
|
|
|
400
400
|
.command('profile')
|
|
401
401
|
.description('Profiles a private function by counting the unconditional operations in its execution steps')
|
|
402
402
|
.argument('<functionName>', 'Name of function to simulate')
|
|
403
|
-
.addOption(pxeOption)
|
|
404
403
|
.addOption(createArgsOption(false, db))
|
|
405
404
|
.addOption(createContractAddressOption(db))
|
|
406
405
|
.addOption(createArtifactOption(db))
|
|
407
406
|
.addOption(createDebugExecutionStepsDirOption())
|
|
408
|
-
.addOption(
|
|
409
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
410
|
-
)
|
|
411
407
|
.addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
|
|
412
408
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db));
|
|
413
409
|
|
|
414
|
-
addOptions(profileCommand,
|
|
410
|
+
addOptions(profileCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command) => {
|
|
415
411
|
const { profile } = await import('./profile.js');
|
|
416
412
|
const options = command.optsWithGlobals();
|
|
417
413
|
const {
|
|
@@ -419,25 +415,24 @@ export function injectCommands(
|
|
|
419
415
|
contractArtifact: artifactPathPromise,
|
|
420
416
|
contractAddress,
|
|
421
417
|
from: parsedFromAddress,
|
|
422
|
-
rpcUrl,
|
|
423
|
-
secretKey,
|
|
424
418
|
debugExecutionStepsDir,
|
|
425
419
|
authWitness,
|
|
426
420
|
} = options;
|
|
427
421
|
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
const wallet = await account.getWallet();
|
|
422
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
423
|
+
|
|
431
424
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
432
425
|
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
433
426
|
await profile(
|
|
434
427
|
wallet,
|
|
428
|
+
node,
|
|
429
|
+
parsedFromAddress,
|
|
435
430
|
functionName,
|
|
436
431
|
args,
|
|
437
432
|
artifactPath,
|
|
438
433
|
contractAddress,
|
|
439
434
|
debugExecutionStepsDir,
|
|
440
|
-
|
|
435
|
+
CLIFeeArgs.parse(options, log, db),
|
|
441
436
|
authWitnesses,
|
|
442
437
|
log,
|
|
443
438
|
);
|
|
@@ -463,12 +458,11 @@ export function injectCommands(
|
|
|
463
458
|
)
|
|
464
459
|
.option('--mint', 'Mint the tokens on L1', false)
|
|
465
460
|
.option('--l1-private-key <string>', 'The private key to the eth account bridging', PRIVATE_KEY)
|
|
466
|
-
.addOption(pxeOption)
|
|
467
461
|
.addOption(l1ChainIdOption)
|
|
468
462
|
.option('--json', 'Output the claim in JSON format')
|
|
469
463
|
// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
470
464
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
471
|
-
.option('--no-wait', 'Wait for the
|
|
465
|
+
.option('--no-wait', 'Wait for the bridged funds to be available in L2, polling every 60 seconds')
|
|
472
466
|
.addOption(
|
|
473
467
|
new Option('--interval <number>', 'The polling interval in seconds for the bridged funds')
|
|
474
468
|
.default('60')
|
|
@@ -476,13 +470,12 @@ export function injectCommands(
|
|
|
476
470
|
)
|
|
477
471
|
.action(async (amount, recipient, options) => {
|
|
478
472
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
479
|
-
const {
|
|
480
|
-
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
473
|
+
const { l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
481
474
|
|
|
482
475
|
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(
|
|
483
476
|
amount,
|
|
484
477
|
recipient,
|
|
485
|
-
|
|
478
|
+
walletAndNodeWrapper.node,
|
|
486
479
|
l1RpcUrls,
|
|
487
480
|
l1ChainId,
|
|
488
481
|
l1PrivateKey,
|
|
@@ -508,13 +501,9 @@ export function injectCommands(
|
|
|
508
501
|
.argument('<caller>', 'Account to be authorized to perform the action', address =>
|
|
509
502
|
aliasedAddressParser('accounts', address, db),
|
|
510
503
|
)
|
|
511
|
-
.addOption(pxeOption)
|
|
512
504
|
.addOption(createArgsOption(false, db))
|
|
513
505
|
.addOption(createContractAddressOption(db))
|
|
514
506
|
.addOption(createArtifactOption(db))
|
|
515
|
-
.addOption(
|
|
516
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
517
|
-
)
|
|
518
507
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
519
508
|
.addOption(
|
|
520
509
|
createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db),
|
|
@@ -522,21 +511,20 @@ export function injectCommands(
|
|
|
522
511
|
.action(async (functionName, caller, _options, command) => {
|
|
523
512
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
524
513
|
const options = command.optsWithGlobals();
|
|
525
|
-
const {
|
|
514
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, alias } = options;
|
|
515
|
+
|
|
516
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
517
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
518
|
+
const witness = await createAuthwit(
|
|
519
|
+
wallet,
|
|
520
|
+
parsedFromAddress,
|
|
521
|
+
functionName,
|
|
522
|
+
caller,
|
|
526
523
|
args,
|
|
527
|
-
|
|
524
|
+
artifactPath,
|
|
528
525
|
contractAddress,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
secretKey,
|
|
532
|
-
alias,
|
|
533
|
-
} = options;
|
|
534
|
-
|
|
535
|
-
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
536
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
537
|
-
const wallet = await account.getWallet();
|
|
538
|
-
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
539
|
-
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
526
|
+
log,
|
|
527
|
+
);
|
|
540
528
|
|
|
541
529
|
if (db) {
|
|
542
530
|
await db.storeAuthwitness(witness, log, alias);
|
|
@@ -552,47 +540,25 @@ export function injectCommands(
|
|
|
552
540
|
.argument('<caller>', 'Account to be authorized to perform the action', address =>
|
|
553
541
|
aliasedAddressParser('accounts', address, db),
|
|
554
542
|
)
|
|
555
|
-
.addOption(pxeOption)
|
|
556
543
|
.addOption(createArgsOption(false, db))
|
|
557
544
|
.addOption(createContractAddressOption(db))
|
|
558
545
|
.addOption(createArtifactOption(db))
|
|
559
|
-
.addOption(
|
|
560
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
561
|
-
)
|
|
562
546
|
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
563
547
|
.action(async (functionName, caller, _options, command) => {
|
|
564
548
|
const { authorizeAction } = await import('./authorize_action.js');
|
|
565
549
|
const options = command.optsWithGlobals();
|
|
566
|
-
const {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
from: parsedFromAddress,
|
|
571
|
-
rpcUrl,
|
|
572
|
-
secretKey,
|
|
573
|
-
} = options;
|
|
574
|
-
|
|
575
|
-
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
576
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
577
|
-
const wallet = await account.getWallet();
|
|
550
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress } = options;
|
|
551
|
+
|
|
552
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
553
|
+
|
|
578
554
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
579
|
-
await authorizeAction(
|
|
580
|
-
wallet,
|
|
581
|
-
wallet.getAddress(),
|
|
582
|
-
functionName,
|
|
583
|
-
caller,
|
|
584
|
-
args,
|
|
585
|
-
artifactPath,
|
|
586
|
-
contractAddress,
|
|
587
|
-
log,
|
|
588
|
-
);
|
|
555
|
+
await authorizeAction(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
589
556
|
});
|
|
590
557
|
|
|
591
558
|
program
|
|
592
559
|
.command('get-tx')
|
|
593
560
|
.description('Gets the status of the recent txs, or a detailed view if a specific transaction hash is provided')
|
|
594
561
|
.argument('[txHash]', 'A transaction hash to get the receipt for.', txHash => aliasedTxHashParser(txHash, db))
|
|
595
|
-
.addOption(pxeOption)
|
|
596
562
|
.option('-p, --page <number>', 'The page number to display', value => integerArgParser(value, '--page', 1), 1)
|
|
597
563
|
.option(
|
|
598
564
|
'-s, --page-size <number>',
|
|
@@ -602,12 +568,14 @@ export function injectCommands(
|
|
|
602
568
|
)
|
|
603
569
|
.action(async (txHash, options) => {
|
|
604
570
|
const { checkTx } = await import('./check_tx.js');
|
|
605
|
-
const {
|
|
571
|
+
const { pageSize } = options;
|
|
606
572
|
let { page } = options;
|
|
607
|
-
|
|
573
|
+
|
|
574
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
575
|
+
const node = walletAndNodeWrapper.node;
|
|
608
576
|
|
|
609
577
|
if (txHash) {
|
|
610
|
-
await checkTx(
|
|
578
|
+
await checkTx(wallet, node, txHash, false, log);
|
|
611
579
|
} else if (db) {
|
|
612
580
|
const aliases = await db.listAliases('transactions');
|
|
613
581
|
const totalPages = Math.ceil(aliases.length / pageSize);
|
|
@@ -616,17 +584,16 @@ export function injectCommands(
|
|
|
616
584
|
aliases.slice(page * pageSize, pageSize * (1 + page)).map(async ({ key, value }) => ({
|
|
617
585
|
alias: key,
|
|
618
586
|
txHash: value,
|
|
619
|
-
|
|
620
|
-
status: await checkTx(client, TxHash.fromString(value), true, log),
|
|
587
|
+
status: await checkTx(wallet, node, TxHash.fromString(value), true, log),
|
|
621
588
|
})),
|
|
622
589
|
);
|
|
623
590
|
log(`Recent transactions:`);
|
|
624
591
|
log('');
|
|
625
592
|
log(`${'Alias'.padEnd(32, ' ')} | ${'TxHash'.padEnd(64, ' ')} | ${'Cancellable'.padEnd(12, ' ')} | Status`);
|
|
626
|
-
log(''.padEnd(32 + 64 +
|
|
627
|
-
for (const { alias, txHash, status
|
|
628
|
-
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${
|
|
629
|
-
log(''.padEnd(32 + 64 +
|
|
593
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
594
|
+
for (const { alias, txHash, status } of dataRows) {
|
|
595
|
+
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${status}`);
|
|
596
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
630
597
|
}
|
|
631
598
|
log(`Displaying ${Math.min(pageSize, aliases.length)} rows, page ${page + 1}/${totalPages}`);
|
|
632
599
|
} else {
|
|
@@ -634,42 +601,6 @@ export function injectCommands(
|
|
|
634
601
|
}
|
|
635
602
|
});
|
|
636
603
|
|
|
637
|
-
program
|
|
638
|
-
.command('cancel-tx')
|
|
639
|
-
.description('Cancels a pending tx by reusing its nonce with a higher fee and an empty payload')
|
|
640
|
-
.argument('<txHash>', 'A transaction hash to cancel.', txHash => aliasedTxHashParser(txHash, db))
|
|
641
|
-
.addOption(pxeOption)
|
|
642
|
-
.addOption(
|
|
643
|
-
createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
|
|
644
|
-
)
|
|
645
|
-
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
646
|
-
.addOption(FeeOpts.paymentMethodOption().default('method=fee_juice'))
|
|
647
|
-
.option(
|
|
648
|
-
'-i --increased-fees <da=1,l2=1>',
|
|
649
|
-
'The amounts by which the fees are increased',
|
|
650
|
-
value => parseGasFees(value),
|
|
651
|
-
new GasFees(1, 1),
|
|
652
|
-
)
|
|
653
|
-
.option('--max-fees-per-gas <da=100,l2=100>', 'Maximum fees per gas unit for DA and L2 computation.', value =>
|
|
654
|
-
parseGasFees(value),
|
|
655
|
-
)
|
|
656
|
-
.action(async (txHash, options) => {
|
|
657
|
-
const { cancelTx } = await import('./cancel_tx.js');
|
|
658
|
-
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
659
|
-
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
660
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
661
|
-
const wallet = await account.getWallet();
|
|
662
|
-
|
|
663
|
-
const txData = await db?.retrieveTxData(txHash);
|
|
664
|
-
if (!txData) {
|
|
665
|
-
throw new Error('Transaction data not found in the database, cannot reuse nonce');
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
const paymentMethod = await parsePaymentMethod(payment, false, log, db)(wallet);
|
|
669
|
-
|
|
670
|
-
await cancelTx(wallet, txData, paymentMethod, increasedFees, maxFeesPerGas, log);
|
|
671
|
-
});
|
|
672
|
-
|
|
673
604
|
program
|
|
674
605
|
.command('register-sender')
|
|
675
606
|
.description(
|
|
@@ -678,15 +609,12 @@ export function injectCommands(
|
|
|
678
609
|
.argument('[address]', 'The address of the sender to register', address =>
|
|
679
610
|
aliasedAddressParser('accounts', address, db),
|
|
680
611
|
)
|
|
681
|
-
.addOption(pxeOption)
|
|
682
|
-
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
683
612
|
.addOption(createAliasOption('Alias for the sender. Used for easy reference in subsequent commands.', !db))
|
|
684
613
|
.action(async (address, options) => {
|
|
685
614
|
const { registerSender } = await import('./register_sender.js');
|
|
686
|
-
const {
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
const wallet = await account.getWallet();
|
|
615
|
+
const { alias } = options;
|
|
616
|
+
|
|
617
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
690
618
|
|
|
691
619
|
await registerSender(wallet, address, log);
|
|
692
620
|
|
|
@@ -717,27 +645,13 @@ export function injectCommands(
|
|
|
717
645
|
aliasedAddressParser('accounts', address, db),
|
|
718
646
|
)
|
|
719
647
|
.addOption(createArgsOption(true, db))
|
|
720
|
-
.addOption(pxeOption)
|
|
721
|
-
.addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
|
|
722
648
|
.addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db))
|
|
723
649
|
.action(async (address, artifactPathPromise, _options, command) => {
|
|
724
650
|
const { registerContract } = await import('./register_contract.js');
|
|
725
|
-
const {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
secretKey,
|
|
730
|
-
alias,
|
|
731
|
-
init,
|
|
732
|
-
publicKey,
|
|
733
|
-
salt,
|
|
734
|
-
deployer,
|
|
735
|
-
args,
|
|
736
|
-
} = command.optsWithGlobals();
|
|
737
|
-
const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
|
|
738
|
-
const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
|
|
739
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
740
|
-
const wallet = await account.getWallet();
|
|
651
|
+
const { alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
|
|
652
|
+
|
|
653
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
654
|
+
const node = walletAndNodeWrapper.node;
|
|
741
655
|
|
|
742
656
|
const artifactPath = await artifactPathPromise;
|
|
743
657
|
|