@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
package/dest/bin/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "0.16.4",
3
+ "version": "0.16.5",
4
4
  "type": "module",
5
5
  "main": "./dest/index.js",
6
6
  "bin": {
@@ -34,13 +34,13 @@
34
34
  "rootDir": "./src"
35
35
  },
36
36
  "dependencies": {
37
- "@aztec/aztec.js": "0.16.4",
38
- "@aztec/ethereum": "0.16.4",
39
- "@aztec/foundation": "0.16.4",
40
- "@aztec/l1-artifacts": "0.16.4",
41
- "@aztec/noir-compiler": "0.16.4",
42
- "@aztec/noir-contracts": "0.16.4",
43
- "@aztec/types": "0.16.4",
37
+ "@aztec/aztec.js": "0.16.5",
38
+ "@aztec/ethereum": "0.16.5",
39
+ "@aztec/foundation": "0.16.5",
40
+ "@aztec/l1-artifacts": "0.16.5",
41
+ "@aztec/noir-compiler": "0.16.5",
42
+ "@aztec/noir-contracts": "0.16.5",
43
+ "@aztec/types": "0.16.5",
44
44
  "@libp2p/peer-id-factory": "^3.0.4",
45
45
  "@ltd/j-toml": "^1.38.0",
46
46
  "commander": "^9.0.0",
package/src/bin/index.ts DELETED
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env -S node --no-warnings
2
- import { createConsoleLogger, createDebugLogger } from '@aztec/foundation/log';
3
-
4
- import { getProgram } from '../index.js';
5
-
6
- const debugLogger = createDebugLogger('aztec:cli');
7
- const log = createConsoleLogger();
8
-
9
- /** CLI main entrypoint */
10
- async function main() {
11
- process.once('SIGINT', () => process.exit(0));
12
- process.once('SIGTERM', () => process.exit(0));
13
-
14
- const program = getProgram(log, debugLogger);
15
- await program.parseAsync(process.argv);
16
- }
17
-
18
- main().catch(err => {
19
- log(`Error in command execution`);
20
- log(err);
21
- process.exit(1);
22
- });
package/src/client.ts DELETED
@@ -1,68 +0,0 @@
1
- import { PXE, createPXEClient } from '@aztec/aztec.js';
2
- import { DebugLogger } from '@aztec/foundation/log';
3
- import { fileURLToPath } from '@aztec/foundation/url';
4
-
5
- import { readFileSync } from 'fs';
6
- import { dirname, resolve } from 'path';
7
- import { gtr, ltr, satisfies, valid } from 'semver';
8
-
9
- /**
10
- * Creates a PXE client with a given set of retries on non-server errors.
11
- * Checks that PXE matches the expected version, and warns if not.
12
- * @param rpcUrl - URL of the RPC server wrapping the PXE.
13
- * @param logger - Debug logger to warn version incompatibilities.
14
- * @returns A PXE client.
15
- */
16
- export async function createCompatibleClient(rpcUrl: string, logger: DebugLogger) {
17
- const pxe = createPXEClient(rpcUrl);
18
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json');
19
- const packageJsonContents = JSON.parse(readFileSync(packageJsonPath).toString());
20
- const expectedVersionRange = packageJsonContents.version; // During sandbox, we'll expect exact matches
21
-
22
- try {
23
- await checkServerVersion(pxe, expectedVersionRange);
24
- } catch (err) {
25
- if (err instanceof VersionMismatchError) {
26
- logger.warn(err.message);
27
- } else {
28
- throw err;
29
- }
30
- }
31
-
32
- return pxe;
33
- }
34
-
35
- /** Mismatch between server and client versions. */
36
- class VersionMismatchError extends Error {}
37
-
38
- /**
39
- * Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not.
40
- * @param pxe - PXE client.
41
- * @param expectedVersionRange - Expected version by CLI.
42
- */
43
- export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) {
44
- const serverName = 'Aztec Sandbox';
45
- const { sandboxVersion } = await pxe.getNodeInfo();
46
- if (!sandboxVersion) {
47
- throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`);
48
- }
49
- if (!sandboxVersion || !valid(sandboxVersion)) {
50
- throw new VersionMismatchError(
51
- `Missing or invalid version identifier for ${serverName} (${sandboxVersion ?? 'empty'}).`,
52
- );
53
- } else if (!satisfies(sandboxVersion, expectedVersionRange)) {
54
- if (gtr(sandboxVersion, expectedVersionRange)) {
55
- throw new VersionMismatchError(
56
- `${serverName} is running version ${sandboxVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`,
57
- );
58
- } else if (ltr(sandboxVersion, expectedVersionRange)) {
59
- throw new VersionMismatchError(
60
- `${serverName} is running version ${sandboxVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`,
61
- );
62
- } else {
63
- throw new VersionMismatchError(
64
- `${serverName} is running version ${sandboxVersion} which does not match the expected by this CLI (${expectedVersionRange}).`,
65
- );
66
- }
67
- }
68
- }
@@ -1,27 +0,0 @@
1
- import { AztecAddress, CompleteAddress, EthAddress, Fr, Point } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
- import { getContractArtifact } from '../utils.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function addContract(
11
- rpcUrl: string,
12
- contractArtifactPath: string,
13
- contractAddress: AztecAddress,
14
- partialAddress: Fr,
15
- publicKey: Point,
16
- portalContract: EthAddress | undefined,
17
- debugLogger: DebugLogger,
18
- log: LogFn,
19
- ) {
20
- const artifact = await getContractArtifact(contractArtifactPath, log);
21
- const completeAddress = new CompleteAddress(contractAddress, publicKey ?? Fr.ZERO, partialAddress);
22
- const portalContractAddress: EthAddress = portalContract ?? EthAddress.ZERO;
23
- const client = await createCompatibleClient(rpcUrl, debugLogger);
24
-
25
- await client.addContracts([{ artifact, completeAddress, portalContract: portalContractAddress }]);
26
- log(`\nContract added to PXE at ${contractAddress.toString()}\n`);
27
- }
@@ -1,24 +0,0 @@
1
- import { AztecAddress, Fr } from '@aztec/aztec.js';
2
- import { DebugLogger } from '@aztec/foundation/log';
3
- import { ExtendedNote, Note, TxHash } from '@aztec/types';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
- import { parseFields } from '../utils.js';
7
-
8
- /**
9
- *
10
- */
11
- export async function addNote(
12
- address: AztecAddress,
13
- contractAddress: AztecAddress,
14
- storageSlot: Fr,
15
- txHash: TxHash,
16
- noteFields: string[],
17
- rpcUrl: string,
18
- debugLogger: DebugLogger,
19
- ) {
20
- const note = new Note(parseFields(noteFields));
21
- const extendedNote = new ExtendedNote(note, address, contractAddress, storageSlot, txHash);
22
- const client = await createCompatibleClient(rpcUrl, debugLogger);
23
- await client.addNote(extendedNote);
24
- }
@@ -1,12 +0,0 @@
1
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
2
-
3
- import { createCompatibleClient } from '../client.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function blockNumber(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
9
- const client = await createCompatibleClient(rpcUrl, debugLogger);
10
- const num = await client.getBlockNumber();
11
- log(`${num}\n`);
12
- }
package/src/cmds/call.ts DELETED
@@ -1,35 +0,0 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { format } from 'util';
5
-
6
- import { createCompatibleClient } from '../client.js';
7
- import { getFunctionArtifact, getTxSender, prepTx } from '../utils.js';
8
-
9
- /**
10
- *
11
- */
12
- export async function call(
13
- functionName: string,
14
- functionArgsIn: any[],
15
- contractArtifactPath: string,
16
- contractAddress: AztecAddress,
17
- fromAddress: string | undefined,
18
- rpcUrl: string,
19
- debugLogger: DebugLogger,
20
- log: LogFn,
21
- ) {
22
- const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
23
-
24
- const fnArtifact = getFunctionArtifact(contractArtifact, functionName);
25
- if (fnArtifact.parameters.length !== functionArgs.length) {
26
- throw Error(
27
- `Invalid number of args passed. Expected ${fnArtifact.parameters.length}; Received: ${functionArgs.length}`,
28
- );
29
- }
30
-
31
- const client = await createCompatibleClient(rpcUrl, debugLogger);
32
- const from = await getTxSender(client, fromAddress);
33
- const result = await client.viewTx(functionName, functionArgs, contractAddress, from);
34
- log(format('\nView result: ', result, '\n'));
35
- }
@@ -1,17 +0,0 @@
1
- import { AztecAddress, isContractDeployed } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
-
6
- /**
7
- *
8
- */
9
- export async function checkDeploy(rpcUrl: string, contractAddress: AztecAddress, debugLogger: DebugLogger, log: LogFn) {
10
- const client = await createCompatibleClient(rpcUrl, debugLogger);
11
- const isDeployed = await isContractDeployed(client, contractAddress);
12
- if (isDeployed) {
13
- log(`\nContract found at ${contractAddress.toString()}\n`);
14
- } else {
15
- log(`\nNo contract found at ${contractAddress.toString()}\n`);
16
- }
17
- }
@@ -1,10 +0,0 @@
1
- import { FunctionSelector } from '@aztec/foundation/abi';
2
- import { LogFn } from '@aztec/foundation/log';
3
-
4
- /**
5
- *
6
- */
7
- export function computeSelector(functionSignature: string, log: LogFn) {
8
- const selector = FunctionSelector.fromSignature(functionSignature);
9
- log(`${selector}`);
10
- }
@@ -1,39 +0,0 @@
1
- import { GrumpkinScalar, getSchnorrAccount } from '@aztec/aztec.js';
2
- import { Fq, Fr } from '@aztec/foundation/fields';
3
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function createAccount(
11
- rpcUrl: string,
12
- privateKey: Fq,
13
- wait: boolean,
14
- debugLogger: DebugLogger,
15
- log: LogFn,
16
- ) {
17
- const client = await createCompatibleClient(rpcUrl, debugLogger);
18
- const actualPrivateKey = privateKey ?? GrumpkinScalar.random();
19
-
20
- const account = getSchnorrAccount(client, actualPrivateKey, actualPrivateKey, Fr.ZERO);
21
- const { address, publicKey, partialAddress } = account.getCompleteAddress();
22
- const tx = await account.deploy();
23
- const txHash = await tx.getTxHash();
24
- debugLogger(`Account contract tx sent with hash ${txHash}`);
25
- if (wait) {
26
- log(`\nWaiting for account contract deployment...`);
27
- await tx.wait();
28
- } else {
29
- log(`\nAccount deployment transaction hash: ${txHash}\n`);
30
- }
31
-
32
- log(`\nNew account:\n`);
33
- log(`Address: ${address.toString()}`);
34
- log(`Public key: ${publicKey.toString()}`);
35
- if (!privateKey) {
36
- log(`Private key: ${actualPrivateKey.toString()}`);
37
- }
38
- log(`Partial address: ${partialAddress.toString()}`);
39
- }
@@ -1,77 +0,0 @@
1
- import { ContractDeployer, EthAddress, Fr, Point } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
- import { encodeArgs } from '../encoding.js';
6
- import { GITHUB_TAG_PREFIX } from '../github.js';
7
- import { getContractArtifact, getFunctionArtifact } from '../utils.js';
8
-
9
- /**
10
- *
11
- */
12
- export async function deploy(
13
- artifactPath: string,
14
- json: boolean,
15
- rpcUrl: string,
16
- publicKey: Point | undefined,
17
- rawArgs: any[],
18
- portalAddress: EthAddress,
19
- salt: Fr,
20
- wait: boolean,
21
- debugLogger: DebugLogger,
22
- log: LogFn,
23
- logJson: (output: any) => void,
24
- ) {
25
- const contractArtifact = await getContractArtifact(artifactPath, log);
26
- const constructorArtifact = contractArtifact.functions.find(({ name }) => name === 'constructor');
27
-
28
- const client = await createCompatibleClient(rpcUrl, debugLogger);
29
- const nodeInfo = await client.getNodeInfo();
30
- const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.sandboxVersion}`;
31
- if (contractArtifact.aztecNrVersion && contractArtifact.aztecNrVersion !== expectedAztecNrVersion) {
32
- log(
33
- `\nWarning: Contract was compiled with a different version of Aztec.nr: ${contractArtifact.aztecNrVersion}. Consider updating Aztec.nr to ${expectedAztecNrVersion}\n`,
34
- );
35
- }
36
-
37
- const deployer = new ContractDeployer(contractArtifact, client, publicKey);
38
-
39
- const constructor = getFunctionArtifact(contractArtifact, 'constructor');
40
- if (!constructor) {
41
- throw new Error(`Constructor not found in contract ABI`);
42
- }
43
-
44
- debugLogger(`Input arguments: ${rawArgs.map((x: any) => `"${x}"`).join(', ')}`);
45
- const args = encodeArgs(rawArgs, constructorArtifact!.parameters);
46
- debugLogger(`Encoded arguments: ${args.join(', ')}`);
47
-
48
- const deploy = deployer.deploy(...args);
49
-
50
- await deploy.create({ contractAddressSalt: salt, portalContract: portalAddress });
51
- const tx = deploy.send({ contractAddressSalt: salt, portalContract: portalAddress });
52
- const txHash = await tx.getTxHash();
53
- debugLogger(`Deploy tx sent with hash ${txHash}`);
54
- if (wait) {
55
- const deployed = await tx.wait();
56
- const { address, partialAddress } = deployed.contract.completeAddress;
57
- if (json) {
58
- logJson({ address: address.toString(), partialAddress: partialAddress.toString() });
59
- } else {
60
- log(`\nContract deployed at ${address.toString()}\n`);
61
- log(`Contract partial address ${partialAddress.toString()}\n`);
62
- }
63
- } else {
64
- const { address, partialAddress } = deploy.completeAddress ?? {};
65
- if (json) {
66
- logJson({
67
- address: address?.toString() ?? 'N/A',
68
- partialAddress: partialAddress?.toString() ?? 'N/A',
69
- txHash: txHash.toString(),
70
- });
71
- } else {
72
- log(`\nContract Address: ${deploy.completeAddress?.address.toString() ?? 'N/A'}`);
73
- log(`Contract Partial Address: ${deploy.completeAddress?.partialAddress.toString() ?? 'N/A'}`);
74
- log(`Deployment transaction hash: ${txHash}\n`);
75
- }
76
- }
77
- }
@@ -1,25 +0,0 @@
1
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
2
-
3
- import { deployAztecContracts } from '../utils.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function deployL1Contracts(
9
- rpcUrl: string,
10
- apiKey: string,
11
- privateKey: string,
12
- mnemonic: string,
13
- log: LogFn,
14
- debugLogger: DebugLogger,
15
- ) {
16
- const { l1ContractAddresses } = await deployAztecContracts(rpcUrl, apiKey, privateKey, mnemonic, debugLogger);
17
-
18
- log('\n');
19
- log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`);
20
- log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`);
21
- log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`);
22
- log(`L2 -> L1 Outbox address: ${l1ContractAddresses.outboxAddress.toString()}`);
23
- log(`Contract Deployment Emitter Address: ${l1ContractAddresses.contractDeploymentEmitterAddress.toString()}`);
24
- log('\n');
25
- }
@@ -1,12 +0,0 @@
1
- import { LogFn } from '@aztec/foundation/log';
2
-
3
- import { getExampleContractArtifacts } from '../utils.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function exampleContracts(log: LogFn) {
9
- const abisList = await getExampleContractArtifacts();
10
- const names = Object.keys(abisList);
11
- names.forEach(name => log(name));
12
- }
@@ -1,13 +0,0 @@
1
- import { LogFn } from '@aztec/foundation/log';
2
-
3
- import { createSecp256k1PeerId } from '@libp2p/peer-id-factory';
4
-
5
- /**
6
- *
7
- */
8
- export async function generateP2PPrivateKey(log: LogFn) {
9
- const peerId = await createSecp256k1PeerId();
10
- const exportedPeerId = Buffer.from(peerId.privateKey!).toString('hex');
11
- log(`Private key: ${exportedPeerId}`);
12
- log(`Peer Id: ${peerId}`);
13
- }
@@ -1,23 +0,0 @@
1
- import { GrumpkinScalar, generatePublicKey } from '@aztec/aztec.js';
2
- import { LogFn } from '@aztec/foundation/log';
3
-
4
- import { mnemonicToAccount } from 'viem/accounts';
5
-
6
- /**
7
- *
8
- */
9
- export function generatePrivateKey(mnemonic: string | undefined, log: LogFn) {
10
- let privKey;
11
- let publicKey;
12
- if (mnemonic) {
13
- const acc = mnemonicToAccount(mnemonic);
14
- // TODO(#2052): This reduction is not secure enough. TACKLE THIS ISSUE BEFORE MAINNET.
15
- const key = GrumpkinScalar.fromBufferReduce(Buffer.from(acc.getHdKey().privateKey!));
16
- publicKey = generatePublicKey(key);
17
- } else {
18
- const key = GrumpkinScalar.random();
19
- privKey = key.toString();
20
- publicKey = generatePublicKey(key);
21
- }
22
- log(`\nPrivate Key: ${privKey}\nPublic Key: ${publicKey.toString()}\n`);
23
- }
@@ -1,18 +0,0 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
-
6
- /**
7
- *
8
- */
9
- export async function getAccount(aztecAddress: AztecAddress, rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
10
- const client = await createCompatibleClient(rpcUrl, debugLogger);
11
- const account = await client.getRegisteredAccount(aztecAddress);
12
-
13
- if (!account) {
14
- log(`Unknown account ${aztecAddress.toString()}`);
15
- } else {
16
- log(account.toReadableString());
17
- }
18
- }
@@ -1,19 +0,0 @@
1
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
2
-
3
- import { createCompatibleClient } from '../client.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function getAccounts(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
9
- const client = await createCompatibleClient(rpcUrl, debugLogger);
10
- const accounts = await client.getRegisteredAccounts();
11
- if (!accounts.length) {
12
- log('No accounts found.');
13
- } else {
14
- log(`Accounts found: \n`);
15
- for (const account of accounts) {
16
- log(account.toReadableString());
17
- }
18
- }
19
- }
@@ -1,39 +0,0 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
- import { ContractData } from '@aztec/types';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function getContractData(
11
- rpcUrl: string,
12
- contractAddress: AztecAddress,
13
- includeBytecode: boolean,
14
- debugLogger: DebugLogger,
15
- log: LogFn,
16
- ) {
17
- const client = await createCompatibleClient(rpcUrl, debugLogger);
18
- const contractDataWithOrWithoutBytecode = includeBytecode
19
- ? await client.getExtendedContractData(contractAddress)
20
- : await client.getContractData(contractAddress);
21
-
22
- if (!contractDataWithOrWithoutBytecode) {
23
- log(`No contract data found at ${contractAddress}`);
24
- return;
25
- }
26
- let contractData: ContractData;
27
-
28
- if ('contractData' in contractDataWithOrWithoutBytecode) {
29
- contractData = contractDataWithOrWithoutBytecode.contractData;
30
- } else {
31
- contractData = contractDataWithOrWithoutBytecode;
32
- }
33
- log(`\nContract Data: \nAddress: ${contractData.contractAddress.toString()}`);
34
- log(`Portal: ${contractData.portalContractAddress.toString()}`);
35
- if ('bytecode' in contractDataWithOrWithoutBytecode) {
36
- log(`Bytecode: ${contractDataWithOrWithoutBytecode.bytecode}`);
37
- }
38
- log('\n');
39
- }
@@ -1,71 +0,0 @@
1
- import { AztecAddress, FunctionSelector, LogFilter, LogId, TxHash } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
- import { sleep } from '@aztec/foundation/sleep';
4
-
5
- import { createCompatibleClient } from '../client.js';
6
-
7
- /**
8
- *
9
- */
10
- export async function getLogs(
11
- txHash: TxHash,
12
- fromBlock: number,
13
- toBlock: number,
14
- afterLog: LogId,
15
- contractAddress: AztecAddress,
16
- selector: FunctionSelector,
17
- rpcUrl: string,
18
- follow: boolean,
19
- debugLogger: DebugLogger,
20
- log: LogFn,
21
- ) {
22
- const pxe = await createCompatibleClient(rpcUrl, debugLogger);
23
-
24
- if (follow) {
25
- if (txHash) {
26
- throw Error('Cannot use --follow with --tx-hash');
27
- }
28
- if (toBlock) {
29
- throw Error('Cannot use --follow with --to-block');
30
- }
31
- }
32
-
33
- const filter: LogFilter = { txHash, fromBlock, toBlock, afterLog, contractAddress, selector };
34
-
35
- const fetchLogs = async () => {
36
- const response = await pxe.getUnencryptedLogs(filter);
37
- const logs = response.logs;
38
-
39
- if (!logs.length) {
40
- const filterOptions = Object.entries(filter)
41
- .filter(([, value]) => value !== undefined)
42
- .map(([key, value]) => `${key}: ${value}`)
43
- .join(', ');
44
- if (!follow) {
45
- log(`No logs found for filter: {${filterOptions}}`);
46
- }
47
- } else {
48
- if (!follow && !filter.afterLog) {
49
- log('Logs found: \n');
50
- }
51
- logs.forEach(unencryptedLog => log(unencryptedLog.toHumanReadable()));
52
- // Set the continuation parameter for the following requests
53
- filter.afterLog = logs[logs.length - 1].id;
54
- }
55
- return response.maxLogsHit;
56
- };
57
-
58
- if (follow) {
59
- log('Fetching logs...');
60
- while (true) {
61
- const maxLogsHit = await fetchLogs();
62
- if (!maxLogsHit) {
63
- await sleep(1000);
64
- }
65
- }
66
- } else {
67
- while (await fetchLogs()) {
68
- // Keep fetching logs until we reach the end.
69
- }
70
- }
71
- }
@@ -1,17 +0,0 @@
1
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
2
-
3
- import { createCompatibleClient } from '../client.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function getNodeInfo(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
9
- const client = await createCompatibleClient(rpcUrl, debugLogger);
10
- const info = await client.getNodeInfo();
11
- log(`\nNode Info:\n`);
12
- log(`Sandbox Version: ${info.sandboxVersion}\n`);
13
- log(`Compatible Nargo Version: ${info.compatibleNargoVersion}\n`);
14
- log(`Chain Id: ${info.chainId}\n`);
15
- log(`Protocol Version: ${info.protocolVersion}\n`);
16
- log(`Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`);
17
- }
@@ -1,18 +0,0 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
2
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
3
-
4
- import { createCompatibleClient } from '../client.js';
5
-
6
- /**
7
- *
8
- */
9
- export async function getRecipient(aztecAddress: AztecAddress, rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
10
- const client = await createCompatibleClient(rpcUrl, debugLogger);
11
- const recipient = await client.getRecipient(aztecAddress);
12
-
13
- if (!recipient) {
14
- log(`Unknown recipient ${aztecAddress.toString()}`);
15
- } else {
16
- log(recipient.toReadableString());
17
- }
18
- }
@@ -1,19 +0,0 @@
1
- import { DebugLogger, LogFn } from '@aztec/foundation/log';
2
-
3
- import { createCompatibleClient } from '../client.js';
4
-
5
- /**
6
- *
7
- */
8
- export async function getRecipients(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
9
- const client = await createCompatibleClient(rpcUrl, debugLogger);
10
- const recipients = await client.getRecipients();
11
- if (!recipients.length) {
12
- log('No recipients found.');
13
- } else {
14
- log(`Recipients found: \n`);
15
- for (const recipient of recipients) {
16
- log(recipient.toReadableString());
17
- }
18
- }
19
- }