-
Notifications
You must be signed in to change notification settings - Fork 27
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
Create TeleporterMessenger ABI Go binding #41
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
728b39c
create abi go binding
gwen917 24628c5
create script to generate abi go bindings
gwen917 23bc0a9
fix github action
gwen917 a3dac11
fix script and github action
gwen917 74430a1
fix script
gwen917 21fbefe
fix script
gwen917 e195536
fix script
gwen917 8e7acf4
test
gwen917 b0bc642
fix test
gwen917 73054c9
fix script
gwen917 831babe
use subnet-evm abigen
gwen917 ff9b1ff
fix
gwen917 4741041
test
gwen917 8b38bdb
test gopath
gwen917 bc73615
Merge branch 'main' into abi-go-binding
gwen917 9640d7a
check gopath
gwen917 976948c
check gopath
gwen917 0494a6b
fix
gwen917 ab35e2c
test
gwen917 6ba8aad
test
gwen917 807ab58
Merge branch 'main' into abi-go-binding
gwen917 78fdaff
fix
gwen917 774c04d
fix
gwen917 c73b386
fix script
gwen917 6e87fa1
fix script
gwen917 1a98e74
fix
gwen917 37902b3
add comments
gwen917 3c43000
fix golang package name
gwen917 aedfb7b
add BridgeToken
gwen917 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: ABI Go Bindings Checker | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "*" | ||
|
||
env: | ||
GO_VERSION: "1.20.8" | ||
|
||
jobs: | ||
abi_binding: | ||
name: abi_binding | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
|
||
- name: Checkout Teleporter repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install forge and generate ABI Go bindings | ||
run: | | ||
BASE_DIR=${XDG_CONFIG_HOME:-$HOME} | ||
curl -L https://foundry.paradigm.xyz | bash | ||
source $HOME/.bashrc | ||
$BASE_DIR/.foundry/bin/foundryup | ||
export GOPATH=$HOME/go | ||
export PATH="$PATH:$BASE_DIR/.foundry/bin" | ||
export PATH="$PATH:$GOPATH/bin" | ||
./scripts/abi_go_bindings.sh | ||
|
||
- name: Check for clean branch | ||
run: .github/workflows/check_clean_branch.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# Exits if any uncommitted changes are found. | ||
|
||
set -o errexit | ||
gwen917 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set -o nounset | ||
set -o pipefail | ||
|
||
# Modifies the index based on the current index. | ||
# Checks to see if merges or updates are needed by checking stat() information. | ||
git update-index --really-refresh > /dev/null | ||
# Checks to see if there are any differences from the index to the current HEAD commit | ||
git diff-index --quiet HEAD |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
610 changes: 610 additions & 0 deletions
610
abis/ExampleCrossChainMessenger/ExampleCrossChainMessenger.go
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. | ||
# See the file LICENSE for licensing terms. | ||
|
||
set -e | ||
|
||
source ./scripts/utils.sh | ||
|
||
setARCH | ||
|
||
gwen917 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TELEPORTER_PATH=$( | ||
cd "$(dirname "${BASH_SOURCE[0]}")" | ||
cd .. && pwd | ||
) | ||
|
||
DEFAULT_CONTRACT_LIST="TeleporterMessenger ERC20Bridge ExampleCrossChainMessenger BlockHashPublisher BlockHashReceiver BridgeToken" | ||
|
||
CONTRACT_LIST= | ||
HELP= | ||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
-c | --contract) CONTRACT_LIST=$2 ;; | ||
-h | --help) HELP=true ;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ "$HELP" = true ]; then | ||
echo "Usage: ./scripts/abi_go_bindings.sh [OPTIONS]" | ||
echo "Build contracts and generate Go bindings" | ||
echo "" | ||
echo "Options:" | ||
echo " -c, --contract <contract_name> Generate Go bindings for the contract. If empty, generate Go bindings for a default list of contracts" | ||
echo " -c, --contract "contract1 contract2" Generate Go bindings for multiple contracts" | ||
echo " -h, --help Print this help message" | ||
exit 0 | ||
fi | ||
|
||
if ! command -v forge &> /dev/null; then | ||
echo "forge not found, installing" | ||
curl -L https://foundry.paradigm.xyz | bash | ||
source $HOME/.bashrc | ||
foundryup | ||
fi | ||
|
||
echo "Building subnet-evm abigen" | ||
go install $TELEPORTER_PATH/subnet-evm/cmd/abigen | ||
|
||
echo "Building Contracts" | ||
cd $TELEPORTER_PATH/contracts | ||
forge build --extra-output-files abi | ||
|
||
contract_names=($CONTRACT_LIST) | ||
|
||
# If CONTRACT_LIST is empty, use DEFAULT_CONTRACT_LIST | ||
if [[ -z "${CONTRACT_LIST}" ]]; then | ||
contract_names=($DEFAULT_CONTRACT_LIST) | ||
fi | ||
|
||
cd $TELEPORTER_PATH | ||
for contract_name in "${contract_names[@]}" | ||
do | ||
abi_file=$TELEPORTER_PATH/contracts/out/$contract_name.sol/$contract_name.abi.json | ||
if ! [ -f $abi_file ]; then | ||
echo "Error: Contract $contract_name abi file not found" | ||
exit 1 | ||
fi | ||
|
||
echo "Generating Go bindings for $contract_name..." | ||
mkdir -p $TELEPORTER_PATH/abis/$contract_name | ||
$GOPATH/bin/abigen --abi $abi_file \ | ||
--pkg $(convertToLower $contract_name) \ | ||
--out $TELEPORTER_PATH/abis/$contract_name/$contract_name.go | ||
echo "Done generating Go bindings for $contract_name." | ||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need need to add on push to main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on Cam's comments, we may not want to run this on
main
in automated fashion