May depend on #45
See threshold-network/keep-core#3630
after_abi_hook in keep-core renames structures that were incorrectly re-declared in the same Go package given this bug: ethereum/go-ethereum#24627.
The generated tbtc/gen/abi/Bridge.go, tbtc/gen/abi/WalletCoordinator.go, and tbtc/gen/abi/MaintainerProxy.go declare BitcoinTxInfo struct. To make the Go compiler happy, we rename BitcoinTxInfo to BitcoinTxInfo2 and BitcoinTxInfo3.
Those Go files are generated with @go run github.com/ethereum/go-ethereum/cmd/abigen.
But this is not enough! If we try to build the project with just this hook, we will encounter errors like:
pkg/chain/ethereum/tbtc/gen/contract/MaintainerProxy.go:730:3: cannot use arg_mainUtxo (variable of type "[github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi](http://github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi)".BitcoinTxUTXO) as type "[github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi](http://github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi)".BitcoinTxUTXO2 in argument to mp.contract.NotifyMovingFundsBelowDust
Looking at the generated code at the problematic line:
transaction, err := mp.contract.NotifyMovingFundsBelowDust(
transactorOptions,
arg_walletPubKeyHash,
arg_mainUtxo,
)
mp.contract.NotifyFundsBelowDust is declared in the tbtc/gen/abi/MaintainerProxy.go and expects BitcoinTxUTXO2.
arg_mainUtxo from tbtc/gen/contract/MaintainerProxy.go has an incorrect type though: arg_mainUtxo abi.BitcoinTxUTXO,
Just like tbtc/gen/abi/MaintainerProxy.go this file is generated based on tbtc/gen/abi/MaintainerProxy.abi and in the *.abi file we don't have the rename performed by after_abi_hook.
The compilation error was solved with the after_contract_hook which is partially a result of ethereum/go-ethereum#24627 and partially how our Go contract bindings work. The fix from ethereum/go-ethereum#24924 will change the generated tbtc/gen/abi/*.go files but we'll have to adjust the @go run github.com/keep-network/keep-common/tools/generators/ethereum logic to follow the same naming rules as the *.abi file will remain unchanged.
May depend on #45
See threshold-network/keep-core#3630
after_abi_hookinkeep-corerenames structures that were incorrectly re-declared in the same Go package given this bug: ethereum/go-ethereum#24627.The generated
tbtc/gen/abi/Bridge.go,tbtc/gen/abi/WalletCoordinator.go, andtbtc/gen/abi/MaintainerProxy.godeclareBitcoinTxInfostruct. To make the Go compiler happy, we renameBitcoinTxInfotoBitcoinTxInfo2andBitcoinTxInfo3.Those Go files are generated with
@go run github.com/ethereum/go-ethereum/cmd/abigen.But this is not enough! If we try to build the project with just this hook, we will encounter errors like:
Looking at the generated code at the problematic line:
mp.contract.NotifyFundsBelowDustis declared in thetbtc/gen/abi/MaintainerProxy.goand expectsBitcoinTxUTXO2.arg_mainUtxofromtbtc/gen/contract/MaintainerProxy.gohas an incorrect type though:arg_mainUtxo abi.BitcoinTxUTXO,Just like
tbtc/gen/abi/MaintainerProxy.gothis file is generated based ontbtc/gen/abi/MaintainerProxy.abiand in the*.abifile we don't have the rename performed byafter_abi_hook.The compilation error was solved with the
after_contract_hookwhich is partially a result of ethereum/go-ethereum#24627 and partially how our Go contract bindings work. The fix from ethereum/go-ethereum#24924 will change the generatedtbtc/gen/abi/*.gofiles but we'll have to adjust the@go run github.com/keep-network/keep-common/tools/generators/ethereumlogic to follow the same naming rules as the*.abifile will remain unchanged.