Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Add Go contract bindings #739

Merged
merged 14 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __pycache__/
node_modules/
artifacts/
.mypy_cache
pkg/chain/ethereum/gen/abi/**/*.abi

# Visual Studio Code
*.code-workspace
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/keep-network/tbtc

go 1.13

require (
github.com/ethereum/go-ethereum v1.9.10
github.com/ipfs/go-log v1.0.4
github.com/keep-network/keep-common v1.2.1-0.20201020114759-19c123cbd4f4
)
409 changes: 409 additions & 0 deletions go.sum

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions pkg/chain/ethereum/gen/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Environment `SOLIDITY_DIR` provides the solidity directory as a
# potentially-relative path, which we resolve. However, because
# Solidity files are grouped into separate subdirectories, specific
# files must be provided explicitly via `SOLIDITY_FILES` variable
# to handle them in a correct way.
solidity_dir=$(realpath ${SOLIDITY_DIR})
solidity_files := $(foreach file,${SOLIDITY_FILES},$(file))

# Solidity filenames without .sol with subdirectories prefixes.
contract_stems := $(basename $(solidity_files))
# Go abigen bindings in abi/ subdirectory with .go suffix, alongside solc ABI
# files with .abi suffix.
abi_files := $(addprefix abi/,$(addsuffix .abi,$(contract_stems)))
abigen_files := $(addprefix abi/,$(addsuffix .go,$(contract_stems)))
contract_files := $(addprefix contract/,$(addsuffix .go,$(contract_stems)))

all: gen_contract_go gen_abi_go

clean:
rm -r abi/*
rm -r contract/*
mkdir tmp && mv cmd/cmd*.go tmp
rm -r cmd/*
mv tmp/* cmd && rm -r tmp

gen_abi_go: $(abigen_files)

gen_contract_go: $(contract_files)

abi/%.abi: ${solidity_dir}/contracts/%.sol
$(eval output=$(dir $@))
mkdir -p $(output)
solc openzeppelin-solidity/=${solidity_dir}/node_modules/openzeppelin-solidity/ \
@summa-tx/bitcoin-spv-sol/=${solidity_dir}/node_modules/@summa-tx/bitcoin-spv-sol/ \
@keep-network/keep-ecdsa/=${solidity_dir}/node_modules/@keep-network/keep-ecdsa/ \
@summa-tx/relay-sol=${solidity_dir}/node_modules/@summa-tx/relay-sol/ \
--allow-paths ${solidity_dir} \
--overwrite \
--abi \
-o $(output) $<

abi/%.go: abi/%.abi
$(eval type=$(notdir $*))
go run github.com/ethereum/go-ethereum/cmd/abigen --abi $< --pkg abi --type $(type) --out $@

contract/deposit/Deposit.go cmd/deposit/Deposit.go: abi/deposit/Deposit.abi abi/deposit/Deposit.go *.go
go run github.com/keep-network/keep-common/tools/generators/ethereum $< contract/Deposit.go

contract/system/TBTCSystem.go cmd/system/TBTCSystem.go: abi/system/TBTCSystem.abi abi/system/TBTCSystem.go *.go
go run github.com/keep-network/keep-common/tools/generators/ethereum $< contract/TBTCSystem.go




1,091 changes: 1,091 additions & 0 deletions pkg/chain/ethereum/gen/abi/deposit/Deposit.go

Large diffs are not rendered by default.

5,145 changes: 5,145 additions & 0 deletions pkg/chain/ethereum/gen/abi/system/TBTCSystem.go

Large diffs are not rendered by default.

Empty file.
Loading