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