Skip to content

Commit

Permalink
MaintainerProxy bindings (#3630)
Browse files Browse the repository at this point in the history
This PR adds binding generation for the `MaintainerProxy` contract.
The bindings were generated using the `make mainnet` command.
  • Loading branch information
pdyraga authored Jun 16, 2023
2 parents 78da87c + 800fdda commit 266b7a3
Show file tree
Hide file tree
Showing 7 changed files with 10,172 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/chain/ethereum/common/gen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ endif
contract/%.go cmd/%.go: abi/%.abi abi/%.go _address/% ${artifacts_dir}/%.json
$(info $* - generating Keep bindings)
@go run github.com/keep-network/keep-common/tools/generators/ethereum $< contract/$*.go cmd/$*.go
$(call after_contract_hook,$*)

# Don't remove intermediate files that got generated.
.PRECIOUS: abi/%.abi abi/%.go _address/%
29 changes: 25 additions & 4 deletions pkg/chain/ethereum/tbtc/gen/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
npm_package_name=@keep-network/tbtc-v2

# Contracts for which the bindings should be generated.
required_contracts := Bridge LightRelay LightRelayMaintainerProxy WalletCoordinator
required_contracts := Bridge MaintainerProxy LightRelay LightRelayMaintainerProxy WalletCoordinator

# There is a bug in the currently used abigen version (v1.10.19) that makes it
# re-declaring structs used by multiple contracts
# https://github.com/ethereum/go-ethereum/issues/24627. This is a problem
# for us because both Bridge and WalletCoordinator contracts use BitcoinTx.Info
# struct which is then re-declared in the same package once abigen does its work.
# for us because Bridge, WalletCoordinator and MaintainerProxy contracts all use
# the same structs which are then re-declared in the same package once abigen
# does its work.
# An ultimate solution would be upgrading go-ethereum (thus abigen too) to v1.11 but
# that version contains some breaking changes that make the upgrade non-trivial.
# As a short-term workaround, we use some Makefile shenanigans to slightly rename
# the conflicting BitcoinTxInfo struct in the WalletCoordinator output file.
# the conflicting structs in the WalletCoordinator and MaintainerProxy output files.
# We use perl for that purpose as sed is not cross-platform and works a bit
# differently on GNU and BSD.
#
Expand All @@ -20,9 +21,29 @@ required_contracts := Bridge LightRelay LightRelayMaintainerProxy WalletCoordina
define after_abi_hook
$(eval type := $(1))
$(if $(filter $(type),WalletCoordinator),$(call fix_wallet_coordinator_collision))
$(if $(filter $(type),MaintainerProxy),$(call fix_maintainer_proxy_collision))
endef
define fix_wallet_coordinator_collision
@perl -pi -e s,BitcoinTxInfo,BitcoinTxInfo2,g ./abi/WalletCoordinator.go
endef
define fix_maintainer_proxy_collision
@perl -pi -e s,BitcoinTxUTXO,BitcoinTxUTXO2,g ./abi/MaintainerProxy.go
@perl -pi -e s,BitcoinTxProof,BitcoinTxProof2,g ./abi/MaintainerProxy.go
@perl -pi -e s,BitcoinTxInfo,BitcoinTxInfo3,g ./abi/MaintainerProxy.go
endef

# See explanation in https://github.com/keep-network/keep-common/issues/117.
define after_contract_hook
$(eval type := $(1))
$(if $(filter $(type),MaintainerProxy),$(call fix_maintainer_proxy_contract_collision))
endef
define fix_maintainer_proxy_contract_collision
@perl -pi -e s,BitcoinTxUTXO,BitcoinTxUTXO2,g ./contract/MaintainerProxy.go
@perl -pi -e s,BitcoinTxProof,BitcoinTxProof2,g ./contract/MaintainerProxy.go
@perl -pi -e s,BitcoinTxInfo,BitcoinTxInfo3,g ./contract/MaintainerProxy.go
@perl -pi -e s,BitcoinTxUTXO,BitcoinTxUTXO2,g ./cmd/MaintainerProxy.go
@perl -pi -e s,BitcoinTxProof,BitcoinTxProof2,g ./cmd/MaintainerProxy.go
@perl -pi -e s,BitcoinTxInfo,BitcoinTxInfo3,g ./cmd/MaintainerProxy.go
endef

include ../../common/gen/Makefile
Empty file.
2,383 changes: 2,383 additions & 0 deletions pkg/chain/ethereum/tbtc/gen/abi/MaintainerProxy.go

Large diffs are not rendered by default.

Loading

0 comments on commit 266b7a3

Please sign in to comment.