From b38482b02622f07e438e41658c5ce8c79eb07bd7 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 16:01:56 -0300 Subject: [PATCH 1/3] feat(docs): Load current aztec version for aztec.nr Instead of pointing the user to install aztec.nr from master, we point them to the last released version. This ensures that any unreleased breaking changes to aztec.nr won't hit the user. --- docs/docs/dev_docs/contracts/syntax/main.md | 17 +++++++------- .../dapps/tutorials/contract_deployment.md | 13 ++++++----- .../getting_started/noir_contracts.md | 9 ++++---- .../token_contract_tutorial.md | 15 ++++++------ docs/docusaurus.config.js | 23 ++++++++++++++++++- docs/src/components/Version/index.js | 1 + docs/src/theme/MDXComponents.js | 1 + 7 files changed, 53 insertions(+), 26 deletions(-) diff --git a/docs/docs/dev_docs/contracts/syntax/main.md b/docs/docs/dev_docs/contracts/syntax/main.md index ff85d8a5b65f..c89e97a1a2db 100644 --- a/docs/docs/dev_docs/contracts/syntax/main.md +++ b/docs/docs/dev_docs/contracts/syntax/main.md @@ -18,21 +18,22 @@ Aztec.nr contains abstractions which remove the need to understand the low-level To import Aztec.nr into your Aztec contract project, simply include it as a dependency. For example: -```toml -[package] +import { AztecPackagesVersion } from "@site/src/components/Version"; + +{`[package] name = "token_contract" authors = [""] compiler_version = "0.1" type = "contract" - + [dependencies] # Framework import -aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/aztec" } - +aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/aztec" } + # Utility dependencies -value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/value-note"} -safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/safe-math"} -``` +value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/value-note"} +safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/safe-math"} +`} :::info Note: currently the dependency name ***MUST*** be `aztec`. The framework expects this namespace to be available when compiling into contracts. This limitation may be removed in the future. diff --git a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md index 90b607a846ce..fc940f98cf82 100644 --- a/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md +++ b/docs/docs/dev_docs/dapps/tutorials/contract_deployment.md @@ -17,12 +17,13 @@ nargo new --contract token Then, open the `contracts/token/Nargo.toml` configuration file, and add the `aztec.nr` and `value_note` libraries as dependencies: -```toml -[dependencies] -aztec = { git="https://github.com/AztecProtocol/aztec-nr", tag="master", directory="aztec" } -value_note = { git="https://github.com/AztecProtocol/aztec-nr", tag="master", directory="value-note" } -safe_math = { git="https://github.com/AztecProtocol/aztec-nr", tag="master", directory="safe-math" } -``` +import { AztecPackagesVersion } from "@site/src/components/Version"; + +{`[dependencies] +aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/aztec" } +value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/value-note"} +safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/safe-math"} +`} Last, copy-paste the code from the `Token` contract into `contracts/token/main.nr`: diff --git a/docs/docs/dev_docs/getting_started/noir_contracts.md b/docs/docs/dev_docs/getting_started/noir_contracts.md index 90d11598e924..65adc75609fd 100644 --- a/docs/docs/dev_docs/getting_started/noir_contracts.md +++ b/docs/docs/dev_docs/getting_started/noir_contracts.md @@ -59,16 +59,17 @@ Before writing the contracts, we must add the aztec.nr library. This adds smart 3. Add aztec.nr library as a dependency to your noir project. Open Nargo.toml that is in the `contracts/example_contract` folder, and add the dependency section as follows: -``` -[package] +import { AztecPackagesVersion } from "@site/src/components/Version"; + +{`[package] name = "example_contract" authors = [""] compiler_version = "0.1" type = "contract" - + [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/aztec" } -``` +`} :::note You may need to update your dependencies depending on the contract that you are writing. For example, the token contract [imports more](../getting_started/token_contract_tutorial#project-setup). diff --git a/docs/docs/dev_docs/getting_started/token_contract_tutorial.md b/docs/docs/dev_docs/getting_started/token_contract_tutorial.md index 3b34a3f34d8b..d53e63c161db 100644 --- a/docs/docs/dev_docs/getting_started/token_contract_tutorial.md +++ b/docs/docs/dev_docs/getting_started/token_contract_tutorial.md @@ -80,18 +80,19 @@ Your project should look like this: Add the following dependencies to your Nargo.toml file, below the package information: -```toml -[package] +import { AztecPackagesVersion } from "@site/src/components/Version"; + +{`[package] name = "token_contract" authors = [""] compiler_version = "0.1" type = "contract" - + [dependencies] -aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/aztec" } -value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/value-note"} -safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="master", directory="yarn-project/aztec-nr/safe-math"} -``` +aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/aztec" } +value_note = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/value-note"} +safe_math = { git="https://github.com/AztecProtocol/aztec-packages/", tag="${AztecPackagesVersion()}", directory="yarn-project/aztec-nr/safe-math"} +`} ## Contract Interface diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 185e49035cf2..7354306c98f9 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -88,7 +88,17 @@ const config = { const noirVersion = JSON.parse( fs.readFileSync(noirVersionPath).toString() ).tag; - return { noir: noirVersion }; + const aztecVersionPath = path.resolve( + __dirname, + "../.release-please-manifest.json" + ); + const aztecVersion = JSON.parse( + fs.readFileSync(aztecVersionPath).toString() + )["."]; + return { + noir: noirVersion, + "aztec-packages": `aztec-packages-v${aztecVersion}`, + }; } catch (err) { throw new Error( `Error loading Noir version from noir-compiler in docusaurus build. Check load-versions in docusaurus.config.js.\n${err}` @@ -236,6 +246,17 @@ const config = { className: "code-block-error-line", line: "this-will-error", }, + // This could be used to have release-please modify the current version in code blocks. + // However doing so requires to manually add each md file to release-please-config.json/extra-files + // which is easy to forget an error prone, so instead we rely on the AztecPackagesVersion() function. + { + line: "x-release-please-version", + block: { + start: "x-release-please-start-version", + end: "x-release-please-end", + }, + className: "not-allowed-to-be-empty", + }, ], }, }), diff --git a/docs/src/components/Version/index.js b/docs/src/components/Version/index.js index 47f934142430..01bf315f2221 100644 --- a/docs/src/components/Version/index.js +++ b/docs/src/components/Version/index.js @@ -8,3 +8,4 @@ export default function Version({ what }) { } export const NoirVersion = () => Versions()["noir"]; +export const AztecPackagesVersion = () => Versions()["aztec-packages"]; \ No newline at end of file diff --git a/docs/src/theme/MDXComponents.js b/docs/src/theme/MDXComponents.js index 3d40619c5cc6..78ee1c4fb222 100644 --- a/docs/src/theme/MDXComponents.js +++ b/docs/src/theme/MDXComponents.js @@ -9,6 +9,7 @@ export default { ...MDXComponents, Version, NoirVersion, + AztecPackagesVersion, InstallNargoInstructions, CodeBlock, }; From a1e3c092a32608fc5461897bce49f3da060b8f75 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 16:17:47 -0300 Subject: [PATCH 2/3] Add missing import --- docs/src/theme/MDXComponents.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/src/theme/MDXComponents.js b/docs/src/theme/MDXComponents.js index 78ee1c4fb222..4593ab51e685 100644 --- a/docs/src/theme/MDXComponents.js +++ b/docs/src/theme/MDXComponents.js @@ -1,6 +1,9 @@ import React from "react"; import MDXComponents from "@theme-original/MDXComponents"; -import Version, { NoirVersion } from "@site/src/components/Version"; +import Version, { + NoirVersion, + AztecPackagesVersion, +} from "@site/src/components/Version"; import InstallNargoInstructions from "@site/src/components/InstallNargoInstructions"; import CodeBlock from "@theme/CodeBlock"; From 927da9255f6e0b30ba5982f44bb8dbdf32690696 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 19:17:05 -0300 Subject: [PATCH 3/3] Update rebuild patterns for docs --- build_manifest.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build_manifest.json b/build_manifest.json index c64447145c64..9379e39a965b 100644 --- a/build_manifest.json +++ b/build_manifest.json @@ -90,7 +90,9 @@ "rebuildPatterns": [ "^docs/", "^.*.cpp$", - "^.*.ts$" + "^.*.ts$", + "^.release-please-manifest.json$", + "^.*/noir-version.json$" ] }, "l1-contracts": {