Skip to content

Commit 43a31f8

Browse files
committed
Decode wallet.AskToTransfer with known FwdPayload type
1 parent 088f197 commit 43a31f8

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

pkg/ton/debug/lib/lib_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"reflect"
66
"testing"
77

8+
"github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton/wallet"
89
"github.com/xssnick/tonutils-go/address"
910
"github.com/xssnick/tonutils-go/tlb"
1011
"github.com/xssnick/tonutils-go/tvm/cell"
@@ -25,7 +26,7 @@ type Baz struct {
2526
Val *address.Address `tlb:"addr"`
2627
}
2728

28-
var TLBs = MustNewTLBMap([]interface{}{Foo{}, Bar{}, Baz{}})
29+
var TLBs = MustNewTLBMap([]interface{}{Foo{}, Bar{}, Baz{}, wallet.AskToTransfer{}})
2930

3031
func mustToCell(v interface{}) *cell.Cell {
3132
c, err := tlb.ToCell(v)
@@ -131,6 +132,32 @@ func TestDecodeJSONMapFromCell(t *testing.T) {
131132
},
132133
expectErr: false,
133134
},
135+
{
136+
name: "Decode Jetton AskToTransfer with Foo in ForwardPayload",
137+
cell: mustToCell(wallet.AskToTransfer{
138+
QueryID: 0,
139+
Amount: tlb.MustFromTON("0.02"),
140+
Destination: address.MustParseAddr("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8"),
141+
// CustomPayload: cell.BeginCell().EndCell(), // default for *cell.Cell
142+
ForwardPayload: mustToCell(Foo{Any: mustToCell(Baz{Val: address.MustParseAddr("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8")})}),
143+
ForwardTonAmount: tlb.MustFromTON("0.01"),
144+
}),
145+
wantType: "AskToTransfer",
146+
wantMap: map[string]interface{}{
147+
"QueryID": float64(0),
148+
"Amount": "20000000",
149+
"Destination": "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8",
150+
"CustomPayload": "te6cckEBAgEAMwABDzmJaAAAAAAMAQBLAAAAA4AAbW63Q2k6USavDXT1yIHGz6nqGKQk7fyzwdLldq2YG1B7fNdk",
151+
"ForwardPayload": map[string]interface{}{
152+
"Any": map[string]interface{}{
153+
"Val": "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8",
154+
},
155+
},
156+
"ForwardTonAmount": "10000000",
157+
"ResponseDestination": "NONE",
158+
},
159+
expectErr: false,
160+
},
134161
}
135162

136163
for _, tt := range tests {

0 commit comments

Comments
 (0)