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

chore: generate the wrappers from .abi and .bin #139

Merged
merged 6 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ gen: solidity-wrappers

SOLIDITY_DIR = .
SOLIDITY_SRC_DIR = $(SOLIDITY_DIR)/src
solidity-wrappers: $(SOLIDITY_SRC_DIR)/QuantumGravityBridge.sol
cd $(SOLIDITY_SRC_DIR) ; \
for file in $(^F) ; do \
mkdir -p ../wrappers/$${file} ; \
echo abigen --type=peggy --pkg wrappers --out=../wrappers/$${file}/wrapper.go --sol $${file} ; \
abigen --type=peggy --pkg wrappers --out=../wrappers/$${file}/wrapper.go --sol $${file} ; \
done
CONTRACTS = QuantumGravityBridge.sol
solidity-wrappers:
SOLIDITY_SRC_DIR=$(SOLIDITY_SRC_DIR) CONTRACTS=$(CONTRACTS) /bin/bash ./scripts/gen.sh
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions scripts/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved

set -e

forge build > /dev/null

cd "${SOLIDITY_SRC_DIR}"

for file in ${CONTRACTS}
do
rach-id marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p ../wrappers/"${file}"
contractName=$(echo "${file}" | cut -d . -f 1)
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved

jq .abi < ../out/"${file}"/"${contractName}".json > ../out/"${file}"/"${contractName}".abi
jq .bytecode.object < ../out/"${file}"/"${contractName}".json | cut -d \" -f 2 > ../out/"${file}"/"${contractName}".bin
adlerjohn marked this conversation as resolved.
Show resolved Hide resolved

abigen --type=qgb --pkg wrappers \
--out=../wrappers/"${file}"/wrapper.go \
--abi ../out/"${file}"/"${contractName}".abi \
--bin ../out/"${file}"/"${contractName}".bin
done

echo "done."
Loading