From 595db117ed4cbe08e259fea1c6bc6b56adfc9290 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 5 Dec 2023 16:33:28 +0100 Subject: [PATCH 1/6] Re-generate tbtc contract bindings Here we re-generate tbtc contracts bindings in order to include the new `WalletProposalValidator` contract and remove the obsolete `WalletCoordinator`. --- pkg/chain/ethereum/tbtc/gen/Makefile | 12 +- ...letCoordinator => WalletProposalValidator} | 0 .../tbtc/gen/abi/WalletCoordinator.go | 2857 --------- .../tbtc/gen/abi/WalletProposalValidator.go | 534 ++ .../tbtc/gen/cmd/WalletCoordinator.go | 1908 ------ .../tbtc/gen/cmd/WalletProposalValidator.go | 446 ++ .../tbtc/gen/contract/WalletCoordinator.go | 5398 ----------------- .../gen/contract/WalletProposalValidator.go | 497 ++ pkg/chain/ethereum/tbtc/gen/gen.go | 10 +- 9 files changed, 1489 insertions(+), 10173 deletions(-) rename pkg/chain/ethereum/tbtc/gen/_address/{WalletCoordinator => WalletProposalValidator} (100%) delete mode 100644 pkg/chain/ethereum/tbtc/gen/abi/WalletCoordinator.go create mode 100644 pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go delete mode 100644 pkg/chain/ethereum/tbtc/gen/cmd/WalletCoordinator.go create mode 100644 pkg/chain/ethereum/tbtc/gen/cmd/WalletProposalValidator.go delete mode 100644 pkg/chain/ethereum/tbtc/gen/contract/WalletCoordinator.go create mode 100644 pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go diff --git a/pkg/chain/ethereum/tbtc/gen/Makefile b/pkg/chain/ethereum/tbtc/gen/Makefile index 6a2f92ff62..cab28225a3 100644 --- a/pkg/chain/ethereum/tbtc/gen/Makefile +++ b/pkg/chain/ethereum/tbtc/gen/Makefile @@ -1,18 +1,18 @@ npm_package_name=@keep-network/tbtc-v2 # Contracts for which the bindings should be generated. -required_contracts := Bridge MaintainerProxy LightRelay LightRelayMaintainerProxy WalletCoordinator +required_contracts := Bridge MaintainerProxy LightRelay LightRelayMaintainerProxy WalletProposalValidator # 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 Bridge, WalletCoordinator and MaintainerProxy contracts all use +# for us because Bridge, WalletProposalValidator 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 structs in the WalletCoordinator and MaintainerProxy output files. +# the conflicting structs in the WalletProposalValidator 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. # @@ -20,11 +20,11 @@ required_contracts := Bridge MaintainerProxy LightRelay LightRelayMaintainerProx # https://github.com/keep-network/keep-core/issues/3524 define after_abi_hook $(eval type := $(1)) - $(if $(filter $(type),WalletCoordinator),$(call fix_wallet_coordinator_collision)) + $(if $(filter $(type),WalletProposalValidator),$(call fix_wallet_proposal_validator_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 +define fix_wallet_proposal_validator_collision + @perl -pi -e s,BitcoinTxInfo,BitcoinTxInfo2,g ./abi/WalletProposalValidator.go endef define fix_maintainer_proxy_collision @perl -pi -e s,BitcoinTxUTXO,BitcoinTxUTXO2,g ./abi/MaintainerProxy.go diff --git a/pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator b/pkg/chain/ethereum/tbtc/gen/_address/WalletProposalValidator similarity index 100% rename from pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator rename to pkg/chain/ethereum/tbtc/gen/_address/WalletProposalValidator diff --git a/pkg/chain/ethereum/tbtc/gen/abi/WalletCoordinator.go b/pkg/chain/ethereum/tbtc/gen/abi/WalletCoordinator.go deleted file mode 100644 index 786b9ceeba..0000000000 --- a/pkg/chain/ethereum/tbtc/gen/abi/WalletCoordinator.go +++ /dev/null @@ -1,2857 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package abi - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// BitcoinTxInfo2 is an auto generated low-level Go binding around an user-defined struct. -type BitcoinTxInfo2 struct { - Version [4]byte - InputVector []byte - OutputVector []byte - Locktime [4]byte -} - -// WalletCoordinatorDepositExtraInfo is an auto generated low-level Go binding around an user-defined struct. -type WalletCoordinatorDepositExtraInfo struct { - FundingTx BitcoinTxInfo2 - BlindingFactor [8]byte - WalletPubKeyHash [20]byte - RefundPubKeyHash [20]byte - RefundLocktime [4]byte -} - -// WalletCoordinatorDepositKey is an auto generated low-level Go binding around an user-defined struct. -type WalletCoordinatorDepositKey struct { - FundingTxHash [32]byte - FundingOutputIndex uint32 -} - -// WalletCoordinatorDepositSweepProposal is an auto generated low-level Go binding around an user-defined struct. -type WalletCoordinatorDepositSweepProposal struct { - WalletPubKeyHash [20]byte - DepositsKeys []WalletCoordinatorDepositKey - SweepTxFee *big.Int - DepositsRevealBlocks []*big.Int -} - -// WalletCoordinatorRedemptionProposal is an auto generated low-level Go binding around an user-defined struct. -type WalletCoordinatorRedemptionProposal struct { - WalletPubKeyHash [20]byte - RedeemersOutputScripts [][]byte - RedemptionTxFee *big.Int -} - -// WalletCoordinatorMetaData contains all meta data concerning the WalletCoordinator contract. -var WalletCoordinatorMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"CoordinatorAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"CoordinatorRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositSweepProposalValidity\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositMinAge\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositRefundSafetyMargin\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"depositSweepMaxSize\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositSweepProposalSubmissionGasOffset\",\"type\":\"uint32\"}],\"name\":\"DepositSweepProposalParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletCoordinator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"indexed\":false,\"internalType\":\"structWalletCoordinator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"DepositSweepProposalSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"heartbeatRequestValidity\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"heartbeatRequestGasOffset\",\"type\":\"uint32\"}],\"name\":\"HeartbeatRequestParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"HeartbeatRequestSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionProposalValidity\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionRequestMinAge\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionRequestTimeoutSafetyMargin\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"redemptionMaxSize\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionProposalSubmissionGasOffset\",\"type\":\"uint32\"}],\"name\":\"RedemptionProposalParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structWalletCoordinator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"RedemptionProposalSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newReimbursementPool\",\"type\":\"address\"}],\"name\":\"ReimbursementPoolUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletManuallyUnlocked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"addCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositMinAge\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositRefundSafetyMargin\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositSweepMaxSize\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositSweepProposalSubmissionGasOffset\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositSweepProposalValidity\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"heartbeatRequestGasOffset\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"heartbeatRequestValidity\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractBridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isCoordinator\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionMaxSize\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionProposalSubmissionGasOffset\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionProposalValidity\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionRequestMinAge\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionRequestTimeoutSafetyMargin\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"reimbursementPool\",\"outputs\":[{\"internalType\":\"contractReimbursementPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"coordinator\",\"type\":\"address\"}],\"name\":\"removeCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"requestHeartbeat\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"requestHeartbeatWithReimbursement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletCoordinator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletCoordinator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"submitDepositSweepProposal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletCoordinator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletCoordinator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"submitDepositSweepProposalWithReimbursement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletCoordinator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"submitRedemptionProposal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletCoordinator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"submitRedemptionProposalWithReimbursement\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"unlockWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_depositSweepProposalValidity\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_depositMinAge\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_depositRefundSafetyMargin\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_depositSweepMaxSize\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"_depositSweepProposalSubmissionGasOffset\",\"type\":\"uint32\"}],\"name\":\"updateDepositSweepProposalParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_heartbeatRequestValidity\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_heartbeatRequestGasOffset\",\"type\":\"uint32\"}],\"name\":\"updateHeartbeatRequestParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_redemptionProposalValidity\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_redemptionRequestMinAge\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_redemptionRequestTimeoutSafetyMargin\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"_redemptionMaxSize\",\"type\":\"uint16\"},{\"internalType\":\"uint32\",\"name\":\"_redemptionProposalSubmissionGasOffset\",\"type\":\"uint32\"}],\"name\":\"updateRedemptionProposalParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contractReimbursementPool\",\"name\":\"_reimbursementPool\",\"type\":\"address\"}],\"name\":\"updateReimbursementPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletCoordinator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletCoordinator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"}],\"internalType\":\"structWalletCoordinator.DepositExtraInfo[]\",\"name\":\"depositsExtraInfo\",\"type\":\"tuple[]\"}],\"name\":\"validateDepositSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletCoordinator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateRedemptionProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"\",\"type\":\"bytes20\"}],\"name\":\"walletLock\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"expiresAt\",\"type\":\"uint32\"},{\"internalType\":\"enumWalletCoordinator.WalletAction\",\"name\":\"cause\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", -} - -// WalletCoordinatorABI is the input ABI used to generate the binding from. -// Deprecated: Use WalletCoordinatorMetaData.ABI instead. -var WalletCoordinatorABI = WalletCoordinatorMetaData.ABI - -// WalletCoordinator is an auto generated Go binding around an Ethereum contract. -type WalletCoordinator struct { - WalletCoordinatorCaller // Read-only binding to the contract - WalletCoordinatorTransactor // Write-only binding to the contract - WalletCoordinatorFilterer // Log filterer for contract events -} - -// WalletCoordinatorCaller is an auto generated read-only Go binding around an Ethereum contract. -type WalletCoordinatorCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// WalletCoordinatorTransactor is an auto generated write-only Go binding around an Ethereum contract. -type WalletCoordinatorTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// WalletCoordinatorFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type WalletCoordinatorFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// WalletCoordinatorSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type WalletCoordinatorSession struct { - Contract *WalletCoordinator // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// WalletCoordinatorCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type WalletCoordinatorCallerSession struct { - Contract *WalletCoordinatorCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// WalletCoordinatorTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type WalletCoordinatorTransactorSession struct { - Contract *WalletCoordinatorTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// WalletCoordinatorRaw is an auto generated low-level Go binding around an Ethereum contract. -type WalletCoordinatorRaw struct { - Contract *WalletCoordinator // Generic contract binding to access the raw methods on -} - -// WalletCoordinatorCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type WalletCoordinatorCallerRaw struct { - Contract *WalletCoordinatorCaller // Generic read-only contract binding to access the raw methods on -} - -// WalletCoordinatorTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type WalletCoordinatorTransactorRaw struct { - Contract *WalletCoordinatorTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewWalletCoordinator creates a new instance of WalletCoordinator, bound to a specific deployed contract. -func NewWalletCoordinator(address common.Address, backend bind.ContractBackend) (*WalletCoordinator, error) { - contract, err := bindWalletCoordinator(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &WalletCoordinator{WalletCoordinatorCaller: WalletCoordinatorCaller{contract: contract}, WalletCoordinatorTransactor: WalletCoordinatorTransactor{contract: contract}, WalletCoordinatorFilterer: WalletCoordinatorFilterer{contract: contract}}, nil -} - -// NewWalletCoordinatorCaller creates a new read-only instance of WalletCoordinator, bound to a specific deployed contract. -func NewWalletCoordinatorCaller(address common.Address, caller bind.ContractCaller) (*WalletCoordinatorCaller, error) { - contract, err := bindWalletCoordinator(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &WalletCoordinatorCaller{contract: contract}, nil -} - -// NewWalletCoordinatorTransactor creates a new write-only instance of WalletCoordinator, bound to a specific deployed contract. -func NewWalletCoordinatorTransactor(address common.Address, transactor bind.ContractTransactor) (*WalletCoordinatorTransactor, error) { - contract, err := bindWalletCoordinator(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &WalletCoordinatorTransactor{contract: contract}, nil -} - -// NewWalletCoordinatorFilterer creates a new log filterer instance of WalletCoordinator, bound to a specific deployed contract. -func NewWalletCoordinatorFilterer(address common.Address, filterer bind.ContractFilterer) (*WalletCoordinatorFilterer, error) { - contract, err := bindWalletCoordinator(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &WalletCoordinatorFilterer{contract: contract}, nil -} - -// bindWalletCoordinator binds a generic wrapper to an already deployed contract. -func bindWalletCoordinator(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(WalletCoordinatorABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_WalletCoordinator *WalletCoordinatorRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _WalletCoordinator.Contract.WalletCoordinatorCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_WalletCoordinator *WalletCoordinatorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WalletCoordinator.Contract.WalletCoordinatorTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_WalletCoordinator *WalletCoordinatorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _WalletCoordinator.Contract.WalletCoordinatorTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_WalletCoordinator *WalletCoordinatorCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _WalletCoordinator.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_WalletCoordinator *WalletCoordinatorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WalletCoordinator.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_WalletCoordinator *WalletCoordinatorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _WalletCoordinator.Contract.contract.Transact(opts, method, params...) -} - -// Bridge is a free data retrieval call binding the contract method 0xe78cea92. -// -// Solidity: function bridge() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCaller) Bridge(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "bridge") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Bridge is a free data retrieval call binding the contract method 0xe78cea92. -// -// Solidity: function bridge() view returns(address) -func (_WalletCoordinator *WalletCoordinatorSession) Bridge() (common.Address, error) { - return _WalletCoordinator.Contract.Bridge(&_WalletCoordinator.CallOpts) -} - -// Bridge is a free data retrieval call binding the contract method 0xe78cea92. -// -// Solidity: function bridge() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCallerSession) Bridge() (common.Address, error) { - return _WalletCoordinator.Contract.Bridge(&_WalletCoordinator.CallOpts) -} - -// DepositMinAge is a free data retrieval call binding the contract method 0xbc20a080. -// -// Solidity: function depositMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) DepositMinAge(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "depositMinAge") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// DepositMinAge is a free data retrieval call binding the contract method 0xbc20a080. -// -// Solidity: function depositMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) DepositMinAge() (uint32, error) { - return _WalletCoordinator.Contract.DepositMinAge(&_WalletCoordinator.CallOpts) -} - -// DepositMinAge is a free data retrieval call binding the contract method 0xbc20a080. -// -// Solidity: function depositMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) DepositMinAge() (uint32, error) { - return _WalletCoordinator.Contract.DepositMinAge(&_WalletCoordinator.CallOpts) -} - -// DepositRefundSafetyMargin is a free data retrieval call binding the contract method 0x31d8c622. -// -// Solidity: function depositRefundSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) DepositRefundSafetyMargin(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "depositRefundSafetyMargin") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// DepositRefundSafetyMargin is a free data retrieval call binding the contract method 0x31d8c622. -// -// Solidity: function depositRefundSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) DepositRefundSafetyMargin() (uint32, error) { - return _WalletCoordinator.Contract.DepositRefundSafetyMargin(&_WalletCoordinator.CallOpts) -} - -// DepositRefundSafetyMargin is a free data retrieval call binding the contract method 0x31d8c622. -// -// Solidity: function depositRefundSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) DepositRefundSafetyMargin() (uint32, error) { - return _WalletCoordinator.Contract.DepositRefundSafetyMargin(&_WalletCoordinator.CallOpts) -} - -// DepositSweepMaxSize is a free data retrieval call binding the contract method 0xacaac705. -// -// Solidity: function depositSweepMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorCaller) DepositSweepMaxSize(opts *bind.CallOpts) (uint16, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "depositSweepMaxSize") - - if err != nil { - return *new(uint16), err - } - - out0 := *abi.ConvertType(out[0], new(uint16)).(*uint16) - - return out0, err - -} - -// DepositSweepMaxSize is a free data retrieval call binding the contract method 0xacaac705. -// -// Solidity: function depositSweepMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorSession) DepositSweepMaxSize() (uint16, error) { - return _WalletCoordinator.Contract.DepositSweepMaxSize(&_WalletCoordinator.CallOpts) -} - -// DepositSweepMaxSize is a free data retrieval call binding the contract method 0xacaac705. -// -// Solidity: function depositSweepMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorCallerSession) DepositSweepMaxSize() (uint16, error) { - return _WalletCoordinator.Contract.DepositSweepMaxSize(&_WalletCoordinator.CallOpts) -} - -// DepositSweepProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x08553292. -// -// Solidity: function depositSweepProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) DepositSweepProposalSubmissionGasOffset(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "depositSweepProposalSubmissionGasOffset") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// DepositSweepProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x08553292. -// -// Solidity: function depositSweepProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) DepositSweepProposalSubmissionGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.DepositSweepProposalSubmissionGasOffset(&_WalletCoordinator.CallOpts) -} - -// DepositSweepProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x08553292. -// -// Solidity: function depositSweepProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) DepositSweepProposalSubmissionGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.DepositSweepProposalSubmissionGasOffset(&_WalletCoordinator.CallOpts) -} - -// DepositSweepProposalValidity is a free data retrieval call binding the contract method 0xf74b37bd. -// -// Solidity: function depositSweepProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) DepositSweepProposalValidity(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "depositSweepProposalValidity") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// DepositSweepProposalValidity is a free data retrieval call binding the contract method 0xf74b37bd. -// -// Solidity: function depositSweepProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) DepositSweepProposalValidity() (uint32, error) { - return _WalletCoordinator.Contract.DepositSweepProposalValidity(&_WalletCoordinator.CallOpts) -} - -// DepositSweepProposalValidity is a free data retrieval call binding the contract method 0xf74b37bd. -// -// Solidity: function depositSweepProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) DepositSweepProposalValidity() (uint32, error) { - return _WalletCoordinator.Contract.DepositSweepProposalValidity(&_WalletCoordinator.CallOpts) -} - -// HeartbeatRequestGasOffset is a free data retrieval call binding the contract method 0xa34fff59. -// -// Solidity: function heartbeatRequestGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) HeartbeatRequestGasOffset(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "heartbeatRequestGasOffset") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// HeartbeatRequestGasOffset is a free data retrieval call binding the contract method 0xa34fff59. -// -// Solidity: function heartbeatRequestGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) HeartbeatRequestGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.HeartbeatRequestGasOffset(&_WalletCoordinator.CallOpts) -} - -// HeartbeatRequestGasOffset is a free data retrieval call binding the contract method 0xa34fff59. -// -// Solidity: function heartbeatRequestGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) HeartbeatRequestGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.HeartbeatRequestGasOffset(&_WalletCoordinator.CallOpts) -} - -// HeartbeatRequestValidity is a free data retrieval call binding the contract method 0x7fbf9b39. -// -// Solidity: function heartbeatRequestValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) HeartbeatRequestValidity(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "heartbeatRequestValidity") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// HeartbeatRequestValidity is a free data retrieval call binding the contract method 0x7fbf9b39. -// -// Solidity: function heartbeatRequestValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) HeartbeatRequestValidity() (uint32, error) { - return _WalletCoordinator.Contract.HeartbeatRequestValidity(&_WalletCoordinator.CallOpts) -} - -// HeartbeatRequestValidity is a free data retrieval call binding the contract method 0x7fbf9b39. -// -// Solidity: function heartbeatRequestValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) HeartbeatRequestValidity() (uint32, error) { - return _WalletCoordinator.Contract.HeartbeatRequestValidity(&_WalletCoordinator.CallOpts) -} - -// IsCoordinator is a free data retrieval call binding the contract method 0xaec32099. -// -// Solidity: function isCoordinator(address ) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCaller) IsCoordinator(opts *bind.CallOpts, arg0 common.Address) (bool, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "isCoordinator", arg0) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsCoordinator is a free data retrieval call binding the contract method 0xaec32099. -// -// Solidity: function isCoordinator(address ) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorSession) IsCoordinator(arg0 common.Address) (bool, error) { - return _WalletCoordinator.Contract.IsCoordinator(&_WalletCoordinator.CallOpts, arg0) -} - -// IsCoordinator is a free data retrieval call binding the contract method 0xaec32099. -// -// Solidity: function isCoordinator(address ) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCallerSession) IsCoordinator(arg0 common.Address) (bool, error) { - return _WalletCoordinator.Contract.IsCoordinator(&_WalletCoordinator.CallOpts, arg0) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_WalletCoordinator *WalletCoordinatorSession) Owner() (common.Address, error) { - return _WalletCoordinator.Contract.Owner(&_WalletCoordinator.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCallerSession) Owner() (common.Address, error) { - return _WalletCoordinator.Contract.Owner(&_WalletCoordinator.CallOpts) -} - -// RedemptionMaxSize is a free data retrieval call binding the contract method 0x6980f9fe. -// -// Solidity: function redemptionMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorCaller) RedemptionMaxSize(opts *bind.CallOpts) (uint16, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "redemptionMaxSize") - - if err != nil { - return *new(uint16), err - } - - out0 := *abi.ConvertType(out[0], new(uint16)).(*uint16) - - return out0, err - -} - -// RedemptionMaxSize is a free data retrieval call binding the contract method 0x6980f9fe. -// -// Solidity: function redemptionMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorSession) RedemptionMaxSize() (uint16, error) { - return _WalletCoordinator.Contract.RedemptionMaxSize(&_WalletCoordinator.CallOpts) -} - -// RedemptionMaxSize is a free data retrieval call binding the contract method 0x6980f9fe. -// -// Solidity: function redemptionMaxSize() view returns(uint16) -func (_WalletCoordinator *WalletCoordinatorCallerSession) RedemptionMaxSize() (uint16, error) { - return _WalletCoordinator.Contract.RedemptionMaxSize(&_WalletCoordinator.CallOpts) -} - -// RedemptionProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x930b4898. -// -// Solidity: function redemptionProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) RedemptionProposalSubmissionGasOffset(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "redemptionProposalSubmissionGasOffset") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// RedemptionProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x930b4898. -// -// Solidity: function redemptionProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) RedemptionProposalSubmissionGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionProposalSubmissionGasOffset(&_WalletCoordinator.CallOpts) -} - -// RedemptionProposalSubmissionGasOffset is a free data retrieval call binding the contract method 0x930b4898. -// -// Solidity: function redemptionProposalSubmissionGasOffset() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) RedemptionProposalSubmissionGasOffset() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionProposalSubmissionGasOffset(&_WalletCoordinator.CallOpts) -} - -// RedemptionProposalValidity is a free data retrieval call binding the contract method 0x300226ae. -// -// Solidity: function redemptionProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) RedemptionProposalValidity(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "redemptionProposalValidity") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// RedemptionProposalValidity is a free data retrieval call binding the contract method 0x300226ae. -// -// Solidity: function redemptionProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) RedemptionProposalValidity() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionProposalValidity(&_WalletCoordinator.CallOpts) -} - -// RedemptionProposalValidity is a free data retrieval call binding the contract method 0x300226ae. -// -// Solidity: function redemptionProposalValidity() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) RedemptionProposalValidity() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionProposalValidity(&_WalletCoordinator.CallOpts) -} - -// RedemptionRequestMinAge is a free data retrieval call binding the contract method 0x6511064d. -// -// Solidity: function redemptionRequestMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) RedemptionRequestMinAge(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "redemptionRequestMinAge") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// RedemptionRequestMinAge is a free data retrieval call binding the contract method 0x6511064d. -// -// Solidity: function redemptionRequestMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) RedemptionRequestMinAge() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionRequestMinAge(&_WalletCoordinator.CallOpts) -} - -// RedemptionRequestMinAge is a free data retrieval call binding the contract method 0x6511064d. -// -// Solidity: function redemptionRequestMinAge() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) RedemptionRequestMinAge() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionRequestMinAge(&_WalletCoordinator.CallOpts) -} - -// RedemptionRequestTimeoutSafetyMargin is a free data retrieval call binding the contract method 0x8aea2ac2. -// -// Solidity: function redemptionRequestTimeoutSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCaller) RedemptionRequestTimeoutSafetyMargin(opts *bind.CallOpts) (uint32, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "redemptionRequestTimeoutSafetyMargin") - - if err != nil { - return *new(uint32), err - } - - out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) - - return out0, err - -} - -// RedemptionRequestTimeoutSafetyMargin is a free data retrieval call binding the contract method 0x8aea2ac2. -// -// Solidity: function redemptionRequestTimeoutSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorSession) RedemptionRequestTimeoutSafetyMargin() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionRequestTimeoutSafetyMargin(&_WalletCoordinator.CallOpts) -} - -// RedemptionRequestTimeoutSafetyMargin is a free data retrieval call binding the contract method 0x8aea2ac2. -// -// Solidity: function redemptionRequestTimeoutSafetyMargin() view returns(uint32) -func (_WalletCoordinator *WalletCoordinatorCallerSession) RedemptionRequestTimeoutSafetyMargin() (uint32, error) { - return _WalletCoordinator.Contract.RedemptionRequestTimeoutSafetyMargin(&_WalletCoordinator.CallOpts) -} - -// ReimbursementPool is a free data retrieval call binding the contract method 0xc09975cd. -// -// Solidity: function reimbursementPool() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCaller) ReimbursementPool(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "reimbursementPool") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// ReimbursementPool is a free data retrieval call binding the contract method 0xc09975cd. -// -// Solidity: function reimbursementPool() view returns(address) -func (_WalletCoordinator *WalletCoordinatorSession) ReimbursementPool() (common.Address, error) { - return _WalletCoordinator.Contract.ReimbursementPool(&_WalletCoordinator.CallOpts) -} - -// ReimbursementPool is a free data retrieval call binding the contract method 0xc09975cd. -// -// Solidity: function reimbursementPool() view returns(address) -func (_WalletCoordinator *WalletCoordinatorCallerSession) ReimbursementPool() (common.Address, error) { - return _WalletCoordinator.Contract.ReimbursementPool(&_WalletCoordinator.CallOpts) -} - -// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. -// -// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCaller) ValidateDepositSweepProposal(opts *bind.CallOpts, proposal WalletCoordinatorDepositSweepProposal, depositsExtraInfo []WalletCoordinatorDepositExtraInfo) (bool, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "validateDepositSweepProposal", proposal, depositsExtraInfo) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. -// -// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorSession) ValidateDepositSweepProposal(proposal WalletCoordinatorDepositSweepProposal, depositsExtraInfo []WalletCoordinatorDepositExtraInfo) (bool, error) { - return _WalletCoordinator.Contract.ValidateDepositSweepProposal(&_WalletCoordinator.CallOpts, proposal, depositsExtraInfo) -} - -// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. -// -// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCallerSession) ValidateDepositSweepProposal(proposal WalletCoordinatorDepositSweepProposal, depositsExtraInfo []WalletCoordinatorDepositExtraInfo) (bool, error) { - return _WalletCoordinator.Contract.ValidateDepositSweepProposal(&_WalletCoordinator.CallOpts, proposal, depositsExtraInfo) -} - -// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. -// -// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCaller) ValidateRedemptionProposal(opts *bind.CallOpts, proposal WalletCoordinatorRedemptionProposal) (bool, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "validateRedemptionProposal", proposal) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. -// -// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorSession) ValidateRedemptionProposal(proposal WalletCoordinatorRedemptionProposal) (bool, error) { - return _WalletCoordinator.Contract.ValidateRedemptionProposal(&_WalletCoordinator.CallOpts, proposal) -} - -// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. -// -// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) -func (_WalletCoordinator *WalletCoordinatorCallerSession) ValidateRedemptionProposal(proposal WalletCoordinatorRedemptionProposal) (bool, error) { - return _WalletCoordinator.Contract.ValidateRedemptionProposal(&_WalletCoordinator.CallOpts, proposal) -} - -// WalletLock is a free data retrieval call binding the contract method 0x2c259d2b. -// -// Solidity: function walletLock(bytes20 ) view returns(uint32 expiresAt, uint8 cause) -func (_WalletCoordinator *WalletCoordinatorCaller) WalletLock(opts *bind.CallOpts, arg0 [20]byte) (struct { - ExpiresAt uint32 - Cause uint8 -}, error) { - var out []interface{} - err := _WalletCoordinator.contract.Call(opts, &out, "walletLock", arg0) - - outstruct := new(struct { - ExpiresAt uint32 - Cause uint8 - }) - if err != nil { - return *outstruct, err - } - - outstruct.ExpiresAt = *abi.ConvertType(out[0], new(uint32)).(*uint32) - outstruct.Cause = *abi.ConvertType(out[1], new(uint8)).(*uint8) - - return *outstruct, err - -} - -// WalletLock is a free data retrieval call binding the contract method 0x2c259d2b. -// -// Solidity: function walletLock(bytes20 ) view returns(uint32 expiresAt, uint8 cause) -func (_WalletCoordinator *WalletCoordinatorSession) WalletLock(arg0 [20]byte) (struct { - ExpiresAt uint32 - Cause uint8 -}, error) { - return _WalletCoordinator.Contract.WalletLock(&_WalletCoordinator.CallOpts, arg0) -} - -// WalletLock is a free data retrieval call binding the contract method 0x2c259d2b. -// -// Solidity: function walletLock(bytes20 ) view returns(uint32 expiresAt, uint8 cause) -func (_WalletCoordinator *WalletCoordinatorCallerSession) WalletLock(arg0 [20]byte) (struct { - ExpiresAt uint32 - Cause uint8 -}, error) { - return _WalletCoordinator.Contract.WalletLock(&_WalletCoordinator.CallOpts, arg0) -} - -// AddCoordinator is a paid mutator transaction binding the contract method 0xfbd6d77e. -// -// Solidity: function addCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) AddCoordinator(opts *bind.TransactOpts, coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "addCoordinator", coordinator) -} - -// AddCoordinator is a paid mutator transaction binding the contract method 0xfbd6d77e. -// -// Solidity: function addCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorSession) AddCoordinator(coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.AddCoordinator(&_WalletCoordinator.TransactOpts, coordinator) -} - -// AddCoordinator is a paid mutator transaction binding the contract method 0xfbd6d77e. -// -// Solidity: function addCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) AddCoordinator(coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.AddCoordinator(&_WalletCoordinator.TransactOpts, coordinator) -} - -// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. -// -// Solidity: function initialize(address _bridge) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) Initialize(opts *bind.TransactOpts, _bridge common.Address) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "initialize", _bridge) -} - -// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. -// -// Solidity: function initialize(address _bridge) returns() -func (_WalletCoordinator *WalletCoordinatorSession) Initialize(_bridge common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.Initialize(&_WalletCoordinator.TransactOpts, _bridge) -} - -// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. -// -// Solidity: function initialize(address _bridge) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) Initialize(_bridge common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.Initialize(&_WalletCoordinator.TransactOpts, _bridge) -} - -// RemoveCoordinator is a paid mutator transaction binding the contract method 0x8cb5a0c0. -// -// Solidity: function removeCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) RemoveCoordinator(opts *bind.TransactOpts, coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "removeCoordinator", coordinator) -} - -// RemoveCoordinator is a paid mutator transaction binding the contract method 0x8cb5a0c0. -// -// Solidity: function removeCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorSession) RemoveCoordinator(coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RemoveCoordinator(&_WalletCoordinator.TransactOpts, coordinator) -} - -// RemoveCoordinator is a paid mutator transaction binding the contract method 0x8cb5a0c0. -// -// Solidity: function removeCoordinator(address coordinator) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) RemoveCoordinator(coordinator common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RemoveCoordinator(&_WalletCoordinator.TransactOpts, coordinator) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_WalletCoordinator *WalletCoordinatorSession) RenounceOwnership() (*types.Transaction, error) { - return _WalletCoordinator.Contract.RenounceOwnership(&_WalletCoordinator.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _WalletCoordinator.Contract.RenounceOwnership(&_WalletCoordinator.TransactOpts) -} - -// RequestHeartbeat is a paid mutator transaction binding the contract method 0x6348c439. -// -// Solidity: function requestHeartbeat(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) RequestHeartbeat(opts *bind.TransactOpts, walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "requestHeartbeat", walletPubKeyHash, message) -} - -// RequestHeartbeat is a paid mutator transaction binding the contract method 0x6348c439. -// -// Solidity: function requestHeartbeat(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorSession) RequestHeartbeat(walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RequestHeartbeat(&_WalletCoordinator.TransactOpts, walletPubKeyHash, message) -} - -// RequestHeartbeat is a paid mutator transaction binding the contract method 0x6348c439. -// -// Solidity: function requestHeartbeat(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) RequestHeartbeat(walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RequestHeartbeat(&_WalletCoordinator.TransactOpts, walletPubKeyHash, message) -} - -// RequestHeartbeatWithReimbursement is a paid mutator transaction binding the contract method 0x34173c2d. -// -// Solidity: function requestHeartbeatWithReimbursement(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) RequestHeartbeatWithReimbursement(opts *bind.TransactOpts, walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "requestHeartbeatWithReimbursement", walletPubKeyHash, message) -} - -// RequestHeartbeatWithReimbursement is a paid mutator transaction binding the contract method 0x34173c2d. -// -// Solidity: function requestHeartbeatWithReimbursement(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorSession) RequestHeartbeatWithReimbursement(walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RequestHeartbeatWithReimbursement(&_WalletCoordinator.TransactOpts, walletPubKeyHash, message) -} - -// RequestHeartbeatWithReimbursement is a paid mutator transaction binding the contract method 0x34173c2d. -// -// Solidity: function requestHeartbeatWithReimbursement(bytes20 walletPubKeyHash, bytes message) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) RequestHeartbeatWithReimbursement(walletPubKeyHash [20]byte, message []byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.RequestHeartbeatWithReimbursement(&_WalletCoordinator.TransactOpts, walletPubKeyHash, message) -} - -// SubmitDepositSweepProposal is a paid mutator transaction binding the contract method 0xf5aceab6. -// -// Solidity: function submitDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) SubmitDepositSweepProposal(opts *bind.TransactOpts, proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "submitDepositSweepProposal", proposal) -} - -// SubmitDepositSweepProposal is a paid mutator transaction binding the contract method 0xf5aceab6. -// -// Solidity: function submitDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorSession) SubmitDepositSweepProposal(proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitDepositSweepProposal(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitDepositSweepProposal is a paid mutator transaction binding the contract method 0xf5aceab6. -// -// Solidity: function submitDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) SubmitDepositSweepProposal(proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitDepositSweepProposal(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitDepositSweepProposalWithReimbursement is a paid mutator transaction binding the contract method 0xb39e1016. -// -// Solidity: function submitDepositSweepProposalWithReimbursement((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) SubmitDepositSweepProposalWithReimbursement(opts *bind.TransactOpts, proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "submitDepositSweepProposalWithReimbursement", proposal) -} - -// SubmitDepositSweepProposalWithReimbursement is a paid mutator transaction binding the contract method 0xb39e1016. -// -// Solidity: function submitDepositSweepProposalWithReimbursement((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorSession) SubmitDepositSweepProposalWithReimbursement(proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitDepositSweepProposalWithReimbursement(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitDepositSweepProposalWithReimbursement is a paid mutator transaction binding the contract method 0xb39e1016. -// -// Solidity: function submitDepositSweepProposalWithReimbursement((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) SubmitDepositSweepProposalWithReimbursement(proposal WalletCoordinatorDepositSweepProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitDepositSweepProposalWithReimbursement(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitRedemptionProposal is a paid mutator transaction binding the contract method 0xe64007d0. -// -// Solidity: function submitRedemptionProposal((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) SubmitRedemptionProposal(opts *bind.TransactOpts, proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "submitRedemptionProposal", proposal) -} - -// SubmitRedemptionProposal is a paid mutator transaction binding the contract method 0xe64007d0. -// -// Solidity: function submitRedemptionProposal((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorSession) SubmitRedemptionProposal(proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitRedemptionProposal(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitRedemptionProposal is a paid mutator transaction binding the contract method 0xe64007d0. -// -// Solidity: function submitRedemptionProposal((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) SubmitRedemptionProposal(proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitRedemptionProposal(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitRedemptionProposalWithReimbursement is a paid mutator transaction binding the contract method 0x265a513e. -// -// Solidity: function submitRedemptionProposalWithReimbursement((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) SubmitRedemptionProposalWithReimbursement(opts *bind.TransactOpts, proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "submitRedemptionProposalWithReimbursement", proposal) -} - -// SubmitRedemptionProposalWithReimbursement is a paid mutator transaction binding the contract method 0x265a513e. -// -// Solidity: function submitRedemptionProposalWithReimbursement((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorSession) SubmitRedemptionProposalWithReimbursement(proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitRedemptionProposalWithReimbursement(&_WalletCoordinator.TransactOpts, proposal) -} - -// SubmitRedemptionProposalWithReimbursement is a paid mutator transaction binding the contract method 0x265a513e. -// -// Solidity: function submitRedemptionProposalWithReimbursement((bytes20,bytes[],uint256) proposal) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) SubmitRedemptionProposalWithReimbursement(proposal WalletCoordinatorRedemptionProposal) (*types.Transaction, error) { - return _WalletCoordinator.Contract.SubmitRedemptionProposalWithReimbursement(&_WalletCoordinator.TransactOpts, proposal) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_WalletCoordinator *WalletCoordinatorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.TransferOwnership(&_WalletCoordinator.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.TransferOwnership(&_WalletCoordinator.TransactOpts, newOwner) -} - -// UnlockWallet is a paid mutator transaction binding the contract method 0x9039bc1c. -// -// Solidity: function unlockWallet(bytes20 walletPubKeyHash) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) UnlockWallet(opts *bind.TransactOpts, walletPubKeyHash [20]byte) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "unlockWallet", walletPubKeyHash) -} - -// UnlockWallet is a paid mutator transaction binding the contract method 0x9039bc1c. -// -// Solidity: function unlockWallet(bytes20 walletPubKeyHash) returns() -func (_WalletCoordinator *WalletCoordinatorSession) UnlockWallet(walletPubKeyHash [20]byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UnlockWallet(&_WalletCoordinator.TransactOpts, walletPubKeyHash) -} - -// UnlockWallet is a paid mutator transaction binding the contract method 0x9039bc1c. -// -// Solidity: function unlockWallet(bytes20 walletPubKeyHash) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) UnlockWallet(walletPubKeyHash [20]byte) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UnlockWallet(&_WalletCoordinator.TransactOpts, walletPubKeyHash) -} - -// UpdateDepositSweepProposalParameters is a paid mutator transaction binding the contract method 0x5486032e. -// -// Solidity: function updateDepositSweepProposalParameters(uint32 _depositSweepProposalValidity, uint32 _depositMinAge, uint32 _depositRefundSafetyMargin, uint16 _depositSweepMaxSize, uint32 _depositSweepProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) UpdateDepositSweepProposalParameters(opts *bind.TransactOpts, _depositSweepProposalValidity uint32, _depositMinAge uint32, _depositRefundSafetyMargin uint32, _depositSweepMaxSize uint16, _depositSweepProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "updateDepositSweepProposalParameters", _depositSweepProposalValidity, _depositMinAge, _depositRefundSafetyMargin, _depositSweepMaxSize, _depositSweepProposalSubmissionGasOffset) -} - -// UpdateDepositSweepProposalParameters is a paid mutator transaction binding the contract method 0x5486032e. -// -// Solidity: function updateDepositSweepProposalParameters(uint32 _depositSweepProposalValidity, uint32 _depositMinAge, uint32 _depositRefundSafetyMargin, uint16 _depositSweepMaxSize, uint32 _depositSweepProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorSession) UpdateDepositSweepProposalParameters(_depositSweepProposalValidity uint32, _depositMinAge uint32, _depositRefundSafetyMargin uint32, _depositSweepMaxSize uint16, _depositSweepProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateDepositSweepProposalParameters(&_WalletCoordinator.TransactOpts, _depositSweepProposalValidity, _depositMinAge, _depositRefundSafetyMargin, _depositSweepMaxSize, _depositSweepProposalSubmissionGasOffset) -} - -// UpdateDepositSweepProposalParameters is a paid mutator transaction binding the contract method 0x5486032e. -// -// Solidity: function updateDepositSweepProposalParameters(uint32 _depositSweepProposalValidity, uint32 _depositMinAge, uint32 _depositRefundSafetyMargin, uint16 _depositSweepMaxSize, uint32 _depositSweepProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) UpdateDepositSweepProposalParameters(_depositSweepProposalValidity uint32, _depositMinAge uint32, _depositRefundSafetyMargin uint32, _depositSweepMaxSize uint16, _depositSweepProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateDepositSweepProposalParameters(&_WalletCoordinator.TransactOpts, _depositSweepProposalValidity, _depositMinAge, _depositRefundSafetyMargin, _depositSweepMaxSize, _depositSweepProposalSubmissionGasOffset) -} - -// UpdateHeartbeatRequestParameters is a paid mutator transaction binding the contract method 0x85a0924c. -// -// Solidity: function updateHeartbeatRequestParameters(uint32 _heartbeatRequestValidity, uint32 _heartbeatRequestGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) UpdateHeartbeatRequestParameters(opts *bind.TransactOpts, _heartbeatRequestValidity uint32, _heartbeatRequestGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "updateHeartbeatRequestParameters", _heartbeatRequestValidity, _heartbeatRequestGasOffset) -} - -// UpdateHeartbeatRequestParameters is a paid mutator transaction binding the contract method 0x85a0924c. -// -// Solidity: function updateHeartbeatRequestParameters(uint32 _heartbeatRequestValidity, uint32 _heartbeatRequestGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorSession) UpdateHeartbeatRequestParameters(_heartbeatRequestValidity uint32, _heartbeatRequestGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateHeartbeatRequestParameters(&_WalletCoordinator.TransactOpts, _heartbeatRequestValidity, _heartbeatRequestGasOffset) -} - -// UpdateHeartbeatRequestParameters is a paid mutator transaction binding the contract method 0x85a0924c. -// -// Solidity: function updateHeartbeatRequestParameters(uint32 _heartbeatRequestValidity, uint32 _heartbeatRequestGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) UpdateHeartbeatRequestParameters(_heartbeatRequestValidity uint32, _heartbeatRequestGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateHeartbeatRequestParameters(&_WalletCoordinator.TransactOpts, _heartbeatRequestValidity, _heartbeatRequestGasOffset) -} - -// UpdateRedemptionProposalParameters is a paid mutator transaction binding the contract method 0x1b9783ff. -// -// Solidity: function updateRedemptionProposalParameters(uint32 _redemptionProposalValidity, uint32 _redemptionRequestMinAge, uint32 _redemptionRequestTimeoutSafetyMargin, uint16 _redemptionMaxSize, uint32 _redemptionProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) UpdateRedemptionProposalParameters(opts *bind.TransactOpts, _redemptionProposalValidity uint32, _redemptionRequestMinAge uint32, _redemptionRequestTimeoutSafetyMargin uint32, _redemptionMaxSize uint16, _redemptionProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "updateRedemptionProposalParameters", _redemptionProposalValidity, _redemptionRequestMinAge, _redemptionRequestTimeoutSafetyMargin, _redemptionMaxSize, _redemptionProposalSubmissionGasOffset) -} - -// UpdateRedemptionProposalParameters is a paid mutator transaction binding the contract method 0x1b9783ff. -// -// Solidity: function updateRedemptionProposalParameters(uint32 _redemptionProposalValidity, uint32 _redemptionRequestMinAge, uint32 _redemptionRequestTimeoutSafetyMargin, uint16 _redemptionMaxSize, uint32 _redemptionProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorSession) UpdateRedemptionProposalParameters(_redemptionProposalValidity uint32, _redemptionRequestMinAge uint32, _redemptionRequestTimeoutSafetyMargin uint32, _redemptionMaxSize uint16, _redemptionProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateRedemptionProposalParameters(&_WalletCoordinator.TransactOpts, _redemptionProposalValidity, _redemptionRequestMinAge, _redemptionRequestTimeoutSafetyMargin, _redemptionMaxSize, _redemptionProposalSubmissionGasOffset) -} - -// UpdateRedemptionProposalParameters is a paid mutator transaction binding the contract method 0x1b9783ff. -// -// Solidity: function updateRedemptionProposalParameters(uint32 _redemptionProposalValidity, uint32 _redemptionRequestMinAge, uint32 _redemptionRequestTimeoutSafetyMargin, uint16 _redemptionMaxSize, uint32 _redemptionProposalSubmissionGasOffset) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) UpdateRedemptionProposalParameters(_redemptionProposalValidity uint32, _redemptionRequestMinAge uint32, _redemptionRequestTimeoutSafetyMargin uint32, _redemptionMaxSize uint16, _redemptionProposalSubmissionGasOffset uint32) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateRedemptionProposalParameters(&_WalletCoordinator.TransactOpts, _redemptionProposalValidity, _redemptionRequestMinAge, _redemptionRequestTimeoutSafetyMargin, _redemptionMaxSize, _redemptionProposalSubmissionGasOffset) -} - -// UpdateReimbursementPool is a paid mutator transaction binding the contract method 0x7b35b4e6. -// -// Solidity: function updateReimbursementPool(address _reimbursementPool) returns() -func (_WalletCoordinator *WalletCoordinatorTransactor) UpdateReimbursementPool(opts *bind.TransactOpts, _reimbursementPool common.Address) (*types.Transaction, error) { - return _WalletCoordinator.contract.Transact(opts, "updateReimbursementPool", _reimbursementPool) -} - -// UpdateReimbursementPool is a paid mutator transaction binding the contract method 0x7b35b4e6. -// -// Solidity: function updateReimbursementPool(address _reimbursementPool) returns() -func (_WalletCoordinator *WalletCoordinatorSession) UpdateReimbursementPool(_reimbursementPool common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateReimbursementPool(&_WalletCoordinator.TransactOpts, _reimbursementPool) -} - -// UpdateReimbursementPool is a paid mutator transaction binding the contract method 0x7b35b4e6. -// -// Solidity: function updateReimbursementPool(address _reimbursementPool) returns() -func (_WalletCoordinator *WalletCoordinatorTransactorSession) UpdateReimbursementPool(_reimbursementPool common.Address) (*types.Transaction, error) { - return _WalletCoordinator.Contract.UpdateReimbursementPool(&_WalletCoordinator.TransactOpts, _reimbursementPool) -} - -// WalletCoordinatorCoordinatorAddedIterator is returned from FilterCoordinatorAdded and is used to iterate over the raw logs and unpacked data for CoordinatorAdded events raised by the WalletCoordinator contract. -type WalletCoordinatorCoordinatorAddedIterator struct { - Event *WalletCoordinatorCoordinatorAdded // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorCoordinatorAddedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorCoordinatorAdded) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorCoordinatorAdded) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorCoordinatorAddedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorCoordinatorAddedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorCoordinatorAdded represents a CoordinatorAdded event raised by the WalletCoordinator contract. -type WalletCoordinatorCoordinatorAdded struct { - Coordinator common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterCoordinatorAdded is a free log retrieval operation binding the contract event 0x56e6c5206d2baab7a01569b19d84b5963ca9f96e10f55076b5e5987fbf780cf5. -// -// Solidity: event CoordinatorAdded(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterCoordinatorAdded(opts *bind.FilterOpts, coordinator []common.Address) (*WalletCoordinatorCoordinatorAddedIterator, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "CoordinatorAdded", coordinatorRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorCoordinatorAddedIterator{contract: _WalletCoordinator.contract, event: "CoordinatorAdded", logs: logs, sub: sub}, nil -} - -// WatchCoordinatorAdded is a free log subscription operation binding the contract event 0x56e6c5206d2baab7a01569b19d84b5963ca9f96e10f55076b5e5987fbf780cf5. -// -// Solidity: event CoordinatorAdded(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchCoordinatorAdded(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorCoordinatorAdded, coordinator []common.Address) (event.Subscription, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "CoordinatorAdded", coordinatorRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorCoordinatorAdded) - if err := _WalletCoordinator.contract.UnpackLog(event, "CoordinatorAdded", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseCoordinatorAdded is a log parse operation binding the contract event 0x56e6c5206d2baab7a01569b19d84b5963ca9f96e10f55076b5e5987fbf780cf5. -// -// Solidity: event CoordinatorAdded(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseCoordinatorAdded(log types.Log) (*WalletCoordinatorCoordinatorAdded, error) { - event := new(WalletCoordinatorCoordinatorAdded) - if err := _WalletCoordinator.contract.UnpackLog(event, "CoordinatorAdded", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorCoordinatorRemovedIterator is returned from FilterCoordinatorRemoved and is used to iterate over the raw logs and unpacked data for CoordinatorRemoved events raised by the WalletCoordinator contract. -type WalletCoordinatorCoordinatorRemovedIterator struct { - Event *WalletCoordinatorCoordinatorRemoved // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorCoordinatorRemovedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorCoordinatorRemoved) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorCoordinatorRemoved) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorCoordinatorRemovedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorCoordinatorRemovedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorCoordinatorRemoved represents a CoordinatorRemoved event raised by the WalletCoordinator contract. -type WalletCoordinatorCoordinatorRemoved struct { - Coordinator common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterCoordinatorRemoved is a free log retrieval operation binding the contract event 0xcf15831020102bbbe0547b0c3460aa49715f2646e0911760d2b069e0fb2f62a1. -// -// Solidity: event CoordinatorRemoved(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterCoordinatorRemoved(opts *bind.FilterOpts, coordinator []common.Address) (*WalletCoordinatorCoordinatorRemovedIterator, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "CoordinatorRemoved", coordinatorRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorCoordinatorRemovedIterator{contract: _WalletCoordinator.contract, event: "CoordinatorRemoved", logs: logs, sub: sub}, nil -} - -// WatchCoordinatorRemoved is a free log subscription operation binding the contract event 0xcf15831020102bbbe0547b0c3460aa49715f2646e0911760d2b069e0fb2f62a1. -// -// Solidity: event CoordinatorRemoved(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchCoordinatorRemoved(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorCoordinatorRemoved, coordinator []common.Address) (event.Subscription, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "CoordinatorRemoved", coordinatorRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorCoordinatorRemoved) - if err := _WalletCoordinator.contract.UnpackLog(event, "CoordinatorRemoved", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseCoordinatorRemoved is a log parse operation binding the contract event 0xcf15831020102bbbe0547b0c3460aa49715f2646e0911760d2b069e0fb2f62a1. -// -// Solidity: event CoordinatorRemoved(address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseCoordinatorRemoved(log types.Log) (*WalletCoordinatorCoordinatorRemoved, error) { - event := new(WalletCoordinatorCoordinatorRemoved) - if err := _WalletCoordinator.contract.UnpackLog(event, "CoordinatorRemoved", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorDepositSweepProposalParametersUpdatedIterator is returned from FilterDepositSweepProposalParametersUpdated and is used to iterate over the raw logs and unpacked data for DepositSweepProposalParametersUpdated events raised by the WalletCoordinator contract. -type WalletCoordinatorDepositSweepProposalParametersUpdatedIterator struct { - Event *WalletCoordinatorDepositSweepProposalParametersUpdated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorDepositSweepProposalParametersUpdatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorDepositSweepProposalParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorDepositSweepProposalParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorDepositSweepProposalParametersUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorDepositSweepProposalParametersUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorDepositSweepProposalParametersUpdated represents a DepositSweepProposalParametersUpdated event raised by the WalletCoordinator contract. -type WalletCoordinatorDepositSweepProposalParametersUpdated struct { - DepositSweepProposalValidity uint32 - DepositMinAge uint32 - DepositRefundSafetyMargin uint32 - DepositSweepMaxSize uint16 - DepositSweepProposalSubmissionGasOffset uint32 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterDepositSweepProposalParametersUpdated is a free log retrieval operation binding the contract event 0xc36fe6b9d74f864b5e345edc3435eb451a80669ec78c8357cc15e3a1d3897a73. -// -// Solidity: event DepositSweepProposalParametersUpdated(uint32 depositSweepProposalValidity, uint32 depositMinAge, uint32 depositRefundSafetyMargin, uint16 depositSweepMaxSize, uint32 depositSweepProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterDepositSweepProposalParametersUpdated(opts *bind.FilterOpts) (*WalletCoordinatorDepositSweepProposalParametersUpdatedIterator, error) { - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "DepositSweepProposalParametersUpdated") - if err != nil { - return nil, err - } - return &WalletCoordinatorDepositSweepProposalParametersUpdatedIterator{contract: _WalletCoordinator.contract, event: "DepositSweepProposalParametersUpdated", logs: logs, sub: sub}, nil -} - -// WatchDepositSweepProposalParametersUpdated is a free log subscription operation binding the contract event 0xc36fe6b9d74f864b5e345edc3435eb451a80669ec78c8357cc15e3a1d3897a73. -// -// Solidity: event DepositSweepProposalParametersUpdated(uint32 depositSweepProposalValidity, uint32 depositMinAge, uint32 depositRefundSafetyMargin, uint16 depositSweepMaxSize, uint32 depositSweepProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchDepositSweepProposalParametersUpdated(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorDepositSweepProposalParametersUpdated) (event.Subscription, error) { - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "DepositSweepProposalParametersUpdated") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorDepositSweepProposalParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "DepositSweepProposalParametersUpdated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseDepositSweepProposalParametersUpdated is a log parse operation binding the contract event 0xc36fe6b9d74f864b5e345edc3435eb451a80669ec78c8357cc15e3a1d3897a73. -// -// Solidity: event DepositSweepProposalParametersUpdated(uint32 depositSweepProposalValidity, uint32 depositMinAge, uint32 depositRefundSafetyMargin, uint16 depositSweepMaxSize, uint32 depositSweepProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseDepositSweepProposalParametersUpdated(log types.Log) (*WalletCoordinatorDepositSweepProposalParametersUpdated, error) { - event := new(WalletCoordinatorDepositSweepProposalParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "DepositSweepProposalParametersUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorDepositSweepProposalSubmittedIterator is returned from FilterDepositSweepProposalSubmitted and is used to iterate over the raw logs and unpacked data for DepositSweepProposalSubmitted events raised by the WalletCoordinator contract. -type WalletCoordinatorDepositSweepProposalSubmittedIterator struct { - Event *WalletCoordinatorDepositSweepProposalSubmitted // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorDepositSweepProposalSubmittedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorDepositSweepProposalSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorDepositSweepProposalSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorDepositSweepProposalSubmittedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorDepositSweepProposalSubmittedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorDepositSweepProposalSubmitted represents a DepositSweepProposalSubmitted event raised by the WalletCoordinator contract. -type WalletCoordinatorDepositSweepProposalSubmitted struct { - Proposal WalletCoordinatorDepositSweepProposal - Coordinator common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterDepositSweepProposalSubmitted is a free log retrieval operation binding the contract event 0x80936884707d12c5d8bb32b32fa91535e4f4200316fb138241181fb647d39fa4. -// -// Solidity: event DepositSweepProposalSubmitted((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterDepositSweepProposalSubmitted(opts *bind.FilterOpts, coordinator []common.Address) (*WalletCoordinatorDepositSweepProposalSubmittedIterator, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "DepositSweepProposalSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorDepositSweepProposalSubmittedIterator{contract: _WalletCoordinator.contract, event: "DepositSweepProposalSubmitted", logs: logs, sub: sub}, nil -} - -// WatchDepositSweepProposalSubmitted is a free log subscription operation binding the contract event 0x80936884707d12c5d8bb32b32fa91535e4f4200316fb138241181fb647d39fa4. -// -// Solidity: event DepositSweepProposalSubmitted((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchDepositSweepProposalSubmitted(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorDepositSweepProposalSubmitted, coordinator []common.Address) (event.Subscription, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "DepositSweepProposalSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorDepositSweepProposalSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "DepositSweepProposalSubmitted", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseDepositSweepProposalSubmitted is a log parse operation binding the contract event 0x80936884707d12c5d8bb32b32fa91535e4f4200316fb138241181fb647d39fa4. -// -// Solidity: event DepositSweepProposalSubmitted((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseDepositSweepProposalSubmitted(log types.Log) (*WalletCoordinatorDepositSweepProposalSubmitted, error) { - event := new(WalletCoordinatorDepositSweepProposalSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "DepositSweepProposalSubmitted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorHeartbeatRequestParametersUpdatedIterator is returned from FilterHeartbeatRequestParametersUpdated and is used to iterate over the raw logs and unpacked data for HeartbeatRequestParametersUpdated events raised by the WalletCoordinator contract. -type WalletCoordinatorHeartbeatRequestParametersUpdatedIterator struct { - Event *WalletCoordinatorHeartbeatRequestParametersUpdated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorHeartbeatRequestParametersUpdatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorHeartbeatRequestParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorHeartbeatRequestParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorHeartbeatRequestParametersUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorHeartbeatRequestParametersUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorHeartbeatRequestParametersUpdated represents a HeartbeatRequestParametersUpdated event raised by the WalletCoordinator contract. -type WalletCoordinatorHeartbeatRequestParametersUpdated struct { - HeartbeatRequestValidity uint32 - HeartbeatRequestGasOffset uint32 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterHeartbeatRequestParametersUpdated is a free log retrieval operation binding the contract event 0xe67c0a182190bf283264290d7208533d5936483c98baee174eeac036b081360a. -// -// Solidity: event HeartbeatRequestParametersUpdated(uint32 heartbeatRequestValidity, uint32 heartbeatRequestGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterHeartbeatRequestParametersUpdated(opts *bind.FilterOpts) (*WalletCoordinatorHeartbeatRequestParametersUpdatedIterator, error) { - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "HeartbeatRequestParametersUpdated") - if err != nil { - return nil, err - } - return &WalletCoordinatorHeartbeatRequestParametersUpdatedIterator{contract: _WalletCoordinator.contract, event: "HeartbeatRequestParametersUpdated", logs: logs, sub: sub}, nil -} - -// WatchHeartbeatRequestParametersUpdated is a free log subscription operation binding the contract event 0xe67c0a182190bf283264290d7208533d5936483c98baee174eeac036b081360a. -// -// Solidity: event HeartbeatRequestParametersUpdated(uint32 heartbeatRequestValidity, uint32 heartbeatRequestGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchHeartbeatRequestParametersUpdated(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorHeartbeatRequestParametersUpdated) (event.Subscription, error) { - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "HeartbeatRequestParametersUpdated") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorHeartbeatRequestParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "HeartbeatRequestParametersUpdated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseHeartbeatRequestParametersUpdated is a log parse operation binding the contract event 0xe67c0a182190bf283264290d7208533d5936483c98baee174eeac036b081360a. -// -// Solidity: event HeartbeatRequestParametersUpdated(uint32 heartbeatRequestValidity, uint32 heartbeatRequestGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseHeartbeatRequestParametersUpdated(log types.Log) (*WalletCoordinatorHeartbeatRequestParametersUpdated, error) { - event := new(WalletCoordinatorHeartbeatRequestParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "HeartbeatRequestParametersUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorHeartbeatRequestSubmittedIterator is returned from FilterHeartbeatRequestSubmitted and is used to iterate over the raw logs and unpacked data for HeartbeatRequestSubmitted events raised by the WalletCoordinator contract. -type WalletCoordinatorHeartbeatRequestSubmittedIterator struct { - Event *WalletCoordinatorHeartbeatRequestSubmitted // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorHeartbeatRequestSubmittedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorHeartbeatRequestSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorHeartbeatRequestSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorHeartbeatRequestSubmittedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorHeartbeatRequestSubmittedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorHeartbeatRequestSubmitted represents a HeartbeatRequestSubmitted event raised by the WalletCoordinator contract. -type WalletCoordinatorHeartbeatRequestSubmitted struct { - WalletPubKeyHash [20]byte - Message []byte - Coordinator common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterHeartbeatRequestSubmitted is a free log retrieval operation binding the contract event 0x46f4f1fc7a1c5c364372f2e4398c3657d5e5cc35ea286f9972459376b29b1384. -// -// Solidity: event HeartbeatRequestSubmitted(bytes20 walletPubKeyHash, bytes message, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterHeartbeatRequestSubmitted(opts *bind.FilterOpts, coordinator []common.Address) (*WalletCoordinatorHeartbeatRequestSubmittedIterator, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "HeartbeatRequestSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorHeartbeatRequestSubmittedIterator{contract: _WalletCoordinator.contract, event: "HeartbeatRequestSubmitted", logs: logs, sub: sub}, nil -} - -// WatchHeartbeatRequestSubmitted is a free log subscription operation binding the contract event 0x46f4f1fc7a1c5c364372f2e4398c3657d5e5cc35ea286f9972459376b29b1384. -// -// Solidity: event HeartbeatRequestSubmitted(bytes20 walletPubKeyHash, bytes message, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchHeartbeatRequestSubmitted(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorHeartbeatRequestSubmitted, coordinator []common.Address) (event.Subscription, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "HeartbeatRequestSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorHeartbeatRequestSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "HeartbeatRequestSubmitted", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseHeartbeatRequestSubmitted is a log parse operation binding the contract event 0x46f4f1fc7a1c5c364372f2e4398c3657d5e5cc35ea286f9972459376b29b1384. -// -// Solidity: event HeartbeatRequestSubmitted(bytes20 walletPubKeyHash, bytes message, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseHeartbeatRequestSubmitted(log types.Log) (*WalletCoordinatorHeartbeatRequestSubmitted, error) { - event := new(WalletCoordinatorHeartbeatRequestSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "HeartbeatRequestSubmitted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the WalletCoordinator contract. -type WalletCoordinatorInitializedIterator struct { - Event *WalletCoordinatorInitialized // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorInitializedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorInitialized) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorInitializedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorInitializedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorInitialized represents a Initialized event raised by the WalletCoordinator contract. -type WalletCoordinatorInitialized struct { - Version uint8 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterInitialized(opts *bind.FilterOpts) (*WalletCoordinatorInitializedIterator, error) { - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return &WalletCoordinatorInitializedIterator{contract: _WalletCoordinator.contract, event: "Initialized", logs: logs, sub: sub}, nil -} - -// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorInitialized) (event.Subscription, error) { - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "Initialized") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorInitialized) - if err := _WalletCoordinator.contract.UnpackLog(event, "Initialized", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. -// -// Solidity: event Initialized(uint8 version) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseInitialized(log types.Log) (*WalletCoordinatorInitialized, error) { - event := new(WalletCoordinatorInitialized) - if err := _WalletCoordinator.contract.UnpackLog(event, "Initialized", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the WalletCoordinator contract. -type WalletCoordinatorOwnershipTransferredIterator struct { - Event *WalletCoordinatorOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorOwnershipTransferred represents a OwnershipTransferred event raised by the WalletCoordinator contract. -type WalletCoordinatorOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*WalletCoordinatorOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorOwnershipTransferredIterator{contract: _WalletCoordinator.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorOwnershipTransferred) - if err := _WalletCoordinator.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseOwnershipTransferred(log types.Log) (*WalletCoordinatorOwnershipTransferred, error) { - event := new(WalletCoordinatorOwnershipTransferred) - if err := _WalletCoordinator.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorRedemptionProposalParametersUpdatedIterator is returned from FilterRedemptionProposalParametersUpdated and is used to iterate over the raw logs and unpacked data for RedemptionProposalParametersUpdated events raised by the WalletCoordinator contract. -type WalletCoordinatorRedemptionProposalParametersUpdatedIterator struct { - Event *WalletCoordinatorRedemptionProposalParametersUpdated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorRedemptionProposalParametersUpdatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorRedemptionProposalParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorRedemptionProposalParametersUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorRedemptionProposalParametersUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorRedemptionProposalParametersUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorRedemptionProposalParametersUpdated represents a RedemptionProposalParametersUpdated event raised by the WalletCoordinator contract. -type WalletCoordinatorRedemptionProposalParametersUpdated struct { - RedemptionProposalValidity uint32 - RedemptionRequestMinAge uint32 - RedemptionRequestTimeoutSafetyMargin uint32 - RedemptionMaxSize uint16 - RedemptionProposalSubmissionGasOffset uint32 - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRedemptionProposalParametersUpdated is a free log retrieval operation binding the contract event 0xa16bb3cf10d251033dcfb3ff6f9601243766f6a3e397b30eb76d69f3fad339c2. -// -// Solidity: event RedemptionProposalParametersUpdated(uint32 redemptionProposalValidity, uint32 redemptionRequestMinAge, uint32 redemptionRequestTimeoutSafetyMargin, uint16 redemptionMaxSize, uint32 redemptionProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterRedemptionProposalParametersUpdated(opts *bind.FilterOpts) (*WalletCoordinatorRedemptionProposalParametersUpdatedIterator, error) { - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "RedemptionProposalParametersUpdated") - if err != nil { - return nil, err - } - return &WalletCoordinatorRedemptionProposalParametersUpdatedIterator{contract: _WalletCoordinator.contract, event: "RedemptionProposalParametersUpdated", logs: logs, sub: sub}, nil -} - -// WatchRedemptionProposalParametersUpdated is a free log subscription operation binding the contract event 0xa16bb3cf10d251033dcfb3ff6f9601243766f6a3e397b30eb76d69f3fad339c2. -// -// Solidity: event RedemptionProposalParametersUpdated(uint32 redemptionProposalValidity, uint32 redemptionRequestMinAge, uint32 redemptionRequestTimeoutSafetyMargin, uint16 redemptionMaxSize, uint32 redemptionProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchRedemptionProposalParametersUpdated(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorRedemptionProposalParametersUpdated) (event.Subscription, error) { - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "RedemptionProposalParametersUpdated") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorRedemptionProposalParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "RedemptionProposalParametersUpdated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRedemptionProposalParametersUpdated is a log parse operation binding the contract event 0xa16bb3cf10d251033dcfb3ff6f9601243766f6a3e397b30eb76d69f3fad339c2. -// -// Solidity: event RedemptionProposalParametersUpdated(uint32 redemptionProposalValidity, uint32 redemptionRequestMinAge, uint32 redemptionRequestTimeoutSafetyMargin, uint16 redemptionMaxSize, uint32 redemptionProposalSubmissionGasOffset) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseRedemptionProposalParametersUpdated(log types.Log) (*WalletCoordinatorRedemptionProposalParametersUpdated, error) { - event := new(WalletCoordinatorRedemptionProposalParametersUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "RedemptionProposalParametersUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorRedemptionProposalSubmittedIterator is returned from FilterRedemptionProposalSubmitted and is used to iterate over the raw logs and unpacked data for RedemptionProposalSubmitted events raised by the WalletCoordinator contract. -type WalletCoordinatorRedemptionProposalSubmittedIterator struct { - Event *WalletCoordinatorRedemptionProposalSubmitted // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorRedemptionProposalSubmittedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorRedemptionProposalSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorRedemptionProposalSubmitted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorRedemptionProposalSubmittedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorRedemptionProposalSubmittedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorRedemptionProposalSubmitted represents a RedemptionProposalSubmitted event raised by the WalletCoordinator contract. -type WalletCoordinatorRedemptionProposalSubmitted struct { - Proposal WalletCoordinatorRedemptionProposal - Coordinator common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRedemptionProposalSubmitted is a free log retrieval operation binding the contract event 0x315f9ad8d0b7518ff779e5acc7c069df04df94325d86b685227473ebd452bb70. -// -// Solidity: event RedemptionProposalSubmitted((bytes20,bytes[],uint256) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterRedemptionProposalSubmitted(opts *bind.FilterOpts, coordinator []common.Address) (*WalletCoordinatorRedemptionProposalSubmittedIterator, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "RedemptionProposalSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorRedemptionProposalSubmittedIterator{contract: _WalletCoordinator.contract, event: "RedemptionProposalSubmitted", logs: logs, sub: sub}, nil -} - -// WatchRedemptionProposalSubmitted is a free log subscription operation binding the contract event 0x315f9ad8d0b7518ff779e5acc7c069df04df94325d86b685227473ebd452bb70. -// -// Solidity: event RedemptionProposalSubmitted((bytes20,bytes[],uint256) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchRedemptionProposalSubmitted(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorRedemptionProposalSubmitted, coordinator []common.Address) (event.Subscription, error) { - - var coordinatorRule []interface{} - for _, coordinatorItem := range coordinator { - coordinatorRule = append(coordinatorRule, coordinatorItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "RedemptionProposalSubmitted", coordinatorRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorRedemptionProposalSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "RedemptionProposalSubmitted", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRedemptionProposalSubmitted is a log parse operation binding the contract event 0x315f9ad8d0b7518ff779e5acc7c069df04df94325d86b685227473ebd452bb70. -// -// Solidity: event RedemptionProposalSubmitted((bytes20,bytes[],uint256) proposal, address indexed coordinator) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseRedemptionProposalSubmitted(log types.Log) (*WalletCoordinatorRedemptionProposalSubmitted, error) { - event := new(WalletCoordinatorRedemptionProposalSubmitted) - if err := _WalletCoordinator.contract.UnpackLog(event, "RedemptionProposalSubmitted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorReimbursementPoolUpdatedIterator is returned from FilterReimbursementPoolUpdated and is used to iterate over the raw logs and unpacked data for ReimbursementPoolUpdated events raised by the WalletCoordinator contract. -type WalletCoordinatorReimbursementPoolUpdatedIterator struct { - Event *WalletCoordinatorReimbursementPoolUpdated // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorReimbursementPoolUpdatedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorReimbursementPoolUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorReimbursementPoolUpdated) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorReimbursementPoolUpdatedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorReimbursementPoolUpdatedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorReimbursementPoolUpdated represents a ReimbursementPoolUpdated event raised by the WalletCoordinator contract. -type WalletCoordinatorReimbursementPoolUpdated struct { - NewReimbursementPool common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterReimbursementPoolUpdated is a free log retrieval operation binding the contract event 0x0e2d2343d31b085b7c4e56d1c8a6ec79f7ab07460386f1c9a1756239fe2533ac. -// -// Solidity: event ReimbursementPoolUpdated(address newReimbursementPool) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterReimbursementPoolUpdated(opts *bind.FilterOpts) (*WalletCoordinatorReimbursementPoolUpdatedIterator, error) { - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "ReimbursementPoolUpdated") - if err != nil { - return nil, err - } - return &WalletCoordinatorReimbursementPoolUpdatedIterator{contract: _WalletCoordinator.contract, event: "ReimbursementPoolUpdated", logs: logs, sub: sub}, nil -} - -// WatchReimbursementPoolUpdated is a free log subscription operation binding the contract event 0x0e2d2343d31b085b7c4e56d1c8a6ec79f7ab07460386f1c9a1756239fe2533ac. -// -// Solidity: event ReimbursementPoolUpdated(address newReimbursementPool) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchReimbursementPoolUpdated(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorReimbursementPoolUpdated) (event.Subscription, error) { - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "ReimbursementPoolUpdated") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorReimbursementPoolUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "ReimbursementPoolUpdated", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseReimbursementPoolUpdated is a log parse operation binding the contract event 0x0e2d2343d31b085b7c4e56d1c8a6ec79f7ab07460386f1c9a1756239fe2533ac. -// -// Solidity: event ReimbursementPoolUpdated(address newReimbursementPool) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseReimbursementPoolUpdated(log types.Log) (*WalletCoordinatorReimbursementPoolUpdated, error) { - event := new(WalletCoordinatorReimbursementPoolUpdated) - if err := _WalletCoordinator.contract.UnpackLog(event, "ReimbursementPoolUpdated", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// WalletCoordinatorWalletManuallyUnlockedIterator is returned from FilterWalletManuallyUnlocked and is used to iterate over the raw logs and unpacked data for WalletManuallyUnlocked events raised by the WalletCoordinator contract. -type WalletCoordinatorWalletManuallyUnlockedIterator struct { - Event *WalletCoordinatorWalletManuallyUnlocked // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *WalletCoordinatorWalletManuallyUnlockedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorWalletManuallyUnlocked) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(WalletCoordinatorWalletManuallyUnlocked) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *WalletCoordinatorWalletManuallyUnlockedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *WalletCoordinatorWalletManuallyUnlockedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// WalletCoordinatorWalletManuallyUnlocked represents a WalletManuallyUnlocked event raised by the WalletCoordinator contract. -type WalletCoordinatorWalletManuallyUnlocked struct { - WalletPubKeyHash [20]byte - Raw types.Log // Blockchain specific contextual infos -} - -// FilterWalletManuallyUnlocked is a free log retrieval operation binding the contract event 0x5ea2f0397ee52fe8e2e6460e92b334c996f3580dc76c022d41b290cb985f41e6. -// -// Solidity: event WalletManuallyUnlocked(bytes20 indexed walletPubKeyHash) -func (_WalletCoordinator *WalletCoordinatorFilterer) FilterWalletManuallyUnlocked(opts *bind.FilterOpts, walletPubKeyHash [][20]byte) (*WalletCoordinatorWalletManuallyUnlockedIterator, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } - - logs, sub, err := _WalletCoordinator.contract.FilterLogs(opts, "WalletManuallyUnlocked", walletPubKeyHashRule) - if err != nil { - return nil, err - } - return &WalletCoordinatorWalletManuallyUnlockedIterator{contract: _WalletCoordinator.contract, event: "WalletManuallyUnlocked", logs: logs, sub: sub}, nil -} - -// WatchWalletManuallyUnlocked is a free log subscription operation binding the contract event 0x5ea2f0397ee52fe8e2e6460e92b334c996f3580dc76c022d41b290cb985f41e6. -// -// Solidity: event WalletManuallyUnlocked(bytes20 indexed walletPubKeyHash) -func (_WalletCoordinator *WalletCoordinatorFilterer) WatchWalletManuallyUnlocked(opts *bind.WatchOpts, sink chan<- *WalletCoordinatorWalletManuallyUnlocked, walletPubKeyHash [][20]byte) (event.Subscription, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } - - logs, sub, err := _WalletCoordinator.contract.WatchLogs(opts, "WalletManuallyUnlocked", walletPubKeyHashRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(WalletCoordinatorWalletManuallyUnlocked) - if err := _WalletCoordinator.contract.UnpackLog(event, "WalletManuallyUnlocked", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseWalletManuallyUnlocked is a log parse operation binding the contract event 0x5ea2f0397ee52fe8e2e6460e92b334c996f3580dc76c022d41b290cb985f41e6. -// -// Solidity: event WalletManuallyUnlocked(bytes20 indexed walletPubKeyHash) -func (_WalletCoordinator *WalletCoordinatorFilterer) ParseWalletManuallyUnlocked(log types.Log) (*WalletCoordinatorWalletManuallyUnlocked, error) { - event := new(WalletCoordinatorWalletManuallyUnlocked) - if err := _WalletCoordinator.contract.UnpackLog(event, "WalletManuallyUnlocked", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go b/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go new file mode 100644 index 0000000000..5a9a581d30 --- /dev/null +++ b/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go @@ -0,0 +1,534 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package abi + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// BitcoinTxInfo2 is an auto generated low-level Go binding around an user-defined struct. +type BitcoinTxInfo2 struct { + Version [4]byte + InputVector []byte + OutputVector []byte + Locktime [4]byte +} + +// WalletProposalValidatorDepositExtraInfo is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorDepositExtraInfo struct { + FundingTx BitcoinTxInfo2 + BlindingFactor [8]byte + WalletPubKeyHash [20]byte + RefundPubKeyHash [20]byte + RefundLocktime [4]byte +} + +// WalletProposalValidatorDepositKey is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorDepositKey struct { + FundingTxHash [32]byte + FundingOutputIndex uint32 +} + +// WalletProposalValidatorDepositSweepProposal is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorDepositSweepProposal struct { + WalletPubKeyHash [20]byte + DepositsKeys []WalletProposalValidatorDepositKey + SweepTxFee *big.Int + DepositsRevealBlocks []*big.Int +} + +// WalletProposalValidatorHeartbeatProposal is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorHeartbeatProposal struct { + WalletPubKeyHash [20]byte + Message []byte +} + +// WalletProposalValidatorRedemptionProposal is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorRedemptionProposal struct { + WalletPubKeyHash [20]byte + RedeemersOutputScripts [][]byte + RedemptionTxFee *big.Int +} + +// WalletProposalValidatorMetaData contains all meta data concerning the WalletProposalValidator contract. +var WalletProposalValidatorMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"contractBridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DEPOSIT_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_REFUND_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_SWEEP_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletProposalValidator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletProposalValidator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"}],\"internalType\":\"structWalletProposalValidator.DepositExtraInfo[]\",\"name\":\"depositsExtraInfo\",\"type\":\"tuple[]\"}],\"name\":\"validateDepositSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structWalletProposalValidator.HeartbeatProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateHeartbeatProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateRedemptionProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// WalletProposalValidatorABI is the input ABI used to generate the binding from. +// Deprecated: Use WalletProposalValidatorMetaData.ABI instead. +var WalletProposalValidatorABI = WalletProposalValidatorMetaData.ABI + +// WalletProposalValidator is an auto generated Go binding around an Ethereum contract. +type WalletProposalValidator struct { + WalletProposalValidatorCaller // Read-only binding to the contract + WalletProposalValidatorTransactor // Write-only binding to the contract + WalletProposalValidatorFilterer // Log filterer for contract events +} + +// WalletProposalValidatorCaller is an auto generated read-only Go binding around an Ethereum contract. +type WalletProposalValidatorCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WalletProposalValidatorTransactor is an auto generated write-only Go binding around an Ethereum contract. +type WalletProposalValidatorTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WalletProposalValidatorFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type WalletProposalValidatorFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// WalletProposalValidatorSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type WalletProposalValidatorSession struct { + Contract *WalletProposalValidator // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// WalletProposalValidatorCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type WalletProposalValidatorCallerSession struct { + Contract *WalletProposalValidatorCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// WalletProposalValidatorTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type WalletProposalValidatorTransactorSession struct { + Contract *WalletProposalValidatorTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// WalletProposalValidatorRaw is an auto generated low-level Go binding around an Ethereum contract. +type WalletProposalValidatorRaw struct { + Contract *WalletProposalValidator // Generic contract binding to access the raw methods on +} + +// WalletProposalValidatorCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type WalletProposalValidatorCallerRaw struct { + Contract *WalletProposalValidatorCaller // Generic read-only contract binding to access the raw methods on +} + +// WalletProposalValidatorTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type WalletProposalValidatorTransactorRaw struct { + Contract *WalletProposalValidatorTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewWalletProposalValidator creates a new instance of WalletProposalValidator, bound to a specific deployed contract. +func NewWalletProposalValidator(address common.Address, backend bind.ContractBackend) (*WalletProposalValidator, error) { + contract, err := bindWalletProposalValidator(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &WalletProposalValidator{WalletProposalValidatorCaller: WalletProposalValidatorCaller{contract: contract}, WalletProposalValidatorTransactor: WalletProposalValidatorTransactor{contract: contract}, WalletProposalValidatorFilterer: WalletProposalValidatorFilterer{contract: contract}}, nil +} + +// NewWalletProposalValidatorCaller creates a new read-only instance of WalletProposalValidator, bound to a specific deployed contract. +func NewWalletProposalValidatorCaller(address common.Address, caller bind.ContractCaller) (*WalletProposalValidatorCaller, error) { + contract, err := bindWalletProposalValidator(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &WalletProposalValidatorCaller{contract: contract}, nil +} + +// NewWalletProposalValidatorTransactor creates a new write-only instance of WalletProposalValidator, bound to a specific deployed contract. +func NewWalletProposalValidatorTransactor(address common.Address, transactor bind.ContractTransactor) (*WalletProposalValidatorTransactor, error) { + contract, err := bindWalletProposalValidator(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &WalletProposalValidatorTransactor{contract: contract}, nil +} + +// NewWalletProposalValidatorFilterer creates a new log filterer instance of WalletProposalValidator, bound to a specific deployed contract. +func NewWalletProposalValidatorFilterer(address common.Address, filterer bind.ContractFilterer) (*WalletProposalValidatorFilterer, error) { + contract, err := bindWalletProposalValidator(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &WalletProposalValidatorFilterer{contract: contract}, nil +} + +// bindWalletProposalValidator binds a generic wrapper to an already deployed contract. +func bindWalletProposalValidator(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(WalletProposalValidatorABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_WalletProposalValidator *WalletProposalValidatorRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WalletProposalValidator.Contract.WalletProposalValidatorCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_WalletProposalValidator *WalletProposalValidatorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WalletProposalValidator.Contract.WalletProposalValidatorTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_WalletProposalValidator *WalletProposalValidatorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WalletProposalValidator.Contract.WalletProposalValidatorTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_WalletProposalValidator *WalletProposalValidatorCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _WalletProposalValidator.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_WalletProposalValidator *WalletProposalValidatorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _WalletProposalValidator.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_WalletProposalValidator *WalletProposalValidatorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _WalletProposalValidator.Contract.contract.Transact(opts, method, params...) +} + +// DEPOSITMINAGE is a free data retrieval call binding the contract method 0x6b562cec. +// +// Solidity: function DEPOSIT_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCaller) DEPOSITMINAGE(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "DEPOSIT_MIN_AGE") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// DEPOSITMINAGE is a free data retrieval call binding the contract method 0x6b562cec. +// +// Solidity: function DEPOSIT_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorSession) DEPOSITMINAGE() (uint32, error) { + return _WalletProposalValidator.Contract.DEPOSITMINAGE(&_WalletProposalValidator.CallOpts) +} + +// DEPOSITMINAGE is a free data retrieval call binding the contract method 0x6b562cec. +// +// Solidity: function DEPOSIT_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) DEPOSITMINAGE() (uint32, error) { + return _WalletProposalValidator.Contract.DEPOSITMINAGE(&_WalletProposalValidator.CallOpts) +} + +// DEPOSITREFUNDSAFETYMARGIN is a free data retrieval call binding the contract method 0x765f28f9. +// +// Solidity: function DEPOSIT_REFUND_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCaller) DEPOSITREFUNDSAFETYMARGIN(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "DEPOSIT_REFUND_SAFETY_MARGIN") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// DEPOSITREFUNDSAFETYMARGIN is a free data retrieval call binding the contract method 0x765f28f9. +// +// Solidity: function DEPOSIT_REFUND_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorSession) DEPOSITREFUNDSAFETYMARGIN() (uint32, error) { + return _WalletProposalValidator.Contract.DEPOSITREFUNDSAFETYMARGIN(&_WalletProposalValidator.CallOpts) +} + +// DEPOSITREFUNDSAFETYMARGIN is a free data retrieval call binding the contract method 0x765f28f9. +// +// Solidity: function DEPOSIT_REFUND_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) DEPOSITREFUNDSAFETYMARGIN() (uint32, error) { + return _WalletProposalValidator.Contract.DEPOSITREFUNDSAFETYMARGIN(&_WalletProposalValidator.CallOpts) +} + +// DEPOSITSWEEPMAXSIZE is a free data retrieval call binding the contract method 0x996a756b. +// +// Solidity: function DEPOSIT_SWEEP_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorCaller) DEPOSITSWEEPMAXSIZE(opts *bind.CallOpts) (uint16, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "DEPOSIT_SWEEP_MAX_SIZE") + + if err != nil { + return *new(uint16), err + } + + out0 := *abi.ConvertType(out[0], new(uint16)).(*uint16) + + return out0, err + +} + +// DEPOSITSWEEPMAXSIZE is a free data retrieval call binding the contract method 0x996a756b. +// +// Solidity: function DEPOSIT_SWEEP_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorSession) DEPOSITSWEEPMAXSIZE() (uint16, error) { + return _WalletProposalValidator.Contract.DEPOSITSWEEPMAXSIZE(&_WalletProposalValidator.CallOpts) +} + +// DEPOSITSWEEPMAXSIZE is a free data retrieval call binding the contract method 0x996a756b. +// +// Solidity: function DEPOSIT_SWEEP_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) DEPOSITSWEEPMAXSIZE() (uint16, error) { + return _WalletProposalValidator.Contract.DEPOSITSWEEPMAXSIZE(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONMAXSIZE is a free data retrieval call binding the contract method 0xe0276b26. +// +// Solidity: function REDEMPTION_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorCaller) REDEMPTIONMAXSIZE(opts *bind.CallOpts) (uint16, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "REDEMPTION_MAX_SIZE") + + if err != nil { + return *new(uint16), err + } + + out0 := *abi.ConvertType(out[0], new(uint16)).(*uint16) + + return out0, err + +} + +// REDEMPTIONMAXSIZE is a free data retrieval call binding the contract method 0xe0276b26. +// +// Solidity: function REDEMPTION_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorSession) REDEMPTIONMAXSIZE() (uint16, error) { + return _WalletProposalValidator.Contract.REDEMPTIONMAXSIZE(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONMAXSIZE is a free data retrieval call binding the contract method 0xe0276b26. +// +// Solidity: function REDEMPTION_MAX_SIZE() view returns(uint16) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) REDEMPTIONMAXSIZE() (uint16, error) { + return _WalletProposalValidator.Contract.REDEMPTIONMAXSIZE(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONREQUESTMINAGE is a free data retrieval call binding the contract method 0xd09520f7. +// +// Solidity: function REDEMPTION_REQUEST_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCaller) REDEMPTIONREQUESTMINAGE(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "REDEMPTION_REQUEST_MIN_AGE") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// REDEMPTIONREQUESTMINAGE is a free data retrieval call binding the contract method 0xd09520f7. +// +// Solidity: function REDEMPTION_REQUEST_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorSession) REDEMPTIONREQUESTMINAGE() (uint32, error) { + return _WalletProposalValidator.Contract.REDEMPTIONREQUESTMINAGE(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONREQUESTMINAGE is a free data retrieval call binding the contract method 0xd09520f7. +// +// Solidity: function REDEMPTION_REQUEST_MIN_AGE() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) REDEMPTIONREQUESTMINAGE() (uint32, error) { + return _WalletProposalValidator.Contract.REDEMPTIONREQUESTMINAGE(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN is a free data retrieval call binding the contract method 0x0538ac1b. +// +// Solidity: function REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCaller) REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN(opts *bind.CallOpts) (uint32, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN") + + if err != nil { + return *new(uint32), err + } + + out0 := *abi.ConvertType(out[0], new(uint32)).(*uint32) + + return out0, err + +} + +// REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN is a free data retrieval call binding the contract method 0x0538ac1b. +// +// Solidity: function REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorSession) REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN() (uint32, error) { + return _WalletProposalValidator.Contract.REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN(&_WalletProposalValidator.CallOpts) +} + +// REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN is a free data retrieval call binding the contract method 0x0538ac1b. +// +// Solidity: function REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN() view returns(uint32) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN() (uint32, error) { + return _WalletProposalValidator.Contract.REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN(&_WalletProposalValidator.CallOpts) +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_WalletProposalValidator *WalletProposalValidatorCaller) Bridge(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "bridge") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_WalletProposalValidator *WalletProposalValidatorSession) Bridge() (common.Address, error) { + return _WalletProposalValidator.Contract.Bridge(&_WalletProposalValidator.CallOpts) +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) Bridge() (common.Address, error) { + return _WalletProposalValidator.Contract.Bridge(&_WalletProposalValidator.CallOpts) +} + +// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. +// +// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCaller) ValidateDepositSweepProposal(opts *bind.CallOpts, proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorDepositExtraInfo) (bool, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "validateDepositSweepProposal", proposal, depositsExtraInfo) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. +// +// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorSession) ValidateDepositSweepProposal(proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorDepositExtraInfo) (bool, error) { + return _WalletProposalValidator.Contract.ValidateDepositSweepProposal(&_WalletProposalValidator.CallOpts, proposal, depositsExtraInfo) +} + +// ValidateDepositSweepProposal is a free data retrieval call binding the contract method 0x7405d7bf. +// +// Solidity: function validateDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes20,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) ValidateDepositSweepProposal(proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorDepositExtraInfo) (bool, error) { + return _WalletProposalValidator.Contract.ValidateDepositSweepProposal(&_WalletProposalValidator.CallOpts, proposal, depositsExtraInfo) +} + +// ValidateHeartbeatProposal is a free data retrieval call binding the contract method 0xf03a4bc5. +// +// Solidity: function validateHeartbeatProposal((bytes20,bytes) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCaller) ValidateHeartbeatProposal(opts *bind.CallOpts, proposal WalletProposalValidatorHeartbeatProposal) (bool, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "validateHeartbeatProposal", proposal) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ValidateHeartbeatProposal is a free data retrieval call binding the contract method 0xf03a4bc5. +// +// Solidity: function validateHeartbeatProposal((bytes20,bytes) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorSession) ValidateHeartbeatProposal(proposal WalletProposalValidatorHeartbeatProposal) (bool, error) { + return _WalletProposalValidator.Contract.ValidateHeartbeatProposal(&_WalletProposalValidator.CallOpts, proposal) +} + +// ValidateHeartbeatProposal is a free data retrieval call binding the contract method 0xf03a4bc5. +// +// Solidity: function validateHeartbeatProposal((bytes20,bytes) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) ValidateHeartbeatProposal(proposal WalletProposalValidatorHeartbeatProposal) (bool, error) { + return _WalletProposalValidator.Contract.ValidateHeartbeatProposal(&_WalletProposalValidator.CallOpts, proposal) +} + +// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. +// +// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCaller) ValidateRedemptionProposal(opts *bind.CallOpts, proposal WalletProposalValidatorRedemptionProposal) (bool, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "validateRedemptionProposal", proposal) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. +// +// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorSession) ValidateRedemptionProposal(proposal WalletProposalValidatorRedemptionProposal) (bool, error) { + return _WalletProposalValidator.Contract.ValidateRedemptionProposal(&_WalletProposalValidator.CallOpts, proposal) +} + +// ValidateRedemptionProposal is a free data retrieval call binding the contract method 0x0fde6c76. +// +// Solidity: function validateRedemptionProposal((bytes20,bytes[],uint256) proposal) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) ValidateRedemptionProposal(proposal WalletProposalValidatorRedemptionProposal) (bool, error) { + return _WalletProposalValidator.Contract.ValidateRedemptionProposal(&_WalletProposalValidator.CallOpts, proposal) +} diff --git a/pkg/chain/ethereum/tbtc/gen/cmd/WalletCoordinator.go b/pkg/chain/ethereum/tbtc/gen/cmd/WalletCoordinator.go deleted file mode 100644 index 97fee599f8..0000000000 --- a/pkg/chain/ethereum/tbtc/gen/cmd/WalletCoordinator.go +++ /dev/null @@ -1,1908 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated command and any manual changes will be lost. - -package cmd - -import ( - "context" - "encoding/json" - "fmt" - "sync" - - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" - - chainutil "github.com/keep-network/keep-common/pkg/chain/ethereum/ethutil" - "github.com/keep-network/keep-common/pkg/cmd" - "github.com/keep-network/keep-common/pkg/utils/decode" - "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi" - "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/contract" - - "github.com/spf13/cobra" -) - -var WalletCoordinatorCommand *cobra.Command - -var walletCoordinatorDescription = `The wallet-coordinator command allows calling the WalletCoordinator contract on an - Ethereum network. It has subcommands corresponding to each contract method, - which respectively each take parameters based on the contract method's - parameters. - - Subcommands will submit a non-mutating call to the network and output the - result. - - All subcommands can be called against a specific block by passing the - -b/--block flag. - - Subcommands for mutating methods may be submitted as a mutating transaction - by passing the -s/--submit flag. In this mode, this command will terminate - successfully once the transaction has been submitted, but will not wait for - the transaction to be included in a block. They return the transaction hash. - - Calls that require ether to be paid will get 0 ether by default, which can - be changed by passing the -v/--value flag.` - -func init() { - WalletCoordinatorCommand := &cobra.Command{ - Use: "wallet-coordinator", - Short: `Provides access to the WalletCoordinator contract.`, - Long: walletCoordinatorDescription, - } - - WalletCoordinatorCommand.AddCommand( - wcBridgeCommand(), - wcDepositMinAgeCommand(), - wcDepositRefundSafetyMarginCommand(), - wcDepositSweepMaxSizeCommand(), - wcDepositSweepProposalSubmissionGasOffsetCommand(), - wcDepositSweepProposalValidityCommand(), - wcHeartbeatRequestGasOffsetCommand(), - wcHeartbeatRequestValidityCommand(), - wcIsCoordinatorCommand(), - wcOwnerCommand(), - wcRedemptionMaxSizeCommand(), - wcRedemptionProposalSubmissionGasOffsetCommand(), - wcRedemptionProposalValidityCommand(), - wcRedemptionRequestMinAgeCommand(), - wcRedemptionRequestTimeoutSafetyMarginCommand(), - wcReimbursementPoolCommand(), - wcValidateRedemptionProposalCommand(), - wcWalletLockCommand(), - wcAddCoordinatorCommand(), - wcInitializeCommand(), - wcRemoveCoordinatorCommand(), - wcRenounceOwnershipCommand(), - wcRequestHeartbeatCommand(), - wcRequestHeartbeatWithReimbursementCommand(), - wcSubmitDepositSweepProposalCommand(), - wcSubmitDepositSweepProposalWithReimbursementCommand(), - wcSubmitRedemptionProposalCommand(), - wcSubmitRedemptionProposalWithReimbursementCommand(), - wcTransferOwnershipCommand(), - wcUnlockWalletCommand(), - wcUpdateDepositSweepProposalParametersCommand(), - wcUpdateHeartbeatRequestParametersCommand(), - wcUpdateRedemptionProposalParametersCommand(), - wcUpdateReimbursementPoolCommand(), - ) - - ModuleCommand.AddCommand(WalletCoordinatorCommand) -} - -/// ------------------- Const methods ------------------- - -func wcBridgeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "bridge", - Short: "Calls the view method bridge on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcBridge, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcBridge(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.BridgeAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcDepositMinAgeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "deposit-min-age", - Short: "Calls the view method depositMinAge on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcDepositMinAge, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcDepositMinAge(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.DepositMinAgeAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcDepositRefundSafetyMarginCommand() *cobra.Command { - c := &cobra.Command{ - Use: "deposit-refund-safety-margin", - Short: "Calls the view method depositRefundSafetyMargin on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcDepositRefundSafetyMargin, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcDepositRefundSafetyMargin(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.DepositRefundSafetyMarginAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcDepositSweepMaxSizeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "deposit-sweep-max-size", - Short: "Calls the view method depositSweepMaxSize on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcDepositSweepMaxSize, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcDepositSweepMaxSize(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.DepositSweepMaxSizeAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcDepositSweepProposalSubmissionGasOffsetCommand() *cobra.Command { - c := &cobra.Command{ - Use: "deposit-sweep-proposal-submission-gas-offset", - Short: "Calls the view method depositSweepProposalSubmissionGasOffset on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcDepositSweepProposalSubmissionGasOffset, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcDepositSweepProposalSubmissionGasOffset(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.DepositSweepProposalSubmissionGasOffsetAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcDepositSweepProposalValidityCommand() *cobra.Command { - c := &cobra.Command{ - Use: "deposit-sweep-proposal-validity", - Short: "Calls the view method depositSweepProposalValidity on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcDepositSweepProposalValidity, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcDepositSweepProposalValidity(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.DepositSweepProposalValidityAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcHeartbeatRequestGasOffsetCommand() *cobra.Command { - c := &cobra.Command{ - Use: "heartbeat-request-gas-offset", - Short: "Calls the view method heartbeatRequestGasOffset on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcHeartbeatRequestGasOffset, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcHeartbeatRequestGasOffset(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.HeartbeatRequestGasOffsetAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcHeartbeatRequestValidityCommand() *cobra.Command { - c := &cobra.Command{ - Use: "heartbeat-request-validity", - Short: "Calls the view method heartbeatRequestValidity on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcHeartbeatRequestValidity, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcHeartbeatRequestValidity(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.HeartbeatRequestValidityAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcIsCoordinatorCommand() *cobra.Command { - c := &cobra.Command{ - Use: "is-coordinator [arg0]", - Short: "Calls the view method isCoordinator on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcIsCoordinator, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcIsCoordinator(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg0, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg0, a address, from passed value %v", - args[0], - ) - } - - result, err := contract.IsCoordinatorAtBlock( - arg0, - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcOwnerCommand() *cobra.Command { - c := &cobra.Command{ - Use: "owner", - Short: "Calls the view method owner on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcOwner, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcOwner(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.OwnerAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcRedemptionMaxSizeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "redemption-max-size", - Short: "Calls the view method redemptionMaxSize on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRedemptionMaxSize, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcRedemptionMaxSize(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.RedemptionMaxSizeAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcRedemptionProposalSubmissionGasOffsetCommand() *cobra.Command { - c := &cobra.Command{ - Use: "redemption-proposal-submission-gas-offset", - Short: "Calls the view method redemptionProposalSubmissionGasOffset on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRedemptionProposalSubmissionGasOffset, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcRedemptionProposalSubmissionGasOffset(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.RedemptionProposalSubmissionGasOffsetAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcRedemptionProposalValidityCommand() *cobra.Command { - c := &cobra.Command{ - Use: "redemption-proposal-validity", - Short: "Calls the view method redemptionProposalValidity on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRedemptionProposalValidity, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcRedemptionProposalValidity(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.RedemptionProposalValidityAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcRedemptionRequestMinAgeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "redemption-request-min-age", - Short: "Calls the view method redemptionRequestMinAge on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRedemptionRequestMinAge, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcRedemptionRequestMinAge(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.RedemptionRequestMinAgeAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcRedemptionRequestTimeoutSafetyMarginCommand() *cobra.Command { - c := &cobra.Command{ - Use: "redemption-request-timeout-safety-margin", - Short: "Calls the view method redemptionRequestTimeoutSafetyMargin on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRedemptionRequestTimeoutSafetyMargin, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcRedemptionRequestTimeoutSafetyMargin(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.RedemptionRequestTimeoutSafetyMarginAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcReimbursementPoolCommand() *cobra.Command { - c := &cobra.Command{ - Use: "reimbursement-pool", - Short: "Calls the view method reimbursementPool on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcReimbursementPool, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcReimbursementPool(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - result, err := contract.ReimbursementPoolAtBlock( - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcValidateRedemptionProposalCommand() *cobra.Command { - c := &cobra.Command{ - Use: "validate-redemption-proposal [arg_proposal_json]", - Short: "Calls the view method validateRedemptionProposal on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcValidateRedemptionProposal, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcValidateRedemptionProposal(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_proposal_json := abi.WalletCoordinatorRedemptionProposal{} - if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletCoordinatorRedemptionProposal: %w", err) - } - - result, err := contract.ValidateRedemptionProposalAtBlock( - arg_proposal_json, - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func wcWalletLockCommand() *cobra.Command { - c := &cobra.Command{ - Use: "wallet-lock [arg0]", - Short: "Calls the view method walletLock on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcWalletLock, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - cmd.InitConstFlags(c) - - return c -} - -func wcWalletLock(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg0, err := decode.ParseBytes20(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg0, a bytes20, from passed value %v", - args[0], - ) - } - - result, err := contract.WalletLockAtBlock( - arg0, - cmd.BlockFlagValue.Int, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -/// ------------------- Non-const methods ------------------- - -func wcAddCoordinatorCommand() *cobra.Command { - c := &cobra.Command{ - Use: "add-coordinator [arg_coordinator]", - Short: "Calls the nonpayable method addCoordinator on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcAddCoordinator, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcAddCoordinator(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_coordinator, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_coordinator, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.AddCoordinator( - arg_coordinator, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallAddCoordinator( - arg_coordinator, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcInitializeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "initialize [arg__bridge]", - Short: "Calls the nonpayable method initialize on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcInitialize, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcInitialize(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg__bridge, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__bridge, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.Initialize( - arg__bridge, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallInitialize( - arg__bridge, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcRemoveCoordinatorCommand() *cobra.Command { - c := &cobra.Command{ - Use: "remove-coordinator [arg_coordinator]", - Short: "Calls the nonpayable method removeCoordinator on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcRemoveCoordinator, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcRemoveCoordinator(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_coordinator, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_coordinator, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.RemoveCoordinator( - arg_coordinator, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallRemoveCoordinator( - arg_coordinator, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcRenounceOwnershipCommand() *cobra.Command { - c := &cobra.Command{ - Use: "renounce-ownership", - Short: "Calls the nonpayable method renounceOwnership on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(0), - RunE: wcRenounceOwnership, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcRenounceOwnership(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.RenounceOwnership() - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallRenounceOwnership( - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcRequestHeartbeatCommand() *cobra.Command { - c := &cobra.Command{ - Use: "request-heartbeat [arg_walletPubKeyHash] [arg_message]", - Short: "Calls the nonpayable method requestHeartbeat on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(2), - RunE: wcRequestHeartbeat, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcRequestHeartbeat(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", - args[0], - ) - } - arg_message, err := hexutil.Decode(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_message, a bytes, from passed value %v", - args[1], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.RequestHeartbeat( - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallRequestHeartbeat( - arg_walletPubKeyHash, - arg_message, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcRequestHeartbeatWithReimbursementCommand() *cobra.Command { - c := &cobra.Command{ - Use: "request-heartbeat-with-reimbursement [arg_walletPubKeyHash] [arg_message]", - Short: "Calls the nonpayable method requestHeartbeatWithReimbursement on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(2), - RunE: wcRequestHeartbeatWithReimbursement, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcRequestHeartbeatWithReimbursement(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", - args[0], - ) - } - arg_message, err := hexutil.Decode(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_message, a bytes, from passed value %v", - args[1], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.RequestHeartbeatWithReimbursement( - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallRequestHeartbeatWithReimbursement( - arg_walletPubKeyHash, - arg_message, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcSubmitDepositSweepProposalCommand() *cobra.Command { - c := &cobra.Command{ - Use: "submit-deposit-sweep-proposal [arg_proposal_json]", - Short: "Calls the nonpayable method submitDepositSweepProposal on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcSubmitDepositSweepProposal, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcSubmitDepositSweepProposal(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_proposal_json := abi.WalletCoordinatorDepositSweepProposal{} - if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletCoordinatorDepositSweepProposal: %w", err) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitDepositSweepProposal( - arg_proposal_json, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallSubmitDepositSweepProposal( - arg_proposal_json, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcSubmitDepositSweepProposalWithReimbursementCommand() *cobra.Command { - c := &cobra.Command{ - Use: "submit-deposit-sweep-proposal-with-reimbursement [arg_proposal_json]", - Short: "Calls the nonpayable method submitDepositSweepProposalWithReimbursement on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcSubmitDepositSweepProposalWithReimbursement, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcSubmitDepositSweepProposalWithReimbursement(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_proposal_json := abi.WalletCoordinatorDepositSweepProposal{} - if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletCoordinatorDepositSweepProposal: %w", err) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitDepositSweepProposalWithReimbursement( - arg_proposal_json, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallSubmitDepositSweepProposalWithReimbursement( - arg_proposal_json, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcSubmitRedemptionProposalCommand() *cobra.Command { - c := &cobra.Command{ - Use: "submit-redemption-proposal [arg_proposal_json]", - Short: "Calls the nonpayable method submitRedemptionProposal on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcSubmitRedemptionProposal, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcSubmitRedemptionProposal(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_proposal_json := abi.WalletCoordinatorRedemptionProposal{} - if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletCoordinatorRedemptionProposal: %w", err) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitRedemptionProposal( - arg_proposal_json, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallSubmitRedemptionProposal( - arg_proposal_json, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcSubmitRedemptionProposalWithReimbursementCommand() *cobra.Command { - c := &cobra.Command{ - Use: "submit-redemption-proposal-with-reimbursement [arg_proposal_json]", - Short: "Calls the nonpayable method submitRedemptionProposalWithReimbursement on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcSubmitRedemptionProposalWithReimbursement, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcSubmitRedemptionProposalWithReimbursement(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_proposal_json := abi.WalletCoordinatorRedemptionProposal{} - if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletCoordinatorRedemptionProposal: %w", err) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitRedemptionProposalWithReimbursement( - arg_proposal_json, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallSubmitRedemptionProposalWithReimbursement( - arg_proposal_json, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcTransferOwnershipCommand() *cobra.Command { - c := &cobra.Command{ - Use: "transfer-ownership [arg_newOwner]", - Short: "Calls the nonpayable method transferOwnership on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcTransferOwnership, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcTransferOwnership(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_newOwner, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_newOwner, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.TransferOwnership( - arg_newOwner, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallTransferOwnership( - arg_newOwner, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcUnlockWalletCommand() *cobra.Command { - c := &cobra.Command{ - Use: "unlock-wallet [arg_walletPubKeyHash]", - Short: "Calls the nonpayable method unlockWallet on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcUnlockWallet, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcUnlockWallet(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.UnlockWallet( - arg_walletPubKeyHash, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallUnlockWallet( - arg_walletPubKeyHash, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcUpdateDepositSweepProposalParametersCommand() *cobra.Command { - c := &cobra.Command{ - Use: "update-deposit-sweep-proposal-parameters [arg__depositSweepProposalValidity] [arg__depositMinAge] [arg__depositRefundSafetyMargin] [arg__depositSweepMaxSize] [arg__depositSweepProposalSubmissionGasOffset]", - Short: "Calls the nonpayable method updateDepositSweepProposalParameters on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(5), - RunE: wcUpdateDepositSweepProposalParameters, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcUpdateDepositSweepProposalParameters(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg__depositSweepProposalValidity, err := decode.ParseUint[uint32](args[0], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__depositSweepProposalValidity, a uint32, from passed value %v", - args[0], - ) - } - arg__depositMinAge, err := decode.ParseUint[uint32](args[1], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__depositMinAge, a uint32, from passed value %v", - args[1], - ) - } - arg__depositRefundSafetyMargin, err := decode.ParseUint[uint32](args[2], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__depositRefundSafetyMargin, a uint32, from passed value %v", - args[2], - ) - } - arg__depositSweepMaxSize, err := decode.ParseUint[uint16](args[3], 16) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__depositSweepMaxSize, a uint16, from passed value %v", - args[3], - ) - } - arg__depositSweepProposalSubmissionGasOffset, err := decode.ParseUint[uint32](args[4], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__depositSweepProposalSubmissionGasOffset, a uint32, from passed value %v", - args[4], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.UpdateDepositSweepProposalParameters( - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallUpdateDepositSweepProposalParameters( - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcUpdateHeartbeatRequestParametersCommand() *cobra.Command { - c := &cobra.Command{ - Use: "update-heartbeat-request-parameters [arg__heartbeatRequestValidity] [arg__heartbeatRequestGasOffset]", - Short: "Calls the nonpayable method updateHeartbeatRequestParameters on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(2), - RunE: wcUpdateHeartbeatRequestParameters, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcUpdateHeartbeatRequestParameters(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg__heartbeatRequestValidity, err := decode.ParseUint[uint32](args[0], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__heartbeatRequestValidity, a uint32, from passed value %v", - args[0], - ) - } - arg__heartbeatRequestGasOffset, err := decode.ParseUint[uint32](args[1], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__heartbeatRequestGasOffset, a uint32, from passed value %v", - args[1], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.UpdateHeartbeatRequestParameters( - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallUpdateHeartbeatRequestParameters( - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcUpdateRedemptionProposalParametersCommand() *cobra.Command { - c := &cobra.Command{ - Use: "update-redemption-proposal-parameters [arg__redemptionProposalValidity] [arg__redemptionRequestMinAge] [arg__redemptionRequestTimeoutSafetyMargin] [arg__redemptionMaxSize] [arg__redemptionProposalSubmissionGasOffset]", - Short: "Calls the nonpayable method updateRedemptionProposalParameters on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(5), - RunE: wcUpdateRedemptionProposalParameters, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcUpdateRedemptionProposalParameters(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg__redemptionProposalValidity, err := decode.ParseUint[uint32](args[0], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__redemptionProposalValidity, a uint32, from passed value %v", - args[0], - ) - } - arg__redemptionRequestMinAge, err := decode.ParseUint[uint32](args[1], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__redemptionRequestMinAge, a uint32, from passed value %v", - args[1], - ) - } - arg__redemptionRequestTimeoutSafetyMargin, err := decode.ParseUint[uint32](args[2], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__redemptionRequestTimeoutSafetyMargin, a uint32, from passed value %v", - args[2], - ) - } - arg__redemptionMaxSize, err := decode.ParseUint[uint16](args[3], 16) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__redemptionMaxSize, a uint16, from passed value %v", - args[3], - ) - } - arg__redemptionProposalSubmissionGasOffset, err := decode.ParseUint[uint32](args[4], 32) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__redemptionProposalSubmissionGasOffset, a uint32, from passed value %v", - args[4], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.UpdateRedemptionProposalParameters( - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallUpdateRedemptionProposalParameters( - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func wcUpdateReimbursementPoolCommand() *cobra.Command { - c := &cobra.Command{ - Use: "update-reimbursement-pool [arg__reimbursementPool]", - Short: "Calls the nonpayable method updateReimbursementPool on the WalletCoordinator contract.", - Args: cmd.ArgCountChecker(1), - RunE: wcUpdateReimbursementPool, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func wcUpdateReimbursementPool(c *cobra.Command, args []string) error { - contract, err := initializeWalletCoordinator(c) - if err != nil { - return err - } - - arg__reimbursementPool, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__reimbursementPool, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.UpdateReimbursementPool( - arg__reimbursementPool, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallUpdateReimbursementPool( - arg__reimbursementPool, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -/// ------------------- Initialization ------------------- - -func initializeWalletCoordinator(c *cobra.Command) (*contract.WalletCoordinator, error) { - cfg := *ModuleCommand.GetConfig() - - client, err := ethclient.Dial(cfg.URL) - if err != nil { - return nil, fmt.Errorf("error connecting to host chain node: [%v]", err) - } - - chainID, err := client.ChainID(context.Background()) - if err != nil { - return nil, fmt.Errorf( - "failed to resolve host chain id: [%v]", - err, - ) - } - - key, err := chainutil.DecryptKeyFile( - cfg.Account.KeyFile, - cfg.Account.KeyFilePassword, - ) - if err != nil { - return nil, fmt.Errorf( - "failed to read KeyFile: %s: [%v]", - cfg.Account.KeyFile, - err, - ) - } - - miningWaiter := chainutil.NewMiningWaiter(client, cfg) - - blockCounter, err := chainutil.NewBlockCounter(client) - if err != nil { - return nil, fmt.Errorf( - "failed to create block counter: [%v]", - err, - ) - } - - address, err := cfg.ContractAddress("WalletCoordinator") - if err != nil { - return nil, fmt.Errorf( - "failed to get %s address: [%w]", - "WalletCoordinator", - err, - ) - } - - return contract.NewWalletCoordinator( - address, - chainID, - key, - client, - chainutil.NewNonceManager(client, key.Address), - miningWaiter, - blockCounter, - &sync.Mutex{}, - ) -} diff --git a/pkg/chain/ethereum/tbtc/gen/cmd/WalletProposalValidator.go b/pkg/chain/ethereum/tbtc/gen/cmd/WalletProposalValidator.go new file mode 100644 index 0000000000..21f2dc6acb --- /dev/null +++ b/pkg/chain/ethereum/tbtc/gen/cmd/WalletProposalValidator.go @@ -0,0 +1,446 @@ +// Code generated - DO NOT EDIT. +// This file is a generated command and any manual changes will be lost. + +package cmd + +import ( + "context" + "encoding/json" + "fmt" + "sync" + + "github.com/ethereum/go-ethereum/ethclient" + + chainutil "github.com/keep-network/keep-common/pkg/chain/ethereum/ethutil" + "github.com/keep-network/keep-common/pkg/cmd" + "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi" + "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/contract" + + "github.com/spf13/cobra" +) + +var WalletProposalValidatorCommand *cobra.Command + +var walletProposalValidatorDescription = `The wallet-proposal-validator command allows calling the WalletProposalValidator contract on an + Ethereum network. It has subcommands corresponding to each contract method, + which respectively each take parameters based on the contract method's + parameters. + + Subcommands will submit a non-mutating call to the network and output the + result. + + All subcommands can be called against a specific block by passing the + -b/--block flag. + + Subcommands for mutating methods may be submitted as a mutating transaction + by passing the -s/--submit flag. In this mode, this command will terminate + successfully once the transaction has been submitted, but will not wait for + the transaction to be included in a block. They return the transaction hash. + + Calls that require ether to be paid will get 0 ether by default, which can + be changed by passing the -v/--value flag.` + +func init() { + WalletProposalValidatorCommand := &cobra.Command{ + Use: "wallet-proposal-validator", + Short: `Provides access to the WalletProposalValidator contract.`, + Long: walletProposalValidatorDescription, + } + + WalletProposalValidatorCommand.AddCommand( + wpvBridgeCommand(), + wpvDEPOSITMINAGECommand(), + wpvDEPOSITREFUNDSAFETYMARGINCommand(), + wpvDEPOSITSWEEPMAXSIZECommand(), + wpvREDEMPTIONMAXSIZECommand(), + wpvREDEMPTIONREQUESTMINAGECommand(), + wpvREDEMPTIONREQUESTTIMEOUTSAFETYMARGINCommand(), + wpvValidateHeartbeatProposalCommand(), + wpvValidateRedemptionProposalCommand(), + ) + + ModuleCommand.AddCommand(WalletProposalValidatorCommand) +} + +/// ------------------- Const methods ------------------- + +func wpvBridgeCommand() *cobra.Command { + c := &cobra.Command{ + Use: "bridge", + Short: "Calls the view method bridge on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvBridge, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvBridge(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.BridgeAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvDEPOSITMINAGECommand() *cobra.Command { + c := &cobra.Command{ + Use: "d-e-p-o-s-i-t-m-i-n-a-g-e", + Short: "Calls the view method dEPOSITMINAGE on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvDEPOSITMINAGE, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvDEPOSITMINAGE(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.DEPOSITMINAGEAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvDEPOSITREFUNDSAFETYMARGINCommand() *cobra.Command { + c := &cobra.Command{ + Use: "d-e-p-o-s-i-t-r-e-f-u-n-d-s-a-f-e-t-y-m-a-r-g-i-n", + Short: "Calls the view method dEPOSITREFUNDSAFETYMARGIN on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvDEPOSITREFUNDSAFETYMARGIN, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvDEPOSITREFUNDSAFETYMARGIN(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.DEPOSITREFUNDSAFETYMARGINAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvDEPOSITSWEEPMAXSIZECommand() *cobra.Command { + c := &cobra.Command{ + Use: "d-e-p-o-s-i-t-s-w-e-e-p-m-a-x-s-i-z-e", + Short: "Calls the view method dEPOSITSWEEPMAXSIZE on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvDEPOSITSWEEPMAXSIZE, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvDEPOSITSWEEPMAXSIZE(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.DEPOSITSWEEPMAXSIZEAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvREDEMPTIONMAXSIZECommand() *cobra.Command { + c := &cobra.Command{ + Use: "r-e-d-e-m-p-t-i-o-n-m-a-x-s-i-z-e", + Short: "Calls the view method rEDEMPTIONMAXSIZE on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvREDEMPTIONMAXSIZE, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvREDEMPTIONMAXSIZE(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.REDEMPTIONMAXSIZEAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvREDEMPTIONREQUESTMINAGECommand() *cobra.Command { + c := &cobra.Command{ + Use: "r-e-d-e-m-p-t-i-o-n-r-e-q-u-e-s-t-m-i-n-a-g-e", + Short: "Calls the view method rEDEMPTIONREQUESTMINAGE on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvREDEMPTIONREQUESTMINAGE, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvREDEMPTIONREQUESTMINAGE(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.REDEMPTIONREQUESTMINAGEAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvREDEMPTIONREQUESTTIMEOUTSAFETYMARGINCommand() *cobra.Command { + c := &cobra.Command{ + Use: "r-e-d-e-m-p-t-i-o-n-r-e-q-u-e-s-t-t-i-m-e-o-u-t-s-a-f-e-t-y-m-a-r-g-i-n", + Short: "Calls the view method rEDEMPTIONREQUESTTIMEOUTSAFETYMARGIN on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(0), + RunE: wpvREDEMPTIONREQUESTTIMEOUTSAFETYMARGIN, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvREDEMPTIONREQUESTTIMEOUTSAFETYMARGIN(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + result, err := contract.REDEMPTIONREQUESTTIMEOUTSAFETYMARGINAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvValidateHeartbeatProposalCommand() *cobra.Command { + c := &cobra.Command{ + Use: "validate-heartbeat-proposal [arg_proposal_json]", + Short: "Calls the view method validateHeartbeatProposal on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(1), + RunE: wpvValidateHeartbeatProposal, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvValidateHeartbeatProposal(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + arg_proposal_json := abi.WalletProposalValidatorHeartbeatProposal{} + if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletProposalValidatorHeartbeatProposal: %w", err) + } + + result, err := contract.ValidateHeartbeatProposalAtBlock( + arg_proposal_json, + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func wpvValidateRedemptionProposalCommand() *cobra.Command { + c := &cobra.Command{ + Use: "validate-redemption-proposal [arg_proposal_json]", + Short: "Calls the view method validateRedemptionProposal on the WalletProposalValidator contract.", + Args: cmd.ArgCountChecker(1), + RunE: wpvValidateRedemptionProposal, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func wpvValidateRedemptionProposal(c *cobra.Command, args []string) error { + contract, err := initializeWalletProposalValidator(c) + if err != nil { + return err + } + + arg_proposal_json := abi.WalletProposalValidatorRedemptionProposal{} + if err := json.Unmarshal([]byte(args[0]), &arg_proposal_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_proposal_json to abi.WalletProposalValidatorRedemptionProposal: %w", err) + } + + result, err := contract.ValidateRedemptionProposalAtBlock( + arg_proposal_json, + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + +/// ------------------- Non-const methods ------------------- + +/// ------------------- Initialization ------------------- + +func initializeWalletProposalValidator(c *cobra.Command) (*contract.WalletProposalValidator, error) { + cfg := *ModuleCommand.GetConfig() + + client, err := ethclient.Dial(cfg.URL) + if err != nil { + return nil, fmt.Errorf("error connecting to host chain node: [%v]", err) + } + + chainID, err := client.ChainID(context.Background()) + if err != nil { + return nil, fmt.Errorf( + "failed to resolve host chain id: [%v]", + err, + ) + } + + key, err := chainutil.DecryptKeyFile( + cfg.Account.KeyFile, + cfg.Account.KeyFilePassword, + ) + if err != nil { + return nil, fmt.Errorf( + "failed to read KeyFile: %s: [%v]", + cfg.Account.KeyFile, + err, + ) + } + + miningWaiter := chainutil.NewMiningWaiter(client, cfg) + + blockCounter, err := chainutil.NewBlockCounter(client) + if err != nil { + return nil, fmt.Errorf( + "failed to create block counter: [%v]", + err, + ) + } + + address, err := cfg.ContractAddress("WalletProposalValidator") + if err != nil { + return nil, fmt.Errorf( + "failed to get %s address: [%w]", + "WalletProposalValidator", + err, + ) + } + + return contract.NewWalletProposalValidator( + address, + chainID, + key, + client, + chainutil.NewNonceManager(client, key.Address), + miningWaiter, + blockCounter, + &sync.Mutex{}, + ) +} diff --git a/pkg/chain/ethereum/tbtc/gen/contract/WalletCoordinator.go b/pkg/chain/ethereum/tbtc/gen/contract/WalletCoordinator.go deleted file mode 100644 index 43ce162145..0000000000 --- a/pkg/chain/ethereum/tbtc/gen/contract/WalletCoordinator.go +++ /dev/null @@ -1,5398 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package contract - -import ( - "context" - "fmt" - "math/big" - "strings" - "sync" - "time" - - hostchainabi "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" - - "github.com/ipfs/go-log" - - "github.com/keep-network/keep-common/pkg/chain/ethereum" - chainutil "github.com/keep-network/keep-common/pkg/chain/ethereum/ethutil" - "github.com/keep-network/keep-common/pkg/subscription" - "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi" -) - -// Create a package-level logger for this contract. The logger exists at -// package level so that the logger is registered at startup and can be -// included or excluded from logging at startup by name. -var wcLogger = log.Logger("keep-contract-WalletCoordinator") - -type WalletCoordinator struct { - contract *abi.WalletCoordinator - contractAddress common.Address - contractABI *hostchainabi.ABI - caller bind.ContractCaller - transactor bind.ContractTransactor - callerOptions *bind.CallOpts - transactorOptions *bind.TransactOpts - errorResolver *chainutil.ErrorResolver - nonceManager *ethereum.NonceManager - miningWaiter *chainutil.MiningWaiter - blockCounter *ethereum.BlockCounter - - transactionMutex *sync.Mutex -} - -func NewWalletCoordinator( - contractAddress common.Address, - chainId *big.Int, - accountKey *keystore.Key, - backend bind.ContractBackend, - nonceManager *ethereum.NonceManager, - miningWaiter *chainutil.MiningWaiter, - blockCounter *ethereum.BlockCounter, - transactionMutex *sync.Mutex, -) (*WalletCoordinator, error) { - callerOptions := &bind.CallOpts{ - From: accountKey.Address, - } - - transactorOptions, err := bind.NewKeyedTransactorWithChainID( - accountKey.PrivateKey, - chainId, - ) - if err != nil { - return nil, fmt.Errorf("failed to instantiate transactor: [%v]", err) - } - - contract, err := abi.NewWalletCoordinator( - contractAddress, - backend, - ) - if err != nil { - return nil, fmt.Errorf( - "failed to instantiate contract at address: %s [%v]", - contractAddress.String(), - err, - ) - } - - contractABI, err := hostchainabi.JSON(strings.NewReader(abi.WalletCoordinatorABI)) - if err != nil { - return nil, fmt.Errorf("failed to instantiate ABI: [%v]", err) - } - - return &WalletCoordinator{ - contract: contract, - contractAddress: contractAddress, - contractABI: &contractABI, - caller: backend, - transactor: backend, - callerOptions: callerOptions, - transactorOptions: transactorOptions, - errorResolver: chainutil.NewErrorResolver(backend, &contractABI, &contractAddress), - nonceManager: nonceManager, - miningWaiter: miningWaiter, - blockCounter: blockCounter, - transactionMutex: transactionMutex, - }, nil -} - -// ----- Non-const Methods ------ - -// Transaction submission. -func (wc *WalletCoordinator) AddCoordinator( - arg_coordinator common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction addCoordinator", - " params: ", - fmt.Sprint( - arg_coordinator, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.AddCoordinator( - transactorOptions, - arg_coordinator, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "addCoordinator", - arg_coordinator, - ) - } - - wcLogger.Infof( - "submitted transaction addCoordinator with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.AddCoordinator( - newTransactorOptions, - arg_coordinator, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "addCoordinator", - arg_coordinator, - ) - } - - wcLogger.Infof( - "submitted transaction addCoordinator with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallAddCoordinator( - arg_coordinator common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "addCoordinator", - &result, - arg_coordinator, - ) - - return err -} - -func (wc *WalletCoordinator) AddCoordinatorGasEstimate( - arg_coordinator common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "addCoordinator", - wc.contractABI, - wc.transactor, - arg_coordinator, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) Initialize( - arg__bridge common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction initialize", - " params: ", - fmt.Sprint( - arg__bridge, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.Initialize( - transactorOptions, - arg__bridge, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "initialize", - arg__bridge, - ) - } - - wcLogger.Infof( - "submitted transaction initialize with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.Initialize( - newTransactorOptions, - arg__bridge, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "initialize", - arg__bridge, - ) - } - - wcLogger.Infof( - "submitted transaction initialize with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallInitialize( - arg__bridge common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "initialize", - &result, - arg__bridge, - ) - - return err -} - -func (wc *WalletCoordinator) InitializeGasEstimate( - arg__bridge common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "initialize", - wc.contractABI, - wc.transactor, - arg__bridge, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) RemoveCoordinator( - arg_coordinator common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction removeCoordinator", - " params: ", - fmt.Sprint( - arg_coordinator, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.RemoveCoordinator( - transactorOptions, - arg_coordinator, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "removeCoordinator", - arg_coordinator, - ) - } - - wcLogger.Infof( - "submitted transaction removeCoordinator with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.RemoveCoordinator( - newTransactorOptions, - arg_coordinator, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "removeCoordinator", - arg_coordinator, - ) - } - - wcLogger.Infof( - "submitted transaction removeCoordinator with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallRemoveCoordinator( - arg_coordinator common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "removeCoordinator", - &result, - arg_coordinator, - ) - - return err -} - -func (wc *WalletCoordinator) RemoveCoordinatorGasEstimate( - arg_coordinator common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "removeCoordinator", - wc.contractABI, - wc.transactor, - arg_coordinator, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) RenounceOwnership( - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction renounceOwnership", - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.RenounceOwnership( - transactorOptions, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "renounceOwnership", - ) - } - - wcLogger.Infof( - "submitted transaction renounceOwnership with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.RenounceOwnership( - newTransactorOptions, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "renounceOwnership", - ) - } - - wcLogger.Infof( - "submitted transaction renounceOwnership with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallRenounceOwnership( - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "renounceOwnership", - &result, - ) - - return err -} - -func (wc *WalletCoordinator) RenounceOwnershipGasEstimate() (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "renounceOwnership", - wc.contractABI, - wc.transactor, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) RequestHeartbeat( - arg_walletPubKeyHash [20]byte, - arg_message []byte, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction requestHeartbeat", - " params: ", - fmt.Sprint( - arg_walletPubKeyHash, - arg_message, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.RequestHeartbeat( - transactorOptions, - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "requestHeartbeat", - arg_walletPubKeyHash, - arg_message, - ) - } - - wcLogger.Infof( - "submitted transaction requestHeartbeat with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.RequestHeartbeat( - newTransactorOptions, - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "requestHeartbeat", - arg_walletPubKeyHash, - arg_message, - ) - } - - wcLogger.Infof( - "submitted transaction requestHeartbeat with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallRequestHeartbeat( - arg_walletPubKeyHash [20]byte, - arg_message []byte, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "requestHeartbeat", - &result, - arg_walletPubKeyHash, - arg_message, - ) - - return err -} - -func (wc *WalletCoordinator) RequestHeartbeatGasEstimate( - arg_walletPubKeyHash [20]byte, - arg_message []byte, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "requestHeartbeat", - wc.contractABI, - wc.transactor, - arg_walletPubKeyHash, - arg_message, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) RequestHeartbeatWithReimbursement( - arg_walletPubKeyHash [20]byte, - arg_message []byte, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction requestHeartbeatWithReimbursement", - " params: ", - fmt.Sprint( - arg_walletPubKeyHash, - arg_message, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.RequestHeartbeatWithReimbursement( - transactorOptions, - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "requestHeartbeatWithReimbursement", - arg_walletPubKeyHash, - arg_message, - ) - } - - wcLogger.Infof( - "submitted transaction requestHeartbeatWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.RequestHeartbeatWithReimbursement( - newTransactorOptions, - arg_walletPubKeyHash, - arg_message, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "requestHeartbeatWithReimbursement", - arg_walletPubKeyHash, - arg_message, - ) - } - - wcLogger.Infof( - "submitted transaction requestHeartbeatWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallRequestHeartbeatWithReimbursement( - arg_walletPubKeyHash [20]byte, - arg_message []byte, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "requestHeartbeatWithReimbursement", - &result, - arg_walletPubKeyHash, - arg_message, - ) - - return err -} - -func (wc *WalletCoordinator) RequestHeartbeatWithReimbursementGasEstimate( - arg_walletPubKeyHash [20]byte, - arg_message []byte, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "requestHeartbeatWithReimbursement", - wc.contractABI, - wc.transactor, - arg_walletPubKeyHash, - arg_message, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) SubmitDepositSweepProposal( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction submitDepositSweepProposal", - " params: ", - fmt.Sprint( - arg_proposal, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.SubmitDepositSweepProposal( - transactorOptions, - arg_proposal, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitDepositSweepProposal", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitDepositSweepProposal with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.SubmitDepositSweepProposal( - newTransactorOptions, - arg_proposal, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitDepositSweepProposal", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitDepositSweepProposal with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallSubmitDepositSweepProposal( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "submitDepositSweepProposal", - &result, - arg_proposal, - ) - - return err -} - -func (wc *WalletCoordinator) SubmitDepositSweepProposalGasEstimate( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "submitDepositSweepProposal", - wc.contractABI, - wc.transactor, - arg_proposal, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) SubmitDepositSweepProposalWithReimbursement( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction submitDepositSweepProposalWithReimbursement", - " params: ", - fmt.Sprint( - arg_proposal, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.SubmitDepositSweepProposalWithReimbursement( - transactorOptions, - arg_proposal, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitDepositSweepProposalWithReimbursement", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitDepositSweepProposalWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.SubmitDepositSweepProposalWithReimbursement( - newTransactorOptions, - arg_proposal, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitDepositSweepProposalWithReimbursement", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitDepositSweepProposalWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallSubmitDepositSweepProposalWithReimbursement( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "submitDepositSweepProposalWithReimbursement", - &result, - arg_proposal, - ) - - return err -} - -func (wc *WalletCoordinator) SubmitDepositSweepProposalWithReimbursementGasEstimate( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "submitDepositSweepProposalWithReimbursement", - wc.contractABI, - wc.transactor, - arg_proposal, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) SubmitRedemptionProposal( - arg_proposal abi.WalletCoordinatorRedemptionProposal, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction submitRedemptionProposal", - " params: ", - fmt.Sprint( - arg_proposal, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.SubmitRedemptionProposal( - transactorOptions, - arg_proposal, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitRedemptionProposal", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitRedemptionProposal with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.SubmitRedemptionProposal( - newTransactorOptions, - arg_proposal, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitRedemptionProposal", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitRedemptionProposal with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallSubmitRedemptionProposal( - arg_proposal abi.WalletCoordinatorRedemptionProposal, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "submitRedemptionProposal", - &result, - arg_proposal, - ) - - return err -} - -func (wc *WalletCoordinator) SubmitRedemptionProposalGasEstimate( - arg_proposal abi.WalletCoordinatorRedemptionProposal, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "submitRedemptionProposal", - wc.contractABI, - wc.transactor, - arg_proposal, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) SubmitRedemptionProposalWithReimbursement( - arg_proposal abi.WalletCoordinatorRedemptionProposal, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction submitRedemptionProposalWithReimbursement", - " params: ", - fmt.Sprint( - arg_proposal, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.SubmitRedemptionProposalWithReimbursement( - transactorOptions, - arg_proposal, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitRedemptionProposalWithReimbursement", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitRedemptionProposalWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.SubmitRedemptionProposalWithReimbursement( - newTransactorOptions, - arg_proposal, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "submitRedemptionProposalWithReimbursement", - arg_proposal, - ) - } - - wcLogger.Infof( - "submitted transaction submitRedemptionProposalWithReimbursement with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallSubmitRedemptionProposalWithReimbursement( - arg_proposal abi.WalletCoordinatorRedemptionProposal, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "submitRedemptionProposalWithReimbursement", - &result, - arg_proposal, - ) - - return err -} - -func (wc *WalletCoordinator) SubmitRedemptionProposalWithReimbursementGasEstimate( - arg_proposal abi.WalletCoordinatorRedemptionProposal, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "submitRedemptionProposalWithReimbursement", - wc.contractABI, - wc.transactor, - arg_proposal, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) TransferOwnership( - arg_newOwner common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction transferOwnership", - " params: ", - fmt.Sprint( - arg_newOwner, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.TransferOwnership( - transactorOptions, - arg_newOwner, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "transferOwnership", - arg_newOwner, - ) - } - - wcLogger.Infof( - "submitted transaction transferOwnership with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.TransferOwnership( - newTransactorOptions, - arg_newOwner, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "transferOwnership", - arg_newOwner, - ) - } - - wcLogger.Infof( - "submitted transaction transferOwnership with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallTransferOwnership( - arg_newOwner common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "transferOwnership", - &result, - arg_newOwner, - ) - - return err -} - -func (wc *WalletCoordinator) TransferOwnershipGasEstimate( - arg_newOwner common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "transferOwnership", - wc.contractABI, - wc.transactor, - arg_newOwner, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) UnlockWallet( - arg_walletPubKeyHash [20]byte, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction unlockWallet", - " params: ", - fmt.Sprint( - arg_walletPubKeyHash, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.UnlockWallet( - transactorOptions, - arg_walletPubKeyHash, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "unlockWallet", - arg_walletPubKeyHash, - ) - } - - wcLogger.Infof( - "submitted transaction unlockWallet with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.UnlockWallet( - newTransactorOptions, - arg_walletPubKeyHash, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "unlockWallet", - arg_walletPubKeyHash, - ) - } - - wcLogger.Infof( - "submitted transaction unlockWallet with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallUnlockWallet( - arg_walletPubKeyHash [20]byte, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "unlockWallet", - &result, - arg_walletPubKeyHash, - ) - - return err -} - -func (wc *WalletCoordinator) UnlockWalletGasEstimate( - arg_walletPubKeyHash [20]byte, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "unlockWallet", - wc.contractABI, - wc.transactor, - arg_walletPubKeyHash, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) UpdateDepositSweepProposalParameters( - arg__depositSweepProposalValidity uint32, - arg__depositMinAge uint32, - arg__depositRefundSafetyMargin uint32, - arg__depositSweepMaxSize uint16, - arg__depositSweepProposalSubmissionGasOffset uint32, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction updateDepositSweepProposalParameters", - " params: ", - fmt.Sprint( - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.UpdateDepositSweepProposalParameters( - transactorOptions, - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateDepositSweepProposalParameters", - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateDepositSweepProposalParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.UpdateDepositSweepProposalParameters( - newTransactorOptions, - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateDepositSweepProposalParameters", - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateDepositSweepProposalParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallUpdateDepositSweepProposalParameters( - arg__depositSweepProposalValidity uint32, - arg__depositMinAge uint32, - arg__depositRefundSafetyMargin uint32, - arg__depositSweepMaxSize uint16, - arg__depositSweepProposalSubmissionGasOffset uint32, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "updateDepositSweepProposalParameters", - &result, - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - - return err -} - -func (wc *WalletCoordinator) UpdateDepositSweepProposalParametersGasEstimate( - arg__depositSweepProposalValidity uint32, - arg__depositMinAge uint32, - arg__depositRefundSafetyMargin uint32, - arg__depositSweepMaxSize uint16, - arg__depositSweepProposalSubmissionGasOffset uint32, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "updateDepositSweepProposalParameters", - wc.contractABI, - wc.transactor, - arg__depositSweepProposalValidity, - arg__depositMinAge, - arg__depositRefundSafetyMargin, - arg__depositSweepMaxSize, - arg__depositSweepProposalSubmissionGasOffset, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) UpdateHeartbeatRequestParameters( - arg__heartbeatRequestValidity uint32, - arg__heartbeatRequestGasOffset uint32, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction updateHeartbeatRequestParameters", - " params: ", - fmt.Sprint( - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.UpdateHeartbeatRequestParameters( - transactorOptions, - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateHeartbeatRequestParameters", - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateHeartbeatRequestParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.UpdateHeartbeatRequestParameters( - newTransactorOptions, - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateHeartbeatRequestParameters", - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateHeartbeatRequestParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallUpdateHeartbeatRequestParameters( - arg__heartbeatRequestValidity uint32, - arg__heartbeatRequestGasOffset uint32, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "updateHeartbeatRequestParameters", - &result, - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - - return err -} - -func (wc *WalletCoordinator) UpdateHeartbeatRequestParametersGasEstimate( - arg__heartbeatRequestValidity uint32, - arg__heartbeatRequestGasOffset uint32, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "updateHeartbeatRequestParameters", - wc.contractABI, - wc.transactor, - arg__heartbeatRequestValidity, - arg__heartbeatRequestGasOffset, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) UpdateRedemptionProposalParameters( - arg__redemptionProposalValidity uint32, - arg__redemptionRequestMinAge uint32, - arg__redemptionRequestTimeoutSafetyMargin uint32, - arg__redemptionMaxSize uint16, - arg__redemptionProposalSubmissionGasOffset uint32, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction updateRedemptionProposalParameters", - " params: ", - fmt.Sprint( - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.UpdateRedemptionProposalParameters( - transactorOptions, - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateRedemptionProposalParameters", - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateRedemptionProposalParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.UpdateRedemptionProposalParameters( - newTransactorOptions, - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateRedemptionProposalParameters", - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - } - - wcLogger.Infof( - "submitted transaction updateRedemptionProposalParameters with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallUpdateRedemptionProposalParameters( - arg__redemptionProposalValidity uint32, - arg__redemptionRequestMinAge uint32, - arg__redemptionRequestTimeoutSafetyMargin uint32, - arg__redemptionMaxSize uint16, - arg__redemptionProposalSubmissionGasOffset uint32, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "updateRedemptionProposalParameters", - &result, - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - - return err -} - -func (wc *WalletCoordinator) UpdateRedemptionProposalParametersGasEstimate( - arg__redemptionProposalValidity uint32, - arg__redemptionRequestMinAge uint32, - arg__redemptionRequestTimeoutSafetyMargin uint32, - arg__redemptionMaxSize uint16, - arg__redemptionProposalSubmissionGasOffset uint32, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "updateRedemptionProposalParameters", - wc.contractABI, - wc.transactor, - arg__redemptionProposalValidity, - arg__redemptionRequestMinAge, - arg__redemptionRequestTimeoutSafetyMargin, - arg__redemptionMaxSize, - arg__redemptionProposalSubmissionGasOffset, - ) - - return result, err -} - -// Transaction submission. -func (wc *WalletCoordinator) UpdateReimbursementPool( - arg__reimbursementPool common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - wcLogger.Debug( - "submitting transaction updateReimbursementPool", - " params: ", - fmt.Sprint( - arg__reimbursementPool, - ), - ) - - wc.transactionMutex.Lock() - defer wc.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *wc.transactorOptions - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := wc.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := wc.contract.UpdateReimbursementPool( - transactorOptions, - arg__reimbursementPool, - ) - if err != nil { - return transaction, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateReimbursementPool", - arg__reimbursementPool, - ) - } - - wcLogger.Infof( - "submitted transaction updateReimbursementPool with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go wc.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := wc.contract.UpdateReimbursementPool( - newTransactorOptions, - arg__reimbursementPool, - ) - if err != nil { - return nil, wc.errorResolver.ResolveError( - err, - wc.transactorOptions.From, - nil, - "updateReimbursementPool", - arg__reimbursementPool, - ) - } - - wcLogger.Infof( - "submitted transaction updateReimbursementPool with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - wc.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (wc *WalletCoordinator) CallUpdateReimbursementPool( - arg__reimbursementPool common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - wc.transactorOptions.From, - blockNumber, nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "updateReimbursementPool", - &result, - arg__reimbursementPool, - ) - - return err -} - -func (wc *WalletCoordinator) UpdateReimbursementPoolGasEstimate( - arg__reimbursementPool common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - wc.callerOptions.From, - wc.contractAddress, - "updateReimbursementPool", - wc.contractABI, - wc.transactor, - arg__reimbursementPool, - ) - - return result, err -} - -// ----- Const Methods ------ - -func (wc *WalletCoordinator) Bridge() (common.Address, error) { - result, err := wc.contract.Bridge( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "bridge", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) BridgeAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "bridge", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) DepositMinAge() (uint32, error) { - result, err := wc.contract.DepositMinAge( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "depositMinAge", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) DepositMinAgeAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "depositMinAge", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) DepositRefundSafetyMargin() (uint32, error) { - result, err := wc.contract.DepositRefundSafetyMargin( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "depositRefundSafetyMargin", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) DepositRefundSafetyMarginAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "depositRefundSafetyMargin", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepMaxSize() (uint16, error) { - result, err := wc.contract.DepositSweepMaxSize( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "depositSweepMaxSize", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepMaxSizeAtBlock( - blockNumber *big.Int, -) (uint16, error) { - var result uint16 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "depositSweepMaxSize", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepProposalSubmissionGasOffset() (uint32, error) { - result, err := wc.contract.DepositSweepProposalSubmissionGasOffset( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "depositSweepProposalSubmissionGasOffset", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepProposalSubmissionGasOffsetAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "depositSweepProposalSubmissionGasOffset", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepProposalValidity() (uint32, error) { - result, err := wc.contract.DepositSweepProposalValidity( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "depositSweepProposalValidity", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) DepositSweepProposalValidityAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "depositSweepProposalValidity", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) HeartbeatRequestGasOffset() (uint32, error) { - result, err := wc.contract.HeartbeatRequestGasOffset( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "heartbeatRequestGasOffset", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) HeartbeatRequestGasOffsetAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "heartbeatRequestGasOffset", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) HeartbeatRequestValidity() (uint32, error) { - result, err := wc.contract.HeartbeatRequestValidity( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "heartbeatRequestValidity", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) HeartbeatRequestValidityAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "heartbeatRequestValidity", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) IsCoordinator( - arg0 common.Address, -) (bool, error) { - result, err := wc.contract.IsCoordinator( - wc.callerOptions, - arg0, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "isCoordinator", - arg0, - ) - } - - return result, err -} - -func (wc *WalletCoordinator) IsCoordinatorAtBlock( - arg0 common.Address, - blockNumber *big.Int, -) (bool, error) { - var result bool - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "isCoordinator", - &result, - arg0, - ) - - return result, err -} - -func (wc *WalletCoordinator) Owner() (common.Address, error) { - result, err := wc.contract.Owner( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "owner", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) OwnerAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "owner", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) RedemptionMaxSize() (uint16, error) { - result, err := wc.contract.RedemptionMaxSize( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "redemptionMaxSize", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) RedemptionMaxSizeAtBlock( - blockNumber *big.Int, -) (uint16, error) { - var result uint16 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "redemptionMaxSize", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) RedemptionProposalSubmissionGasOffset() (uint32, error) { - result, err := wc.contract.RedemptionProposalSubmissionGasOffset( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "redemptionProposalSubmissionGasOffset", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) RedemptionProposalSubmissionGasOffsetAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "redemptionProposalSubmissionGasOffset", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) RedemptionProposalValidity() (uint32, error) { - result, err := wc.contract.RedemptionProposalValidity( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "redemptionProposalValidity", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) RedemptionProposalValidityAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "redemptionProposalValidity", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) RedemptionRequestMinAge() (uint32, error) { - result, err := wc.contract.RedemptionRequestMinAge( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "redemptionRequestMinAge", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) RedemptionRequestMinAgeAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "redemptionRequestMinAge", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) RedemptionRequestTimeoutSafetyMargin() (uint32, error) { - result, err := wc.contract.RedemptionRequestTimeoutSafetyMargin( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "redemptionRequestTimeoutSafetyMargin", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) RedemptionRequestTimeoutSafetyMarginAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "redemptionRequestTimeoutSafetyMargin", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) ReimbursementPool() (common.Address, error) { - result, err := wc.contract.ReimbursementPool( - wc.callerOptions, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "reimbursementPool", - ) - } - - return result, err -} - -func (wc *WalletCoordinator) ReimbursementPoolAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "reimbursementPool", - &result, - ) - - return result, err -} - -func (wc *WalletCoordinator) ValidateDepositSweepProposal( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - arg_depositsExtraInfo []abi.WalletCoordinatorDepositExtraInfo, -) (bool, error) { - result, err := wc.contract.ValidateDepositSweepProposal( - wc.callerOptions, - arg_proposal, - arg_depositsExtraInfo, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "validateDepositSweepProposal", - arg_proposal, - arg_depositsExtraInfo, - ) - } - - return result, err -} - -func (wc *WalletCoordinator) ValidateDepositSweepProposalAtBlock( - arg_proposal abi.WalletCoordinatorDepositSweepProposal, - arg_depositsExtraInfo []abi.WalletCoordinatorDepositExtraInfo, - blockNumber *big.Int, -) (bool, error) { - var result bool - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "validateDepositSweepProposal", - &result, - arg_proposal, - arg_depositsExtraInfo, - ) - - return result, err -} - -func (wc *WalletCoordinator) ValidateRedemptionProposal( - arg_proposal abi.WalletCoordinatorRedemptionProposal, -) (bool, error) { - result, err := wc.contract.ValidateRedemptionProposal( - wc.callerOptions, - arg_proposal, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "validateRedemptionProposal", - arg_proposal, - ) - } - - return result, err -} - -func (wc *WalletCoordinator) ValidateRedemptionProposalAtBlock( - arg_proposal abi.WalletCoordinatorRedemptionProposal, - blockNumber *big.Int, -) (bool, error) { - var result bool - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "validateRedemptionProposal", - &result, - arg_proposal, - ) - - return result, err -} - -type walletLock struct { - ExpiresAt uint32 - Cause uint8 -} - -func (wc *WalletCoordinator) WalletLock( - arg0 [20]byte, -) (walletLock, error) { - result, err := wc.contract.WalletLock( - wc.callerOptions, - arg0, - ) - - if err != nil { - return result, wc.errorResolver.ResolveError( - err, - wc.callerOptions.From, - nil, - "walletLock", - arg0, - ) - } - - return result, err -} - -func (wc *WalletCoordinator) WalletLockAtBlock( - arg0 [20]byte, - blockNumber *big.Int, -) (walletLock, error) { - var result walletLock - - err := chainutil.CallAtBlock( - wc.callerOptions.From, - blockNumber, - nil, - wc.contractABI, - wc.caller, - wc.errorResolver, - wc.contractAddress, - "walletLock", - &result, - arg0, - ) - - return result, err -} - -// ------ Events ------- - -func (wc *WalletCoordinator) CoordinatorAddedEvent( - opts *ethereum.SubscribeOpts, - coordinatorFilter []common.Address, -) *WcCoordinatorAddedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcCoordinatorAddedSubscription{ - wc, - opts, - coordinatorFilter, - } -} - -type WcCoordinatorAddedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - coordinatorFilter []common.Address -} - -type walletCoordinatorCoordinatorAddedFunc func( - Coordinator common.Address, - blockNumber uint64, -) - -func (cas *WcCoordinatorAddedSubscription) OnEvent( - handler walletCoordinatorCoordinatorAddedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorCoordinatorAdded) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.Coordinator, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := cas.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (cas *WcCoordinatorAddedSubscription) Pipe( - sink chan *abi.WalletCoordinatorCoordinatorAdded, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(cas.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := cas.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - cas.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past CoordinatorAdded events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := cas.contract.PastCoordinatorAddedEvents( - fromBlock, - nil, - cas.coordinatorFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past CoordinatorAdded events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := cas.contract.watchCoordinatorAdded( - sink, - cas.coordinatorFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchCoordinatorAdded( - sink chan *abi.WalletCoordinatorCoordinatorAdded, - coordinatorFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchCoordinatorAdded( - &bind.WatchOpts{Context: ctx}, - sink, - coordinatorFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event CoordinatorAdded had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event CoordinatorAdded failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastCoordinatorAddedEvents( - startBlock uint64, - endBlock *uint64, - coordinatorFilter []common.Address, -) ([]*abi.WalletCoordinatorCoordinatorAdded, error) { - iterator, err := wc.contract.FilterCoordinatorAdded( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - coordinatorFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past CoordinatorAdded events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorCoordinatorAdded, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) CoordinatorRemovedEvent( - opts *ethereum.SubscribeOpts, - coordinatorFilter []common.Address, -) *WcCoordinatorRemovedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcCoordinatorRemovedSubscription{ - wc, - opts, - coordinatorFilter, - } -} - -type WcCoordinatorRemovedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - coordinatorFilter []common.Address -} - -type walletCoordinatorCoordinatorRemovedFunc func( - Coordinator common.Address, - blockNumber uint64, -) - -func (crs *WcCoordinatorRemovedSubscription) OnEvent( - handler walletCoordinatorCoordinatorRemovedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorCoordinatorRemoved) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.Coordinator, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := crs.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (crs *WcCoordinatorRemovedSubscription) Pipe( - sink chan *abi.WalletCoordinatorCoordinatorRemoved, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(crs.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := crs.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - crs.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past CoordinatorRemoved events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := crs.contract.PastCoordinatorRemovedEvents( - fromBlock, - nil, - crs.coordinatorFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past CoordinatorRemoved events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := crs.contract.watchCoordinatorRemoved( - sink, - crs.coordinatorFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchCoordinatorRemoved( - sink chan *abi.WalletCoordinatorCoordinatorRemoved, - coordinatorFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchCoordinatorRemoved( - &bind.WatchOpts{Context: ctx}, - sink, - coordinatorFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event CoordinatorRemoved had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event CoordinatorRemoved failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastCoordinatorRemovedEvents( - startBlock uint64, - endBlock *uint64, - coordinatorFilter []common.Address, -) ([]*abi.WalletCoordinatorCoordinatorRemoved, error) { - iterator, err := wc.contract.FilterCoordinatorRemoved( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - coordinatorFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past CoordinatorRemoved events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorCoordinatorRemoved, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) DepositSweepProposalParametersUpdatedEvent( - opts *ethereum.SubscribeOpts, -) *WcDepositSweepProposalParametersUpdatedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcDepositSweepProposalParametersUpdatedSubscription{ - wc, - opts, - } -} - -type WcDepositSweepProposalParametersUpdatedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts -} - -type walletCoordinatorDepositSweepProposalParametersUpdatedFunc func( - DepositSweepProposalValidity uint32, - DepositMinAge uint32, - DepositRefundSafetyMargin uint32, - DepositSweepMaxSize uint16, - DepositSweepProposalSubmissionGasOffset uint32, - blockNumber uint64, -) - -func (dsppus *WcDepositSweepProposalParametersUpdatedSubscription) OnEvent( - handler walletCoordinatorDepositSweepProposalParametersUpdatedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorDepositSweepProposalParametersUpdated) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.DepositSweepProposalValidity, - event.DepositMinAge, - event.DepositRefundSafetyMargin, - event.DepositSweepMaxSize, - event.DepositSweepProposalSubmissionGasOffset, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := dsppus.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (dsppus *WcDepositSweepProposalParametersUpdatedSubscription) Pipe( - sink chan *abi.WalletCoordinatorDepositSweepProposalParametersUpdated, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(dsppus.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := dsppus.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - dsppus.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past DepositSweepProposalParametersUpdated events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := dsppus.contract.PastDepositSweepProposalParametersUpdatedEvents( - fromBlock, - nil, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past DepositSweepProposalParametersUpdated events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := dsppus.contract.watchDepositSweepProposalParametersUpdated( - sink, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchDepositSweepProposalParametersUpdated( - sink chan *abi.WalletCoordinatorDepositSweepProposalParametersUpdated, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchDepositSweepProposalParametersUpdated( - &bind.WatchOpts{Context: ctx}, - sink, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event DepositSweepProposalParametersUpdated had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event DepositSweepProposalParametersUpdated failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastDepositSweepProposalParametersUpdatedEvents( - startBlock uint64, - endBlock *uint64, -) ([]*abi.WalletCoordinatorDepositSweepProposalParametersUpdated, error) { - iterator, err := wc.contract.FilterDepositSweepProposalParametersUpdated( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past DepositSweepProposalParametersUpdated events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorDepositSweepProposalParametersUpdated, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) DepositSweepProposalSubmittedEvent( - opts *ethereum.SubscribeOpts, - coordinatorFilter []common.Address, -) *WcDepositSweepProposalSubmittedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcDepositSweepProposalSubmittedSubscription{ - wc, - opts, - coordinatorFilter, - } -} - -type WcDepositSweepProposalSubmittedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - coordinatorFilter []common.Address -} - -type walletCoordinatorDepositSweepProposalSubmittedFunc func( - Proposal abi.WalletCoordinatorDepositSweepProposal, - Coordinator common.Address, - blockNumber uint64, -) - -func (dspss *WcDepositSweepProposalSubmittedSubscription) OnEvent( - handler walletCoordinatorDepositSweepProposalSubmittedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorDepositSweepProposalSubmitted) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.Proposal, - event.Coordinator, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := dspss.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (dspss *WcDepositSweepProposalSubmittedSubscription) Pipe( - sink chan *abi.WalletCoordinatorDepositSweepProposalSubmitted, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(dspss.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := dspss.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - dspss.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past DepositSweepProposalSubmitted events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := dspss.contract.PastDepositSweepProposalSubmittedEvents( - fromBlock, - nil, - dspss.coordinatorFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past DepositSweepProposalSubmitted events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := dspss.contract.watchDepositSweepProposalSubmitted( - sink, - dspss.coordinatorFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchDepositSweepProposalSubmitted( - sink chan *abi.WalletCoordinatorDepositSweepProposalSubmitted, - coordinatorFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchDepositSweepProposalSubmitted( - &bind.WatchOpts{Context: ctx}, - sink, - coordinatorFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event DepositSweepProposalSubmitted had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event DepositSweepProposalSubmitted failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastDepositSweepProposalSubmittedEvents( - startBlock uint64, - endBlock *uint64, - coordinatorFilter []common.Address, -) ([]*abi.WalletCoordinatorDepositSweepProposalSubmitted, error) { - iterator, err := wc.contract.FilterDepositSweepProposalSubmitted( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - coordinatorFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past DepositSweepProposalSubmitted events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorDepositSweepProposalSubmitted, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) HeartbeatRequestParametersUpdatedEvent( - opts *ethereum.SubscribeOpts, -) *WcHeartbeatRequestParametersUpdatedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcHeartbeatRequestParametersUpdatedSubscription{ - wc, - opts, - } -} - -type WcHeartbeatRequestParametersUpdatedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts -} - -type walletCoordinatorHeartbeatRequestParametersUpdatedFunc func( - HeartbeatRequestValidity uint32, - HeartbeatRequestGasOffset uint32, - blockNumber uint64, -) - -func (hrpus *WcHeartbeatRequestParametersUpdatedSubscription) OnEvent( - handler walletCoordinatorHeartbeatRequestParametersUpdatedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorHeartbeatRequestParametersUpdated) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.HeartbeatRequestValidity, - event.HeartbeatRequestGasOffset, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := hrpus.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (hrpus *WcHeartbeatRequestParametersUpdatedSubscription) Pipe( - sink chan *abi.WalletCoordinatorHeartbeatRequestParametersUpdated, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(hrpus.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := hrpus.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - hrpus.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past HeartbeatRequestParametersUpdated events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := hrpus.contract.PastHeartbeatRequestParametersUpdatedEvents( - fromBlock, - nil, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past HeartbeatRequestParametersUpdated events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := hrpus.contract.watchHeartbeatRequestParametersUpdated( - sink, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchHeartbeatRequestParametersUpdated( - sink chan *abi.WalletCoordinatorHeartbeatRequestParametersUpdated, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchHeartbeatRequestParametersUpdated( - &bind.WatchOpts{Context: ctx}, - sink, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event HeartbeatRequestParametersUpdated had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event HeartbeatRequestParametersUpdated failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastHeartbeatRequestParametersUpdatedEvents( - startBlock uint64, - endBlock *uint64, -) ([]*abi.WalletCoordinatorHeartbeatRequestParametersUpdated, error) { - iterator, err := wc.contract.FilterHeartbeatRequestParametersUpdated( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past HeartbeatRequestParametersUpdated events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorHeartbeatRequestParametersUpdated, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) HeartbeatRequestSubmittedEvent( - opts *ethereum.SubscribeOpts, - coordinatorFilter []common.Address, -) *WcHeartbeatRequestSubmittedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcHeartbeatRequestSubmittedSubscription{ - wc, - opts, - coordinatorFilter, - } -} - -type WcHeartbeatRequestSubmittedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - coordinatorFilter []common.Address -} - -type walletCoordinatorHeartbeatRequestSubmittedFunc func( - WalletPubKeyHash [20]byte, - Message []byte, - Coordinator common.Address, - blockNumber uint64, -) - -func (hrss *WcHeartbeatRequestSubmittedSubscription) OnEvent( - handler walletCoordinatorHeartbeatRequestSubmittedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorHeartbeatRequestSubmitted) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.WalletPubKeyHash, - event.Message, - event.Coordinator, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := hrss.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (hrss *WcHeartbeatRequestSubmittedSubscription) Pipe( - sink chan *abi.WalletCoordinatorHeartbeatRequestSubmitted, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(hrss.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := hrss.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - hrss.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past HeartbeatRequestSubmitted events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := hrss.contract.PastHeartbeatRequestSubmittedEvents( - fromBlock, - nil, - hrss.coordinatorFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past HeartbeatRequestSubmitted events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := hrss.contract.watchHeartbeatRequestSubmitted( - sink, - hrss.coordinatorFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchHeartbeatRequestSubmitted( - sink chan *abi.WalletCoordinatorHeartbeatRequestSubmitted, - coordinatorFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchHeartbeatRequestSubmitted( - &bind.WatchOpts{Context: ctx}, - sink, - coordinatorFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event HeartbeatRequestSubmitted had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event HeartbeatRequestSubmitted failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastHeartbeatRequestSubmittedEvents( - startBlock uint64, - endBlock *uint64, - coordinatorFilter []common.Address, -) ([]*abi.WalletCoordinatorHeartbeatRequestSubmitted, error) { - iterator, err := wc.contract.FilterHeartbeatRequestSubmitted( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - coordinatorFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past HeartbeatRequestSubmitted events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorHeartbeatRequestSubmitted, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) InitializedEvent( - opts *ethereum.SubscribeOpts, -) *WcInitializedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcInitializedSubscription{ - wc, - opts, - } -} - -type WcInitializedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts -} - -type walletCoordinatorInitializedFunc func( - Version uint8, - blockNumber uint64, -) - -func (is *WcInitializedSubscription) OnEvent( - handler walletCoordinatorInitializedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorInitialized) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.Version, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := is.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (is *WcInitializedSubscription) Pipe( - sink chan *abi.WalletCoordinatorInitialized, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(is.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := is.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - is.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past Initialized events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := is.contract.PastInitializedEvents( - fromBlock, - nil, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past Initialized events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := is.contract.watchInitialized( - sink, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchInitialized( - sink chan *abi.WalletCoordinatorInitialized, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchInitialized( - &bind.WatchOpts{Context: ctx}, - sink, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event Initialized had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event Initialized failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastInitializedEvents( - startBlock uint64, - endBlock *uint64, -) ([]*abi.WalletCoordinatorInitialized, error) { - iterator, err := wc.contract.FilterInitialized( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past Initialized events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorInitialized, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) OwnershipTransferredEvent( - opts *ethereum.SubscribeOpts, - previousOwnerFilter []common.Address, - newOwnerFilter []common.Address, -) *WcOwnershipTransferredSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcOwnershipTransferredSubscription{ - wc, - opts, - previousOwnerFilter, - newOwnerFilter, - } -} - -type WcOwnershipTransferredSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - previousOwnerFilter []common.Address - newOwnerFilter []common.Address -} - -type walletCoordinatorOwnershipTransferredFunc func( - PreviousOwner common.Address, - NewOwner common.Address, - blockNumber uint64, -) - -func (ots *WcOwnershipTransferredSubscription) OnEvent( - handler walletCoordinatorOwnershipTransferredFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorOwnershipTransferred) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.PreviousOwner, - event.NewOwner, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := ots.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (ots *WcOwnershipTransferredSubscription) Pipe( - sink chan *abi.WalletCoordinatorOwnershipTransferred, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(ots.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := ots.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - ots.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past OwnershipTransferred events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := ots.contract.PastOwnershipTransferredEvents( - fromBlock, - nil, - ots.previousOwnerFilter, - ots.newOwnerFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past OwnershipTransferred events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := ots.contract.watchOwnershipTransferred( - sink, - ots.previousOwnerFilter, - ots.newOwnerFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchOwnershipTransferred( - sink chan *abi.WalletCoordinatorOwnershipTransferred, - previousOwnerFilter []common.Address, - newOwnerFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchOwnershipTransferred( - &bind.WatchOpts{Context: ctx}, - sink, - previousOwnerFilter, - newOwnerFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event OwnershipTransferred had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event OwnershipTransferred failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastOwnershipTransferredEvents( - startBlock uint64, - endBlock *uint64, - previousOwnerFilter []common.Address, - newOwnerFilter []common.Address, -) ([]*abi.WalletCoordinatorOwnershipTransferred, error) { - iterator, err := wc.contract.FilterOwnershipTransferred( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - previousOwnerFilter, - newOwnerFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past OwnershipTransferred events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorOwnershipTransferred, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) RedemptionProposalParametersUpdatedEvent( - opts *ethereum.SubscribeOpts, -) *WcRedemptionProposalParametersUpdatedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcRedemptionProposalParametersUpdatedSubscription{ - wc, - opts, - } -} - -type WcRedemptionProposalParametersUpdatedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts -} - -type walletCoordinatorRedemptionProposalParametersUpdatedFunc func( - RedemptionProposalValidity uint32, - RedemptionRequestMinAge uint32, - RedemptionRequestTimeoutSafetyMargin uint32, - RedemptionMaxSize uint16, - RedemptionProposalSubmissionGasOffset uint32, - blockNumber uint64, -) - -func (rppus *WcRedemptionProposalParametersUpdatedSubscription) OnEvent( - handler walletCoordinatorRedemptionProposalParametersUpdatedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorRedemptionProposalParametersUpdated) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.RedemptionProposalValidity, - event.RedemptionRequestMinAge, - event.RedemptionRequestTimeoutSafetyMargin, - event.RedemptionMaxSize, - event.RedemptionProposalSubmissionGasOffset, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := rppus.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (rppus *WcRedemptionProposalParametersUpdatedSubscription) Pipe( - sink chan *abi.WalletCoordinatorRedemptionProposalParametersUpdated, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(rppus.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := rppus.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - rppus.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past RedemptionProposalParametersUpdated events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := rppus.contract.PastRedemptionProposalParametersUpdatedEvents( - fromBlock, - nil, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past RedemptionProposalParametersUpdated events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := rppus.contract.watchRedemptionProposalParametersUpdated( - sink, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchRedemptionProposalParametersUpdated( - sink chan *abi.WalletCoordinatorRedemptionProposalParametersUpdated, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchRedemptionProposalParametersUpdated( - &bind.WatchOpts{Context: ctx}, - sink, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event RedemptionProposalParametersUpdated had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event RedemptionProposalParametersUpdated failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastRedemptionProposalParametersUpdatedEvents( - startBlock uint64, - endBlock *uint64, -) ([]*abi.WalletCoordinatorRedemptionProposalParametersUpdated, error) { - iterator, err := wc.contract.FilterRedemptionProposalParametersUpdated( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past RedemptionProposalParametersUpdated events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorRedemptionProposalParametersUpdated, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) RedemptionProposalSubmittedEvent( - opts *ethereum.SubscribeOpts, - coordinatorFilter []common.Address, -) *WcRedemptionProposalSubmittedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcRedemptionProposalSubmittedSubscription{ - wc, - opts, - coordinatorFilter, - } -} - -type WcRedemptionProposalSubmittedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - coordinatorFilter []common.Address -} - -type walletCoordinatorRedemptionProposalSubmittedFunc func( - Proposal abi.WalletCoordinatorRedemptionProposal, - Coordinator common.Address, - blockNumber uint64, -) - -func (rpss *WcRedemptionProposalSubmittedSubscription) OnEvent( - handler walletCoordinatorRedemptionProposalSubmittedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorRedemptionProposalSubmitted) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.Proposal, - event.Coordinator, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := rpss.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (rpss *WcRedemptionProposalSubmittedSubscription) Pipe( - sink chan *abi.WalletCoordinatorRedemptionProposalSubmitted, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(rpss.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := rpss.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - rpss.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past RedemptionProposalSubmitted events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := rpss.contract.PastRedemptionProposalSubmittedEvents( - fromBlock, - nil, - rpss.coordinatorFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past RedemptionProposalSubmitted events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := rpss.contract.watchRedemptionProposalSubmitted( - sink, - rpss.coordinatorFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchRedemptionProposalSubmitted( - sink chan *abi.WalletCoordinatorRedemptionProposalSubmitted, - coordinatorFilter []common.Address, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchRedemptionProposalSubmitted( - &bind.WatchOpts{Context: ctx}, - sink, - coordinatorFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event RedemptionProposalSubmitted had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event RedemptionProposalSubmitted failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastRedemptionProposalSubmittedEvents( - startBlock uint64, - endBlock *uint64, - coordinatorFilter []common.Address, -) ([]*abi.WalletCoordinatorRedemptionProposalSubmitted, error) { - iterator, err := wc.contract.FilterRedemptionProposalSubmitted( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - coordinatorFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past RedemptionProposalSubmitted events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorRedemptionProposalSubmitted, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) ReimbursementPoolUpdatedEvent( - opts *ethereum.SubscribeOpts, -) *WcReimbursementPoolUpdatedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcReimbursementPoolUpdatedSubscription{ - wc, - opts, - } -} - -type WcReimbursementPoolUpdatedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts -} - -type walletCoordinatorReimbursementPoolUpdatedFunc func( - NewReimbursementPool common.Address, - blockNumber uint64, -) - -func (rpus *WcReimbursementPoolUpdatedSubscription) OnEvent( - handler walletCoordinatorReimbursementPoolUpdatedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorReimbursementPoolUpdated) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.NewReimbursementPool, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := rpus.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (rpus *WcReimbursementPoolUpdatedSubscription) Pipe( - sink chan *abi.WalletCoordinatorReimbursementPoolUpdated, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(rpus.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := rpus.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - rpus.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past ReimbursementPoolUpdated events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := rpus.contract.PastReimbursementPoolUpdatedEvents( - fromBlock, - nil, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past ReimbursementPoolUpdated events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := rpus.contract.watchReimbursementPoolUpdated( - sink, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchReimbursementPoolUpdated( - sink chan *abi.WalletCoordinatorReimbursementPoolUpdated, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchReimbursementPoolUpdated( - &bind.WatchOpts{Context: ctx}, - sink, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event ReimbursementPoolUpdated had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event ReimbursementPoolUpdated failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastReimbursementPoolUpdatedEvents( - startBlock uint64, - endBlock *uint64, -) ([]*abi.WalletCoordinatorReimbursementPoolUpdated, error) { - iterator, err := wc.contract.FilterReimbursementPoolUpdated( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past ReimbursementPoolUpdated events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorReimbursementPoolUpdated, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} - -func (wc *WalletCoordinator) WalletManuallyUnlockedEvent( - opts *ethereum.SubscribeOpts, - walletPubKeyHashFilter [][20]byte, -) *WcWalletManuallyUnlockedSubscription { - if opts == nil { - opts = new(ethereum.SubscribeOpts) - } - if opts.Tick == 0 { - opts.Tick = chainutil.DefaultSubscribeOptsTick - } - if opts.PastBlocks == 0 { - opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks - } - - return &WcWalletManuallyUnlockedSubscription{ - wc, - opts, - walletPubKeyHashFilter, - } -} - -type WcWalletManuallyUnlockedSubscription struct { - contract *WalletCoordinator - opts *ethereum.SubscribeOpts - walletPubKeyHashFilter [][20]byte -} - -type walletCoordinatorWalletManuallyUnlockedFunc func( - WalletPubKeyHash [20]byte, - blockNumber uint64, -) - -func (wmus *WcWalletManuallyUnlockedSubscription) OnEvent( - handler walletCoordinatorWalletManuallyUnlockedFunc, -) subscription.EventSubscription { - eventChan := make(chan *abi.WalletCoordinatorWalletManuallyUnlocked) - ctx, cancelCtx := context.WithCancel(context.Background()) - - go func() { - for { - select { - case <-ctx.Done(): - return - case event := <-eventChan: - handler( - event.WalletPubKeyHash, - event.Raw.BlockNumber, - ) - } - } - }() - - sub := wmus.Pipe(eventChan) - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wmus *WcWalletManuallyUnlockedSubscription) Pipe( - sink chan *abi.WalletCoordinatorWalletManuallyUnlocked, -) subscription.EventSubscription { - ctx, cancelCtx := context.WithCancel(context.Background()) - go func() { - ticker := time.NewTicker(wmus.opts.Tick) - defer ticker.Stop() - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - lastBlock, err := wmus.contract.blockCounter.CurrentBlock() - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - } - fromBlock := lastBlock - wmus.opts.PastBlocks - - wcLogger.Infof( - "subscription monitoring fetching past WalletManuallyUnlocked events "+ - "starting from block [%v]", - fromBlock, - ) - events, err := wmus.contract.PastWalletManuallyUnlockedEvents( - fromBlock, - nil, - wmus.walletPubKeyHashFilter, - ) - if err != nil { - wcLogger.Errorf( - "subscription failed to pull events: [%v]", - err, - ) - continue - } - wcLogger.Infof( - "subscription monitoring fetched [%v] past WalletManuallyUnlocked events", - len(events), - ) - - for _, event := range events { - sink <- event - } - } - } - }() - - sub := wmus.contract.watchWalletManuallyUnlocked( - sink, - wmus.walletPubKeyHashFilter, - ) - - return subscription.NewEventSubscription(func() { - sub.Unsubscribe() - cancelCtx() - }) -} - -func (wc *WalletCoordinator) watchWalletManuallyUnlocked( - sink chan *abi.WalletCoordinatorWalletManuallyUnlocked, - walletPubKeyHashFilter [][20]byte, -) event.Subscription { - subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return wc.contract.WatchWalletManuallyUnlocked( - &bind.WatchOpts{Context: ctx}, - sink, - walletPubKeyHashFilter, - ) - } - - thresholdViolatedFn := func(elapsed time.Duration) { - wcLogger.Warnf( - "subscription to event WalletManuallyUnlocked had to be "+ - "retried [%s] since the last attempt; please inspect "+ - "host chain connectivity", - elapsed, - ) - } - - subscriptionFailedFn := func(err error) { - wcLogger.Errorf( - "subscription to event WalletManuallyUnlocked failed "+ - "with error: [%v]; resubscription attempt will be "+ - "performed", - err, - ) - } - - return chainutil.WithResubscription( - chainutil.SubscriptionBackoffMax, - subscribeFn, - chainutil.SubscriptionAlertThreshold, - thresholdViolatedFn, - subscriptionFailedFn, - ) -} - -func (wc *WalletCoordinator) PastWalletManuallyUnlockedEvents( - startBlock uint64, - endBlock *uint64, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.WalletCoordinatorWalletManuallyUnlocked, error) { - iterator, err := wc.contract.FilterWalletManuallyUnlocked( - &bind.FilterOpts{ - Start: startBlock, - End: endBlock, - }, - walletPubKeyHashFilter, - ) - if err != nil { - return nil, fmt.Errorf( - "error retrieving past WalletManuallyUnlocked events: [%v]", - err, - ) - } - - events := make([]*abi.WalletCoordinatorWalletManuallyUnlocked, 0) - - for iterator.Next() { - event := iterator.Event - events = append(events, event) - } - - return events, nil -} diff --git a/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go b/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go new file mode 100644 index 0000000000..7471e71c13 --- /dev/null +++ b/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go @@ -0,0 +1,497 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contract + +import ( + "fmt" + "math/big" + "strings" + "sync" + + hostchainabi "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/common" + + "github.com/ipfs/go-log" + + "github.com/keep-network/keep-common/pkg/chain/ethereum" + chainutil "github.com/keep-network/keep-common/pkg/chain/ethereum/ethutil" + "github.com/keep-network/keep-core/pkg/chain/ethereum/tbtc/gen/abi" +) + +// Create a package-level logger for this contract. The logger exists at +// package level so that the logger is registered at startup and can be +// included or excluded from logging at startup by name. +var wpvLogger = log.Logger("keep-contract-WalletProposalValidator") + +type WalletProposalValidator struct { + contract *abi.WalletProposalValidator + contractAddress common.Address + contractABI *hostchainabi.ABI + caller bind.ContractCaller + transactor bind.ContractTransactor + callerOptions *bind.CallOpts + transactorOptions *bind.TransactOpts + errorResolver *chainutil.ErrorResolver + nonceManager *ethereum.NonceManager + miningWaiter *chainutil.MiningWaiter + blockCounter *ethereum.BlockCounter + + transactionMutex *sync.Mutex +} + +func NewWalletProposalValidator( + contractAddress common.Address, + chainId *big.Int, + accountKey *keystore.Key, + backend bind.ContractBackend, + nonceManager *ethereum.NonceManager, + miningWaiter *chainutil.MiningWaiter, + blockCounter *ethereum.BlockCounter, + transactionMutex *sync.Mutex, +) (*WalletProposalValidator, error) { + callerOptions := &bind.CallOpts{ + From: accountKey.Address, + } + + transactorOptions, err := bind.NewKeyedTransactorWithChainID( + accountKey.PrivateKey, + chainId, + ) + if err != nil { + return nil, fmt.Errorf("failed to instantiate transactor: [%v]", err) + } + + contract, err := abi.NewWalletProposalValidator( + contractAddress, + backend, + ) + if err != nil { + return nil, fmt.Errorf( + "failed to instantiate contract at address: %s [%v]", + contractAddress.String(), + err, + ) + } + + contractABI, err := hostchainabi.JSON(strings.NewReader(abi.WalletProposalValidatorABI)) + if err != nil { + return nil, fmt.Errorf("failed to instantiate ABI: [%v]", err) + } + + return &WalletProposalValidator{ + contract: contract, + contractAddress: contractAddress, + contractABI: &contractABI, + caller: backend, + transactor: backend, + callerOptions: callerOptions, + transactorOptions: transactorOptions, + errorResolver: chainutil.NewErrorResolver(backend, &contractABI, &contractAddress), + nonceManager: nonceManager, + miningWaiter: miningWaiter, + blockCounter: blockCounter, + transactionMutex: transactionMutex, + }, nil +} + +// ----- Non-const Methods ------ + +// ----- Const Methods ------ + +func (wpv *WalletProposalValidator) Bridge() (common.Address, error) { + result, err := wpv.contract.Bridge( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "bridge", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) BridgeAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "bridge", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITMINAGE() (uint32, error) { + result, err := wpv.contract.DEPOSITMINAGE( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "dEPOSITMINAGE", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITMINAGEAtBlock( + blockNumber *big.Int, +) (uint32, error) { + var result uint32 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "dEPOSITMINAGE", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITREFUNDSAFETYMARGIN() (uint32, error) { + result, err := wpv.contract.DEPOSITREFUNDSAFETYMARGIN( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "dEPOSITREFUNDSAFETYMARGIN", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITREFUNDSAFETYMARGINAtBlock( + blockNumber *big.Int, +) (uint32, error) { + var result uint32 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "dEPOSITREFUNDSAFETYMARGIN", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITSWEEPMAXSIZE() (uint16, error) { + result, err := wpv.contract.DEPOSITSWEEPMAXSIZE( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "dEPOSITSWEEPMAXSIZE", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) DEPOSITSWEEPMAXSIZEAtBlock( + blockNumber *big.Int, +) (uint16, error) { + var result uint16 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "dEPOSITSWEEPMAXSIZE", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONMAXSIZE() (uint16, error) { + result, err := wpv.contract.REDEMPTIONMAXSIZE( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "rEDEMPTIONMAXSIZE", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONMAXSIZEAtBlock( + blockNumber *big.Int, +) (uint16, error) { + var result uint16 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "rEDEMPTIONMAXSIZE", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONREQUESTMINAGE() (uint32, error) { + result, err := wpv.contract.REDEMPTIONREQUESTMINAGE( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "rEDEMPTIONREQUESTMINAGE", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONREQUESTMINAGEAtBlock( + blockNumber *big.Int, +) (uint32, error) { + var result uint32 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "rEDEMPTIONREQUESTMINAGE", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN() (uint32, error) { + result, err := wpv.contract.REDEMPTIONREQUESTTIMEOUTSAFETYMARGIN( + wpv.callerOptions, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "rEDEMPTIONREQUESTTIMEOUTSAFETYMARGIN", + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) REDEMPTIONREQUESTTIMEOUTSAFETYMARGINAtBlock( + blockNumber *big.Int, +) (uint32, error) { + var result uint32 + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "rEDEMPTIONREQUESTTIMEOUTSAFETYMARGIN", + &result, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateDepositSweepProposal( + arg_proposal abi.WalletProposalValidatorDepositSweepProposal, + arg_depositsExtraInfo []abi.WalletProposalValidatorDepositExtraInfo, +) (bool, error) { + result, err := wpv.contract.ValidateDepositSweepProposal( + wpv.callerOptions, + arg_proposal, + arg_depositsExtraInfo, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "validateDepositSweepProposal", + arg_proposal, + arg_depositsExtraInfo, + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateDepositSweepProposalAtBlock( + arg_proposal abi.WalletProposalValidatorDepositSweepProposal, + arg_depositsExtraInfo []abi.WalletProposalValidatorDepositExtraInfo, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "validateDepositSweepProposal", + &result, + arg_proposal, + arg_depositsExtraInfo, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateHeartbeatProposal( + arg_proposal abi.WalletProposalValidatorHeartbeatProposal, +) (bool, error) { + result, err := wpv.contract.ValidateHeartbeatProposal( + wpv.callerOptions, + arg_proposal, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "validateHeartbeatProposal", + arg_proposal, + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateHeartbeatProposalAtBlock( + arg_proposal abi.WalletProposalValidatorHeartbeatProposal, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "validateHeartbeatProposal", + &result, + arg_proposal, + ) + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateRedemptionProposal( + arg_proposal abi.WalletProposalValidatorRedemptionProposal, +) (bool, error) { + result, err := wpv.contract.ValidateRedemptionProposal( + wpv.callerOptions, + arg_proposal, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "validateRedemptionProposal", + arg_proposal, + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateRedemptionProposalAtBlock( + arg_proposal abi.WalletProposalValidatorRedemptionProposal, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "validateRedemptionProposal", + &result, + arg_proposal, + ) + + return result, err +} + +// ------ Events ------- diff --git a/pkg/chain/ethereum/tbtc/gen/gen.go b/pkg/chain/ethereum/tbtc/gen/gen.go index 73d85a2a8f..65300e2a22 100644 --- a/pkg/chain/ethereum/tbtc/gen/gen.go +++ b/pkg/chain/ethereum/tbtc/gen/gen.go @@ -39,9 +39,11 @@ var ( lightRelayMaintainerProxyAddressFileContent, ) - //go:embed _address/WalletCoordinator - walletCoordinatorAddressFileContent string + //go:embed _address/WalletProposalValidator + walletProposalValidatorAddressFileContent string - // WalletCoordinatorAddress is a WalletCoordinator contract's address read from the NPM package. - WalletCoordinatorAddress string = strings.TrimSpace(walletCoordinatorAddressFileContent) + // WalletProposalValidatorAddress is a WalletProposalValidator contract's address read from the NPM package. + WalletProposalValidatorAddress string = strings.TrimSpace(walletProposalValidatorAddressFileContent) + + WalletCoordinatorAddress string = "" ) From a0372008d966f3a9a1492490eb411bbcab1a2ea3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 6 Dec 2023 13:53:48 +0100 Subject: [PATCH 2/6] Cleanup `WalletCoordinator` usage and use `WalletProposalValidator` where needed --- cmd/flags.go | 2 +- cmd/flags_test.go | 8 +- cmd/helpers.go | 2 +- cmd/maintainercli.go | 2 +- config/config_test.go | 56 ++--- config/contracts.go | 6 +- configs/config.toml.SAMPLE | 2 +- docs/resources/client-start-help | 2 +- pkg/chain/ethereum/tbtc.go | 384 ++++------------------------- pkg/chain/ethereum/tbtc/gen/gen.go | 2 - pkg/maintainer/spv/chain.go | 12 - pkg/maintainer/spv/chain_test.go | 180 +------------- pkg/tbtc/chain.go | 97 +------- pkg/tbtc/chain_test.go | 33 +-- pkg/tbtcpg/chain.go | 5 +- pkg/tbtcpg/chain_test.go | 1 + pkg/tbtcpg/deposit_sweep.go | 2 +- pkg/tbtcpg/heartbeat.go | 5 +- test/config.json | 9 +- test/config.toml | 9 +- test/config.yaml | 8 +- 21 files changed, 136 insertions(+), 691 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index ba0fb317d9..09b205be1f 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -386,5 +386,5 @@ func initDeveloperFlags(command *cobra.Command) { initContractAddressFlag(chainEthereum.RandomBeaconContractName) initContractAddressFlag(chainEthereum.TokenStakingContractName) initContractAddressFlag(chainEthereum.WalletRegistryContractName) - initContractAddressFlag(chainEthereum.WalletCoordinatorContractName) + initContractAddressFlag(chainEthereum.WalletProposalValidatorContractName) } diff --git a/cmd/flags_test.go b/cmd/flags_test.go index fc55031f36..58ee1249ae 100644 --- a/cmd/flags_test.go +++ b/cmd/flags_test.go @@ -344,15 +344,15 @@ var cmdFlagsTests = map[string]struct { expectedValueFromFlag: common.HexToAddress("0x861b021462e7864a7413edF0113030B892978617"), defaultValue: common.HexToAddress(ethereumThreshold.TokenStakingAddress), }, - "developer.walletCoordinatorAddress": { + "developer.walletProposalValidatorAddress": { readValueFunc: func(c *config.Config) interface{} { - address, _ := c.Ethereum.ContractAddress(chainEthereum.WalletCoordinatorContractName) + address, _ := c.Ethereum.ContractAddress(chainEthereum.WalletProposalValidatorContractName) return address }, - flagName: "--developer.walletCoordinatorAddress", + flagName: "--developer.walletProposalValidatorAddress", flagValue: "0xE7d33d8AA55B73a93059a24b900366894684a497", expectedValueFromFlag: common.HexToAddress("0xE7d33d8AA55B73a93059a24b900366894684a497"), - defaultValue: common.HexToAddress(ethereumTbtc.WalletCoordinatorAddress), + defaultValue: common.HexToAddress(ethereumTbtc.WalletProposalValidatorAddress), }, } diff --git a/cmd/helpers.go b/cmd/helpers.go index 8b1d2636b5..ee3fa35416 100644 --- a/cmd/helpers.go +++ b/cmd/helpers.go @@ -99,7 +99,7 @@ func buildContractAddresses(lineLength int, prefix, suffix string, ethereumConfi chainEthereum.BridgeContractName, chainEthereum.WalletRegistryContractName, chainEthereum.TokenStakingContractName, - chainEthereum.WalletCoordinatorContractName, + chainEthereum.WalletProposalValidatorContractName, } entries := []string{} diff --git a/cmd/maintainercli.go b/cmd/maintainercli.go index 7d1d6f698b..abc43b3bd2 100644 --- a/cmd/maintainercli.go +++ b/cmd/maintainercli.go @@ -265,7 +265,7 @@ var estimateDepositsSweepFeeCommandDescription = "Estimates the satoshi " + "fee for the entire Bitcoin deposits sweep transaction, based on " + "the number of input deposits. By default, provides estimations for " + "transactions containing a various number of input deposits, from 1 up " + - "to the maximum count allowed by the WalletCoordinator contract. " + + "to the maximum count allowed by the WalletProposalValidator contract. " + "The --deposits-count flag can be used to obtain a fee estimation for " + "a Bitcoin sweep transaction containing a specific count of input " + "deposits. All estimations assume the wallet main UTXO is used as one " + diff --git a/config/config_test.go b/config/config_test.go index 8371f3d170..26d8a74fea 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -73,7 +73,7 @@ func TestReadConfigFromFile(t *testing.T) { "maintainerproxy": "0xC6D21c2871586A2B098c0ad043fF0D47a3c7e7ae", "lightrelay": "0x68e20afD773fDF1231B5cbFeA7040e73e79cAc36", "lightrelaymaintainerproxy": "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5", - "walletcoordinator": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA", + "walletproposalvalidator": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA", }, }, "Developer - RandomBeacon": { @@ -129,9 +129,9 @@ func TestReadConfigFromFile(t *testing.T) { }, expectedValue: "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5", }, - "Ethereum.Developer - WalletCoordinator": { + "Ethereum.Developer - WalletProposalValidator": { readValueFunc: func(c *Config) interface{} { - address, _ := c.Ethereum.ContractAddress(ethereum.WalletCoordinatorContractName) + address, _ := c.Ethereum.ContractAddress(ethereum.WalletProposalValidatorContractName) return address.String() }, expectedValue: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA", @@ -333,40 +333,40 @@ func TestReadConfig_ReadContracts(t *testing.T) { ethereumEcdsa.WalletRegistryAddress = "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a" ethereumThreshold.TokenStakingAddress = "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27" ethereumTbtc.BridgeAddress = "0x9490165195503fcf6a0fd20ac113223fefb66ed5" - ethereumTbtc.WalletCoordinatorAddress = "0xE7d33d8AA55B73a93059a24b900366894684a497" + ethereumTbtc.WalletProposalValidatorAddress = "0xE7d33d8AA55B73a93059a24b900366894684a497" var configReadTests = map[string]struct { configFilePath string - expectedRandomBeaconAddress string - expectedWalletRegistryAddress string - expectedTokenStakingAddress string - expectedBridgeAddress string - expectedWalletCoordinatorAddress string + expectedRandomBeaconAddress string + expectedWalletRegistryAddress string + expectedTokenStakingAddress string + expectedBridgeAddress string + expectedWalletProposalValidatorAddress string }{ "no developer contracts addresses configured": { - configFilePath: "../test/config_no_contracts.toml", - expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857", - expectedWalletRegistryAddress: "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a", - expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27", - expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5", - expectedWalletCoordinatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497", + configFilePath: "../test/config_no_contracts.toml", + expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857", + expectedWalletRegistryAddress: "0xdb3dd6d4f43d39c996d0afeb6fbabc284f9ffb1a", + expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27", + expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5", + expectedWalletProposalValidatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497", }, "developer contracts addresses configured": { - configFilePath: "../test/config.toml", - expectedRandomBeaconAddress: "0xcf64c2a367341170cb4e09cf8c0ed137d8473ceb", - expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76", - expectedTokenStakingAddress: "0xa363a197f1bbb8877f50350234e3f15fb4175457", - expectedBridgeAddress: "0x138D2a0c87BA9f6BE1DCc13D6224A6aCE9B6b6F0", - expectedWalletCoordinatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA", + configFilePath: "../test/config.toml", + expectedRandomBeaconAddress: "0xcf64c2a367341170cb4e09cf8c0ed137d8473ceb", + expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76", + expectedTokenStakingAddress: "0xa363a197f1bbb8877f50350234e3f15fb4175457", + expectedBridgeAddress: "0x138D2a0c87BA9f6BE1DCc13D6224A6aCE9B6b6F0", + expectedWalletProposalValidatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA", }, "mxied contracts addresses configured": { - configFilePath: "../test/config_mixed_contracts.toml", - expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857", - expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76", - expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27", - expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5", - expectedWalletCoordinatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497", + configFilePath: "../test/config_mixed_contracts.toml", + expectedRandomBeaconAddress: "0xd1640b381327c2d5425d6d3d605539a3db72f857", + expectedWalletRegistryAddress: "0x143ba24e66fce8bca22f7d739f9a932c519b1c76", + expectedTokenStakingAddress: "0xaa7b41039ea8f9ec2d89bbe96e19f97b6c267a27", + expectedBridgeAddress: "0x9490165195503fcf6a0fd20ac113223fefb66ed5", + expectedWalletProposalValidatorAddress: "0xE7d33d8AA55B73a93059a24b900366894684a497", }, } @@ -400,7 +400,7 @@ func TestReadConfig_ReadContracts(t *testing.T) { validate(ethereum.WalletRegistryContractName, test.expectedWalletRegistryAddress) validate(ethereum.TokenStakingContractName, test.expectedTokenStakingAddress) validate(ethereum.BridgeContractName, test.expectedBridgeAddress) - validate(ethereum.WalletCoordinatorContractName, test.expectedWalletCoordinatorAddress) + validate(ethereum.WalletProposalValidatorContractName, test.expectedWalletProposalValidatorAddress) }) } } diff --git a/config/contracts.go b/config/contracts.go index 565a1ce2f7..9bd5055020 100644 --- a/config/contracts.go +++ b/config/contracts.go @@ -43,7 +43,7 @@ func initializeContractAddressesAliases() { aliasEthereumContract(chainEthereum.MaintainerProxyContractName) aliasEthereumContract(chainEthereum.LightRelayContractName) aliasEthereumContract(chainEthereum.LightRelayMaintainerProxyContractName) - aliasEthereumContract(chainEthereum.WalletCoordinatorContractName) + aliasEthereumContract(chainEthereum.WalletProposalValidatorContractName) } // resolveContractsAddresses verifies if contracts addresses are configured, if not @@ -93,7 +93,7 @@ func (c *Config) resolveContractsAddresses() { ethereumThreshold.TokenStakingAddress, ) resolveContractAddress( - chainEthereum.WalletCoordinatorContractName, - ethereumTbtc.WalletCoordinatorAddress, + chainEthereum.WalletProposalValidatorContractName, + ethereumTbtc.WalletProposalValidatorAddress, ) } diff --git a/configs/config.toml.SAMPLE b/configs/config.toml.SAMPLE index 5d9240d5b4..9ef7e220e9 100644 --- a/configs/config.toml.SAMPLE +++ b/configs/config.toml.SAMPLE @@ -125,4 +125,4 @@ Port = 9601 # RandomBeaconAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" # WalletRegistryAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" # BridgeAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" -# WalletCoordinatorAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" +# WalletProposalValidatorAddress = "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" diff --git a/docs/resources/client-start-help b/docs/resources/client-start-help index 09bc3386aa..76fcba6f86 100644 --- a/docs/resources/client-start-help +++ b/docs/resources/client-start-help @@ -39,7 +39,7 @@ Flags: --developer.randomBeaconAddress string Address of the RandomBeacon smart contract --developer.tokenStakingAddress string Address of the TokenStaking smart contract --developer.walletRegistryAddress string Address of the WalletRegistry smart contract - --developer.walletCoordinatorAddress string Address of the WalletCoordinator smart contract + --developer.walletProposalValidatorAddress string Address of the WalletProposalValidator smart contract Global Flags: -c, --config string Path to the configuration file. Supported formats: TOML, YAML, JSON. diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index 0721957b8a..b0b3bceaf3 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -34,21 +34,21 @@ import ( const ( // TODO: The WalletRegistry address is taken from the Bridge contract. // Remove the possibility of passing it through the config. - WalletRegistryContractName = "WalletRegistry" - BridgeContractName = "Bridge" - MaintainerProxyContractName = "MaintainerProxy" - WalletCoordinatorContractName = "WalletCoordinator" + WalletRegistryContractName = "WalletRegistry" + BridgeContractName = "Bridge" + MaintainerProxyContractName = "MaintainerProxy" + WalletProposalValidatorContractName = "WalletProposalValidator" ) // TbtcChain represents a TBTC-specific chain handle. type TbtcChain struct { *baseChain - bridge *tbtccontract.Bridge - maintainerProxy *tbtccontract.MaintainerProxy - walletRegistry *ecdsacontract.WalletRegistry - sortitionPool *ecdsacontract.EcdsaSortitionPool - walletCoordinator *tbtccontract.WalletCoordinator + bridge *tbtccontract.Bridge + maintainerProxy *tbtccontract.MaintainerProxy + walletRegistry *ecdsacontract.WalletRegistry + sortitionPool *ecdsacontract.EcdsaSortitionPool + walletProposalValidator *tbtccontract.WalletProposalValidator } // NewTbtcChain construct a new instance of the TBTC-specific Ethereum @@ -165,20 +165,20 @@ func newTbtcChain( ) } - walletCoordinatorAddress, err := config.ContractAddress( - WalletCoordinatorContractName, + walletProposalValidatorAddress, err := config.ContractAddress( + WalletProposalValidatorContractName, ) if err != nil { return nil, fmt.Errorf( "failed to resolve %s contract address: [%v]", - WalletCoordinatorContractName, + WalletProposalValidatorContractName, err, ) } - walletCoordinator, err := - tbtccontract.NewWalletCoordinator( - walletCoordinatorAddress, + walletProposalValidator, err := + tbtccontract.NewWalletProposalValidator( + walletProposalValidatorAddress, baseChain.chainID, baseChain.key, baseChain.client, @@ -189,18 +189,18 @@ func newTbtcChain( ) if err != nil { return nil, fmt.Errorf( - "failed to attach to WalletCoordinator contract: [%v]", + "failed to attach to WalletProposalValidator contract: [%v]", err, ) } return &TbtcChain{ - baseChain: baseChain, - bridge: bridge, - maintainerProxy: maintainerProxy, - walletRegistry: walletRegistry, - sortitionPool: sortitionPool, - walletCoordinator: walletCoordinator, + baseChain: baseChain, + bridge: bridge, + maintainerProxy: maintainerProxy, + walletRegistry: walletRegistry, + sortitionPool: sortitionPool, + walletProposalValidator: walletProposalValidator, }, nil } @@ -1024,134 +1024,6 @@ func (tc *TbtcChain) PastDepositRevealedEvents( return convertedEvents, err } -func (tc *TbtcChain) PastDepositSweepProposalSubmittedEvents( - filter *tbtc.DepositSweepProposalSubmittedEventFilter, -) ([]*tbtc.DepositSweepProposalSubmittedEvent, error) { - var startBlock uint64 - var endBlock *uint64 - var coordinator []common.Address - var walletPublicKeyHash [20]byte - - if filter != nil { - startBlock = filter.StartBlock - endBlock = filter.EndBlock - - for _, ps := range filter.Coordinator { - coordinator = append( - coordinator, - common.HexToAddress(ps.String()), - ) - } - - walletPublicKeyHash = filter.WalletPublicKeyHash - } - - events, err := tc.walletCoordinator.PastDepositSweepProposalSubmittedEvents( - startBlock, - endBlock, - coordinator, - ) - if err != nil { - return nil, err - } - - convertedEvents := make([]*tbtc.DepositSweepProposalSubmittedEvent, 0) - for _, event := range events { - // If the wallet PKH filter is set, omit all events that target - // different wallets. - if walletPublicKeyHash != [20]byte{} { - if event.Proposal.WalletPubKeyHash != walletPublicKeyHash { - continue - } - } - - convertedEvent := &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: convertDepositSweepProposalFromAbiType(event.Proposal), - Coordinator: chain.Address(event.Coordinator.Hex()), - BlockNumber: event.Raw.BlockNumber, - } - - convertedEvents = append(convertedEvents, convertedEvent) - } - - sort.SliceStable( - convertedEvents, - func(i, j int) bool { - return convertedEvents[i].BlockNumber < convertedEvents[j].BlockNumber - }, - ) - - return convertedEvents, err -} - -func (tc *TbtcChain) PastRedemptionProposalSubmittedEvents( - filter *tbtc.RedemptionProposalSubmittedEventFilter, -) ([]*tbtc.RedemptionProposalSubmittedEvent, error) { - var startBlock uint64 - var endBlock *uint64 - var coordinator []common.Address - var walletPublicKeyHash [20]byte - - if filter != nil { - startBlock = filter.StartBlock - endBlock = filter.EndBlock - - for _, ps := range filter.Coordinator { - coordinator = append( - coordinator, - common.HexToAddress(ps.String()), - ) - } - - walletPublicKeyHash = filter.WalletPublicKeyHash - } - - events, err := tc.walletCoordinator.PastRedemptionProposalSubmittedEvents( - startBlock, - endBlock, - coordinator, - ) - if err != nil { - return nil, err - } - - convertedEvents := make([]*tbtc.RedemptionProposalSubmittedEvent, 0) - for _, event := range events { - // If the wallet PKH filter is set, omit all events that target - // different wallets. - if walletPublicKeyHash != [20]byte{} { - if event.Proposal.WalletPubKeyHash != walletPublicKeyHash { - continue - } - } - - tbtcProposal, err := convertRedemptionProposalFromAbiType(event.Proposal) - if err != nil { - return nil, fmt.Errorf( - "unexpected proposal in RedemptionProposalSubmitted event: [%v]", - err, - ) - } - - convertedEvent := &tbtc.RedemptionProposalSubmittedEvent{ - Proposal: tbtcProposal, - Coordinator: chain.Address(event.Coordinator.Hex()), - BlockNumber: event.Raw.BlockNumber, - } - - convertedEvents = append(convertedEvents, convertedEvent) - } - - sort.SliceStable( - convertedEvents, - func(i, j int) bool { - return convertedEvents[i].BlockNumber < convertedEvents[j].BlockNumber - }, - ) - - return convertedEvents, err -} - func (tc *TbtcChain) PastRedemptionRequestedEvents( filter *tbtc.RedemptionRequestedEventFilter, ) ([]*tbtc.RedemptionRequestedEvent, error) { @@ -1595,84 +1467,11 @@ func buildDepositKey( return depositKey.Big() } -func (tc *TbtcChain) OnHeartbeatRequestSubmitted( - handler func(event *tbtc.HeartbeatRequestSubmittedEvent), -) subscription.EventSubscription { - onEvent := func( - walletPubKeyHash [20]byte, - message []byte, - coordinator common.Address, - blockNumber uint64, - ) { - handler(&tbtc.HeartbeatRequestSubmittedEvent{ - WalletPublicKeyHash: walletPubKeyHash, - Message: message, - Coordinator: chain.Address(coordinator.Hex()), - BlockNumber: blockNumber, - }) - } - - return tc.walletCoordinator.HeartbeatRequestSubmittedEvent(nil, nil).OnEvent(onEvent) -} - -func (tc *TbtcChain) OnDepositSweepProposalSubmitted( - handler func(event *tbtc.DepositSweepProposalSubmittedEvent), -) subscription.EventSubscription { - onEvent := func( - proposal tbtcabi.WalletCoordinatorDepositSweepProposal, - coordinator common.Address, - blockNumber uint64, - ) { - handler(&tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: convertDepositSweepProposalFromAbiType(proposal), - Coordinator: chain.Address(coordinator.Hex()), - BlockNumber: blockNumber, - }) - } - - return tc.walletCoordinator. - DepositSweepProposalSubmittedEvent(nil, nil). - OnEvent(onEvent) -} - -func convertDepositSweepProposalFromAbiType( - proposal tbtcabi.WalletCoordinatorDepositSweepProposal, -) *tbtc.DepositSweepProposal { - depositsKeys := make( - []struct { - FundingTxHash bitcoin.Hash - FundingOutputIndex uint32 - }, - len(proposal.DepositsKeys), - ) - - for i, depositKey := range proposal.DepositsKeys { - // We can map the depositKey.FundingTxHash field directly to the - // bitcoin.Hash type. This is because depositKey.FundingTxHash is - // a [32]byte type representing a hash in the bitcoin.InternalByteOrder, - // just as bitcoin.Hash assumes. - depositsKeys[i] = struct { - FundingTxHash bitcoin.Hash - FundingOutputIndex uint32 - }{ - FundingTxHash: depositKey.FundingTxHash, - FundingOutputIndex: depositKey.FundingOutputIndex, - } - } - - return &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: proposal.WalletPubKeyHash, - DepositsKeys: depositsKeys, - SweepTxFee: proposal.SweepTxFee, - DepositsRevealBlocks: proposal.DepositsRevealBlocks, - } -} - func convertDepositSweepProposalToAbiType( proposal *tbtc.DepositSweepProposal, -) tbtcabi.WalletCoordinatorDepositSweepProposal { +) tbtcabi.WalletProposalValidatorDepositSweepProposal { depositsKeys := make( - []tbtcabi.WalletCoordinatorDepositKey, + []tbtcabi.WalletProposalValidatorDepositKey, len(proposal.DepositsKeys), ) @@ -1681,13 +1480,13 @@ func convertDepositSweepProposalToAbiType( // [32]byte type. This is because depositKey.FundingTxHash is // a bitcoin.Hash type representing a hash in the // bitcoin.InternalByteOrder, just as the on-chain contract assumes. - depositsKeys[i] = tbtcabi.WalletCoordinatorDepositKey{ + depositsKeys[i] = tbtcabi.WalletProposalValidatorDepositKey{ FundingTxHash: depositKey.FundingTxHash, FundingOutputIndex: depositKey.FundingOutputIndex, } } - return tbtcabi.WalletCoordinatorDepositSweepProposal{ + return tbtcabi.WalletProposalValidatorDepositSweepProposal{ WalletPubKeyHash: proposal.WalletPublicKeyHash, DepositsKeys: depositsKeys, SweepTxFee: proposal.SweepTxFee, @@ -1695,41 +1494,6 @@ func convertDepositSweepProposalToAbiType( } } -func (tc *TbtcChain) GetWalletLock( - walletPublicKeyHash [20]byte, -) (time.Time, tbtc.WalletActionType, error) { - lock, err := tc.walletCoordinator.WalletLock(walletPublicKeyHash) - if err != nil { - return time.Time{}, 0, fmt.Errorf("cannot get wallet lock from chain: [%v]", err) - } - - cause, err := parseWalletActionType(lock.Cause) - if err != nil { - return time.Time{}, 0, fmt.Errorf("cannot parse wallet lock cause: [%v]", err) - } - - return time.Unix(int64(lock.ExpiresAt), 0), cause, nil -} - -func parseWalletActionType(value uint8) (tbtc.WalletActionType, error) { - switch value { - case 0: - return tbtc.ActionNoop, nil - case 1: - return tbtc.ActionHeartbeat, nil - case 2: - return tbtc.ActionDepositSweep, nil - case 3: - return tbtc.ActionRedemption, nil - case 4: - return tbtc.ActionMovingFunds, nil - case 5: - return tbtc.ActionMovedFundsSweep, nil - default: - return 0, fmt.Errorf("unexpected wallet action value: [%v]", value) - } -} - func parseWalletState(value uint8) (tbtc.WalletState, error) { switch value { case 0: @@ -1756,7 +1520,7 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( FundingTx *bitcoin.Transaction }, ) error { - dei := make([]tbtcabi.WalletCoordinatorDepositExtraInfo, len(depositsExtraInfo)) + dei := make([]tbtcabi.WalletProposalValidatorDepositExtraInfo, len(depositsExtraInfo)) for i, depositExtraInfo := range depositsExtraInfo { fundingTx := tbtcabi.BitcoinTxInfo2{ Version: depositExtraInfo.FundingTx.SerializeVersion(), @@ -1765,7 +1529,7 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( Locktime: depositExtraInfo.FundingTx.SerializeLocktime(), } - dei[i] = tbtcabi.WalletCoordinatorDepositExtraInfo{ + dei[i] = tbtcabi.WalletProposalValidatorDepositExtraInfo{ FundingTx: fundingTx, BlindingFactor: depositExtraInfo.Deposit.BlindingFactor, WalletPubKeyHash: depositExtraInfo.Deposit.WalletPublicKeyHash, @@ -1774,7 +1538,7 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( } } - valid, err := tc.walletCoordinator.ValidateDepositSweepProposal( + valid, err := tc.walletProposalValidator.ValidateDepositSweepProposal( convertDepositSweepProposalToAbiType(proposal), dei, ) @@ -1792,36 +1556,7 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( } func (tc *TbtcChain) GetDepositSweepMaxSize() (uint16, error) { - return tc.walletCoordinator.DepositSweepMaxSize() -} - -func (tc *TbtcChain) OnRedemptionProposalSubmitted( - handler func(event *tbtc.RedemptionProposalSubmittedEvent), -) subscription.EventSubscription { - onEvent := func( - proposal tbtcabi.WalletCoordinatorRedemptionProposal, - coordinator common.Address, - blockNumber uint64, - ) { - tbtcProposal, err := convertRedemptionProposalFromAbiType(proposal) - if err != nil { - logger.Errorf( - "unexpected proposal in RedemptionProposalSubmitted event: [%v]", - err, - ) - return - } - - handler(&tbtc.RedemptionProposalSubmittedEvent{ - Proposal: tbtcProposal, - Coordinator: chain.Address(coordinator.Hex()), - BlockNumber: blockNumber, - }) - } - - return tc.walletCoordinator. - RedemptionProposalSubmittedEvent(nil, nil). - OnEvent(onEvent) + return tc.walletProposalValidator.DEPOSITSWEEPMAXSIZE() } func (tc *TbtcChain) ValidateRedemptionProposal( @@ -1832,7 +1567,7 @@ func (tc *TbtcChain) ValidateRedemptionProposal( return fmt.Errorf("cannot convert proposal to abi type: [%v]", err) } - valid, err := tc.walletCoordinator.ValidateRedemptionProposal( + valid, err := tc.walletProposalValidator.ValidateRedemptionProposal( abiProposal, ) if err != nil { @@ -1848,36 +1583,9 @@ func (tc *TbtcChain) ValidateRedemptionProposal( return nil } -func convertRedemptionProposalFromAbiType( - proposal tbtcabi.WalletCoordinatorRedemptionProposal, -) (*tbtc.RedemptionProposal, error) { - redeemersOutputScripts := make( - []bitcoin.Script, - len(proposal.RedeemersOutputScripts), - ) - - for i, script := range proposal.RedeemersOutputScripts { - // The on-chain script representation is prepended with the script's - // byte-length while bitcoin.Script is not. We need to remove the - // length prefix. - unprefixedScript, err := bitcoin.NewScriptFromVarLenData(script) - if err != nil { - return nil, fmt.Errorf("cannot convert redeemer output script: [%v]", err) - } - - redeemersOutputScripts[i] = unprefixedScript - } - - return &tbtc.RedemptionProposal{ - WalletPublicKeyHash: proposal.WalletPubKeyHash, - RedeemersOutputScripts: redeemersOutputScripts, - RedemptionTxFee: proposal.RedemptionTxFee, - }, nil -} - func convertRedemptionProposalToAbiType( proposal *tbtc.RedemptionProposal, -) (tbtcabi.WalletCoordinatorRedemptionProposal, error) { +) (tbtcabi.WalletProposalValidatorRedemptionProposal, error) { redeemersOutputScripts := make( [][]byte, len(proposal.RedeemersOutputScripts), @@ -1889,7 +1597,7 @@ func convertRedemptionProposalToAbiType( // length prefix. prefixedScript, err := script.ToVarLenData() if err != nil { - return tbtcabi.WalletCoordinatorRedemptionProposal{}, fmt.Errorf( + return tbtcabi.WalletProposalValidatorRedemptionProposal{}, fmt.Errorf( "cannot convert redeemer output script: [%v]", err, ) @@ -1898,7 +1606,7 @@ func convertRedemptionProposalToAbiType( redeemersOutputScripts[i] = prefixedScript } - return tbtcabi.WalletCoordinatorRedemptionProposal{ + return tbtcabi.WalletProposalValidatorRedemptionProposal{ WalletPubKeyHash: proposal.WalletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: proposal.RedemptionTxFee, @@ -1906,16 +1614,32 @@ func convertRedemptionProposalToAbiType( } func (tc *TbtcChain) GetRedemptionMaxSize() (uint16, error) { - return tc.walletCoordinator.RedemptionMaxSize() + return tc.walletProposalValidator.REDEMPTIONMAXSIZE() } func (tc *TbtcChain) GetRedemptionRequestMinAge() (uint32, error) { - return tc.walletCoordinator.RedemptionRequestMinAge() + return tc.walletProposalValidator.REDEMPTIONREQUESTMINAGE() } func (tc *TbtcChain) ValidateHeartbeatProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.HeartbeatProposal, ) error { - // TODO: Implementation. - panic("not implemented yet") + valid, err := tc.walletProposalValidator.ValidateHeartbeatProposal( + tbtcabi.WalletProposalValidatorHeartbeatProposal{ + WalletPubKeyHash: walletPublicKeyHash, + Message: proposal.Message[:], + }, + ) + if err != nil { + return fmt.Errorf("validation failed: [%v]", err) + } + + // Should never happen because `validateHeartbeatProposal` returns true + // or reverts (returns an error) but do the check just in case. + if !valid { + return fmt.Errorf("unexpected validation result") + } + + return nil } diff --git a/pkg/chain/ethereum/tbtc/gen/gen.go b/pkg/chain/ethereum/tbtc/gen/gen.go index 65300e2a22..ad804d3b02 100644 --- a/pkg/chain/ethereum/tbtc/gen/gen.go +++ b/pkg/chain/ethereum/tbtc/gen/gen.go @@ -44,6 +44,4 @@ var ( // WalletProposalValidatorAddress is a WalletProposalValidator contract's address read from the NPM package. WalletProposalValidatorAddress string = strings.TrimSpace(walletProposalValidatorAddressFileContent) - - WalletCoordinatorAddress string = "" ) diff --git a/pkg/maintainer/spv/chain.go b/pkg/maintainer/spv/chain.go index 94bf11e70f..0af4c7e4d1 100644 --- a/pkg/maintainer/spv/chain.go +++ b/pkg/maintainer/spv/chain.go @@ -49,18 +49,6 @@ type Chain interface { // BlockCounter returns the chain's block counter. BlockCounter() (chain.BlockCounter, error) - // PastDepositSweepProposalSubmittedEvents returns past - // `DepositSweepProposalSubmitted` events. - PastDepositSweepProposalSubmittedEvents( - filter *tbtc.DepositSweepProposalSubmittedEventFilter, - ) ([]*tbtc.DepositSweepProposalSubmittedEvent, error) - - // PastRedemptionProposalSubmittedEvents returns past - // `RedemptionProposalSubmitted` events. - PastRedemptionProposalSubmittedEvents( - filter *tbtc.RedemptionProposalSubmittedEventFilter, - ) ([]*tbtc.RedemptionProposalSubmittedEvent, error) - // GetPendingRedemptionRequest gets the on-chain pending redemption request // for the given wallet public key hash and redeemer output script. // The returned bool value indicates whether the request was found or not. diff --git a/pkg/maintainer/spv/chain_test.go b/pkg/maintainer/spv/chain_test.go index c9302935e4..d16e4a20d7 100644 --- a/pkg/maintainer/spv/chain_test.go +++ b/pkg/maintainer/spv/chain_test.go @@ -5,7 +5,6 @@ import ( "context" "crypto/sha256" "encoding/binary" - "encoding/hex" "fmt" "math/big" "sync" @@ -33,14 +32,12 @@ type submittedDepositSweepProof struct { type localChain struct { mutex sync.Mutex - blockCounter chain.BlockCounter - pastDepositSweepProposalSubmittedEvents map[[32]byte][]*tbtc.DepositSweepProposalSubmittedEvent - pastRedemptionProposalSubmittedEvents map[[32]byte][]*tbtc.RedemptionProposalSubmittedEvent - wallets map[[20]byte]*tbtc.WalletChainData - depositRequests map[[32]byte]*tbtc.DepositChainRequest - pendingRedemptionRequests map[[32]byte]*tbtc.RedemptionRequest - submittedRedemptionProofs []*submittedRedemptionProof - submittedDepositSweepProofs []*submittedDepositSweepProof + blockCounter chain.BlockCounter + wallets map[[20]byte]*tbtc.WalletChainData + depositRequests map[[32]byte]*tbtc.DepositChainRequest + pendingRedemptionRequests map[[32]byte]*tbtc.RedemptionRequest + submittedRedemptionProofs []*submittedRedemptionProof + submittedDepositSweepProofs []*submittedDepositSweepProof txProofDifficultyFactor *big.Int currentEpoch uint64 @@ -50,13 +47,11 @@ type localChain struct { func newLocalChain() *localChain { return &localChain{ - pastDepositSweepProposalSubmittedEvents: make(map[[32]byte][]*tbtc.DepositSweepProposalSubmittedEvent), - pastRedemptionProposalSubmittedEvents: make(map[[32]byte][]*tbtc.RedemptionProposalSubmittedEvent), - wallets: make(map[[20]byte]*tbtc.WalletChainData), - depositRequests: make(map[[32]byte]*tbtc.DepositChainRequest), - pendingRedemptionRequests: make(map[[32]byte]*tbtc.RedemptionRequest), - submittedRedemptionProofs: make([]*submittedRedemptionProof, 0), - submittedDepositSweepProofs: make([]*submittedDepositSweepProof, 0), + wallets: make(map[[20]byte]*tbtc.WalletChainData), + depositRequests: make(map[[32]byte]*tbtc.DepositChainRequest), + pendingRedemptionRequests: make(map[[32]byte]*tbtc.RedemptionRequest), + submittedRedemptionProofs: make([]*submittedRedemptionProof, 0), + submittedDepositSweepProofs: make([]*submittedDepositSweepProof, 0), } } @@ -196,159 +191,6 @@ func (lc *localChain) setBlockCounter(blockCounter chain.BlockCounter) { lc.blockCounter = blockCounter } -func (lc *localChain) PastDepositSweepProposalSubmittedEvents( - filter *tbtc.DepositSweepProposalSubmittedEventFilter, -) ( - []*tbtc.DepositSweepProposalSubmittedEvent, - error, -) { - lc.mutex.Lock() - defer lc.mutex.Unlock() - - var eventsKey [32]byte - var err error - - if filter != nil { - eventsKey, err = buildPastProposalSubmittedEventsKey( - filter.StartBlock, - filter.EndBlock, - filter.Coordinator, - filter.WalletPublicKeyHash, - ) - if err != nil { - return nil, err - } - } - - events, ok := lc.pastDepositSweepProposalSubmittedEvents[eventsKey] - if !ok { - return nil, fmt.Errorf("no events for given filter") - } - - return events, nil -} - -func (lc *localChain) PastRedemptionProposalSubmittedEvents( - filter *tbtc.RedemptionProposalSubmittedEventFilter, -) ([]*tbtc.RedemptionProposalSubmittedEvent, error) { - lc.mutex.Lock() - defer lc.mutex.Unlock() - - var eventsKey [32]byte - var err error - - if filter != nil { - eventsKey, err = buildPastProposalSubmittedEventsKey( - filter.StartBlock, - filter.EndBlock, - filter.Coordinator, - filter.WalletPublicKeyHash, - ) - if err != nil { - return nil, err - } - } - - events, ok := lc.pastRedemptionProposalSubmittedEvents[eventsKey] - if !ok { - return nil, fmt.Errorf("no events for given filter") - } - - return events, nil -} - -func (lc *localChain) AddPastDepositSweepProposalSubmittedEvent( - filter *tbtc.DepositSweepProposalSubmittedEventFilter, - event *tbtc.DepositSweepProposalSubmittedEvent, -) error { - lc.mutex.Lock() - defer lc.mutex.Unlock() - - var eventsKey [32]byte - var err error - - if filter != nil { - eventsKey, err = buildPastProposalSubmittedEventsKey( - filter.StartBlock, - filter.EndBlock, - filter.Coordinator, - filter.WalletPublicKeyHash, - ) - if err != nil { - return err - } - } - - lc.pastDepositSweepProposalSubmittedEvents[eventsKey] = append( - lc.pastDepositSweepProposalSubmittedEvents[eventsKey], - event, - ) - - return nil -} - -func (lc *localChain) AddPastRedemptionProposalSubmittedEvent( - filter *tbtc.RedemptionProposalSubmittedEventFilter, - event *tbtc.RedemptionProposalSubmittedEvent, -) error { - lc.mutex.Lock() - defer lc.mutex.Unlock() - - var eventsKey [32]byte - var err error - - if filter != nil { - eventsKey, err = buildPastProposalSubmittedEventsKey( - filter.StartBlock, - filter.EndBlock, - filter.Coordinator, - filter.WalletPublicKeyHash, - ) - if err != nil { - return err - } - } - - lc.pastRedemptionProposalSubmittedEvents[eventsKey] = append( - lc.pastRedemptionProposalSubmittedEvents[eventsKey], - event, - ) - - return nil -} - -func buildPastProposalSubmittedEventsKey( - startBlock uint64, - endBlock *uint64, - coordinators []chain.Address, - walletPublicKeyHash [20]byte, -) ([32]byte, error) { - var buffer bytes.Buffer - - startBlockBytes := make([]byte, 8) - binary.BigEndian.PutUint64(startBlockBytes, startBlock) - buffer.Write(startBlockBytes) - - if endBlock != nil { - endBlockBytes := make([]byte, 8) - binary.BigEndian.PutUint64(endBlockBytes, *endBlock) - buffer.Write(endBlockBytes) - } - - for _, coordinator := range coordinators { - coordinatorBytes, err := hex.DecodeString(coordinator.String()) - if err != nil { - return [32]byte{}, err - } - - buffer.Write(coordinatorBytes) - } - - buffer.Write(walletPublicKeyHash[:]) - - return sha256.Sum256(buffer.Bytes()), nil -} - func (lc *localChain) GetPendingRedemptionRequest( walletPublicKeyHash [20]byte, redeemerOutputScript bitcoin.Script, diff --git a/pkg/tbtc/chain.go b/pkg/tbtc/chain.go index fe2240b0c4..f3b81a5f66 100644 --- a/pkg/tbtc/chain.go +++ b/pkg/tbtc/chain.go @@ -314,35 +314,9 @@ type WalletChainData struct { MovingFundsTargetWalletsCommitmentHash [32]byte } -// WalletCoordinatorChain defines the subset of the TBTC chain interface that -// pertains specifically to the tBTC wallet coordination. -type WalletCoordinatorChain interface { - // OnHeartbeatRequestSubmitted registers a callback that is invoked when - // an on-chain notification of the wallet heartbeat request is seen. - OnHeartbeatRequestSubmitted( - handler func(event *HeartbeatRequestSubmittedEvent), - ) subscription.EventSubscription - - // OnDepositSweepProposalSubmitted registers a callback that is invoked when - // an on-chain notification of the deposit sweep proposal submission is seen. - OnDepositSweepProposalSubmitted( - func(event *DepositSweepProposalSubmittedEvent), - ) subscription.EventSubscription - - // GetWalletLock gets the current wallet lock for the given wallet. - // Returned values represent the expiration time and the cause of the lock. - // The expiration time can be UNIX timestamp 0 which means there is no lock - // on the wallet at the given moment. - GetWalletLock( - walletPublicKeyHash [20]byte, - ) (time.Time, WalletActionType, error) - - // OnRedemptionProposalSubmitted registers a callback that is invoked when - // an on-chain notification of the redemption proposal submission is seen. - OnRedemptionProposalSubmitted( - func(event *RedemptionProposalSubmittedEvent), - ) subscription.EventSubscription - +// WalletProposalValidatorChain defines the subset of the TBTC chain interface +// that pertains specifically to the tBTC wallet proposal validator. +type WalletProposalValidatorChain interface { // ValidateDepositSweepProposal validates the given deposit sweep proposal // against the chain. It requires some additional data about the deposits // that must be fetched externally. Returns an error if the proposal is @@ -359,63 +333,14 @@ type WalletCoordinatorChain interface { // against the chain. Returns an error if the proposal is not valid or // nil otherwise. ValidateRedemptionProposal(proposal *RedemptionProposal) error -} - -// HeartbeatRequestSubmittedEvent represents a wallet heartbeat request -// submitted to the chain. -// -// TODO: Remove this type and all related code. -type HeartbeatRequestSubmittedEvent struct { - WalletPublicKeyHash [20]byte - Message []byte - Coordinator chain.Address - BlockNumber uint64 -} - -// DepositSweepProposalSubmittedEvent represents a deposit sweep proposal -// submission event. -// -// TODO: Remove this type and all related code. -type DepositSweepProposalSubmittedEvent struct { - Proposal *DepositSweepProposal - Coordinator chain.Address - BlockNumber uint64 -} - -func (dspse *DepositSweepProposalSubmittedEvent) WalletPublicKeyHash() [20]byte { - return dspse.Proposal.WalletPublicKeyHash -} - -// DepositSweepProposalSubmittedEventFilter is a component allowing to -// filter DepositSweepProposalSubmittedEvent. -type DepositSweepProposalSubmittedEventFilter struct { - StartBlock uint64 - EndBlock *uint64 - Coordinator []chain.Address - WalletPublicKeyHash [20]byte -} - -// RedemptionProposalSubmittedEvent represents a redemption proposal -// submission event. -// -// TODO: Remove this type and all related code. -type RedemptionProposalSubmittedEvent struct { - Proposal *RedemptionProposal - Coordinator chain.Address - BlockNumber uint64 -} -func (rpse *RedemptionProposalSubmittedEvent) WalletPublicKeyHash() [20]byte { - return rpse.Proposal.WalletPublicKeyHash -} - -// RedemptionProposalSubmittedEventFilter is a component allowing to -// filter RedemptionProposalSubmittedEvent. -type RedemptionProposalSubmittedEventFilter struct { - StartBlock uint64 - EndBlock *uint64 - Coordinator []chain.Address - WalletPublicKeyHash [20]byte + // ValidateHeartbeatProposal validates the given heartbeat proposal + // against the chain. Returns an error if the proposal is not valid or + // nil otherwise. + ValidateHeartbeatProposal( + walletPublicKeyHash [20]byte, + proposal *HeartbeatProposal, + ) error } // RedemptionRequestedEvent represents a redemption requested event. @@ -459,5 +384,5 @@ type Chain interface { GroupSelectionChain DistributedKeyGenerationChain BridgeChain - WalletCoordinatorChain + WalletProposalValidatorChain } diff --git a/pkg/tbtc/chain_test.go b/pkg/tbtc/chain_test.go index eaad15c787..c2dbbc8f7b 100644 --- a/pkg/tbtc/chain_test.go +++ b/pkg/tbtc/chain_test.go @@ -663,26 +663,6 @@ func (lc *localChain) operatorAddress() (chain.Address, error) { return lc.Signing().PublicKeyToAddress(operatorPublicKey) } -func (lc *localChain) OnHeartbeatRequestSubmitted( - handler func(event *HeartbeatRequestSubmittedEvent), -) subscription.EventSubscription { - panic("unsupported") -} - -func (lc *localChain) OnDepositSweepProposalSubmitted( - handler func(event *DepositSweepProposalSubmittedEvent), -) subscription.EventSubscription { - panic("unsupported") -} - -func (lc *localChain) GetWalletLock(walletPublicKeyHash [20]byte) ( - time.Time, - WalletActionType, - error, -) { - panic("unsupported") -} - func (lc *localChain) ValidateDepositSweepProposal( proposal *DepositSweepProposal, depositsExtraInfo []struct { @@ -767,12 +747,6 @@ func buildDepositSweepProposalValidationKey( return sha256.Sum256(buffer.Bytes()), nil } -func (lc *localChain) OnRedemptionProposalSubmitted( - func(event *RedemptionProposalSubmittedEvent), -) subscription.EventSubscription { - panic("unsupported") -} - func (lc *localChain) ValidateRedemptionProposal( proposal *RedemptionProposal, ) error { @@ -829,6 +803,13 @@ func buildRedemptionProposalValidationKey( return sha256.Sum256(buffer.Bytes()), nil } +func (lc *localChain) ValidateHeartbeatProposal( + walletPublicKeyHash [20]byte, + proposal *HeartbeatProposal, +) error { + panic("unsupported") +} + // Connect sets up the local chain. func Connect(blockTime ...time.Duration) *localChain { operatorPrivateKey, _, err := operator.GenerateKeyPair(local_v1.DefaultCurve) diff --git a/pkg/tbtcpg/chain.go b/pkg/tbtcpg/chain.go index 23114615d9..4e1bdc4972 100644 --- a/pkg/tbtcpg/chain.go +++ b/pkg/tbtcpg/chain.go @@ -103,5 +103,8 @@ type Chain interface { // ValidateHeartbeatProposal validates the given heartbeat proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. - ValidateHeartbeatProposal(proposal *tbtc.HeartbeatProposal) error + ValidateHeartbeatProposal( + walletPublicKeyHash [20]byte, + proposal *tbtc.HeartbeatProposal, + ) error } diff --git a/pkg/tbtcpg/chain_test.go b/pkg/tbtcpg/chain_test.go index b1e09bc9f6..2d0ddb7e12 100644 --- a/pkg/tbtcpg/chain_test.go +++ b/pkg/tbtcpg/chain_test.go @@ -571,6 +571,7 @@ func (lc *LocalChain) SetRedemptionProposalValidationResult( } func (lc *LocalChain) ValidateHeartbeatProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.HeartbeatProposal, ) error { lc.mutex.Lock() diff --git a/pkg/tbtcpg/deposit_sweep.go b/pkg/tbtcpg/deposit_sweep.go index 771e0c5934..f8bd567fc0 100644 --- a/pkg/tbtcpg/deposit_sweep.go +++ b/pkg/tbtcpg/deposit_sweep.go @@ -403,7 +403,7 @@ func (dst *DepositSweepTask) ProposeDepositsSweep( // sweep transaction for the given depositsCount. If the provided depositsCount // is 0, this function computes the total fee for Bitcoin deposits sweep // transactions containing a various number of input deposits, from 1 up to the -// maximum count allowed by the WalletCoordinator contract. Computed fees for +// maximum count allowed by the WalletProposalValidator contract. Computed fees for // specific deposits counts are returned as a map. // // While making estimations, this function assumes a sweep transaction diff --git a/pkg/tbtcpg/heartbeat.go b/pkg/tbtcpg/heartbeat.go index 7f4bf36d67..ede9d25fc0 100644 --- a/pkg/tbtcpg/heartbeat.go +++ b/pkg/tbtcpg/heartbeat.go @@ -49,7 +49,10 @@ func (ht *HeartbeatTask) Run(request *tbtc.CoordinationProposalRequest) ( Message: message, } - if err := ht.chain.ValidateHeartbeatProposal(proposal); err != nil { + if err := ht.chain.ValidateHeartbeatProposal( + walletPublicKeyHash, + proposal, + ); err != nil { return nil, false, fmt.Errorf( "failed to verify heartbeat proposal: [%v]", err, diff --git a/test/config.json b/test/config.json index 5637912686..9b10178109 100644 --- a/test/config.json +++ b/test/config.json @@ -44,13 +44,6 @@ "Enabled": true, "DisableProxy": true }, - "WalletCoordination": { - "Enabled": true, - "RedemptionInterval": "13h", - "RedemptionWalletsLimit": 10, - "RedemptionRequestAmountLimit": 500, - "DepositSweepInterval": "64h" - }, "Spv": { "Enabled": true, "HistoryDepth": 25000, @@ -67,6 +60,6 @@ "MaintainerProxyAddress": "0xC6D21c2871586A2B098c0ad043fF0D47a3c7e7ae", "LightRelayAddress": "0x68e20afD773fDF1231B5cbFeA7040e73e79cAc36", "LightRelayMaintainerProxyAddress": "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5", - "WalletCoordinatorAddress": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" + "WalletProposalValidatorAddress": "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" } } diff --git a/test/config.toml b/test/config.toml index 92a13c8295..9801f00f0a 100644 --- a/test/config.toml +++ b/test/config.toml @@ -39,13 +39,6 @@ EthereumMetricsTick = "1m27s" Enabled = true DisableProxy = true -[maintainer.WalletCoordination] -Enabled = true -RedemptionInterval = "13h" -RedemptionWalletsLimit = 10 -RedemptionRequestAmountLimit = 500 -DepositSweepInterval = "64h" - [maintainer.Spv] Enabled = true HistoryDepth = 25000 @@ -61,4 +54,4 @@ BridgeAddress = "0x138D2a0c87BA9f6BE1DCc13D6224A6aCE9B6b6F0" MaintainerProxyAddress = "0xC6D21c2871586A2B098c0ad043fF0D47a3c7e7ae" LightRelayAddress = "0x68e20afD773fDF1231B5cbFeA7040e73e79cAc36" LightRelayMaintainerProxyAddress = "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5" -WalletCoordinatorAddress = "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" +WalletProposalValidatorAddress = "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" diff --git a/test/config.yaml b/test/config.yaml index 8fcd91675a..abddcb3fde 100644 --- a/test/config.yaml +++ b/test/config.yaml @@ -34,12 +34,6 @@ Maintainer: BitcoinDifficulty: Enabled: true DisableProxy: true - WalletCoordination: - Enabled: true - RedemptionInterval: "13h" - RedemptionWalletsLimit: 10 - RedemptionRequestAmountLimit: 500 - DepositSweepInterval: "64h" Spv: Enabled: true HistoryDepth: 25000 @@ -54,4 +48,4 @@ Developer: MaintainerProxyAddress: "0xC6D21c2871586A2B098c0ad043fF0D47a3c7e7ae" LightRelayAddress: "0x68e20afD773fDF1231B5cbFeA7040e73e79cAc36" LightRelayMaintainerProxyAddress: "0x30cd93828613D5945A2916a22E0f0e9bC561EAB5" - WalletCoordinatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" + WalletProposalValidatorAddress: "0xfdc315b0e608b7cDE9166D9D69a1506779e3E0CA" From 475920319ce3a9831c73f24c9a9f4c70f3f897f3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 6 Dec 2023 14:42:20 +0100 Subject: [PATCH 3/6] Remove wallet PKH from proposal structures This is no longer needed with the new coordination mechanism. Proposals are now tied with specific wallet contexts so holding wallet PKH inside the proposal is redundant. --- pkg/chain/ethereum/tbtc.go | 15 ++++-- pkg/tbtc/chain.go | 6 ++- pkg/tbtc/chain_test.go | 32 +++++++++--- pkg/tbtc/deposit_sweep.go | 19 ++++--- pkg/tbtc/deposit_sweep_test.go | 2 +- pkg/tbtc/node.go | 69 ++++++++++++-------------- pkg/tbtc/redemption.go | 17 ++++--- pkg/tbtc/redemption_test.go | 2 +- pkg/tbtcpg/chain.go | 6 ++- pkg/tbtcpg/chain_test.go | 30 ++++++++--- pkg/tbtcpg/deposit_sweep.go | 2 +- pkg/tbtcpg/deposit_sweep_test.go | 1 + pkg/tbtcpg/internal/test/marshaling.go | 17 ++++--- pkg/tbtcpg/redemptions.go | 2 +- pkg/tbtcpg/redemptions_test.go | 3 +- 15 files changed, 142 insertions(+), 81 deletions(-) diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index b0b3bceaf3..114d2d3fc8 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -1468,6 +1468,7 @@ func buildDepositKey( } func convertDepositSweepProposalToAbiType( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, ) tbtcabi.WalletProposalValidatorDepositSweepProposal { depositsKeys := make( @@ -1487,7 +1488,7 @@ func convertDepositSweepProposalToAbiType( } return tbtcabi.WalletProposalValidatorDepositSweepProposal{ - WalletPubKeyHash: proposal.WalletPublicKeyHash, + WalletPubKeyHash: walletPublicKeyHash, DepositsKeys: depositsKeys, SweepTxFee: proposal.SweepTxFee, DepositsRevealBlocks: proposal.DepositsRevealBlocks, @@ -1514,6 +1515,7 @@ func parseWalletState(value uint8) (tbtc.WalletState, error) { } func (tc *TbtcChain) ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit @@ -1539,7 +1541,7 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( } valid, err := tc.walletProposalValidator.ValidateDepositSweepProposal( - convertDepositSweepProposalToAbiType(proposal), + convertDepositSweepProposalToAbiType(walletPublicKeyHash, proposal), dei, ) if err != nil { @@ -1560,9 +1562,13 @@ func (tc *TbtcChain) GetDepositSweepMaxSize() (uint16, error) { } func (tc *TbtcChain) ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) error { - abiProposal, err := convertRedemptionProposalToAbiType(proposal) + abiProposal, err := convertRedemptionProposalToAbiType( + walletPublicKeyHash, + proposal, + ) if err != nil { return fmt.Errorf("cannot convert proposal to abi type: [%v]", err) } @@ -1584,6 +1590,7 @@ func (tc *TbtcChain) ValidateRedemptionProposal( } func convertRedemptionProposalToAbiType( + walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) (tbtcabi.WalletProposalValidatorRedemptionProposal, error) { redeemersOutputScripts := make( @@ -1607,7 +1614,7 @@ func convertRedemptionProposalToAbiType( } return tbtcabi.WalletProposalValidatorRedemptionProposal{ - WalletPubKeyHash: proposal.WalletPublicKeyHash, + WalletPubKeyHash: walletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: proposal.RedemptionTxFee, }, nil diff --git a/pkg/tbtc/chain.go b/pkg/tbtc/chain.go index f3b81a5f66..60d180ecbb 100644 --- a/pkg/tbtc/chain.go +++ b/pkg/tbtc/chain.go @@ -322,6 +322,7 @@ type WalletProposalValidatorChain interface { // that must be fetched externally. Returns an error if the proposal is // not valid or nil otherwise. ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, depositsExtraInfo []struct { *Deposit @@ -332,7 +333,10 @@ type WalletProposalValidatorChain interface { // ValidateRedemptionProposal validates the given redemption proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. - ValidateRedemptionProposal(proposal *RedemptionProposal) error + ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, + proposal *RedemptionProposal, + ) error // ValidateHeartbeatProposal validates the given heartbeat proposal // against the chain. Returns an error if the proposal is not valid or diff --git a/pkg/tbtc/chain_test.go b/pkg/tbtc/chain_test.go index c2dbbc8f7b..dae120c826 100644 --- a/pkg/tbtc/chain_test.go +++ b/pkg/tbtc/chain_test.go @@ -664,6 +664,7 @@ func (lc *localChain) operatorAddress() (chain.Address, error) { } func (lc *localChain) ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, depositsExtraInfo []struct { *Deposit @@ -673,7 +674,11 @@ func (lc *localChain) ValidateDepositSweepProposal( lc.depositSweepProposalValidationsMutex.Lock() defer lc.depositSweepProposalValidationsMutex.Unlock() - key, err := buildDepositSweepProposalValidationKey(proposal, depositsExtraInfo) + key, err := buildDepositSweepProposalValidationKey( + walletPublicKeyHash, + proposal, + depositsExtraInfo, + ) if err != nil { return err } @@ -691,6 +696,7 @@ func (lc *localChain) ValidateDepositSweepProposal( } func (lc *localChain) setDepositSweepProposalValidationResult( + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, depositsExtraInfo []struct { *Deposit @@ -701,7 +707,11 @@ func (lc *localChain) setDepositSweepProposalValidationResult( lc.depositSweepProposalValidationsMutex.Lock() defer lc.depositSweepProposalValidationsMutex.Unlock() - key, err := buildDepositSweepProposalValidationKey(proposal, depositsExtraInfo) + key, err := buildDepositSweepProposalValidationKey( + walletPublicKeyHash, + proposal, + depositsExtraInfo, + ) if err != nil { return err } @@ -712,6 +722,7 @@ func (lc *localChain) setDepositSweepProposalValidationResult( } func buildDepositSweepProposalValidationKey( + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, depositsExtraInfo []struct { *Deposit @@ -720,7 +731,7 @@ func buildDepositSweepProposalValidationKey( ) ([32]byte, error) { var buffer bytes.Buffer - buffer.Write(proposal.WalletPublicKeyHash[:]) + buffer.Write(walletPublicKeyHash[:]) for _, deposit := range proposal.DepositsKeys { buffer.Write(deposit.FundingTxHash[:]) @@ -748,12 +759,16 @@ func buildDepositSweepProposalValidationKey( } func (lc *localChain) ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, proposal *RedemptionProposal, ) error { lc.redemptionProposalValidationsMutex.Lock() defer lc.redemptionProposalValidationsMutex.Unlock() - key, err := buildRedemptionProposalValidationKey(proposal) + key, err := buildRedemptionProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -771,13 +786,17 @@ func (lc *localChain) ValidateRedemptionProposal( } func (lc *localChain) setRedemptionProposalValidationResult( + walletPublicKeyHash [20]byte, proposal *RedemptionProposal, result bool, ) error { lc.redemptionProposalValidationsMutex.Lock() defer lc.redemptionProposalValidationsMutex.Unlock() - key, err := buildRedemptionProposalValidationKey(proposal) + key, err := buildRedemptionProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -788,11 +807,12 @@ func (lc *localChain) setRedemptionProposalValidationResult( } func buildRedemptionProposalValidationKey( + walletPublicKeyHash [20]byte, proposal *RedemptionProposal, ) ([32]byte, error) { var buffer bytes.Buffer - buffer.Write(proposal.WalletPublicKeyHash[:]) + buffer.Write(walletPublicKeyHash[:]) for _, script := range proposal.RedeemersOutputScripts { buffer.Write(script) diff --git a/pkg/tbtc/deposit_sweep.go b/pkg/tbtc/deposit_sweep.go index dd9696d525..008e9ebde2 100644 --- a/pkg/tbtc/deposit_sweep.go +++ b/pkg/tbtc/deposit_sweep.go @@ -54,9 +54,7 @@ const ( // DepositSweepProposal represents a deposit sweep proposal issued by a // wallet's coordination leader. type DepositSweepProposal struct { - // TODO: Remove WalletPublicKeyHash field. - WalletPublicKeyHash [20]byte - DepositsKeys []struct { + DepositsKeys []struct { FundingTxHash bitcoin.Hash FundingOutputIndex uint32 } @@ -130,8 +128,11 @@ func (dsa *depositSweepAction) execute() error { zap.String("step", "validateProposal"), ) + walletPublicKeyHash := bitcoin.PublicKeyHash(dsa.wallet().publicKey) + validatedDeposits, err := ValidateDepositSweepProposal( validateProposalLogger, + walletPublicKeyHash, dsa.proposal, dsa.requiredFundingTxConfirmations, dsa.chain, @@ -141,8 +142,6 @@ func (dsa *depositSweepAction) execute() error { return fmt.Errorf("validate proposal step failed: [%v]", err) } - walletPublicKeyHash := bitcoin.PublicKeyHash(dsa.wallet().publicKey) - walletMainUtxo, err := DetermineWalletMainUtxo( walletPublicKeyHash, dsa.chain, @@ -224,6 +223,7 @@ func (dsa *depositSweepAction) execute() error { // validation rules and verifies transactions on the Bitcoin chain. func ValidateDepositSweepProposal( validateProposalLogger log.StandardLogger, + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, requiredFundingTxConfirmations uint, chain interface { @@ -240,6 +240,7 @@ func ValidateDepositSweepProposal( // that must be fetched externally. Returns an error if the proposal is // not valid or nil otherwise. ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, depositsExtraInfo []struct { *Deposit @@ -322,7 +323,7 @@ func ValidateDepositSweepProposal( events, err := chain.PastDepositRevealedEvents(&DepositRevealedEventFilter{ StartBlock: revealBlock, EndBlock: &revealBlock, - WalletPublicKeyHash: [][20]byte{proposal.WalletPublicKeyHash}, + WalletPublicKeyHash: [][20]byte{walletPublicKeyHash}, }) if err != nil { return nil, fmt.Errorf( @@ -362,7 +363,11 @@ func ValidateDepositSweepProposal( validateProposalLogger.Infof("calling chain for proposal validation") - err := chain.ValidateDepositSweepProposal(proposal, depositExtraInfo) + err := chain.ValidateDepositSweepProposal( + walletPublicKeyHash, + proposal, + depositExtraInfo, + ) if err != nil { return nil, fmt.Errorf("deposit sweep proposal is invalid: [%v]", err) } diff --git a/pkg/tbtc/deposit_sweep_test.go b/pkg/tbtc/deposit_sweep_test.go index d5f7ea14ee..d831d2525e 100644 --- a/pkg/tbtc/deposit_sweep_test.go +++ b/pkg/tbtc/deposit_sweep_test.go @@ -123,7 +123,6 @@ func TestDepositSweepAction_Execute(t *testing.T) { // Build the sweep proposal based on the scenario data. proposal := &DepositSweepProposal{ - WalletPublicKeyHash: walletPublicKeyHash, DepositsKeys: depositsKeys, SweepTxFee: big.NewInt(scenario.Fee), DepositsRevealBlocks: depositsRevealBlocks, @@ -136,6 +135,7 @@ func TestDepositSweepAction_Execute(t *testing.T) { // Simulate the on-chain proposal validation passes with success. err = hostChain.setDepositSweepProposalValidationResult( + walletPublicKeyHash, proposal, depositsExtraInfo, true, diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index 9e15ac78f2..b438721ab2 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -413,7 +413,11 @@ func (n *node) handleHeartbeatProposal( startBlock uint64, expiryBlock uint64, ) { - walletPublicKeyHash := bitcoin.PublicKeyHash(wallet.publicKey) + walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) + if err != nil { + logger.Errorf("cannot marshal wallet public key: [%v]", err) + return + } signingExecutor, ok, err := n.getSigningExecutor(wallet.publicKey) if err != nil { @@ -426,25 +430,18 @@ func (n *node) handleHeartbeatProposal( // contract of getSigningExecutor may change one day. if !ok { logger.Infof( - "node does not control signers of wallet PKH [0x%x]; "+ + "node does not control signers of wallet [0x%x]; "+ "ignoring the received heartbeat request", - walletPublicKeyHash, + walletPublicKeyBytes, ) return } - walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) - if err != nil { - logger.Errorf("cannot marshal wallet public key: [%v]", err) - return - } - logger.Infof( - "node controls signers of wallet PKH [0x%x]; "+ - "plain-text uncompressed public key of that wallet is [0x%x]; "+ - "starting orchestration of the heartbeat action", - walletPublicKeyHash, + "starting orchestration of the heartbeat action for wallet [0x%x]; "+ + "20-byte public key hash of that wallet is [0x%x]", walletPublicKeyBytes, + bitcoin.PublicKeyHash(wallet.publicKey), ) walletActionLogger := logger.With( @@ -482,6 +479,12 @@ func (n *node) handleDepositSweepProposal( startBlock uint64, expiryBlock uint64, ) { + walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) + if err != nil { + logger.Errorf("cannot marshal wallet public key: [%v]", err) + return + } + signingExecutor, ok, err := n.getSigningExecutor(wallet.publicKey) if err != nil { logger.Errorf("cannot get signing executor: [%v]", err) @@ -493,25 +496,18 @@ func (n *node) handleDepositSweepProposal( // contract of getSigningExecutor may change one day. if !ok { logger.Infof( - "node does not control signers of wallet PKH [0x%x]; "+ + "node does not control signers of wallet [0x%x]; "+ "ignoring the received deposit sweep proposal", - proposal.WalletPublicKeyHash, + walletPublicKeyBytes, ) return } - walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) - if err != nil { - logger.Errorf("cannot marshal wallet public key: [%v]", err) - return - } - logger.Infof( - "node controls signers of wallet PKH [0x%x]; "+ - "plain-text uncompressed public key of that wallet is [0x%x]; "+ - "starting orchestration of the deposit sweep action", - proposal.WalletPublicKeyHash, + "starting orchestration of the deposit sweep action for wallet [0x%x]; "+ + "20-byte public key hash of that wallet is [0x%x]", walletPublicKeyBytes, + bitcoin.PublicKeyHash(wallet.publicKey), ) walletActionLogger := logger.With( @@ -551,6 +547,12 @@ func (n *node) handleRedemptionProposal( startBlock uint64, expiryBlock uint64, ) { + walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) + if err != nil { + logger.Errorf("cannot marshal wallet public key: [%v]", err) + return + } + signingExecutor, ok, err := n.getSigningExecutor(wallet.publicKey) if err != nil { logger.Errorf("cannot get signing executor: [%v]", err) @@ -562,25 +564,18 @@ func (n *node) handleRedemptionProposal( // contract of getSigningExecutor may change one day. if !ok { logger.Infof( - "node does not control signers of wallet PKH [0x%x]; "+ + "node does not control signers of wallet [0x%x]; "+ "ignoring the received redemption proposal", - proposal.WalletPublicKeyHash, + walletPublicKeyBytes, ) return } - walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) - if err != nil { - logger.Errorf("cannot marshal wallet public key: [%v]", err) - return - } - logger.Infof( - "node controls signers of wallet PKH [0x%x]; "+ - "plain-text uncompressed public key of that wallet is [0x%x]; "+ - "starting orchestration of the redemption action", - proposal.WalletPublicKeyHash, + "starting orchestration of the redemption action for wallet [0x%x]; "+ + "20-byte public key hash of that wallet is [0x%x]", walletPublicKeyBytes, + bitcoin.PublicKeyHash(wallet.publicKey), ) walletActionLogger := logger.With( diff --git a/pkg/tbtc/redemption.go b/pkg/tbtc/redemption.go index 55ba2d293d..218f2db58d 100644 --- a/pkg/tbtc/redemption.go +++ b/pkg/tbtc/redemption.go @@ -51,8 +51,6 @@ const ( // RedemptionProposal represents a redemption proposal issued by a wallet's // coordination leader. type RedemptionProposal struct { - // TODO: Remove WalletPublicKeyHash field. - WalletPublicKeyHash [20]byte RedeemersOutputScripts []bitcoin.Script RedemptionTxFee *big.Int } @@ -164,8 +162,11 @@ func (ra *redemptionAction) execute() error { zap.String("step", "validateProposal"), ) + walletPublicKeyHash := bitcoin.PublicKeyHash(ra.wallet().publicKey) + validatedRequests, err := ValidateRedemptionProposal( validateProposalLogger, + walletPublicKeyHash, ra.proposal, ra.chain, ) @@ -173,8 +174,6 @@ func (ra *redemptionAction) execute() error { return fmt.Errorf("validate proposal step failed: [%v]", err) } - walletPublicKeyHash := bitcoin.PublicKeyHash(ra.wallet().publicKey) - walletMainUtxo, err := DetermineWalletMainUtxo( walletPublicKeyHash, ra.chain, @@ -263,6 +262,7 @@ func (ra *redemptionAction) execute() error { // validation rules. func ValidateRedemptionProposal( validateProposalLogger log.StandardLogger, + walletPublicKeyHash [20]byte, proposal *RedemptionProposal, chain interface { // GetPendingRedemptionRequest gets the on-chain pending redemption request @@ -276,12 +276,15 @@ func ValidateRedemptionProposal( // ValidateRedemptionProposal validates the given redemption proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. - ValidateRedemptionProposal(proposal *RedemptionProposal) error + ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, + proposal *RedemptionProposal, + ) error }, ) ([]*RedemptionRequest, error) { validateProposalLogger.Infof("calling chain for proposal validation") - err := chain.ValidateRedemptionProposal(proposal) + err := chain.ValidateRedemptionProposal(walletPublicKeyHash, proposal) if err != nil { return nil, fmt.Errorf("redemption proposal is invalid: [%v]", err) } @@ -299,7 +302,7 @@ func ValidateRedemptionProposal( ) request, found, err := chain.GetPendingRedemptionRequest( - proposal.WalletPublicKeyHash, + walletPublicKeyHash, script, ) if err != nil { diff --git a/pkg/tbtc/redemption_test.go b/pkg/tbtc/redemption_test.go index 8d0f2b624f..ffe68e4716 100644 --- a/pkg/tbtc/redemption_test.go +++ b/pkg/tbtc/redemption_test.go @@ -69,7 +69,6 @@ func TestRedemptionAction_Execute(t *testing.T) { // Build the redemption proposal based on the scenario data. proposal := &RedemptionProposal{ - WalletPublicKeyHash: walletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: big.NewInt(totalFee), } @@ -81,6 +80,7 @@ func TestRedemptionAction_Execute(t *testing.T) { // Simulate the on-chain proposal validation passes with success. err = hostChain.setRedemptionProposalValidationResult( + walletPublicKeyHash, proposal, true, ) diff --git a/pkg/tbtcpg/chain.go b/pkg/tbtcpg/chain.go index 4e1bdc4972..976648b079 100644 --- a/pkg/tbtcpg/chain.go +++ b/pkg/tbtcpg/chain.go @@ -80,6 +80,7 @@ type Chain interface { // that must be fetched externally. Returns an error if the proposal is // not valid or nil otherwise. ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit @@ -90,7 +91,10 @@ type Chain interface { // ValidateRedemptionProposal validates the given redemption proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. - ValidateRedemptionProposal(proposal *tbtc.RedemptionProposal) error + ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, + proposal *tbtc.RedemptionProposal, + ) error // GetDepositSweepMaxSize gets the maximum number of deposits that can // be part of a deposit sweep proposal. diff --git a/pkg/tbtcpg/chain_test.go b/pkg/tbtcpg/chain_test.go index 2d0ddb7e12..c158dab9a4 100644 --- a/pkg/tbtcpg/chain_test.go +++ b/pkg/tbtcpg/chain_test.go @@ -463,6 +463,7 @@ func (lc *LocalChain) SetRedemptionParameters( } func (lc *LocalChain) ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit @@ -472,7 +473,10 @@ func (lc *LocalChain) ValidateDepositSweepProposal( lc.mutex.Lock() defer lc.mutex.Unlock() - key, err := buildDepositSweepProposalValidationKey(proposal) + key, err := buildDepositSweepProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -490,6 +494,7 @@ func (lc *LocalChain) ValidateDepositSweepProposal( } func (lc *LocalChain) SetDepositSweepProposalValidationResult( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, depositsExtraInfo []struct { *tbtc.Deposit @@ -500,7 +505,10 @@ func (lc *LocalChain) SetDepositSweepProposalValidationResult( lc.mutex.Lock() defer lc.mutex.Unlock() - key, err := buildDepositSweepProposalValidationKey(proposal) + key, err := buildDepositSweepProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -511,11 +519,12 @@ func (lc *LocalChain) SetDepositSweepProposalValidationResult( } func buildDepositSweepProposalValidationKey( + walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, ) ([32]byte, error) { var buffer bytes.Buffer - buffer.Write(proposal.WalletPublicKeyHash[:]) + buffer.Write(walletPublicKeyHash[:]) for _, deposit := range proposal.DepositsKeys { buffer.Write(deposit.FundingTxHash[:]) @@ -531,12 +540,16 @@ func buildDepositSweepProposalValidationKey( } func (lc *LocalChain) ValidateRedemptionProposal( + walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) error { lc.mutex.Lock() defer lc.mutex.Unlock() - key, err := buildRedemptionProposalValidationKey(proposal) + key, err := buildRedemptionProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -554,13 +567,17 @@ func (lc *LocalChain) ValidateRedemptionProposal( } func (lc *LocalChain) SetRedemptionProposalValidationResult( + walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, result bool, ) error { lc.mutex.Lock() defer lc.mutex.Unlock() - key, err := buildRedemptionProposalValidationKey(proposal) + key, err := buildRedemptionProposalValidationKey( + walletPublicKeyHash, + proposal, + ) if err != nil { return err } @@ -600,11 +617,12 @@ func (lc *LocalChain) SetHeartbeatProposalValidationResult( } func buildRedemptionProposalValidationKey( + walletPublicKeyHash [20]byte, proposal *tbtc.RedemptionProposal, ) ([32]byte, error) { var buffer bytes.Buffer - buffer.Write(proposal.WalletPublicKeyHash[:]) + buffer.Write(walletPublicKeyHash[:]) for _, script := range proposal.RedeemersOutputScripts { buffer.Write(script) diff --git a/pkg/tbtcpg/deposit_sweep.go b/pkg/tbtcpg/deposit_sweep.go index f8bd567fc0..f80fa05cbe 100644 --- a/pkg/tbtcpg/deposit_sweep.go +++ b/pkg/tbtcpg/deposit_sweep.go @@ -378,7 +378,6 @@ func (dst *DepositSweepTask) ProposeDepositsSweep( } proposal := &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: walletPublicKeyHash, DepositsKeys: depositsKeys, SweepTxFee: big.NewInt(fee), DepositsRevealBlocks: depositsRevealBlocks, @@ -388,6 +387,7 @@ func (dst *DepositSweepTask) ProposeDepositsSweep( if _, err := tbtc.ValidateDepositSweepProposal( taskLogger, + walletPublicKeyHash, proposal, tbtc.DepositSweepRequiredFundingTxConfirmations, dst.chain, diff --git a/pkg/tbtcpg/deposit_sweep_test.go b/pkg/tbtcpg/deposit_sweep_test.go index af7faad986..7695878adf 100644 --- a/pkg/tbtcpg/deposit_sweep_test.go +++ b/pkg/tbtcpg/deposit_sweep_test.go @@ -121,6 +121,7 @@ func TestDepositSweepTask_ProposeDepositsSweep(t *testing.T) { if scenario.ExpectedDepositSweepProposal != nil { err := tbtcChain.SetDepositSweepProposalValidationResult( + scenario.WalletPublicKeyHash, scenario.ExpectedDepositSweepProposal, nil, true, diff --git a/pkg/tbtcpg/internal/test/marshaling.go b/pkg/tbtcpg/internal/test/marshaling.go index b5bc17dff9..ed919ec615 100644 --- a/pkg/tbtcpg/internal/test/marshaling.go +++ b/pkg/tbtcpg/internal/test/marshaling.go @@ -132,15 +132,20 @@ type depositSweepProposal struct { DepositsRevealBlocks []int64 } -func (dsp *depositSweepProposal) convert() (*tbtc.DepositSweepProposal, error) { +func (dsp *depositSweepProposal) convert() ( + [20]byte, + *tbtc.DepositSweepProposal, + error, +) { if dsp == nil { - return nil, nil + return [20]byte{}, nil, nil } result := &tbtc.DepositSweepProposal{} + var walletPublicKeyHash [20]byte if len(dsp.WalletPublicKeyHash) > 0 { - copy(result.WalletPublicKeyHash[:], hexToSlice(dsp.WalletPublicKeyHash)) + copy(walletPublicKeyHash[:], hexToSlice(dsp.WalletPublicKeyHash)) } result.DepositsKeys = make([]struct { @@ -150,7 +155,7 @@ func (dsp *depositSweepProposal) convert() (*tbtc.DepositSweepProposal, error) { for i, depositKey := range dsp.DepositsKeys { fundingTxHash, err := bitcoin.NewHashFromString(depositKey.FundingTxHash, bitcoin.ReversedByteOrder) if err != nil { - return nil, fmt.Errorf( + return [20]byte{}, nil, fmt.Errorf( "failed to unmarshal funding transaction hash for deposit [%d/%d]: [%w]", i, len(dsp.DepositsKeys), @@ -168,7 +173,7 @@ func (dsp *depositSweepProposal) convert() (*tbtc.DepositSweepProposal, error) { result.SweepTxFee = big.NewInt(dsp.SweepTxFee) - return result, nil + return walletPublicKeyHash, result, nil } // UnmarshalJSON implements a custom JSON unmarshaling logic to produce a @@ -237,7 +242,7 @@ func (psts *ProposeSweepTestScenario) UnmarshalJSON(data []byte) error { psts.EstimateSatPerVByteFee = unmarshaled.EstimateSatPerVByteFee // Unmarshal deposit sweep proposal - psts.ExpectedDepositSweepProposal, err = unmarshaled.ExpectedDepositSweepProposal.convert() + _, psts.ExpectedDepositSweepProposal, err = unmarshaled.ExpectedDepositSweepProposal.convert() if err != nil { return fmt.Errorf( "failed to unmarshal expected deposit sweep proposal: [%w]", diff --git a/pkg/tbtcpg/redemptions.go b/pkg/tbtcpg/redemptions.go index b1a993dcb0..1401a13ec7 100644 --- a/pkg/tbtcpg/redemptions.go +++ b/pkg/tbtcpg/redemptions.go @@ -217,7 +217,6 @@ func (rt *RedemptionTask) ProposeRedemption( taskLogger.Infof("redemption transaction fee: [%d]", fee) proposal := &tbtc.RedemptionProposal{ - WalletPublicKeyHash: walletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: big.NewInt(fee), } @@ -226,6 +225,7 @@ func (rt *RedemptionTask) ProposeRedemption( if _, err := tbtc.ValidateRedemptionProposal( taskLogger, + walletPublicKeyHash, proposal, rt.chain, ); err != nil { diff --git a/pkg/tbtcpg/redemptions_test.go b/pkg/tbtcpg/redemptions_test.go index 38ffafd469..205f5f7c75 100644 --- a/pkg/tbtcpg/redemptions_test.go +++ b/pkg/tbtcpg/redemptions_test.go @@ -152,7 +152,6 @@ func TestRedemptionAction_ProposeRedemption(t *testing.T) { "fee provided": { fee: 10000, expectedProposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: walletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: big.NewInt(10000), }, @@ -160,7 +159,6 @@ func TestRedemptionAction_ProposeRedemption(t *testing.T) { "fee estimated": { fee: 0, // trigger fee estimation expectedProposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: walletPublicKeyHash, RedeemersOutputScripts: redeemersOutputScripts, RedemptionTxFee: big.NewInt(4300), }, @@ -184,6 +182,7 @@ func TestRedemptionAction_ProposeRedemption(t *testing.T) { } err := tbtcChain.SetRedemptionProposalValidationResult( + walletPublicKeyHash, test.expectedProposal, true, ) From d34b9e84c188d0f2191c16569ec9bd27d89567dd Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 6 Dec 2023 16:23:29 +0100 Subject: [PATCH 4/6] Add missing heartbeat proposal validation --- pkg/tbtc/chain_test.go | 28 ++++++++++++++++++- pkg/tbtc/heartbeat.go | 31 ++++++++++++++------- pkg/tbtc/heartbeat_test.go | 55 +++++++++++++++++++++++++++++++------- pkg/tbtc/node.go | 3 ++- 4 files changed, 96 insertions(+), 21 deletions(-) diff --git a/pkg/tbtc/chain_test.go b/pkg/tbtc/chain_test.go index dae120c826..2a56530018 100644 --- a/pkg/tbtc/chain_test.go +++ b/pkg/tbtc/chain_test.go @@ -65,6 +65,9 @@ type localChain struct { redemptionProposalValidationsMutex sync.Mutex redemptionProposalValidations map[[32]byte]bool + heartbeatProposalValidationsMutex sync.Mutex + heartbeatProposalValidations map[[16]byte]bool + blockCounter chain.BlockCounter operatorPrivateKey *operator.PrivateKey } @@ -827,7 +830,29 @@ func (lc *localChain) ValidateHeartbeatProposal( walletPublicKeyHash [20]byte, proposal *HeartbeatProposal, ) error { - panic("unsupported") + lc.heartbeatProposalValidationsMutex.Lock() + defer lc.heartbeatProposalValidationsMutex.Unlock() + + result, ok := lc.heartbeatProposalValidations[proposal.Message] + if !ok { + return fmt.Errorf("validation result unknown") + } + + if !result { + return fmt.Errorf("validation failed") + } + + return nil +} + +func (lc *localChain) setHeartbeatProposalValidationResult( + proposal *HeartbeatProposal, + result bool, +) { + lc.heartbeatProposalValidationsMutex.Lock() + defer lc.heartbeatProposalValidationsMutex.Unlock() + + lc.heartbeatProposalValidations[proposal.Message] = result } // Connect sets up the local chain. @@ -865,6 +890,7 @@ func ConnectWithKey( depositSweepProposalValidations: make(map[[32]byte]bool), pendingRedemptionRequests: make(map[[32]byte]*RedemptionRequest), redemptionProposalValidations: make(map[[32]byte]bool), + heartbeatProposalValidations: make(map[[16]byte]bool), blockCounter: blockCounter, operatorPrivateKey: operatorPrivateKey, } diff --git a/pkg/tbtc/heartbeat.go b/pkg/tbtc/heartbeat.go index 807292b565..5c4141966b 100644 --- a/pkg/tbtc/heartbeat.go +++ b/pkg/tbtc/heartbeat.go @@ -50,29 +50,35 @@ type heartbeatSigningExecutor interface { // heartbeatAction is a walletAction implementation handling heartbeat requests // from the wallet coordinator. type heartbeatAction struct { - logger log.StandardLogger + logger log.StandardLogger + chain Chain + executingWallet wallet signingExecutor heartbeatSigningExecutor - message []byte - startBlock uint64 - expiryBlock uint64 - waitForBlockFn waitForBlockFn + + proposal *HeartbeatProposal + startBlock uint64 + expiryBlock uint64 + + waitForBlockFn waitForBlockFn } func newHeartbeatAction( logger log.StandardLogger, + chain Chain, executingWallet wallet, signingExecutor heartbeatSigningExecutor, - message []byte, + proposal *HeartbeatProposal, startBlock uint64, expiryBlock uint64, waitForBlockFn waitForBlockFn, ) *heartbeatAction { return &heartbeatAction{ logger: logger, + chain: chain, executingWallet: executingWallet, signingExecutor: signingExecutor, - message: message, + proposal: proposal, startBlock: startBlock, expiryBlock: expiryBlock, waitForBlockFn: waitForBlockFn, @@ -83,7 +89,14 @@ func (ha *heartbeatAction) execute() error { // TODO: When implementing the moving funds action we should make sure // heartbeats are not executed by unstaking clients. - messageBytes := bitcoin.ComputeHash(ha.message) + walletPublicKeyHash := bitcoin.PublicKeyHash(ha.wallet().publicKey) + + err := ha.chain.ValidateHeartbeatProposal(walletPublicKeyHash, ha.proposal) + if err != nil { + return fmt.Errorf("heartbeat proposal is invalid: [%v]", err) + } + + messageBytes := bitcoin.ComputeHash(ha.proposal.Message[:]) messageToSign := new(big.Int).SetBytes(messageBytes[:]) // Just in case. This should never happen. @@ -106,7 +119,7 @@ func (ha *heartbeatAction) execute() error { logger.Infof( "generated signature [%s] for heartbeat message [0x%x]", signature, - ha.message, + ha.proposal.Message[:], ) return nil diff --git a/pkg/tbtc/heartbeat_test.go b/pkg/tbtc/heartbeat_test.go index a218887f31..32941e9b59 100644 --- a/pkg/tbtc/heartbeat_test.go +++ b/pkg/tbtc/heartbeat_test.go @@ -11,24 +11,42 @@ import ( ) func TestHeartbeatAction_HappyPath(t *testing.T) { - startBlock := uint64(10) - expiryBlock := startBlock + heartbeatProposalValidityBlocks - messageToSign, err := hex.DecodeString("FFFFFFFFFFFFFFFF0000000000000001") + walletPublicKeyHex, err := hex.DecodeString( + "0471e30bca60f6548d7b42582a478ea37ada63b402af7b3ddd57f0c95bb6843175" + + "aa0d2053a91a050a6797d85c38f2909cb7027f2344a01986aa2f9f8ca7a0c289", + ) if err != nil { t.Fatal(err) } + + startBlock := uint64(10) + expiryBlock := startBlock + heartbeatProposalValidityBlocks + + proposal := &HeartbeatProposal{ + Message: [16]byte{ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + } + // sha256(sha256(messageToSign)) sha256d, err := hex.DecodeString("38d30dacec5083c902952ce99fc0287659ad0b1ca2086827a8e78b0bef2c8bc1") if err != nil { t.Fatal(err) } + hostChain := Connect() + hostChain.setHeartbeatProposalValidationResult(proposal, true) + mockExecutor := &mockHeartbeatSigningExecutor{} action := newHeartbeatAction( logger, - wallet{}, + hostChain, + wallet{ + publicKey: unmarshalPublicKey(walletPublicKeyHex), + }, mockExecutor, - messageToSign, + proposal, startBlock, expiryBlock, func(ctx context.Context, blockHeight uint64) error { @@ -56,21 +74,38 @@ func TestHeartbeatAction_HappyPath(t *testing.T) { } func TestHeartbeatAction_SigningError(t *testing.T) { - startBlock := uint64(10) - expiryBlock := startBlock + heartbeatProposalValidityBlocks - messageToSign, err := hex.DecodeString("FFFFFFFFFFFFFFFF0000000000000001") + walletPublicKeyHex, err := hex.DecodeString( + "0471e30bca60f6548d7b42582a478ea37ada63b402af7b3ddd57f0c95bb6843175" + + "aa0d2053a91a050a6797d85c38f2909cb7027f2344a01986aa2f9f8ca7a0c289", + ) if err != nil { t.Fatal(err) } + startBlock := uint64(10) + expiryBlock := startBlock + heartbeatProposalValidityBlocks + + proposal := &HeartbeatProposal{ + Message: [16]byte{ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + } + + hostChain := Connect() + hostChain.setHeartbeatProposalValidationResult(proposal, true) + mockExecutor := &mockHeartbeatSigningExecutor{} mockExecutor.shouldFail = true action := newHeartbeatAction( logger, - wallet{}, + hostChain, + wallet{ + publicKey: unmarshalPublicKey(walletPublicKeyHex), + }, mockExecutor, - messageToSign, + proposal, startBlock, expiryBlock, func(ctx context.Context, blockHeight uint64) error { diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index b438721ab2..aefd85b5d7 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -454,9 +454,10 @@ func (n *node) handleHeartbeatProposal( action := newHeartbeatAction( walletActionLogger, + n.chain, wallet, signingExecutor, - proposal.Message[:], + proposal, startBlock, expiryBlock, n.waitForBlockHeight, From 19bc96b49a16f744f098af9b6b1acdcedac49063 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 6 Dec 2023 16:56:04 +0100 Subject: [PATCH 5/6] Adjust SPV maintainer to recent changes --- cmd/flags.go | 3 +- pkg/maintainer/spv/chain.go | 16 +++ pkg/maintainer/spv/chain_test.go | 175 +++++++++++++++++++++-- pkg/maintainer/spv/config.go | 24 ++-- pkg/maintainer/spv/deposit_sweep.go | 10 +- pkg/maintainer/spv/deposit_sweep_test.go | 40 +++--- pkg/maintainer/spv/redemptions.go | 10 +- pkg/maintainer/spv/redemptions_test.go | 38 ++--- pkg/maintainer/spv/spv.go | 4 +- pkg/maintainer/spv/spv_test.go | 62 ++++---- pkg/tbtc/chain.go | 8 ++ 11 files changed, 268 insertions(+), 122 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 09b205be1f..6ce094c2e6 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -337,8 +337,7 @@ func initMaintainerFlags(command *cobra.Command, cfg *config.Config) { &cfg.Maintainer.Spv.HistoryDepth, "spv.historyDepth", spv.DefaultHistoryDepth, - "Number of blocks to look back for past deposit sweep proposal "+ - "submitted events.", + "Number of blocks to look back for past wallet-related events.", ) command.Flags().IntVar( diff --git a/pkg/maintainer/spv/chain.go b/pkg/maintainer/spv/chain.go index 0af4c7e4d1..670fb91ac1 100644 --- a/pkg/maintainer/spv/chain.go +++ b/pkg/maintainer/spv/chain.go @@ -65,4 +65,20 @@ type Chain interface { mainUTXO bitcoin.UnspentTransactionOutput, walletPublicKeyHash [20]byte, ) error + + // PastDepositRevealedEvents fetches past deposit reveal events according + // to the provided filter or unfiltered if the filter is nil. Returned + // events are sorted by the block number in the ascending order, i.e. the + // latest event is at the end of the slice. + PastDepositRevealedEvents( + filter *tbtc.DepositRevealedEventFilter, + ) ([]*tbtc.DepositRevealedEvent, error) + + // PastRedemptionRequestedEvents fetches past redemption requested events according + // to the provided filter or unfiltered if the filter is nil. Returned + // events are sorted by the block number in the ascending order, i.e. the + // latest event is at the end of the slice. + PastRedemptionRequestedEvents( + filter *tbtc.RedemptionRequestedEventFilter, + ) ([]*tbtc.RedemptionRequestedEvent, error) } diff --git a/pkg/maintainer/spv/chain_test.go b/pkg/maintainer/spv/chain_test.go index d16e4a20d7..5c26da0e05 100644 --- a/pkg/maintainer/spv/chain_test.go +++ b/pkg/maintainer/spv/chain_test.go @@ -5,6 +5,7 @@ import ( "context" "crypto/sha256" "encoding/binary" + "encoding/hex" "fmt" "math/big" "sync" @@ -32,12 +33,14 @@ type submittedDepositSweepProof struct { type localChain struct { mutex sync.Mutex - blockCounter chain.BlockCounter - wallets map[[20]byte]*tbtc.WalletChainData - depositRequests map[[32]byte]*tbtc.DepositChainRequest - pendingRedemptionRequests map[[32]byte]*tbtc.RedemptionRequest - submittedRedemptionProofs []*submittedRedemptionProof - submittedDepositSweepProofs []*submittedDepositSweepProof + blockCounter chain.BlockCounter + wallets map[[20]byte]*tbtc.WalletChainData + depositRequests map[[32]byte]*tbtc.DepositChainRequest + pendingRedemptionRequests map[[32]byte]*tbtc.RedemptionRequest + submittedRedemptionProofs []*submittedRedemptionProof + submittedDepositSweepProofs []*submittedDepositSweepProof + pastRedemptionRequestedEvents map[[32]byte][]*tbtc.RedemptionRequestedEvent + pastDepositRevealedEvents map[[32]byte][]*tbtc.DepositRevealedEvent txProofDifficultyFactor *big.Int currentEpoch uint64 @@ -47,11 +50,13 @@ type localChain struct { func newLocalChain() *localChain { return &localChain{ - wallets: make(map[[20]byte]*tbtc.WalletChainData), - depositRequests: make(map[[32]byte]*tbtc.DepositChainRequest), - pendingRedemptionRequests: make(map[[32]byte]*tbtc.RedemptionRequest), - submittedRedemptionProofs: make([]*submittedRedemptionProof, 0), - submittedDepositSweepProofs: make([]*submittedDepositSweepProof, 0), + wallets: make(map[[20]byte]*tbtc.WalletChainData), + depositRequests: make(map[[32]byte]*tbtc.DepositChainRequest), + pendingRedemptionRequests: make(map[[32]byte]*tbtc.RedemptionRequest), + submittedRedemptionProofs: make([]*submittedRedemptionProof, 0), + submittedDepositSweepProofs: make([]*submittedDepositSweepProof, 0), + pastRedemptionRequestedEvents: make(map[[32]byte][]*tbtc.RedemptionRequestedEvent), + pastDepositRevealedEvents: make(map[[32]byte][]*tbtc.DepositRevealedEvent), } } @@ -338,6 +343,154 @@ func (lc *localChain) setCurrentAndPrevEpochDifficulty( lc.previousEpochDifficulty = previousEpochDifficulty } +func (lc *localChain) PastDepositRevealedEvents( + filter *tbtc.DepositRevealedEventFilter, +) ([]*tbtc.DepositRevealedEvent, error) { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return nil, err + } + + events, ok := lc.pastDepositRevealedEvents[eventsKey] + if !ok { + return nil, fmt.Errorf("no events for given filter") + } + + return events, nil +} + +func (lc *localChain) addPastDepositRevealedEvent( + filter *tbtc.DepositRevealedEventFilter, + event *tbtc.DepositRevealedEvent, +) error { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return err + } + + lc.pastDepositRevealedEvents[eventsKey] = append( + lc.pastDepositRevealedEvents[eventsKey], + event, + ) + + return nil +} + +func buildPastDepositRevealedEventsKey( + filter *tbtc.DepositRevealedEventFilter, +) ([32]byte, error) { + if filter == nil { + return [32]byte{}, nil + } + + var buffer bytes.Buffer + + startBlock := make([]byte, 8) + binary.BigEndian.PutUint64(startBlock, filter.StartBlock) + buffer.Write(startBlock) + + if filter.EndBlock != nil { + endBlock := make([]byte, 8) + binary.BigEndian.PutUint64(startBlock, *filter.EndBlock) + buffer.Write(endBlock) + } + + for _, depositor := range filter.Depositor { + depositorBytes, err := hex.DecodeString(depositor.String()) + if err != nil { + return [32]byte{}, err + } + + buffer.Write(depositorBytes) + } + + for _, walletPublicKeyHash := range filter.WalletPublicKeyHash { + buffer.Write(walletPublicKeyHash[:]) + } + + return sha256.Sum256(buffer.Bytes()), nil +} + +func (lc *localChain) PastRedemptionRequestedEvents( + filter *tbtc.RedemptionRequestedEventFilter, +) ([]*tbtc.RedemptionRequestedEvent, error) { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastRedemptionRequestedEventsKey(filter) + if err != nil { + return nil, err + } + + events, ok := lc.pastRedemptionRequestedEvents[eventsKey] + if !ok { + return nil, fmt.Errorf("no events for given filter") + } + + return events, nil +} + +func (lc *localChain) addPastRedemptionRequestedEvent( + filter *tbtc.RedemptionRequestedEventFilter, + event *tbtc.RedemptionRequestedEvent, +) error { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastRedemptionRequestedEventsKey(filter) + if err != nil { + return err + } + + lc.pastRedemptionRequestedEvents[eventsKey] = append( + lc.pastRedemptionRequestedEvents[eventsKey], + event, + ) + + return nil +} + +func buildPastRedemptionRequestedEventsKey( + filter *tbtc.RedemptionRequestedEventFilter, +) ([32]byte, error) { + if filter == nil { + return [32]byte{}, nil + } + + var buffer bytes.Buffer + + startBlock := make([]byte, 8) + binary.BigEndian.PutUint64(startBlock, filter.StartBlock) + buffer.Write(startBlock) + + if filter.EndBlock != nil { + endBlock := make([]byte, 8) + binary.BigEndian.PutUint64(startBlock, *filter.EndBlock) + buffer.Write(endBlock) + } + + for _, walletPublicKeyHash := range filter.WalletPublicKeyHash { + buffer.Write(walletPublicKeyHash[:]) + } + + for _, redeemer := range filter.Redeemer { + redeemerHex, err := hex.DecodeString(redeemer.String()) + if err != nil { + return [32]byte{}, err + } + + buffer.Write(redeemerHex) + } + + return sha256.Sum256(buffer.Bytes()), nil +} + type mockBlockCounter struct { mutex sync.Mutex currentBlock uint64 diff --git a/pkg/maintainer/spv/config.go b/pkg/maintainer/spv/config.go index 87a7fc6e49..49cdfe40d9 100644 --- a/pkg/maintainer/spv/config.go +++ b/pkg/maintainer/spv/config.go @@ -7,7 +7,7 @@ import ( const ( // DefaultHistoryDepth is the default value for history depth which is the // number of blocks to look back from the current block when searching for - // past proposal submission events. The value is the approximate number of + // past wallet-related events. The value is the approximate number of // Ethereum blocks in a week, assuming one block is 12s. DefaultHistoryDepth = 50400 @@ -35,22 +35,20 @@ type Config struct { Enabled bool // HistoryDepth is the number of blocks to look back from the current block - // when searching for past proposal submission events. - // To find Bitcoin transactions for which the SPV proof should be submitted, - // the maintainer first inspects the proposal events from the wallet - // coordinator contract. This depth determines how far into the past the - // system will consider events for processing. This value must not be too - // high so that the event lookup is efficient. At the same time, this value - // can not be too low to make sure all performed and not yet proven - // transactions can be found. + // when searching for past wallet-related events. To find Bitcoin transactions + // for which the SPV proof should be submitted, the maintainer first inspects + // the appropriate type of wallet-related events. This depth determines how + // far into the past the system will consider events for processing. This + // value must not be too high so that the event lookup is efficient. At the + // same time, this value can not be too low to make sure all performed and + // not yet proven transactions can be found. HistoryDepth uint64 // TransactionLimit sets the maximum number of confirmed transactions // returned when getting transactions for a public key hash. Once the - // maintainer establishes the list of proposals of given type, based on the - // proposal submission events from the wallet coordinator contract, it needs - // to check Bitcoin transactions executed by the wallet. Then, it tries to - // find the transactions matching the given proposal type. For example, if set + // maintainer establishes the list of wallets, it needs to check Bitcoin + // transactions executed by each wallet. Then, it tries to find the + // transactions matching the given proposal type. For example, if set // to `20`, only the latest twenty transactions will be returned. This // value must not be too high so that the transaction lookup is efficient. // At the same time, this value can not be too low to make sure the diff --git a/pkg/maintainer/spv/deposit_sweep.go b/pkg/maintainer/spv/deposit_sweep.go index 964e60b0ad..ef85221b90 100644 --- a/pkg/maintainer/spv/deposit_sweep.go +++ b/pkg/maintainer/spv/deposit_sweep.go @@ -245,15 +245,15 @@ func getUnprovenDepositSweepTransactions( // searched for. startBlock := currentBlock - historyDepth - depositSweepProposals, err := - spvChain.PastDepositSweepProposalSubmittedEvents( - &tbtc.DepositSweepProposalSubmittedEventFilter{ + events, err := + spvChain.PastDepositRevealedEvents( + &tbtc.DepositRevealedEventFilter{ StartBlock: startBlock, }, ) if err != nil { return nil, fmt.Errorf( - "failed to get past deposit sweep proposal submitted events: [%v]", + "failed to get past deposit revealed events: [%v]", err, ) } @@ -261,7 +261,7 @@ func getUnprovenDepositSweepTransactions( // There will often be multiple events emitted for a single wallet. Prepare // a list of unique wallet public key hashes. walletPublicKeyHashes := uniqueWalletPublicKeyHashes( - depositSweepProposals, + events, ) unprovenDepositSweepTransactions := []*bitcoin.Transaction{} diff --git a/pkg/maintainer/spv/deposit_sweep_test.go b/pkg/maintainer/spv/deposit_sweep_test.go index 252da9c41e..fa9ff0f655 100644 --- a/pkg/maintainer/spv/deposit_sweep_test.go +++ b/pkg/maintainer/spv/deposit_sweep_test.go @@ -313,43 +313,35 @@ func TestGetUnprovenDepositSweepTransactions(t *testing.T) { }, ) - // Add proposal events for the wallets. Only wallet public key hash field + // Add deposit events for the wallets. Only wallet public key hash field // is relevant as those events are just used to get a list of distinct - // wallets who performed deposit sweeps recently. The block number field - // is just to make them distinguishable while reading. - proposalEvents := []*tbtc.DepositSweepProposalSubmittedEvent{ + // wallets who likely performed deposit sweeps recently. The block number + // field is just to make them distinguishable while reading. + events := []*tbtc.DepositRevealedEvent{ { - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: wallets[0].walletPublicKeyHash, - }, - BlockNumber: 100, + WalletPublicKeyHash: wallets[0].walletPublicKeyHash, + BlockNumber: 100, }, { - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: wallets[0].walletPublicKeyHash, - }, - BlockNumber: 200, + WalletPublicKeyHash: wallets[0].walletPublicKeyHash, + BlockNumber: 200, }, { - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: wallets[1].walletPublicKeyHash, - }, - BlockNumber: 300, + WalletPublicKeyHash: wallets[1].walletPublicKeyHash, + BlockNumber: 300, }, { - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: wallets[1].walletPublicKeyHash, - }, - BlockNumber: 400, + WalletPublicKeyHash: wallets[1].walletPublicKeyHash, + BlockNumber: 400, }, } - for _, proposalEvent := range proposalEvents { - err := spvChain.AddPastDepositSweepProposalSubmittedEvent( - &tbtc.DepositSweepProposalSubmittedEventFilter{ + for _, event := range events { + err := spvChain.addPastDepositRevealedEvent( + &tbtc.DepositRevealedEventFilter{ StartBlock: currentBlock - historyDepth, }, - proposalEvent, + event, ) if err != nil { t.Fatal(err) diff --git a/pkg/maintainer/spv/redemptions.go b/pkg/maintainer/spv/redemptions.go index af74e39745..df8541f07b 100644 --- a/pkg/maintainer/spv/redemptions.go +++ b/pkg/maintainer/spv/redemptions.go @@ -146,15 +146,15 @@ func getUnprovenRedemptionTransactions( // searched for. startBlock := currentBlock - historyDepth - redemptionProposals, err := - spvChain.PastRedemptionProposalSubmittedEvents( - &tbtc.RedemptionProposalSubmittedEventFilter{ + events, err := + spvChain.PastRedemptionRequestedEvents( + &tbtc.RedemptionRequestedEventFilter{ StartBlock: startBlock, }, ) if err != nil { return nil, fmt.Errorf( - "failed to get past redemption proposal submitted events: [%v]", + "failed to get past redemption requested events: [%v]", err, ) } @@ -162,7 +162,7 @@ func getUnprovenRedemptionTransactions( // There will often be multiple events emitted for a single wallet. Prepare // a list of unique wallet public key hashes. walletPublicKeyHashes := uniqueWalletPublicKeyHashes( - redemptionProposals, + events, ) var unprovenRedemptionTransactions []*bitcoin.Transaction diff --git a/pkg/maintainer/spv/redemptions_test.go b/pkg/maintainer/spv/redemptions_test.go index 7d647e089f..70a1594c00 100644 --- a/pkg/maintainer/spv/redemptions_test.go +++ b/pkg/maintainer/spv/redemptions_test.go @@ -252,43 +252,35 @@ func TestGetUnprovenRedemptionTransactions(t *testing.T) { ) } - // Add proposal events for the wallets. Only wallet public key hash field + // Add redemption events for the wallets. Only wallet public key hash field // is relevant as those events are just used to get a list of distinct - // wallets who performed redemptions recently. The block number field + // wallets who likely performed redemptions recently. The block number field // is just to make them distinguishable while reading. - proposalEvents := []*tbtc.RedemptionProposalSubmittedEvent{ + events := []*tbtc.RedemptionRequestedEvent{ { - Proposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: wallets[0].walletPublicKeyHash, - }, - BlockNumber: 100, + WalletPublicKeyHash: wallets[0].walletPublicKeyHash, + BlockNumber: 100, }, { - Proposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: wallets[0].walletPublicKeyHash, - }, - BlockNumber: 200, + WalletPublicKeyHash: wallets[0].walletPublicKeyHash, + BlockNumber: 200, }, { - Proposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: wallets[1].walletPublicKeyHash, - }, - BlockNumber: 300, + WalletPublicKeyHash: wallets[1].walletPublicKeyHash, + BlockNumber: 300, }, { - Proposal: &tbtc.RedemptionProposal{ - WalletPublicKeyHash: wallets[1].walletPublicKeyHash, - }, - BlockNumber: 400, + WalletPublicKeyHash: wallets[1].walletPublicKeyHash, + BlockNumber: 400, }, } - for _, proposalEvent := range proposalEvents { - err := spvChain.AddPastRedemptionProposalSubmittedEvent( - &tbtc.RedemptionProposalSubmittedEventFilter{ + for _, event := range events { + err := spvChain.addPastRedemptionRequestedEvent( + &tbtc.RedemptionRequestedEventFilter{ StartBlock: currentBlock - historyDepth, }, - proposalEvent, + event, ) if err != nil { t.Fatal(err) diff --git a/pkg/maintainer/spv/spv.go b/pkg/maintainer/spv/spv.go index 50de02189a..27c03c5d1e 100644 --- a/pkg/maintainer/spv/spv.go +++ b/pkg/maintainer/spv/spv.go @@ -426,7 +426,7 @@ func getProofInfo( // walletEvent is a type constraint representing wallet-related chain events. type walletEvent interface { - WalletPublicKeyHash() [20]byte + GetWalletPublicKeyHash() [20]byte } // uniqueWalletPublicKeyHashes parses the list of wallet-related events and @@ -436,7 +436,7 @@ func uniqueWalletPublicKeyHashes[T walletEvent](events []T) [][20]byte { var publicKeyHashes [][20]byte for _, event := range events { - key := event.WalletPublicKeyHash() + key := event.GetWalletPublicKeyHash() strKey := hex.EncodeToString(key[:]) // Check for uniqueness diff --git a/pkg/maintainer/spv/spv_test.go b/pkg/maintainer/spv/spv_test.go index 1fe3b468f7..94c2084d11 100644 --- a/pkg/maintainer/spv/spv_test.go +++ b/pkg/maintainer/spv/spv_test.go @@ -167,48 +167,36 @@ func TestUniqueWalletPublicKeyHashes(t *testing.T) { return value } - events := []*tbtc.DepositSweepProposalSubmittedEvent{ - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "4cc32253cc0bcd0cf9cfc79ed7b21d10df207f0d", - ), - }, + events := []*tbtc.DepositRevealedEvent{ + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "4cc32253cc0bcd0cf9cfc79ed7b21d10df207f0d", + ), }, - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "ddbd706d13dbd06038519c7621ac5de167bd3fd6", - ), - }, + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "ddbd706d13dbd06038519c7621ac5de167bd3fd6", + ), }, - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "4cc32253cc0bcd0cf9cfc79ed7b21d10df207f0d", - ), - }, + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "4cc32253cc0bcd0cf9cfc79ed7b21d10df207f0d", + ), }, - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "1016a8ff380e8907c82a88158019917e65c16ac4", - ), - }, + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "1016a8ff380e8907c82a88158019917e65c16ac4", + ), }, - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "1016a8ff380e8907c82a88158019917e65c16ac4", - ), - }, + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "1016a8ff380e8907c82a88158019917e65c16ac4", + ), }, - &tbtc.DepositSweepProposalSubmittedEvent{ - Proposal: &tbtc.DepositSweepProposal{ - WalletPublicKeyHash: bytes20FromHex( - "2c35ed9921fa35482c3cb3ae1190d87ede65dfd8", - ), - }, + &tbtc.DepositRevealedEvent{ + WalletPublicKeyHash: bytes20FromHex( + "2c35ed9921fa35482c3cb3ae1190d87ede65dfd8", + ), }, } walletKeyHashes := uniqueWalletPublicKeyHashes(events) diff --git a/pkg/tbtc/chain.go b/pkg/tbtc/chain.go index 60d180ecbb..cbad8737d1 100644 --- a/pkg/tbtc/chain.go +++ b/pkg/tbtc/chain.go @@ -279,6 +279,10 @@ func (dre *DepositRevealedEvent) unpack() *Deposit { } } +func (dre *DepositRevealedEvent) GetWalletPublicKeyHash() [20]byte { + return dre.WalletPublicKeyHash +} + // DepositRevealedEventFilter is a component allowing to filter DepositRevealedEvent. type DepositRevealedEventFilter struct { StartBlock uint64 @@ -358,6 +362,10 @@ type RedemptionRequestedEvent struct { BlockNumber uint64 } +func (rre *RedemptionRequestedEvent) GetWalletPublicKeyHash() [20]byte { + return rre.WalletPublicKeyHash +} + // RedemptionRequestedEventFilter is a component allowing to filter RedemptionRequestedEvent. type RedemptionRequestedEventFilter struct { StartBlock uint64 From 1fd56de1c6a0e2c782ebdfa9c076db0a3136bc03 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 6 Dec 2023 17:15:34 +0100 Subject: [PATCH 6/6] Update maintainer k8s manifests --- .../kube/keep-test/keep-maintainer/kustomization.yaml | 5 +---- .../templates/keep-maintainer/maintainer-statefulset.yaml | 7 ------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/infrastructure/kube/keep-test/keep-maintainer/kustomization.yaml b/infrastructure/kube/keep-test/keep-maintainer/kustomization.yaml index b5af7cc89d..59ad3afb84 100644 --- a/infrastructure/kube/keep-test/keep-maintainer/kustomization.yaml +++ b/infrastructure/kube/keep-test/keep-maintainer/kustomization.yaml @@ -5,7 +5,7 @@ namespace: default commonLabels: app: keep-maintainer - # The current setup runs spv and walletCoordination modules as a workaround + # The current setup runs only the spv module as a workaround # for reasons mentioned in `patches` property below. type: all network: sepolia @@ -45,9 +45,6 @@ patches: - op: add path: /spec/template/spec/containers/0/args/- value: --spv - - op: add - path: /spec/template/spec/containers/0/args/- - value: --walletCoordination - op: replace path: /spec/template/spec/containers/0/env/0/valueFrom/secretKeyRef/name value: eth-network-sepolia diff --git a/infrastructure/kube/templates/keep-maintainer/maintainer-statefulset.yaml b/infrastructure/kube/templates/keep-maintainer/maintainer-statefulset.yaml index 93b9c013c9..8587a6a9ea 100644 --- a/infrastructure/kube/templates/keep-maintainer/maintainer-statefulset.yaml +++ b/infrastructure/kube/templates/keep-maintainer/maintainer-statefulset.yaml @@ -46,11 +46,6 @@ spec: configMapKeyRef: name: keep-maintainer-config key: electrum-api-url - - name: REDEMPTION_REQUEST_AMOUNT_LIMIT - valueFrom: - configMapKeyRef: - name: keep-maintainer-config - key: redemption-request-amount-limit command: - keep-client - maintainer @@ -62,8 +57,6 @@ spec: - /mnt/keep-maintainer/keyfile/keep-maintainer-keyfile - --bitcoin.electrum.url - $(ELECTRUM_API_URL) - - --walletCoordination.redemptionRequestAmountLimit - - $(REDEMPTION_REQUEST_AMOUNT_LIMIT) volumeMounts: - name: eth-account-keyfile mountPath: /mnt/keep-maintainer/keyfile