|
1 | 1 | // Standard library for Tolk (LGPL licence). |
2 | 2 | // It contains common functions that are available out of the box, the user doesn't have to import anything. |
3 | 3 | // More specific functions are required to be imported explicitly, like "@stdlib/tvm-dicts". |
4 | | -tolk 0.10 |
| 4 | +tolk 0.11 |
| 5 | + |
| 6 | +/// In Tolk v1.x there would be a type `map<K,V>`. |
| 7 | +/// Currently, working with dictionaries is still low-level, with raw cells. |
| 8 | +/// But just for clarity, we use "dict" instead of a "cell?" where a cell-dictionary is assumed. |
| 9 | +/// Every dictionary object can be null. TVM NULL is essentially "empty dictionary". |
| 10 | +type dict = cell?; |
5 | 11 |
|
6 | 12 | /** |
7 | 13 | Tuple manipulation primitives. |
@@ -144,9 +150,9 @@ fun getMyOriginalBalance(): int |
144 | 150 |
|
145 | 151 | /// Same as [getMyOriginalBalance], but returns a tuple: |
146 | 152 | /// `int` — balance in nanotoncoins; |
147 | | -/// `cell` — a dictionary with 32-bit keys representing the balance of "extra currencies". |
| 153 | +/// `dict` — a dictionary with 32-bit keys representing the balance of "extra currencies". |
148 | 154 | @pure |
149 | | -fun getMyOriginalBalanceWithExtraCurrencies(): [int, cell?] |
| 155 | +fun getMyOriginalBalanceWithExtraCurrencies(): [int, dict] |
150 | 156 | asm "BALANCE"; |
151 | 157 |
|
152 | 158 | /// Returns the logical time of the current transaction. |
@@ -476,12 +482,12 @@ fun getLastBits(self: slice, len: int): slice |
476 | 482 | /// Loads a dictionary (TL HashMapE structure, represented as TVM cell) from a slice. |
477 | 483 | /// Returns `null` if `nothing` constructor is used. |
478 | 484 | @pure |
479 | | -fun loadDict(mutate self: slice): cell? |
| 485 | +fun loadDict(mutate self: slice): dict |
480 | 486 | asm( -> 1 0) "LDDICT"; |
481 | 487 |
|
482 | 488 | /// Preloads a dictionary (cell) from a slice. |
483 | 489 | @pure |
484 | | -fun preloadDict(self: slice): cell? |
| 490 | +fun preloadDict(self: slice): dict |
485 | 491 | asm "PLDDICT"; |
486 | 492 |
|
487 | 493 | /// Loads a dictionary as [loadDict], but returns only the remainder of the slice. |
@@ -556,7 +562,7 @@ fun storeBool(mutate self: builder, x: bool): self |
556 | 562 | /// Stores dictionary (represented by TVM `cell` or `null`) into a builder. |
557 | 563 | /// In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise. |
558 | 564 | @pure |
559 | | -fun storeDict(mutate self: builder, c: cell?): self |
| 565 | +fun storeDict(mutate self: builder, c: dict): self |
560 | 566 | asm(c self) "STDICT"; |
561 | 567 |
|
562 | 568 | /// Stores (Maybe ^Cell) into a builder. |
@@ -720,7 +726,7 @@ fun reserveToncoinsOnBalance(nanoTonCoins: int, reserveMode: int): void |
720 | 726 |
|
721 | 727 | /// Similar to [reserveToncoinsOnBalance], but also accepts a dictionary extraAmount (represented by a cell or null) |
722 | 728 | /// with extra currencies. In this way currencies other than Toncoin can be reserved. |
723 | | -fun reserveExtraCurrenciesOnBalance(nanoTonCoins: int, extraAmount: cell?, reserveMode: int): void |
| 729 | +fun reserveExtraCurrenciesOnBalance(nanoTonCoins: int, extraAmount: dict, reserveMode: int): void |
724 | 730 | asm "RAWRESERVEX"; |
725 | 731 |
|
726 | 732 |
|
|
0 commit comments