Skip to content

Commit ed46820

Browse files
authored
Merge pull request #1610 from ton-blockchain/tolk-v0.11
Tolk v0.11: type aliases, union types, and pattern matching
2 parents 303e92b + cadb66e commit ed46820

File tree

111 files changed

+4808
-945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4808
-945
lines changed

crypto/smartcont/tolk-stdlib/common.tolk

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// Standard library for Tolk (LGPL licence).
22
// It contains common functions that are available out of the box, the user doesn't have to import anything.
33
// 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?;
511

612
/**
713
Tuple manipulation primitives.
@@ -144,9 +150,9 @@ fun getMyOriginalBalance(): int
144150

145151
/// Same as [getMyOriginalBalance], but returns a tuple:
146152
/// `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".
148154
@pure
149-
fun getMyOriginalBalanceWithExtraCurrencies(): [int, cell?]
155+
fun getMyOriginalBalanceWithExtraCurrencies(): [int, dict]
150156
asm "BALANCE";
151157

152158
/// Returns the logical time of the current transaction.
@@ -476,12 +482,12 @@ fun getLastBits(self: slice, len: int): slice
476482
/// Loads a dictionary (TL HashMapE structure, represented as TVM cell) from a slice.
477483
/// Returns `null` if `nothing` constructor is used.
478484
@pure
479-
fun loadDict(mutate self: slice): cell?
485+
fun loadDict(mutate self: slice): dict
480486
asm( -> 1 0) "LDDICT";
481487

482488
/// Preloads a dictionary (cell) from a slice.
483489
@pure
484-
fun preloadDict(self: slice): cell?
490+
fun preloadDict(self: slice): dict
485491
asm "PLDDICT";
486492

487493
/// 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
556562
/// Stores dictionary (represented by TVM `cell` or `null`) into a builder.
557563
/// In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise.
558564
@pure
559-
fun storeDict(mutate self: builder, c: cell?): self
565+
fun storeDict(mutate self: builder, c: dict): self
560566
asm(c self) "STDICT";
561567

562568
/// Stores (Maybe ^Cell) into a builder.
@@ -720,7 +726,7 @@ fun reserveToncoinsOnBalance(nanoTonCoins: int, reserveMode: int): void
720726

721727
/// Similar to [reserveToncoinsOnBalance], but also accepts a dictionary extraAmount (represented by a cell or null)
722728
/// 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
724730
asm "RAWRESERVEX";
725731

726732

crypto/smartcont/tolk-stdlib/gas-payments.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 0.10
2+
tolk 0.11
33

44
/**
55
Gas and payment related primitives.

crypto/smartcont/tolk-stdlib/lisp-lists.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 0.10
2+
tolk 0.11
33

44
/**
55
Lisp-style lists are nested 2-elements tuples: `(1, (2, (3, null)))` represents list `[1, 2, 3]`.

0 commit comments

Comments
 (0)