From fe9ba5cc72fb76cb0c092552bc3885cb83eb31ee Mon Sep 17 00:00:00 2001 From: Ahmed Ali Date: Wed, 14 Feb 2024 16:31:50 +0000 Subject: [PATCH] build: install openzeppelin docs: update README.md file --- README.md | 21 +++++++++++++++++---- package.json | 1 + remappings.txt | 3 ++- yarn.lock | 8 ++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cfb7e95..5d9f216 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ A Foundry + Hardhat based template for developing Solidity smart contracts, with deploy smart contracts - [Forge Std](https://github.com/foundry-rs/forge-std): collection of helpful contracts and cheatcodes for testing -- [Solhint Community](https://github.com/solhint-community/solhint-community): code linter -- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code - formatter +- [Solhint](https://github.com/protofire/solhint): linter for Solidity code ## Table of Contents @@ -78,7 +76,7 @@ $ cd my-project $ forge init --template ahmedali8/foundry-hardhat-template ``` -Recommended node version is v18.x +Recommended node version is v20.x If you have [nvm](https://github.com/nvm-sh/nvm) then run: @@ -145,6 +143,21 @@ Note though that by default it injects `.env.example` env variables into github You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.yml). +## Installing Dependencies + +Foundry typically uses git submodules to manage dependencies, but this template uses Node.js +packages because [submodules don't scale](https://twitter.com/PaulRBerg/status/1736695487057531328). + +This is how to install dependencies: + +1. Install the dependency using your preferred package manager, e.g. + `yarn add dependency-name:dependency-url` + - Use this syntax to install from GitHub: `yarn add repo-name@github:username/repo-name#tag-name` +2. Add a remapping for the dependency in [remappings.txt](./remappings.txt), e.g. + `dependency-name=node_modules/dependency-name` + +Note that OpenZeppelin Contracts is pre-installed, so you can follow that as an example. + # Usage ### Pre Requisites diff --git a/package.json b/package.json index 316bfcb..bb1d3b6 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@nomicfoundation/hardhat-network-helpers": "^1.0.10", "@nomicfoundation/hardhat-toolbox": "^4.0.0", "@nomicfoundation/hardhat-verify": "^2.0.4", + "@openzeppelin/contracts": "^5.0.1", "@primitivefi/hardhat-dodoc": "^0.2.3", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@typechain/ethers-v6": "^0.5.1", diff --git a/remappings.txt b/remappings.txt index 156bcd4..31a8fca 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,3 +1,4 @@ ds-test/=node_modules/forge-std/lib/ds-test/src/ forge-std/=node_modules/forge-std/src/ -hardhat/=node_modules/hardhat/ \ No newline at end of file +hardhat/=node_modules/hardhat/ +@openzeppelin/=node_modules/@openzeppelin/ \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 3b1d265..5b09435 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,6 +30,7 @@ __metadata: "@nomicfoundation/hardhat-network-helpers": "npm:^1.0.10" "@nomicfoundation/hardhat-toolbox": "npm:^4.0.0" "@nomicfoundation/hardhat-verify": "npm:^2.0.4" + "@openzeppelin/contracts": "npm:^5.0.1" "@primitivefi/hardhat-dodoc": "npm:^0.2.3" "@trivago/prettier-plugin-sort-imports": "npm:^4.3.0" "@typechain/ethers-v6": "npm:^0.5.1" @@ -1494,6 +1495,13 @@ __metadata: languageName: node linkType: hard +"@openzeppelin/contracts@npm:^5.0.1": + version: 5.0.1 + resolution: "@openzeppelin/contracts@npm:5.0.1" + checksum: 10/d0a9ae98c2486eb3c4a3fa31cb9d4e8ea21aef3f1d0d4709a6c8550be0133ccfbad541e524980356b802c10c47de24c49844fac1b746980dbd5b560bd1762301 + languageName: node + linkType: hard + "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0"