66 "testing"
77
88 "github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton/wallet"
9+ "github.com/smartcontractkit/chainlink-ton/pkg/bindings/mcms/mcms"
10+ "github.com/smartcontractkit/chainlink-ton/pkg/bindings/mcms/timelock"
11+ "github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/common"
912
1013 "github.com/xssnick/tonutils-go/address"
1114 "github.com/xssnick/tonutils-go/tlb"
@@ -27,7 +30,14 @@ type Baz struct {
2730 Val * address.Address `tlb:"addr"`
2831}
2932
30- var TLBs = MustNewTLBMap ([]interface {}{Foo {}, Bar {}, Baz {}, wallet.AskToTransfer {}})
33+ var TLBs = MustNewTLBMap ([]interface {}{
34+ Foo {},
35+ Bar {},
36+ Baz {},
37+ wallet.AskToTransfer {},
38+ mcms.Execute {},
39+ timelock.ScheduleBatch {},
40+ })
3141
3242func mustToCell (v interface {}) * cell.Cell {
3343 c , err := tlb .ToCell (v )
@@ -159,8 +169,81 @@ func TestDecodeJSONMapFromCell(t *testing.T) {
159169 },
160170 expectErr : false ,
161171 },
172+ {
173+ name : "Decode MCMS Execute > Timelock ScheduleBatch > Op[]s with Bar and Baz in payload" ,
174+ cell : mustToCell (mcms.Execute {
175+ QueryID : 31 ,
176+ Op : mcms.Op {
177+ ChainID : big .NewInt (- 14 ),
178+ MultiSig : address .MustParseAddr ("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ),
179+ Nonce : 42 ,
180+ To : address .MustParseAddr ("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ),
181+ Value : tlb .MustFromTON ("1.5" ),
182+ Data : mustToCell (timelock.ScheduleBatch {
183+ QueryID : 31 ,
184+ Calls : common.SnakeData [timelock.Call ]{
185+ timelock.Call {
186+ Target : address .MustParseAddr ("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ),
187+ Value : tlb .MustFromTON ("0.5" ).Nano (),
188+ Data : mustToCell (Bar {
189+ Val : big .NewInt (55555555 ),
190+ }),
191+ },
192+ timelock.Call {
193+ Target : address .MustParseAddr ("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ),
194+ Value : tlb .MustFromTON ("1.0" ).Nano (),
195+ Data : mustToCell (Baz {
196+ Val : address .MustParseAddr ("EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ),
197+ }),
198+ },
199+ },
200+ Predecessor : big .NewInt (- 1 ),
201+ Salt : big .NewInt (1337 ),
202+ Delay : 10000 ,
203+ }),
204+ },
205+ }),
206+ wantType : "Execute" ,
207+ wantMap : map [string ]interface {}{
208+ "QueryID" : float64 (31 ),
209+ "Op" : map [string ]interface {}{
210+ "ChainID" : float64 (- 14 ),
211+ "MultiSig" : "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ,
212+ "Nonce" : float64 (42 ),
213+ "To" : "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ,
214+ "Value" : "1500000000" ,
215+ "Data" : map [string ]interface {}{
216+ "QueryID" : float64 (31 ),
217+ "Calls" : []interface {}{
218+ map [string ]interface {}{
219+ "Target" : "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ,
220+ "Value" : "500000000" ,
221+ "Data" : map [string ]interface {}{
222+ "Val" : float64 (55555555 ),
223+ },
224+ },
225+ map [string ]interface {}{
226+ "Target" : "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ,
227+ "Value" : "1000000000" ,
228+ "Data" : map [string ]interface {}{
229+ "Val" : "EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8" ,
230+ },
231+ },
232+ },
233+ "Predecessor" : float64 (- 1 ),
234+ "Salt" : float64 (1337 ),
235+ "Delay" : float64 (10000 ),
236+ },
237+ },
238+ "Proof" : nil ,
239+ },
240+ },
162241 }
163242
243+ // TODO: *cell.Cell in nested struct is not getting decoded
244+ // gotMap = map[Op:map[ChainID:-14 Data:te6cckECBQEAARQAAagJRxj0AAAAAAAAAB///////////////////////////////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU5AAAAAAAAJxABAoOAAG1ut0NpOlEmrw109ciBxs+p6hikJO38s8HS5XatmBtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7msoBACAwAQAAAAAgNPteMBg4AAbW63Q2k6USavDXT1yIHGz6nqGKQk7fyzwdLldq2YG0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHc1lAEAQASwAAAAOAAG1ut0NpOlEmrw109ciBxs+p6hikJO38s8HS5XatmBtQHjc2Pw== MultiSig:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Nonce:42 To:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Value:1500000000] Proof:<nil> QueryID:31],
245+ // want = map[Op:map[ChainID:-14 Data:map[Calls:[map[Data:map[Val:5.5555555e+07] Target:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Value:500000000] map[Data:map[Val:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8] Target:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Value:1000000000]] Delay:10000 Predecessor:-1 QueryID:31 Salt:1337] MultiSig:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Nonce:42 To:EQADa3W6G0nSiTV4a6euRA42fU9QxSEnb-WeDpcrtWzA2jM8 Value:1500000000] QueryID:31]
246+
164247 for _ , tt := range tests {
165248 t .Run (tt .name , func (t * testing.T ) {
166249 gotType , gotMap , err := DecodeJSONMapFromCell (tt .cell , TLBs )
0 commit comments