|
1 | 1 | // A part of standard library for Tolk |
2 | | -tolk 0.99 |
| 2 | +tolk 1.0 |
3 | 3 |
|
4 | 4 | /** |
5 | 5 | Gas and payment related primitives. |
6 | 6 | */ |
7 | 7 |
|
8 | 8 | /// Returns amount of gas (in gas units) consumed in current Computation Phase. |
9 | 9 | fun getGasConsumedAtTheMoment(): int |
10 | | - asm "GASCONSUMED"; |
| 10 | + asm "GASCONSUMED" |
11 | 11 |
|
12 | 12 | /// This function is required to be called when you process an external message (from an outer world) |
13 | 13 | /// and "accept" it to blockchain. |
14 | 14 | /// Without calling this function, an external message would be discarded. |
15 | 15 | /// As an effect, the current smart contract agrees to buy some gas to finish the current transaction. |
16 | 16 | /// For more details, check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept). |
17 | 17 | fun acceptExternalMessage(): void |
18 | | - asm "ACCEPT"; |
| 18 | + asm "ACCEPT" |
19 | 19 |
|
20 | 20 | /// When processing an internal message, by default, the limit of gas consumption is determined by incoming message. |
21 | 21 | /// Functions [setGasLimit] and [setGasLimitToMaximum] allow you to change this behavior. |
22 | 22 | /// Sets current gas limit `gl` to its maximal allowed value `gm`, and resets the gas credit `gc` to zero, |
23 | 23 | /// decreasing the value of `gr` by `gc` in the process. |
24 | 24 | fun setGasLimitToMaximum(): void |
25 | | - asm "ACCEPT"; |
| 25 | + asm "ACCEPT" |
26 | 26 |
|
27 | 27 | /// When processing an internal message, by default, the limit of gas consumption is determined by incoming message. |
28 | 28 | /// Functions [setGasLimit] and [setGasLimitToMaximum] allow you to change this behavior. |
29 | 29 | /// Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero. |
30 | 30 | /// If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`, |
31 | 31 | /// an (unhandled) out of gas exception is thrown before setting new gas limits. |
32 | 32 | fun setGasLimit(limit: int): void |
33 | | - asm "SETGASLIMIT"; |
| 33 | + asm "SETGASLIMIT" |
34 | 34 |
|
35 | 35 | /// Calculates fee (amount in nanotoncoins to be paid) for a transaction which consumed [gasUsed] gas units. |
36 | 36 | fun calculateGasFee(workchain: int8, gasUsed: int): coins |
37 | | - asm(gasUsed workchain) "GETGASFEE"; |
| 37 | + asm(gasUsed workchain) "GETGASFEE" |
38 | 38 |
|
39 | 39 | /// Same as [calculateGasFee], but without flat price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level) |
40 | 40 | fun calculateGasFeeWithoutFlatPrice(workchain: int8, gasUsed: coins): coins |
41 | | - asm(gasUsed workchain) "GETGASFEESIMPLE"; |
| 41 | + asm(gasUsed workchain) "GETGASFEESIMPLE" |
42 | 42 |
|
43 | 43 | /// Calculates amount of nanotoncoins you should pay for storing a contract of provided size for [seconds]. |
44 | 44 | /// [bits] and [cells] represent contract state (code + data). |
45 | 45 | fun calculateStorageFee(workchain: int8, seconds: int, bits: int, cells: int): coins |
46 | | - asm(cells bits seconds workchain) "GETSTORAGEFEE"; |
| 46 | + asm(cells bits seconds workchain) "GETSTORAGEFEE" |
47 | 47 |
|
48 | | -/// Calculates amount of nanotoncoins you should pay to send a message of specified size. |
49 | | -fun calculateMessageFee(workchain: int8, bits: int, cells: int): coins |
50 | | - asm(cells bits workchain) "GETFORWARDFEE"; |
| 48 | +/// Calculates amount of nanotoncoins you should pay to send a message of a specified size. |
| 49 | +fun calculateForwardFee(workchain: int8, bits: int, cells: int): coins |
| 50 | + asm(cells bits workchain) "GETFORWARDFEE" |
51 | 51 |
|
52 | | -/// 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: int8, bits: int, cells: int): coins |
54 | | - asm(cells bits workchain) "GETFORWARDFEESIMPLE"; |
| 52 | +/// Same as [calculateForwardFee], but without lump price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level) |
| 53 | +fun calculateForwardFeeWithoutLumpPrice(workchain: int8, bits: int, cells: int): coins |
| 54 | + asm(cells bits workchain) "GETFORWARDFEESIMPLE" |
55 | 55 |
|
56 | 56 | /// Calculates fee that was paid by the sender of an incoming internal message. |
57 | | -fun calculateOriginalMessageFee(workchain: int8, incomingFwdFee: coins): coins |
58 | | - asm(incomingFwdFee workchain) "GETORIGINALFWDFEE"; |
| 57 | +@deprecated("use modern `onInternalMessage` and access `in.originalForwardFee` directly") |
| 58 | +fun calculateOriginalForwardFee(workchain: int8, incomingFwdFee: coins): coins |
| 59 | + asm(incomingFwdFee workchain) "GETORIGINALFWDFEE" |
59 | 60 |
|
60 | 61 | /// Returns the amount of nanotoncoins current contract debts for storage. ("due" and "debt" are synonyms) |
61 | 62 | /// If it has no debt, `0` is returned. |
62 | 63 | fun contract.getStorageDuePayment(): coins |
63 | | - asm "DUEPAYMENT"; |
| 64 | + asm "DUEPAYMENT" |
64 | 65 |
|
65 | 66 | /// Returns the amount of nanotoncoins charged for storage. |
66 | 67 | /// (during storage phase preceeding to current computation phase) |
67 | 68 | @pure |
68 | 69 | fun contract.getStoragePaidPayment(): coins |
69 | | - asm "STORAGEFEES"; |
| 70 | + asm "STORAGEFEES" |
0 commit comments