diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index 05ac6fe249..51ad479acf 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -1529,17 +1529,17 @@ func (tc *TbtcChain) GetWalletLock( func parseWalletActionType(value uint8) (tbtc.WalletActionType, error) { switch value { case 0: - return tbtc.Noop, nil + return tbtc.ActionNoop, nil case 1: - return tbtc.Heartbeat, nil + return tbtc.ActionHeartbeat, nil case 2: - return tbtc.DepositSweep, nil + return tbtc.ActionDepositSweep, nil case 3: - return tbtc.Redemption, nil + return tbtc.ActionRedemption, nil case 4: - return tbtc.MovingFunds, nil + return tbtc.ActionMovingFunds, nil case 5: - return tbtc.MovedFundsSweep, nil + return tbtc.ActionMovedFundsSweep, nil default: return 0, fmt.Errorf("unexpected wallet action value: [%v]", value) } diff --git a/pkg/maintainer/wallet/chain_test.go b/pkg/maintainer/wallet/chain_test.go index 97ffa8440d..0de2f6cd37 100644 --- a/pkg/maintainer/wallet/chain_test.go +++ b/pkg/maintainer/wallet/chain_test.go @@ -6,11 +6,12 @@ import ( "encoding/binary" "encoding/hex" "fmt" - "github.com/keep-network/keep-core/pkg/bitcoin" "math/big" "sync" "time" + "github.com/keep-network/keep-core/pkg/bitcoin" + "github.com/keep-network/keep-core/pkg/tbtc" ) @@ -426,7 +427,7 @@ func (lc *LocalChain) GetWalletLock( walletLock, ok := lc.walletLocks[walletPublicKeyHash] if !ok { - return time.Time{}, tbtc.Noop, fmt.Errorf("no lock configured for given wallet") + return time.Time{}, tbtc.ActionNoop, fmt.Errorf("no lock configured for given wallet") } return walletLock.lockExpiration, walletLock.walletAction, nil @@ -454,6 +455,6 @@ func (lc *LocalChain) ResetWalletLock( lc.walletLocks[walletPublicKeyHash] = &walletLock{ lockExpiration: time.Unix(0, 0), - walletAction: tbtc.Noop, + walletAction: tbtc.ActionNoop, } } diff --git a/pkg/maintainer/wallet/deposit_sweep.go b/pkg/maintainer/wallet/deposit_sweep.go index 365db73b4a..e814f545a2 100644 --- a/pkg/maintainer/wallet/deposit_sweep.go +++ b/pkg/maintainer/wallet/deposit_sweep.go @@ -38,7 +38,7 @@ func (wm *walletMaintainer) runDepositSweepTask(ctx context.Context) error { return wm.runIfWalletUnlocked( ctx, walletPublicKeyHash, - tbtc.DepositSweep, + tbtc.ActionDepositSweep, func() error { return ProposeDepositsSweep( wm.chain, diff --git a/pkg/maintainer/wallet/redemptions.go b/pkg/maintainer/wallet/redemptions.go index c7b8dc8495..57da3ff0b1 100644 --- a/pkg/maintainer/wallet/redemptions.go +++ b/pkg/maintainer/wallet/redemptions.go @@ -36,7 +36,7 @@ func (wm *walletMaintainer) runRedemptionTask(ctx context.Context) error { return wm.runIfWalletUnlocked( ctx, walletPublicKeyHash, - tbtc.Redemption, + tbtc.ActionRedemption, func() error { return ProposeRedemption( wm.chain, diff --git a/pkg/maintainer/wallet/wallet_test.go b/pkg/maintainer/wallet/wallet_test.go index 5a2adc8f18..b0f5166eef 100644 --- a/pkg/maintainer/wallet/wallet_test.go +++ b/pkg/maintainer/wallet/wallet_test.go @@ -20,7 +20,7 @@ func TestRunIfWalletUnlocked_WhenLocked(t *testing.T) { localChain.SetWalletLock( walletPublicKeyHash, lockExpiration, - tbtc.Heartbeat, + tbtc.ActionHeartbeat, ) runFunc := func() error { @@ -35,7 +35,7 @@ func TestRunIfWalletUnlocked_WhenLocked(t *testing.T) { err := wm.runIfWalletUnlocked( context.Background(), walletPublicKeyHash, - tbtc.DepositSweep, + tbtc.ActionDepositSweep, runFunc, ) if err != nil { @@ -75,7 +75,7 @@ func TestRunIfWalletUnlocked_WhenUnlocked(t *testing.T) { err := wm.runIfWalletUnlocked( context.Background(), walletPublicKeyHash, - tbtc.DepositSweep, + tbtc.ActionDepositSweep, runFunc, ) diff --git a/pkg/tbtc/deposit_sweep.go b/pkg/tbtc/deposit_sweep.go index 707a6a1e05..68e0785fbb 100644 --- a/pkg/tbtc/deposit_sweep.go +++ b/pkg/tbtc/deposit_sweep.go @@ -351,7 +351,7 @@ func (dsa *depositSweepAction) wallet() wallet { } func (dsa *depositSweepAction) actionType() WalletActionType { - return DepositSweep + return ActionDepositSweep } // assembleDepositSweepTransaction constructs an unsigned deposit sweep Bitcoin diff --git a/pkg/tbtc/heartbeat.go b/pkg/tbtc/heartbeat.go index ef9136259d..a26c960919 100644 --- a/pkg/tbtc/heartbeat.go +++ b/pkg/tbtc/heartbeat.go @@ -96,5 +96,5 @@ func (ha *heartbeatAction) wallet() wallet { } func (ha *heartbeatAction) actionType() WalletActionType { - return Heartbeat + return ActionHeartbeat } diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index 16fbdf943b..8c21e04195 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -350,7 +350,7 @@ func (n *node) handleHeartbeatRequest( walletActionLogger := logger.With( zap.String("wallet", fmt.Sprintf("0x%x", walletPublicKeyBytes)), - zap.String("action", Heartbeat.String()), + zap.String("action", ActionHeartbeat.String()), zap.Uint64("startBlock", heartbeatRequestProcessingStartBlock), ) walletActionLogger.Infof("dispatching wallet action") @@ -435,7 +435,7 @@ func (n *node) handleDepositSweepProposal( walletActionLogger := logger.With( zap.String("wallet", fmt.Sprintf("0x%x", walletPublicKeyBytes)), - zap.String("action", DepositSweep.String()), + zap.String("action", ActionDepositSweep.String()), zap.Uint64("startBlock", proposalProcessingStartBlock), ) walletActionLogger.Infof("dispatching wallet action") @@ -522,7 +522,7 @@ func (n *node) handleRedemptionProposal( walletActionLogger := logger.With( zap.String("wallet", fmt.Sprintf("0x%x", walletPublicKeyBytes)), - zap.String("action", Redemption.String()), + zap.String("action", ActionRedemption.String()), zap.Uint64("startBlock", proposalProcessingStartBlock), ) walletActionLogger.Infof("dispatching wallet action") diff --git a/pkg/tbtc/redemption.go b/pkg/tbtc/redemption.go index 9734d1ac13..98b9394170 100644 --- a/pkg/tbtc/redemption.go +++ b/pkg/tbtc/redemption.go @@ -292,7 +292,7 @@ func (ra *redemptionAction) wallet() wallet { } func (ra *redemptionAction) actionType() WalletActionType { - return Redemption + return ActionRedemption } // redemptionFeeDistributionFn calculates the redemption transaction fee diff --git a/pkg/tbtc/tbtc.go b/pkg/tbtc/tbtc.go index 407c9f5612..6cb8ad1b03 100644 --- a/pkg/tbtc/tbtc.go +++ b/pkg/tbtc/tbtc.go @@ -331,7 +331,7 @@ func Initialize( // The event is confirmed if the wallet is locked due to a heartbeat // action. - if time.Now().Before(expiresAt) && cause == Heartbeat { + if time.Now().Before(expiresAt) && cause == ActionHeartbeat { logger.Infof( "heartbeat request submitted for "+ "wallet PKH [0x%x] at block [%v] by [%v]", @@ -432,7 +432,7 @@ func Initialize( // The event is confirmed if the wallet is locked due to a deposit // sweep action. - if time.Now().Before(expiresAt) && cause == DepositSweep { + if time.Now().Before(expiresAt) && cause == ActionDepositSweep { logger.Infof( "deposit sweep proposal submitted for "+ "wallet PKH [0x%x] at block [%v] by [%v]", @@ -532,7 +532,7 @@ func Initialize( // The event is confirmed if the wallet is locked due to a // redemption action. - if time.Now().Before(expiresAt) && cause == Redemption { + if time.Now().Before(expiresAt) && cause == ActionRedemption { logger.Infof( "redemption proposal submitted for "+ "wallet PKH [0x%x] at block [%v] by [%v]", diff --git a/pkg/tbtc/wallet.go b/pkg/tbtc/wallet.go index 126621a20e..9c9e663337 100644 --- a/pkg/tbtc/wallet.go +++ b/pkg/tbtc/wallet.go @@ -23,27 +23,27 @@ import ( type WalletActionType uint8 const ( - Noop WalletActionType = iota - Heartbeat - DepositSweep - Redemption - MovingFunds - MovedFundsSweep + ActionNoop WalletActionType = iota + ActionHeartbeat + ActionDepositSweep + ActionRedemption + ActionMovingFunds + ActionMovedFundsSweep ) func (wat WalletActionType) String() string { switch wat { - case Noop: + case ActionNoop: return "Noop" - case Heartbeat: + case ActionHeartbeat: return "Heartbeat" - case DepositSweep: + case ActionDepositSweep: return "DepositSweep" - case Redemption: + case ActionRedemption: return "Redemption" - case MovingFunds: + case ActionMovingFunds: return "MovingFunds" - case MovedFundsSweep: + case ActionMovedFundsSweep: return "MovedFundsSweep" default: panic("unknown wallet action type") diff --git a/pkg/tbtc/wallet_test.go b/pkg/tbtc/wallet_test.go index 9157622620..977f491d7a 100644 --- a/pkg/tbtc/wallet_test.go +++ b/pkg/tbtc/wallet_test.go @@ -273,7 +273,7 @@ func (mwa *mockWalletAction) wallet() wallet { } func (mwa *mockWalletAction) actionType() WalletActionType { - return Noop + return ActionNoop } func generateWallet(privateKey *big.Int) wallet {