Skip to content

Commit f245900

Browse files
authored
Initial commit
0 parents  commit f245900

32 files changed

+13017
-0
lines changed

.commitlintrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"extends": [
3+
"@commitlint/config-conventional"
4+
],
5+
"rules": {
6+
"subject-case": [
7+
2,
8+
"always",
9+
"sentence-case"
10+
],
11+
"type-enum": [
12+
2,
13+
"always",
14+
[
15+
"build",
16+
"ci",
17+
"chore",
18+
"docs",
19+
"feat",
20+
"fix",
21+
"perf",
22+
"refactor",
23+
"revert",
24+
"style",
25+
"test"
26+
]
27+
]
28+
}
29+
}

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
artifacts
3+
cache
4+
coverage*
5+
gasReporterOutput.json
6+
typechain
7+
lib*

.eslintrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"es2021": true,
5+
"mocha": true,
6+
"node": true
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"extends": [
10+
"standard",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:prettier/recommended",
13+
"plugin:node/recommended"
14+
],
15+
"parser": "@typescript-eslint/parser",
16+
"parserOptions": {
17+
"ecmaVersion": 12
18+
},
19+
"rules": {
20+
"node/no-unsupported-features/es-syntax": ["error", { "ignores": ["modules"] }]
21+
},
22+
"settings": {
23+
"node": {
24+
"tryExtensions": [".js", ".json", ".ts", ".d.ts"]
25+
}
26+
}
27+
}

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help improve this repo
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
- **Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
- **To reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
- **Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
- **Additional context**
24+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this repo
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
- **Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
- **Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
- **Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
- **Additional context**
19+
Add any other context or screenshots about the feature request here.

.github/workflows/checks.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Format and lint checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
format:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
with:
16+
submodules: recursive
17+
- name: Setup Node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 14.x
21+
- name: Get yarn cache directory path
22+
id: yarn-cache-dir-path
23+
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
- uses: actions/cache@v2
25+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
26+
with:
27+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
28+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-yarn-
31+
- name: Install dependencies
32+
run: yarn install --frozen-lockfile
33+
- name: Run format checks
34+
run: yarn format:check
35+
- name: Run lint
36+
run: yarn lint

.github/workflows/tests.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
with:
16+
submodules: recursive
17+
- name: Setup Node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 14.x
21+
- name: Get yarn cache directory path
22+
id: yarn-cache-dir-path
23+
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
- uses: actions/cache@v2
25+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
26+
with:
27+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
28+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-yarn-
31+
- name: Install dev dependencies
32+
run: yarn install --frozen-lockfile
33+
- name: Install Foundry
34+
uses: onbjerg/foundry-toolchain@v1
35+
with:
36+
version: nightly
37+
- name: Compile code (Hardhat)
38+
run: yarn compile:force
39+
- name: Run TypeScript/Waffle tests
40+
run: yarn test
41+
- name: Run Solidity/Forge tests
42+
run: forge test

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
.env
3+
.env*
4+
coverage
5+
coverage.json
6+
typechain
7+
.DS_Store
8+
9+
# Hardhat files
10+
cache
11+
artifacts
12+
abis/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint
5+
yarn format:check

.npmignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
node_modules
2+
.env
3+
.env*
4+
coverage
5+
coverage.json
6+
typechain
7+
8+
# Hardhat files
9+
cache
10+
artifacts
11+
12+
hardhat.config.ts
13+
contracts/test
14+
test/
15+
16+
# Others
17+
lib
18+
.DS_Store

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
artifacts
3+
cache
4+
coverage*
5+
gasReporterOutput.json
6+
typechain
7+
lib*

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"printWidth": 120
3+
}

.solcover.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
silent: true,
3+
measureStatementCoverage: true,
4+
measureFunctionCoverage: true,
5+
skipFiles: ["interfaces", "test"],
6+
configureYulOptimizer: true,
7+
};

.solhint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"rules": {
4+
"compiler-version": ["error", "^0.8.0"],
5+
"func-visibility": [{ "ignoreConstructors": true }],
6+
"func-name-mixedcase": "off",
7+
"reason-string": "off",
8+
"var-name-mixedcase": "off"
9+
}
10+
}

.solhintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
test
3+
demo.sol
4+
*.t.sol

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 LooksRare
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Solidity template
2+
3+
This is a template for GitHub repos with Solidity smart contracts using Forge and Hardhat. This template is used by the LooksRare team for Solidity-based repos. Feel free to use or get inspired to build your own templates!
4+
5+
## About this repo
6+
7+
### Structure
8+
9+
It is a hybrid [Hardhat](https://hardhat.org/) repo that also requires [Foundry](https://book.getfoundry.sh/index.html) to run Solidity tests powered by the [ds-test library](https://github.com/dapphub/ds-test/).
10+
11+
> To install Foundry, please follow the instructions [here](https://book.getfoundry.sh/getting-started/installation.html).
12+
13+
### Run tests
14+
15+
- TypeScript tests are included in the `typescript` folder in the `test` folder at the root of the repo.
16+
- Solidity tests are included in the `foundry` folder in the `test` folder at the root of the repo.
17+
18+
### Example of Foundry/Forge commands
19+
20+
```shell
21+
forge build
22+
forge test
23+
forge test -vv
24+
forge tree
25+
```
26+
27+
### Example of Hardhat commands
28+
29+
```shell
30+
npx hardhat accounts
31+
npx hardhat compile
32+
npx hardhat clean
33+
npx hardhat test
34+
npx hardhat node
35+
npx hardhat help
36+
REPORT_GAS=true npx hardhat test
37+
npx hardhat coverage
38+
npx hardhat run scripts/deploy.ts
39+
TS_NODE_FILES=true npx ts-node scripts/deploy.ts
40+
npx eslint '**/*.{js,ts}'
41+
npx eslint '**/*.{js,ts}' --fix
42+
npx prettier '**/*.{json,sol,md}' --check
43+
npx prettier '**/*.{json,sol,md}' --write
44+
npx solhint 'contracts/**/*.sol'
45+
npx solhint 'contracts/**/*.sol' --fix
46+
```

contracts/Greeter.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
contract Greeter {
5+
string private greeting;
6+
7+
constructor(string memory _greeting) {
8+
greeting = _greeting;
9+
}
10+
11+
function greet() public view returns (string memory) {
12+
return greeting;
13+
}
14+
15+
function setGreeting(string memory _greeting) public {
16+
greeting = _greeting;
17+
}
18+
}

0 commit comments

Comments
 (0)