Skip to content

Commit

Permalink
go-types: add bytecode for contract deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
jordipainan committed Jan 20, 2025
1 parent b540833 commit 5a7ad5a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go_bind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ abi() {
local json_file="$1"
local pkg_name="$2"
local output_file="$3"
local bin_file="./golang-types/${pkg_name}.bin"

if [[ ! -f "$json_file" ]]; then
echo "Error: File '$json_file' does not exist." >&2
exit 1
fi

jq -r '.bytecode' "$json_file" > "$bin_file"

# Generate the Go bindings directly from the JSON ABI
jq -r '.abi' "$json_file" | abigen --abi=/dev/stdin --pkg="$pkg_name" --out="$output_file"
jq -r '.abi' "$json_file" | abigen --abi=/dev/stdin --pkg="$pkg_name" --out="$output_file" --bin="$bin_file"
echo "Successfully generated Go bindings for '$pkg_name' contract."

rm -f "$bin_file"

# Replace the package name in the generated file with "contracts"
sed_in_place "s/^package $pkg_name/package contracts/" "$output_file"
}
Expand Down
Loading

0 comments on commit 5a7ad5a

Please sign in to comment.