Skip to content

Commit c85424e

Browse files
committed
Merge remote-tracking branch 'gnosh/main'
Add gnosh-contracts.
2 parents 1a033c6 + 924b70f commit c85424e

35 files changed

+2293
-0
lines changed

.github/workflows/forge-test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on: [push]
2+
3+
name: test
4+
5+
jobs:
6+
check:
7+
name: Foundry project
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
submodules: recursive
13+
14+
- name: Install Foundry
15+
uses: foundry-rs/foundry-toolchain@v1
16+
17+
- name: Run tests
18+
run: forge test -vvv
19+
20+
- name: Run snapshot
21+
run: forge snapshot

.github/workflows/pre-commit.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: pre-commit
2+
3+
on: [push]
4+
5+
jobs:
6+
pre-commit:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v3
11+
- uses: pre-commit/[email protected]

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
FOUNDRY_PROFILE: ci
7+
8+
jobs:
9+
check:
10+
strategy:
11+
fail-fast: true
12+
13+
name: Foundry project
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: recursive
19+
20+
- name: Install Foundry
21+
uses: foundry-rs/foundry-toolchain@v1
22+
with:
23+
version: nightly
24+
25+
- name: Run Forge build
26+
run: |
27+
forge --version
28+
forge build --sizes
29+
id: build
30+
31+
- name: Run Forge tests
32+
run: |
33+
forge test -vvv
34+
id: test

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Compiler files
2+
cache/
3+
out/
4+
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
9+
10+
# Docs
11+
docs/
12+
13+
# Dotenv file
14+
.env

.gitmodules

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

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
default_language_version:
2+
python: python3
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.4.0
7+
hooks:
8+
- id: check-added-large-files
9+
args: ["--maxkb=1000"]
10+
- id: fix-byte-order-marker
11+
- id: check-case-conflict
12+
- id: check-merge-conflict
13+
- id: check-toml
14+
- id: end-of-file-fixer
15+
- id: trailing-whitespace
16+
17+
- repo: https://github.com/pre-commit/mirrors-prettier
18+
rev: v3.0.0-alpha.9-for-vscode
19+
hooks:
20+
- id: prettier
21+
additional_dependencies:
22+
23+
args: ["--plugin=prettier-plugin-solidity"]
24+
types_or:
25+
[
26+
"yaml",
27+
"markdown",
28+
"solidity",
29+
"makefile",
30+
"gitignore",
31+
"toml",
32+
"json",
33+
"javascript",
34+
"proto",
35+
]
36+
37+
- repo: local
38+
hooks:
39+
- id: bindings
40+
name: bindings
41+
entry: ./gen_bindings.sh
42+
language: script
43+
types: [solidity]
44+
files: gen_bindings.sh
45+
pass_filenames: false

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pre-commit 3.3.3
2+
golang 1.21.4

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# gnosh-contracts
2+
3+
## Running the tests
4+
5+
Install [foundry](https://book.getfoundry.sh/getting-started/installation).
6+
7+
Run `forge test -vvv`
8+
9+
## Using the deploy script
10+
11+
Create a `.env` file with the following content, fill in the missing values:
12+
13+
```shell
14+
GOERLI_RPC_URL=https://ethereum-goerli.publicnode.com
15+
PRIVATE_KEY=0xe1...
16+
ETHERSCAN_API_KEY=BIR44...
17+
```
18+
19+
Run the following command:
20+
21+
```shell
22+
source .env
23+
forge script script/deploy.s.sol --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
24+
```

foundry.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
6+
[rpc_endpoints]
7+
goerli = "${GOERLI_RPC_URL}"
8+
9+
[etherscan]
10+
goerli = { key = "${ETHERSCAN_API_KEY}" }
11+
#
12+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

gen_bindings.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
CONTRACTS=(
4+
"Sequencer"
5+
"ValidatorRegistry"
6+
)
7+
OUTPUT_DIR="gnoshcontracts"
8+
PACKAGE_NAME="gnoshcontracts"
9+
10+
mkdir -p "$OUTPUT_DIR"
11+
12+
forge build
13+
14+
for contract in "${CONTRACTS[@]}"; do
15+
pkg=$(echo "$contract" | tr '[:upper:]' '[:lower:]')
16+
d="${OUTPUT_DIR}/${pkg}"
17+
mkdir -p "${d}"
18+
abigen --abi <(jq '.["abi"]' "out/${contract}.sol/${contract}.json") --pkg "${pkg}" --out "${d}/${pkg}.go"
19+
done

0 commit comments

Comments
 (0)