Skip to content

Commit

Permalink
build: install openzeppelin
Browse files Browse the repository at this point in the history
docs: update README.md file
  • Loading branch information
ahmedali8 committed Feb 14, 2024
1 parent 67620c6 commit 7a8c974
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -51,11 +52,12 @@
"chalk": "4.1.2",
"cross-env": "^7.0.3",
"dotenv": "^16.4.4",
"ds-test": "github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"ethers": "6.11.0",
"evm-bn": "^1.1.2",
"forge-std": "github:foundry-rs/forge-std#v1.7.5",
"forge-std": "github:foundry-rs/forge-std#v1.7.6",
"fs-extra": "^11.2.0",
"hardhat": "2.20.0",
"hardhat-contract-sizer": "2.10.0",
Expand Down
7 changes: 4 additions & 3 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -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/
ds-test/=node_modules/ds-test/src/
forge-std/=node_modules/forge-std/
hardhat/=node_modules/hardhat/
@openzeppelin/=node_modules/@openzeppelin/
2 changes: 1 addition & 1 deletion scripts/foundry/Base.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.23 <=0.9.0;

import { Script } from "forge-std/Script.sol";
import { Script } from "forge-std/src/Script.sol";

abstract contract BaseScript is Script {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/Base.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.23 <0.9.0;

import { Test } from "forge-std/Test.sol";
import { Test } from "forge-std/src/Test.sol";

import { Lock } from "contracts/Lock.sol";

Expand Down
26 changes: 21 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,11 +45,12 @@ __metadata:
chalk: "npm:4.1.2"
cross-env: "npm:^7.0.3"
dotenv: "npm:^16.4.4"
ds-test: "github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0"
eslint: "npm:^8.56.0"
eslint-config-prettier: "npm:^9.1.0"
ethers: "npm:6.11.0"
evm-bn: "npm:^1.1.2"
forge-std: "github:foundry-rs/forge-std#v1.7.5"
forge-std: "github:foundry-rs/forge-std#v1.7.6"
fs-extra: "npm:^11.2.0"
hardhat: "npm:2.20.0"
hardhat-contract-sizer: "npm:2.10.0"
Expand Down Expand Up @@ -1494,6 +1496,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"
Expand Down Expand Up @@ -3277,6 +3286,13 @@ __metadata:
languageName: node
linkType: hard

"ds-test@github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0":
version: 1.0.0
resolution: "ds-test@https://github.com/dapphub/ds-test.git#commit=e282159d5170298eb2455a6c05280ab5a73a4ef0"
checksum: 10/a63cada107d8f2775934bc580f04cb6f6509f843cb41cbc3a617e77b2e628a86d7fd858f964e7e2d6f41c3797c0e16ec2d87a6cb4c6187c5b6c2bc969ccae4b3
languageName: node
linkType: hard

"eastasianwidth@npm:^0.2.0":
version: 0.2.0
resolution: "eastasianwidth@npm:0.2.0"
Expand Down Expand Up @@ -3923,10 +3939,10 @@ __metadata:
languageName: node
linkType: hard

"forge-std@github:foundry-rs/forge-std#v1.7.5":
version: 1.7.5
resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=36c303b7ffdd842d06b1ec2744c9b9b5fb3083f3"
checksum: 10/3e21412f608e4be5136bc1fcc06e30c85554a78940385187f8d37d04db23a471f7f8d82644cf303a8b21e5d559c52b326c49a1ef43c017bb346fde19cf5f2932
"forge-std@github:foundry-rs/forge-std#v1.7.6":
version: 1.7.6
resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=ae570fec082bfe1c1f45b0acca4a2b4f84d345ce"
checksum: 10/40f626df42a21f9b14f66489d5c4de7d4e14fd96e92629c2f68dac636b454af4453fb44c0dbf9c10e0e15114b3b81cf0a98f15b5dae55b9c3d8738de48c2bea7
languageName: node
linkType: hard

Expand Down

0 comments on commit 7a8c974

Please sign in to comment.