From 306698f67d543a3f459603c8c846174e5767956c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Wed, 23 Aug 2023 10:15:13 -0300 Subject: [PATCH] Add OZ installation example (#570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds an example of how to properly install the OZ Contracts for Cairo library, while showing how to use the `tag` parameter for dependencies. This PR is better merged by next week, when the OZ release tag is live. --------- Signed-off-by: Martín Triay Co-authored-by: Marek Kaput --- website/docs/guides/dependencies.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/website/docs/guides/dependencies.md b/website/docs/guides/dependencies.md index 48ef243e5..ba42bd74e 100644 --- a/website/docs/guides/dependencies.md +++ b/website/docs/guides/dependencies.md @@ -23,19 +23,26 @@ alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.g In fact, it is always good to pin Git dependencies to concrete commits, otherwise Scarb would try to update this dependency each time it is executed. You can achieve this using one of the following extra fields that you can pass along `git`: `branch`, `tag` and `rev`. -For example, in this guide we will pin to a concrete commit hash: + +Actually this is how the OpenZeppelin Contracts for Cairo library is released, since the `main` branch is not stable. ```toml [dependencies] -alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "27fbf5b" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.7.0-rc.0" } ``` ::: info -In the future this paragraph will be irrelevant, because Scarb will maintain a lockfile. +In the future commit pinning will not be needed because Scarb will maintain a lockfile. We track this feature in this issue: [#126](https://github.com/software-mansion/scarb/issues/126). ::: -Note, that if you want to add more dependencies, you do not have to add `[dependencies]` for each package separately. +Note, that if you want to add more dependencies, you do not have to add `[dependencies]` for each package separately. For example: + +```toml +[dependencies] +alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.7.0-rc.0" } +``` Now, run `scarb build`, and Scarb will fetch new dependencies and all of their dependencies. Then it will compile your package with all of these packages included: @@ -43,6 +50,7 @@ Then it will compile your package with all of these packages included: ```shell $ scarb build Updating git repository https://github.com/keep-starknet-strange/alexandria + Updating git repository https://github.com/OpenZeppelin/cairo-contracts Compiling hello_world v0.1.0 (/path/to/package/hello_world/Scarb.toml) Finished release target(s) in 4 seconds ```