Skip to content

Commit

Permalink
ABI Gen scipt
Browse files Browse the repository at this point in the history
compile-bindings.sh script to generate go-abi bindings with Abigen
+ some tidyup
  • Loading branch information
FeurJak committed Jul 23, 2024
1 parent 1d1224a commit 68dfc8d
Show file tree
Hide file tree
Showing 13 changed files with 4,731 additions and 65 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: compile
compile:
forge b

.PHONY: test
test:
forge test -vvvv

.PHONY: bindings
bindings: compile
./bin/compile-bindings.sh

.PHONY: all
all: compile bindings
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ensure you have the following installed:

- [ ] [Foundry Forge (>=v0.2.0)](https://book.getfoundry.sh/getting-started/installation)
- [ ] [Golang (==v1.22.5)](https://go.dev/doc/install)
- [ ] [AbiGen (>=1.1.4.7-stable](https://geth.ethereum.org/docs/tools/abigen)
- [ ] [Bun (>=v1.1.19)](https://bun.sh/)

### 1.2. Testing:
Expand Down Expand Up @@ -82,7 +83,7 @@ forge script --chain $CHAIN script/deployment.s.sol:Deploy_AssociationSetProvide

## 2. Integration:

Refer to the the [integrations directory](Integrations/) for integrating the ASP with other systems / protocols.
Refer to the the [integrations directory](integrations/) for integrating the ASP with other systems / protocols.

---

Expand Down
52 changes: 52 additions & 0 deletions bin/compile-bindings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

BINDING_DIR=./pkg/bindings
JSON_DIR=./out

function create_binding {
contract_name=$1

mkdir -p $BINDING_DIR/${contract_name}

contract_json_path="${JSON_DIR}/${contract_name}.sol/${contract_name}.json"

binding_out_dir="${BINDING_DIR}/${contract_name}"
mkdir -p $binding_out_dir || true

cat $contract_json_path | jq -r '.abi' > $binding_out_dir/tmp.abi
cat $contract_json_path | jq -r '.bytecode.object' > $binding_out_dir/tmp.bin

abigen \
--bin=$binding_out_dir/tmp.bin \
--abi=$binding_out_dir/tmp.abi \
--pkg="${contract_name}" \
--out=$BINDING_DIR/$contract_name/binding.go \
> /dev/null 2>&1

if [[ $? == "1" ]];
then
echo "Failed to generate binding for $contract_json_path"
fi
rm $binding_out_dir/tmp.abi
rm $binding_out_dir/tmp.bin
}

# Create or overwrite the README.md file with the initial content
cat << EOF > $BINDING_DIR/README.md
# Go-ABI Bindings for ASP Contracts V1.0
> These bindings were generated with [AbiGen](https://geth.ethereum.org/docs/tools/abigen).
EOF


contracts=$(find src/ -type f -name "*.sol" )
IFS=$'\n'

for contract_name in $contracts; do
# Append the contract link to README.md
contract_name=$(basename $contract_name .sol)

echo "* [$contract_name]($contract_name/)" >> $BINDING_DIR/README.md
create_binding $contract_name
done
2 changes: 1 addition & 1 deletion script/1_get_deps.sh → bin/install-deps.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##!/bin/bash

## Get all the dependencies
## Get all the dependencies for smart contracts
echo "Fetching dependencies..."
rm -rf lib
forge install OpenZeppelin/openzeppelin-contracts privacy-scaling-explorations/zk-kit.solidity vimwitch/poseidon-solidity
Expand Down
30 changes: 30 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
module github.com/0xBow-io/asp-contracts-V1.0

go 1.22.5

require github.com/ethereum/go-ethereum v1.14.7

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.3.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
190 changes: 190 additions & 0 deletions go.sum

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions packages/README.md

This file was deleted.

7 changes: 7 additions & 0 deletions pkg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ASP Contracts V1.0 Pkg

> The Pkg directory contains Go packages for interacting with the ASP contracts.
| **Package** | **Version** | **View** | **Status** |
|---------|--------------|---------|---------|
| | | | |
2,237 changes: 2,237 additions & 0 deletions pkg/bindings/AssociationSetProvider/binding.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pkg/bindings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Go-ABI Bindings for ASP Contracts V1.0

> These bindings were generated with [AbiGen](https://geth.ethereum.org/docs/tools/abigen).
* [RecordCategoryRegistry](RecordCategoryRegistry/)
* [AssociationSetProvider](AssociationSetProvider/)
2,192 changes: 2,192 additions & 0 deletions pkg/bindings/RecordCategoryRegistry/binding.go

Large diffs are not rendered by default.

25 changes: 0 additions & 25 deletions script/gen_ts_abi_bindings.ts

This file was deleted.

34 changes: 0 additions & 34 deletions workflows/test.yml

This file was deleted.

0 comments on commit 68dfc8d

Please sign in to comment.