Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 175 additions & 152 deletions crypto/smartcont/tolk-stdlib/common.tolk

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions crypto/smartcont/tolk-stdlib/gas-payments.tolk
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// A part of standard library for Tolk
tolk 0.11
tolk 0.12

/**
Gas and payment related primitives.
*/

/// Returns amount of gas (in gas units) consumed in current Computation Phase.
fun getGasConsumedAtTheMoment(): int
fun getGasConsumedAtTheMoment(): coins
asm "GASCONSUMED";

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

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

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

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

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

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

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

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

/// Returns the amount of nanotoncoins charged for storage.
/// (during storage phase preceeding to current computation phase)
@pure
fun getMyStoragePaidPayment(): int
fun contract.getStoragePaidPayment(): coins
asm "STORAGEFEES";
10 changes: 2 additions & 8 deletions crypto/smartcont/tolk-stdlib/lisp-lists.tolk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// A part of standard library for Tolk
tolk 0.11
tolk 0.12

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

/// Extracts the tail and the head of lisp-style list.
/// After extracting the last element, tuple is assigned to null.
@pure
fun listNext<X>(mutate self: tuple?): X
asm( -> 1 0) "UNCONS";

/// Returns the head of lisp-style list.
@pure
fun listGetHead<X>(list: tuple): X
Expand Down
Loading
Loading