Skip to content

Commit

Permalink
chore: transform contracts repository into forge repository and f…
Browse files Browse the repository at this point in the history
…ix the `ERC20` bytecode deployment issue (#162)

* feat: init `forge` repository

* chore: update job

* chore: refactor and move go bindings to `bindings` pkg

* ci: update job to make sure go bindings are up to date

* ci: install `solc` and `abigen`

* ci: fix job and only run when files under `contracts/` are modified

* chore: nit

* test: modify file under `bindings`

* fix: path issue

* fix: issue with concurrent workflows

* chore: clean up

* chore: clean up

* ci: install abigen using another method

* chore: rename jobs

* chore: show diffs when there is a problem

* chore: nit

* chore: clean up

* chore: install specific version of solc

* chore: remove solc installation as foundry handles it

* chore: bump solc version

* chore: generate new bindings
  • Loading branch information
leovct authored Nov 20, 2023
1 parent 601409d commit 96089ed
Show file tree
Hide file tree
Showing 127 changed files with 2,732 additions and 621 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
name: ci

on:
push:
branches:
- "main"
pull_request:
branches:
- "**"
types: [opened, synchronize]
on: push

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
Expand All @@ -34,7 +27,7 @@ jobs:
run: make lint

doc:
name: Doc
name: Check documentation
runs-on: ubuntu-latest
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
Expand All @@ -48,6 +41,7 @@ jobs:
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Error: Documentation is not up to date. Please run \`make gen-doc\`."
git diff
exit 1
else
echo "✅ The documentation is up to date."
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/go-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: go-bindings

on:
push:
# Only run when files under `bindings/` or `contracts/` folders are modified.
paths:
- '.github/workflows/go-bindings.yml'
- 'contracts/**'
- 'bindings/**'

concurrency:
group: go-bindings-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
SOLC_VERSION: "0.8.21"

jobs:
go-bindings:
name: Check go bindings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install abigen
run: |
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
abigen --version
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install dependencies
working-directory: contracts
run: forge install

- name: Generate go bindings
run: make gen-go-bindings
- name: Check if the go bindings are up to date
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Error: Go bindings are not up to date. Please run \`make gen-go-bindings\`."
git diff
exit 1
else
echo "✅ Go bindings are up to date."
fi
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/openzeppelin-contracts"]
path = contracts/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ gen-loadtest-modes: ## Generate loadtest modes strings.

.PHONY: gen-go-bindings
gen-go-bindings: ## Generate go bindings for smart contracts.
$(call gen_go_binding,contracts/tokens/ERC20,ERC20,tokens,contracts/tokens)
$(call gen_go_binding,contracts/tokens/ERC721,ERC721,tokens,contracts/tokens)
$(call gen_go_binding,contracts/loadtester,LoadTester,contracts,contracts)
$(call gen_go_binding,contracts/conformancetester,ConformanceTester,conformancetester,contracts/conformancetester)
cd contracts && make gen-go-bindings

.PHONY: gen-json-rpctypes
gen-json-rpctypes: ## Generate go bindings for smart contracts.
Expand Down
78 changes: 78 additions & 0 deletions bindings/tester/ConformanceTester.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[
{
"inputs": [
{
"internalType": "string",
"name": "_name",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "RevertErrorMessage",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "balances",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "deposit",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "testRevert",
"outputs": [],
"stateMutability": "pure",
"type": "function"
}
]
1 change: 1 addition & 0 deletions bindings/tester/ConformanceTester.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x608060405234801561001057600080fd5b506040516106ff3803806106ff83398101604081905261002f9161015b565b600061003b8282610281565b5050610344565b634e487b7160e01b600052604160045260246000fd5b601f19601f83011681018181106001600160401b038211171561007d5761007d610042565b6040525050565b600061008f60405190565b905061009b8282610058565b919050565b60006001600160401b038211156100b9576100b9610042565b601f19601f83011660200192915050565b60005b838110156100e55781810151838201526020016100cd565b50506000910152565b60006101016100fc846100a0565b610084565b90508281526020810184848401111561011c5761011c600080fd5b6101278482856100ca565b509392505050565b600082601f83011261014357610143600080fd5b81516101538482602086016100ee565b949350505050565b60006020828403121561017057610170600080fd5b81516001600160401b0381111561018957610189600080fd5b6101538482850161012f565b634e487b7160e01b600052602260045260246000fd5b6002810460018216806101bf57607f821691505b6020821081036101d1576101d1610195565b50919050565b60006101e66101e38381565b90565b92915050565b6101f5836101d7565b815460001960089490940293841b1916921b91909117905550565b600061021d8184846101ec565b505050565b8181101561023d57610235600082610210565b600101610222565b5050565b601f82111561021d576000818152602090206020601f850104810160208510156102685750805b61027a6020601f860104830182610222565b5050505050565b81516001600160401b0381111561029a5761029a610042565b6102a482546101ab565b6102af828285610241565b6020601f8311600181146102e357600084156102cb5750858201515b600019600886021c198116600286021786555061033c565b600085815260208120601f198616915b8281101561031357888501518255602094850194600190920191016102f3565b8683101561032f5784890151600019601f89166008021c191682555b6001600288020188555050505b505050505050565b6103ac806103536000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306fdde031461005c578063242e7fa11461007a57806327e235e3146100b2578063a26388bb146100df578063b6b55f25146100e9575b600080fd5b6100646100fc565b6040516100719190610257565b60405180910390f35b610064604051806040016040528060198152602001785465737420526576657274204572726f72204d65737361676560381b81525081565b6100d26100c03660046102a4565b60016020526000908152604090205481565b60405161007191906102cd565b6100e761018a565b005b6100e76100f73660046102ea565b6101da565b6000805461010990610321565b80601f016020809104026020016040519081016040528092919081815260200182805461013590610321565b80156101825780601f1061015757610100808354040283529160200191610182565b820191906000526020600020905b81548152906001019060200180831161016557829003601f168201915b505050505081565b60408051808201825260198152785465737420526576657274204572726f72204d65737361676560381b6020820152905162461bcd60e51b81526101d19190600401610257565b60405180910390fd5b33600090815260016020526040812080548392906101f9908490610363565b909155505050565b60005b8381101561021c578181015183820152602001610204565b50506000910152565b600061022f825190565b808452602084019350610246818560208601610201565b601f01601f19169290920192915050565b602080825281016102688184610225565b9392505050565b60006001600160a01b0382165b92915050565b61028b8161026f565b811461029657600080fd5b50565b803561027c81610282565b6000602082840312156102b9576102b9600080fd5b60006102c58484610299565b949350505050565b8181526020810161027c565b8061028b565b803561027c816102d9565b6000602082840312156102ff576102ff600080fd5b60006102c584846102df565b634e487b7160e01b600052602260045260246000fd5b60028104600182168061033557607f821691505b6020821081036103475761034761030b565b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561027c5761027c61034d56fea2646970667358221220cb58571a678e4a04b84ef57d328d854bedb20916a4a95a84ccc3bae10d9cc02e64736f6c63430008170033
Loading

0 comments on commit 96089ed

Please sign in to comment.