@aztec/cli 0.16.4 → 0.16.5

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.
Files changed (40) hide show
  1. package/dest/bin/index.js +0 -0
  2. package/package.json +8 -8
  3. package/src/bin/index.ts +0 -22
  4. package/src/client.ts +0 -68
  5. package/src/cmds/add_contract.ts +0 -27
  6. package/src/cmds/add_note.ts +0 -24
  7. package/src/cmds/block_number.ts +0 -12
  8. package/src/cmds/call.ts +0 -35
  9. package/src/cmds/check_deploy.ts +0 -17
  10. package/src/cmds/compute_selector.ts +0 -10
  11. package/src/cmds/create_account.ts +0 -39
  12. package/src/cmds/deploy.ts +0 -77
  13. package/src/cmds/deploy_l1_contracts.ts +0 -25
  14. package/src/cmds/example_contracts.ts +0 -12
  15. package/src/cmds/generate_p2p_private_key.ts +0 -13
  16. package/src/cmds/generate_private_key.ts +0 -23
  17. package/src/cmds/get_account.ts +0 -18
  18. package/src/cmds/get_accounts.ts +0 -19
  19. package/src/cmds/get_contract_data.ts +0 -39
  20. package/src/cmds/get_logs.ts +0 -71
  21. package/src/cmds/get_node_info.ts +0 -17
  22. package/src/cmds/get_recipient.ts +0 -18
  23. package/src/cmds/get_recipients.ts +0 -19
  24. package/src/cmds/get_tx_receipt.ts +0 -18
  25. package/src/cmds/inspect_contract.ts +0 -29
  26. package/src/cmds/parse_parameter_struct.ts +0 -30
  27. package/src/cmds/register_account.ts +0 -24
  28. package/src/cmds/register_recipient.ts +0 -21
  29. package/src/cmds/send.ts +0 -40
  30. package/src/cmds/unbox.ts +0 -11
  31. package/src/encoding.ts +0 -115
  32. package/src/github.ts +0 -3
  33. package/src/index.ts +0 -487
  34. package/src/test/mocks.ts +0 -65
  35. package/src/unbox.ts +0 -345
  36. package/src/update/common.ts +0 -16
  37. package/src/update/noir.ts +0 -79
  38. package/src/update/npm.ts +0 -134
  39. package/src/update/update.ts +0 -132
  40. package/src/utils.ts +0 -439
