Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Aug 12, 2024
1 parent 7b0722b commit e69e1cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 118 deletions.
4 changes: 2 additions & 2 deletions pkg/bath/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
114 changes: 0 additions & 114 deletions pkg/bath/tf_nominators.go
Original file line number Diff line number Diff line change
@@ -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

}
3 changes: 1 addition & 2 deletions pkg/pusher/websocket/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit e69e1cc

Please sign in to comment.