You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
closesAztecProtocol#3540AztecProtocol#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>
Copy file name to clipboardexpand all lines: docs/docs/dev_docs/cli/cli-commands.md
+23-14
Original file line number
Diff line number
Diff line change
@@ -2,48 +2,57 @@
2
2
title: CLI Commands
3
3
---
4
4
5
+
import Tabs from '@theme/Tabs';
6
+
import TabItem from '@theme/TabItem';
7
+
5
8
Here you will find a reference to the commands available in the Aztec CLI.
6
9
7
10
## Installation
8
11
9
-
### NPM
10
-
11
-
This command will install the Aztec CLI as a dev dependency in your npm project.
12
+
### Docker
12
13
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).
16
15
17
16
:::info
18
17
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).
20
19
21
-
:::
20
+
<Tabs>
21
+
<TabItemvalue="yarn"label="yarn"default>
22
+
23
+
<code>
24
+
yarn global remove @aztec/aztec-sandbox@aztec/cli
25
+
</code>
22
26
23
-
### Docker
27
+
</TabItem>
28
+
<TabItemvalue="npm"label="npm">
24
29
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).
- If you installed the CLI globally via a node package manager, it updates to the specified version. Defaults to latest.
38
48
- It looks for a `package.json` and updates all `@aztec/` dependencies to the versions the sandbox expects.
39
49
- It looks for `Nargo.toml` at the `--contract` paths specified and updates all `aztec.nr` dependencies to the versions the sandbox expects.
40
50
- It outputs the changes.
41
51
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`.
43
52
44
53
:::info
45
54
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).
Copy file name to clipboardexpand all lines: docs/docs/dev_docs/cli/sandbox-reference.md
+2-16
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Here you will find a reference to everything available within the Sandbox.
6
6
7
7
## Installation
8
8
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.
10
10
11
11
### With Docker
12
12
@@ -16,28 +16,14 @@ You can run the Sandbox using either Docker or npm.
16
16
17
17
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`.
18
18
19
-
If you don't have the CLIinstalled 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.
20
20
21
21
To install a specific version of the sandbox, you can set the environment variable `SANDBOX_VERSION`
Copy file name to clipboardexpand all lines: docs/docs/dev_docs/getting_started/quickstart.md
+15-4
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,24 @@ In this guide, you will
14
14
## Prerequisites
15
15
16
16
- 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
+
```
18
31
19
32
## Install the Sandbox
20
33
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.
22
35
23
36
To install the latest Sandbox version, run:
24
37
@@ -30,8 +43,6 @@ This will attempt to run the Sandbox on ` localhost:8080`, so you will have to m
30
43
31
44
This command will also install the CLI if a node package version of the CLI isn't found locally.
32
45
33
-
Alternatively, you can [run the sandbox as an npm package](../cli/sandbox-reference.md#with-npm).
34
-
35
46
## Deploy a contract using the CLI
36
47
37
48
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:
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:
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`.
36
34
37
35
## Compile your contract
38
36
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).
Copy file name to clipboardexpand all lines: docs/docs/dev_docs/tutorials/writing_dapp/testing.md
+1-6
Original file line number
Diff line number
Diff line change
@@ -14,18 +14,13 @@ Start by installing our test runner, in this case jest:
14
14
yarn add -D jest
15
15
```
16
16
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).
22
18
23
19
## Test setup
24
20
25
21
Create a new file `src/index.test.mjs` with the imports we'll be using and an empty test suite to begin with:
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).
214
214
215
215
[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.
216
216
217
217
For more detail on execution contexts, see [Contract Communication](../../concepts/foundation/communication/main).
218
218
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.
220
224
221
225
### Note on private state
222
226
@@ -309,7 +313,7 @@ First, storage is initialized. Then it checks whether the calling contract (`con
309
313
310
314
##### Authorizing token spends
311
315
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.
313
317
314
318
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`.
315
319
@@ -360,7 +364,7 @@ The function returns `1` to indicate successful execution.
0 commit comments