Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/slither #27

Merged
merged 7 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup
description: Install and cache npm and node_modules to reuse them in workflows and jobs
inputs:
foundry:
description: "Boolean to flag foundry installation"

runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
cache: "npm"
node-version: 18.x
- uses: actions/cache@v3
id: cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
- run: make install-ci
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
- name: Install Foundry
if: ${{ inputs.foundry }}
uses: foundry-rs/foundry-toolchain@v1
70 changes: 47 additions & 23 deletions .github/workflows/quality-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,56 @@ name: Quality Gate
on:
push:

env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
group: quality-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
packages: read

jobs:
build_and_validate:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: make lint

check-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
foundry: true
- run: make compile
- run: make deploy

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
foundry: true
- run: make test

slither:
permissions:
contents: read
packages: read
security-events: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: rm foundry.toml && touch .env
- uses: crytic/[email protected]
id: slither
with:
node-version: 18.15
sarif: results.sarif
fail-on: none
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
cache: "npm"
node-version: "18.x"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install Dependancies
run: make install-ci
- name: code quality
run: make lint
- name: Run harhat compilation
run: make hh-build
- name: Run unit tests
run: make test
- name: Run demo deployment
run: make deploy
sarif_file: ${{ steps.slither.outputs.sarif }}
29 changes: 0 additions & 29 deletions .github/workflows/security-gate.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ abi/

node_modules
.yarn
lib/forge-std

.DS_Store
src/.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged;
make test
npx lint-staged;
3 changes: 2 additions & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

make lint;
make lint;
make test;
1 change: 0 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "solhint:recommended",
"rules": {
"prettier/prettier": "error",
"avoid-throw": "off",
"avoid-suicide": "error",
"avoid-sha3": "warn",
Expand Down
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
-include .env

.PHONY: all test clean deploy-anvil
.PHONY: all test clean install compile snapshot

all: clean install forge-build hh-build test
all: clean install test

# Clean the repo
clean :; forge clean

# Local installation
install :; rm -rf lib && forge install --no-commit --no-git foundry-rs/forge-std && npm i && npx husky install
install :; npm i && npx husky install

# CI installation
install-ci :; touch .env; forge install --no-commit --no-git foundry-rs/forge-std; npm ci
install-ci :; touch .env; npm ci

# Update Dependencies
forge-update:; forge update

forge-build:; forge build
compile :; npx hardhat compile

hh-build :; npx hardhat compile

test :; forge test -vvv
test :; forge test -vvv; npx hardhat test

snapshot :; forge snapshot

slither :; slither ./src

format :; npx prettier --write src/**/*.sol
format :; forge fmt src/; forge fmt test/

lint :; npx solhint src/**/*.sol

hh-node :; npx hardhat node
node :; npx hardhat node

network?=hardhat

Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,22 @@ make test

### Deploying

Deploying to a network uses the [hardhat](https://hardhat.org/) custom tasks. Currently project supports deployment to hardhat (deploy-and-kill) network, hardhat localhost and arbitrum-sepolia.
To deploy fortis oracle run:
Project leverage [@dgma/hardhat-sol-bundler](https://www.npmjs.com/package/@dgma/hardhat-sol-bundler) util dor deployment. Find more details for deployment in `deployment.config.js`
To deploy fortis oracle, run:

```sh
make deploy network=arbitrum-sepolia
```

To deploy fortis oracle along with demo contracts, run:

```sh
make deploy-demo network=arbitrum-sepolia
```

The script will run and deploy only changed contracts. In case you need a fresh deployment, please remove `deployment.lock` file.
The script will run and deploy only changed contracts. In case you need a fresh deployment, please remove `deployment-lock.js` file.
In case of new Oracle deployment, you will need to register it with [Chainlink automation log trigger](https://docs.chain.link/chainlink-automation/overview/getting-started#try-out-chainlink-automation).
After successful registration, you'll need to set Upkeep ID running:

```sh
# Oracle without demo modules
make onRegister network=arbitrum-sepolia id={your_upkeep_id} oracle=Oracle
# Oracle for demo
make onRegister-demo network=arbitrum-sepolia id={your_upkeep_id}
make onRegister network=arbitrum-sepolia id={your_upkeep_id} oracle=FakedOracle
```

### Useful commands
Expand All @@ -102,7 +96,7 @@ To fund oracle with LINK tokens in exchange for collected ETH, run:
# Oracle without demo modules
make refund network=arbitrum-sepolia amount={link_tokens} oracle=Oracle
# Oracle for demo
make refund-demo network=arbitrum-sepolia amount={link_tokens}
make refund network=arbitrum-sepolia amount={link_tokens} oracle=FakedOracle
```

To trade ETH\fUSDC with [SwapAPP](https://github.com/killroy192/fortis/blob/main/src/example/SwapApp.sol), run:
Expand Down
Loading