From 7495cf3f7dc0dd8442a99bab6b67b2bba55ca40d Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Tue, 3 Sep 2024 12:39:53 +0000 Subject: [PATCH 1/3] Improve mint straws --- pkg/bath/jettons.go | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/pkg/bath/jettons.go b/pkg/bath/jettons.go index 35615f90e..f2ad1f70a 100644 --- a/pkg/bath/jettons.go +++ b/pkg/bath/jettons.go @@ -115,16 +115,23 @@ var DedustLPJettonMintStraw = Straw[BubbleJettonMint]{ newAction.amount = msg.Amount newAction.recipientWallet = tx.account.Address newAction.success = tx.success + newAction.recipient = *parseAccount(msg.ResponseAddress) return nil }, Children: []Straw[BubbleJettonMint]{ { - CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp)}, + CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp), func(bubble *Bubble) bool { + if len(bubble.Children) > 0 { + return false + } + return true + }}, Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error { tx := bubble.Info.(BubbleTx) newAction.recipient = tx.account return nil }, + Optional: true, }, {CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)}, Optional: true}, }, @@ -162,13 +169,17 @@ var JettonBurnStraw = Straw[BubbleJettonBurn]{ } var JettonMintStrawGovernance = Straw[BubbleJettonMint]{ - CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonMintMsgOp), HasInterface(abi.JettonMaster)}, + CheckFuncs: []bubbleCheck{IsTx, Or(HasOperation(abi.JettonMintMsgOp), HasOpcode(0x7362d09c)), HasInterface(abi.JettonMaster)}, Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error { tx := bubble.Info.(BubbleTx) - msg := tx.decodedBody.Value.(abi.JettonMintMsgBody) - dest, err := tongo.AccountIDFromTlb(msg.ToAddress) - if err == nil && dest != nil { - newAction.recipient = Account{Address: *dest} + msg, ok := tx.decodedBody.Value.(abi.JettonMintMsgBody) + if ok { + dest, err := tongo.AccountIDFromTlb(msg.ToAddress) + if err == nil && dest != nil { + newAction.recipient = Account{Address: *dest} + } + } else { + newAction.master = tx.account.Address } return nil }, @@ -181,11 +192,25 @@ var JettonMintStrawGovernance = Straw[BubbleJettonMint]{ newAction.recipientWallet = tx.account.Address newAction.master = tx.inputFrom.Address newAction.success = tx.success + newAction.recipient = *parseAccount(msg.ResponseAddress) return nil }, - SingleChild: &Straw[BubbleJettonMint]{ - Optional: true, - CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)}, + Children: []Straw[BubbleJettonMint]{ + { + CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp), func(bubble *Bubble) bool { + if len(bubble.Children) > 0 { + return false + } + return true + }}, + Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error { + tx := bubble.Info.(BubbleTx) + newAction.recipient = tx.account + return nil + }, + Optional: true, + }, + {CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)}, Optional: true}, }, }, } From 8db15d2867941dea564b722d8d5328a37ca1f06b Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Tue, 3 Sep 2024 12:46:08 +0000 Subject: [PATCH 2/3] Add nil check --- pkg/bath/jettons.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/bath/jettons.go b/pkg/bath/jettons.go index f2ad1f70a..f24055e89 100644 --- a/pkg/bath/jettons.go +++ b/pkg/bath/jettons.go @@ -192,7 +192,10 @@ var JettonMintStrawGovernance = Straw[BubbleJettonMint]{ newAction.recipientWallet = tx.account.Address newAction.master = tx.inputFrom.Address newAction.success = tx.success - newAction.recipient = *parseAccount(msg.ResponseAddress) + recipient := parseAccount(msg.ResponseAddress) + if recipient != nil { + newAction.recipient = *recipient + } return nil }, Children: []Straw[BubbleJettonMint]{ From d96809b6da8ebc4dedf1db83aaa8815594726488 Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Wed, 4 Sep 2024 15:18:39 +0000 Subject: [PATCH 3/3] undo change recipient --- pkg/bath/jettons.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/bath/jettons.go b/pkg/bath/jettons.go index f24055e89..12becda36 100644 --- a/pkg/bath/jettons.go +++ b/pkg/bath/jettons.go @@ -192,10 +192,6 @@ var JettonMintStrawGovernance = Straw[BubbleJettonMint]{ newAction.recipientWallet = tx.account.Address newAction.master = tx.inputFrom.Address newAction.success = tx.success - recipient := parseAccount(msg.ResponseAddress) - if recipient != nil { - newAction.recipient = *recipient - } return nil }, Children: []Straw[BubbleJettonMint]{