@@ -250,11 +250,143 @@ primitive AnyStruct;
250
250
// / Pseudo-type that represents any Message.
251
251
primitive AnyMessage ;
252
252
253
- fun AnyStruct_fromCell (cell : Cell ): S {}
254
- fun AnyStruct_fromSlice (slice : Slice ): S {}
253
+ // / Extension function for any Struct type.
254
+ // /
255
+ // / Converts a `Cell` into the specified `Struct` and returns that `Struct`.
256
+ // /
257
+ // / Attempts to pass a `Cell` with a layout different from the specified `Struct` or
258
+ // / to load more data than the `Cell` contains throw an exception with
259
+ // / [exit code 9]: `Cell underflow`.
260
+ // /
261
+ // / ```tact
262
+ // / struct GuessCoin {
263
+ // / probably: Int as coins;
264
+ // / nothing: Int as coins;
265
+ // / }
266
+ // /
267
+ // / fun directParse(payload: Cell): GuessCoin {
268
+ // / return GuessCoin.fromCell(payload);
269
+ // / }
270
+ // /
271
+ // / fun cautiousParse(payload: Cell): GuessCoin? {
272
+ // / let coin: GuessCoin? = null;
273
+ // / try {
274
+ // / coin = GuessCoin.fromCell(payload);
275
+ // / } catch (e) {
276
+ // / dump("Cell payload doesn't match GuessCoin Struct!");
277
+ // / }
278
+ // / return coin;
279
+ // / }
280
+ // / ```
281
+ // /
282
+ // / See: https://docs.tact-lang.org/ref/core-cells/#structfromcell
283
+ // /
284
+ // / [exit code 9]: https://docs.tact-lang.org/book/exit-codes#9
285
+ // /
286
+ fun AnyStruct_fromCell (cell : Cell ): S ;
287
+
288
+ // / Extension function for any Struct type.
289
+ // /
290
+ // / Converts a `Slice` into the specified `Struct` and returns that `Struct`.
291
+ // /
292
+ // / Attempts to pass a `Slice` with a layout different from the specified `Struct` or
293
+ // / to load more data than the `Slice` contains throw an exception with
294
+ // / [exit code 9]: `Cell underflow`.
295
+ // /
296
+ // / ```tact
297
+ // / struct GuessCoin {
298
+ // / probably: Int as coins;
299
+ // / nothing: Int as coins;
300
+ // / }
301
+ // /
302
+ // / fun directParse(payload: Slice): GuessCoin {
303
+ // / return GuessCoin.fromSlice(payload);
304
+ // / }
305
+ // /
306
+ // / fun cautiousParse(payload: Slice): GuessCoin? {
307
+ // / let coin: GuessCoin? = null;
308
+ // / try {
309
+ // / coin = GuessCoin.fromSlice(payload);
310
+ // / } catch (e) {
311
+ // / dump("Slice payload doesn't match GuessCoin Struct!");
312
+ // / }
313
+ // / return coin;
314
+ // / }
315
+ // / ```
316
+ // /
317
+ // / See: https://docs.tact-lang.org/ref/core-cells/#structfromslice
318
+ // /
319
+ // / [exit code 9]: https://docs.tact-lang.org/book/exit-codes#9
320
+ // /
321
+ fun AnyStruct_fromSlice (slice : Slice ): S ;
322
+
323
+ // / Extension function for any Message type.
324
+ // /
325
+ // / Converts a `Cell` into the specified `Message` and returns that `Message`.
326
+ // /
327
+ // / Attempts to pass a `Cell` with a layout different from the specified `Message` or
328
+ // / to load more data than the `Cell` contains throw an exception with
329
+ // / [exit code 9]: `Cell underflow`.
330
+ // /
331
+ // / ```tact
332
+ // / message(0x777) TripleAxe {
333
+ // / prize: Int as uint32;
334
+ // / }
335
+ // /
336
+ // / fun directParse(payload: Cell): TripleAxe {
337
+ // / return TripleAxe.fromCell(payload);
338
+ // / }
339
+ // /
340
+ // / fun cautiousParse(payload: Cell): TripleAxe? {
341
+ // / let coin: TripleAxe? = null;
342
+ // / try {
343
+ // / coin = TripleAxe.fromCell(payload);
344
+ // / } catch (e) {
345
+ // / dump("Cell payload doesn't match TripleAxe Message!");
346
+ // / }
347
+ // / return coin;
348
+ // / }
349
+ // / ```
350
+ // /
351
+ // / See: https://docs.tact-lang.org/ref/core-cells/#messagefromcell
352
+ // /
353
+ // / [exit code 9]: https://docs.tact-lang.org/book/exit-codes#9
354
+ // /
355
+ fun AnyMessage_fromCell (cell : Cell ): M ;
255
356
256
- fun AnyMessage_fromCell (cell : Cell ): M {}
257
- fun AnyMessage_fromSlice (slice : Slice ): M {}
357
+ // / Extension function for any Message type.
358
+ // /
359
+ // / Converts a `Slice` into the specified `Message` and returns that `Message`.
360
+ // /
361
+ // / Attempts to pass a `Slice` with a layout different from the specified `Message` or
362
+ // / to load more data than the `Slice` contains throw an exception with
363
+ // / [exit code 9]: `Cell underflow`.
364
+ // /
365
+ // / ```tact
366
+ // / message(0x777) TripleAxe {
367
+ // / prize: Int as uint32;
368
+ // / }
369
+ // /
370
+ // / fun directParse(payload: Slice): TripleAxe {
371
+ // / return TripleAxe.fromSlice(payload);
372
+ // / }
373
+ // /
374
+ // / fun cautiousParse(payload: Slice): TripleAxe? {
375
+ // / let coin: TripleAxe? = null;
376
+ // / try {
377
+ // / coin = TripleAxe.fromSlice(payload);
378
+ // / } catch (e) {
379
+ // / dump("Slice payload doesn't match TripleAxe Message!");
380
+ // / }
381
+ // / return coin;
382
+ // / }
383
+ // / ```
384
+ // /
385
+ // / See: https://docs.tact-lang.org/ref/core-cells/#messagefromslice
386
+ // /
387
+ // / [exit code 9]: https://docs.tact-lang.org/book/exit-codes#9
388
+ // /
389
+ fun AnyMessage_fromSlice (slice : Slice ): M ;
258
390
259
391
// / Extension function for any Struct.
260
392
// /
0 commit comments