forked from storyprotocol/protocol-core-v1
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66b711d
Showing
73 changed files
with
40,423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# MAINNET | ||
MAINNET_URL = https://eth-mainnet.g.alchemy.com/v2/1234123412341234 | ||
MAINNET_PRIVATEKEY= 12341234123412341234123412341234 | ||
|
||
# GOERLI | ||
GOERLI_URL = https://eth-goerli.g.alchemy.com/v2/1234123412341234 | ||
GOERLI_PRIVATEKEY = 12341234123412341234123412341234 | ||
|
||
# ETHSCAN | ||
ETHERSCAN_API_KEY = ETHERSCANAPIKEYETHERSCANAPIKEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.openzeppelin | ||
.eslintrc.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
root: true, | ||
plugins: ["prettier"], | ||
extends: ["eslint:recommended"], | ||
rules: { | ||
"comma-spacing": ["error", {before: false, after: true}], | ||
"prettier/prettier": "error", | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
env: { | ||
es6: true, | ||
node: true, | ||
mocha: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CounterTest:testIncrement() (gas: 28286) | ||
CounterTest:testSetNumber(uint256) (runs: 256, μ: 27045, ~: 28367) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: UnitTest | ||
|
||
on: [pull_request] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: '**/node_modules' | ||
key: npm-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: npm- | ||
- run: yarn | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
- run: npm run lint | ||
|
||
foundry-test: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry Unit Test | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- uses: chill-viking/npm-ci@latest | ||
name: Install NPM Dependencies | ||
with: | ||
working_directory: ${{ github.workspace }} | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: forge-test | ||
|
||
- name: Gas Difference | ||
run: | ||
forge snapshot --gas-report --diff --desc | ||
id: forge-gas-snapshot-diff | ||
|
||
- name: Code Coverage | ||
run: | ||
forge coverage --report lcov --report summary | ||
id: forge-code-coverage | ||
|
||
hardhat-test: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Hardhat Unit Test | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
#- name: Environment | ||
# uses: actions/setup-node@v3 | ||
- name: Test | ||
uses: ambersun1234/[email protected] | ||
with: | ||
network: hardhat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
artifacts/ | ||
forge-cache/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env | ||
|
||
.idea/ | ||
.github/ | ||
node_modules/ | ||
|
||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build | ||
coverage | ||
out | ||
lib | ||
assets | ||
node_modules | ||
.next | ||
.idea | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"semi": false, | ||
"singleQuote": false, | ||
"useTabs": false, | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 150, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"code-complexity": ["error", 8], | ||
"compiler-version": ["error", ">=0.8.0"], | ||
"const-name-snakecase": "off", | ||
"constructor-syntax": "error", | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"max-line-length": ["error", 150], | ||
"not-rely-on-time": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"endOfLine": "auto" | ||
} | ||
], | ||
"reason-string": ["error", { "maxLength": 64 }], | ||
"private-vars-leading-underscore": ["error", { "strict": false }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Story Protocol | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-include .env | ||
|
||
.PHONY: all test clean | ||
|
||
all: clean install build | ||
|
||
# Clean the repo | ||
forge-clean :; forge clean | ||
clean :; npx hardhat clean | ||
|
||
# Remove modules | ||
forge-remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules" | ||
|
||
install :; npm install | ||
|
||
# Update Dependencies | ||
forge-update:; forge update | ||
|
||
forge-build:; forge build | ||
build :; npx hardhat compile | ||
|
||
test :; forge test | ||
|
||
snapshot :; forge snapshot | ||
|
||
slither :; slither ./contracts | ||
|
||
format :; npx prettier --write contracts/**/*.sol && npx prettier --write contracts/*.sol | ||
|
||
# solhint should be installed globally | ||
lint :; npx solhint contracts/**/*.sol && npx solhint contracts/*.sol | ||
|
||
deploy-goerli :; npx hardhat run ./script/deploy-reveal-engine.js --network goerli | ||
verify-goerli :; npx hardhat verify --network goerli ${contract} | ||
|
||
anvil :; anvil -m 'test test test test test test test test test test test junk' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
# Solidity Template | ||
|
||
Support both [Foundry](https://github.com/gakonst/foundry) test and [Hardhat](https://hardhat.org/). | ||
|
||
# Getting Started | ||
|
||
## Requirements | ||
|
||
Please install the following: | ||
|
||
- [Foundry / Foundryup](https://github.com/gakonst/foundry) | ||
- [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#overview) | ||
|
||
And you probably already have `make` installed... but if not [try looking here.](https://askubuntu.com/questions/161104/how-do-i-install-make) and [here for MacOS](https://stackoverflow.com/questions/1469994/using-make-on-os-x) | ||
|
||
## Quickstart | ||
|
||
```sh | ||
make # This installs the project's dependencies. | ||
make test | ||
``` | ||
|
||
## Testing | ||
|
||
``` | ||
make test | ||
``` | ||
|
||
or | ||
|
||
``` | ||
forge test | ||
``` | ||
|
||
# Deploying to a network | ||
|
||
## Setup | ||
|
||
You'll need to add the following variables to a `.env` file: | ||
|
||
- `MAINNET_URL` | ||
- `MAINNET_PRIVATEKEY` | ||
- `GOERLI_URL` | ||
- `GOERLI_PRIVATEKEY` | ||
- `ETHERSCAN_API_KEY` | ||
|
||
## Deploying | ||
|
||
``` | ||
make deploy-goerli | ||
``` | ||
|
||
|
||
### Working with a local network | ||
|
||
Foundry comes with local network [anvil](https://book.getfoundry.sh/anvil/index.html) baked in, and allows us to deploy to our local network for quick testing locally. | ||
|
||
To start a local network run: | ||
|
||
``` | ||
make anvil | ||
``` | ||
|
||
This will spin up a local blockchain with a determined private key, so you can use the same private key each time. | ||
|
||
# Code Style | ||
We employed solhint to check code style. | ||
To check code style with solhint run: | ||
``` | ||
make lint | ||
``` | ||
To re-format code with prettier run: | ||
``` | ||
make format | ||
``` | ||
|
||
# Security | ||
|
||
We use slither, a popular security framework from [Trail of Bits](https://www.trailofbits.com/). To use slither, you'll first need to [install python](https://www.python.org/downloads/) and [install slither](https://github.com/crytic/slither#how-to-install). | ||
|
||
Then, you can run: | ||
|
||
``` | ||
make slither | ||
``` | ||
|
||
And get your slither output. | ||
|
||
|
||
## Resources | ||
- [Hardhat](https://hardhat.org/docs) | ||
- [Foundry Documentation](https://book.getfoundry.sh/) | ||
- [Yarn](https://yarnpkg.com/getting-started) | ||
|
||
### TODO | ||
|
||
[ ] Add support for sepolia chain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
contract Counter { | ||
uint256 public number; | ||
|
||
function setNumber(uint256 newNumber) public { | ||
number = newNumber; | ||
} | ||
|
||
function increment() public { | ||
number++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[profile.default] | ||
src = 'contracts' | ||
out = 'out' | ||
libs = ['node_modules', 'lib'] | ||
cache_path = 'forge-cache' | ||
gas_reports = ["*"] | ||
optimizer = true | ||
optimizer_runs = 20000 | ||
test = 'test' | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/tree/master/config |
Oops, something went wrong.