@@ -1,18 +0,0 @@
1
- import { TxHash } from '@aztec/aztec.js';
2
- import { JsonStringify } from '@aztec/foundation/json-rpc';
3
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function getTxReceipt(rpcUrl: string, txHash: TxHash, debugLogger: DebugLogger, log: LogFn) {
11
- const client = await createCompatibleClient(rpcUrl, debugLogger);
12
- const receipt = await client.getTxReceipt(txHash);
13
- if (!receipt) {
14
- log(`No receipt found for transaction hash ${txHash.toString()}`);
15
- } else {
16
- log(`\nTransaction receipt: \n${JsonStringify(receipt, true)}\n`);
17
- }
18
- }
@@ -1,29 +0,0 @@
1
- import {
2
- FunctionSelector,
3
- decodeFunctionSignature,
4
- decodeFunctionSignatureWithParameterNames,
5
- } from '@aztec/foundation/abi';
6
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
7
-
8
- import { getContractArtifact } from '../utils.js';
9
-
10
- /**
11
- *
12
- */
13
- export async function inspectContract(contractArtifactFile: string, debugLogger: DebugLogger, log: LogFn) {
14
- const contractArtifact = await getContractArtifact(contractArtifactFile, debugLogger);
15
- const contractFns = contractArtifact.functions.filter(
16
- f => !f.isInternal && f.name !== 'compute_note_hash_and_nullifier',
17
- );
18
- if (contractFns.length === 0) {
19
- log(`No external functions found for contract ${contractArtifact.name}`);
20
- }
21
- for (const fn of contractFns) {
22
- const signatureWithParameterNames = decodeFunctionSignatureWithParameterNames(fn.name, fn.parameters);
23
- const signature = decodeFunctionSignature(fn.name, fn.parameters);
24
- const selector = FunctionSelector.fromSignature(signature);
25
- log(
26
- `${fn.functionType} ${signatureWithParameterNames} \n\tfunction signature: ${signature}\n\tselector: ${selector}`,
27
- );
28
- }
29
- }
@@ -1,30 +0,0 @@
1
- import { StructType } from '@aztec/foundation/abi';
2
- import { JsonStringify } from '@aztec/foundation/json-rpc';
3
- import { LogFn } from '@aztec/foundation/log';
4
-
5
- import { parseStructString } from '../encoding.js';
6
- import { getContractArtifact } from '../utils.js';
7
-
8
- /**
9
- *
10
- */
11
- export async function parseParameterStruct(
12
- encodedString: string,
13
- contractArtifactPath: string,
14
- parameterName: string,
15
- log: LogFn,
16
- ) {
17
- const contractArtifact = await getContractArtifact(contractArtifactPath, log);
18
- const parameterAbitype = contractArtifact.functions
19
- .map(({ parameters }) => parameters)
20
- .flat()
21
- .find(({ name, type }) => name === parameterName && type.kind === 'struct');
22
-
23
- if (!parameterAbitype) {
24
- log(`No struct parameter found with name ${parameterName}`);
25
- return;
26
- }
27
-
28
- const data = parseStructString(encodedString, parameterAbitype.type as StructType);
29
- log(`\nStruct Data: \n${JsonStringify(data, true)}\n`);
30
- }
@@ -1,24 +0,0 @@
1
- import { Fq, Fr } from '@aztec/foundation/fields';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
-
6
- /**
7
- *
8
- */
9
- export async function registerAccount(
10
- rpcUrl: string,
11
- privateKey: Fq,
12
- partialAddress: Fr,
13
- debugLogger: DebugLogger,
14
- log: LogFn,
15
- ) {
16
- const client = await createCompatibleClient(rpcUrl, debugLogger);
17
-
18
- const { address, publicKey } = await client.registerAccount(privateKey, partialAddress);
19
-
20
- log(`\nRegistered account:\n`);
21
- log(`Address: ${address.toString()}`);
22
- log(`Public key: ${publicKey.toString()}`);
23
- log(`Partial address: ${partialAddress.toString()}`);
24
- }
@@ -1,21 +0,0 @@
1
- import { AztecAddress, Fr, Point } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
- import { CompleteAddress } from '@aztec/types';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function registerRecipient(
11
- aztecAddress: AztecAddress,
12
- publicKey: Point,
13
- partialAddress: Fr,
14
- rpcUrl: string,
15
- debugLogger: DebugLogger,
16
- log: LogFn,
17
- ) {
18
- const client = await createCompatibleClient(rpcUrl, debugLogger);
19
- await client.registerRecipient(CompleteAddress.create(aztecAddress, publicKey, partialAddress));
20
- log(`\nRegistered details for account with address: ${aztecAddress}\n`);
21
- }
package/src/cmds/send.ts DELETED
@@ -1,40 +0,0 @@
1
- import { AztecAddress, Contract, Fq, Fr, getSchnorrAccount } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
- import { prepTx } from '../utils.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function send(
11
- functionName: string,
12
- functionArgsIn: any[],
13
- contractArtifactPath: string,
14
- contractAddress: AztecAddress,
15
- privateKey: Fq,
16
- rpcUrl: string,
17
- wait: boolean,
18
- debugLogger: DebugLogger,
19
- log: LogFn,
20
- ) {
21
- const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
22
-
23
- const client = await createCompatibleClient(rpcUrl, debugLogger);
24
- const wallet = await getSchnorrAccount(client, privateKey, privateKey, Fr.ZERO).getWallet();
25
- const contract = await Contract.at(contractAddress, contractArtifact, wallet);
26
- const tx = contract.methods[functionName](...functionArgs).send();
27
- log(`\nTransaction hash: ${(await tx.getTxHash()).toString()}`);
28
- if (wait) {
29
- await tx.wait();
30
-
31
- log('Transaction has been mined');
32
-
33
- const receipt = await tx.getReceipt();
34
- log(`Status: ${receipt.status}\n`);
35
- log(`Block number: ${receipt.blockNumber}`);
36
- log(`Block hash: ${receipt.blockHash?.toString('hex')}`);
37
- } else {
38
- log('Transaction pending. Check status with get-tx-receipt');
39
- }
40
- }
package/src/cmds/unbox.ts DELETED
@@ -1,11 +0,0 @@
1
- import { LogFn } from '@aztec/foundation/log';
2
-
3
- import { unboxContract } from '../unbox.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function unbox(contractName: string, localDirectory: string | undefined, cliVersion: string, log: LogFn) {
9
- const unboxTo: string = localDirectory ? localDirectory : contractName;
10
- await unboxContract(contractName, unboxTo, cliVersion, log);
11
- }
package/src/encoding.ts DELETED
@@ -1,115 +0,0 @@
1
- import { ABIParameter, ABIType, StructType } from '@aztec/foundation/abi';
2
- import { Fr } from '@aztec/foundation/fields';
3
-
4
- /**
5
- * Parses a hex string into an ABI struct type.
6
- * @param str - The encoded hex string.
7
- * @param abiType - The ABI Struct type.
8
- * @returns An object in the ABI struct type's format.
9
- */
10
- export function parseStructString(str: string, abiType: StructType) {
11
- // Assign string bytes to struct fields.
12
- const buf = Buffer.from(str.replace(/^0x/i, ''), 'hex');
13
- const struct: any = {};
14
- let byteIndex = 0;
15
- let argIndex = 0;
16
- while (byteIndex < buf.length) {
17
- const { name } = abiType.fields[argIndex];
18
- struct[name] = Fr.fromBuffer(buf.subarray(byteIndex, byteIndex + 32));
19
- byteIndex += 32;
20
- argIndex += 1;
21
- }
22
-
23
- return struct;
24
- }
25
-
26
- /**
27
- * Helper function to encode CLI string args to an appropriate JS type.
28
- * @param arg - The CLI argument.
29
- * @param abiType - The type as described by the contract's ABI.
30
- * @returns The encoded argument.
31
- */
32
- function encodeArg(arg: string, abiType: ABIType, name: string): any {
33
- const { kind } = abiType;
34
- if (kind === 'field' || kind === 'integer') {
35
- let res: bigint;
36
- try {
37
- res = BigInt(arg);
38
- } catch (err) {
39
- throw new Error(
40
- `Invalid value passed for ${name}. Could not parse ${arg} as a${kind === 'integer' ? 'n' : ''} ${kind}.`,
41
- );
42
- }
43
- return res;
44
- } else if (kind === 'boolean') {
45
- if (arg === 'true') {
46
- return true;
47
- }
48
- if (arg === 'false') {
49
- return false;
50
- } else {
51
- throw Error(`Invalid boolean value passed for ${name}: ${arg}.`);
52
- }
53
- } else if (kind === 'array') {
54
- let arr;
55
- const res = [];
56
- try {
57
- arr = JSON.parse(arg);
58
- } catch {
59
- throw new Error(`Unable to parse arg ${arg} as array for ${name} parameter`);
60
- }
61
- if (!Array.isArray(arr)) {
62
- throw Error(`Invalid argument ${arg} passed for array parameter ${name}.`);
63
- }
64
- if (arr.length !== abiType.length) {
65
- throw Error(`Invalid array length passed for ${name}. Expected ${abiType.length}, received ${arr.length}.`);
66
- }
67
- for (let i = 0; i < abiType.length; i += 1) {
68
- res.push(encodeArg(arr[i], abiType.type, name));
69
- }
70
- return res;
71
- } else if (kind === 'struct') {
72
- // check if input is encoded long string
73
- if (arg.startsWith('0x')) {
74
- return parseStructString(arg, abiType);
75
- }
76
- let obj;
77
- try {
78
- obj = JSON.parse(arg);
79
- } catch {
80
- throw new Error(`Unable to parse arg ${arg} as struct`);
81
- }
82
- if (Array.isArray(obj)) {
83
- throw Error(`Array passed for arg ${name}. Expected a struct.`);
84
- }
85
- const res: any = {};
86
- for (const field of abiType.fields) {
87
- // Remove field name from list as it's present
88
- const arg = obj[field.name];
89
- if (!arg) {
90
- throw Error(`Expected field ${field.name} not found in struct ${name}.`);
91
- }
92
- res[field.name] = encodeArg(obj[field.name], field.type, field.name);
93
- }
94
- return res;
95
- }
96
- }
97
-
98
- /**
99
- * Tries to encode function args to their equivalent TS type.
100
- * @param args - An array of function's / constructor's args.
101
- * @returns The encoded array.
102
- */
103
- export function encodeArgs(args: any[], params: ABIParameter[]) {
104
- if (args.length !== params.length) {
105
- throw new Error(
106
- `Invalid args provided.\nExpected args: [${params
107
- .map(param => param.name + ': ' + param.type.kind)
108
- .join(', ')}]\nReceived args: ${args.join(', ')}`,
109
- );
110
- }
111
- return args.map((arg: any, index) => {
112
- const { type, name } = params[index];
113
- return encodeArg(arg, type, name);
114
- });
115
- }
package/src/github.ts DELETED
@@ -1,3 +0,0 @@
1
- export const GITHUB_OWNER = 'AztecProtocol';
2
- export const GITHUB_REPO = 'aztec-packages';
3
- export const GITHUB_TAG_PREFIX = 'aztec-packages';