From c48c91349dd592520ee33d4c45bc2d3913883541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Mon, 22 Apr 2024 10:10:05 +0200 Subject: [PATCH] chore: nuking CLI (#5865) Fixes #5894 --- .circleci/config.yml | 15 - aztec-up/bin/aztec-install | 3 - boxes/Dockerfile | 2 +- boxes/Earthfile | 2 +- boxes/boxes/react/package.json | 2 +- boxes/boxes/vanilla/package.json | 2 +- boxes/contract-only/package.json | 2 +- build_manifest.yml | 10 - .../aztecjs/guides/call_view_function.md | 4 +- .../aztecjs/guides/create_account.md | 2 - .../aztecjs/guides/deploy_contract.md | 2 - .../aztecjs/guides/send_transaction.md | 2 - .../how_to_compile_contract.md | 2 +- .../sandbox/references/cli-commands.md | 129 ----- .../writing_private_voting_contract.md | 2 +- docs/sidebars.js | 1 - release-please-config.json | 6 +- yarn-project/Dockerfile | 2 +- yarn-project/Earthfile | 7 +- yarn-project/cli/.eslintrc.cjs | 1 - yarn-project/cli/CHANGELOG.md | 221 -------- yarn-project/cli/Dockerfile | 10 - yarn-project/cli/README.md | 450 ---------------- yarn-project/cli/aztec-cli-dest | 3 - yarn-project/cli/package.json | 86 --- yarn-project/cli/src/bin/index.ts | 24 - yarn-project/cli/src/client.test.ts | 31 -- yarn-project/cli/src/client.ts | 68 --- yarn-project/cli/src/cmds/add_contract.ts | 46 -- yarn-project/cli/src/cmds/add_note.ts | 22 - yarn-project/cli/src/cmds/block_number.ts | 9 - yarn-project/cli/src/cmds/call.ts | 32 -- yarn-project/cli/src/cmds/check_deploy.ts | 19 - yarn-project/cli/src/cmds/compute_selector.ts | 7 - yarn-project/cli/src/cmds/create_account.ts | 38 -- yarn-project/cli/src/cmds/deploy.ts | 81 --- .../cli/src/cmds/deploy_l1_contracts.ts | 24 - .../cli/src/cmds/example_contracts.ts | 9 - .../cli/src/cmds/generate_p2p_private_key.ts | 10 - .../cli/src/cmds/generate_private_key.ts | 20 - yarn-project/cli/src/cmds/get_account.ts | 15 - yarn-project/cli/src/cmds/get_accounts.ts | 36 -- .../cli/src/cmds/get_contract_data.ts | 32 -- yarn-project/cli/src/cmds/get_logs.ts | 69 --- yarn-project/cli/src/cmds/get_node_info.ts | 13 - yarn-project/cli/src/cmds/get_recipient.ts | 15 - yarn-project/cli/src/cmds/get_recipients.ts | 16 - yarn-project/cli/src/cmds/get_tx_receipt.ts | 15 - yarn-project/cli/src/cmds/inspect_contract.ts | 43 -- .../cli/src/cmds/parse_parameter_struct.ts | 27 - yarn-project/cli/src/cmds/register_account.ts | 21 - .../cli/src/cmds/register_recipient.ts | 18 - yarn-project/cli/src/cmds/send.ts | 40 -- yarn-project/cli/src/encoding.ts | 117 ---- yarn-project/cli/src/github.ts | 3 - yarn-project/cli/src/index.ts | 502 ------------------ yarn-project/cli/src/parse_args.ts | 248 --------- yarn-project/cli/src/test/mocks.ts | 73 --- yarn-project/cli/src/test/utils.test.ts | 157 ------ yarn-project/cli/src/update/common.ts | 16 - yarn-project/cli/src/update/noir.ts | 57 -- yarn-project/cli/src/update/npm.ts | 154 ------ yarn-project/cli/src/update/update.ts | 79 --- yarn-project/cli/src/utils.ts | 235 -------- yarn-project/cli/tsconfig.json | 42 -- yarn-project/end-to-end/Earthfile | 4 - yarn-project/end-to-end/package.json | 1 - .../src/composed/cli_docs_sandbox.test.ts | 389 -------------- yarn-project/end-to-end/src/e2e_cli.test.ts | 35 -- .../src/guides/up_quick_start.test.ts | 3 +- yarn-project/end-to-end/src/shared/cli.ts | 242 --------- yarn-project/end-to-end/src/shared/index.ts | 1 - yarn-project/end-to-end/tsconfig.json | 3 - yarn-project/noir-compiler/aztec-compile-dest | 3 + yarn-project/tsconfig.json | 1 - yarn-project/yarn.lock | 204 +------ 76 files changed, 21 insertions(+), 4316 deletions(-) delete mode 100644 docs/docs/developers/sandbox/references/cli-commands.md delete mode 100644 yarn-project/cli/.eslintrc.cjs delete mode 100644 yarn-project/cli/CHANGELOG.md delete mode 100644 yarn-project/cli/Dockerfile delete mode 100644 yarn-project/cli/README.md delete mode 100755 yarn-project/cli/aztec-cli-dest delete mode 100644 yarn-project/cli/package.json delete mode 100644 yarn-project/cli/src/bin/index.ts delete mode 100644 yarn-project/cli/src/client.test.ts delete mode 100644 yarn-project/cli/src/client.ts delete mode 100644 yarn-project/cli/src/cmds/add_contract.ts delete mode 100644 yarn-project/cli/src/cmds/add_note.ts delete mode 100644 yarn-project/cli/src/cmds/block_number.ts delete mode 100644 yarn-project/cli/src/cmds/call.ts delete mode 100644 yarn-project/cli/src/cmds/check_deploy.ts delete mode 100644 yarn-project/cli/src/cmds/compute_selector.ts delete mode 100644 yarn-project/cli/src/cmds/create_account.ts delete mode 100644 yarn-project/cli/src/cmds/deploy.ts delete mode 100644 yarn-project/cli/src/cmds/deploy_l1_contracts.ts delete mode 100644 yarn-project/cli/src/cmds/example_contracts.ts delete mode 100644 yarn-project/cli/src/cmds/generate_p2p_private_key.ts delete mode 100644 yarn-project/cli/src/cmds/generate_private_key.ts delete mode 100644 yarn-project/cli/src/cmds/get_account.ts delete mode 100644 yarn-project/cli/src/cmds/get_accounts.ts delete mode 100644 yarn-project/cli/src/cmds/get_contract_data.ts delete mode 100644 yarn-project/cli/src/cmds/get_logs.ts delete mode 100644 yarn-project/cli/src/cmds/get_node_info.ts delete mode 100644 yarn-project/cli/src/cmds/get_recipient.ts delete mode 100644 yarn-project/cli/src/cmds/get_recipients.ts delete mode 100644 yarn-project/cli/src/cmds/get_tx_receipt.ts delete mode 100644 yarn-project/cli/src/cmds/inspect_contract.ts delete mode 100644 yarn-project/cli/src/cmds/parse_parameter_struct.ts delete mode 100644 yarn-project/cli/src/cmds/register_account.ts delete mode 100644 yarn-project/cli/src/cmds/register_recipient.ts delete mode 100644 yarn-project/cli/src/cmds/send.ts delete mode 100644 yarn-project/cli/src/encoding.ts delete mode 100644 yarn-project/cli/src/github.ts delete mode 100644 yarn-project/cli/src/index.ts delete mode 100644 yarn-project/cli/src/parse_args.ts delete mode 100644 yarn-project/cli/src/test/mocks.ts delete mode 100644 yarn-project/cli/src/test/utils.test.ts delete mode 100644 yarn-project/cli/src/update/common.ts delete mode 100644 yarn-project/cli/src/update/noir.ts delete mode 100644 yarn-project/cli/src/update/npm.ts delete mode 100644 yarn-project/cli/src/update/update.ts delete mode 100644 yarn-project/cli/src/utils.ts delete mode 100644 yarn-project/cli/tsconfig.json delete mode 100644 yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts delete mode 100644 yarn-project/end-to-end/src/e2e_cli.test.ts delete mode 100644 yarn-project/end-to-end/src/shared/cli.ts create mode 100755 yarn-project/noir-compiler/aztec-compile-dest diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b4c8af64ae..49f9588d930 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -443,18 +443,6 @@ jobs: command: build aztec aztec_manifest_key: aztec - cli: - machine: - image: default - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: "Build and test" - command: build cli - aztec_manifest_key: cli - mainnet-fork: machine: image: default @@ -621,7 +609,6 @@ jobs: should_release || exit 0 deploy_dockerhub noir deploy_dockerhub aztec - deploy_dockerhub cli deploy_dockerhub aztec-faucet deploy_dockerhub mainnet-fork - run: @@ -851,7 +838,6 @@ workflows: # Artifacts - aztec-package: *defaults_yarn_project - - cli: *defaults_yarn_project # Boxes. - boxes: @@ -872,7 +858,6 @@ workflows: requires: - end-to-end - aztec-package - - cli <<: *defaults # Everything that must complete before deployment. diff --git a/aztec-up/bin/aztec-install b/aztec-up/bin/aztec-install index 769ed5fcb8c..1862bf2d400 100755 --- a/aztec-up/bin/aztec-install +++ b/aztec-up/bin/aztec-install @@ -41,7 +41,6 @@ function title() { fi echo -e "This will install the following scripts and update your PATH if necessary:" echo -e " ${bold}${g}aztec${r} - launches various infrastructure subsystems (node, sequencer, prover, pxe, etc)." - echo -e " ${bold}${g}aztec-cli${r} - a command line tool for interfacing and experimenting with infrastructure." echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain." echo -e " ${bold}${g}aztec-sandbox${r} - a wrapper around docker-compose that launches services needed for sandbox testing." echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions." @@ -106,7 +105,6 @@ export DOCKER_CLI_HINTS=false if [ -z "${SKIP_PULL:-}" ]; then info "Pulling aztec version $VERSION..." pull_container aztec - pull_container cli pull_container noir fi @@ -123,7 +121,6 @@ info "Installing scripts in $BIN_PATH..." rm -f $BIN_PATH/aztec* install_bin .aztec-run install_bin aztec -install_bin aztec-cli install_bin aztec-sandbox install_bin aztec-up install_bin aztec-nargo diff --git a/boxes/Dockerfile b/boxes/Dockerfile index d1bb35ae159..5809c3a2b5b 100644 --- a/boxes/Dockerfile +++ b/boxes/Dockerfile @@ -13,7 +13,7 @@ COPY --from=noir-projects /usr/src/noir-projects/noir-protocol-circuits/crates/t WORKDIR /usr/src/boxes COPY . . ENV AZTEC_NARGO=/usr/src/noir/noir-repo/target/release/nargo -ENV AZTEC_CLI=/usr/src/yarn-project/cli/aztec-cli-dest +ENV AZTEC_COMPILE=/usr/src/yarn-project/noir-compiler/aztec-compile-dest RUN yarn RUN npx -y playwright@1.42 install --with-deps ENTRYPOINT ["/bin/sh", "-c"] diff --git a/boxes/Earthfile b/boxes/Earthfile index 35ebe466c69..77999a36a41 100644 --- a/boxes/Earthfile +++ b/boxes/Earthfile @@ -12,7 +12,7 @@ build: WORKDIR /usr/src/boxes COPY . . ENV AZTEC_NARGO=/usr/src/noir/noir-repo/target/release/nargo - ENV AZTEC_CLI=/usr/src/yarn-project/cli/aztec-cli-dest + ENV AZTEC_COMPILE=/usr/src/yarn-project/noir-compiler/aztec-compile-dest RUN yarn && yarn build RUN npx -y playwright@1.42 install --with-deps ENTRYPOINT ["/bin/sh", "-c"] diff --git a/boxes/boxes/react/package.json b/boxes/boxes/react/package.json index 0cd42e16ae5..31619d2ea24 100644 --- a/boxes/boxes/react/package.json +++ b/boxes/boxes/react/package.json @@ -7,7 +7,7 @@ "main": "./dist/index.js", "scripts": { "compile": "cd src/contracts && ${AZTEC_NARGO:-aztec-nargo} compile", - "codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts", + "codegen": "${AZTEC_COMPILE:-aztec-compile} codegen src/contracts/target -o artifacts", "clean": "rm -rf ./dist .tsbuildinfo ./artifacts ./src/contracts/target", "prep": "yarn clean && yarn compile && yarn codegen", "dev": "yarn prep && webpack serve --mode development", diff --git a/boxes/boxes/vanilla/package.json b/boxes/boxes/vanilla/package.json index 4e9c549afc6..92b3ebc7cd2 100644 --- a/boxes/boxes/vanilla/package.json +++ b/boxes/boxes/vanilla/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "compile": "cd src/contracts && ${AZTEC_NARGO:-aztec-nargo} compile", - "codegen": "${AZTEC_CLI:-aztec-cli} codegen src/contracts/target -o artifacts", + "codegen": "${AZTEC_COMPILE:-aztec-compile} codegen src/contracts/target -o artifacts", "clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./src/contracts/target", "prep": "yarn clean && yarn compile && yarn codegen && tsc -b", "dev": "yarn prep && webpack serve --mode development", diff --git a/boxes/contract-only/package.json b/boxes/contract-only/package.json index 93e8c27ca85..13edb7678fd 100644 --- a/boxes/contract-only/package.json +++ b/boxes/contract-only/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "compile": "cd src && ${AZTEC_NARGO:-aztec-nargo} compile", - "codegen": "${AZTEC_CLI:-aztec-cli} codegen target -o artifacts", + "codegen": "${AZTEC_COMPILE:-aztec-compile} codegen target -o artifacts", "clean": "rm -rf ./dest .tsbuildinfo ./artifacts ./target", "prep": "yarn clean && yarn compile && yarn codegen && tsc -b", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand", diff --git a/build_manifest.yml b/build_manifest.yml index eb20879ecae..7fa488e722f 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -153,7 +153,6 @@ yarn-project-test: rebuildPatterns: - ^yarn-project/.*\.(ts|tsx|js|cjs|mjs|json|html|md|sh|nr|toml|snap)$ - ^yarn-project/Dockerfile$ - - ^yarn-project/cli/aztec-cli dependencies: - bb.js - noir-packages @@ -185,7 +184,6 @@ yarn-project: rebuildPatterns: - ^yarn-project/.*\.(ts|tsx|js|cjs|mjs|json|html|md|sh|nr|toml|snap)$ - ^yarn-project/Dockerfile$ - - ^yarn-project/cli/aztec-cli dependencies: - bb.js - noir-packages @@ -211,14 +209,6 @@ aztec-faucet: - bb.js - noir-packages -# A runnable container, sets entrypoint to be the aztec-cli entrypoint. -cli: - buildDir: yarn-project - projectDir: yarn-project/cli - dependencies: - - yarn-project - multiarch: buildx - # Builds all the boxes. They are then independently tested in the container. boxes: buildDir: boxes diff --git a/docs/docs/developers/aztecjs/guides/call_view_function.md b/docs/docs/developers/aztecjs/guides/call_view_function.md index 4ff12b8e5fd..4eacff80d1b 100644 --- a/docs/docs/developers/aztecjs/guides/call_view_function.md +++ b/docs/docs/developers/aztecjs/guides/call_view_function.md @@ -4,8 +4,6 @@ title: How to Simulate a Function Call This guide explains how to `simulate` a function call using [Aztec.js](../main.md). -To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#calling-an-unconstrained-view-function). - ## Prerequisites You should have a wallet to act as the caller, and a contract that has been deployed. @@ -14,7 +12,7 @@ You can learn how to create wallets from [this guide](./create_account.md). You can learn how to deploy a contract [here](./deploy_contract.md). -## Relevent imports +## Relevant imports You will need to import this from Aztec.js: diff --git a/docs/docs/developers/aztecjs/guides/create_account.md b/docs/docs/developers/aztecjs/guides/create_account.md index 9aacc62a851..de27eea400c 100644 --- a/docs/docs/developers/aztecjs/guides/create_account.md +++ b/docs/docs/developers/aztecjs/guides/create_account.md @@ -4,8 +4,6 @@ title: How to Create a New Account This guide explains how to create a new account using [Aztec.js](../main.md). -To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#creating-accounts). - ## Relevant imports You will need to import these libraries: diff --git a/docs/docs/developers/aztecjs/guides/deploy_contract.md b/docs/docs/developers/aztecjs/guides/deploy_contract.md index 8f16fbe3364..72aab6ab758 100644 --- a/docs/docs/developers/aztecjs/guides/deploy_contract.md +++ b/docs/docs/developers/aztecjs/guides/deploy_contract.md @@ -4,8 +4,6 @@ title: How to Deploy a Contract This guide explains how to deploy a smart contract using [Aztec.js](../main.md). -To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#deploying-a-token-contract). - ## Prerequisites You should have a wallet to act as the deployer, and a contract artifact ready to be deployed. diff --git a/docs/docs/developers/aztecjs/guides/send_transaction.md b/docs/docs/developers/aztecjs/guides/send_transaction.md index cd05c514942..b1daee16121 100644 --- a/docs/docs/developers/aztecjs/guides/send_transaction.md +++ b/docs/docs/developers/aztecjs/guides/send_transaction.md @@ -4,8 +4,6 @@ title: How to Send a Transaction This guide explains how to send a transaction using [Aztec.js](../main.md). -To do this from the CLI, go [here](../../sandbox/references/cli-commands.md#sending-a-transaction). - ## Prerequisites You should have a wallet to act as the transaction sender, and a contract that has been deployed. diff --git a/docs/docs/developers/contracts/compiling_contracts/how_to_compile_contract.md b/docs/docs/developers/contracts/compiling_contracts/how_to_compile_contract.md index 25f87f2d2e4..3f53b1b55d7 100644 --- a/docs/docs/developers/contracts/compiling_contracts/how_to_compile_contract.md +++ b/docs/docs/developers/contracts/compiling_contracts/how_to_compile_contract.md @@ -254,7 +254,7 @@ At the moment, the compiler generates these interfaces from already compiled ABI ## Next steps -Once you have compiled your contracts, you can use the generated artifacts via the `Contract` class in the `aztec.js` package to deploy and interact with them, or rely on the type-safe typescript classes directly. Alternatively, use the CLI [to deploy](../../sandbox/references/cli-commands.md#deploying-a-token-contract) and [interact](../../sandbox/references/cli-commands.md#calling-an-unconstrained-view-function) with them. +Once you have compiled your contracts, you can use the generated artifacts via the `Contract` class in the `aztec.js` package to deploy and interact with them, or rely on the type-safe typescript classes directly. import Disclaimer from "../../../misc/common/\_disclaimer.mdx"; diff --git a/docs/docs/developers/sandbox/references/cli-commands.md b/docs/docs/developers/sandbox/references/cli-commands.md deleted file mode 100644 index b9a5b5fc896..00000000000 --- a/docs/docs/developers/sandbox/references/cli-commands.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -title: CLI Commands ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -Here you will find an incomplete reference to the commands available in the Aztec CLI. - -:::info - -For a full up-to-date list, run `aztec-cli -h`. - -::: - -## Installation - -### Docker - -The CLI will be installed automatically via Docker by running the command to install and start the sandbox, [instructions here](./sandbox-reference.md#with-docker). - -## Update - -The CLI comes with an update command. - -```bash -aztec-cli update . --contract src/contract1 --contract src/contract2 -``` - -This command does a few things to manage updates: - -- It looks for a `package.json` and updates all `@aztec/` dependencies to the versions the sandbox expects. -- It looks for `Nargo.toml` at the `--contract` paths specified and updates all `aztec.nr` dependencies to the versions the sandbox expects. -- It outputs the changes. - -You can specify a version to update to with the `--aztec-version` flag, but it defaults to `latest` so this is typically not necessary. - -:::info - -The update command won't update the CLI itself. To update these follow the [updating instructions which point to our curl command](./sandbox-reference.md#with-docker). - -::: - -## Compile - -You can find more information about compiling contracts [on this page](../../contracts/compiling_contracts/how_to_compile_contract.md). - -## Creating Accounts - -The first thing we want to do is create a couple of accounts. We will use the `create-account` command which will generate a new private key for us, register the account on the sandbox, and deploy a simple account contract which [uses a single key for privacy and authentication](../../../learn/concepts/accounts/keys.md): - -#include_code create-account yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -Once the account is set up, the CLI returns the resulting address, its privacy key, and partial address. You can read more about these [here](../../../learn/concepts/accounts/keys.md#addresses-partial-addresses-and-public-keys). - -Save the Address and Private key as environment variables. We will be using them later. - -```bash -export ADDRESS=
-export PRIVATE_KEY= -``` - -Alternatively, we can also manually generate a private key and use it for creating the account, either via a `-k` option or by setting the `PRIVATE_KEY` environment variable. - -#include_code create-account-from-private-key yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -For all commands that require a user's private key, the CLI will look for the `PRIVATE_KEY` environment variable in absence of an optional argument. - -Let's double check that the accounts have been registered with the sandbox using the `get-accounts` command: - -#include_code get-accounts yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -You will see that a number of accounts exist that we did not create. The Sandbox initializes itself with 3 default accounts. Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. - -```bash -export ADDRESS2= -``` - -## Deploying a Token Contract - -We will now deploy a token contract using the `deploy` command, and set an address of the admin via a constructor argument. You can find the contract we are deploying [here](https://github.com/AztecProtocol/aztec-packages/blob/master/noir-projects/noir-contracts/contracts/token_contract/src/main.nr) (or write it for yourself in [this tutorial!](../../tutorials/writing_token_contract.md)) -Make sure to replace this address with one of the two you created earlier. - -#include_code deploy yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -Save the contract address as an environment variable. We will use it later. - -```bash -export CONTRACT_ADDRESS= -``` - -- `--args` - Arguments to the constructor of the contract. In this case we have set an address as admin. - -The CLI tells us that the contract was successfully deployed. We can use the `check-deploy` command to verify that a contract has been successfully deployed to that address: - -#include_code check-deploy yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -## Sending a Transaction - -We can now send a transaction to the network. We will mint funds in the public domain. -To form and submit the transaction we will use the `send` command of `aztec-cli`. -The `send` command expect the function name as the first unnamed argument and the following named arguments: - -- `--args` - The list of arguments to the function call. -- `--contract-artifact` - The artifact of the contract to call. -- `--contract-address` - The deployed address of the contract to call. -- `--private-key` - The private key of the sender. - -#include_code send yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -We called the [`mint_public`](https://github.com/AztecProtocol/aztec-packages/blob/87fa621347e55f82e36c70515c1824161eee5282/noir-projects/noir-contracts/contracts/token_contract/src/main.nr#L157C10-L157C10) function and provided it with the 2 arguments it expects: the recipient's address and the amount to be minted. Make sure to replace all addresses in this command with yours. - -The command output tells us the details of the transaction such as its hash and status. We can use this hash to query the receipt of the transaction at a later time: - -#include_code get-tx-receipt yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -## Calling an Unconstrained (View) Function - -Now that the `mint_public` tx has been settled we can call the `balance_of_public` unconstrained function: - -#include_code call yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts bash - -The `call` command calls a read-only method on a contract, one that will not generate a transaction to be sent to the network. The arguments here are: - -- `--args` - The address for which we want to retrieve the balance. -- `--contract-artifact` - The artifact of the contract we are calling. -- `--contract-address` - The address of the deployed contract - -As you can see from the result, this address has a public balance of 543, as expected. diff --git a/docs/docs/developers/tutorials/writing_private_voting_contract.md b/docs/docs/developers/tutorials/writing_private_voting_contract.md index 1178600c72a..df8a8f03a05 100644 --- a/docs/docs/developers/tutorials/writing_private_voting_contract.md +++ b/docs/docs/developers/tutorials/writing_private_voting_contract.md @@ -191,7 +191,7 @@ aztec-cli call get_vote --contract-artifact ./target/private_voting-Voting.json This should return `1n`. -You can follow this pattern to test `end_vote()` and access control of other functions. Find more information about calling functions from the CLI [here](../sandbox/references/cli-commands.md). +You can follow this pattern to test `end_vote()` and access control of other functions. ## Next steps diff --git a/docs/sidebars.js b/docs/sidebars.js index 5a5e9b00006..f4725933719 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -308,7 +308,6 @@ const sidebars = { label: "References", type: "category", items: [ - "developers/sandbox/references/cli-commands", "developers/sandbox/references/sandbox-reference", "developers/sandbox/references/cheat_codes", { diff --git a/release-please-config.json b/release-please-config.json index 7cf01cd694f..6c5411dc506 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -21,10 +21,6 @@ "component": "aztec-packages", "package-name": "aztec-packages" }, - "yarn-project/cli": { - "release-type": "node", - "component": "aztec-cli" - }, "yarn-project/aztec": { "release-type": "node", "component": "aztec-package" @@ -48,7 +44,7 @@ { "type": "linked-versions", "groupName": "aztec-packages", - "components": ["barretenberg", "barretenberg.js", "aztec-packages", "aztec-package", "aztec-cli"] + "components": ["barretenberg", "barretenberg.js", "aztec-packages", "aztec-package"] }, "sentence-case" ] diff --git a/yarn-project/Dockerfile b/yarn-project/Dockerfile index 7223c9b057a..2038b05b45e 100644 --- a/yarn-project/Dockerfile +++ b/yarn-project/Dockerfile @@ -32,7 +32,7 @@ RUN ln -s /usr/src/yarn-project/node_modules /usr/src/node_modules ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true RUN ./bootstrap.sh -RUN yarn workspaces focus @aztec/cli @aztec/aztec --production && yarn cache clean +RUN yarn workspaces focus @aztec/aztec --production && yarn cache clean # TODO: Use release-please to update package.json directly, and remove this! # It's here to ensure the image rebuilds if the commit tag changes (as the content hash won't). diff --git a/yarn-project/Earthfile b/yarn-project/Earthfile index 6825755a732..0118394dc78 100644 --- a/yarn-project/Earthfile +++ b/yarn-project/Earthfile @@ -49,7 +49,7 @@ build: aztec-prod: FROM +build - RUN yarn workspaces focus @aztec/cli @aztec/aztec --production && yarn cache clean + RUN yarn workspaces focus @aztec/aztec --production && yarn cache clean SAVE ARTIFACT /usr/src /usr/src aztec-prod-slim: @@ -61,11 +61,6 @@ aztec: ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"] EXPOSE 8080 -cli: - FROM +aztec-prod-slim - ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/cli/dest/bin/index.js"] - EXPOSE 8080 - end-to-end-prod: FROM +build RUN yarn workspaces focus @aztec/end-to-end --production && yarn cache clean diff --git a/yarn-project/cli/.eslintrc.cjs b/yarn-project/cli/.eslintrc.cjs deleted file mode 100644 index e659927475c..00000000000 --- a/yarn-project/cli/.eslintrc.cjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@aztec/foundation/eslint'); diff --git a/yarn-project/cli/CHANGELOG.md b/yarn-project/cli/CHANGELOG.md deleted file mode 100644 index bdb8e7a5808..00000000000 --- a/yarn-project/cli/CHANGELOG.md +++ /dev/null @@ -1,221 +0,0 @@ -# Changelog - -## [0.35.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.35.0...aztec-cli-v0.35.1) (2024-04-16) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.35.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.34.0...aztec-cli-v0.35.0) (2024-04-16) - - -### ⚠ BREAKING CHANGES - -* pay fee for account init ([#5601](https://github.com/AztecProtocol/aztec-packages/issues/5601)) - -### Features - -* Pay fee for account init ([#5601](https://github.com/AztecProtocol/aztec-packages/issues/5601)) ([aca804f](https://github.com/AztecProtocol/aztec-packages/commit/aca804f96ca9e74b6b553449333e195c0639b151)) - -## [0.34.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.33.0...aztec-cli-v0.34.0) (2024-04-10) - - -### Miscellaneous - -* Reduce log verbosity in local e2e tests ([#5622](https://github.com/AztecProtocol/aztec-packages/issues/5622)) ([c496a10](https://github.com/AztecProtocol/aztec-packages/commit/c496a105eac3b78e53b7d42d4a64e88e3a4759a5)) - -## [0.33.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.32.1...aztec-cli-v0.33.0) (2024-04-09) - - -### ⚠ BREAKING CHANGES - -* contract_abi-exports ([#5386](https://github.com/AztecProtocol/aztec-packages/issues/5386)) - -### Features - -* **avm:** Integrate AVM with initializers ([#5469](https://github.com/AztecProtocol/aztec-packages/issues/5469)) ([59799f2](https://github.com/AztecProtocol/aztec-packages/commit/59799f273addec01eb0cdea365fe72bcbc8d9493)) -* Contract_abi-exports ([#5386](https://github.com/AztecProtocol/aztec-packages/issues/5386)) ([745d522](https://github.com/AztecProtocol/aztec-packages/commit/745d5229db86b2188f52ab7ccc8f568aef8f5797)) -* Jest fast transpile. no more ts-jest. ([#5530](https://github.com/AztecProtocol/aztec-packages/issues/5530)) ([1912802](https://github.com/AztecProtocol/aztec-packages/commit/19128024292a91d0f947f397ab1b0dc2cd7ef7aa)) - - -### Bug Fixes - -* Update CLI & terraforms with new contract addresses ([#5553](https://github.com/AztecProtocol/aztec-packages/issues/5553)) ([eb73d20](https://github.com/AztecProtocol/aztec-packages/commit/eb73d20e825f3e18acfb68a2b0b7d3501f39e52d)) - -## [0.32.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.32.0...aztec-cli-v0.32.1) (2024-04-02) - - -### Miscellaneous - -* Explicit type imports ([#5519](https://github.com/AztecProtocol/aztec-packages/issues/5519)) ([2a217de](https://github.com/AztecProtocol/aztec-packages/commit/2a217de4da2031a9f3913a657a4b39201f4483bf)) - -## [0.32.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.31.0...aztec-cli-v0.32.0) (2024-03-27) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.31.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.30.1...aztec-cli-v0.31.0) (2024-03-26) - - -### Features - -* Capture broadcasted functions in node ([#5353](https://github.com/AztecProtocol/aztec-packages/issues/5353)) ([bc05db2](https://github.com/AztecProtocol/aztec-packages/commit/bc05db26c864c9a9dae43f149814e082cdcfd7df)) - - -### Bug Fixes - -* **cli:** Support initializers not named constructor in cli ([#5397](https://github.com/AztecProtocol/aztec-packages/issues/5397)) ([85f14c5](https://github.com/AztecProtocol/aztec-packages/commit/85f14c5dc84c46910b8de498472959fa561d593c)) - -## [0.30.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.30.0...aztec-cli-v0.30.1) (2024-03-20) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.30.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.29.0...aztec-cli-v0.30.0) (2024-03-19) - - -### Features - -* Allow registering contract classes in PXE ([#5291](https://github.com/AztecProtocol/aztec-packages/issues/5291)) ([b811207](https://github.com/AztecProtocol/aztec-packages/commit/b811207bad691f519b31a6391967b9215a9e17d3)), closes [#4055](https://github.com/AztecProtocol/aztec-packages/issues/4055) - - -### Miscellaneous - -* Add gas portal to l1 contract addresses ([#5265](https://github.com/AztecProtocol/aztec-packages/issues/5265)) ([640c89a](https://github.com/AztecProtocol/aztec-packages/commit/640c89a04d7b780795d40e239be3b3db73a16923)), closes [#5022](https://github.com/AztecProtocol/aztec-packages/issues/5022) - -## [0.29.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.28.1...aztec-cli-v0.29.0) (2024-03-18) - - -### Features - -* Use deployer in address computation ([#5201](https://github.com/AztecProtocol/aztec-packages/issues/5201)) ([258ff4a](https://github.com/AztecProtocol/aztec-packages/commit/258ff4a00208be8695e2e59aecc14d6a92eaac1c)) - - -### Miscellaneous - -* Delete ContractData ([#5258](https://github.com/AztecProtocol/aztec-packages/issues/5258)) ([e516f9b](https://github.com/AztecProtocol/aztec-packages/commit/e516f9b94d1fbdc126a9d0d7d79c571d61914980)) -* Delete ExtendedContractData struct ([#5248](https://github.com/AztecProtocol/aztec-packages/issues/5248)) ([8ae0c13](https://github.com/AztecProtocol/aztec-packages/commit/8ae0c13ceaf8a1f3db09d0e61f0a3781c8926ca6)) -* Removing redundant receipts check ([#5271](https://github.com/AztecProtocol/aztec-packages/issues/5271)) ([5ab07fb](https://github.com/AztecProtocol/aztec-packages/commit/5ab07fb8b395b6edbda6167845c7ea864e9395a3)) - -## [0.28.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.28.0...aztec-cli-v0.28.1) (2024-03-14) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.28.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.27.2...aztec-cli-v0.28.0) (2024-03-14) - - -### ⚠ BREAKING CHANGES - -* Support contracts with no constructor ([#5175](https://github.com/AztecProtocol/aztec-packages/issues/5175)) - -### Features - -* Support contracts with no constructor ([#5175](https://github.com/AztecProtocol/aztec-packages/issues/5175)) ([df7fa32](https://github.com/AztecProtocol/aztec-packages/commit/df7fa32f34e790231e091c38a4a6e84be5407763)) - -## [0.27.2](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.27.1...aztec-cli-v0.27.2) (2024-03-13) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.27.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.27.0...aztec-cli-v0.27.1) (2024-03-12) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.27.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.6...aztec-cli-v0.27.0) (2024-03-12) - - -### Miscellaneous - -* Remove old contract deployment flow ([#4970](https://github.com/AztecProtocol/aztec-packages/issues/4970)) ([6d15947](https://github.com/AztecProtocol/aztec-packages/commit/6d1594736e96cd744ea691a239fcd3a46bdade60)) - -## [0.26.6](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.5...aztec-cli-v0.26.6) (2024-03-08) - - -### Features - -* Show bytecode size per function in CLI inspect-contract ([#5059](https://github.com/AztecProtocol/aztec-packages/issues/5059)) ([cb9fdc6](https://github.com/AztecProtocol/aztec-packages/commit/cb9fdc6b5069ee2ab8fb1f68f369e360039fa18b)) - -## [0.26.5](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.4...aztec-cli-v0.26.5) (2024-03-07) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.26.4](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.3...aztec-cli-v0.26.4) (2024-03-06) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.26.3](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.2...aztec-cli-v0.26.3) (2024-03-06) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.26.2](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.1...aztec-cli-v0.26.2) (2024-03-06) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.26.1](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.26.0...aztec-cli-v0.26.1) (2024-03-06) - - -### Miscellaneous - -* **aztec-cli:** Synchronize aztec-packages versions - -## [0.26.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-cli-v0.25.0...aztec-cli-v0.26.0) (2024-03-05) - - -### ⚠ BREAKING CHANGES - -* Use new deployment flow in ContractDeployer ([#4497](https://github.com/AztecProtocol/aztec-packages/issues/4497)) -* move noir out of yarn-project ([#4479](https://github.com/AztecProtocol/aztec-packages/issues/4479)) -* note type ids ([#4500](https://github.com/AztecProtocol/aztec-packages/issues/4500)) -* Include contract class id in deployment info ([#4223](https://github.com/AztecProtocol/aztec-packages/issues/4223)) -* aztec binary ([#3927](https://github.com/AztecProtocol/aztec-packages/issues/3927)) - -### Features - -* **avm-transpiler:** Brillig to AVM transpiler ([#4227](https://github.com/AztecProtocol/aztec-packages/issues/4227)) ([c366c6e](https://github.com/AztecProtocol/aztec-packages/commit/c366c6e6d5c9f28a5dc92a303dcab4a23fb2d84e)) -* Aztec binary ([#3927](https://github.com/AztecProtocol/aztec-packages/issues/3927)) ([12356d9](https://github.com/AztecProtocol/aztec-packages/commit/12356d9e34994a239d5612798c1bc82fa3d26562)) -* Aztec.js API for registering a contract class ([#4469](https://github.com/AztecProtocol/aztec-packages/issues/4469)) ([d566c74](https://github.com/AztecProtocol/aztec-packages/commit/d566c74786a1ea960e9beee4599c1fdedc7ae6eb)) -* Include contract class id in deployment info ([#4223](https://github.com/AztecProtocol/aztec-packages/issues/4223)) ([0ed4126](https://github.com/AztecProtocol/aztec-packages/commit/0ed41261ae43e21f695c35ad753e07adfaaa55f9)), closes [#4054](https://github.com/AztecProtocol/aztec-packages/issues/4054) -* Moving the unbox option to npx command ([#4718](https://github.com/AztecProtocol/aztec-packages/issues/4718)) ([4c3bb92](https://github.com/AztecProtocol/aztec-packages/commit/4c3bb9294fc10ff4663275c952e277eaa7ecd647)) -* Note type ids ([#4500](https://github.com/AztecProtocol/aztec-packages/issues/4500)) ([e1da2fd](https://github.com/AztecProtocol/aztec-packages/commit/e1da2fd509c75d7886b95655d233165e087cf2ed)) -* Parallel native/wasm bb builds. Better messaging around using ci cache. ([#4766](https://github.com/AztecProtocol/aztec-packages/issues/4766)) ([a924e55](https://github.com/AztecProtocol/aztec-packages/commit/a924e55393daa89fbba3a87cf019977286104b59)) -* Use new deployment flow in ContractDeployer ([#4497](https://github.com/AztecProtocol/aztec-packages/issues/4497)) ([0702dc6](https://github.com/AztecProtocol/aztec-packages/commit/0702dc6988149258124184b85d38db930effe0e7)) - - -### Bug Fixes - -* Add new oracle contract to devnet in CI ([#4687](https://github.com/AztecProtocol/aztec-packages/issues/4687)) ([920fa10](https://github.com/AztecProtocol/aztec-packages/commit/920fa10d4d5fb476cd6d868439310452f6e8dcc5)) -* Load contract artifact from json ([#4352](https://github.com/AztecProtocol/aztec-packages/issues/4352)) ([47a0a79](https://github.com/AztecProtocol/aztec-packages/commit/47a0a79f6beaa241eafc94fcae84103488a9dcef)) - - -### Miscellaneous - -* **docs:** Fix a few links to docs ([#4260](https://github.com/AztecProtocol/aztec-packages/issues/4260)) ([1c8ea49](https://github.com/AztecProtocol/aztec-packages/commit/1c8ea497fb1d64da64cb240917a60d57bd1efef8)) -* Move noir out of yarn-project ([#4479](https://github.com/AztecProtocol/aztec-packages/issues/4479)) ([1fe674b](https://github.com/AztecProtocol/aztec-packages/commit/1fe674b046c694e1cbbbb2edaf5a855828bb5340)), closes [#4107](https://github.com/AztecProtocol/aztec-packages/issues/4107) -* Remove stubbed docs ([#4196](https://github.com/AztecProtocol/aztec-packages/issues/4196)) ([25a4bc4](https://github.com/AztecProtocol/aztec-packages/commit/25a4bc490a53304110e7e1f79e99f4c8b7639164)) -* Squash yp ypb + other build improvements. ([#4901](https://github.com/AztecProtocol/aztec-packages/issues/4901)) ([be5855c](https://github.com/AztecProtocol/aztec-packages/commit/be5855cdbd1993155bd228afbeafee2c447b46a5)) -* Updating viem ([#4783](https://github.com/AztecProtocol/aztec-packages/issues/4783)) ([23bc26a](https://github.com/AztecProtocol/aztec-packages/commit/23bc26a4859d9777c3e6dd49e351a4e6b13a989a)) diff --git a/yarn-project/cli/Dockerfile b/yarn-project/cli/Dockerfile deleted file mode 100644 index c69606b278c..00000000000 --- a/yarn-project/cli/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM aztecprotocol/yarn-project AS yarn-project -ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/cli/dest/bin/index.js"] - -# The version has been updated in yarn-project. -# Adding COMMIT_TAG here to rebuild versioned image. -ARG COMMIT_TAG="" - -RUN mkdir /cache && chmod 777 /cache -ENV XDG_CACHE_HOME /cache -VOLUME "/cache" diff --git a/yarn-project/cli/README.md b/yarn-project/cli/README.md deleted file mode 100644 index 56bf674e842..00000000000 --- a/yarn-project/cli/README.md +++ /dev/null @@ -1,450 +0,0 @@ -# Aztec CLI Documentation - -The Aztec CLI `aztec-cli` is a command-line interface (CLI) tool for interacting with Aztec. It provides various commands for deploying contracts, creating accounts, interacting with contracts, and retrieving blockchain data. - -## Installation - -1. In your terminal, download the sandbox by running - -``` -bash -i <(curl -s install.aztec.network) -``` - -2. Verify the installation: After the installation is complete, run the following command to verify that `aztec-cli` is installed correctly: - - ```shell - aztec-cli --version - ``` - - This command will display the version number of `aztec-cli` if the installation was successful. - -## Usage - -To use `aztec-cli`, open a terminal or command prompt and run the `aztec-cli` command followed by the desired command and its options. - -Here's the basic syntax for running a command: - -```shell -aztec-cli [options] -``` - -Replace `` with the actual command you want to execute and `[options]` with any optional flags or parameters required by the command. - -### Environment Variables - -Some options can be set globally as environment variables to avoid having to re-enter them every time you call `aztec-cli.` -These options are: - -- `PRIVATE_KEY` -> `-k, --private-key` for all commands that require a private key. -- `PUBLIC_KEY` -> `-k, --public-key` for all commands that require a public key. -- `PXE_URL` -> `-u, --rpc-url` for commands that require a PXE -- `API_KEY` -> `a, --api-key` for `deploy-l1-contracts`. -- `ETHEREUM_RPC_HOST` -> `-u, --rpc-url` for `deploy-l1-contracts`. - -So if for example you are running your Private eXecution Environment (PXE) remotely you can do: - -```shell -export PXE_URL=http://external.site/rpc:8080 -aztec-cli deploy my_contract.json -``` - -And this will send the request to `http://external.site/rpc:8080`. - -**NOTE**: Entering an option value will override the environment variable. - -## Available Commands - -`aztec-cli` provides the following commands for interacting with Aztec: - -### deploy-l1-contracts - -Deploys all necessary Ethereum contracts for Aztec. - -Syntax: - -```shell -aztec-cli deploy-l1-contracts [rpcUrl] [options] -``` - -- `rpcUrl` (optional): URL of the Ethereum host. Chain identifiers `localhost` and `testnet` can be used. Default: `http://localhost:8545`. - -Options: - -- `-a, --api-key `: API key for the Ethereum host. -- `-p, --private-key `: The private key to use for deployment. -- `-m, --mnemonic `: The mnemonic to use in deployment. Default: `test test test test test test test test test test test junk`. - -This command deploys all the necessary Ethereum contracts required for Aztec. It creates the rollup contract, registry contract, inbox contract, outbox contract, and contract deployment emitter. The command displays the addresses of the deployed contracts. - -Example usage: - -```shell -aztec-cli deploy-l1-contracts -``` - -### create-private-key - -Generates a 32-byte private key. - -Syntax: - -```shell -aztec-cli create-private-key [options] -``` - -Options: - -- `-m, --mnemonic`: A mnemonic string that can be used for the private key generation. - -This command generates a random 32-byte private key or derives one from the provided mnemonic string. It displays the generated private key. - -Example usage: - -```shell -aztec-cli create-private-key -``` - -### create-account - -Creates an Aztec account that can be used for transactions. - -Syntax: - -```shell -aztec-cli create-account [options] -``` - -Options: - -- `-k, --private-key`: Private key to use for the account generation. Uses a random key by default. -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command creates an Aztec account that can be used for transactions. It generates a new account with a private key or uses the provided private key. The command displays the account's address and public key. - -Example usage: - -```shell -aztec-cli create-account -``` - -### deploy - -Deploys a compiled Aztec.nr contract to Aztec. - -Syntax: - -```shell -aztec-cli deploy [options] -``` - -Options: - -- `-c, --contract-artifact `: Path to the compiled Aztec.nr contract's artifact file in JSON format. You can also use one of Aztec's example contracts found in [@aztec/noir-contracts](https://www.npmjs.com/package/@aztec/noir-contracts), e.g. PrivateTokenContractArtifact. You can get a full ist of the available contracts with `aztec-cli example-contracts` -- `-a, --args ` (optional): Contract constructor arguments Default: []. -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. -- `-k, --public-key `: Public key of the deployer. If not provided, it will check the RPC for existing ones. - -This command deploys a compiled Aztec.nr contract to Aztec. It requires the path to the contract's artifact file in JSON format. Optionally, you can specify the public key of the deployer and provide constructor arguments for the contract. The command displays the address of the deployed contract. - -Example usage: - -```shell -aztec-cli deploy -c path/to/contract.artifact.json -a ...args -``` - -With an Aztec example contract: - -```shell -aztec-cli deploy -c PrivateTokenContractArtifact -a 333 0x134567890abcdef -``` - -### check-deploy - -Checks if a contract is deployed to the specified Aztec address. - -Syntax: - -```shell -aztec-cli check-deploy [options] -``` - -Options: - -- `-ca, --contract-address
`: An Aztec address to check if the contract has been deployed to. -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command checks if a contract is deployed to the specified Aztec address. It verifies if the contract is present at the given address and displays the result. - -Example usage: - -```shell -aztec-cli check-deploy -ca 0x123456789abcdef123456789abcdef12345678 -``` - -### get-tx-receipt - -Gets the receipt for the specified transaction hash. - -Syntax: - -```shell -aztec-cli get-tx-receipt [options] -``` - -- `txHash`: A transaction hash to get the receipt for. - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command retrieves and displays the receipt for the specified transaction hash. It shows details such as the transaction status, block number, and block hash. - -Example usage: - -```shell -aztec-cli get-tx-receipt 0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef12345678 -``` - -### get-contract-data - -Gets information about the Aztec contract deployed at the specified address. - -Syntax: - -```shell -aztec-cli get-contract-data [options] -``` - -- `contractAddress`: Aztec address of the contract. - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. -- `-b, --include-bytecode`: Include the contract's public function bytecode, if any. - -This command retrieves and displays information about the Aztec contract deployed at the specified address. It shows the contract address, portal contract address, and optionally, the bytecode of the contract's public functions. - -Example usage: - -```shell -aztec-cli get-contract-data 0x123456789abcdef123456789abcdef12345678 -``` - -### register-recipient - -Register a recipient account on the PXE (called recipient because we can only send notes to this account and not receive them via this PXE). -To read about how keys are generated and used, head to our docs [here](https://github.com/AztecProtocol/aztec-packages/blob/master/docs/docs/aztec/developer/wallet-providers/keys.md#addresses-partial-addresses-and-public-keys). - -Syntax: - -```shell -aztec-cli register-recipient [options] -``` - -Options: - -- `-a, --address `: The account's Aztec address. -- `-p, --public-key `: 'The account public key.' -- `-pa, --partial-address `: URL of PXE Service. Default: `http://localhost:8080`. - -Example usage: - -```shell -aztec-cli register-recipient -p 0x20d9d93c4a9eb2b4bdb70ead07d28d1edb74bfd78443a8c36b098b024cd26f0e0647f5dbe3619453f42eb788c2beed0294c84676425047aadac23294605c4af9 -a 0x111fdc0f6bf831ca59f05863199762d643b782699d7ce6feaae40a923baf60af -pa 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed -``` - -### get-accounts - -Gets all the Aztec accounts stored in a PXE. - -Syntax: - -```shell -aztec-cli get-accounts [options] -``` - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command retrieves and displays all the Aztec accounts available in the system. - -Example usage: - -```shell -aztec-cli get-accounts -``` - -### get-account - -Gets an account given its Aztec address. - -Syntax: - -```shell -aztec-cli get-account
[options] -``` - -- `address`: The Aztec address to get the public key for. - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command retrieves and displays the public key of an account given its Aztec address. - -Example usage: - -```shell -aztec-cli get-account 0x123456789abcdef123456789abcdef12345678 -``` - -### send - -Sends a transaction invoking a function on an Aztec contract. - -Syntax: - -```shell -aztec-cli send --args [functionArgs...] --contract-artifact --contract-address --private-key -``` - -- `functionName`: Name of the function to call. - -Options: - -- `'-a, --args [functionArgs...]` (optional): Function arguments. Default: []. -- `-c, --contract-artifact `: The compiled contract's artifact in JSON format. You can also use one of Aztec's example contracts found in (@aztec/noir-contracts)[https://www.npmjs.com/package/@aztec/noir-contracts], e.g. PrivateTokenContractArtifact. -- `-ca, --contract-address
`: Address of the contract. -- `-k, --private-key `: The sender's private key. -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command calls a function on an Aztec contract. It requires the contract's artifact, address, function name, and optionally, function arguments. The command executes the function call and displays the transaction details. - -Example usage: - -```shell -aztec-cli send transfer -ca 0x123456789abcdef123456789abcdef12345678 -a 100 -c path/to/artifact.json -``` - -### call - -Calls a view (read-only) function on a deployed contract. -Unlike transactions, view calls do not modify the state of the contract. - -Syntax: - -```shell -aztec-cli call -a [functionArgs...] -c -ca -f -``` - -- `functionName`: Name of the function to view. - -Options: - -- `'-a, --args [functionArgs...]` (optional): Function arguments. Default: []. -- `-c, --contract-artifact `: The compiled contract's artifact in JSON format. You can also use one of Aztec's example contracts found in (@aztec/noir-contracts)[https://www.npmjs.com/package/@aztec/noir-contracts], e.g. PrivateTokenContractArtifact. -- `-ca, --contract-address
`: Address of the contract. -- `-f, --from `: Address of the caller. If empty, first account in the Private eXecution Environment (PXE) will be used. -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command simulates the execution of a view function on a deployed contract without modifying the state. It requires the contract's artifact, address, function name, and optionally, function arguments. The command displays the result of the view function. - -Example usage: - -```shell -aztec-cli call balanceOf -c path/to/contract.artifact.json -ca 0x123456789abcdef123456789abcdef12345678 -a balanceOf 0xabcdef1234567890abcdef1234567890abcdef12 -``` - -### parse-parameter-struct - -Helper for parsing an encoded string into a contract's parameter struct. - -Syntax: - -```shell -aztec-cli parse-parameter-struct -``` - -- `encodedString`: The encoded hex string. -- `contractArtifact`: The compiled contract's artifact in JSON format. -- `parameterName`: The name of the struct parameter to decode into. - -This command is a helper for parsing an encoded hex string into a contract's parameter struct. It requires the encoded string, the contract's artifact, and the name of the struct parameter. The command decodes the string and displays the struct data. - -Example usage: - -```shell -aztec-cli parse-parameter-struct 0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 path/to/contract.artifact.json paramName -``` - -### get-logs - -Applies filter and returns the resulting unencrypted logs. -The filter is applied by doing an intersection of all its params. - -Syntax: - -```shell -aztec-cli get-logs --fromBlock -``` - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command retrieves and displays all the unencrypted logs from L2 blocks in the specified range or from a specific transaction. -Example usage: - -```shell -aztec-cli get-logs --txHash 21fef567e01f8508e30843ebcef9c5f6ff27b29d66783cfcdbd070c3a9174234 -aztec-cli get-logs --fromBlock 4 --toBlock 5 --contractAddress 0x1db5f68861c5960c37205d3d5b23466240359c115c49e45982865ea7ace69a02 -aztec-cli get-logs --fromBlock 4 --toBlock 5 --contractAddress 0x1db5f68861c5960c37205d3d5b23466240359c115c49e45982865ea7ace69a02 --selector 00000005 -``` - -Run `aztec-cli get-logs --help` for more information on the filtering options. - -### block-number - -Gets the current Aztec L2 block number. - -Syntax: - -```shell -aztec-cli block-number -``` - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -This command retrieves and displays the current Aztec L2 block number. - -### example-contracts - -Lists the contracts available in [@aztec/noir-contracts](https://github.com/AztecProtocol/aztec-packages/tree/master/noir-contracts) - -Syntax: - -```shell -aztec-cli example-contracts -``` - -### get-node-info - -Gets information of an Aztec node at the specified URL. - -Syntax: - -```shell -aztec-cli get-node-info -``` - -Options: - -- `-u, --rpc-url `: URL of PXE Service. Default: `http://localhost:8080`. - -## Conclusion - -That covers the available commands and their usage in the `aztec-cli`. You can now use these commands to interact with Aztec and perform various actions such as deploying contracts, creating accounts, executing functions, and retrieving blockchain data. diff --git a/yarn-project/cli/aztec-cli-dest b/yarn-project/cli/aztec-cli-dest deleted file mode 100755 index d2fc2aa3694..00000000000 --- a/yarn-project/cli/aztec-cli-dest +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -SCRIPT_PATH=$(dirname $(realpath $0)) -node --no-warnings $SCRIPT_PATH/dest/bin/index.js $@ diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json deleted file mode 100644 index e1a887fb1cb..00000000000 --- a/yarn-project/cli/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@aztec/cli", - "version": "0.35.1", - "type": "module", - "main": "./dest/index.js", - "bin": { - "aztec-cli": "./dest/bin/index.js" - }, - "typedocOptions": { - "entryPoints": [ - "./src/index.ts" - ], - "name": "Aztec CLI", - "tsconfig": "./tsconfig.json" - }, - "scripts": { - "build": "yarn clean && tsc -b", - "build:dev": "tsc -b --watch", - "clean": "rm -rf ./dest .tsbuildinfo", - "formatting": "run -T prettier --check ./src && run -T eslint ./src", - "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests", - "start": "node --no-warnings ./dest/bin/index.js" - }, - "inherits": [ - "../package.common.json" - ], - "jest": { - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.[cm]?js$": "$1" - }, - "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$", - "rootDir": "./src", - "transform": { - "^.+\\.tsx?$": [ - "@swc/jest" - ] - }, - "extensionsToTreatAsEsm": [ - ".ts" - ] - }, - "dependencies": { - "@aztec/accounts": "workspace:^", - "@aztec/aztec.js": "workspace:^", - "@aztec/circuit-types": "workspace:^", - "@aztec/circuits.js": "workspace:^", - "@aztec/ethereum": "workspace:^", - "@aztec/foundation": "workspace:^", - "@aztec/l1-artifacts": "workspace:^", - "@aztec/noir-compiler": "workspace:^", - "@aztec/noir-contracts.js": "workspace:^", - "@aztec/types": "workspace:^", - "@iarna/toml": "^2.2.5", - "@libp2p/peer-id-factory": "^3.0.4", - "commander": "^9.0.0", - "jszip": "^3.10.1", - "lodash.startcase": "^4.4.0", - "node-fetch": "^3.3.2", - "semver": "^7.5.4", - "source-map-support": "^0.5.21", - "tslib": "^2.4.0", - "viem": "^2.7.15" - }, - "devDependencies": { - "@jest/globals": "^29.5.0", - "@types/jest": "^29.5.0", - "@types/lodash.startcase": "^4.4.7", - "@types/node": "^18.7.23", - "@types/semver": "^7.5.2", - "@types/source-map-support": "^0.5.10", - "jest": "^29.5.0", - "jest-mock-extended": "^3.0.5", - "ts-node": "^10.9.1", - "typescript": "^5.0.4" - }, - "files": [ - "dest", - "src", - "!*.test.*" - ], - "types": "./dest/index.d.ts", - "engines": { - "node": ">=18" - } -} diff --git a/yarn-project/cli/src/bin/index.ts b/yarn-project/cli/src/bin/index.ts deleted file mode 100644 index 0d79e796d50..00000000000 --- a/yarn-project/cli/src/bin/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env -S node --no-warnings -import { createConsoleLogger, createDebugLogger } from '@aztec/foundation/log'; - -import 'source-map-support/register.js'; - -import { getProgram } from '../index.js'; - -const debugLogger = createDebugLogger('aztec:cli-client'); -const log = createConsoleLogger(); - -/** CLI main entrypoint */ -async function main() { - process.once('SIGINT', () => process.exit(0)); - process.once('SIGTERM', () => process.exit(0)); - - const program = getProgram(log, debugLogger); - await program.parseAsync(process.argv); -} - -main().catch(err => { - log(`Error in command execution`); - log(err); - process.exit(1); -}); diff --git a/yarn-project/cli/src/client.test.ts b/yarn-project/cli/src/client.test.ts deleted file mode 100644 index ad21f399256..00000000000 --- a/yarn-project/cli/src/client.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { type NodeInfo } from '@aztec/aztec.js'; -import { type PXE } from '@aztec/circuit-types'; - -import { type MockProxy, mock } from 'jest-mock-extended'; - -import { checkServerVersion } from './client.js'; - -describe('client', () => { - describe('checkServerVersion', () => { - let pxe: MockProxy; - - beforeEach(() => { - pxe = mock(); - }); - - it('checks versions match', async () => { - pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha47' } as NodeInfo); - await checkServerVersion(pxe, '0.1.0-alpha47'); - }); - - it('reports mismatch on older pxe version', async () => { - pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha47' } as NodeInfo); - await expect(checkServerVersion(pxe, '0.1.0-alpha48')).rejects.toThrow(/is older than the expected by this CLI/); - }); - - it('reports mismatch on newer pxe version', async () => { - pxe.getNodeInfo.mockResolvedValue({ nodeVersion: '0.1.0-alpha48' } as NodeInfo); - await expect(checkServerVersion(pxe, '0.1.0-alpha47')).rejects.toThrow(/is newer than the expected by this CLI/); - }); - }); -}); diff --git a/yarn-project/cli/src/client.ts b/yarn-project/cli/src/client.ts deleted file mode 100644 index 8b3d55c37d9..00000000000 --- a/yarn-project/cli/src/client.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { type PXE, createPXEClient } from '@aztec/aztec.js'; -import { type DebugLogger } from '@aztec/foundation/log'; -import { fileURLToPath } from '@aztec/foundation/url'; - -import { readFileSync } from 'fs'; -import { dirname, resolve } from 'path'; -import { gtr, ltr, satisfies, valid } from 'semver'; - -/** - * Creates a PXE client with a given set of retries on non-server errors. - * Checks that PXE matches the expected version, and warns if not. - * @param rpcUrl - URL of the RPC server wrapping the PXE. - * @param logger - Debug logger to warn version incompatibilities. - * @returns A PXE client. - */ -export async function createCompatibleClient(rpcUrl: string, logger: DebugLogger) { - const pxe = createPXEClient(rpcUrl); - const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'); - const packageJsonContents = JSON.parse(readFileSync(packageJsonPath).toString()); - const expectedVersionRange = packageJsonContents.version; - - try { - await checkServerVersion(pxe, expectedVersionRange); - } catch (err) { - if (err instanceof VersionMismatchError) { - logger.warn(err.message); - } else { - throw err; - } - } - - return pxe; -} - -/** Mismatch between server and client versions. */ -class VersionMismatchError extends Error {} - -/** - * Checks that Private eXecution Environment (PXE) version matches the expected one by this CLI. Throws if not. - * @param pxe - PXE client. - * @param expectedVersionRange - Expected version by CLI. - */ -export async function checkServerVersion(pxe: PXE, expectedVersionRange: string) { - const serverName = 'Aztec Node'; - const { nodeVersion } = await pxe.getNodeInfo(); - if (!nodeVersion) { - throw new VersionMismatchError(`Couldn't determine ${serverName} version. You may run into issues.`); - } - if (!nodeVersion || !valid(nodeVersion)) { - throw new VersionMismatchError( - `Missing or invalid version identifier for ${serverName} (${nodeVersion ?? 'empty'}).`, - ); - } else if (!satisfies(nodeVersion, expectedVersionRange)) { - if (gtr(nodeVersion, expectedVersionRange)) { - throw new VersionMismatchError( - `${serverName} is running version ${nodeVersion} which is newer than the expected by this CLI (${expectedVersionRange}). Consider upgrading your CLI to a newer version.`, - ); - } else if (ltr(nodeVersion, expectedVersionRange)) { - throw new VersionMismatchError( - `${serverName} is running version ${nodeVersion} which is older than the expected by this CLI (${expectedVersionRange}). Consider upgrading your ${serverName} to a newer version.`, - ); - } else { - throw new VersionMismatchError( - `${serverName} is running version ${nodeVersion} which does not match the expected by this CLI (${expectedVersionRange}).`, - ); - } - } -} diff --git a/yarn-project/cli/src/cmds/add_contract.ts b/yarn-project/cli/src/cmds/add_contract.ts deleted file mode 100644 index 2c29aedf3f8..00000000000 --- a/yarn-project/cli/src/cmds/add_contract.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { - AztecAddress, - type ContractInstanceWithAddress, - EthAddress, - Fr, - getContractClassFromArtifact, -} from '@aztec/aztec.js'; -import { computeContractAddressFromInstance } from '@aztec/circuits.js/contract'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; -import { getContractArtifact } from '../utils.js'; - -export async function addContract( - rpcUrl: string, - contractArtifactPath: string, - address: AztecAddress, - initializationHash: Fr, - salt: Fr, - publicKeysHash: Fr | undefined, - portalContract: EthAddress | undefined, - deployer: AztecAddress | undefined, - debugLogger: DebugLogger, - log: LogFn, -) { - const artifact = await getContractArtifact(contractArtifactPath); - const instance: ContractInstanceWithAddress = { - version: 1, - salt, - initializationHash, - contractClassId: getContractClassFromArtifact(artifact).id, - portalContractAddress: portalContract ?? EthAddress.ZERO, - publicKeysHash: publicKeysHash ?? Fr.ZERO, // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5862) - address, - deployer: deployer ?? AztecAddress.ZERO, - }; - const computed = computeContractAddressFromInstance(instance); - if (!computed.equals(address)) { - throw new Error(`Contract address ${address.toString()} does not match computed address ${computed.toString()}`); - } - - const client = await createCompatibleClient(rpcUrl, debugLogger); - - await client.registerContract({ artifact, instance }); - log(`\nContract added to PXE at ${address.toString()} with class ${instance.contractClassId.toString()}\n`); -} diff --git a/yarn-project/cli/src/cmds/add_note.ts b/yarn-project/cli/src/cmds/add_note.ts deleted file mode 100644 index f6359bd5c1c..00000000000 --- a/yarn-project/cli/src/cmds/add_note.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { type AztecAddress, type Fr } from '@aztec/aztec.js'; -import { ExtendedNote, Note, type TxHash } from '@aztec/circuit-types'; -import { type DebugLogger } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; -import { parseFields } from '../parse_args.js'; - -export async function addNote( - address: AztecAddress, - contractAddress: AztecAddress, - storageSlot: Fr, - noteTypeId: Fr, - txHash: TxHash, - noteFields: string[], - rpcUrl: string, - debugLogger: DebugLogger, -) { - const note = new Note(parseFields(noteFields)); - const extendedNote = new ExtendedNote(note, address, contractAddress, storageSlot, noteTypeId, txHash); - const client = await createCompatibleClient(rpcUrl, debugLogger); - await client.addNote(extendedNote); -} diff --git a/yarn-project/cli/src/cmds/block_number.ts b/yarn-project/cli/src/cmds/block_number.ts deleted file mode 100644 index 5b6ca472d6b..00000000000 --- a/yarn-project/cli/src/cmds/block_number.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function blockNumber(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const num = await client.getBlockNumber(); - log(`${num}\n`); -} diff --git a/yarn-project/cli/src/cmds/call.ts b/yarn-project/cli/src/cmds/call.ts deleted file mode 100644 index 3efffe1668c..00000000000 --- a/yarn-project/cli/src/cmds/call.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { type AztecAddress } from '@aztec/aztec.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { format } from 'util'; - -import { createCompatibleClient } from '../client.js'; -import { getFunctionArtifact, getTxSender, prepTx } from '../utils.js'; - -export async function call( - functionName: string, - functionArgsIn: any[], - contractArtifactPath: string, - contractAddress: AztecAddress, - fromAddress: string | undefined, - rpcUrl: string, - debugLogger: DebugLogger, - log: LogFn, -) { - const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn); - - const fnArtifact = getFunctionArtifact(contractArtifact, functionName); - if (fnArtifact.parameters.length !== functionArgs.length) { - throw Error( - `Invalid number of args passed. Expected ${fnArtifact.parameters.length}; Received: ${functionArgs.length}`, - ); - } - - const client = await createCompatibleClient(rpcUrl, debugLogger); - const from = await getTxSender(client, fromAddress); - const result = await client.viewTx(functionName, functionArgs, contractAddress, from); - log(format('\nView result: ', result, '\n')); -} diff --git a/yarn-project/cli/src/cmds/check_deploy.ts b/yarn-project/cli/src/cmds/check_deploy.ts deleted file mode 100644 index 4a00c72a518..00000000000 --- a/yarn-project/cli/src/cmds/check_deploy.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { type AztecAddress } from '@aztec/aztec.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function checkDeploy(rpcUrl: string, contractAddress: AztecAddress, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const isPrivatelyDeployed = await client.getContractInstance(contractAddress); - const isPubliclyDeployed = await client.isContractPubliclyDeployed(contractAddress); - if (isPubliclyDeployed && isPrivatelyDeployed) { - log(`\nContract is publicly deployed at ${contractAddress.toString()}\n`); - } else if (isPrivatelyDeployed) { - log(`\nContract is registered in the local pxe at ${contractAddress.toString()} but not publicly deployed\n`); - } else if (isPubliclyDeployed) { - log(`\nContract is publicly deployed at ${contractAddress.toString()} but not registered in the local pxe\n`); - } else { - log(`\nNo contract found at ${contractAddress.toString()}\n`); - } -} diff --git a/yarn-project/cli/src/cmds/compute_selector.ts b/yarn-project/cli/src/cmds/compute_selector.ts deleted file mode 100644 index 9d299a64eff..00000000000 --- a/yarn-project/cli/src/cmds/compute_selector.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { FunctionSelector } from '@aztec/foundation/abi'; -import { type LogFn } from '@aztec/foundation/log'; - -export function computeSelector(functionSignature: string, log: LogFn) { - const selector = FunctionSelector.fromSignature(functionSignature); - log(`${selector}`); -} diff --git a/yarn-project/cli/src/cmds/create_account.ts b/yarn-project/cli/src/cmds/create_account.ts deleted file mode 100644 index f0dc92fdf37..00000000000 --- a/yarn-project/cli/src/cmds/create_account.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { getSchnorrAccount } from '@aztec/accounts/schnorr'; -import { deriveKeys } from '@aztec/circuits.js'; -import { Fr } from '@aztec/foundation/fields'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function createAccount( - rpcUrl: string, - secretKey: Fr, - wait: boolean, - debugLogger: DebugLogger, - log: LogFn, -) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const actualSecretKey = secretKey ?? Fr.random(); - - const signingKey = deriveKeys(actualSecretKey).masterIncomingViewingSecretKey; - const account = getSchnorrAccount(client, actualSecretKey, signingKey, Fr.ZERO); - const { address, publicKey, partialAddress } = account.getCompleteAddress(); - const tx = account.deploy(); - const txHash = await tx.getTxHash(); - debugLogger.verbose(`Account contract tx sent with hash ${txHash}`); - if (wait) { - log(`\nWaiting for account contract deployment...`); - await tx.wait(); - } else { - log(`\nAccount deployment transaction hash: ${txHash}\n`); - } - - log(`\nNew account:\n`); - log(`Address: ${address.toString()}`); - log(`Public key: ${publicKey.toString()}`); - if (!secretKey) { - log(`Secret key: ${actualSecretKey.toString()}`); - } - log(`Partial address: ${partialAddress.toString()}`); -} diff --git a/yarn-project/cli/src/cmds/deploy.ts b/yarn-project/cli/src/cmds/deploy.ts deleted file mode 100644 index 91b64afaf34..00000000000 --- a/yarn-project/cli/src/cmds/deploy.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { getSchnorrAccount } from '@aztec/accounts/schnorr'; -import { ContractDeployer, type EthAddress, Fr } from '@aztec/aztec.js'; -import { deriveKeys } from '@aztec/circuits.js'; -import { getInitializer } from '@aztec/foundation/abi'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; -import { encodeArgs } from '../encoding.js'; -import { GITHUB_TAG_PREFIX } from '../github.js'; -import { getContractArtifact } from '../utils.js'; - -export async function deploy( - artifactPath: string, - json: boolean, - rpcUrl: string, - rawArgs: any[], - portalAddress: EthAddress, - salt: Fr, - secretKey: Fr, - initializer: string | undefined, - wait: boolean, - debugLogger: DebugLogger, - log: LogFn, - logJson: (output: any) => void, -) { - const contractArtifact = await getContractArtifact(artifactPath); - const constructorArtifact = getInitializer(contractArtifact, initializer); - - const client = await createCompatibleClient(rpcUrl, debugLogger); - const nodeInfo = await client.getNodeInfo(); - const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.nodeVersion}`; - if (contractArtifact.aztecNrVersion && contractArtifact.aztecNrVersion !== expectedAztecNrVersion) { - log( - `\nWarning: Contract was compiled with a different version of Aztec.nr: ${contractArtifact.aztecNrVersion}. Consider updating Aztec.nr to ${expectedAztecNrVersion}\n`, - ); - } - - const keys = deriveKeys(secretKey); - const wallet = await getSchnorrAccount(client, secretKey, keys.masterIncomingViewingSecretKey, Fr.ZERO).getWallet(); - const deployer = new ContractDeployer(contractArtifact, wallet, keys.publicKeysHash, initializer); - - let args = []; - if (rawArgs.length > 0) { - if (!constructorArtifact) { - throw new Error(`Cannot process constructor arguments as no constructor was found`); - } - debugLogger.verbose(`Input arguments: ${rawArgs.map((x: any) => `"${x}"`).join(', ')}`); - args = encodeArgs(rawArgs, constructorArtifact!.parameters); - debugLogger.verbose(`Encoded arguments: ${args.join(', ')}`); - } - - const deploy = deployer.deploy(...args); - - await deploy.create({ contractAddressSalt: salt, portalContract: portalAddress }); - const tx = deploy.send({ contractAddressSalt: salt, portalContract: portalAddress }); - const txHash = await tx.getTxHash(); - debugLogger.verbose(`Deploy tx sent with hash ${txHash}`); - if (wait) { - const deployed = await tx.wait(); - const { address, partialAddress } = deployed.contract; - if (json) { - logJson({ address: address.toString(), partialAddress: partialAddress.toString() }); - } else { - log(`\nContract deployed at ${address.toString()}\n`); - log(`Contract partial address ${partialAddress.toString()}\n`); - } - } else { - const { address, partialAddress } = deploy; - if (json) { - logJson({ - address: address?.toString() ?? 'N/A', - partialAddress: partialAddress?.toString() ?? 'N/A', - txHash: txHash.toString(), - }); - } else { - log(`\nContract Address: ${address?.toString() ?? 'N/A'}`); - log(`Contract Partial Address: ${partialAddress?.toString() ?? 'N/A'}`); - log(`Deployment transaction hash: ${txHash}\n`); - } - } -} diff --git a/yarn-project/cli/src/cmds/deploy_l1_contracts.ts b/yarn-project/cli/src/cmds/deploy_l1_contracts.ts deleted file mode 100644 index 49c6f5decb6..00000000000 --- a/yarn-project/cli/src/cmds/deploy_l1_contracts.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { deployAztecContracts } from '../utils.js'; - -export async function deployL1Contracts( - rpcUrl: string, - apiKey: string, - privateKey: string, - mnemonic: string, - log: LogFn, - debugLogger: DebugLogger, -) { - const { l1ContractAddresses } = await deployAztecContracts(rpcUrl, apiKey, privateKey, mnemonic, debugLogger); - - log('\n'); - log(`Rollup Address: ${l1ContractAddresses.rollupAddress.toString()}`); - log(`Registry Address: ${l1ContractAddresses.registryAddress.toString()}`); - log(`L1 -> L2 Inbox Address: ${l1ContractAddresses.inboxAddress.toString()}`); - log(`L2 -> L1 Outbox address: ${l1ContractAddresses.outboxAddress.toString()}`); - log(`Availability Oracle Address: ${l1ContractAddresses.availabilityOracleAddress.toString()}`); - log(`Gas Token Address: ${l1ContractAddresses.gasTokenAddress.toString()}`); - log(`Gas Portal Address: ${l1ContractAddresses.gasPortalAddress.toString()}`); - log('\n'); -} diff --git a/yarn-project/cli/src/cmds/example_contracts.ts b/yarn-project/cli/src/cmds/example_contracts.ts deleted file mode 100644 index f79be05b25a..00000000000 --- a/yarn-project/cli/src/cmds/example_contracts.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { type LogFn } from '@aztec/foundation/log'; - -import { getExampleContractArtifacts } from '../utils.js'; - -export async function exampleContracts(log: LogFn) { - const abisList = await getExampleContractArtifacts(); - const names = Object.keys(abisList).filter(name => !name.startsWith('Avm')); - names.forEach(name => log(name)); -} diff --git a/yarn-project/cli/src/cmds/generate_p2p_private_key.ts b/yarn-project/cli/src/cmds/generate_p2p_private_key.ts deleted file mode 100644 index f62617ae6ea..00000000000 --- a/yarn-project/cli/src/cmds/generate_p2p_private_key.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { type LogFn } from '@aztec/foundation/log'; - -import { createSecp256k1PeerId } from '@libp2p/peer-id-factory'; - -export async function generateP2PPrivateKey(log: LogFn) { - const peerId = await createSecp256k1PeerId(); - const exportedPeerId = Buffer.from(peerId.privateKey!).toString('hex'); - log(`Private key: ${exportedPeerId}`); - log(`Peer Id: ${peerId}`); -} diff --git a/yarn-project/cli/src/cmds/generate_private_key.ts b/yarn-project/cli/src/cmds/generate_private_key.ts deleted file mode 100644 index f7504de90de..00000000000 --- a/yarn-project/cli/src/cmds/generate_private_key.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { GrumpkinScalar, generatePublicKey } from '@aztec/aztec.js'; -import { type LogFn } from '@aztec/foundation/log'; - -import { mnemonicToAccount } from 'viem/accounts'; - -export function generatePrivateKey(mnemonic: string | undefined, log: LogFn) { - let privKey; - let publicKey; - if (mnemonic) { - const acc = mnemonicToAccount(mnemonic); - // TODO(#2052): This reduction is not secure enough. TACKLE THIS ISSUE BEFORE MAINNET. - const key = GrumpkinScalar.fromBufferReduce(Buffer.from(acc.getHdKey().privateKey!)); - publicKey = generatePublicKey(key); - } else { - const key = GrumpkinScalar.random(); - privKey = key.toString(); - publicKey = generatePublicKey(key); - } - log(`\nPrivate Key: ${privKey}\nPublic Key: ${publicKey.toString()}\n`); -} diff --git a/yarn-project/cli/src/cmds/get_account.ts b/yarn-project/cli/src/cmds/get_account.ts deleted file mode 100644 index c672c85fb85..00000000000 --- a/yarn-project/cli/src/cmds/get_account.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { type AztecAddress } from '@aztec/aztec.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getAccount(aztecAddress: AztecAddress, rpcUrl: string, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const account = await client.getRegisteredAccount(aztecAddress); - - if (!account) { - log(`Unknown account ${aztecAddress.toString()}`); - } else { - log(account.toReadableString()); - } -} diff --git a/yarn-project/cli/src/cmds/get_accounts.ts b/yarn-project/cli/src/cmds/get_accounts.ts deleted file mode 100644 index 9d84cc581ed..00000000000 --- a/yarn-project/cli/src/cmds/get_accounts.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getAccounts( - rpcUrl: string, - json: boolean, - debugLogger: DebugLogger, - log: LogFn, - logJson: (output: any) => void, -) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const accounts = await client.getRegisteredAccounts(); - if (!accounts.length) { - if (json) { - logJson([]); - } else { - log('No accounts found.'); - } - return; - } - if (json) { - logJson( - accounts.map(a => ({ - address: a.address.toString(), - publicKey: a.publicKey.toString(), - partialAddress: a.partialAddress.toString(), - })), - ); - } else { - log(`Accounts found: \n`); - for (const account of accounts) { - log(account.toReadableString()); - } - } -} diff --git a/yarn-project/cli/src/cmds/get_contract_data.ts b/yarn-project/cli/src/cmds/get_contract_data.ts deleted file mode 100644 index 592358a9fd3..00000000000 --- a/yarn-project/cli/src/cmds/get_contract_data.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { type AztecAddress } from '@aztec/aztec.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getContractData( - rpcUrl: string, - contractAddress: AztecAddress, - includeBytecode: boolean, - debugLogger: DebugLogger, - log: LogFn, -) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const instance = await client.getContractInstance(contractAddress); - const contractClass = includeBytecode && instance && (await client.getContractClass(instance?.contractClassId)); - - if (!instance) { - log(`No contract found at ${contractAddress}`); - return; - } - - log(`\nContract Data:`); - Object.entries(instance).forEach(([key, value]) => { - const capitalized = key.charAt(0).toUpperCase() + key.slice(1); - log(`${capitalized}: ${value.toString()}`); - }); - - if (contractClass) { - log(`Bytecode: ${contractClass.packedBytecode.toString('base64')}`); - } - log('\n'); -} diff --git a/yarn-project/cli/src/cmds/get_logs.ts b/yarn-project/cli/src/cmds/get_logs.ts deleted file mode 100644 index 29afb7bbc6f..00000000000 --- a/yarn-project/cli/src/cmds/get_logs.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { type AztecAddress, type LogFilter, type LogId, type TxHash } from '@aztec/aztec.js'; -import { type EventSelector } from '@aztec/foundation/abi'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; -import { sleep } from '@aztec/foundation/sleep'; - -import { createCompatibleClient } from '../client.js'; - -export async function getLogs( - txHash: TxHash, - fromBlock: number, - toBlock: number, - afterLog: LogId, - contractAddress: AztecAddress, - selector: EventSelector, - rpcUrl: string, - follow: boolean, - debugLogger: DebugLogger, - log: LogFn, -) { - const pxe = await createCompatibleClient(rpcUrl, debugLogger); - - if (follow) { - if (txHash) { - throw Error('Cannot use --follow with --tx-hash'); - } - if (toBlock) { - throw Error('Cannot use --follow with --to-block'); - } - } - - const filter: LogFilter = { txHash, fromBlock, toBlock, afterLog, contractAddress, selector }; - - const fetchLogs = async () => { - const response = await pxe.getUnencryptedLogs(filter); - const logs = response.logs; - - if (!logs.length) { - const filterOptions = Object.entries(filter) - .filter(([, value]) => value !== undefined) - .map(([key, value]) => `${key}: ${value}`) - .join(', '); - if (!follow) { - log(`No logs found for filter: {${filterOptions}}`); - } - } else { - if (!follow && !filter.afterLog) { - log('Logs found: \n'); - } - logs.forEach(unencryptedLog => log(unencryptedLog.toHumanReadable())); - // Set the continuation parameter for the following requests - filter.afterLog = logs[logs.length - 1].id; - } - return response.maxLogsHit; - }; - - if (follow) { - log('Fetching logs...'); - while (true) { - const maxLogsHit = await fetchLogs(); - if (!maxLogsHit) { - await sleep(1000); - } - } - } else { - while (await fetchLogs()) { - // Keep fetching logs until we reach the end. - } - } -} diff --git a/yarn-project/cli/src/cmds/get_node_info.ts b/yarn-project/cli/src/cmds/get_node_info.ts deleted file mode 100644 index b66df822532..00000000000 --- a/yarn-project/cli/src/cmds/get_node_info.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getNodeInfo(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const info = await client.getNodeInfo(); - log(`\nNode Info:\n`); - log(`Node Version: ${info.nodeVersion}\n`); - log(`Chain Id: ${info.chainId}\n`); - log(`Protocol Version: ${info.protocolVersion}\n`); - log(`Rollup Address: ${info.l1ContractAddresses.rollupAddress.toString()}`); -} diff --git a/yarn-project/cli/src/cmds/get_recipient.ts b/yarn-project/cli/src/cmds/get_recipient.ts deleted file mode 100644 index 4ae6baac896..00000000000 --- a/yarn-project/cli/src/cmds/get_recipient.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { type AztecAddress } from '@aztec/aztec.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getRecipient(aztecAddress: AztecAddress, rpcUrl: string, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const recipient = await client.getRecipient(aztecAddress); - - if (!recipient) { - log(`Unknown recipient ${aztecAddress.toString()}`); - } else { - log(recipient.toReadableString()); - } -} diff --git a/yarn-project/cli/src/cmds/get_recipients.ts b/yarn-project/cli/src/cmds/get_recipients.ts deleted file mode 100644 index bc091bc5dd6..00000000000 --- a/yarn-project/cli/src/cmds/get_recipients.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getRecipients(rpcUrl: string, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const recipients = await client.getRecipients(); - if (!recipients.length) { - log('No recipients found.'); - } else { - log(`Recipients found: \n`); - for (const recipient of recipients) { - log(recipient.toReadableString()); - } - } -} diff --git a/yarn-project/cli/src/cmds/get_tx_receipt.ts b/yarn-project/cli/src/cmds/get_tx_receipt.ts deleted file mode 100644 index 6119f035aac..00000000000 --- a/yarn-project/cli/src/cmds/get_tx_receipt.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { type TxHash } from '@aztec/aztec.js'; -import { JsonStringify } from '@aztec/foundation/json-rpc'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function getTxReceipt(rpcUrl: string, txHash: TxHash, debugLogger: DebugLogger, log: LogFn) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - const receipt = await client.getTxReceipt(txHash); - if (!receipt) { - log(`No receipt found for transaction hash ${txHash.toString()}`); - } else { - log(`\nTransaction receipt: \n${JsonStringify(receipt, true)}\n`); - } -} diff --git a/yarn-project/cli/src/cmds/inspect_contract.ts b/yarn-project/cli/src/cmds/inspect_contract.ts deleted file mode 100644 index 0156c1e8c77..00000000000 --- a/yarn-project/cli/src/cmds/inspect_contract.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { getContractClassFromArtifact } from '@aztec/circuits.js'; -import { - type FunctionArtifact, - FunctionSelector, - decodeFunctionSignature, - decodeFunctionSignatureWithParameterNames, -} from '@aztec/foundation/abi'; -import { sha256 } from '@aztec/foundation/crypto'; -import { type LogFn } from '@aztec/foundation/log'; - -import { getContractArtifact } from '../utils.js'; - -export async function inspectContract(contractArtifactFile: string, log: LogFn) { - const contractArtifact = await getContractArtifact(contractArtifactFile); - const contractFns = contractArtifact.functions.filter(f => f.name !== 'compute_note_hash_and_nullifier'); - if (contractFns.length === 0) { - log(`No functions found for contract ${contractArtifact.name}`); - } - const contractClass = getContractClassFromArtifact(contractArtifact); - const bytecodeLengthInFields = 1 + Math.ceil(contractClass.packedBytecode.length / 31); - - log(`Contract class details:`); - log(`\tidentifier: ${contractClass.id.toString()}`); - log(`\tartifact hash: ${contractClass.artifactHash.toString()}`); - log(`\tprivate function tree root: ${contractClass.privateFunctionsRoot.toString()}`); - log(`\tpublic bytecode commitment: ${contractClass.publicBytecodeCommitment.toString()}`); - log(`\tpublic bytecode length: ${contractClass.packedBytecode.length} bytes (${bytecodeLengthInFields} fields)`); - log(`\nExternal functions:`); - contractFns.filter(f => !f.isInternal).forEach(f => logFunction(f, log)); - log(`\nInternal functions:`); - contractFns.filter(f => f.isInternal).forEach(f => logFunction(f, log)); -} - -function logFunction(fn: FunctionArtifact, log: LogFn) { - const signatureWithParameterNames = decodeFunctionSignatureWithParameterNames(fn.name, fn.parameters); - const signature = decodeFunctionSignature(fn.name, fn.parameters); - const selector = FunctionSelector.fromSignature(signature); - const bytecodeSize = fn.bytecode.length; - const bytecodeHash = sha256(fn.bytecode).toString('hex'); - log( - `${fn.functionType} ${signatureWithParameterNames} \n\tfunction signature: ${signature}\n\tselector: ${selector}\n\tbytecode: ${bytecodeSize} bytes (sha256 ${bytecodeHash})`, - ); -} diff --git a/yarn-project/cli/src/cmds/parse_parameter_struct.ts b/yarn-project/cli/src/cmds/parse_parameter_struct.ts deleted file mode 100644 index e319b8fe8e0..00000000000 --- a/yarn-project/cli/src/cmds/parse_parameter_struct.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { type StructType } from '@aztec/foundation/abi'; -import { JsonStringify } from '@aztec/foundation/json-rpc'; -import { type LogFn } from '@aztec/foundation/log'; - -import { parseStructString } from '../encoding.js'; -import { getContractArtifact } from '../utils.js'; - -export async function parseParameterStruct( - encodedString: string, - contractArtifactPath: string, - parameterName: string, - log: LogFn, -) { - const contractArtifact = await getContractArtifact(contractArtifactPath); - const parameterAbitype = contractArtifact.functions - .map(({ parameters }) => parameters) - .flat() - .find(({ name, type }) => name === parameterName && type.kind === 'struct'); - - if (!parameterAbitype) { - log(`No struct parameter found with name ${parameterName}`); - return; - } - - const data = parseStructString(encodedString, parameterAbitype.type as StructType); - log(`\nStruct Data: \n${JsonStringify(data, true)}\n`); -} diff --git a/yarn-project/cli/src/cmds/register_account.ts b/yarn-project/cli/src/cmds/register_account.ts deleted file mode 100644 index 868bd04721d..00000000000 --- a/yarn-project/cli/src/cmds/register_account.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { type Fr } from '@aztec/foundation/fields'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function registerAccount( - rpcUrl: string, - secretKey: Fr, - partialAddress: Fr, - debugLogger: DebugLogger, - log: LogFn, -) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - - const { address, publicKey } = await client.registerAccount(secretKey, partialAddress); - - log(`\nRegistered account:\n`); - log(`Address: ${address.toString()}`); - log(`Public key: ${publicKey.toString()}`); - log(`Partial address: ${partialAddress.toString()}`); -} diff --git a/yarn-project/cli/src/cmds/register_recipient.ts b/yarn-project/cli/src/cmds/register_recipient.ts deleted file mode 100644 index 7e9cf877f04..00000000000 --- a/yarn-project/cli/src/cmds/register_recipient.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { type AztecAddress, type Fr, type Point } from '@aztec/aztec.js'; -import { CompleteAddress } from '@aztec/circuit-types'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; - -export async function registerRecipient( - aztecAddress: AztecAddress, - publicKey: Point, - partialAddress: Fr, - rpcUrl: string, - debugLogger: DebugLogger, - log: LogFn, -) { - const client = await createCompatibleClient(rpcUrl, debugLogger); - await client.registerRecipient(CompleteAddress.create(aztecAddress, publicKey, partialAddress)); - log(`\nRegistered details for account with address: ${aztecAddress}\n`); -} diff --git a/yarn-project/cli/src/cmds/send.ts b/yarn-project/cli/src/cmds/send.ts deleted file mode 100644 index be3c4eea600..00000000000 --- a/yarn-project/cli/src/cmds/send.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { getSchnorrAccount } from '@aztec/accounts/schnorr'; -import { type AztecAddress, Contract, Fr } from '@aztec/aztec.js'; -import { deriveKeys } from '@aztec/circuits.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; - -import { createCompatibleClient } from '../client.js'; -import { prepTx } from '../utils.js'; - -export async function send( - functionName: string, - functionArgsIn: any[], - contractArtifactPath: string, - contractAddress: AztecAddress, - secretKey: Fr, - rpcUrl: string, - wait: boolean, - debugLogger: DebugLogger, - log: LogFn, -) { - const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn); - - const client = await createCompatibleClient(rpcUrl, debugLogger); - const signingKey = deriveKeys(secretKey).masterIncomingViewingSecretKey; - const wallet = await getSchnorrAccount(client, secretKey, signingKey, Fr.ZERO).getWallet(); - const contract = await Contract.at(contractAddress, contractArtifact, wallet); - const tx = contract.methods[functionName](...functionArgs).send(); - log(`\nTransaction hash: ${(await tx.getTxHash()).toString()}`); - if (wait) { - await tx.wait(); - - log('Transaction has been mined'); - - const receipt = await tx.getReceipt(); - log(`Status: ${receipt.status}\n`); - log(`Block number: ${receipt.blockNumber}`); - log(`Block hash: ${receipt.blockHash?.toString('hex')}`); - } else { - log('Transaction pending. Check status with get-tx-receipt'); - } -} diff --git a/yarn-project/cli/src/encoding.ts b/yarn-project/cli/src/encoding.ts deleted file mode 100644 index e10f843814d..00000000000 --- a/yarn-project/cli/src/encoding.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { type ABIParameter, type AbiType, type StructType } from '@aztec/foundation/abi'; -import { Fr } from '@aztec/foundation/fields'; - -/** - * Parses a hex string into an ABI struct type. - * @param str - The encoded hex string. - * @param abiType - The ABI Struct type. - * @returns An object in the ABI struct type's format. - */ -export function parseStructString(str: string, abiType: StructType) { - // Assign string bytes to struct fields. - const buf = Buffer.from(str.replace(/^0x/i, ''), 'hex'); - const struct: any = {}; - let byteIndex = 0; - let argIndex = 0; - while (byteIndex < buf.length) { - const { name } = abiType.fields[argIndex]; - struct[name] = Fr.fromBuffer(buf.subarray(byteIndex, byteIndex + 32)); - byteIndex += 32; - argIndex += 1; - } - - return struct; -} - -/** - * Helper function to encode CLI string args to an appropriate JS type. - * @param arg - The CLI argument. - * @param abiType - The type as described by the contract's ABI. - * @returns The encoded argument. - */ -function encodeArg(arg: string, abiType: AbiType, name: string): any { - const { kind } = abiType; - if (kind === 'field' || kind === 'integer') { - let res: bigint; - try { - res = BigInt(arg); - } catch (err) { - throw new Error( - `Invalid value passed for ${name}. Could not parse ${arg} as a${kind === 'integer' ? 'n' : ''} ${kind}.`, - ); - } - return res; - } else if (kind === 'boolean') { - if (arg === 'true') { - return true; - } - if (arg === 'false') { - return false; - } else { - throw Error(`Invalid boolean value passed for ${name}: ${arg}.`); - } - } else if (kind === 'string') { - return arg; - } else if (kind === 'array') { - let arr; - const res = []; - try { - arr = JSON.parse(arg); - } catch { - throw new Error(`Unable to parse arg ${arg} as array for ${name} parameter`); - } - if (!Array.isArray(arr)) { - throw Error(`Invalid argument ${arg} passed for array parameter ${name}.`); - } - if (arr.length !== abiType.length) { - throw Error(`Invalid array length passed for ${name}. Expected ${abiType.length}, received ${arr.length}.`); - } - for (let i = 0; i < abiType.length; i += 1) { - res.push(encodeArg(arr[i], abiType.type, name)); - } - return res; - } else if (kind === 'struct') { - // check if input is encoded long string - if (arg.startsWith('0x')) { - return parseStructString(arg, abiType); - } - let obj; - try { - obj = JSON.parse(arg); - } catch { - throw new Error(`Unable to parse arg ${arg} as struct`); - } - if (Array.isArray(obj)) { - throw Error(`Array passed for arg ${name}. Expected a struct.`); - } - const res: any = {}; - for (const field of abiType.fields) { - // Remove field name from list as it's present - const arg = obj[field.name]; - if (!arg) { - throw Error(`Expected field ${field.name} not found in struct ${name}.`); - } - res[field.name] = encodeArg(obj[field.name], field.type, field.name); - } - return res; - } -} - -/** - * Tries to encode function args to their equivalent TS type. - * @param args - An array of function's / constructor's args. - * @returns The encoded array. - */ -export function encodeArgs(args: any[], params: ABIParameter[]) { - if (args.length !== params.length) { - throw new Error( - `Invalid args provided.\nExpected args: [${params - .map(param => param.name + ': ' + param.type.kind) - .join(', ')}]\nReceived args: ${args.join(', ')}`, - ); - } - return args.map((arg: any, index) => { - const { type, name } = params[index]; - return encodeArg(arg, type, name); - }); -} diff --git a/yarn-project/cli/src/github.ts b/yarn-project/cli/src/github.ts deleted file mode 100644 index 0486c382369..00000000000 --- a/yarn-project/cli/src/github.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const GITHUB_OWNER = 'AztecProtocol'; -export const GITHUB_REPO = 'aztec-packages'; -export const GITHUB_TAG_PREFIX = 'aztec-packages'; diff --git a/yarn-project/cli/src/index.ts b/yarn-project/cli/src/index.ts deleted file mode 100644 index fc9daa45fbf..00000000000 --- a/yarn-project/cli/src/index.ts +++ /dev/null @@ -1,502 +0,0 @@ -import { Fr } from '@aztec/circuits.js'; -import { type DebugLogger, type LogFn } from '@aztec/foundation/log'; -import { fileURLToPath } from '@aztec/foundation/url'; -import { addCodegenCommanderAction } from '@aztec/noir-compiler/cli'; - -import { Command, Option } from 'commander'; -import { lookup } from 'dns/promises'; -import { readFileSync } from 'fs'; -import { dirname, resolve } from 'path'; - -import { - parseAztecAddress, - parseEthereumAddress, - parseField, - parseFieldFromHexString, - parseOptionalAztecAddress, - parseOptionalInteger, - parseOptionalLogId, - parseOptionalSelector, - parseOptionalTxHash, - parsePartialAddress, - parsePrivateKey, - parsePublicKey, - parseTxHash, -} from './parse_args.js'; - -/** - * If we can successfully resolve 'host.docker.internal', then we are running in a container, and we should treat - * localhost as being host.docker.internal. - */ -const getLocalhost = () => - lookup('host.docker.internal') - .then(() => 'host.docker.internal') - .catch(() => 'localhost'); - -const LOCALHOST = await getLocalhost(); -const { ETHEREUM_HOST = `http://${LOCALHOST}:8545`, PRIVATE_KEY, API_KEY, CLI_VERSION } = process.env; - -/** - * Returns commander program that defines the CLI. - * @param log - Console logger. - * @param debugLogger - Debug logger. - * @returns The CLI. - */ -export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { - const program = new Command(); - - const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'); - const cliVersion: string = CLI_VERSION || JSON.parse(readFileSync(packageJsonPath).toString()).version; - const logJson = (obj: object) => log(JSON.stringify(obj, null, 2)); - - program.name('aztec-cli').description('CLI for interacting with Aztec.').version(cliVersion); - - const pxeOption = new Option('-u, --rpc-url ', 'URL of the PXE') - .env('PXE_URL') - .default(`http://${LOCALHOST}:8080`) - .makeOptionMandatory(true); - - const createPrivateKeyOption = (description: string, mandatory: boolean) => - new Option('-k, --private-key ', description) - .env('PRIVATE_KEY') - .argParser(parsePrivateKey) - .makeOptionMandatory(mandatory); - - program - .command('deploy-l1-contracts') - .description('Deploys all necessary Ethereum contracts for Aztec.') - .requiredOption( - '-u, --rpc-url ', - 'Url of the ethereum host. Chain identifiers localhost and testnet can be used', - ETHEREUM_HOST, - ) - .option('-a, --api-key ', 'Api key for the ethereum host', API_KEY) - .requiredOption('-p, --private-key ', 'The private key to use for deployment', PRIVATE_KEY) - .option( - '-m, --mnemonic ', - 'The mnemonic to use in deployment', - 'test test test test test test test test test test test junk', - ) - .action(async options => { - const { deployL1Contracts } = await import('./cmds/deploy_l1_contracts.js'); - await deployL1Contracts( - options.rpcUrl, - options.apiKey ?? '', - options.privateKey, - options.mnemonic, - log, - debugLogger, - ); - }); - - program - .command('generate-private-key') - .summary('Generates an encryption private key.') - .description( - 'Generates a private key which fits into the scalar field used by Grumpkin curve, can be used as an encryption private key.', - ) - .option( - '-m, --mnemonic', - 'An optional mnemonic string used for the private key generation. If not provided, random private key will be generated.', - ) - .action(async options => { - const { generatePrivateKey } = await import('./cmds/generate_private_key.js'); - generatePrivateKey(options.mnemonic, log); - }); - - program - .command('generate-p2p-private-key') - .summary('Generates a LibP2P peer private key.') - .description('Generates a private key that can be used for running a node on a LibP2P network.') - .action(async () => { - const { generateP2PPrivateKey } = await import('./cmds/generate_p2p_private_key.js'); - await generateP2PPrivateKey(log); - }); - - program - .command('create-account') - .description( - 'Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).', - ) - .summary('Creates an aztec account that can be used for sending transactions.') - .addOption( - createPrivateKeyOption('Private key for note encryption and transaction signing. Uses random by default.', false), - ) - .addOption(pxeOption) - // `options.wait` is default true. Passing `--no-wait` will set it to false. - // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue - .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction') - .action(async ({ rpcUrl, privateKey, wait }) => { - const { createAccount } = await import('./cmds/create_account.js'); - await createAccount(rpcUrl, privateKey, wait, debugLogger, log); - }); - - program - .command('register-account') - .description( - 'Registers an aztec account that can be used for sending transactions. Registers the account on the PXE. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).', - ) - .summary('Registers an aztec account that can be used for sending transactions.') - .addOption(createPrivateKeyOption('Private key for note encryption and transaction signing.', true)) - .requiredOption( - '-pa, --partial-address ', - 'The partially computed address of the account contract.', - parsePartialAddress, - ) - .addOption(pxeOption) - .action(async ({ rpcUrl, privateKey, partialAddress }) => { - const { registerAccount } = await import('./cmds/register_account.js'); - await registerAccount(rpcUrl, privateKey, partialAddress, debugLogger, log); - }); - - program - .command('deploy') - .description('Deploys a compiled Aztec.nr contract to Aztec.') - .argument( - '', - "A compiled Aztec.nr contract's artifact in JSON format or name of a contract artifact exported by @aztec/noir-contracts.js", - ) - .option('--initializer ', 'The contract initializer function to call') - .option('-a, --args ', 'Contract constructor arguments', []) - .addOption(pxeOption) - .option( - '-p, --portal-address ', - 'Optional L1 portal address to link the contract to.', - parseEthereumAddress, - ) - .option( - '-s, --salt ', - 'Optional deployment salt as a hex string for generating the deployment address.', - parseFieldFromHexString, - ) - .addOption(createPrivateKeyOption("The sender's private key.", true)) - .option('--json', 'Emit output as json') - // `options.wait` is default true. Passing `--no-wait` will set it to false. - // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue - .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction') - .action( - async (artifactPath, { json, rpcUrl, args: rawArgs, portalAddress, salt, wait, privateKey, initializer }) => { - // TODO(#5726): everywhere here in CLI we consume private key instead of secret key --> we should accept - // secret key everywhere and derive the rest. Also unlike before the keys change the public key is now always - // derived and set for the contract. We should allow setting zero public key again. Remove the hack on the next - // line. - const secretKey = Fr.fromBufferReduce(privateKey.toBuffer()); - const { deploy } = await import('./cmds/deploy.js'); - await deploy( - artifactPath, - json, - rpcUrl, - rawArgs, - portalAddress, - salt, - secretKey, - initializer, - wait, - debugLogger, - log, - logJson, - ); - }, - ); - - program - .command('check-deploy') - .description('Checks if a contract is deployed to the specified Aztec address.') - .requiredOption( - '-ca, --contract-address
', - 'An Aztec address to check if contract has been deployed to.', - parseAztecAddress, - ) - .addOption(pxeOption) - .action(async options => { - const { checkDeploy } = await import('./cmds/check_deploy.js'); - await checkDeploy(options.rpcUrl, options.contractAddress, debugLogger, log); - }); - - program - .command('add-contract') - .description( - 'Adds an existing contract to the PXE. This is useful if you have deployed a contract outside of the PXE and want to use it with the PXE.', - ) - .requiredOption( - '-c, --contract-artifact ', - "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts.js", - ) - .requiredOption('-ca, --contract-address
', 'Aztec address of the contract.', parseAztecAddress) - .requiredOption('--init-hash ', 'Initialization hash', parseFieldFromHexString) - .option('--salt ', 'Optional deployment salt', parseFieldFromHexString) - .option('-p, --public-key ', 'Optional public key for this contract', parsePublicKey) - .option('--portal-address
', 'Optional address to a portal contract on L1', parseEthereumAddress) - .option('--deployer-address
', 'Optional address of the contract deployer', parseAztecAddress) - .addOption(pxeOption) - .action(async options => { - const { addContract } = await import('./cmds/add_contract.js'); - await addContract( - options.rpcUrl, - options.contractArtifact, - options.contractAddress, - options.initHash, - options.salt ?? Fr.ZERO, - options.publicKey, - options.portalContract, - options.deployerAddress, - debugLogger, - log, - ); - }); - - program - .command('get-tx-receipt') - .description('Gets the receipt for the specified transaction hash.') - .argument('', 'A transaction hash to get the receipt for.', parseTxHash) - .addOption(pxeOption) - .action(async (txHash, options) => { - const { getTxReceipt } = await import('./cmds/get_tx_receipt.js'); - await getTxReceipt(options.rpcUrl, txHash, debugLogger, log); - }); - - program - .command('get-contract-data') - .description('Gets information about the Aztec contract deployed at the specified address.') - .argument('', 'Aztec address of the contract.', parseAztecAddress) - .addOption(pxeOption) - .option('-b, --include-bytecode ', "Include the contract's public function bytecode, if any.", false) - .action(async (contractAddress, options) => { - const { getContractData } = await import('./cmds/get_contract_data.js'); - await getContractData(options.rpcUrl, contractAddress, options.includeBytecode, debugLogger, log); - }); - - program - .command('get-logs') - .description('Gets all the unencrypted logs from an intersection of all the filter params.') - .option('-tx, --tx-hash ', 'A transaction hash to get the receipt for.', parseOptionalTxHash) - .option( - '-fb, --from-block ', - 'Initial block number for getting logs (defaults to 1).', - parseOptionalInteger, - ) - .option('-tb, --to-block ', 'Up to which block to fetch logs (defaults to latest).', parseOptionalInteger) - .option('-al --after-log ', 'ID of a log after which to fetch the logs.', parseOptionalLogId) - .option('-ca, --contract-address
', 'Contract address to filter logs by.', parseOptionalAztecAddress) - .option('-s, --selector ', 'Event selector to filter logs by.', parseOptionalSelector) - .addOption(pxeOption) - .option('--follow', 'If set, will keep polling for new logs until interrupted.') - .action(async ({ txHash, fromBlock, toBlock, afterLog, contractAddress, selector, rpcUrl, follow }) => { - const { getLogs } = await import('./cmds/get_logs.js'); - await getLogs(txHash, fromBlock, toBlock, afterLog, contractAddress, selector, rpcUrl, follow, debugLogger, log); - }); - - program - .command('register-recipient') - .description('Register a recipient in the PXE.') - .requiredOption('-a, --address ', "The account's Aztec address.", parseAztecAddress) - .requiredOption('-p, --public-key ', 'The account public key.', parsePublicKey) - .requiredOption( - '-pa, --partial-address ', - 'The partially computed address of the account contract.', - parsePartialAddress, - ) - .addOption(pxeOption) - .action(async ({ address, publicKey, partialAddress, rpcUrl }) => { - const { registerRecipient } = await import('./cmds/register_recipient.js'); - await registerRecipient(address, publicKey, partialAddress, rpcUrl, debugLogger, log); - }); - - program - .command('get-accounts') - .description('Gets all the Aztec accounts stored in the PXE.') - .addOption(pxeOption) - .option('--json', 'Emit output as json') - .action(async (options: any) => { - const { getAccounts } = await import('./cmds/get_accounts.js'); - await getAccounts(options.rpcUrl, options.json, debugLogger, log, logJson); - }); - - program - .command('get-account') - .description('Gets an account given its Aztec address.') - .argument('
', 'The Aztec address to get account for', parseAztecAddress) - .addOption(pxeOption) - .action(async (address, options) => { - const { getAccount } = await import('./cmds/get_account.js'); - await getAccount(address, options.rpcUrl, debugLogger, log); - }); - - program - .command('get-recipients') - .description('Gets all the recipients stored in the PXE.') - .addOption(pxeOption) - .action(async (options: any) => { - const { getRecipients } = await import('./cmds/get_recipients.js'); - await getRecipients(options.rpcUrl, debugLogger, log); - }); - - program - .command('get-recipient') - .description('Gets a recipient given its Aztec address.') - .argument('
', 'The Aztec address to get recipient for', parseAztecAddress) - .addOption(pxeOption) - .action(async (address, options) => { - const { getRecipient } = await import('./cmds/get_recipient.js'); - await getRecipient(address, options.rpcUrl, debugLogger, log); - }); - - program - .command('send') - .description('Calls a function on an Aztec contract.') - .argument('', 'Name of function to execute') - .option('-a, --args [functionArgs...]', 'Function arguments', []) - .requiredOption( - '-c, --contract-artifact ', - "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts.js", - ) - .requiredOption('-ca, --contract-address
', 'Aztec address of the contract.', parseAztecAddress) - .addOption(createPrivateKeyOption("The sender's private key.", true)) - .addOption(pxeOption) - .option('--no-wait', 'Print transaction hash without waiting for it to be mined') - .action(async (functionName, options) => { - const { send } = await import('./cmds/send.js'); - await send( - functionName, - options.args, - options.contractArtifact, - options.contractAddress, - options.privateKey, - options.rpcUrl, - !options.noWait, - debugLogger, - log, - ); - }); - - program - .command('call') - .description( - 'Simulates the execution of a view (read-only) function on a deployed contract, without modifying state.', - ) - .argument('', 'Name of function to call') - .option('-a, --args [functionArgs...]', 'Function arguments', []) - .requiredOption( - '-c, --contract-artifact ', - "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts.js", - ) - .requiredOption('-ca, --contract-address
', 'Aztec address of the contract.', parseAztecAddress) - .option('-f, --from ', 'Aztec address of the caller. If empty, will use the first account from RPC.') - .addOption(pxeOption) - .action(async (functionName, options) => { - const { call } = await import('./cmds/call.js'); - await call( - functionName, - options.args, - options.contractArtifact, - options.contractAddress, - options.from, - options.rpcUrl, - debugLogger, - log, - ); - }); - - program - .command('add-note') - .description('Adds a note to the database in the PXE.') - .argument('
', 'The Aztec address of the note owner.', parseAztecAddress) - .argument('', 'Aztec address of the contract.', parseAztecAddress) - .argument('', 'The storage slot of the note.', parseField) - .argument('', 'The type ID of the note.', parseField) - .argument('', 'The tx hash of the tx containing the note.', parseTxHash) - .requiredOption('-n, --note [note...]', 'The members of a Note serialized as hex strings.', []) - .addOption(pxeOption) - .action(async (address, contractAddress, storageSlot, noteTypeId, txHash, options) => { - const { addNote } = await import('./cmds/add_note.js'); - await addNote( - address, - contractAddress, - storageSlot, - noteTypeId, - txHash, - options.note, - options.rpcUrl, - debugLogger, - ); - }); - - // Helper for users to decode hex strings into structs if needed. - program - .command('parse-parameter-struct') - .description("Helper for parsing an encoded string into a contract's parameter struct.") - .argument('', 'The encoded hex string') - .requiredOption( - '-c, --contract-artifact ', - "A compiled Aztec.nr contract's ABI in JSON format or name of a contract ABI exported by @aztec/noir-contracts.js", - ) - .requiredOption('-p, --parameter ', 'The name of the struct parameter to decode into') - .action(async (encodedString, options) => { - const { parseParameterStruct } = await import('./cmds/parse_parameter_struct.js'); - await parseParameterStruct(encodedString, options.contractArtifact, options.parameter, log); - }); - - program - .command('block-number') - .description('Gets the current Aztec L2 block number.') - .addOption(pxeOption) - .action(async (options: any) => { - const { blockNumber } = await import('./cmds/block_number.js'); - await blockNumber(options.rpcUrl, debugLogger, log); - }); - - program - .command('example-contracts') - .description('Lists the example contracts available to deploy from @aztec/noir-contracts.js') - .action(async () => { - const { exampleContracts } = await import('./cmds/example_contracts.js'); - await exampleContracts(log); - }); - - program - .command('get-node-info') - .description('Gets the information of an aztec node at a URL.') - .addOption(pxeOption) - .action(async options => { - const { getNodeInfo } = await import('./cmds/get_node_info.js'); - await getNodeInfo(options.rpcUrl, debugLogger, log); - }); - - program - .command('inspect-contract') - .description('Shows list of external callable functions for a contract') - .argument( - '', - `A compiled Noir contract's artifact in JSON format or name of a contract artifact exported by @aztec/noir-contracts.js`, - ) - .action(async (contractArtifactFile: string) => { - const { inspectContract } = await import('./cmds/inspect_contract.js'); - await inspectContract(contractArtifactFile, log); - }); - - program - .command('compute-selector') - .description('Given a function signature, it computes a selector') - .argument('', 'Function signature to compute selector for e.g. foo(Field)') - .action(async (functionSignature: string) => { - const { computeSelector } = await import('./cmds/compute_selector.js'); - computeSelector(functionSignature, log); - }); - - program - .command('update') - .description('Updates Nodejs and Noir dependencies') - .argument('[projectPath]', 'Path to the project directory', process.cwd()) - .option('--contract [paths...]', 'Paths to contracts to update dependencies', []) - .option('--aztec-version ', 'The version to update Aztec packages to. Defaults to latest', 'latest') - .addOption(pxeOption) - .action(async (projectPath: string, options) => { - const { update } = await import('./update/update.js'); - const { contract, aztecVersion, rpcUrl } = options; - await update(projectPath, contract, rpcUrl, aztecVersion, log); - }); - - addCodegenCommanderAction(program, log); - - return program; -} diff --git a/yarn-project/cli/src/parse_args.ts b/yarn-project/cli/src/parse_args.ts deleted file mode 100644 index d71129d48dd..00000000000 --- a/yarn-project/cli/src/parse_args.ts +++ /dev/null @@ -1,248 +0,0 @@ -import { FunctionSelector } from '@aztec/aztec.js/abi'; -import { AztecAddress } from '@aztec/aztec.js/aztec_address'; -import { EthAddress } from '@aztec/aztec.js/eth_address'; -import { Fr, GrumpkinScalar, Point } from '@aztec/aztec.js/fields'; -import { LogId } from '@aztec/aztec.js/log_id'; -import { TxHash } from '@aztec/aztec.js/tx_hash'; - -import { InvalidArgumentError } from 'commander'; - -/** - * Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged. - * @param hex - A hex string - * @returns A new string with leading 0x removed - */ -const stripLeadingHex = (hex: string) => { - if (hex.length > 2 && hex.startsWith('0x')) { - return hex.substring(2); - } - return hex; -}; - -/** - * Parses a hex encoded string to an Fr integer - * @param str - Hex encoded string - * @returns A integer - */ -export function parseFieldFromHexString(str: string): Fr { - const hex = stripLeadingHex(str); - - // ensure it's a hex string - if (!hex.match(/^[0-9a-f]+$/i)) { - throw new InvalidArgumentError('Invalid hex string'); - } - - // pad it so that we may read it as a buffer. - // Buffer needs _exactly_ two hex characters per byte - const padded = hex.length % 2 === 1 ? '0' + hex : hex; - - // finally, turn it into an integer - return Fr.fromBuffer(Buffer.from(padded, 'hex')); -} - -/** - * Parses an AztecAddress from a string. - * @param address - A serialized Aztec address - * @returns An Aztec address - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseAztecAddress(address: string): AztecAddress { - try { - return AztecAddress.fromString(address); - } catch { - throw new InvalidArgumentError(`Invalid address: ${address}`); - } -} - -/** - * Parses an Ethereum address from a string. - * @param address - A serialized Ethereum address - * @returns An Ethereum address - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseEthereumAddress(address: string): EthAddress { - try { - return EthAddress.fromString(address); - } catch { - throw new InvalidArgumentError(`Invalid address: ${address}`); - } -} - -/** - * Parses an AztecAddress from a string. - * @param address - A serialized Aztec address - * @returns An Aztec address - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseOptionalAztecAddress(address: string): AztecAddress | undefined { - if (!address) { - return undefined; - } - return parseAztecAddress(address); -} - -/** - * Parses an optional log ID string into a LogId object. - * - * @param logId - The log ID string to parse. - * @returns The parsed LogId object, or undefined if the log ID is missing or empty. - */ -export function parseOptionalLogId(logId: string): LogId | undefined { - if (!logId) { - return undefined; - } - return LogId.fromString(logId); -} - -/** - * Parses a selector from a string. - * @param selector - A serialized selector. - * @returns A selector. - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseOptionalSelector(selector: string): FunctionSelector | undefined { - if (!selector) { - return undefined; - } - try { - return FunctionSelector.fromString(selector); - } catch { - throw new InvalidArgumentError(`Invalid selector: ${selector}`); - } -} - -/** - * Parses a string into an integer or returns undefined if the input is falsy. - * - * @param value - The string to parse into an integer. - * @returns The parsed integer, or undefined if the input string is falsy. - * @throws If the input is not a valid integer. - */ -export function parseOptionalInteger(value: string): number | undefined { - if (!value) { - return undefined; - } - const parsed = Number(value); - if (!Number.isInteger(parsed)) { - throw new InvalidArgumentError('Invalid integer.'); - } - return parsed; -} - -/** - * Parses a TxHash from a string. - * @param txHash - A transaction hash - * @returns A TxHash instance - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseTxHash(txHash: string): TxHash { - try { - return TxHash.fromString(txHash); - } catch { - throw new InvalidArgumentError(`Invalid transaction hash: ${txHash}`); - } -} - -/** - * Parses an optional TxHash from a string. - * Calls parseTxHash internally. - * @param txHash - A transaction hash - * @returns A TxHash instance, or undefined if the input string is falsy. - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseOptionalTxHash(txHash: string): TxHash | undefined { - if (!txHash) { - return undefined; - } - return parseTxHash(txHash); -} - -/** - * Parses a public key from a string. - * @param publicKey - A public key - * @returns A Point instance - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parsePublicKey(publicKey: string): Point { - try { - return Point.fromString(publicKey); - } catch (err) { - throw new InvalidArgumentError(`Invalid public key: ${publicKey}`); - } -} - -/** - * Parses a partial address from a string. - * @param address - A partial address - * @returns A Fr instance - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parsePartialAddress(address: string): Fr { - try { - return Fr.fromString(address); - } catch (err) { - throw new InvalidArgumentError(`Invalid partial address: ${address}`); - } -} - -/** - * Parses a private key from a string. - * @param privateKey - A string - * @returns A private key - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parsePrivateKey(privateKey: string): GrumpkinScalar { - try { - const value = GrumpkinScalar.fromString(privateKey); - // most likely a badly formatted key was passed - if (value.isZero()) { - throw new Error('Private key must not be zero'); - } - - return value; - } catch (err) { - throw new InvalidArgumentError(`Invalid private key: ${privateKey}`); - } -} - -/** - * Parses a field from a string. - * @param field - A string representing the field. - * @returns A field. - * @throws InvalidArgumentError if the input string is not valid. - */ -export function parseField(field: string): Fr { - try { - const isHex = field.startsWith('0x') || field.match(new RegExp(`^[0-9a-f]{${Fr.SIZE_IN_BYTES * 2}}$`, 'i')); - if (isHex) { - return Fr.fromString(field); - } - - if (['true', 'false'].includes(field)) { - return new Fr(field === 'true'); - } - - const isNumber = +field || field === '0'; - if (isNumber) { - return new Fr(BigInt(field)); - } - - const isBigInt = field.endsWith('n'); - if (isBigInt) { - return new Fr(BigInt(field.replace(/n$/, ''))); - } - - return new Fr(BigInt(field)); - } catch (err) { - throw new InvalidArgumentError(`Invalid field: ${field}`); - } -} - -/** - * Parses an array of strings to Frs. - * @param fields - An array of strings representing the fields. - * @returns An array of Frs. - */ -export function parseFields(fields: string[]): Fr[] { - return fields.map(parseField); -} diff --git a/yarn-project/cli/src/test/mocks.ts b/yarn-project/cli/src/test/mocks.ts deleted file mode 100644 index 1c56cf0dba2..00000000000 --- a/yarn-project/cli/src/test/mocks.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ABIParameterVisibility, type ContractArtifact, FunctionType } from '@aztec/foundation/abi'; - -export const mockContractArtifact: ContractArtifact = { - name: 'MockContract', - functions: [ - { - name: 'constructor', - isInitializer: true, - functionType: FunctionType.SECRET, - isInternal: false, - parameters: [ - { - name: 'constructorParam1', - type: { - kind: 'field', - }, - visibility: ABIParameterVisibility.SECRET, - }, - ], - returnTypes: [], - bytecode: Buffer.alloc(8, 0xfa), - debugSymbols: '', - }, - { - name: 'mockFunction', - isInitializer: false, - functionType: FunctionType.SECRET, - isInternal: false, - parameters: [ - { - name: 'fieldParam', - type: { kind: 'field' }, - visibility: ABIParameterVisibility.SECRET, - }, - { - name: 'boolParam', - type: { kind: 'boolean' }, - visibility: ABIParameterVisibility.SECRET, - }, - { - name: 'integerParam', - type: { kind: 'integer', sign: 'signed', width: 32 }, - visibility: ABIParameterVisibility.SECRET, - }, - { - name: 'arrayParam', - type: { kind: 'array', length: 3, type: { kind: 'field' } }, - visibility: ABIParameterVisibility.SECRET, - }, - { - name: 'structParam', - type: { - kind: 'struct', - path: 'mystruct', - fields: [ - { name: 'subField1', type: { kind: 'field' } }, - { name: 'subField2', type: { kind: 'boolean' } }, - ], - }, - visibility: ABIParameterVisibility.SECRET, - }, - ], - returnTypes: [{ kind: 'boolean' }], - bytecode: Buffer.alloc(8, 0xfa), - debugSymbols: '', - }, - ], - outputs: { - structs: {}, - globals: {}, - }, - fileMap: {}, -}; diff --git a/yarn-project/cli/src/test/utils.test.ts b/yarn-project/cli/src/test/utils.test.ts deleted file mode 100644 index 56f3e109d91..00000000000 --- a/yarn-project/cli/src/test/utils.test.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { AztecAddress, Fr } from '@aztec/aztec.js'; -import { CompleteAddress, type PXE } from '@aztec/circuit-types'; - -import { InvalidArgumentError } from 'commander'; -import { type MockProxy, mock } from 'jest-mock-extended'; - -import { encodeArgs } from '../encoding.js'; -import { parseFieldFromHexString } from '../parse_args.js'; -import { getTxSender, stripLeadingHex } from '../utils.js'; -import { mockContractArtifact } from './mocks.js'; - -describe('CLI Utils', () => { - let client: MockProxy; - - // test values - const addr1 = AztecAddress.random(); - const addr2 = AztecAddress.random(); - const addr3 = AztecAddress.random(); - const fieldArray = [addr1.toString(), addr2.toString(), addr3.toString()]; - const num = 33; - const field = Fr.random(); - const struct = { - subField1: field.toString(), - subField2: 'true', - }; - - beforeEach(() => { - client = mock(); - }); - - it('Gets a txSender correctly or throw error', async () => { - // returns a parsed Aztec Address - const aztecAddress = AztecAddress.random(); - const result = await getTxSender(client, aztecAddress.toString()); - expect(client.getRegisteredAccounts).toHaveBeenCalledTimes(0); - expect(result).toEqual(aztecAddress); - - // returns an address found in the aztec client - const completeAddress = CompleteAddress.random(); - client.getRegisteredAccounts.mockResolvedValueOnce([completeAddress]); - const resultWithoutString = await getTxSender(client); - expect(client.getRegisteredAccounts).toHaveBeenCalled(); - expect(resultWithoutString).toEqual(completeAddress.address); - - // throws when invalid parameter passed - const errorAddr = 'foo'; - await expect(getTxSender(client, errorAddr)).rejects.toThrow(`Invalid option 'from' passed: ${errorAddr}`); - - // Throws error when no string is passed & no accounts found in RPC - client.getRegisteredAccounts.mockResolvedValueOnce([]); - await expect(getTxSender(client)).rejects.toThrow('No accounts found in PXE instance.'); - }); - - it('Encodes args correctly', () => { - const args = [addr1.toString(), 'false', num.toString(), `${JSON.stringify(fieldArray)}`, JSON.stringify(struct)]; - const result = encodeArgs(args, mockContractArtifact.functions[1].parameters); - const exp = [ - addr1.toBigInt(), - false, - 33n, - [addr1.toBigInt(), addr2.toBigInt(), addr3.toBigInt()], - { - subField1: field.toBigInt(), - subField2: true, - }, - ]; - expect(result).toEqual(exp); - }); - - it('Errors on invalid inputs', () => { - // invalid number of args - const args1 = [field.toString(), 'false']; - expect(() => encodeArgs(args1, mockContractArtifact.functions[1].parameters)).toThrow('Invalid args provided'); - - // invalid array length - const invalidArray = fieldArray.concat([Fr.random().toString()]); - const args2 = [ - addr1.toString(), - 'false', - num.toString(), - `${JSON.stringify(invalidArray)}`, - JSON.stringify(struct), - ]; - expect(() => encodeArgs(args2, mockContractArtifact.functions[1].parameters)).toThrow( - 'Invalid array length passed for arrayParam. Expected 3, received 4.', - ); - - // invalid struct - const invalidStruct = { - subField1: Fr.random().toString(), - }; - const args3 = [ - addr1.toString(), - 'false', - num.toString(), - `${JSON.stringify(fieldArray)}`, - JSON.stringify(invalidStruct), - ]; - expect(() => encodeArgs(args3, mockContractArtifact.functions[1].parameters)).toThrow( - 'Expected field subField2 not found in struct structParam.', - ); - - // invalid bool - const args4 = [ - addr1.toString(), - 'foo', - num.toString(), - `${JSON.stringify(fieldArray)}`, - JSON.stringify(invalidStruct), - ]; - expect(() => encodeArgs(args4, mockContractArtifact.functions[1].parameters)).toThrow( - 'Invalid boolean value passed for boolParam: foo.', - ); - - // invalid field - const args5 = ['foo', 'false', num.toString(), `${JSON.stringify(fieldArray)}`, JSON.stringify(invalidStruct)]; - expect(() => encodeArgs(args5, mockContractArtifact.functions[1].parameters)).toThrow( - 'Invalid value passed for fieldParam. Could not parse foo as a field.', - ); - - // invalid int - const args6 = [addr1.toString(), 'false', 'foo', `${JSON.stringify(fieldArray)}`, JSON.stringify(invalidStruct)]; - expect(() => encodeArgs(args6, mockContractArtifact.functions[1].parameters)).toThrow( - 'Invalid value passed for integerParam. Could not parse foo as an integer.', - ); - }); - - describe('stripLeadingHex', () => { - it.each([ - ['0x1', '1'], - ['1', '1'], - ['0x00', '00'], - ['00', '00'], - ])('removes optional leading hex', (hex, expected) => { - expect(stripLeadingHex(hex)).toEqual(expected); - }); - }); - - describe('parseSaltFromHexString', () => { - it.each([ - ['0', Fr.ZERO], - ['0x0', Fr.ZERO], - ['00', Fr.ZERO], - ['1', new Fr(1)], - ['0x1', new Fr(1)], - ['0x01', new Fr(1)], - ['0xa', new Fr(0xa)], - ['fff', new Fr(0xfff)], - ])('correctly generates salt from a hex string', (hex, expected) => { - expect(parseFieldFromHexString(hex)).toEqual(expected); - }); - - it.each(['foo', '', ' ', ' 0x1', '01foo', 'foo1', '0xfoo'])('throws an error for invalid hex strings', str => { - expect(() => parseFieldFromHexString(str)).toThrow(InvalidArgumentError); - }); - }); -}); diff --git a/yarn-project/cli/src/update/common.ts b/yarn-project/cli/src/update/common.ts deleted file mode 100644 index 6041c1266e4..00000000000 --- a/yarn-project/cli/src/update/common.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Tracks changes to dependencies - */ -export type DependencyChanges = { - /** Which file was changed */ - file: string; - /** changes done to the file */ - dependencies: Array<{ - /** Name of the dependency being changed */ - name: string; - /** Previous version of the dependency */ - from: string; - /** New version of the dependency (after the update) */ - to: string; - }>; -}; diff --git a/yarn-project/cli/src/update/noir.ts b/yarn-project/cli/src/update/noir.ts deleted file mode 100644 index b18c38284b6..00000000000 --- a/yarn-project/cli/src/update/noir.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { type LogFn } from '@aztec/foundation/log'; -import { parseNoirPackageConfig } from '@aztec/foundation/noir'; - -import TOML from '@iarna/toml'; -import { readFile } from 'fs/promises'; -import { join, relative, resolve } from 'path'; - -import { atomicUpdateFile, prettyPrintNargoToml } from '../utils.js'; -import { type DependencyChanges } from './common.js'; - -/** - * Updates Aztec.nr dependencies - * @param contractPath - Path to the contract to be updated - * @param tag - The tag to update to - * @param log - Logging function - */ -export async function updateAztecNr(contractPath: string, tag: string, log: LogFn): Promise { - const configFilepath = resolve(join(contractPath, 'Nargo.toml')); - const packageConfig = parseNoirPackageConfig(TOML.parse(await readFile(configFilepath, 'utf-8'))); - const changes: DependencyChanges = { - dependencies: [], - file: configFilepath, - }; - - log(`Updating Aztec.nr libraries to ${tag} in ${relative(process.cwd(), changes.file)}`); - for (const dep of Object.values(packageConfig.dependencies)) { - if (!('git' in dep)) { - continue; - } - - // remove trailing slash - const gitUrl = dep.git.toLowerCase().replace(/\/$/, ''); - if (gitUrl !== 'https://github.com/aztecprotocol/aztec-packages') { - continue; - } - - if (dep.tag !== tag) { - // show the Aztec.nr package name rather than the lib name - const dirParts = dep.directory?.split('/') ?? []; - changes.dependencies.push({ - name: dirParts.slice(-2).join('/'), - from: dep.tag, - to: tag, - }); - - dep.tag = tag; - dep.directory = dep.directory?.replace('yarn-project/', 'noir-projects/'); - } - } - - if (changes.dependencies.length > 0) { - const contents = prettyPrintNargoToml(packageConfig); - await atomicUpdateFile(configFilepath, contents); - } - - return changes; -} diff --git a/yarn-project/cli/src/update/npm.ts b/yarn-project/cli/src/update/npm.ts deleted file mode 100644 index c18716ca474..00000000000 --- a/yarn-project/cli/src/update/npm.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { type LogFn } from '@aztec/foundation/log'; - -import { spawnSync } from 'child_process'; -import { existsSync } from 'fs'; -import { readFile } from 'fs/promises'; -import { join, relative, resolve } from 'path'; -import { type SemVer, parse } from 'semver'; - -import { atomicUpdateFile } from '../utils.js'; -import { type DependencyChanges } from './common.js'; - -const deprecatedNpmPackages = new Set(['@aztec/cli', '@aztec/aztec-sandbox']); -const npmDeprecationMessage = ` -The following packages have been deprecated and will no longer be updated on the npm registry: -${Array.from(deprecatedNpmPackages) - .map(pkg => ` - ${pkg}`) - .join('\n')} -Remove them from package.json -`; - -/** - * Looks up a package.json file and returns its contents - * @param projectPath - Path to Nodejs project - * @returns The parsed package.json - */ -export async function readPackageJson(projectPath: string): Promise<{ - /** dependencies */ - dependencies?: Record; - /** devDependencies */ - devDependencies?: Record; -}> { - const configFilepath = resolve(join(projectPath, 'package.json')); - const pkg = JSON.parse(await readFile(configFilepath, 'utf-8')); - - return pkg; -} - -/** - * Queries the npm registry for the latest version of a package - * @param packageName - The package to query - * @param distTag - The distribution tag - * @returns The latest version of the package on that distribution tag - */ -export async function getNewestVersion(packageName: string, distTag = 'latest'): Promise { - const url = new URL(packageName, 'https://registry.npmjs.org/'); - const response = await fetch(url); - if (!response.ok) { - throw new Error(`Failed to fetch ${url}`); - } - - const body = await response.json(); - const latestVersion = parse(body['dist-tags'][distTag]); - if (!latestVersion) { - throw new Error(`Failed to get latest version from registry`); - } - - return latestVersion; -} - -/** - * Updates a project's \@aztec/* dependencies to the specific version - * @param projectPath - Path to Nodejs project - * @param aztecVersion - The version to update to - * @returns True if the project was updated - */ -export async function updateAztecDeps( - projectPath: string, - aztecVersion: SemVer, - log: LogFn, -): Promise { - const pkg = await readPackageJson(projectPath); - const changes: DependencyChanges = { - file: resolve(join(projectPath, 'package.json')), - dependencies: [], - }; - - log(`Updating @aztec packages to ${aztecVersion} in ${relative(process.cwd(), changes.file)}`); - const version = aztecVersion.version; - - let detectedDeprecatedPackages = false; - - for (const depType of ['dependencies', 'devDependencies'] as const) { - const dependencies = pkg[depType]; - if (!dependencies) { - continue; - } - - for (const name of Object.keys(dependencies)) { - if (!name.startsWith('@aztec/')) { - continue; - } - - // different release schedule - if (name === '@aztec/aztec-ui') { - continue; - } - - if (deprecatedNpmPackages.has(name)) { - detectedDeprecatedPackages = true; - continue; - } - - if (dependencies[name] !== version) { - changes.dependencies.push({ - name, - from: dependencies[name], - to: version, - }); - - dependencies[name] = version; - } - } - } - - if (detectedDeprecatedPackages) { - log(npmDeprecationMessage); - } - - if (changes.dependencies.length > 0) { - const contents = JSON.stringify(pkg, null, 2) + '\n'; - await atomicUpdateFile(resolve(join(projectPath, 'package.json')), contents); - } - - return changes; -} - -/** - * Updates a project's yarn.lock or package-lock.json - * @param projectPath - Path to Nodejs project - */ -export function updateLockfile(projectPath: string, log: LogFn): void { - const isNpm = existsSync(resolve(join(projectPath, 'package-lock.json'))); - const isYarn = existsSync(resolve(join(projectPath, 'yarn.lock'))); - const isPnpm = existsSync(resolve(join(projectPath, 'pnpm-lock.yaml'))); - - if (isPnpm) { - spawnSync('pnpm', ['install'], { - cwd: projectPath, - stdio: 'inherit', - }); - } else if (isYarn) { - spawnSync('yarn', ['install'], { - cwd: projectPath, - stdio: 'inherit', - }); - } else if (isNpm) { - spawnSync('npm', ['install'], { - cwd: projectPath, - stdio: 'inherit', - }); - } else { - log(`No lockfile found in ${projectPath}. Skipping lockfile update...`); - } -} diff --git a/yarn-project/cli/src/update/update.ts b/yarn-project/cli/src/update/update.ts deleted file mode 100644 index e2bc90f7947..00000000000 --- a/yarn-project/cli/src/update/update.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* eslint-disable jsdoc/require-jsdoc */ -import { type LogFn } from '@aztec/foundation/log'; - -import { relative, resolve } from 'path'; -import { parse } from 'semver'; - -import { GITHUB_TAG_PREFIX } from '../github.js'; -import { type DependencyChanges } from './common.js'; -import { updateAztecNr } from './noir.js'; -import { getNewestVersion, updateAztecDeps, updateLockfile } from './npm.js'; - -const AZTECJS_PACKAGE = '@aztec/aztec.js'; -const UPDATE_DOCS_URL = 'https://docs.aztec.network/developers/updating'; - -export async function update( - projectPath: string, - contracts: string[], - pxeUrl: string, - aztecVersion: string, - log: LogFn, -): Promise { - const targetAztecVersion = - aztecVersion === 'latest' ? await getNewestVersion(AZTECJS_PACKAGE, 'latest') : parse(aztecVersion); - - if (!targetAztecVersion) { - throw new Error(`Invalid aztec version ${aztecVersion}`); - } - - const projectDependencyChanges: DependencyChanges[] = []; - try { - const npmChanges = await updateAztecDeps(resolve(process.cwd(), projectPath), targetAztecVersion, log); - if (npmChanges.dependencies.length > 0) { - updateLockfile(projectPath, log); - } - - projectDependencyChanges.push(npmChanges); - } catch (err) { - if (err instanceof Error && 'code' in err && err.code === 'ENOENT') { - log(`No package.json found in ${projectPath}. Skipping npm update...`); - } else { - throw err; - } - } - - for (const contract of contracts) { - try { - projectDependencyChanges.push( - await updateAztecNr( - resolve(process.cwd(), projectPath, contract), - `${GITHUB_TAG_PREFIX}-v${targetAztecVersion.version}`, - log, - ), - ); - } catch (err) { - if (err instanceof Error && 'code' in err && err.code === 'ENOENT') { - log(`No Nargo.toml found in ${relative(process.cwd(), contract)}. Skipping...`); - } else { - throw err; - } - } - } - - log(`To update Docker containers follow instructions at ${UPDATE_DOCS_URL}`); - - projectDependencyChanges.forEach(changes => { - printChanges(changes, log); - }); -} - -function printChanges(changes: DependencyChanges, log: LogFn): void { - log(`\nIn ${relative(process.cwd(), changes.file)}:`); - if (changes.dependencies.length === 0) { - log(' No changes'); - } else { - changes.dependencies.forEach(({ name, from, to }) => { - log(` Updated ${name} from ${from} to ${to}`); - }); - } -} diff --git a/yarn-project/cli/src/utils.ts b/yarn-project/cli/src/utils.ts deleted file mode 100644 index e9e17997f2d..00000000000 --- a/yarn-project/cli/src/utils.ts +++ /dev/null @@ -1,235 +0,0 @@ -import { type ContractArtifact, type FunctionArtifact, loadContractArtifact } from '@aztec/aztec.js/abi'; -import { AztecAddress } from '@aztec/aztec.js/aztec_address'; -import { type L1ContractArtifactsForDeployment } from '@aztec/aztec.js/ethereum'; -import { type PXE } from '@aztec/aztec.js/interfaces/pxe'; -import { type DebugLogger } from '@aztec/foundation/log'; -import { type NoirPackageConfig } from '@aztec/foundation/noir'; - -import TOML from '@iarna/toml'; -import { CommanderError, InvalidArgumentError } from 'commander'; -import { readFile, rename, writeFile } from 'fs/promises'; - -import { encodeArgs } from './encoding.js'; - -/** - * Helper type to dynamically import contracts. - */ -interface ArtifactsType { - [key: string]: ContractArtifact; -} - -/** - * Helper to get an ABI function or throw error if it doesn't exist. - * @param artifact - Contract's build artifact in JSON format. - * @param fnName - Function name to be found. - * @returns The function's ABI. - */ -export function getFunctionArtifact(artifact: ContractArtifact, fnName: string): FunctionArtifact { - const fn = artifact.functions.find(({ name }) => name === fnName); - if (!fn) { - throw Error(`Function ${fnName} not found in contract ABI.`); - } - return fn; -} - -/** - * Function to execute the 'deployRollupContracts' command. - * @param rpcUrl - The RPC URL of the ethereum node. - * @param apiKey - The api key of the ethereum node endpoint. - * @param privateKey - The private key to be used in contract deployment. - * @param mnemonic - The mnemonic to be used in contract deployment. - */ -export async function deployAztecContracts( - rpcUrl: string, - apiKey: string, - privateKey: string, - mnemonic: string, - debugLogger: DebugLogger, -) { - const { - AvailabilityOracleAbi, - AvailabilityOracleBytecode, - GasPortalAbi, - GasPortalBytecode, - InboxAbi, - InboxBytecode, - OutboxAbi, - OutboxBytecode, - PortalERC20Abi, - PortalERC20Bytecode, - RegistryAbi, - RegistryBytecode, - RollupAbi, - RollupBytecode, - } = await import('@aztec/l1-artifacts'); - const { createEthereumChain, deployL1Contracts } = await import('@aztec/ethereum'); - const { mnemonicToAccount, privateKeyToAccount } = await import('viem/accounts'); - - const account = !privateKey - ? mnemonicToAccount(mnemonic!) - : privateKeyToAccount(`${privateKey.startsWith('0x') ? '' : '0x'}${privateKey}` as `0x${string}`); - const chain = createEthereumChain(rpcUrl, apiKey); - const l1Artifacts: L1ContractArtifactsForDeployment = { - registry: { - contractAbi: RegistryAbi, - contractBytecode: RegistryBytecode, - }, - inbox: { - contractAbi: InboxAbi, - contractBytecode: InboxBytecode, - }, - outbox: { - contractAbi: OutboxAbi, - contractBytecode: OutboxBytecode, - }, - availabilityOracle: { - contractAbi: AvailabilityOracleAbi, - contractBytecode: AvailabilityOracleBytecode, - }, - rollup: { - contractAbi: RollupAbi, - contractBytecode: RollupBytecode, - }, - gasToken: { - contractAbi: PortalERC20Abi, - contractBytecode: PortalERC20Bytecode, - }, - gasPortal: { - contractAbi: GasPortalAbi, - contractBytecode: GasPortalBytecode, - }, - }; - return await deployL1Contracts(chain.rpcUrl, account, chain.chainInfo, debugLogger, l1Artifacts); -} - -/** - * Gets all contracts available in \@aztec/noir-contracts.js. - * @returns The contract ABIs. - */ -export async function getExampleContractArtifacts(): Promise { - const imports: any = await import('@aztec/noir-contracts.js'); - return Object.fromEntries(Object.entries(imports).filter(([key]) => key.endsWith('Artifact'))) as any; -} - -/** - * Reads a file and converts it to an Aztec Contract ABI. - * @param fileDir - The directory of the compiled contract ABI. - * @returns The parsed contract artifact. - */ -export async function getContractArtifact(fileDir: string) { - // first check if it's a noir-contracts example - const artifacts = await getExampleContractArtifacts(); - if (artifacts[fileDir]) { - return artifacts[fileDir] as ContractArtifact; - } - - let contents: string; - try { - contents = await readFile(fileDir, 'utf8'); - } catch { - throw new Error(`Contract ${fileDir} not found`); - } - - try { - return loadContractArtifact(JSON.parse(contents)); - } catch (err) { - throw new Error(`Invalid contract ABI file ${fileDir}: ${err}`); - } -} - -/** - * Utility to select a TX sender either from user input - * or from the first account that is found in a PXE instance. - * @param pxe - The PXE instance that will be checked for an account. - * @param _from - The user input. - * @returns An Aztec address. Will throw if one can't be found in either options. - */ -export async function getTxSender(pxe: PXE, _from?: string) { - let from: AztecAddress; - if (_from) { - try { - from = AztecAddress.fromString(_from); - } catch { - throw new InvalidArgumentError(`Invalid option 'from' passed: ${_from}`); - } - } else { - const accounts = await pxe.getRegisteredAccounts(); - if (!accounts.length) { - throw new Error('No accounts found in PXE instance.'); - } - from = accounts[0].address; - } - return from; -} - -/** - * Performs necessary checks, conversions & operations to call a contract fn from the CLI. - * @param contractFile - Directory of the compiled contract ABI. - * @param functionName - Name of the function to be called. - * @param _functionArgs - Arguments to call the function with. - * @returns Formatted contract address, function arguments and caller's aztec address. - */ -export async function prepTx(contractFile: string, functionName: string, _functionArgs: string[]) { - const contractArtifact = await getContractArtifact(contractFile); - const functionArtifact = getFunctionArtifact(contractArtifact, functionName); - const functionArgs = encodeArgs(_functionArgs, functionArtifact.parameters); - - return { functionArgs, contractArtifact }; -} - -/** - * Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged. - * @param hex - A hex string - * @returns A new string with leading 0x removed - */ -export const stripLeadingHex = (hex: string) => { - if (hex.length > 2 && hex.startsWith('0x')) { - return hex.substring(2); - } - return hex; -}; - -/** - * Updates a file in place atomically. - * @param filePath - Path to file - * @param contents - New contents to write - */ -export async function atomicUpdateFile(filePath: string, contents: string) { - const tmpFilepath = filePath + '.tmp'; - try { - await writeFile(tmpFilepath, contents, { - // let's crash if the tmp file already exists - flag: 'wx', - }); - await rename(tmpFilepath, filePath); - } catch (e) { - if (e instanceof Error && 'code' in e && e.code === 'EEXIST') { - const commanderError = new CommanderError( - 1, - e.code, - `Temporary file already exists: ${tmpFilepath}. Delete this file and try again.`, - ); - commanderError.nestedError = e.message; - throw commanderError; - } else { - throw e; - } - } -} - -/** - * Pretty prints Nargo.toml contents to a string - * @param config - Nargo.toml contents - * @returns The Nargo.toml contents as a string - */ -export function prettyPrintNargoToml(config: NoirPackageConfig): string { - const withoutDependencies = Object.fromEntries(Object.entries(config).filter(([key]) => key !== 'dependencies')); - - const partialToml = TOML.stringify(withoutDependencies); - const dependenciesToml = Object.entries(config.dependencies).map(([name, dep]) => { - const depToml = TOML.stringify.value(dep); - return `${name} = ${depToml}`; - }); - - return partialToml + '\n[dependencies]\n' + dependenciesToml.join('\n') + '\n'; -} diff --git a/yarn-project/cli/tsconfig.json b/yarn-project/cli/tsconfig.json deleted file mode 100644 index 29032103ade..00000000000 --- a/yarn-project/cli/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "extends": "..", - "compilerOptions": { - "outDir": "dest", - "rootDir": "src", - "tsBuildInfoFile": ".tsbuildinfo" - }, - "references": [ - { - "path": "../accounts" - }, - { - "path": "../aztec.js" - }, - { - "path": "../circuit-types" - }, - { - "path": "../circuits.js" - }, - { - "path": "../ethereum" - }, - { - "path": "../foundation" - }, - { - "path": "../l1-artifacts" - }, - { - "path": "../noir-compiler" - }, - { - "path": "../noir-contracts.js" - }, - { - "path": "../types" - } - ], - "include": ["src"], - "exclude": ["contracts"] -} diff --git a/yarn-project/end-to-end/Earthfile b/yarn-project/end-to-end/Earthfile index f75127fe1f2..b546dbf84a3 100644 --- a/yarn-project/end-to-end/Earthfile +++ b/yarn-project/end-to-end/Earthfile @@ -106,10 +106,6 @@ pxe: ARG e2e_mode=local DO +E2E_TEST --test=pxe.test.ts --e2e_mode=$e2e_mode -cli-docs-sandbox: - ARG e2e_mode=local - DO +E2E_TEST --test=cli_docs_sandbox.test.ts --e2e_mode=$e2e_mode - e2e-docs-examples: ARG e2e_mode=local DO +E2E_TEST --test=docs_examples.test.ts --e2e_mode=$e2e_mode diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 9fe157450d0..3ff8401dd77 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -26,7 +26,6 @@ "@aztec/aztec.js": "workspace:^", "@aztec/circuit-types": "workspace:^", "@aztec/circuits.js": "workspace:^", - "@aztec/cli": "workspace:^", "@aztec/entrypoints": "workspace:^", "@aztec/ethereum": "workspace:^", "@aztec/foundation": "workspace:^", diff --git a/yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts b/yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts deleted file mode 100644 index 09f026b561f..00000000000 --- a/yarn-project/end-to-end/src/composed/cli_docs_sandbox.test.ts +++ /dev/null @@ -1,389 +0,0 @@ -import { AztecAddress, TxHash, createDebugLogger, sleep } from '@aztec/aztec.js'; -import { getProgram } from '@aztec/cli'; - -import stringArgv from 'string-argv'; - -const debug = createDebugLogger('aztec:e2e_cli'); - -const { PXE_URL = 'http://localhost:8080' } = process.env; - -describe('CLI docs sandbox', () => { - let cli: ReturnType; - let log: (msg: string) => void; - - // All logs emitted by the cli will be collected here, and reset between tests - const logs: string[] = []; - - beforeAll(async () => { - log = (msg: string) => { - logs.push(msg); - debug.verbose(msg); - }; - - await waitForSandboxWithCli(); - }, 60_000); - - const waitForSandboxWithCli = async () => { - const docs = ` -// docs:start:node-info -% aztec-cli get-node-info -Node Info: - -Node Version: #include_aztec_short_version -Chain Id: 31337 -Protocol Version: 1 -Rollup Address: 0x0dcd1bf9a1b36ce34237eeafef220932846bcd82 -// docs:end:node-info -`; - - const command = docs.split('\n')[2].split('aztec-cli ')[1]; - while (true) { - resetCli(); - try { - await run(command); - break; - } catch (err) { - await sleep(1000); - } - } - }; - - // in order to run the same command twice, we need to create a new CLI instance - const resetCli = () => { - cli = getProgram(log, debug); - }; - - beforeEach(() => { - logs.splice(0); - resetCli(); - }); - - // Run a command on the CLI - const run = (cmd: string, addRpcUrl = true) => { - const args = stringArgv(cmd, 'node', 'dest/bin/index.js'); - if (addRpcUrl) { - args.push('--rpc-url', PXE_URL); - } - return cli.parseAsync(args); - }; - - // Returns first match across all logs collected so far - const findInLogs = (regex: RegExp) => { - for (const log of logs) { - const match = regex.exec(log); - if (match) { - return match; - } - } - }; - - const findMultipleInLogs = (regex: RegExp) => { - const matches = []; - for (const log of logs) { - const match = regex.exec(log); - if (match) { - matches.push(match); - } - } - return matches; - }; - - const clearLogs = () => { - logs.splice(0); - }; - - it('prints example contracts', async () => { - const docs = ` -// docs:start:example-contracts -% aztec-cli example-contracts -AppSubscriptionContractArtifact -AuthContractArtifact -BenchmarkingContractArtifact -CardGameContractArtifact -ChildContractArtifact -ClaimContractArtifact -ContractClassRegistererContractArtifact -ContractInstanceDeployerContractArtifact -CounterContractArtifact -CrowdfundingContractArtifact -DelegatedOnContractArtifact -DelegatorContractArtifact -DocsExampleContractArtifact -EasyPrivateTokenContractArtifact -EasyPrivateVotingContractArtifact -EcdsaAccountContractArtifact -EscrowContractArtifact -FPCContractArtifact -GasTokenContractArtifact -ImportTestContractArtifact -InclusionProofsContractArtifact -KeyRegistryContractArtifact -LendingContractArtifact -MultiCallEntrypointContractArtifact -ParentContractArtifact -PendingNoteHashesContractArtifact -PriceFeedContractArtifact -ReaderContractArtifact -SchnorrAccountContractArtifact -SchnorrHardcodedAccountContractArtifact -SchnorrSingleKeyAccountContractArtifact -SlowTreeContractArtifact -StatefulTestContractArtifact -TestContractArtifact -TokenBlacklistContractArtifact -TokenBridgeContractArtifact -TokenContractArtifact -UniswapContractArtifact -// docs:end:example-contracts -`; - - const command = docs.split('\n')[2].split('aztec-cli ')[1]; - const expectedConsoleOutput = docs.split('\n').slice(3, -2); - - await run(command, false); - expect(logs).toEqual(expectedConsoleOutput); - }); - - it('gets a block number', async () => { - const docs = ` -// docs:start:block-number -% aztec-cli block-number -1 -// docs:end:block-number -`; - - const command = docs.split('\n')[2].split('aztec-cli ')[1]; - - await run(command); - // expect logs to contain a number and nothing else - expect(logs.length).toEqual(1); - expect(logs[0]).toMatch(/\d+/); - }); - - it('creates an account from private key', async () => { - const docs = ` -// docs:start:create-account-from-private-key -% aztec-cli generate-private-key - -Private Key: 0x12684562c8676e66be100878434b01286a757dea468233f818b906f66fb34984 -Public Key: 0x1003732857c052c1d6af4dd74b5631863a056c90a586c4e3ea6d94782ee712d317cdb713ed1ba02d3df0ac2b581d269490f9e24916c1b677c7259444aa0ad66b - - -% aztec-cli create-account --private-key 0x12684562c8676e66be100878434b01286a757dea468233f818b906f66fb34984 - -Created new account: - -Address: 0x26e831b1b146d1faf0c1d27fc72f2243887e9963cc87a6b3af64fe6481920a80 -Public key: 0x1003732857c052c1d6af4dd74b5631863a056c90a586c4e3ea6d94782ee712d317cdb713ed1ba02d3df0ac2b581d269490f9e24916c1b677c7259444aa0ad66b -Partial address: 0x01e5e7b2abbfb98a93b7549ae80faa6886f8ea8e8f412416fb330b565fd2b4ed -// docs:end:create-account-from-private-key -`; - - const generateCommand = docs.split('\n')[2].split('aztec-cli ')[1]; - await run(generateCommand, false); - - const foundPrivateKey = findInLogs(/Private\sKey:\s+(?0x[a-fA-F0-9]+)/)?.groups?.privateKey; - expect(foundPrivateKey).toBeDefined(); - const foundPublicKeyGenerate = findInLogs(/Public\sKey:\s+(?0x[a-fA-F0-9]+)/)?.groups?.publicKey; - expect(foundPublicKeyGenerate).toBeDefined(); - - clearLogs(); - - const createCommand = docs.split('\n')[8].split('aztec-cli ')[1]; - - await run(createCommand); - const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundAddress).toBeDefined(); - const foundPublicKey = findInLogs(/Public\skey:\s+(?0x[a-fA-F0-9]+)/)?.groups?.publicKey; - expect(foundPublicKey).toBeDefined(); - const foundPartialAddress = findInLogs(/Partial\saddress:\s+(?0x[a-fA-F0-9]+)/)?.groups - ?.partialAddress; - expect(foundPartialAddress).toBeDefined(); - }); - - it.skip('creates an account, gets account, deploys, checks deployed, view method, sending a tx... [SEQUENTIAL]', async () => { - // Test create-account - let docs = ` -// docs:start:create-account -% aztec-cli create-account -Created new account: - -Address: 0x20d3321707d53cebb168568e25c5c62a853ae1f0766d965e00d6f6c4eb05d599 -Public key: 0x02d18745eadddd496be95274367ee2cbf0bf667b81373fb6bed715c18814a09022907c273ec1c469fcc678738bd8efc3e9053fe1acbb11fa32da0d6881a1370e -Private key: 0x2aba9e7de7075deee3e3f4ad1e47749f985f0f72543ed91063cc97a40d851f1e -Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed -// docs:end:create-account -`; - - let command = docs.split('\n')[2].split('aztec-cli ')[1]; - - await run(command); - const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundAddress).toBeDefined(); - const foundPublicKey = findInLogs(/Public\skey:\s+(?0x[a-fA-F0-9]+)/)?.groups?.publicKey; - expect(foundPublicKey).toBeDefined(); - const foundPrivateKey = findInLogs(/Private\skey:\s+(?0x[a-fA-F0-9]+)/)?.groups?.privateKey; - expect(foundPrivateKey).toBeDefined(); - const foundPartialAddress = findInLogs(/Partial\saddress:\s+(?0x[a-fA-F0-9]+)/)?.groups - ?.partialAddress; - expect(foundPartialAddress).toBeDefined(); - const newAddress = AztecAddress.fromString(foundAddress!); - - clearLogs(); - - // Test get-account - docs = ` -// docs:start:get-accounts -% aztec-cli get-accounts -Accounts found: - - Address: 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d - Public Key: 0x27c20118733174347b8082f578a7d8fb84b3ad38be293715eee8119ee5cd8a6d0d6b7d8124b37359663e75bcd2756f544a93b821a06f8e33fba68cc8029794d9 - Partial Address: 0x1c6484e22441e5ca43bba53495d0cdc911da299150fde1191bcb330b64716ff9 - - Address: 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972 - Public Key: 0x08145e8e8d46f51cda8d4c9cad81920236366abeafb8d387002bad879a3e87a81570b04ac829e4c007141d856d5a36d3b9c464e0f3c1c99cdbadaa6bb93f3257 - Partial Address: 0x1833e53112953e6830a230cfc2895caed604f6395bbfafa730da26c5bf53c0a9 - - Address: 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b - Public Key: 0x13e6151ea8e7386a5e7c4c5221047bf73d0b1b7a2ad14d22b7f73e57c1fa00c614bc6da69da1b581b09ee6cdc195e5d58ae4dce01b63bbb744e58f03855a94dd - Partial Address: 0x30034aaf5d78821effa4827a132357110a49a4f37b6e384d884e233595bcf342 - - Address: 0x01b18c2044bbedd4a2e5f67cf6858370ccfb2b869b2000abe2f4ca12d9cc166e - Public Key: 0x240845f1179e3fbaa6ce587d44722b3452bbdaa11deb29553196b23534985d432b746bcf2f0e7046eb13f0ca0c4fedd027dc80b64384f50d6a14ad248faa941a - Partial Address: 0x03834845fc488d1454f195abe7d52b3393f6902eee080c90cd694c63572f7160 -// docs:end:get-accounts -`; - - command = docs.split('\n')[2].split('aztec-cli ')[1]; - await run(command); - - const fetchedAddresses = findMultipleInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/); - const foundFetchedAddress = fetchedAddresses.find(match => match.groups?.address === newAddress.toString()); - expect(foundFetchedAddress).toBeDefined(); - - clearLogs(); - - // Test deploy - docs = ` -// docs:start:deploy -% aztec-cli deploy TokenContractArtifact --private-key $PRIVATE_KEY --args $ADDRESS TokenName TKN 18 - -Contract deployed at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f -// docs:end:deploy - `; - - command = docs - .split('\n')[2] - .split('aztec-cli ')[1] - .replace('$ADDRESS', newAddress.toString()) - .replace('$PRIVATE_KEY', foundPrivateKey!); - await run(command); - - let foundContractAddress = findInLogs(/Contract\sdeployed\sat\s(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundContractAddress).toBeDefined(); - const contractAddress = AztecAddress.fromString(foundContractAddress!); - - clearLogs(); - - // Test check-deploy - docs = ` -// docs:start:check-deploy -% aztec-cli check-deploy --contract-address $CONTRACT_ADDRESS - -Contract is publicly deployed at 0x1ae8eea0dc265fb7f160dae62cc8912686d8a9ed78e821fbdd8bcedc54c06d0f -// docs:end:check-deploy -`; - command = docs.split('\n')[2].split('aztec-cli ')[1].replace('$CONTRACT_ADDRESS', contractAddress.toString()); - await run(command); - - foundContractAddress = findInLogs(/Contract.+\sat\s(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundContractAddress).toEqual(contractAddress.toString()); - - clearLogs(); - - // Test send - docs = ` -// docs:start:send -% aztec-cli send mint_public \ - --args $ADDRESS 543 \ - --contract-artifact TokenContractArtifact \ - --contract-address $CONTRACT_ADDRESS \ - --private-key $PRIVATE_KEY - -Transaction has been mined -Transaction hash: 15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c -Status: mined -Block number: 5 -Block hash: 163697608599543b2bee9652f543938683e4cdd0f94ac506e5764d8b908d43d4 -// docs:end:send -`; - - command = docs - .split('\n')[2] - .split('aztec-cli ')[1] - .replace('$ADDRESS', newAddress.toString()) - .replace('$CONTRACT_ADDRESS', contractAddress.toString()) - .replace('$PRIVATE_KEY', foundPrivateKey!); - await run(command); - - let foundTxHash = findInLogs(/Transaction\shash:\s+(?\S+)/)?.groups?.txHash; - expect(foundTxHash).toBeDefined(); - - clearLogs(); - - // Save the tx hash for later use - const transferTxHash = TxHash.fromString(foundTxHash!); - - // Test get-tx-receipt - docs = ` -// docs:start:get-tx-receipt -% aztec-cli get-tx-receipt 15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c - -Transaction receipt: -{ - "txHash": "15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c", - "status": "mined", - "error": "", - "blockHash": "163697608599543b2bee9652f543938683e4cdd0f94ac506e5764d8b908d43d4", - "blockNumber": 5, - "origin": "0x2337f1d5cfa6c03796db5539b0b2d5a57e9aed42665df2e0907f66820cb6eebe" -} -// docs:end:get-tx-receipt -`; - - command = docs - .split('\n')[2] - .split('aztec-cli ')[1] - .replace('15c5a8e58d5f895c7e3017a706efbad693635e01f67345fa60a64a340d83c78c', transferTxHash.toString()); - await run(command); - - foundTxHash = findInLogs(/"txHash":\s+"(?\S+)"/)?.groups?.txHash; - expect(foundTxHash).toEqual(transferTxHash.toString()); - const status = findInLogs(/"status":\s+"(?\S+)"/)?.groups?.status; - expect(status).toEqual('mined'); - const error = findInLogs(/"error":\s+"(?\S*)"/)?.groups?.error; - expect(error).toEqual(''); - - clearLogs(); - - // Test call - docs = ` -// docs:start:call -% aztec-cli call balance_of_public -a $ADDRESS -c TokenContractArtifact -ca $CONTRACT_ADDRESS - -View result: 543n -// docs:end:call -`; - command = docs - .split('\n')[2] - .split('aztec-cli ')[1] - .replace('$ADDRESS', newAddress.toString()) - .replace('$CONTRACT_ADDRESS', contractAddress.toString()); - - await run(command); - - const foundBalance = findInLogs(/View\sresult:\s+(?\S+)/)?.groups?.data; - expect(foundBalance!).toEqual(`${BigInt(543).toString()}n`); - }, 60_000); -}); diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts deleted file mode 100644 index 7acb8ed6327..00000000000 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { type PXE, createDebugLogger } from '@aztec/aztec.js'; -import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server'; -import { createPXERpcServer } from '@aztec/pxe'; - -import { setup as e2eSetup } from './fixtures/utils.js'; -import { cliTestSuite } from './shared/cli.js'; - -const HTTP_PORT = 9009; -const log = createDebugLogger('aztec:e2e_cli'); - -const { PXE_URL = '' } = process.env; -let RPC_URL = PXE_URL; - -let http: ReturnType; -let pxe: PXE; -let teardown: () => Promise; - -const testSetup = async () => { - const context = await e2eSetup(2); - log.info(`Environment set up`); - ({ pxe, teardown } = context); - if (!RPC_URL) { - http = startHttpRpcServer('pxe', pxe, createPXERpcServer, HTTP_PORT); - log.info(`HTTP RPC server started on port ${HTTP_PORT}`); - RPC_URL = `http://localhost:${HTTP_PORT}`; - } - return { pxe, rpcURL: RPC_URL }; -}; - -const testCleanup = async () => { - http?.close(); - await teardown(); -}; - -cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli')); diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts index dfacf8687cf..1dd55e6ea35 100644 --- a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts +++ b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts @@ -6,7 +6,8 @@ const { PXE_URL = '' } = process.env; // Entrypoint for running the up-quick-start script on the CI describe('guides/up_quick_start', () => { - it('works', async () => { + // TODO: update to not use CLI + it.skip('works', async () => { await waitForPXE(createPXEClient(PXE_URL)); execSync( `DEBUG="aztec:*" PXE_URL=\${PXE_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, diff --git a/yarn-project/end-to-end/src/shared/cli.ts b/yarn-project/end-to-end/src/shared/cli.ts deleted file mode 100644 index b6738c2371a..00000000000 --- a/yarn-project/end-to-end/src/shared/cli.ts +++ /dev/null @@ -1,242 +0,0 @@ -import { - AztecAddress, - type CompleteAddress, - type DebugLogger, - Fr, - type PXE, - computeMessageSecretHash, -} from '@aztec/aztec.js'; -import { getProgram } from '@aztec/cli'; - -import stringArgv from 'string-argv'; - -const INITIAL_BALANCE = 33000; -const TRANSFER_BALANCE = 3000; - -export const cliTestSuite = ( - name: string, - setup: () => Promise<{ pxe: PXE; rpcURL: string }>, - cleanup: () => Promise, - debug: DebugLogger, -) => - describe(name, () => { - let cli: ReturnType; - let pxe: PXE; - let existingAccounts: CompleteAddress[]; - let contractAddress: AztecAddress; - let log: (msg: string) => void; - let rpcURL = ''; - - // All logs emitted by the cli will be collected here, and reset between tests - const logs: string[] = []; - - beforeAll(async () => { - ({ pxe, rpcURL } = await setup()); - log = (msg: string) => { - logs.push(msg); - debug.verbose(msg); - }; - }, 30_000); - - afterAll(async () => { - await cleanup(); - }); - - // in order to run the same command twice, we need to create a new CLI instance - const resetCli = () => { - cli = getProgram(log, debug); - }; - - beforeEach(() => { - logs.splice(0); - resetCli(); - }); - - // Run a command on the CLI - const run = (cmd: string, addRpcUrl = true) => { - const args = stringArgv(cmd, 'node', 'dest/bin/index.js'); - if (addRpcUrl) { - args.push('--rpc-url', rpcURL); - } - debug.info(`Running command ${args.join(' ')}`); - const res = cli.parseAsync(args); - resetCli(); - return res; - }; - - // Returns first match across all logs collected so far - const findInLogs = (regex: RegExp) => { - for (const log of logs) { - const match = regex.exec(log); - if (match) { - return match; - } - } - }; - - const findMultipleInLogs = (regex: RegExp) => { - const matches = []; - for (const log of logs) { - const match = regex.exec(log); - if (match) { - matches.push(match); - } - } - return matches; - }; - - const clearLogs = () => { - logs.splice(0); - }; - - it('creates & retrieves an account', async () => { - existingAccounts = await pxe.getRegisteredAccounts(); - debug.info('Create an account'); - await run(`create-account`); - const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundAddress).toBeDefined(); - const newAddress = AztecAddress.fromString(foundAddress!); - - const accountsAfter = await pxe.getRegisteredAccounts(); - const expectedAccounts = [...existingAccounts.map(a => a.address), newAddress]; - expect(accountsAfter.map(a => a.address)).toEqual(expectedAccounts); - const newCompleteAddress = accountsAfter[accountsAfter.length - 1]; - - // Test get-accounts - debug.info('Check that account was added to the list of accounts in RPC'); - await run('get-accounts'); - const fetchedAddresses = findMultipleInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/); - const foundFetchedAddress = fetchedAddresses.find(match => match.groups?.address === newAddress.toString()); - expect(foundFetchedAddress).toBeDefined(); - - // Test get-account - debug.info('Check we can retrieve the specific account'); - clearLogs(); - await run(`get-account ${newAddress.toString()}`); - const fetchedAddress = findInLogs(/Public Key:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(fetchedAddress).toEqual(newCompleteAddress.publicKey.toString()); - }); - - // Regression test for deploy cmd with a constructor not named "constructor" - it('deploys a contract using a public initializer', async () => { - debug.info('Create an account using a private key'); - await run('generate-private-key', false); - const privKey = findInLogs(/Private\sKey:\s+0x(?[a-fA-F0-9]+)/)?.groups?.privKey; - expect(privKey).toHaveLength(64); - await run(`create-account --private-key ${privKey}`); - const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundAddress).toBeDefined(); - const ownerAddress = AztecAddress.fromString(foundAddress!); - const salt = 42; - - debug.info('Deploy StatefulTestContract with public_constructor using created account.'); - await run( - `deploy StatefulTestContractArtifact --private-key ${privKey} --salt ${salt} --initializer public_constructor --args ${ownerAddress} 100`, - ); - const loggedAddress = findInLogs(/Contract\sdeployed\sat\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(loggedAddress).toBeDefined(); - contractAddress = AztecAddress.fromString(loggedAddress!); - - const deployedContract = await pxe.getContractInstance(contractAddress); - expect(deployedContract?.address).toEqual(contractAddress); - - clearLogs(); - await run( - `call get_public_value --args ${ownerAddress} --contract-artifact StatefulTestContractArtifact --contract-address ${contractAddress.toString()}`, - ); - - const balance = findInLogs(/View\sresult:\s+(?\S+)/)?.groups?.data; - expect(balance!).toEqual(`${BigInt(100).toString()}n`); - }, 60_000); - - it.each([ - ['an example Token contract', 'TokenContractArtifact', '0'], - ['a Nargo artifact', '../noir-contracts.js/artifacts/token_contract-Token.json', '1'], - ])( - 'deploys %s & sends transactions', - async (_, artifact, salt) => { - // generate a private key - debug.info('Create an account using a private key'); - await run('generate-private-key', false); - const privKey = findInLogs(/Private\sKey:\s+0x(?[a-fA-F0-9]+)/)?.groups?.privKey; - expect(privKey).toHaveLength(64); - await run(`create-account --private-key ${privKey}`); - const foundAddress = findInLogs(/Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(foundAddress).toBeDefined(); - const ownerAddress = AztecAddress.fromString(foundAddress!); - - debug.info('Deploy Token Contract using created account.'); - await run( - `deploy ${artifact} --private-key ${privKey} --salt ${salt} --args ${ownerAddress} 'TokenName' 'TKN' 18`, - ); - const loggedAddress = findInLogs(/Contract\sdeployed\sat\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(loggedAddress).toBeDefined(); - contractAddress = AztecAddress.fromString(loggedAddress!); - - const deployedContract = await pxe.getContractInstance(contractAddress); - expect(deployedContract?.address).toEqual(contractAddress); - - debug.info('Check contract can be found in returned address'); - await run(`check-deploy -ca ${loggedAddress}`); - const checkResult = findInLogs(/Contract.+\sat\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(checkResult).toEqual(deployedContract?.address.toString()); - - const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); - - debug.info('Mint initial tokens.'); - await run( - `send mint_private --args ${INITIAL_BALANCE} ${secretHash} --contract-artifact TokenContractArtifact --contract-address ${contractAddress.toString()} --private-key ${privKey}`, - ); - - debug.info('Add note to the PXE.'); - const txHashes = findMultipleInLogs(/Transaction Hash: ([0-9a-f]{64})/i); - const mintPrivateTxHash = txHashes[txHashes.length - 1][1]; - await run( - `add-note ${ownerAddress} ${contractAddress} 5 84114971101151129711410111011678111116101 ${mintPrivateTxHash} --note ${INITIAL_BALANCE} ${secretHash}`, - ); - - debug.info('Redeem tokens.'); - await run( - `send redeem_shield --args ${ownerAddress} ${INITIAL_BALANCE} ${secret} --contract-artifact TokenContractArtifact --contract-address ${contractAddress.toString()} --private-key ${privKey}`, - ); - - clearLogs(); - await run(`get-contract-data ${loggedAddress}`); - const contractDataAddress = findInLogs(/^\s?Address:\s+(?
0x[a-fA-F0-9]+)/)?.groups?.address; - expect(contractDataAddress).toEqual(deployedContract?.address.toString()); - - debug.info("Check owner's balance"); - await run( - `call balance_of_private --args ${ownerAddress} --contract-artifact TokenContractArtifact --contract-address ${contractAddress.toString()}`, - ); - const balance = findInLogs(/View\sresult:\s+(?\S+)/)?.groups?.data; - expect(balance!).toEqual(`${BigInt(INITIAL_BALANCE).toString()}n`); - - debug.info('Transfer some tokens'); - const existingAccounts = await pxe.getRegisteredAccounts(); - // ensure we pick a different acc - const receiver = existingAccounts.find(acc => acc.address.toString() !== ownerAddress.toString()); - - await run( - `send transfer --args ${ownerAddress.toString()} ${receiver?.address.toString()} ${TRANSFER_BALANCE} 0 --contract-address ${contractAddress.toString()} --contract-artifact TokenContractArtifact --private-key ${privKey}`, - ); - const txHash = findInLogs(/Transaction\shash:\s+(?\S+)/)?.groups?.txHash; - - debug.info('Check the transfer receipt'); - await run(`get-tx-receipt ${txHash}`); - const txResult = findInLogs(/Transaction receipt:\s*(?[\s\S]*?\})/)?.groups?.txHash; - const parsedResult = JSON.parse(txResult!); - expect(parsedResult.txHash).toEqual(txHash); - expect(parsedResult.status).toEqual('mined'); - debug.info("Check Receiver's balance"); - clearLogs(); - await run( - `call balance_of_private --args ${receiver?.address.toString()} --contract-artifact TokenContractArtifact --contract-address ${contractAddress.toString()}`, - ); - const receiverBalance = findInLogs(/View\sresult:\s+(?\S+)/)?.groups?.data; - expect(receiverBalance).toEqual(`${BigInt(TRANSFER_BALANCE).toString()}n`); - }, - 100_000, - ); - }); diff --git a/yarn-project/end-to-end/src/shared/index.ts b/yarn-project/end-to-end/src/shared/index.ts index 4c6d1eef910..dcb31a19745 100644 --- a/yarn-project/end-to-end/src/shared/index.ts +++ b/yarn-project/end-to-end/src/shared/index.ts @@ -1,3 +1,2 @@ -export { cliTestSuite } from './cli.js'; export { browserTestSuite } from './browser.js'; export { uniswapL1L2TestSuite, UniswapSetupContext } from './uniswap_l1_l2.js'; diff --git a/yarn-project/end-to-end/tsconfig.json b/yarn-project/end-to-end/tsconfig.json index 159d8f7cea1..b0e697f1148 100644 --- a/yarn-project/end-to-end/tsconfig.json +++ b/yarn-project/end-to-end/tsconfig.json @@ -24,9 +24,6 @@ { "path": "../circuits.js" }, - { - "path": "../cli" - }, { "path": "../entrypoints" }, diff --git a/yarn-project/noir-compiler/aztec-compile-dest b/yarn-project/noir-compiler/aztec-compile-dest new file mode 100755 index 00000000000..c5b74ae02df --- /dev/null +++ b/yarn-project/noir-compiler/aztec-compile-dest @@ -0,0 +1,3 @@ +#!/bin/sh +SCRIPT_PATH=$(dirname $(realpath $0)) +node --no-warnings $SCRIPT_PATH/dest/cli.js $@ diff --git a/yarn-project/tsconfig.json b/yarn-project/tsconfig.json index eafb807f772..3fde67b857e 100644 --- a/yarn-project/tsconfig.json +++ b/yarn-project/tsconfig.json @@ -29,7 +29,6 @@ { "path": "aztec/tsconfig.json" }, { "path": "circuits.js/tsconfig.json" }, { "path": "circuit-types/tsconfig.json" }, - { "path": "cli/tsconfig.json" }, { "path": "end-to-end/tsconfig.json" }, { "path": "foundation/tsconfig.json" }, { "path": "key-store/tsconfig.json" }, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 1121959ee0b..105ac89cb19 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -314,45 +314,6 @@ __metadata: languageName: unknown linkType: soft -"@aztec/cli@workspace:^, @aztec/cli@workspace:cli": - version: 0.0.0-use.local - resolution: "@aztec/cli@workspace:cli" - dependencies: - "@aztec/accounts": "workspace:^" - "@aztec/aztec.js": "workspace:^" - "@aztec/circuit-types": "workspace:^" - "@aztec/circuits.js": "workspace:^" - "@aztec/ethereum": "workspace:^" - "@aztec/foundation": "workspace:^" - "@aztec/l1-artifacts": "workspace:^" - "@aztec/noir-compiler": "workspace:^" - "@aztec/noir-contracts.js": "workspace:^" - "@aztec/types": "workspace:^" - "@iarna/toml": ^2.2.5 - "@jest/globals": ^29.5.0 - "@libp2p/peer-id-factory": ^3.0.4 - "@types/jest": ^29.5.0 - "@types/lodash.startcase": ^4.4.7 - "@types/node": ^18.7.23 - "@types/semver": ^7.5.2 - "@types/source-map-support": ^0.5.10 - commander: ^9.0.0 - jest: ^29.5.0 - jest-mock-extended: ^3.0.5 - jszip: ^3.10.1 - lodash.startcase: ^4.4.0 - node-fetch: ^3.3.2 - semver: ^7.5.4 - source-map-support: ^0.5.21 - ts-node: ^10.9.1 - tslib: ^2.4.0 - typescript: ^5.0.4 - viem: ^2.7.15 - bin: - aztec-cli: ./dest/bin/index.js - languageName: unknown - linkType: soft - "@aztec/docs@workspace:docs": version: 0.0.0-use.local resolution: "@aztec/docs@workspace:docs" @@ -371,7 +332,6 @@ __metadata: "@aztec/aztec.js": "workspace:^" "@aztec/circuit-types": "workspace:^" "@aztec/circuits.js": "workspace:^" - "@aztec/cli": "workspace:^" "@aztec/entrypoints": "workspace:^" "@aztec/ethereum": "workspace:^" "@aztec/foundation": "workspace:^" @@ -2467,7 +2427,7 @@ __metadata: languageName: node linkType: hard -"@libp2p/peer-id-factory@npm:^3.0.3, @libp2p/peer-id-factory@npm:^3.0.4, @libp2p/peer-id-factory@npm:^3.0.8": +"@libp2p/peer-id-factory@npm:^3.0.3, @libp2p/peer-id-factory@npm:^3.0.8": version: 3.0.11 resolution: "@libp2p/peer-id-factory@npm:3.0.11" dependencies: @@ -3617,15 +3577,6 @@ __metadata: languageName: node linkType: hard -"@types/lodash.startcase@npm:^4.4.7": - version: 4.4.9 - resolution: "@types/lodash.startcase@npm:4.4.9" - dependencies: - "@types/lodash": "*" - checksum: 448203f0b6d31c1af9fe8292d5417af670bee560bb0af0cac3a6047b90c2d60ba03197367c2defae21e3982c665763197343863ce7d97131efa8e13e6431fe9f - languageName: node - linkType: hard - "@types/lodash.times@npm:^4.3.7": version: 4.3.9 resolution: "@types/lodash.times@npm:4.3.9" @@ -3748,7 +3699,7 @@ __metadata: languageName: node linkType: hard -"@types/semver@npm:^7.5.0, @types/semver@npm:^7.5.2, @types/semver@npm:^7.5.4": +"@types/semver@npm:^7.5.0, @types/semver@npm:^7.5.4": version: 7.5.6 resolution: "@types/semver@npm:7.5.6" checksum: 563a0120ec0efcc326567db2ed920d5d98346f3638b6324ea6b50222b96f02a8add3c51a916b6897b51523aad8ac227d21d3dcf8913559f1bfc6c15b14d23037 @@ -5570,7 +5521,7 @@ __metadata: languageName: node linkType: hard -"core-util-is@npm:^1.0.2, core-util-is@npm:~1.0.0": +"core-util-is@npm:^1.0.2": version: 1.0.3 resolution: "core-util-is@npm:1.0.3" checksum: 9de8597363a8e9b9952491ebe18167e3b36e7707569eed0ebf14f8bba773611376466ae34575bca8cfe3c767890c859c74056084738f09d4e4a6f902b2ad7d99 @@ -5694,13 +5645,6 @@ __metadata: languageName: node linkType: hard -"data-uri-to-buffer@npm:^4.0.0": - version: 4.0.1 - resolution: "data-uri-to-buffer@npm:4.0.1" - checksum: 0d0790b67ffec5302f204c2ccca4494f70b4e2d940fea3d36b09f0bb2b8539c2e86690429eb1f1dc4bcc9e4df0644193073e63d9ee48ac9fce79ec1506e4aa4c - languageName: node - linkType: hard - "data-uri-to-buffer@npm:^6.0.0": version: 6.0.1 resolution: "data-uri-to-buffer@npm:6.0.1" @@ -7072,16 +7016,6 @@ __metadata: languageName: node linkType: hard -"fetch-blob@npm:^3.1.2, fetch-blob@npm:^3.1.4": - version: 3.2.0 - resolution: "fetch-blob@npm:3.2.0" - dependencies: - node-domexception: ^1.0.0 - web-streams-polyfill: ^3.0.3 - checksum: f19bc28a2a0b9626e69fd7cf3a05798706db7f6c7548da657cbf5026a570945f5eeaedff52007ea35c8bcd3d237c58a20bf1543bc568ab2422411d762dd3d5bf - languageName: node - linkType: hard - "file-entry-cache@npm:^6.0.1": version: 6.0.1 resolution: "file-entry-cache@npm:6.0.1" @@ -7233,15 +7167,6 @@ __metadata: languageName: node linkType: hard -"formdata-polyfill@npm:^4.0.10": - version: 4.0.10 - resolution: "formdata-polyfill@npm:4.0.10" - dependencies: - fetch-blob: ^3.1.2 - checksum: 82a34df292afadd82b43d4a740ce387bc08541e0a534358425193017bf9fb3567875dc5f69564984b1da979979b70703aa73dee715a17b6c229752ae736dd9db - languageName: node - linkType: hard - "formidable@npm:^2.1.2": version: 2.1.2 resolution: "formidable@npm:2.1.2" @@ -7931,13 +7856,6 @@ __metadata: languageName: node linkType: hard -"immediate@npm:~3.0.5": - version: 3.0.6 - resolution: "immediate@npm:3.0.6" - checksum: f9b3486477555997657f70318cc8d3416159f208bec4cca3ff3442fd266bc23f50f0c9bd8547e1371a6b5e82b821ec9a7044a4f7b944798b25aa3cc6d5e63e62 - languageName: node - linkType: hard - "import-fresh@npm:^3.2.1, import-fresh@npm:^3.3.0": version: 3.3.0 resolution: "import-fresh@npm:3.3.0" @@ -7998,7 +7916,7 @@ __metadata: languageName: node linkType: hard -"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4, inherits@npm:~2.0.3, inherits@npm:~2.0.4": +"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4, inherits@npm:~2.0.4": version: 2.0.4 resolution: "inherits@npm:2.0.4" checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 @@ -8413,13 +8331,6 @@ __metadata: languageName: node linkType: hard -"isarray@npm:~1.0.0": - version: 1.0.0 - resolution: "isarray@npm:1.0.0" - checksum: f032df8e02dce8ec565cf2eb605ea939bdccea528dbcf565cdf92bfa2da9110461159d86a537388ef1acef8815a330642d7885b29010e8f7eac967c9993b65ab - languageName: node - linkType: hard - "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -9369,18 +9280,6 @@ __metadata: languageName: node linkType: hard -"jszip@npm:^3.10.1": - version: 3.10.1 - resolution: "jszip@npm:3.10.1" - dependencies: - lie: ~3.3.0 - pako: ~1.0.2 - readable-stream: ~2.3.6 - setimmediate: ^1.0.5 - checksum: abc77bfbe33e691d4d1ac9c74c8851b5761fba6a6986630864f98d876f3fcc2d36817dfc183779f32c00157b5d53a016796677298272a714ae096dfe6b1c8b60 - languageName: node - linkType: hard - "keygrip@npm:~1.1.0": version: 1.1.0 resolution: "keygrip@npm:1.1.0" @@ -9668,15 +9567,6 @@ __metadata: languageName: node linkType: hard -"lie@npm:~3.3.0": - version: 3.3.0 - resolution: "lie@npm:3.3.0" - dependencies: - immediate: ~3.0.5 - checksum: 33102302cf19766f97919a6a98d481e01393288b17a6aa1f030a3542031df42736edde8dab29ffdbf90bebeffc48c761eb1d064dc77592ca3ba3556f9fe6d2a8 - languageName: node - linkType: hard - "lines-and-columns@npm:^1.1.6": version: 1.2.4 resolution: "lines-and-columns@npm:1.2.4" @@ -9840,13 +9730,6 @@ __metadata: languageName: node linkType: hard -"lodash.startcase@npm:^4.4.0": - version: 4.4.0 - resolution: "lodash.startcase@npm:4.4.0" - checksum: c03a4a784aca653845fe09d0ef67c902b6e49288dc45f542a4ab345a9c406a6dc194c774423fa313ee7b06283950301c1221dd2a1d8ecb2dac8dfbb9ed5606b5 - languageName: node - linkType: hard - "lodash.times@npm:^4.3.2": version: 4.3.2 resolution: "lodash.times@npm:4.3.2" @@ -10554,13 +10437,6 @@ __metadata: languageName: node linkType: hard -"node-domexception@npm:^1.0.0": - version: 1.0.0 - resolution: "node-domexception@npm:1.0.0" - checksum: ee1d37dd2a4eb26a8a92cd6b64dfc29caec72bff5e1ed9aba80c294f57a31ba4895a60fd48347cf17dd6e766da0ae87d75657dfd1f384ebfa60462c2283f5c7f - languageName: node - linkType: hard - "node-fetch@npm:^2.6.12": version: 2.7.0 resolution: "node-fetch@npm:2.7.0" @@ -10575,17 +10451,6 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^3.3.2": - version: 3.3.2 - resolution: "node-fetch@npm:3.3.2" - dependencies: - data-uri-to-buffer: ^4.0.0 - fetch-blob: ^3.1.4 - formdata-polyfill: ^4.0.10 - checksum: 06a04095a2ddf05b0830a0d5302699704d59bda3102894ea64c7b9d4c865ecdff2d90fd042df7f5bc40337266961cb6183dcc808ea4f3000d024f422b462da92 - languageName: node - linkType: hard - "node-forge@npm:^1.1.0": version: 1.3.1 resolution: "node-forge@npm:1.3.1" @@ -11039,13 +10904,6 @@ __metadata: languageName: node linkType: hard -"pako@npm:~1.0.2": - version: 1.0.11 - resolution: "pako@npm:1.0.11" - checksum: 1be2bfa1f807608c7538afa15d6f25baa523c30ec870a3228a89579e474a4d992f4293859524e46d5d87fd30fa17c5edf34dbef0671251d9749820b488660b16 - languageName: node - linkType: hard - "parent-module@npm:^1.0.0": version: 1.0.1 resolution: "parent-module@npm:1.0.1" @@ -11361,13 +11219,6 @@ __metadata: languageName: node linkType: hard -"process-nextick-args@npm:~2.0.0": - version: 2.0.1 - resolution: "process-nextick-args@npm:2.0.1" - checksum: 1d38588e520dab7cea67cbbe2efdd86a10cc7a074c09657635e34f035277b59fbb57d09d8638346bf7090f8e8ebc070c96fa5fd183b777fff4f5edff5e9466cf - languageName: node - linkType: hard - "process@npm:^0.11.10": version: 0.11.10 resolution: "process@npm:0.11.10" @@ -11655,21 +11506,6 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:~2.3.6": - version: 2.3.8 - resolution: "readable-stream@npm:2.3.8" - dependencies: - core-util-is: ~1.0.0 - inherits: ~2.0.3 - isarray: ~1.0.0 - process-nextick-args: ~2.0.0 - safe-buffer: ~5.1.1 - string_decoder: ~1.1.1 - util-deprecate: ~1.0.1 - checksum: 65645467038704f0c8aaf026a72fbb588a9e2ef7a75cd57a01702ee9db1c4a1e4b03aaad36861a6a0926546a74d174149c8c207527963e0c2d3eee2f37678a42 - languageName: node - linkType: hard - "receptacle@npm:^1.3.2": version: 1.3.2 resolution: "receptacle@npm:1.3.2" @@ -11971,13 +11807,6 @@ __metadata: languageName: node linkType: hard -"safe-buffer@npm:~5.1.0, safe-buffer@npm:~5.1.1": - version: 5.1.2 - resolution: "safe-buffer@npm:5.1.2" - checksum: f2f1f7943ca44a594893a852894055cf619c1fbcb611237fc39e461ae751187e7baf4dc391a72125e0ac4fb2d8c5c0b3c71529622e6a58f46b960211e704903c - languageName: node - linkType: hard - "safe-regex-test@npm:^1.0.0": version: 1.0.2 resolution: "safe-regex-test@npm:1.0.2" @@ -12123,13 +11952,6 @@ __metadata: languageName: node linkType: hard -"setimmediate@npm:^1.0.5": - version: 1.0.5 - resolution: "setimmediate@npm:1.0.5" - checksum: c9a6f2c5b51a2dabdc0247db9c46460152ffc62ee139f3157440bd48e7c59425093f42719ac1d7931f054f153e2d26cf37dfeb8da17a794a58198a2705e527fd - languageName: node - linkType: hard - "setprototypeof@npm:1.1.0": version: 1.1.0 resolution: "setprototypeof@npm:1.1.0" @@ -12581,15 +12403,6 @@ __metadata: languageName: node linkType: hard -"string_decoder@npm:~1.1.1": - version: 1.1.1 - resolution: "string_decoder@npm:1.1.1" - dependencies: - safe-buffer: ~5.1.0 - checksum: 9ab7e56f9d60a28f2be697419917c50cac19f3e8e6c28ef26ed5f4852289fe0de5d6997d29becf59028556f2c62983790c1d9ba1e2a3cc401768ca12d5183a5b - languageName: node - linkType: hard - "stringify-object@npm:^3.2.1": version: 3.3.0 resolution: "stringify-object@npm:3.3.0" @@ -13441,7 +13254,7 @@ __metadata: languageName: node linkType: hard -"util-deprecate@npm:^1.0.1, util-deprecate@npm:~1.0.1": +"util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2" checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 @@ -13620,13 +13433,6 @@ __metadata: languageName: node linkType: hard -"web-streams-polyfill@npm:^3.0.3": - version: 3.3.2 - resolution: "web-streams-polyfill@npm:3.3.2" - checksum: 0292f4113c1bda40d8e8ecebee39eb14cc2e2e560a65a6867980e394537a2645130e2c73f5ef6e641fd3697d2f71720ccf659aebaf69a9d5a773f653a0fdf39d - languageName: node - linkType: hard - "webidl-conversions@npm:^3.0.0": version: 3.0.1 resolution: "webidl-conversions@npm:3.0.1"