Skip to content

Commit 6f745c0

Browse files
authored
Merge pull request #1645 from ton-blockchain/tolk-v0.12
Tolk v0.12: structures, generics, and methods
2 parents cee4c67 + 50b8873 commit 6f745c0

File tree

248 files changed

+8893
-3472
lines changed

Some content is hidden

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

248 files changed

+8893
-3472
lines changed

crypto/smartcont/tolk-stdlib/common.tolk

Lines changed: 175 additions & 152 deletions
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// A part of standard library for Tolk
2-
tolk 0.11
2+
tolk 0.12
33

44
/**
55
Gas and payment related primitives.
66
*/
77

88
/// Returns amount of gas (in gas units) consumed in current Computation Phase.
9-
fun getGasConsumedAtTheMoment(): int
9+
fun getGasConsumedAtTheMoment(): coins
1010
asm "GASCONSUMED";
1111

1212
/// This function is required to be called when you process an external message (from an outer world)
@@ -33,37 +33,37 @@ fun setGasLimit(limit: int): void
3333
asm "SETGASLIMIT";
3434

3535
/// Calculates fee (amount in nanotoncoins to be paid) for a transaction which consumed [gasUsed] gas units.
36-
fun calculateGasFee(workchain: int, gasUsed: int): int
36+
fun calculateGasFee(workchain: int8, gasUsed: int): coins
3737
asm(gasUsed workchain) "GETGASFEE";
3838

3939
/// Same as [calculateGasFee], but without flat price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level)
40-
fun calculateGasFeeWithoutFlatPrice(workchain: int, gasUsed: int): int
40+
fun calculateGasFeeWithoutFlatPrice(workchain: int8, gasUsed: coins): coins
4141
asm(gasUsed workchain) "GETGASFEESIMPLE";
4242

4343
/// Calculates amount of nanotoncoins you should pay for storing a contract of provided size for [seconds].
4444
/// [bits] and [cells] represent contract state (code + data).
45-
fun calculateStorageFee(workchain: int, seconds: int, bits: int, cells: int): int
45+
fun calculateStorageFee(workchain: int8, seconds: int, bits: int, cells: int): coins
4646
asm(cells bits seconds workchain) "GETSTORAGEFEE";
4747

4848
/// Calculates amount of nanotoncoins you should pay to send a message of specified size.
49-
fun calculateMessageFee(workchain: int, bits: int, cells: int): int
49+
fun calculateMessageFee(workchain: int8, bits: int, cells: int): coins
5050
asm(cells bits workchain) "GETFORWARDFEE";
5151

5252
/// Same as [calculateMessageFee], but without lump price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level)
53-
fun calculateMessageFeeWithoutLumpPrice(workchain: int, bits: int, cells: int): int
53+
fun calculateMessageFeeWithoutLumpPrice(workchain: int8, bits: int, cells: int): coins
5454
asm(cells bits workchain) "GETFORWARDFEESIMPLE";
5555

5656
/// Calculates fee that was paid by the sender of an incoming internal message.
57-
fun calculateOriginalMessageFee(workchain: int, incomingFwdFee: int): int
57+
fun calculateOriginalMessageFee(workchain: int8, incomingFwdFee: coins): coins
5858
asm(incomingFwdFee workchain) "GETORIGINALFWDFEE";
5959

6060
/// Returns the amount of nanotoncoins current contract debts for storage. ("due" and "debt" are synonyms)
6161
/// If it has no debt, `0` is returned.
62-
fun getMyStorageDuePayment(): int
62+
fun contract.getStorageDuePayment(): coins
6363
asm "DUEPAYMENT";
6464

6565
/// Returns the amount of nanotoncoins charged for storage.
6666
/// (during storage phase preceeding to current computation phase)
6767
@pure
68-
fun getMyStoragePaidPayment(): int
68+
fun contract.getStoragePaidPayment(): coins
6969
asm "STORAGEFEES";

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// A part of standard library for Tolk
2-
tolk 0.11
2+
tolk 0.12
33

44
/**
5-
Lisp-style lists are nested 2-elements tuples: `(1, (2, (3, null)))` represents list `[1, 2, 3]`.
5+
Lisp-style lists are nested 2-elements tuples: `[1, [2, [3, null]]]` represents list `[1, 2, 3]`.
66
Elements of a list can be of different types.
77
Empty list is conventionally represented as TVM `null` value.
88
*/
@@ -22,12 +22,6 @@ fun listPrepend<X>(head: X, tail: tuple?): tuple
2222
fun listSplit<X>(list: tuple): (X, tuple?)
2323
asm "UNCONS";
2424

25-
/// Extracts the tail and the head of lisp-style list.
26-
/// After extracting the last element, tuple is assigned to null.
27-
@pure
28-
fun listNext<X>(mutate self: tuple?): X
29-
asm( -> 1 0) "UNCONS";
30-
3125
/// Returns the head of lisp-style list.
3226
@pure
3327
fun listGetHead<X>(list: tuple): X

0 commit comments

Comments
 (0)