@aztec/cli 0.16.2 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/index.js +4 -3
- package/dest/cmds/add_contract.d.ts +7 -0
- package/dest/cmds/add_contract.d.ts.map +1 -0
- package/dest/cmds/add_contract.js +15 -0
- package/dest/cmds/add_note.d.ts +8 -0
- package/dest/cmds/add_note.d.ts.map +1 -0
- package/dest/cmds/add_note.js +13 -0
- package/dest/cmds/block_number.d.ts +6 -0
- package/dest/cmds/block_number.d.ts.map +1 -0
- package/dest/cmds/block_number.js +10 -0
- package/dest/cmds/call.d.ts +7 -0
- package/dest/cmds/call.d.ts.map +1 -0
- package/dest/cmds/call.js +18 -0
- package/dest/cmds/check_deploy.d.ts +7 -0
- package/dest/cmds/check_deploy.d.ts.map +1 -0
- package/dest/cmds/check_deploy.js +16 -0
- package/dest/cmds/compute_selector.d.ts +6 -0
- package/dest/cmds/compute_selector.d.ts.map +1 -0
- package/dest/cmds/compute_selector.js +9 -0
- package/dest/cmds/create_account.d.ts +7 -0
- package/dest/cmds/create_account.d.ts.map +1 -0
- package/dest/cmds/create_account.js +30 -0
- package/dest/cmds/deploy.d.ts +7 -0
- package/dest/cmds/deploy.d.ts.map +1 -0
- package/dest/cmds/deploy.js +58 -0
- package/dest/cmds/deploy_l1_contracts.d.ts +6 -0
- package/dest/cmds/deploy_l1_contracts.d.ts.map +1 -0
- package/dest/cmds/deploy_l1_contracts.js +15 -0
- package/dest/cmds/example_contracts.d.ts +6 -0
- package/dest/cmds/example_contracts.d.ts.map +1 -0
- package/dest/cmds/example_contracts.js +10 -0
- package/dest/cmds/generate_p2p_private_key.d.ts +6 -0
- package/dest/cmds/generate_p2p_private_key.d.ts.map +1 -0
- package/dest/cmds/generate_p2p_private_key.js +11 -0
- package/dest/cmds/generate_private_key.d.ts +6 -0
- package/dest/cmds/generate_private_key.d.ts.map +1 -0
- package/dest/cmds/generate_private_key.js +22 -0
- package/dest/cmds/get_account.d.ts +7 -0
- package/dest/cmds/get_account.d.ts.map +1 -0
- package/dest/cmds/get_account.js +15 -0
- package/dest/cmds/get_accounts.d.ts +6 -0
- package/dest/cmds/get_accounts.d.ts.map +1 -0
- package/dest/cmds/get_accounts.js +18 -0
- package/dest/cmds/get_contract_data.d.ts +7 -0
- package/dest/cmds/get_contract_data.d.ts.map +1 -0
- package/dest/cmds/get_contract_data.js +28 -0
- package/dest/cmds/get_logs.d.ts +7 -0
- package/dest/cmds/get_logs.d.ts.map +1 -0
- package/dest/cmds/get_logs.js +54 -0
- package/dest/cmds/get_node_info.d.ts +6 -0
- package/dest/cmds/get_node_info.d.ts.map +1 -0
- package/dest/cmds/get_node_info.js +15 -0
- package/dest/cmds/get_recipient.d.ts +7 -0
- package/dest/cmds/get_recipient.d.ts.map +1 -0
- package/dest/cmds/get_recipient.js +15 -0
- package/dest/cmds/get_recipients.d.ts +6 -0
- package/dest/cmds/get_recipients.d.ts.map +1 -0
- package/dest/cmds/get_recipients.js +18 -0
- package/dest/cmds/get_tx_receipt.d.ts +7 -0
- package/dest/cmds/get_tx_receipt.d.ts.map +1 -0
- package/dest/cmds/get_tx_receipt.js +16 -0
- package/dest/cmds/inspect_contract.d.ts +6 -0
- package/dest/cmds/inspect_contract.d.ts.map +1 -0
- package/dest/cmds/inspect_contract.js +19 -0
- package/dest/cmds/parse_parameter_struct.d.ts +6 -0
- package/dest/cmds/parse_parameter_struct.d.ts.map +1 -0
- package/dest/cmds/parse_parameter_struct.js +20 -0
- package/dest/cmds/register_account.d.ts +7 -0
- package/dest/cmds/register_account.d.ts.map +1 -0
- package/dest/cmds/register_account.js +13 -0
- package/dest/cmds/register_recipient.d.ts +7 -0
- package/dest/cmds/register_recipient.d.ts.map +1 -0
- package/dest/cmds/register_recipient.js +11 -0
- package/dest/cmds/send.d.ts +7 -0
- package/dest/cmds/send.d.ts.map +1 -0
- package/dest/cmds/send.js +26 -0
- package/dest/cmds/unbox.d.ts +6 -0
- package/dest/cmds/unbox.d.ts.map +1 -0
- package/dest/cmds/unbox.js +9 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +62 -327
- package/dest/utils.d.ts +9 -5
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +10 -6
- package/package.json +8 -8
- package/src/bin/index.ts +4 -2
- package/src/cmds/add_contract.ts +27 -0
- package/src/cmds/add_note.ts +24 -0
- package/src/cmds/block_number.ts +12 -0
- package/src/cmds/call.ts +35 -0
- package/src/cmds/check_deploy.ts +17 -0
- package/src/cmds/compute_selector.ts +10 -0
- package/src/cmds/create_account.ts +39 -0
- package/src/cmds/deploy.ts +77 -0
- package/src/cmds/deploy_l1_contracts.ts +25 -0
- package/src/cmds/example_contracts.ts +12 -0
- package/src/cmds/generate_p2p_private_key.ts +13 -0
- package/src/cmds/generate_private_key.ts +23 -0
- package/src/cmds/get_account.ts +18 -0
- package/src/cmds/get_accounts.ts +19 -0
- package/src/cmds/get_contract_data.ts +39 -0
- package/src/cmds/get_logs.ts +71 -0
- package/src/cmds/get_node_info.ts +17 -0
- package/src/cmds/get_recipient.ts +18 -0
- package/src/cmds/get_recipients.ts +19 -0
- package/src/cmds/get_tx_receipt.ts +18 -0
- package/src/cmds/inspect_contract.ts +29 -0
- package/src/cmds/parse_parameter_struct.ts +30 -0
- package/src/cmds/register_account.ts +24 -0
- package/src/cmds/register_recipient.ts +21 -0
- package/src/cmds/send.ts +40 -0
- package/src/cmds/unbox.ts +11 -0
- package/src/index.ts +94 -371
- package/src/utils.ts +24 -18
package/src/index.ts
CHANGED
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AztecAddress,
|
|
3
|
-
Contract,
|
|
4
|
-
ContractDeployer,
|
|
5
|
-
EthAddress,
|
|
6
|
-
Fr,
|
|
7
|
-
GrumpkinScalar,
|
|
8
|
-
Note,
|
|
9
|
-
generatePublicKey,
|
|
10
|
-
getSchnorrAccount,
|
|
11
|
-
isContractDeployed,
|
|
12
|
-
} from '@aztec/aztec.js';
|
|
13
|
-
import {
|
|
14
|
-
FunctionSelector,
|
|
15
|
-
StructType,
|
|
16
|
-
decodeFunctionSignature,
|
|
17
|
-
decodeFunctionSignatureWithParameterNames,
|
|
18
|
-
} from '@aztec/foundation/abi';
|
|
19
|
-
import { JsonStringify } from '@aztec/foundation/json-rpc';
|
|
1
|
+
import { initAztecJs } from '@aztec/aztec.js/init';
|
|
20
2
|
import { DebugLogger, LogFn } from '@aztec/foundation/log';
|
|
21
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
22
3
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
23
|
-
import {
|
|
24
|
-
import { CompleteAddress, ContractData, ExtendedNote, LogFilter } from '@aztec/types';
|
|
4
|
+
import { addNoirCompilerCommanderActions } from '@aztec/noir-compiler/cli';
|
|
25
5
|
|
|
26
|
-
import { createSecp256k1PeerId } from '@libp2p/peer-id-factory';
|
|
27
6
|
import { Command, Option } from 'commander';
|
|
28
7
|
import { readFileSync } from 'fs';
|
|
29
8
|
import { dirname, resolve } from 'path';
|
|
30
|
-
|
|
31
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
32
|
-
|
|
33
|
-
import { createCompatibleClient } from './client.js';
|
|
34
|
-
import { encodeArgs, parseStructString } from './encoding.js';
|
|
35
|
-
import { GITHUB_TAG_PREFIX } from './github.js';
|
|
36
|
-
import { unboxContract } from './unbox.js';
|
|
37
|
-
import { update } from './update/update.js';
|
|
9
|
+
|
|
38
10
|
import {
|
|
39
|
-
deployAztecContracts,
|
|
40
|
-
getContractArtifact,
|
|
41
|
-
getExampleContractArtifacts,
|
|
42
|
-
getFunctionArtifact,
|
|
43
|
-
getTxSender,
|
|
44
11
|
parseAztecAddress,
|
|
45
12
|
parseEthereumAddress,
|
|
46
13
|
parseField,
|
|
47
|
-
parseFields,
|
|
48
14
|
parseOptionalAztecAddress,
|
|
49
15
|
parseOptionalInteger,
|
|
50
16
|
parseOptionalLogId,
|
|
@@ -55,11 +21,8 @@ import {
|
|
|
55
21
|
parsePublicKey,
|
|
56
22
|
parseSaltFromHexString,
|
|
57
23
|
parseTxHash,
|
|
58
|
-
prepTx,
|
|
59
24
|
} from './utils.js';
|
|
60
25
|
|
|
61
|
-
const accountCreationSalt = Fr.ZERO;
|
|
62
|
-
|
|
63
26
|
const { ETHEREUM_HOST = 'http://localhost:8545', PRIVATE_KEY, API_KEY } = process.env;
|
|
64
27
|
|
|
65
28
|
/**
|
|
@@ -88,6 +51,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
88
51
|
.argParser(parsePrivateKey)
|
|
89
52
|
.makeOptionMandatory(mandatory);
|
|
90
53
|
|
|
54
|
+
program.hook('preAction', initAztecJs);
|
|
55
|
+
|
|
91
56
|
program
|
|
92
57
|
.command('deploy-l1-contracts')
|
|
93
58
|
.description('Deploys all necessary Ethereum contracts for Aztec.')
|
|
@@ -104,20 +69,15 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
104
69
|
'test test test test test test test test test test test junk',
|
|
105
70
|
)
|
|
106
71
|
.action(async options => {
|
|
107
|
-
const {
|
|
72
|
+
const { deployL1Contracts } = await import('./cmds/deploy_l1_contracts.js');
|
|
73
|
+
await deployL1Contracts(
|
|
108
74
|
options.rpcUrl,
|
|
109
75
|
options.apiKey ?? '',
|
|
110
76
|
options.privateKey,
|
|
111
77
|
options.mnemonic,
|
|
78
|
+
log,
|
|
112
79
|
debugLogger,
|
|
113
80
|
);
|
|
114
|
-
log('\n');
|
|
115
|
-
log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
|
|
116
|
-
log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
|
|
117
|
-
log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
|
|
118
|
-
log(`L2 -> L1 Outbox address: ${l1ContractAddresses.outboxAddress.toString()}`);
|
|
119
|
-
log(`Contract Deployment Emitter Address: ${l1ContractAddresses.contractDeploymentEmitterAddress.toString()}`);
|
|
120
|
-
log('\n');
|
|
121
81
|
});
|
|
122
82
|
|
|
123
83
|
program
|
|
@@ -130,20 +90,9 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
130
90
|
'-m, --mnemonic',
|
|
131
91
|
'An optional mnemonic string used for the private key generation. If not provided, random private key will be generated.',
|
|
132
92
|
)
|
|
133
|
-
.action(options => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (options.mnemonic) {
|
|
137
|
-
const acc = mnemonicToAccount(options.mnemonic);
|
|
138
|
-
// TODO(#2052): This reduction is not secure enough. TACKLE THIS ISSUE BEFORE MAINNET.
|
|
139
|
-
const key = GrumpkinScalar.fromBufferReduce(Buffer.from(acc.getHdKey().privateKey!));
|
|
140
|
-
publicKey = generatePublicKey(key);
|
|
141
|
-
} else {
|
|
142
|
-
const key = GrumpkinScalar.random();
|
|
143
|
-
privKey = key.toString();
|
|
144
|
-
publicKey = generatePublicKey(key);
|
|
145
|
-
}
|
|
146
|
-
log(`\nPrivate Key: ${privKey}\nPublic Key: ${publicKey.toString()}\n`);
|
|
93
|
+
.action(async options => {
|
|
94
|
+
const { generatePrivateKey } = await import('./cmds/generate_private_key.js');
|
|
95
|
+
generatePrivateKey(options.mnemonic, log);
|
|
147
96
|
});
|
|
148
97
|
|
|
149
98
|
program
|
|
@@ -151,10 +100,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
151
100
|
.summary('Generates a LibP2P peer private key.')
|
|
152
101
|
.description('Generates a private key that can be used for running a node on a LibP2P network.')
|
|
153
102
|
.action(async () => {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
log(`Private key: ${exportedPeerId}`);
|
|
157
|
-
log(`Peer Id: ${peerId}`);
|
|
103
|
+
const { generateP2PPrivateKey } = await import('./cmds/generate_p2p_private_key.js');
|
|
104
|
+
await generateP2PPrivateKey(log);
|
|
158
105
|
});
|
|
159
106
|
|
|
160
107
|
program
|
|
@@ -171,28 +118,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
171
118
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
172
119
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
173
120
|
.action(async ({ rpcUrl, privateKey, wait }) => {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const account = getSchnorrAccount(client, actualPrivateKey, actualPrivateKey, accountCreationSalt);
|
|
178
|
-
const { address, publicKey, partialAddress } = account.getCompleteAddress();
|
|
179
|
-
const tx = await account.deploy();
|
|
180
|
-
const txHash = await tx.getTxHash();
|
|
181
|
-
debugLogger(`Account contract tx sent with hash ${txHash}`);
|
|
182
|
-
if (wait) {
|
|
183
|
-
log(`\nWaiting for account contract deployment...`);
|
|
184
|
-
await tx.wait();
|
|
185
|
-
} else {
|
|
186
|
-
log(`\nAccount deployment transaction hash: ${txHash}\n`);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
log(`\nNew account:\n`);
|
|
190
|
-
log(`Address: ${address.toString()}`);
|
|
191
|
-
log(`Public key: ${publicKey.toString()}`);
|
|
192
|
-
if (!privateKey) {
|
|
193
|
-
log(`Private key: ${actualPrivateKey.toString()}`);
|
|
194
|
-
}
|
|
195
|
-
log(`Partial address: ${partialAddress.toString()}`);
|
|
121
|
+
const { createAccount } = await import('./cmds/create_account.js');
|
|
122
|
+
await createAccount(rpcUrl, privateKey, wait, debugLogger, log);
|
|
196
123
|
});
|
|
197
124
|
|
|
198
125
|
program
|
|
@@ -209,14 +136,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
209
136
|
)
|
|
210
137
|
.addOption(pxeOption)
|
|
211
138
|
.action(async ({ rpcUrl, privateKey, partialAddress }) => {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
const { address, publicKey } = await client.registerAccount(privateKey, partialAddress);
|
|
215
|
-
|
|
216
|
-
log(`\nRegistered account:\n`);
|
|
217
|
-
log(`Address: ${address.toString()}`);
|
|
218
|
-
log(`Public key: ${publicKey.toString()}`);
|
|
219
|
-
log(`Partial address: ${partialAddress.toString()}`);
|
|
139
|
+
const { registerAccount } = await import('./cmds/register_account.js');
|
|
140
|
+
await registerAccount(rpcUrl, privateKey, partialAddress, debugLogger, log);
|
|
220
141
|
});
|
|
221
142
|
|
|
222
143
|
program
|
|
@@ -248,58 +169,20 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
248
169
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
249
170
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
|
|
250
171
|
.action(async (artifactPath, { json, rpcUrl, publicKey, args: rawArgs, portalAddress, salt, wait }) => {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const constructor = getFunctionArtifact(contractArtifact, 'constructor');
|
|
266
|
-
if (!constructor) {
|
|
267
|
-
throw new Error(`Constructor not found in contract ABI`);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
debugLogger(`Input arguments: ${rawArgs.map((x: any) => `"${x}"`).join(', ')}`);
|
|
271
|
-
const args = encodeArgs(rawArgs, constructorArtifact!.parameters);
|
|
272
|
-
debugLogger(`Encoded arguments: ${args.join(', ')}`);
|
|
273
|
-
|
|
274
|
-
const deploy = deployer.deploy(...args);
|
|
275
|
-
|
|
276
|
-
await deploy.create({ contractAddressSalt: salt, portalContract: portalAddress });
|
|
277
|
-
const tx = deploy.send({ contractAddressSalt: salt, portalContract: portalAddress });
|
|
278
|
-
const txHash = await tx.getTxHash();
|
|
279
|
-
debugLogger(`Deploy tx sent with hash ${txHash}`);
|
|
280
|
-
if (wait) {
|
|
281
|
-
const deployed = await tx.wait();
|
|
282
|
-
const { address, partialAddress } = deployed.contract.completeAddress;
|
|
283
|
-
if (json) {
|
|
284
|
-
logJson({ address: address.toString(), partialAddress: partialAddress.toString() });
|
|
285
|
-
} else {
|
|
286
|
-
log(`\nContract deployed at ${address.toString()}\n`);
|
|
287
|
-
log(`Contract partial address ${partialAddress.toString()}\n`);
|
|
288
|
-
}
|
|
289
|
-
} else {
|
|
290
|
-
const { address, partialAddress } = deploy.completeAddress ?? {};
|
|
291
|
-
if (json) {
|
|
292
|
-
logJson({
|
|
293
|
-
address: address?.toString() ?? 'N/A',
|
|
294
|
-
partialAddress: partialAddress?.toString() ?? 'N/A',
|
|
295
|
-
txHash: txHash.toString(),
|
|
296
|
-
});
|
|
297
|
-
} else {
|
|
298
|
-
log(`\nContract Address: ${deploy.completeAddress?.address.toString() ?? 'N/A'}`);
|
|
299
|
-
log(`Contract Partial Address: ${deploy.completeAddress?.partialAddress.toString() ?? 'N/A'}`);
|
|
300
|
-
log(`Deployment transaction hash: ${txHash}\n`);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
172
|
+
const { deploy } = await import('./cmds/deploy.js');
|
|
173
|
+
await deploy(
|
|
174
|
+
artifactPath,
|
|
175
|
+
json,
|
|
176
|
+
rpcUrl,
|
|
177
|
+
publicKey,
|
|
178
|
+
rawArgs,
|
|
179
|
+
portalAddress,
|
|
180
|
+
salt,
|
|
181
|
+
wait,
|
|
182
|
+
debugLogger,
|
|
183
|
+
log,
|
|
184
|
+
logJson,
|
|
185
|
+
);
|
|
303
186
|
});
|
|
304
187
|
|
|
305
188
|
program
|
|
@@ -312,14 +195,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
312
195
|
)
|
|
313
196
|
.addOption(pxeOption)
|
|
314
197
|
.action(async options => {
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
const isDeployed = await isContractDeployed(client, address);
|
|
318
|
-
if (isDeployed) {
|
|
319
|
-
log(`\nContract found at ${address.toString()}\n`);
|
|
320
|
-
} else {
|
|
321
|
-
log(`\nNo contract found at ${address.toString()}\n`);
|
|
322
|
-
}
|
|
198
|
+
const { checkDeploy } = await import('./cmds/check_deploy.js');
|
|
199
|
+
await checkDeploy(options.rpcUrl, options.contractAddress, debugLogger, log);
|
|
323
200
|
});
|
|
324
201
|
|
|
325
202
|
program
|
|
@@ -337,32 +214,27 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
337
214
|
.option('--portal-address <address>', 'Optional address to a portal contract on L1', parseEthereumAddress)
|
|
338
215
|
.addOption(pxeOption)
|
|
339
216
|
.action(async options => {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
options.
|
|
217
|
+
const { addContract } = await import('./cmds/add_contract.js');
|
|
218
|
+
await addContract(
|
|
219
|
+
options.rpcUrl,
|
|
220
|
+
options.contractArtifact,
|
|
221
|
+
options.contractAddress,
|
|
345
222
|
options.partialAddress,
|
|
223
|
+
options.publicKey,
|
|
224
|
+
options.portalContract,
|
|
225
|
+
debugLogger,
|
|
226
|
+
log,
|
|
346
227
|
);
|
|
347
|
-
const portalContract: EthAddress = options.portalContract ?? EthAddress.ZERO;
|
|
348
|
-
const client = await createCompatibleClient(options.rpcUrl, debugLogger);
|
|
349
|
-
|
|
350
|
-
await client.addContracts([{ artifact, completeAddress, portalContract }]);
|
|
351
|
-
log(`\nContract added to PXE at ${contractAddress.toString()}\n`);
|
|
352
228
|
});
|
|
229
|
+
|
|
353
230
|
program
|
|
354
231
|
.command('get-tx-receipt')
|
|
355
232
|
.description('Gets the receipt for the specified transaction hash.')
|
|
356
233
|
.argument('<txHash>', 'A transaction hash to get the receipt for.', parseTxHash)
|
|
357
234
|
.addOption(pxeOption)
|
|
358
235
|
.action(async (txHash, options) => {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
if (!receipt) {
|
|
362
|
-
log(`No receipt found for transaction hash ${txHash.toString()}`);
|
|
363
|
-
} else {
|
|
364
|
-
log(`\nTransaction receipt: \n${JsonStringify(receipt, true)}\n`);
|
|
365
|
-
}
|
|
236
|
+
const { getTxReceipt } = await import('./cmds/get_tx_receipt.js');
|
|
237
|
+
await getTxReceipt(options.rpcUrl, txHash, debugLogger, log);
|
|
366
238
|
});
|
|
367
239
|
|
|
368
240
|
program
|
|
@@ -372,28 +244,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
372
244
|
.addOption(pxeOption)
|
|
373
245
|
.option('-b, --include-bytecode <boolean>', "Include the contract's public function bytecode, if any.", false)
|
|
374
246
|
.action(async (contractAddress, options) => {
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
? await client.getExtendedContractData(contractAddress)
|
|
378
|
-
: await client.getContractData(contractAddress);
|
|
379
|
-
|
|
380
|
-
if (!contractDataWithOrWithoutBytecode) {
|
|
381
|
-
log(`No contract data found at ${contractAddress}`);
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
let contractData: ContractData;
|
|
385
|
-
|
|
386
|
-
if ('contractData' in contractDataWithOrWithoutBytecode) {
|
|
387
|
-
contractData = contractDataWithOrWithoutBytecode.contractData;
|
|
388
|
-
} else {
|
|
389
|
-
contractData = contractDataWithOrWithoutBytecode;
|
|
390
|
-
}
|
|
391
|
-
log(`\nContract Data: \nAddress: ${contractData.contractAddress.toString()}`);
|
|
392
|
-
log(`Portal: ${contractData.portalContractAddress.toString()}`);
|
|
393
|
-
if ('bytecode' in contractDataWithOrWithoutBytecode) {
|
|
394
|
-
log(`Bytecode: ${contractDataWithOrWithoutBytecode.bytecode}`);
|
|
395
|
-
}
|
|
396
|
-
log('\n');
|
|
247
|
+
const { getContractData } = await import('./cmds/get_contract_data.js');
|
|
248
|
+
await getContractData(options.rpcUrl, contractAddress, options.includeBytecode, debugLogger, log);
|
|
397
249
|
});
|
|
398
250
|
|
|
399
251
|
program
|
|
@@ -412,55 +264,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
412
264
|
.addOption(pxeOption)
|
|
413
265
|
.option('--follow', 'If set, will keep polling for new logs until interrupted.')
|
|
414
266
|
.action(async ({ txHash, fromBlock, toBlock, afterLog, contractAddress, selector, rpcUrl, follow }) => {
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
if (follow) {
|
|
418
|
-
if (txHash) {
|
|
419
|
-
throw Error('Cannot use --follow with --tx-hash');
|
|
420
|
-
}
|
|
421
|
-
if (toBlock) {
|
|
422
|
-
throw Error('Cannot use --follow with --to-block');
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
const filter: LogFilter = { txHash, fromBlock, toBlock, afterLog, contractAddress, selector };
|
|
427
|
-
|
|
428
|
-
const fetchLogs = async () => {
|
|
429
|
-
const response = await pxe.getUnencryptedLogs(filter);
|
|
430
|
-
const logs = response.logs;
|
|
431
|
-
|
|
432
|
-
if (!logs.length) {
|
|
433
|
-
const filterOptions = Object.entries(filter)
|
|
434
|
-
.filter(([, value]) => value !== undefined)
|
|
435
|
-
.map(([key, value]) => `${key}: ${value}`)
|
|
436
|
-
.join(', ');
|
|
437
|
-
if (!follow) {
|
|
438
|
-
log(`No logs found for filter: {${filterOptions}}`);
|
|
439
|
-
}
|
|
440
|
-
} else {
|
|
441
|
-
if (!follow && !filter.afterLog) {
|
|
442
|
-
log('Logs found: \n');
|
|
443
|
-
}
|
|
444
|
-
logs.forEach(unencryptedLog => log(unencryptedLog.toHumanReadable()));
|
|
445
|
-
// Set the continuation parameter for the following requests
|
|
446
|
-
filter.afterLog = logs[logs.length - 1].id;
|
|
447
|
-
}
|
|
448
|
-
return response.maxLogsHit;
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
if (follow) {
|
|
452
|
-
log('Fetching logs...');
|
|
453
|
-
while (true) {
|
|
454
|
-
const maxLogsHit = await fetchLogs();
|
|
455
|
-
if (!maxLogsHit) {
|
|
456
|
-
await sleep(1000);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
} else {
|
|
460
|
-
while (await fetchLogs()) {
|
|
461
|
-
// Keep fetching logs until we reach the end.
|
|
462
|
-
}
|
|
463
|
-
}
|
|
267
|
+
const { getLogs } = await import('./cmds/get_logs.js');
|
|
268
|
+
await getLogs(txHash, fromBlock, toBlock, afterLog, contractAddress, selector, rpcUrl, follow, debugLogger, log);
|
|
464
269
|
});
|
|
465
270
|
|
|
466
271
|
program
|
|
@@ -475,9 +280,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
475
280
|
)
|
|
476
281
|
.addOption(pxeOption)
|
|
477
282
|
.action(async ({ address, publicKey, partialAddress, rpcUrl }) => {
|
|
478
|
-
const
|
|
479
|
-
await
|
|
480
|
-
log(`\nRegistered details for account with address: ${address}\n`);
|
|
283
|
+
const { registerRecipient } = await import('./cmds/register_recipient.js');
|
|
284
|
+
await registerRecipient(address, publicKey, partialAddress, rpcUrl, debugLogger, log);
|
|
481
285
|
});
|
|
482
286
|
|
|
483
287
|
program
|
|
@@ -485,16 +289,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
485
289
|
.description('Gets all the Aztec accounts stored in the PXE.')
|
|
486
290
|
.addOption(pxeOption)
|
|
487
291
|
.action(async (options: any) => {
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
if (!accounts.length) {
|
|
491
|
-
log('No accounts found.');
|
|
492
|
-
} else {
|
|
493
|
-
log(`Accounts found: \n`);
|
|
494
|
-
for (const account of accounts) {
|
|
495
|
-
log(account.toReadableString());
|
|
496
|
-
}
|
|
497
|
-
}
|
|
292
|
+
const { getAccounts } = await import('./cmds/get_accounts.js');
|
|
293
|
+
await getAccounts(options.rpcUrl, debugLogger, log);
|
|
498
294
|
});
|
|
499
295
|
|
|
500
296
|
program
|
|
@@ -503,14 +299,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
503
299
|
.argument('<address>', 'The Aztec address to get account for', parseAztecAddress)
|
|
504
300
|
.addOption(pxeOption)
|
|
505
301
|
.action(async (address, options) => {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (!account) {
|
|
510
|
-
log(`Unknown account ${address.toString()}`);
|
|
511
|
-
} else {
|
|
512
|
-
log(account.toReadableString());
|
|
513
|
-
}
|
|
302
|
+
const { getAccount } = await import('./cmds/get_account.js');
|
|
303
|
+
await getAccount(address, options.rpcUrl, debugLogger, log);
|
|
514
304
|
});
|
|
515
305
|
|
|
516
306
|
program
|
|
@@ -518,16 +308,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
518
308
|
.description('Gets all the recipients stored in the PXE.')
|
|
519
309
|
.addOption(pxeOption)
|
|
520
310
|
.action(async (options: any) => {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
if (!recipients.length) {
|
|
524
|
-
log('No recipients found.');
|
|
525
|
-
} else {
|
|
526
|
-
log(`Recipients found: \n`);
|
|
527
|
-
for (const recipient of recipients) {
|
|
528
|
-
log(recipient.toReadableString());
|
|
529
|
-
}
|
|
530
|
-
}
|
|
311
|
+
const { getRecipients } = await import('./cmds/get_recipients.js');
|
|
312
|
+
await getRecipients(options.rpcUrl, debugLogger, log);
|
|
531
313
|
});
|
|
532
314
|
|
|
533
315
|
program
|
|
@@ -536,14 +318,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
536
318
|
.argument('<address>', 'The Aztec address to get recipient for', parseAztecAddress)
|
|
537
319
|
.addOption(pxeOption)
|
|
538
320
|
.action(async (address, options) => {
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (!recipient) {
|
|
543
|
-
log(`Unknown recipient ${address.toString()}`);
|
|
544
|
-
} else {
|
|
545
|
-
log(recipient.toReadableString());
|
|
546
|
-
}
|
|
321
|
+
const { getRecipient } = await import('./cmds/get_recipient.js');
|
|
322
|
+
await getRecipient(address, options.rpcUrl, debugLogger, log);
|
|
547
323
|
});
|
|
548
324
|
|
|
549
325
|
program
|
|
@@ -560,31 +336,18 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
560
336
|
.addOption(pxeOption)
|
|
561
337
|
.option('--no-wait', 'Print transaction hash without waiting for it to be mined')
|
|
562
338
|
.action(async (functionName, options) => {
|
|
563
|
-
const {
|
|
564
|
-
|
|
339
|
+
const { send } = await import('./cmds/send.js');
|
|
340
|
+
await send(
|
|
565
341
|
functionName,
|
|
566
342
|
options.args,
|
|
343
|
+
options.contractArtifact,
|
|
344
|
+
options.contractAddress,
|
|
345
|
+
options.privateKey,
|
|
346
|
+
options.rpcUrl,
|
|
347
|
+
!options.noWait,
|
|
348
|
+
debugLogger,
|
|
567
349
|
log,
|
|
568
350
|
);
|
|
569
|
-
const { contractAddress, privateKey } = options;
|
|
570
|
-
|
|
571
|
-
const client = await createCompatibleClient(options.rpcUrl, debugLogger);
|
|
572
|
-
const wallet = await getSchnorrAccount(client, privateKey, privateKey, accountCreationSalt).getWallet();
|
|
573
|
-
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
574
|
-
const tx = contract.methods[functionName](...functionArgs).send();
|
|
575
|
-
log(`\nTransaction hash: ${(await tx.getTxHash()).toString()}`);
|
|
576
|
-
if (options.wait) {
|
|
577
|
-
await tx.wait();
|
|
578
|
-
|
|
579
|
-
log('Transaction has been mined');
|
|
580
|
-
|
|
581
|
-
const receipt = await tx.getReceipt();
|
|
582
|
-
log(`Status: ${receipt.status}\n`);
|
|
583
|
-
log(`Block number: ${receipt.blockNumber}`);
|
|
584
|
-
log(`Block hash: ${receipt.blockHash?.toString('hex')}`);
|
|
585
|
-
} else {
|
|
586
|
-
log('Transaction pending. Check status with get-tx-receipt');
|
|
587
|
-
}
|
|
588
351
|
});
|
|
589
352
|
|
|
590
353
|
program
|
|
@@ -602,23 +365,17 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
602
365
|
.option('-f, --from <string>', 'Aztec address of the caller. If empty, will use the first account from RPC.')
|
|
603
366
|
.addOption(pxeOption)
|
|
604
367
|
.action(async (functionName, options) => {
|
|
605
|
-
const {
|
|
606
|
-
|
|
368
|
+
const { call } = await import('./cmds/call.js');
|
|
369
|
+
await call(
|
|
607
370
|
functionName,
|
|
608
371
|
options.args,
|
|
372
|
+
options.contractArtifact,
|
|
373
|
+
options.contractAddress,
|
|
374
|
+
options.from,
|
|
375
|
+
options.rpcUrl,
|
|
376
|
+
debugLogger,
|
|
609
377
|
log,
|
|
610
378
|
);
|
|
611
|
-
|
|
612
|
-
const fnArtifact = getFunctionArtifact(contractArtifact, functionName);
|
|
613
|
-
if (fnArtifact.parameters.length !== options.args.length) {
|
|
614
|
-
throw Error(
|
|
615
|
-
`Invalid number of args passed. Expected ${fnArtifact.parameters.length}; Received: ${options.args.length}`,
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
const client = await createCompatibleClient(options.rpcUrl, debugLogger);
|
|
619
|
-
const from = await getTxSender(client, options.from);
|
|
620
|
-
const result = await client.viewTx(functionName, functionArgs, options.contractAddress, from);
|
|
621
|
-
log(format('\nView result: ', result, '\n'));
|
|
622
379
|
});
|
|
623
380
|
|
|
624
381
|
program
|
|
@@ -631,10 +388,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
631
388
|
.requiredOption('-n, --note [note...]', 'The members of a Note serialized as hex strings.', [])
|
|
632
389
|
.addOption(pxeOption)
|
|
633
390
|
.action(async (address, contractAddress, storageSlot, txHash, options) => {
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
const client = await createCompatibleClient(options.rpcUrl, debugLogger);
|
|
637
|
-
await client.addNote(extendedNote);
|
|
391
|
+
const { addNote } = await import('./cmds/add_note.js');
|
|
392
|
+
await addNote(address, contractAddress, storageSlot, txHash, options.note, options.rpcUrl, debugLogger);
|
|
638
393
|
});
|
|
639
394
|
|
|
640
395
|
// Helper for users to decode hex strings into structs if needed.
|
|
@@ -648,17 +403,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
648
403
|
)
|
|
649
404
|
.requiredOption('-p, --parameter <parameterName>', 'The name of the struct parameter to decode into')
|
|
650
405
|
.action(async (encodedString, options) => {
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
.map(({ parameters }) => parameters)
|
|
654
|
-
.flat()
|
|
655
|
-
.find(({ name, type }) => name === options.parameter && type.kind === 'struct');
|
|
656
|
-
if (!parameterAbitype) {
|
|
657
|
-
log(`No struct parameter found with name ${options.parameter}`);
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
const data = parseStructString(encodedString, parameterAbitype.type as StructType);
|
|
661
|
-
log(`\nStruct Data: \n${JsonStringify(data, true)}\n`);
|
|
406
|
+
const { parseParameterStruct } = await import('./cmds/parse_parameter_struct.js');
|
|
407
|
+
await parseParameterStruct(encodedString, options.contractArtifact, options.parameter, log);
|
|
662
408
|
});
|
|
663
409
|
|
|
664
410
|
program
|
|
@@ -666,18 +412,16 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
666
412
|
.description('Gets the current Aztec L2 block number.')
|
|
667
413
|
.addOption(pxeOption)
|
|
668
414
|
.action(async (options: any) => {
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
log(`${num}\n`);
|
|
415
|
+
const { blockNumber } = await import('./cmds/block_number.js');
|
|
416
|
+
await blockNumber(options.rpcUrl, debugLogger, log);
|
|
672
417
|
});
|
|
673
418
|
|
|
674
419
|
program
|
|
675
420
|
.command('example-contracts')
|
|
676
421
|
.description('Lists the example contracts available to deploy from @aztec/noir-contracts')
|
|
677
422
|
.action(async () => {
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
names.forEach(name => log(name));
|
|
423
|
+
const { exampleContracts } = await import('./cmds/example_contracts.js');
|
|
424
|
+
await exampleContracts(log);
|
|
681
425
|
});
|
|
682
426
|
|
|
683
427
|
program
|
|
@@ -691,8 +435,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
691
435
|
'Local directory to unbox source folder to (relative or absolute), optional - defaults to `<contractName>/`',
|
|
692
436
|
)
|
|
693
437
|
.action(async (contractName, localDirectory) => {
|
|
694
|
-
const
|
|
695
|
-
await
|
|
438
|
+
const { unbox } = await import('./cmds/unbox.js');
|
|
439
|
+
await unbox(contractName, localDirectory, cliVersion, log);
|
|
696
440
|
});
|
|
697
441
|
|
|
698
442
|
program
|
|
@@ -700,14 +444,8 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
700
444
|
.description('Gets the information of an aztec node at a URL.')
|
|
701
445
|
.addOption(pxeOption)
|
|
702
446
|
.action(async options => {
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
log(`\nNode Info:\n`);
|
|
706
|
-
log(`Sandbox Version: ${info.sandboxVersion}\n`);
|
|
707
|
-
log(`Compatible Nargo Version: ${info.compatibleNargoVersion}\n`);
|
|
708
|
-
log(`Chain Id: ${info.chainId}\n`);
|
|
709
|
-
log(`Protocol Version: ${info.protocolVersion}\n`);
|
|
710
|
-
log(`Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
|
|
447
|
+
const { getNodeInfo } = await import('./cmds/get_node_info.js');
|
|
448
|
+
await getNodeInfo(options.rpcUrl, debugLogger, log);
|
|
711
449
|
});
|
|
712
450
|
|
|
713
451
|
program
|
|
@@ -718,30 +456,17 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
718
456
|
`A compiled Noir contract's artifact in JSON format or name of a contract artifact exported by @aztec/noir-contracts`,
|
|
719
457
|
)
|
|
720
458
|
.action(async (contractArtifactFile: string) => {
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
f => !f.isInternal && f.name !== 'compute_note_hash_and_nullifier',
|
|
724
|
-
);
|
|
725
|
-
if (contractFns.length === 0) {
|
|
726
|
-
log(`No external functions found for contract ${contractArtifact.name}`);
|
|
727
|
-
}
|
|
728
|
-
for (const fn of contractFns) {
|
|
729
|
-
const signatureWithParameterNames = decodeFunctionSignatureWithParameterNames(fn.name, fn.parameters);
|
|
730
|
-
const signature = decodeFunctionSignature(fn.name, fn.parameters);
|
|
731
|
-
const selector = FunctionSelector.fromSignature(signature);
|
|
732
|
-
log(
|
|
733
|
-
`${fn.functionType} ${signatureWithParameterNames} \n\tfunction signature: ${signature}\n\tselector: ${selector}`,
|
|
734
|
-
);
|
|
735
|
-
}
|
|
459
|
+
const { inspectContract } = await import('./cmds/inspect_contract.js');
|
|
460
|
+
await inspectContract(contractArtifactFile, debugLogger, log);
|
|
736
461
|
});
|
|
737
462
|
|
|
738
463
|
program
|
|
739
464
|
.command('compute-selector')
|
|
740
465
|
.description('Given a function signature, it computes a selector')
|
|
741
466
|
.argument('<functionSignature>', 'Function signature to compute selector for e.g. foo(Field)')
|
|
742
|
-
.action((functionSignature: string) => {
|
|
743
|
-
const
|
|
744
|
-
log
|
|
467
|
+
.action(async (functionSignature: string) => {
|
|
468
|
+
const { computeSelector } = await import('./cmds/compute_selector.js');
|
|
469
|
+
computeSelector(functionSignature, log);
|
|
745
470
|
});
|
|
746
471
|
|
|
747
472
|
program
|
|
@@ -752,13 +477,11 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command {
|
|
|
752
477
|
.option('--sandbox-version <semver>', 'The sandbox version to update to. Defaults to latest', 'latest')
|
|
753
478
|
.addOption(pxeOption)
|
|
754
479
|
.action(async (projectPath: string, options) => {
|
|
755
|
-
const {
|
|
756
|
-
await update(projectPath, contract, options.rpcUrl, options.sandboxVersion, log, debugLogger);
|
|
480
|
+
const { update } = await import('./update/update.js');
|
|
481
|
+
await update(projectPath, options.contract, options.rpcUrl, options.sandboxVersion, log, debugLogger);
|
|
757
482
|
});
|
|
758
483
|
|
|
759
|
-
|
|
760
|
-
generateTypescriptInterface(program, 'generate-typescript', log);
|
|
761
|
-
generateNoirInterface(program, 'generate-noir-interface', log);
|
|
484
|
+
addNoirCompilerCommanderActions(program, log);
|
|
762
485
|
|
|
763
486
|
return program;
|
|
764
487
|
}
|