Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conditions of SmartContractExec action #151

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions pkg/bath/bath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,22 @@ func TestFindActions(t *testing.T) {
tongo.MustParseBlockID("(0,8000000000000000,36828763)"),
// cancel sale at getgems
tongo.MustParseBlockID("(0,8000000000000000,36025985)"),
// multiple call contracts
tongo.MustParseBlockID("(0,8000000000000000,36692636)"),
}),
)

if err != nil {
t.Fatal(err)
}
type Case struct {
name string
account string
hash string
filenamePrefix string
source core.InformationSource
valueFlow ValueFlow
additionalStraws []Straw
name string
account string
hash string
filenamePrefix string
source core.InformationSource
valueFlow ValueFlow
straws []Straw
}
for _, c := range []Case{
{
Expand Down Expand Up @@ -248,6 +250,15 @@ func TestFindActions(t *testing.T) {
},
},
},
{
name: "multiple call contracts",
hash: "e87ec0ae9ebdba400b82887462dd0908a954fe2165c1a89775742d85a5e2a5f8",
filenamePrefix: "multiple-call-contracts",
straws: []Straw{
FindNFTTransfer,
FindJettonTransfer,
},
},
} {
t.Run(c.name, func(t *testing.T) {
trace, err := storage.GetTrace(context.Background(), tongo.MustParseHash(c.hash))
Expand All @@ -256,9 +267,13 @@ func TestFindActions(t *testing.T) {
if c.source == nil {
source = storage
}
straws := DefaultStraws
if len(c.straws) > 0 {
straws = c.straws
}
actionsList, err := FindActions(context.Background(),
trace,
WithStraws(append(c.additionalStraws, DefaultStraws...)),
WithStraws(straws),
WithInformationSource(source))
require.Nil(t, err)
results := result{
Expand Down
2 changes: 1 addition & 1 deletion pkg/bath/bubble_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b BubbleTx) ToAction() *Action {
}
return nil
}
if b.opCode != nil && (*b.opCode == 0 || b.operation(abi.EncryptedTextCommentMsgOp)) && b.accountWasActiveAtComputingTime && !b.account.Is(abi.Wallet) {
if b.opCode != nil && (*b.opCode != 0 && !b.operation(abi.EncryptedTextCommentMsgOp)) && b.accountWasActiveAtComputingTime && !b.account.Is(abi.Wallet) {
operation := fmt.Sprintf("0x%08x", *b.opCode)
payload := ""
if b.decodedBody != nil {
Expand Down
15 changes: 7 additions & 8 deletions pkg/bath/testdata/getgetms-cancel-sale.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"Actions": [
{
"TonTransfer": {
"Amount": 1100000000,
"Comment": null,
"EncryptedComment": null,
"Recipient": "0:30635bdaa6736ad1ed89146b5a34e2cc21e9eca51031a463fe4c89a537304547",
"Sender": "0:e3e4dbd02b51e1e9c72de4f017f1771be882a8d479a3a1cd8b33535a83fd5fa4",
"Refund": null
"SmartContractExec": {
"TonAttached": 1100000000,
"Executor": "0:e3e4dbd02b51e1e9c72de4f017f1771be882a8d479a3a1cd8b33535a83fd5fa4",
"Contract": "0:30635bdaa6736ad1ed89146b5a34e2cc21e9eca51031a463fe4c89a537304547",
"Operation": "0x00000003",
"Payload": ""
},
"Success": true,
"Type": "TonTransfer"
"Type": "SmartContractExec"
},
{
"NftItemTransfer": {
Expand Down
135 changes: 135 additions & 0 deletions pkg/bath/testdata/multiple-call-contracts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"Actions": [
{
"JettonTransfer": {
"Comment": "Call: 0x25938561",
"EncryptedComment": null,
"Jetton": "0:9c2c05b9dfb2a7460fda48fae7409a32623399933a98a7a15599152f37572b49",
"Recipient": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"Sender": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"RecipientsWallet": "0:755f21900374af9b39f25e90276caed94409194cad6c32cd12abf336c0df9eb7",
"SendersWallet": "0:efde81ab6cd63d8d96efe2ea7a7396066d2f396f19df4e4e03a7ed5f82d73754",
"Amount": "16666723091",
"Refund": null
},
"Success": true,
"Type": "JettonTransfer"
},
{
"SmartContractExec": {
"TonAttached": 236264000,
"Executor": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"Contract": "0:afe41587f4f404b99c567b9cacedd1381f5ff855ccdc112e0cf8291afa7f19f9",
"Operation": "StonfiSwap",
"Payload": "Addrs:\n Value:\n FromUser: 0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb\nHasRefAddress: true\nJettonAmount: \"16666723091\"\nMinOut: \"2087431288\"\nQueryId: 1763571776588606\nSenderAddress: 0:755f21900374af9b39f25e90276caed94409194cad6c32cd12abf336c0df9eb7\nToAddress: 0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb\n"
},
"Success": true,
"Type": "SmartContractExec"
},
{
"SmartContractExec": {
"TonAttached": 103470000,
"Executor": "0:afe41587f4f404b99c567b9cacedd1381f5ff855ccdc112e0cf8291afa7f19f9",
"Contract": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"Operation": "StonfiPaymentRequest",
"Payload": "ExitCode: 1158120768\nOwner: 0:6c8eef549f003f4f421d009aede507e3f7535667b639e98fd09b55c8fc0e23cb\nParams:\n IsRight: true\n Value:\n Amount0Out: \"2102126\"\n Amount1Out: \"0\"\n Token0Address: 0:b90a4147ba83fea581fa8d73b1c92cf82dcc92b0c6df924c3c0553d713b35e6c\n Token1Address: 0:755f21900374af9b39f25e90276caed94409194cad6c32cd12abf336c0df9eb7\nQueryId: 1763571776588606\n"
},
"Success": true,
"Type": "SmartContractExec"
},
{
"JettonTransfer": {
"Comment": "Call: 0x45078540",
"EncryptedComment": null,
"Jetton": "0:d0a1ce4cdc187c79615ea618bd6c29617af7a56d966f5a192a768f345ee63fd2",
"Recipient": "0:6c8eef549f003f4f421d009aede507e3f7535667b639e98fd09b55c8fc0e23cb",
"Sender": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"RecipientsWallet": "0:b34b16cac2989483cb2b67514bc752b3b2fc4bd9281cea53aad3b9cc9dfeaa9c",
"SendersWallet": "0:b90a4147ba83fea581fa8d73b1c92cf82dcc92b0c6df924c3c0553d713b35e6c",
"Amount": "2102126",
"Refund": null
},
"Success": true,
"Type": "JettonTransfer"
},
{
"SmartContractExec": {
"TonAttached": 103462000,
"Executor": "0:afe41587f4f404b99c567b9cacedd1381f5ff855ccdc112e0cf8291afa7f19f9",
"Contract": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"Operation": "StonfiPaymentRequest",
"Payload": "ExitCode: 3326308581\nOwner: 0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb\nParams:\n IsRight: true\n Value:\n Amount0Out: \"2097920891\"\n Amount1Out: \"0\"\n Token0Address: 0:b90a4147ba83fea581fa8d73b1c92cf82dcc92b0c6df924c3c0553d713b35e6c\n Token1Address: 0:755f21900374af9b39f25e90276caed94409194cad6c32cd12abf336c0df9eb7\nQueryId: 1763571776588606\n"
},
"Success": true,
"Type": "SmartContractExec"
},
{
"JettonTransfer": {
"Comment": "Call: 0xc64370e5",
"EncryptedComment": null,
"Jetton": "0:d0a1ce4cdc187c79615ea618bd6c29617af7a56d966f5a192a768f345ee63fd2",
"Recipient": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Sender": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"RecipientsWallet": "0:ba799c63dfaa07244c407dc5ebd6e8ffb1807f636ca6d02677e7848100234ef3",
"SendersWallet": "0:b90a4147ba83fea581fa8d73b1c92cf82dcc92b0c6df924c3c0553d713b35e6c",
"Amount": "2097920891",
"Refund": null
},
"Success": true,
"Type": "JettonTransfer"
}
],
"Accounts": [
{
"Account": "0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb",
"Ton": -251200000,
"Fee": 9749064,
"Jettons": [
{
"Address": "0:d0a1ce4cdc187c79615ea618bd6c29617af7a56d966f5a192a768f345ee63fd2",
"Quantity": 2097920891
}
]
},
{
"Account": "0:6c8eef549f003f4f421d009aede507e3f7535667b639e98fd09b55c8fc0e23cb",
"Ton": 58824000,
"Fee": 3,
"Jettons": [
{
"Address": "0:d0a1ce4cdc187c79615ea618bd6c29617af7a56d966f5a192a768f345ee63fd2",
"Quantity": 2102126
}
]
},
{
"Account": "0:779dcc815138d9500e449c5291e7f12738c23d575b5310000f6a253bd607384e",
"Ton": 43796000,
"Fee": 43796010,
"Jettons": [
{
"Address": "0:9c2c05b9dfb2a7460fda48fae7409a32623399933a98a7a15599152f37572b49",
"Quantity": 16666723091
}
]
},
{
"Account": "0:afe41587f4f404b99c567b9cacedd1381f5ff855ccdc112e0cf8291afa7f19f9",
"Ton": 29332000,
"Fee": 23309865,
"Jettons": null
},
{
"Account": "0:b90a4147ba83fea581fa8d73b1c92cf82dcc92b0c6df924c3c0553d713b35e6c",
"Ton": 37248000,
"Fee": 37268488,
"Jettons": null
},
{
"Account": "0:efde81ab6cd63d8d96efe2ea7a7396066d2f396f19df4e4e03a7ed5f82d73754",
"Ton": 20167000,
"Fee": 20167068,
"Jettons": null
}
]
}
4 changes: 4 additions & 0 deletions pkg/core/testdata/convert-tx-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"CreatedLt": 37362820000002,
"Source": "0:6ccd325a858c379693fae2bcaab1c2906831a4e10a6c3bb44ee8b615bca1d220",
"Destination": "0:6dcb8357c6bef52b43f0f681d976f5a46068ae195cb95f7a959d25c71b0cac6c",
"SourceExtern": null,
"DestinationExtern": null,
"IhrDisabled": true,
"Bounce": true,
"Bounced": false,
Expand All @@ -28,6 +30,8 @@
"CreatedLt": 37362820000004,
"Source": "0:6dcb8357c6bef52b43f0f681d976f5a46068ae195cb95f7a959d25c71b0cac6c",
"Destination": "0:e185f22dd230150f2a9d6e9d2bf833b5c03d6215bdfd031d2691f8b835dd99de",
"SourceExtern": null,
"DestinationExtern": null,
"IhrDisabled": true,
"Bounce": true,
"Bounced": false,
Expand Down