From e69e1cca1406d55b6c8372e1fa3dd4f5ecc633f7 Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Mon, 12 Aug 2024 13:26:00 +0300 Subject: [PATCH] minor fixes --- pkg/bath/staking.go | 4 +- pkg/bath/tf_nominators.go | 114 -------------------------------- pkg/pusher/websocket/handler.go | 3 +- 3 files changed, 3 insertions(+), 118 deletions(-) diff --git a/pkg/bath/staking.go b/pkg/bath/staking.go index 633d5208..08e36512 100644 --- a/pkg/bath/staking.go +++ b/pkg/bath/staking.go @@ -260,11 +260,11 @@ var PendingWithdrawRequestLiquidStraw = Straw[BubbleWithdrawStakeRequest]{ }, SingleChild: &Straw[BubbleWithdrawStakeRequest]{ Optional: true, - CheckFuncs: []bubbleCheck{IsTx, HasOpcode(0x1674b0a0)}, + CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.TonstakePayoutMintJettonsMsgOp)}, SingleChild: &Straw[BubbleWithdrawStakeRequest]{ CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.TonstakeNftInitMsgOp)}, SingleChild: &Straw[BubbleWithdrawStakeRequest]{ - CheckFuncs: []bubbleCheck{Is(BubbleNftTransfer{})}, + CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.NftOwnershipAssignedMsgOp)}, Builder: func(newAction *BubbleWithdrawStakeRequest, bubble *Bubble) error { newAction.Success = true return nil diff --git a/pkg/bath/tf_nominators.go b/pkg/bath/tf_nominators.go index 5f9c4df9..9965c5f4 100644 --- a/pkg/bath/tf_nominators.go +++ b/pkg/bath/tf_nominators.go @@ -1,115 +1 @@ package bath - -import ( - "github.com/tonkeeper/tongo" - "github.com/tonkeeper/tongo/abi" -) - -type TFCommand string - -// todo: move to tongo -const ( - TfDepositStakeRequest TFCommand = "TfDepositStakeRequest" - TfRecoverStakeRequest TFCommand = "TfRecoverStakeRequest" - TfProcessPendingWithdrawRequests TFCommand = "TfProcessPendingWithdrawRequests" - TfUpdateValidatorSet TFCommand = "TfUpdateValidatorSet" -) - -type BubbleTFNominator struct { - Command TFCommand - Amount int64 - Actor tongo.AccountID - Contract tongo.AccountID - Success bool -} - -func (b BubbleTFNominator) ToAction() *Action { - return &Action{ - SmartContractExec: &SmartContractAction{ - TonAttached: b.Amount, - Executor: b.Actor, - Contract: b.Contract, - Operation: string(b.Command), - }, - Type: SmartContractExec, - Success: b.Success, - } - -} - -func FindTFNominatorAction(bubble *Bubble) bool { - bubbleTx, ok := bubble.Info.(BubbleTx) - if !ok { - return false - } - if bubbleTx.opCode == nil { - return false - } - if !bubbleTx.account.Is(abi.TvPool) { - return false - } - if bubbleTx.inputFrom == nil { - return false - } - - var command TFCommand - amount := bubbleTx.inputAmount - sender := bubbleTx.inputFrom.Address - children := bubble.Children - - newBubble := Bubble{ - Accounts: bubble.Accounts, - ValueFlow: bubble.ValueFlow, - } - switch *bubbleTx.opCode { - case abi.ElectorNewStakeMsgOpCode: - command = TfDepositStakeRequest - case abi.ElectorRecoverStakeRequestMsgOpCode: - command = TfRecoverStakeRequest - case 2: - command = TfProcessPendingWithdrawRequests - children = ProcessChildren(bubble.Children, - func(child *Bubble) *Merge { - tx, ok := child.Info.(BubbleTx) - if !ok { - return nil - } - if tx.opCode == nil && tx.account.Address == sender { - // this is a send-excess transfer, let's eliminate it - amount -= tx.inputAmount - newBubble.ValueFlow.Merge(child.ValueFlow) - return &Merge{children: child.Children} - } - return nil - }) - case 6: - command = TfUpdateValidatorSet - children = ProcessChildren(bubble.Children, - func(child *Bubble) *Merge { - tx, ok := child.Info.(BubbleTx) - if !ok { - return nil - } - if tx.opCode == nil && tx.account.Address == sender { - // this is a send-excess transfer, let's eliminate it - amount -= tx.inputAmount - newBubble.ValueFlow.Merge(child.ValueFlow) - return &Merge{children: child.Children} - } - return nil - }) - default: - return false - } - newBubble.Info = BubbleTFNominator{ - Command: command, - Amount: amount, - Actor: sender, - Contract: bubbleTx.account.Address, - Success: bubbleTx.success, - } - newBubble.Children = children - *bubble = newBubble - return true - -} diff --git a/pkg/pusher/websocket/handler.go b/pkg/pusher/websocket/handler.go index 54755372..e1dff7d7 100644 --- a/pkg/pusher/websocket/handler.go +++ b/pkg/pusher/websocket/handler.go @@ -37,8 +37,7 @@ func Handler(logger *zap.Logger, txSource sources.TransactionSource, traceSource conn, err := upgrader.Upgrade(w, r, nil) if err != nil { logger.Error("failed to upgrade HTTP connection to websocket protocol", - zap.Error(err), - zap.String("remoteAddr", conn.RemoteAddr().String())) + zap.Error(err)) return err } ctx, cancel := context.WithCancel(r.Context())