diff --git a/abi/generated_test.go b/abi/generated_test.go index f80522cf..86602ec2 100644 --- a/abi/generated_test.go +++ b/abi/generated_test.go @@ -2439,6 +2439,40 @@ func TestMessageDecoder(t *testing.T) { }, }, }, + { + name: "new_bounce_flag_1", + boc: "b5ee9c720101030100a3000213fffffffe00ffffffff40010200ff000000007364676c6b647368676a736168676b6a61736468676a6b647368676b6a7368616a6b676864736b6a6768736b6a6468676b6a736468676a6b647368676b6a736864676a68736468736a6b68676b6a736468677368646b6a67686473676a6b6873646b6a676873646b6a68676b6a736867646a6b7364686b6a676873650021405f5e10000001225ea9938c134733ab6c", + wantOpName: BounceV2MsgOp, + wantValue: BounceV2MsgBody{ + OriginalBody: tlb.Any(mustHexToCell("b5ee9c720101010100820000ff000000007364676c6b647368676a736168676b6a61736468676a6b647368676b6a7368616a6b676864736b6a6768736b6a6468676b6a736468676a6b647368676b6a736864676a68736468736a6b68676b6a736468677368646b6a67686473676a6b6873646b6a676873646b6a68676b6a736867646a6b7364686b6a67687365")), + OriginalInfo: NewBounceOriginalInfo{ + Value: tlb.CurrencyCollection{ + Grams: tlb.Grams(100000000), + }, + CreatedLt: 39908118000002, + CreatedAt: 1759933805, + }, + BouncedByPhase: 0, + ExitCode: -1, + }, + }, + { + name: "new_bounce_flag_3", + boc: "b5ee9c72010103010054000213fffffffe00ffffffff40010200620000000068692120686f70652069742077696c6c20626520656e6f75676820666f7220627579696e6720612079616368740021405f5e10000001225d27569813473370b4", + wantOpName: BounceV2MsgOp, + wantValue: BounceV2MsgBody{ + OriginalBody: tlb.Any(mustHexToCell("b5ee9c720101010100330000620000000068692120686f70652069742077696c6c20626520656e6f75676820666f7220627579696e672061207961636874")), + OriginalInfo: NewBounceOriginalInfo{ + Value: tlb.CurrencyCollection{ + Grams: tlb.Grams(100000000), + }, + CreatedLt: 39907308000002, + CreatedAt: 1759931926, + }, + BouncedByPhase: 0, + ExitCode: -1, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/abi/messages.md b/abi/messages.md index c6125d65..fa26e6b4 100644 --- a/abi/messages.md +++ b/abi/messages.md @@ -42,6 +42,7 @@ The list below contains the supported message operations, their names and opcode | BidaskSwapV2| 0x87d36990 | | BidaskSwapV2| 0x87d36990 | | Bounce| 0xffffffff | +| BounceV2| 0xfffffffe | | ChallengeQuarantinedChannelState| 0x088eaa32 | | ChangeDnsRecord| 0x4eb1f0f9 | | ChannelClosed| 0xdddc88ba | diff --git a/abi/messages_generated.go b/abi/messages_generated.go index d1f28298..3f15f1ff 100644 --- a/abi/messages_generated.go +++ b/abi/messages_generated.go @@ -553,6 +553,8 @@ var ( decodeFuncElectorRecoverStakeResponseMsgBody = decodeMsg(tlb.Tag{Val: 0xf96f7324, Len: 32}, ElectorRecoverStakeResponseMsgOp, ElectorRecoverStakeResponseMsgBody{}) // 0xfb88e119 decodeFuncJettonClaimAdminMsgBody = decodeMsg(tlb.Tag{Val: 0xfb88e119, Len: 32}, JettonClaimAdminMsgOp, JettonClaimAdminMsgBody{}) + // 0xfffffffe + decodeFuncBounceV2MsgBody = decodeMsg(tlb.Tag{Val: 0xfffffffe, Len: 32}, BounceV2MsgOp, BounceV2MsgBody{}) // 0xffffffff decodeFuncBounceMsgBody = decodeMsg(tlb.Tag{Val: 0xffffffff, Len: 32}, BounceMsgOp, BounceMsgBody{}) ) @@ -1383,6 +1385,9 @@ var opcodedMsgInDecodeFunctions = map[uint32]msgDecoderFunc{ // 0xfb88e119 JettonClaimAdminMsgOpCode: decodeFuncJettonClaimAdminMsgBody, + // 0xfffffffe + BounceV2MsgOpCode: decodeFuncBounceV2MsgBody, + // 0xffffffff BounceMsgOpCode: decodeFuncBounceMsgBody, } @@ -1661,6 +1666,7 @@ const ( CoffeeStakingDepositMsgOp MsgOpName = "CoffeeStakingDeposit" ElectorRecoverStakeResponseMsgOp MsgOpName = "ElectorRecoverStakeResponse" JettonClaimAdminMsgOp MsgOpName = "JettonClaimAdmin" + BounceV2MsgOp MsgOpName = "BounceV2" BounceMsgOp MsgOpName = "Bounce" ) @@ -1938,6 +1944,7 @@ const ( CoffeeStakingDepositMsgOpCode MsgOpCode = 0xf9471134 ElectorRecoverStakeResponseMsgOpCode MsgOpCode = 0xf96f7324 JettonClaimAdminMsgOpCode MsgOpCode = 0xfb88e119 + BounceV2MsgOpCode MsgOpCode = 0xfffffffe BounceMsgOpCode MsgOpCode = 0xffffffff ) @@ -3793,6 +3800,14 @@ type JettonClaimAdminMsgBody struct { QueryId uint64 } +type BounceV2MsgBody struct { + OriginalBody tlb.Any `tlb:"^"` + OriginalInfo NewBounceOriginalInfo `tlb:"^"` + BouncedByPhase uint8 + ExitCode int32 + ComputePhase *NewBounceComputePhaseInfo `tlb:"maybe"` +} + type BounceMsgBody struct { Payload tlb.Any } @@ -4071,6 +4086,7 @@ var KnownMsgInTypes = map[string]any{ CoffeeStakingDepositMsgOp: CoffeeStakingDepositMsgBody{}, ElectorRecoverStakeResponseMsgOp: ElectorRecoverStakeResponseMsgBody{}, JettonClaimAdminMsgOp: JettonClaimAdminMsgBody{}, + BounceV2MsgOp: BounceV2MsgBody{}, BounceMsgOp: BounceMsgBody{}, } diff --git a/abi/schemas/known.xml b/abi/schemas/known.xml index 63cb638c..82b0d5ae 100644 --- a/abi/schemas/known.xml +++ b/abi/schemas/known.xml @@ -1,10 +1,18 @@ + + _ value:CurrencyCollection created_lt:uint64 created_at:uint32 = NewBounceOriginalInfo; + _ gas_used:uint32 vm_steps:uint32 = NewBounceComputePhaseInfo; + bounce_message#ffffffff payload:Cell = InternalMsgBody; + + new_bounce_body#fffffffe original_body:^Cell original_info:^NewBounceOriginalInfo bounced_by_phase:uint8 exit_code:int32 compute_phase:(Maybe NewBounceComputePhaseInfo) = InternalMsgBody; + + text_comment#00000000 text:Text = InternalMsgBody; diff --git a/abi/types.go b/abi/types.go index 997eb05e..c34058aa 100644 --- a/abi/types.go +++ b/abi/types.go @@ -188,6 +188,17 @@ func (t *JettonForceAction) MarshalJSON() ([]byte, error) { } } +type NewBounceComputePhaseInfo struct { + GasUsed uint32 + VmSteps uint32 +} + +type NewBounceOriginalInfo struct { + Value tlb.CurrencyCollection + CreatedLt uint64 + CreatedAt uint32 +} + type TonstakersControllerData struct { ControllerId uint32 Validator tlb.MsgAddress diff --git a/tlb/messages.go b/tlb/messages.go index fe5b7cd8..d75333db 100644 --- a/tlb/messages.go +++ b/tlb/messages.go @@ -2,8 +2,10 @@ package tlb import ( "encoding/hex" + "encoding/json" "fmt" "math" + "math/big" "strconv" "strings" @@ -97,18 +99,28 @@ func (m Message) MarshalTLB(c *boc.Cell, encoder *Encoder) error { // created_lt:uint64 created_at:uint32 = CommonMsgInfo; type CommonMsgInfo struct { SumType - IntMsgInfo *struct { - IhrDisabled bool - Bounce bool - Bounced bool - Src MsgAddress - Dest MsgAddress - Value CurrencyCollection - IhrFee Grams - FwdFee Grams - CreatedLt uint64 - CreatedAt uint32 - } `tlbSumType:"int_msg_info$0"` + IntMsgInfoIhr *struct { + Bounce bool + Bounced bool + Src MsgAddress + Dest MsgAddress + Value CurrencyCollection + IhrFee Grams + FwdFee Grams + CreatedLt uint64 + CreatedAt uint32 + } `tlbSumType:"int_msg_info_ihr$00"` + IntMsgInfoNoIhr *struct { + Bounce bool + Bounced bool + Src MsgAddress + Dest MsgAddress + Value CurrencyCollection + ExtraFlags InMsgExtraFlags + FwdFee Grams + CreatedLt uint64 + CreatedAt uint32 + } `tlbSumType:"int_msg_info_no_ihr$01"` ExtInMsgInfo *struct { Src MsgAddress Dest MsgAddress @@ -122,6 +134,54 @@ type CommonMsgInfo struct { } `tlbSumType:"ext_out_msg_info$11"` } +type BouncedMessageFormat string + +const ( + OldFormat BouncedMessageFormat = "old" + BodyRoot BouncedMessageFormat = "body_root" + WholeBody BouncedMessageFormat = "whole_body" +) + +type InMsgExtraFlags VarUInteger16 + +func (f InMsgExtraFlags) BouncedMessageFormat() BouncedMessageFormat { + flags := big.Int(f) + if flags.Bit(0) == 0 { // ...0 + return OldFormat + } + if flags.Bit(1) == 0 { // ...01 = 1 + return BodyRoot + } else { // ...11 = 3 + return WholeBody + } +} + +func (f BouncedMessageFormat) ToFlags() InMsgExtraFlags { + switch f { + case BodyRoot: + return InMsgExtraFlags(*big.NewInt(1)) + case WholeBody: + return InMsgExtraFlags(*big.NewInt(3)) + } + return InMsgExtraFlags(*big.NewInt(0)) +} + +func (f *InMsgExtraFlags) UnmarshalTLB(c *boc.Cell, decoder *Decoder) error { + return decoder.Unmarshal(c, (*VarUInteger16)(f)) +} + +func (f InMsgExtraFlags) MarshalTLB(c *boc.Cell, encoder *Encoder) error { + return encoder.Marshal(c, VarUInteger16(f)) +} + +func (f InMsgExtraFlags) MarshalJSON() ([]byte, error) { + return json.Marshal(VarUInteger16(f)) +} + +func (f *InMsgExtraFlags) UnmarshalJSON(p []byte) error { + return json.Unmarshal(p, (*VarUInteger16)(f)) +} + // StateInit // _ split_depth:(Maybe (## 5)) special:(Maybe TickTock) // code:(Maybe ^Cell) data:(Maybe ^Cell) diff --git a/tlb/messages_test.go b/tlb/messages_test.go index 4cd0645b..a629a7c9 100644 --- a/tlb/messages_test.go +++ b/tlb/messages_test.go @@ -301,11 +301,41 @@ func TestMessage_Marshal_and_Unmarshal(t *testing.T) { wantHash: "23ff6f150d573f64d5599a57813f991882b7b4d5ae0550ebd08ea658431e62f6", }, { - name: "IntMsg with body", + name: "IntMsg with body without ihr fee", boc: "te6ccgEBAgEAjAABsUgALXKEDiSWLCdVuhCWy/hYz3hnzF93uwd93pYymUX+v88AGzNMlqFjDeWk/rivKqxwpBoMaThCmw7tE7othW8odIgQBycOAAYdyRAAAEQo20NHEsixYeDAAQBbBRONkQAAAAAAAAAAgBZQOG7qXmeA/2Tw1pLX2IkcQ5h5fxWzzcBskMJbVVRsKA==", filename: "testdata/message-2", wantHash: "b55e0995ab2428b7ccffa4d417ff78caca62dc4d33bc0e33b2d9bcf0c396f08c", }, + { + name: "IntMsg with ihr fee", + boc: "te6ccgEBAgEAkgABtSgAF/xeC0+Z4JVGTZZ1wRhXb7LlO72P+AlL86AgD7OMvz8AKKsn8cUm4Sk3Ql20owK7xh4S3Go43Wl1UJu/tiH0UrBOgN6AYbd0Bgw1CAAAP6tjTcqE0GZh/sABAGQjsFZBaQj/SM/sMMAfore0NaplC/1LWkSitkf0UwRrPbvG7oLtN8TM6hReXwAAaDMw9A==", + filename: "testdata/message-3", + wantHash: "d0ac48e7bd45ab1e2612b9b34dd61d819caa93519fd78343fe2671f4669651e1", + }, + { + name: "IntMsg with extra flags: flag 3", + boc: "te6ccgEBAwEAtAABs2gBYqR801amEcWPEqykRMeNbQq1nQkyHZStEyBBnWaWQKU/1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ6MY8ACBneJb+AABIh5nK9YjRynviwAEBY25DU2wAAAAAAAAAAP///ACAEzaGxPYq5VZDsyPobYQJ9FdB3Ks7FbJX8SODYzN6WKBQAgBAIP1FYVtaLm1bwsfi0pEzUpDxKI/Sjw36lANz1WAnOLg=", + filename: "testdata/message-4", + wantHash: "6282b35168e81b57184e1cd095599be4659b47e7f06c2d1c393c0da1604aea75", + }, + { + name: "IntMsg with extra flags: flag 1", + boc: "te6ccgEBAwEAtAABs2gBYqR801amEcWPEqykRMeNbQq1nQkyHZStEyBBnWaWQKU/1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ6MY8ACAneJb+AABIh5nK9YjRynviwAEBY25DU2wAAAAAAAAAAP///ACAEzaGxPYq5VZDsyPobYQJ9FdB3Ks7FbJX8SODYzN6WKBQAgBAIP1FYVtaLm1bwsfi0pEzUpDxKI/Sjw36lANz1WAnOLg=", + filename: "testdata/message-5", + wantHash: "0388917b66f8685eb1851a302ec3495e46cfa4ca805708c5f221299835069df2", + }, + { + name: "IntMsg with extra flags: flag 2", + boc: "te6ccgEBAwEAtAABs2gBYqR801amEcWPEqykRMeNbQq1nQkyHZStEyBBnWaWQKU/1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ6MY8ACBHeJb+AABIh5nK9YjRynviwAEBY25DU2wAAAAAAAAAAP///ACAEzaGxPYq5VZDsyPobYQJ9FdB3Ks7FbJX8SODYzN6WKBQAgBAIP1FYVtaLm1bwsfi0pEzUpDxKI/Sjw36lANz1WAnOLg=", + filename: "testdata/message-6", + wantHash: "1d9c0b411914c309eafc5b804e4bb786574f07729fbc51c5d77572e9d212fabe", + }, + { + name: "IntMsg with extra flags: flag random", + boc: "te6ccgEBAwEAtQABtWgBYqR801amEcWPEqykRMeNbQq1nQkyHZStEyBBnWaWQKU/1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ6MY8AEYHJ3iW/gAASIeZyvWI0cp74sABAWNuQ1NsAAAAAAAAAAD///wAgBM2hsT2KuVWQ7Mj6G2ECfRXQdyrOxWyV/Ejg2MzeligUAIAQCD9RWFbWi5tW8LH4tKRM1KQ8SiP0o8N+pQDc9VgJzi4", + filename: "testdata/message-7", + wantHash: "3399d38ccd1099d98bc5fab725c29b63815ae4041c9ba756d2d619bae9035b49", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -351,3 +381,46 @@ func TestMessage_Marshal_and_Unmarshal(t *testing.T) { }) } } + +func TestInMsgExtraFlags_BouncedMessageFormat(t *testing.T) { + tests := []struct { + name string + flags int64 + wantFormat BouncedMessageFormat + }{ + { + name: "old", + flags: 0, + wantFormat: OldFormat, + }, + { + name: "root", + flags: 1, + wantFormat: BodyRoot, + }, + { + name: "old", + flags: 2, + wantFormat: OldFormat, + }, + { + name: "full", + flags: 3, + wantFormat: WholeBody, + }, + { + name: "random", + flags: 12145624761, + wantFormat: BodyRoot, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + x := InMsgExtraFlags(*big.NewInt(tt.flags)) + res := x.BouncedMessageFormat() + if res != tt.wantFormat { + t.Fatalf("want format: %v, got: %v", tt.wantFormat, res) + } + }) + } +} diff --git a/tlb/testdata/message-1.json b/tlb/testdata/message-1.json index 4b9045e3..440006ed 100644 --- a/tlb/testdata/message-1.json +++ b/tlb/testdata/message-1.json @@ -1,7 +1,8 @@ { "Info": { "SumType": "ExtInMsgInfo", - "IntMsgInfo": null, + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": null, "ExtInMsgInfo": { "Src": "", "Dest": "0:6ccd325a858c379693fae2bcaab1c2906831a4e10a6c3bb44ee8b615bca1d220", diff --git a/tlb/testdata/message-2.json b/tlb/testdata/message-2.json index eaf58880..c591a9bc 100644 --- a/tlb/testdata/message-2.json +++ b/tlb/testdata/message-2.json @@ -1,8 +1,8 @@ { "Info": { - "SumType": "IntMsgInfo", - "IntMsgInfo": { - "IhrDisabled": true, + "SumType": "IntMsgInfoNoIhr", + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": { "Bounce": false, "Bounced": false, "Src": "0:16b94207124b1613aadd084b65fc2c67bc33e62fbbdd83beef4b194ca2ff5fe7", @@ -11,7 +11,7 @@ "Grams": "30000000", "Other": {} }, - "IhrFee": "0", + "ExtraFlags": "0", "FwdFee": "976008", "CreatedLt": 37471134000009, "CreatedAt": 1683534064 diff --git a/tlb/testdata/message-3.json b/tlb/testdata/message-3.json new file mode 100644 index 00000000..868dc1b7 --- /dev/null +++ b/tlb/testdata/message-3.json @@ -0,0 +1,27 @@ +{ + "Info": { + "SumType": "IntMsgInfoIhr", + "IntMsgInfoIhr": { + "Bounce": true, + "Bounced": false, + "Src": "0:0bfe2f05a7ccf04aa326cb3ae08c2bb7d9729ddec7fc04a5f9d01007d9c65f9f", + "Dest": "0:a2ac9fc7149b84a4dd0976d28c0aef18784b71a8e375a5d5426efed887d14ac1", + "Value": { + "Grams": "10500000", + "Other": {} + }, + "IhrFee": "900000", + "FwdFee": "400004", + "CreatedLt": 35002669000002, + "CreatedAt": 1748185343 + }, + "IntMsgInfoNoIhr": null, + "ExtInMsgInfo": null, + "ExtOutMsgInfo": null + }, + "Init": null, + "Body": { + "IsRight": true, + "Value": "b5ee9c7201010101003400006423b056416908ff48cfec30c01fa2b7b435aa650bfd4b5a44a2b647f453046b3dbbc6ee82ed37c4ccea145e5f0000683330f4" + } + } \ No newline at end of file diff --git a/tlb/testdata/message-4.json b/tlb/testdata/message-4.json new file mode 100644 index 00000000..0c478eaa --- /dev/null +++ b/tlb/testdata/message-4.json @@ -0,0 +1,27 @@ +{ + "Info": { + "SumType": "IntMsgInfoNoIhr", + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": { + "Bounce": true, + "Bounced": false, + "Src": "0:b1523e69ab5308e2c78956522263c6b6855ace84990eca56899020ceb34b2052", + "Dest": "-1:5555555555555555555555555555555555555555555555555555555555555555", + "Value": { + "Grams": "976326400", + "Other": {} + }, + "ExtraFlags": "3", + "FwdFee": "12340095", + "CreatedLt": 39873619000004, + "CreatedAt": 1759854065 + }, + "ExtInMsgInfo": null, + "ExtOutMsgInfo": null + }, + "Init": null, + "Body": { + "IsRight": true, + "Value": "b5ee9c720101020100570001636e43536c0000000000000000fffffc0080133686c4f62ae55643b323e86d8409f45741dcab3b15b257f1238363337a58a05001004020fd45615b5a2e6d5bc2c7e2d291335290f1288fd28f0dfa940373d5602738b8" + } + } \ No newline at end of file diff --git a/tlb/testdata/message-5.json b/tlb/testdata/message-5.json new file mode 100644 index 00000000..8cd0298e --- /dev/null +++ b/tlb/testdata/message-5.json @@ -0,0 +1,27 @@ +{ + "Info": { + "SumType": "IntMsgInfoNoIhr", + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": { + "Bounce": true, + "Bounced": false, + "Src": "0:b1523e69ab5308e2c78956522263c6b6855ace84990eca56899020ceb34b2052", + "Dest": "-1:5555555555555555555555555555555555555555555555555555555555555555", + "Value": { + "Grams": "976326400", + "Other": {} + }, + "ExtraFlags": "1", + "FwdFee": "12340095", + "CreatedLt": 39873619000004, + "CreatedAt": 1759854065 + }, + "ExtInMsgInfo": null, + "ExtOutMsgInfo": null + }, + "Init": null, + "Body": { + "IsRight": true, + "Value": "b5ee9c720101020100570001636e43536c0000000000000000fffffc0080133686c4f62ae55643b323e86d8409f45741dcab3b15b257f1238363337a58a05001004020fd45615b5a2e6d5bc2c7e2d291335290f1288fd28f0dfa940373d5602738b8" + } + } \ No newline at end of file diff --git a/tlb/testdata/message-6.json b/tlb/testdata/message-6.json new file mode 100644 index 00000000..ee2429fb --- /dev/null +++ b/tlb/testdata/message-6.json @@ -0,0 +1,27 @@ +{ + "Info": { + "SumType": "IntMsgInfoNoIhr", + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": { + "Bounce": true, + "Bounced": false, + "Src": "0:b1523e69ab5308e2c78956522263c6b6855ace84990eca56899020ceb34b2052", + "Dest": "-1:5555555555555555555555555555555555555555555555555555555555555555", + "Value": { + "Grams": "976326400", + "Other": {} + }, + "ExtraFlags": "2", + "FwdFee": "12340095", + "CreatedLt": 39873619000004, + "CreatedAt": 1759854065 + }, + "ExtInMsgInfo": null, + "ExtOutMsgInfo": null + }, + "Init": null, + "Body": { + "IsRight": true, + "Value": "b5ee9c720101020100570001636e43536c0000000000000000fffffc0080133686c4f62ae55643b323e86d8409f45741dcab3b15b257f1238363337a58a05001004020fd45615b5a2e6d5bc2c7e2d291335290f1288fd28f0dfa940373d5602738b8" + } + } \ No newline at end of file diff --git a/tlb/testdata/message-7.json b/tlb/testdata/message-7.json new file mode 100644 index 00000000..b7cde9e8 --- /dev/null +++ b/tlb/testdata/message-7.json @@ -0,0 +1,27 @@ +{ + "Info": { + "SumType": "IntMsgInfoNoIhr", + "IntMsgInfoIhr": null, + "IntMsgInfoNoIhr": { + "Bounce": true, + "Bounced": false, + "Src": "0:b1523e69ab5308e2c78956522263c6b6855ace84990eca56899020ceb34b2052", + "Dest": "-1:5555555555555555555555555555555555555555555555555555555555555555", + "Value": { + "Grams": "976326400", + "Other": {} + }, + "ExtraFlags": "12345", + "FwdFee": "12340095", + "CreatedLt": 39873619000004, + "CreatedAt": 1759854065 + }, + "ExtInMsgInfo": null, + "ExtOutMsgInfo": null + }, + "Init": null, + "Body": { + "IsRight": true, + "Value": "b5ee9c720101020100570001636e43536c0000000000000000fffffc0080133686c4f62ae55643b323e86d8409f45741dcab3b15b257f1238363337a58a05001004020fd45615b5a2e6d5bc2c7e2d291335290f1288fd28f0dfa940373d5602738b8" + } + } \ No newline at end of file diff --git a/tontest/helpers.go b/tontest/helpers.go index d27c6593..667478ec 100644 --- a/tontest/helpers.go +++ b/tontest/helpers.go @@ -3,6 +3,7 @@ package tontest import ( "crypto/rand" "fmt" + "math/big" "time" "github.com/tonkeeper/tongo/boc" @@ -258,29 +259,27 @@ func (b messageBuilder) Message() (tlb.Message, error) { ImportFee tlb.VarUInteger16 }{Src: tlb.MsgAddress{SumType: "AddrNone"}, Dest: b.to.ToMsgAddress()} case Internal: - m.Info.SumType = "IntMsgInfo" - m.Info.IntMsgInfo = &struct { - IhrDisabled bool - Bounce bool - Bounced bool - Src tlb.MsgAddress - Dest tlb.MsgAddress - Value tlb.CurrencyCollection - IhrFee tlb.Grams - FwdFee tlb.Grams - CreatedLt uint64 - CreatedAt uint32 + m.Info.SumType = "IntMsgInfoNoIhr" + m.Info.IntMsgInfoNoIhr = &struct { + Bounce bool + Bounced bool + Src tlb.MsgAddress + Dest tlb.MsgAddress + Value tlb.CurrencyCollection + ExtraFlags tlb.InMsgExtraFlags + FwdFee tlb.Grams + CreatedLt uint64 + CreatedAt uint32 }{ - IhrDisabled: true, - Bounce: b.bounce, - Bounced: b.bounced, - Src: b.from.ToMsgAddress(), - Dest: b.to.ToMsgAddress(), - Value: tlb.CurrencyCollection{Grams: b.value}, - IhrFee: 0, - FwdFee: 0, - CreatedLt: 100500, - CreatedAt: uint32(time.Now().Unix())} + Bounce: b.bounce, + Bounced: b.bounced, + Src: b.from.ToMsgAddress(), + Dest: b.to.ToMsgAddress(), + Value: tlb.CurrencyCollection{Grams: b.value}, + ExtraFlags: tlb.InMsgExtraFlags(*big.NewInt(0)), + FwdFee: 0, + CreatedLt: 100500, + CreatedAt: uint32(time.Now().Unix())} } if b.body != nil { m.Body.Value = tlb.Any(*b.body) diff --git a/txemulator/trace.go b/txemulator/trace.go index 797c1879..d04224c7 100644 --- a/txemulator/trace.go +++ b/txemulator/trace.go @@ -374,8 +374,10 @@ type emulatedMessage struct { func toEmulatedMessage(m tlb.Message, parentTx *TxTree) (emulatedMessage, error) { var a tlb.MsgAddress switch m.Info.SumType { - case "IntMsgInfo": - a = m.Info.IntMsgInfo.Dest + case "IntMsgInfoNoIhr": + a = m.Info.IntMsgInfoNoIhr.Dest + case "IntMsgInfoIhr": + a = m.Info.IntMsgInfoIhr.Dest case "ExtInMsgInfo": a = m.Info.ExtInMsgInfo.Dest default: diff --git a/txemulator/trace_test.go b/txemulator/trace_test.go index 4e5828f8..f84e561d 100644 --- a/txemulator/trace_test.go +++ b/txemulator/trace_test.go @@ -70,7 +70,7 @@ func TestSimpleEmulation(t *testing.T) { if len(tree.Children) != 2 { t.Fatal(len(tree.Children)) } - if tree.Children[0].TX.Msgs.InMsg.Value.Value.Info.IntMsgInfo.Value.Grams != ton.OneTON/10 { + if tree.Children[0].TX.Msgs.InMsg.Value.Value.Info.IntMsgInfoNoIhr.Value.Grams != ton.OneTON/10 { t.Fatal("invalid amount") } } diff --git a/wallet/models.go b/wallet/models.go index dc932725..d80d0273 100644 --- a/wallet/models.go +++ b/wallet/models.go @@ -3,9 +3,11 @@ package wallet import ( "context" "fmt" - "github.com/tonkeeper/tongo/utils" + "math/big" "time" + "github.com/tonkeeper/tongo/utils" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tlb" "github.com/tonkeeper/tongo/ton" @@ -200,29 +202,28 @@ type SimpleTransfer struct { func (m SimpleTransfer) ToInternal() (message tlb.Message, mode uint8, err error) { info := tlb.CommonMsgInfo{ - SumType: "IntMsgInfo", - } - - info.IntMsgInfo = &struct { - IhrDisabled bool - Bounce bool - Bounced bool - Src tlb.MsgAddress - Dest tlb.MsgAddress - Value tlb.CurrencyCollection - IhrFee tlb.Grams - FwdFee tlb.Grams - CreatedLt uint64 - CreatedAt uint32 + SumType: "IntMsgInfoNoIhr", + } + + info.IntMsgInfoNoIhr = &struct { + Bounce bool + Bounced bool + Src tlb.MsgAddress + Dest tlb.MsgAddress + Value tlb.CurrencyCollection + ExtraFlags tlb.InMsgExtraFlags + FwdFee tlb.Grams + CreatedLt uint64 + CreatedAt uint32 }{ - IhrDisabled: true, - Bounce: m.Bounceable, - Src: (*ton.AccountID)(nil).ToMsgAddress(), - Dest: m.Address.ToMsgAddress(), + Bounce: m.Bounceable, + Src: (*ton.AccountID)(nil).ToMsgAddress(), + Dest: m.Address.ToMsgAddress(), + ExtraFlags: tlb.InMsgExtraFlags(*big.NewInt(0)), } - info.IntMsgInfo.Value.Grams = m.Amount + info.IntMsgInfoNoIhr.Value.Grams = m.Amount for k, v := range m.ExtraCurrency { - info.IntMsgInfo.Value.Other.Dict.Put(tlb.Uint32(k), v) + info.IntMsgInfoNoIhr.Value.Other.Dict.Put(tlb.Uint32(k), v) } intMsg := tlb.Message{ @@ -242,38 +243,38 @@ func (m SimpleTransfer) ToInternal() (message tlb.Message, mode uint8, err error } type Message struct { - Amount tlb.Grams - Address ton.AccountID - Body *boc.Cell - Code *boc.Cell - Data *boc.Cell - Bounce bool - Mode uint8 + Amount tlb.Grams + Address ton.AccountID + Body *boc.Cell + Code *boc.Cell + Data *boc.Cell + Bounce bool + BouncedMessageFormat tlb.BouncedMessageFormat + Mode uint8 } func (m Message) ToInternal() (message tlb.Message, mode uint8, err error) { info := tlb.CommonMsgInfo{ - SumType: "IntMsgInfo", - } - - info.IntMsgInfo = &struct { - IhrDisabled bool - Bounce bool - Bounced bool - Src tlb.MsgAddress - Dest tlb.MsgAddress - Value tlb.CurrencyCollection - IhrFee tlb.Grams - FwdFee tlb.Grams - CreatedLt uint64 - CreatedAt uint32 + SumType: "IntMsgInfoNoIhr", + } + + info.IntMsgInfoNoIhr = &struct { + Bounce bool + Bounced bool + Src tlb.MsgAddress + Dest tlb.MsgAddress + Value tlb.CurrencyCollection + ExtraFlags tlb.InMsgExtraFlags + FwdFee tlb.Grams + CreatedLt uint64 + CreatedAt uint32 }{ - IhrDisabled: true, - Bounce: m.Bounce, - Src: (*ton.AccountID)(nil).ToMsgAddress(), - Dest: m.Address.ToMsgAddress(), + Bounce: m.Bounce, + ExtraFlags: m.BouncedMessageFormat.ToFlags(), + Src: (*ton.AccountID)(nil).ToMsgAddress(), + Dest: m.Address.ToMsgAddress(), } - info.IntMsgInfo.Value.Grams = m.Amount + info.IntMsgInfoNoIhr.Value.Grams = m.Amount intMsg := tlb.Message{ Info: info,