Skip to content

Commit

Permalink
Move contracts to foundry (frolic#15)
Browse files Browse the repository at this point in the history
* add foundry to CI actions

* set up forge project

* submodules should be submodules

* update remappings, update types

* update imports

* set up app build/lint CI
  • Loading branch information
frolic authored Jun 9, 2022
1 parent a39cbe1 commit 1867b7f
Show file tree
Hide file tree
Showing 112 changed files with 11,814 additions and 7,634 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: app
on:
- push
env:
NODE_ENV: ci

defaults:
run:
working-directory: ./packages/app

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Setup pnpm
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.10.0
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm build

lint:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- name: Setup pnpm
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.10.0
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
38 changes: 22 additions & 16 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ on:
- push
env:
NODE_ENV: ci

defaults:
run:
working-directory: ./packages/contracts

jobs:
build:
defaults:
run:
working-directory: ./packages/contracts
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -34,25 +37,26 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Run build step (compile contracts, generate types, etc.)
run: pnpm build
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly
- run: pnpm install
- run: pnpm build
- name: Outdated files detected, run `pnpm build` and commit them
run: |
if [[ -n "$(git status --porcelain)" ]]; then
git status
git --no-pager diff
exit 1
fi
test:
defaults:
run:
working-directory: ./packages/contracts
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -74,7 +78,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Run tests
run: pnpm test
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly
- run: pnpm install
- run: pnpm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
*debug.log

.vercel
.DS_Store
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "packages/contracts/lib/ds-test"]
path = packages/contracts/lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "packages/contracts/lib/openzeppelin-contracts"]
path = packages/contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/contracts/lib/erc721a"]
path = packages/contracts/lib/erc721a
url = https://github.com/chiru-labs/erc721a
[submodule "packages/contracts/lib/ERC721A"]
path = packages/contracts/lib/ERC721A
url = https://github.com/chiru-labs/ERC721A
1 change: 0 additions & 1 deletion packages/app/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NEXT_PUBLIC_ETHEREUM_RPC_ENDPOINT=
NEXT_PUBLIC_POLYGON_RPC_ENDPOINT=
12 changes: 5 additions & 7 deletions packages/app/src/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import deploys from "@web3-scaffold/contracts/deploys.json";
import { ExampleNFT__factory } from "@web3-scaffold/contracts/typechain-types";
import ExampleNFTGoerli from "@web3-scaffold/contracts/deploys/goerli/ExampleNFT.json";
import { ExampleNFT__factory } from "@web3-scaffold/contracts/types";

import { polygonProvider } from "./providers";

const network = process.env.NODE_ENV === "production" ? "matic" : "mumbai";
import { ethereumProvider } from "./providers";

export const exampleNFTContract = ExampleNFT__factory.connect(
deploys[network].ExampleNFT.address,
polygonProvider
ExampleNFTGoerli.deployedTo,
ethereumProvider
);
4 changes: 0 additions & 4 deletions packages/app/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ import { StaticJsonRpcProvider } from "@ethersproject/providers";
export const ethereumProvider = new StaticJsonRpcProvider(
process.env.NEXT_PUBLIC_ETHEREUM_RPC_ENDPOINT
);

export const polygonProvider = new StaticJsonRpcProvider(
process.env.NEXT_PUBLIC_POLYGON_RPC_ENDPOINT
);
5 changes: 5 additions & 0 deletions packages/contracts/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DEPLOYER=
DEPLOYER_PRIVATE_KEY=
CHAIN_NAME=goerli
RPC_URL=
ETHERSCAN_API_KEY=
8 changes: 0 additions & 8 deletions packages/contracts/.env.sample

This file was deleted.

6 changes: 2 additions & 4 deletions packages/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
cache
artifacts/build-info
artifacts/**/*.dbg.json
*.tsbuildinfo
out

.env*
.env.*
Loading

0 comments on commit 1867b7f

Please sign in to comment.