Skip to content

Commit bd5355f

Browse files
critesjoshalexghr
andauthored
chore(docs): remove references to npm packages (AztecProtocol#3676)
This PR removes references to installing @aztec/aztec-sandbox and @aztec/cli via NPM in favor of installing via Docker. It also updates notes about types imports for the token contract contract tutorial and the token reference in the "writing a dapp" tutorial. Note: recent additions broke the [Quickstart guide](https://docs.aztec.network/dev_docs/getting_started/quickstart). The docs got out of sync with the latest version because docs are always tested against master. This should be fixed with the new release going out tomorrow morning, so I'm not bothering to change it now, but we should test the Quickstart page again once the new release goes out. closes AztecProtocol#3540 AztecProtocol#3541 # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --------- Co-authored-by: Alex Gherghisan <alexghr@users.noreply.github.com>
1 parent 4902f82 commit bd5355f

File tree

11 files changed

+90
-137
lines changed

11 files changed

+90
-137
lines changed

docs/docs/dev_docs/cli/cli-commands.md

+23-14
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,57 @@
22
title: CLI Commands
33
---
44

5+
import Tabs from '@theme/Tabs';
6+
import TabItem from '@theme/TabItem';
7+
58
Here you will find a reference to the commands available in the Aztec CLI.
69

710
## Installation
811

9-
### NPM
10-
11-
This command will install the Aztec CLI as a dev dependency in your npm project.
12+
### Docker
1213

13-
```bash
14-
npm install --save-dev @aztec/cli
15-
```
14+
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).
1615

1716
:::info
1817

19-
You can install the CLI globally, but it is recommended that you install the CLI as a local dependency in your project. This will make it easier to keep the CLI version in sync with the sandbox version.
18+
The `@aztec/aztec-sandbox` and `@aztec/cli` packages published to npm **should not be used**, in favor of Docker. If you've installed the sandbox or the CLI via NPM, **uninstall** them and remove them from your project dependencies and [install via Docker](./sandbox-reference.md#with-docker).
2019

21-
:::
20+
<Tabs>
21+
<TabItem value="yarn" label="yarn" default>
22+
23+
<code>
24+
yarn global remove @aztec/aztec-sandbox @aztec/cli
25+
</code>
2226

23-
### Docker
27+
</TabItem>
28+
<TabItem value="npm" label="npm">
2429

25-
The CLI will be installed automatically via Docker if it is not already found locally, by running the command to install and start the sandbox, [instructions here](./sandbox-reference.md#with-docker).
30+
<code>
31+
npm -g uninstall @aztec/aztec-sandbox @aztec/cli
32+
</code>
33+
34+
</TabItem>
35+
</Tabs>
36+
:::
2637

2738
## Update
2839

2940
The CLI comes with an update command.
3041

3142
```bash
32-
npx @aztec/cli@latest update . --contract src/contract1 --contract src/contract2
43+
aztec-cli update . --contract src/contract1 --contract src/contract2
3344
```
3445

3546
This command does a few things to manage updates:
3647

37-
- If you installed the CLI globally via a node package manager, it updates to the specified version. Defaults to latest.
3848
- It looks for a `package.json` and updates all `@aztec/` dependencies to the versions the sandbox expects.
3949
- It looks for `Nargo.toml` at the `--contract` paths specified and updates all `aztec.nr` dependencies to the versions the sandbox expects.
4050
- It outputs the changes.
4151

42-
The sandbox must be running for the update command to work unless there the project defines `@aztec/aztec-sandbox` as a dependency, in which case the command will compare against the version listed in `package.json`.
4352

4453
:::info
4554

46-
If you installed the CLI via Docker (with the sandbox install Docker command), the `aztec-cli update` command won't work. You can update the CLI it by [running the command again](./sandbox-reference.md#installation-with-docker).
55+
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).
4756

4857
:::
4958

docs/docs/dev_docs/cli/sandbox-reference.md

+2-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Here you will find a reference to everything available within the Sandbox.
66

77
## Installation
88

9-
You can run the Sandbox using either Docker or npm.
9+
You can run the Sandbox using Docker. See the [Quickstart](../getting_started/quickstart.md#install-docker) for instructions on installing Docker.
1010

1111
### With Docker
1212

@@ -16,28 +16,14 @@ You can run the Sandbox using either Docker or npm.
1616

1717
This will attempt to run the Sandbox on ` localhost:8080`. You can change the port defined in `./.aztec/docker-compose.yml`. Running the command again will overwrite any changes made to the `docker-compose.yml`.
1818

19-
If you don't have the CLI installed via a node package manager, this command will also install or update the CLI.
19+
This command also installs or updates the CLI. If you have previously installed the CLI via a node package manager, you will need to uninstall it and remove it from your project dependencies and install it via Docker.
2020

2121
To install a specific version of the sandbox, you can set the environment variable `SANDBOX_VERSION`
2222

2323
```bash
2424
SANDBOX_VERSION=<version> /bin/bash -c "$(curl -fsSL 'https://sandbox.aztec.network')"
2525
```
2626

27-
NOTE: The sandbox version should be the same as your `@aztec/cli` package to ensure compatibility.
28-
29-
### With npm
30-
31-
You can download and run the Sandbox package directly if you have nodejs 18 or higher installed.
32-
33-
You will also need an Ethereum node like Anvil or Hardhat running locally on port 8545.
34-
35-
```bash
36-
npx @aztec/aztec-sandbox @aztec/cli
37-
```
38-
39-
You can read [this tutorial on how to use the npm package](../tutorials/testing.md#running-sandbox-in-the-nodejs-process)
40-
4127
## Running
4228

4329
The installation command will run the sandbox, and once installed you can run like so:

docs/docs/dev_docs/contracts/deploying.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Once you have [compiled](./compiling.md) your contracts you can proceed to deplo
44

55
## Prerequisites
66

7-
- aztec-cli installed (go to [CLI main section](../cli/main.md) for installation instructions)
7+
- `aztec-cli` installed (go to [CLI main section](../cli/main.md) for installation instructions)
88
- contract artifacts ready (go to [Compiling contracts section](./compiling.md) for instructions on how to compile contracts)
99
- aztec-sandbox running (go to [Sandbox section](../getting_started/quickstart.md) for instructions on how to install and run the sandbox)
1010

docs/docs/dev_docs/debugging/main.md

-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ Prepend the command to start the sandbox with `DEBUG=aztec:*` to log everything
5252
```bash
5353
# Using the docker-compose.yml setup
5454
cd ~./aztec && DEBUG=aztec:* docker-compose up
55-
56-
# or if you're using the npm package
57-
DEBUG=aztec:* aztec-sandbox
5855
```
5956

6057
Alternatively you can update the `DEBUG` environment variable in docker-compose.yml and start the sandbox normally.

docs/docs/dev_docs/getting_started/quickstart.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,24 @@ In this guide, you will
1414
## Prerequisites
1515

1616
- Node.js >= v18 (recommend installing with [nvm](https://github.com/nvm-sh/nvm))
17-
- Docker and Docker Compose (Docker Desktop under WSL2 on windows)
17+
18+
## Install Docker
19+
20+
See this page of the Docker docs for instructions on how to install Docker Desktop for your operating system: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/)
21+
22+
Once you have Docker installed, make sure it is running by opening the Docker Desktop application.
23+
24+
### Note on Linux
25+
26+
If you are running Linux, you will need to set the context (because Docker Desktop runs in a VM by default). See [this page](https://docs.docker.com/desktop/faqs/linuxfaqs/#what-is-the-difference-between-docker-desktop-for-linux-and-docker-engine) for more information. You can do this by running:
27+
28+
```bash
29+
docker context use default
30+
```
1831

1932
## Install the Sandbox
2033

21-
You can run the Sandbox using either Docker or npm. In this guide we will use Docker, but you can learn more about alternative installation methods [here](../cli/sandbox-reference.md).
34+
You can run the Sandbox using Docker.
2235

2336
To install the latest Sandbox version, run:
2437

@@ -30,8 +43,6 @@ This will attempt to run the Sandbox on ` localhost:8080`, so you will have to m
3043

3144
This command will also install the CLI if a node package version of the CLI isn't found locally.
3245

33-
Alternatively, you can [run the sandbox as an npm package](../cli/sandbox-reference.md#with-npm).
34-
3546
## Deploy a contract using the CLI
3647

3748
The sandbox is preloaded with multiple accounts. Let's assign them to shell variables. Run the following in your terminal, so we can refer to the accounts as $ALICE and $BOB from now on:

docs/docs/dev_docs/tutorials/token_portal/setup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Now inside `packages` create a new directory called `aztec-contracts`
4343

4444
Inside `aztec-contracts`, create the following file structure:
4545

46-
```
46+
```tree
4747
aztec-contracts
4848
└── token_bridge
4949
├── Nargo.toml
@@ -68,7 +68,7 @@ safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#incl
6868

6969
We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this:
7070

71-
```
71+
```tree
7272
aztec-contracts
7373
└── token_bridge
7474
├── Nargo.toml

docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,26 @@ Then, open the `contracts/token/Nargo.toml` configuration file, and add the `azt
2020
```toml
2121
[dependencies]
2222
aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" }
23-
value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/value-note"}
23+
authwit = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/authwit"}
2424
safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/safe-math"}
2525
```
2626

2727
Last, copy-paste the code from the `Token` contract into `contracts/token/main.nr`:
2828

2929
#include_code token_all yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust
3030

31-
The `Token` contract also requires a helper file. Copy it too:
31+
### Helper files
3232

33-
Create `contracts/token/types.nr` and copy-paste the following:
34-
35-
#include_code token_types_all yarn-project/noir-contracts/src/contracts/token_contract/src/types/transparent_note.nr rust
33+
The `Token` contract also requires some helper files. You can view the files [here](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/noir-contracts/src/contracts/token_contract/src). Copy the `types.nr` and the `types` folder into `contracts/token/src`.
3634

3735
## Compile your contract
3836

39-
We'll now use the [Aztec CLI](../../cli/main.md) to [compile](../../contracts/compiling.md) our project. If you haven't installed the CLI already, you can install it locally to your project running:
40-
41-
```sh
42-
yarn add -D @aztec/cli
43-
```
37+
We'll now use the [Aztec CLI](../../cli/main.md) to [compile](../../contracts/compiling.md) our project. If you haven't installed the CLI already, it comes with the sandbox, so you can install it via the [Sandbox install command](../../cli/sandbox-reference.md#installation).
4438

4539
Now run the following from your project root:
4640

4741
```sh
48-
yarn aztec-cli compile contracts/token
42+
aztec-cli compile contracts/token
4943
```
5044

5145
:::info

docs/docs/dev_docs/tutorials/writing_dapp/testing.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ Start by installing our test runner, in this case jest:
1414
yarn add -D jest
1515
```
1616

17-
We'll also be running our Sandbox within the test suite, to avoid polluting a global instance, so we'll need to install the Sandbox itself as a dependency as well:
18-
19-
```sh
20-
yarn add -D @aztec/aztec-sandbox
21-
```
17+
We'll need to [install and run the Sandbox](../../cli/sandbox-reference.md#installation).
2218

2319
## Test setup
2420

2521
Create a new file `src/index.test.mjs` with the imports we'll be using and an empty test suite to begin with:
2622

2723
```js
28-
import { createSandbox } from "@aztec/aztec-sandbox";
2924
import { Contract, createAccount } from "@aztec/aztec.js";
3025
import TokenContractArtifact from "../contracts/token/target/Token.json" assert { type: "json" };
3126

docs/docs/dev_docs/tutorials/writing_token_contract.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,17 @@ Just below the contract definition, add the following imports:
210210

211211
#include_code imports /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust
212212

213-
We are importing the Option type, note utilities, context (for managing private and public execution contexts), `state_vars` for helping manage state, `compute_selector` for helping with calling public functions from private functions, and `types` for data manipulation. We also import the `authwit` [library](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/auth.nr) to handle token authorizations from [Account Contracts](../../concepts/foundation/accounts/main). Check out the Account Contract with AuthWitness [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/main.nr).
213+
We are importing the Option type, items from the `value_note` library to help manage private value storage, note utilities, context (for managing private and public execution contexts), `state_vars` for helping manage state, `types` for data manipulation and `oracle` for help passing data from the private to public execution context. We also import the `auth` [library](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/auth.nr) to handle token authorizations from [Account Contracts](../../concepts/foundation/accounts/main). Check out the Account Contract with AuthWitness [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/main.nr).
214214

215215
[SafeU120](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/safe-math/src/safe_u120.nr) is a library to do safe math operations on unsigned integers that protects against overflows and underflows.
216216

217217
For more detail on execution contexts, see [Contract Communication](../../concepts/foundation/communication/main).
218218

219-
We are also importing types from a `types.nr` file. The main thing to note from this types file is the `TransparentNote` definition. This defines how the contract moves value from the public domain into the private domain. It is similar to the `value_note` that we imported, but with some modifications namely, instead of a defined `owner`, it allows anyone that can produce the pre-image to the stored `secret_hash` to spend the note.
219+
### Types files
220+
221+
We are also importing types from a `types.nr` file, which imports types from the `types` folder. You can view them [here](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/noir-contracts/src/contracts/token_contract/src).
222+
223+
The main thing to note from this types folder is the `TransparentNote` definition. This defines how the contract moves value from the public domain into the private domain. It is similar to the `value_note` that we imported, but with some modifications namely, instead of a defined `owner`, it allows anyone that can produce the pre-image to the stored `secret_hash` to spend the note.
220224

221225
### Note on private state
222226

@@ -309,7 +313,7 @@ First, storage is initialized. Then it checks whether the calling contract (`con
309313

310314
##### Authorizing token spends
311315

312-
If the `msg_sender` is **NOT** the same as the account to debit from, the function checks that the account has authorized the `msg_sender` contract to debit tokens on its behalf. This check is done by computing the function selector that needs to be authorized (in this case, the `shield` function), computing the hash of the message that the account contract has approved. This is a hash of the contract that is approved to spend (`context.msg_sender`), the token contract that can be spent from (`context.this_address()`), the `selector`, the account to spend from (`from.address`), the `amount`, the `secret_hash` and a `nonce` to prevent multiple spends. This hash is passed to `assert_current_call_valid_authwit_public` to ensure that the Account Contract has approved tokens to be spent on it's behalf.
316+
If the `msg_sender` is **NOT** the same as the account to debit from, the function checks that the account has authorized the `msg_sender` contract to debit tokens on its behalf. This check is done by computing the function selector that needs to be authorized (in this case, the `shield` function), computing the hash of the message that the account contract has approved. This is a hash of the contract that is approved to spend (`context.msg_sender`), the token contract that can be spent from (`context.this_address()`), the `selector`, the account to spend from (`from.address`), the `amount`, the `secret_hash` and a `nonce` to prevent multiple spends. This hash is passed to `assert_valid_public_message_for` to ensure that the Account Contract has approved tokens to be spent on it's behalf.
313317

314318
If the `msg_sender` is the same as the account to debit tokens from, the authorization check is bypassed and the function proceeds to update the account's `public_balance` and adds a new `TransparentNote` to the `pending_shields`.
315319

@@ -360,7 +364,7 @@ The function returns `1` to indicate successful execution.
360364

361365
This private function enables un-shielding of private `ValueNote`s stored in `balances` to any Aztec account's `public_balance`.
362366

363-
After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. See [the Authorizing token spends section](#authorizing-token-spends) above for more detail--the only difference being that `assert_current_call_valid_authwit` is modified to work specifically in the private context. After the authorization check, the sender's private balance is decreased using the `decrement` helper function for the `value_note` library. Then it stages a public function call on this contract ([`_increase_public_balance`](#_increase_public_balance)) to be executed in the [public execution phase](#execution-contexts) of transaction execution. `_increase_public_balance` is marked as an `internal` function, so can only be called by this token contract.
367+
After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. See [the Authorizing token spends section](#authorizing-token-spends) above for more detail--the only difference being that `assert_valid_message_for` is modified to work specifically in the private context. After the authorization check, the sender's private balance is decreased using the `decrement` helper function for the `value_note` library. Then it stages a public function call on this contract ([`_increase_public_balance`](#_increase_public_balance)) to be executed in the [public execution phase](#execution-contexts) of transaction execution. `_increase_public_balance` is marked as an `internal` function, so can only be called by this token contract.
364368

365369
The function returns `1` to indicate successful execution.
366370

@@ -370,7 +374,7 @@ The function returns `1` to indicate successful execution.
370374

371375
This private function enables private token transfers between Aztec accounts.
372376

373-
After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. See [the Authorizing token spends section](#authorizing-token-spends) above for more detail--the only difference being that `assert_current_call_valid_authwit` is modified to work specifically in the private context. After authorization, the function gets the current balances for the sender and recipient and decrements and increments them, respectively, using the `value_note` helper functions.
377+
After initializing storage, the function checks that the `msg_sender` is authorized to spend tokens. See [the Authorizing token spends section](#authorizing-token-spends) above for more detail--the only difference being that `assert_valid_message_for` is modified to work specifically in the private context. After authorization, the function gets the current balances for the sender and recipient and decrements and increments them, respectively, using the `value_note` helper functions.
374378

375379
#include_code transfer /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust
376380

0 commit comments

Comments
 (0)