Skip to content

Commit 74adc64

Browse files
committed
fix failed transfers with pton
1 parent c952d5c commit 74adc64

File tree

3 files changed

+66
-35
lines changed

3 files changed

+66
-35
lines changed

pkg/bath/bath_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func TestFindActions(t *testing.T) {
350350
straws: []Merger{
351351
NftTransferStraw,
352352
NftTransferNotifyStraw,
353-
JettonTransferPTONStraw,
353+
StonfiV1PTONStraw,
354354
JettonTransferClassicStraw,
355355
},
356356
},
@@ -359,7 +359,7 @@ func TestFindActions(t *testing.T) {
359359
hash: "6a4c8e0dca5b052ab75f535df9d42ede949054f0004d3dd7aa6197af9dff0e1e",
360360
filenamePrefix: "megatonfi-swap",
361361
straws: []Merger{
362-
JettonTransferPTONStraw,
362+
StonfiV1PTONStraw,
363363
JettonTransferClassicStraw,
364364
MegatonFiJettonSwap,
365365
},

pkg/bath/stonfi.go

+59
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,37 @@ var StonfiSwapStraw = Straw[BubbleJettonSwap]{
123123
},
124124
}
125125

126+
var StonfiV1PTONStraw = Straw[BubbleJettonTransfer]{
127+
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.JettonTransferMsgOp)},
128+
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
129+
tx := bubble.Info.(BubbleTx)
130+
newAction.master, _ = tx.additionalInfo.JettonMaster(tx.account.Address)
131+
newAction.senderWallet = tx.account.Address
132+
newAction.sender = tx.inputFrom
133+
body := tx.decodedBody.Value.(abi.JettonTransferMsgBody)
134+
newAction.amount = body.Amount
135+
newAction.isWrappedTon = true
136+
recipient, err := ton.AccountIDFromTlb(body.Destination)
137+
if err == nil && recipient != nil {
138+
newAction.recipient = &Account{Address: *recipient}
139+
bubble.Accounts = append(bubble.Accounts, *recipient)
140+
}
141+
return nil
142+
},
143+
SingleChild: &Straw[BubbleJettonTransfer]{
144+
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp)},
145+
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
146+
tx := bubble.Info.(BubbleTx)
147+
newAction.success = true
148+
body := tx.decodedBody.Value.(abi.JettonNotifyMsgBody)
149+
newAction.amount = body.Amount
150+
newAction.payload = body.ForwardPayload.Value
151+
newAction.recipient = &tx.account
152+
return nil
153+
},
154+
},
155+
}
156+
126157
var StonfiV2PTONStraw = Straw[BubbleJettonTransfer]{
127158
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.PtonTonTransferMsgOp)},
128159
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
@@ -153,6 +184,34 @@ var StonfiV2PTONStraw = Straw[BubbleJettonTransfer]{
153184
},
154185
}
155186

187+
var StonfiV2PTONStrawReverse = Straw[BubbleJettonTransfer]{
188+
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.JettonTransferMsgOp)},
189+
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
190+
tx := bubble.Info.(BubbleTx)
191+
newAction.master, _ = tx.additionalInfo.JettonMaster(tx.account.Address)
192+
newAction.senderWallet = tx.account.Address
193+
newAction.sender = tx.inputFrom
194+
body := tx.decodedBody.Value.(abi.JettonTransferMsgBody)
195+
newAction.amount = body.Amount
196+
newAction.isWrappedTon = true
197+
newAction.payload = body.ForwardPayload.Value
198+
recipient, err := ton.AccountIDFromTlb(body.Destination)
199+
if err == nil {
200+
newAction.recipient = &Account{Address: *recipient}
201+
}
202+
return nil
203+
},
204+
SingleChild: &Straw[BubbleJettonTransfer]{
205+
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.PtonTonTransferMsgOp)},
206+
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
207+
tx := bubble.Info.(BubbleTx)
208+
newAction.success = true
209+
newAction.recipient = &tx.account
210+
return nil
211+
},
212+
},
213+
}
214+
156215
var StonfiSwapV2Straw = Straw[BubbleJettonSwap]{
157216
CheckFuncs: []bubbleCheck{func(bubble *Bubble) bool {
158217
jettonTx, ok := bubble.Info.(BubbleJettonTransfer)

pkg/bath/straws.go

+5-33
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ type Merger interface {
1414
}
1515

1616
var JettonTransfersBurnsMints = []Merger{
17-
JettonTransferPTONStraw,
17+
StonfiV1PTONStraw,
18+
StonfiV2PTONStrawReverse,
19+
StonfiV2PTONStraw,
1820
JettonTransferClassicStraw,
1921
JettonTransferMinimalStraw,
2022
JettonBurnStraw,
@@ -38,7 +40,8 @@ var DefaultStraws = []Merger{
3840
StrawFindAuctionBidFragmentSimple,
3941
NftTransferStraw,
4042
NftTransferNotifyStraw,
41-
JettonTransferPTONStraw,
43+
StonfiV1PTONStraw,
44+
StonfiV2PTONStrawReverse,
4245
StonfiV2PTONStraw,
4346
JettonTransferClassicStraw,
4447
JettonTransferMinimalStraw,
@@ -71,37 +74,6 @@ var DefaultStraws = []Merger{
7174
DNSRenewStraw,
7275
}
7376

74-
var JettonTransferPTONStraw = Straw[BubbleJettonTransfer]{
75-
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.JettonTransferMsgOp)},
76-
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
77-
tx := bubble.Info.(BubbleTx)
78-
newAction.master, _ = tx.additionalInfo.JettonMaster(tx.account.Address)
79-
newAction.senderWallet = tx.account.Address
80-
newAction.sender = tx.inputFrom
81-
body := tx.decodedBody.Value.(abi.JettonTransferMsgBody)
82-
newAction.amount = body.Amount
83-
newAction.isWrappedTon = true
84-
recipient, err := ton.AccountIDFromTlb(body.Destination)
85-
if err == nil && recipient != nil {
86-
newAction.recipient = &Account{Address: *recipient}
87-
bubble.Accounts = append(bubble.Accounts, *recipient)
88-
}
89-
return nil
90-
},
91-
SingleChild: &Straw[BubbleJettonTransfer]{
92-
CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp)},
93-
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {
94-
tx := bubble.Info.(BubbleTx)
95-
newAction.success = true
96-
body := tx.decodedBody.Value.(abi.JettonNotifyMsgBody)
97-
newAction.amount = body.Amount
98-
newAction.payload = body.ForwardPayload.Value
99-
newAction.recipient = &tx.account
100-
return nil
101-
},
102-
},
103-
}
104-
10577
var JettonTransferClassicStraw = Straw[BubbleJettonTransfer]{
10678
CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.JettonWallet), HasOperation(abi.JettonTransferMsgOp)},
10779
Builder: func(newAction *BubbleJettonTransfer, bubble *Bubble) error {

0 commit comments

Comments
 (0)