@layerzerolabs/layerzero-v2-ton 3.0.27 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/ActionsSerde.test.compiled.json +1 -0
- package/build/AllStorages.compiled.json +1 -1
- package/build/AllStorages.test.compiled.json +1 -1
- package/build/BaseContract.test.compiled.json +1 -1
- package/build/Channel.compiled.json +1 -1
- package/build/Channel.permissions.test.compiled.json +1 -1
- package/build/ChannelBurn.test.compiled.json +1 -1
- package/build/ChannelCommitPacket.test.compiled.json +1 -1
- package/build/ChannelConfig.test.compiled.json +1 -1
- package/build/ChannelInitialize.test.compiled.json +1 -1
- package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
- package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
- package/build/ChannelNilify.test.compiled.json +1 -1
- package/build/ChannelReceive.test.compiled.json +1 -1
- package/build/ChannelReceiveCallback.test.compiled.json +1 -1
- package/build/ChannelReceiveView.test.compiled.json +1 -1
- package/build/ChannelSend.test.compiled.json +1 -1
- package/build/ChannelSerde.test.compiled.json +1 -0
- package/build/Classlib.test.compiled.json +1 -1
- package/build/ComputeDataSizeGas.test.compiled.json +1 -1
- package/build/Connection.compiled.json +1 -1
- package/build/Controller.assertions.test.compiled.json +1 -1
- package/build/Controller.compiled.json +1 -1
- package/build/Controller.permissions.test.compiled.json +1 -1
- package/build/Controller.test.compiled.json +1 -1
- package/build/Counter.compiled.json +1 -1
- package/build/Counter.permissions.test.compiled.json +1 -1
- package/build/Counter.setters.test.compiled.json +1 -1
- package/build/Counter.test.compiled.json +1 -1
- package/build/Dvn.compiled.json +1 -1
- package/build/Dvn.test.compiled.json +1 -1
- package/build/DvnFeeLib.compiled.json +1 -1
- package/build/DvnFeeLibSerde.test.compiled.json +1 -0
- package/build/DvnPermissions.test.compiled.json +1 -1
- package/build/DvnSerde.test.compiled.json +1 -0
- package/build/Endpoint.compiled.json +1 -1
- package/build/Endpoint.permissions.test.compiled.json +1 -1
- package/build/Endpoint.test.compiled.json +1 -1
- package/build/EndpointSerde.test.compiled.json +1 -0
- package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
- package/build/Executor.compiled.json +1 -1
- package/build/Executor.test.compiled.json +1 -1
- package/build/ExecutorFeeLib.compiled.json +1 -1
- package/build/ExecutorFeeLibSerde.test.compiled.json +1 -0
- package/build/ExecutorPermissions.test.compiled.json +1 -1
- package/build/ExecutorSerde.test.compiled.json +1 -0
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzClassesSerde.test.compiled.json +1 -0
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsgDataSerde.test.compiled.json +1 -0
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -0
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
- package/build/PriceFeedCacheSerde.test.compiled.json +1 -0
- package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -0
- package/build/Proxy.compiled.json +1 -1
- package/build/Proxy.permissions.test.compiled.json +1 -1
- package/build/Proxy.test.compiled.json +1 -1
- package/build/SmlConnection.compiled.json +1 -1
- package/build/SmlConnection.permissions.test.compiled.json +1 -1
- package/build/SmlConnection.test.compiled.json +1 -1
- package/build/SmlManager.compiled.json +1 -1
- package/build/SmlManager.permissions.test.compiled.json +1 -1
- package/build/SmlManager.test.compiled.json +1 -1
- package/build/Uln.compiled.json +1 -1
- package/build/Uln.test.compiled.json +1 -1
- package/build/UlnConnection.compiled.json +1 -1
- package/build/UlnConnection.test.compiled.json +1 -1
- package/build/UlnConnectionPermissions.test.compiled.json +1 -1
- package/build/UlnConnectionSerde.test.compiled.json +1 -0
- package/build/UlnManagement.test.compiled.json +1 -1
- package/build/UlnManager.compiled.json +1 -1
- package/build/UlnManager.test.compiled.json +1 -1
- package/build/UlnManagerPermissions.test.compiled.json +1 -1
- package/build/UlnManagerUtil.test.compiled.json +1 -1
- package/build/UlnMsgDataSerde.test.compiled.json +1 -0
- package/build/UlnPermissions.test.compiled.json +1 -1
- package/build/UlnReceiveConfig.test.compiled.json +1 -1
- package/build/UlnSend.test.compiled.json +1 -1
- package/build/UlnSendConfig.test.compiled.json +1 -1
- package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
- package/build/UlnSerde.test.compiled.json +1 -0
- package/build/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -0
- package/build/WorkerCoreSerde.test.compiled.json +1 -0
- package/build/badFeeLib1.test.compiled.json +1 -1
- package/build/badFeeLib10.test.compiled.json +1 -1
- package/build/badFeeLib11.test.compiled.json +1 -1
- package/build/badFeeLib12.test.compiled.json +1 -1
- package/build/badFeeLib2.test.compiled.json +1 -1
- package/build/badFeeLib3.test.compiled.json +1 -1
- package/build/badFeeLib4.test.compiled.json +1 -1
- package/build/badFeeLib5.test.compiled.json +1 -1
- package/build/badFeeLib6.test.compiled.json +1 -1
- package/build/badFeeLib7.test.compiled.json +1 -1
- package/build/badFeeLib8.test.compiled.json +1 -1
- package/build/badFeeLib9.test.compiled.json +1 -1
- package/package.json +2 -1
- package/src/classes/lz/EpConfig.fc +90 -23
- package/src/classes/lz/MsglibInfo.fc +32 -5
- package/src/classes/lz/Packet.fc +109 -48
- package/src/classes/lz/Path.fc +55 -4
- package/src/classes/lz/ReceiveEpConfig.fc +36 -5
- package/src/classes/lz/SendEpConfig.fc +55 -5
- package/src/classes/msgdata/AddMsglib.fc +11 -0
- package/src/classes/msgdata/ChannelNonceInfo.fc +20 -0
- package/src/classes/msgdata/CoinsAmount.fc +8 -0
- package/src/classes/msgdata/Deploy.fc +19 -0
- package/src/classes/msgdata/ExtendedMd.fc +52 -1
- package/src/classes/msgdata/LzReceivePrepare.fc +21 -1
- package/src/classes/msgdata/LzReceiveStatus.fc +72 -1
- package/src/classes/msgdata/LzSend.fc +143 -24
- package/src/classes/msgdata/MdAddress.fc +42 -0
- package/src/classes/msgdata/MdEid.fc +8 -0
- package/src/classes/msgdata/MdObj.fc +32 -0
- package/src/classes/msgdata/MessagingReceipt.fc +34 -1
- package/src/classes/msgdata/MsglibSendCallback.fc +82 -0
- package/src/classes/msgdata/Nonce.fc +30 -0
- package/src/classes/msgdata/OptionsV1.fc +21 -1
- package/src/classes/msgdata/OptionsV2.fc +27 -0
- package/src/classes/msgdata/PacketId.fc +24 -0
- package/src/classes/msgdata/PacketSent.fc +35 -1
- package/src/classes/msgdata/SetAddress.fc +7 -0
- package/src/classes/msgdata/SetEpConfig.fc +17 -0
- package/src/funC++/actions/event.fc +17 -2
- package/src/funC++/actions/utils.fc +2 -2
- package/src/funC++/classlib.fc +33 -43
- package/src/funC++/constants.fc +28 -28
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +75 -59
- package/src/funC++/stdlib.fc +26 -11
- package/src/funC++/testutils.fc +2 -2
- package/src/funC++/txnContext.fc +14 -14
- package/src/funC++/utils.fc +97 -1
- package/src/protocol/channel/handler.fc +247 -189
- package/src/protocol/channel/storage.fc +206 -1
- package/src/protocol/controller/handler.fc +35 -17
- package/src/protocol/controller/main.fc +1 -1
- package/src/protocol/core/abstract/protocolHandler.fc +11 -21
- package/src/protocol/core/baseStorage.fc +24 -0
- package/src/protocol/endpoint/handler.fc +99 -57
- package/src/protocol/endpoint/storage.fc +69 -5
- package/src/protocol/msglibs/BytesEncoder.fc +11 -10
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +1 -4
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +7 -8
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +114 -28
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +84 -107
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +77 -1
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +92 -66
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +113 -6
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +6 -91
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +55 -31
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +13 -9
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +63 -27
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +19 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +55 -6
- package/src/workers/core/abstract/workerHandler.fc +20 -19
- package/src/workers/core/interface.fc +2 -1
- package/src/workers/core/workerCoreStorage.fc +16 -1
- package/src/workers/dvn/handler.fc +67 -26
- package/src/workers/dvn/storage.fc +15 -2
- package/src/workers/executor/handler.fc +18 -6
- package/src/workers/executor/interface.fc +1 -0
- package/src/workers/executor/storage.fc +8 -1
- package/src/workers/msgdata/DropEvent.fc +18 -0
- package/src/workers/msgdata/ExecuteParams.fc +66 -3
- package/src/workers/msgdata/NativeDrop.fc +4 -0
- package/src/workers/msgdata/SetDict.fc +6 -4
- package/src/workers/msgdata/SetQuorum.fc +4 -2
- package/src/workers/msgdata/SignedRequest.fc +8 -0
- package/src/workers/priceFeedCache/handler.fc +21 -27
- package/src/workers/priceFeedCache/storage.fc +16 -1
- package/src/workers/proxy/handler.fc +2 -1
- package/src/workers/proxy/storage.fc +1 -1
- package/tests/baseContractTest.fc +2 -6
- package/tests/baseSerdeTest.fc +117 -0
- package/tests/testMain.fc +2 -2
- package/src/classes/msgdata/Amount.fc +0 -16
- package/src/funC++/actions/destroy.fc +0 -27
|
@@ -16,8 +16,8 @@ tuple emptyActions() inline {
|
|
|
16
16
|
.store_slice(hashpartToBasechainAddressStd(toAddress))
|
|
17
17
|
.store_coins(0);
|
|
18
18
|
b = stateInit.is_null()
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
? b.store_uint(1, 107)
|
|
20
|
+
: b.store_uint(7, 108).store_ref(stateInit);
|
|
21
21
|
send_raw_message(b.store_ref(messageBody).end_cell(), CARRY_ALL_BALANCE | extraFlags);
|
|
22
22
|
}
|
|
23
23
|
|
package/src/funC++/classlib.fc
CHANGED
|
@@ -36,10 +36,10 @@ const int _DATA_OFFSET_WIDTH = 10; ;; 1023 bits per cell = 2**10 - 1
|
|
|
36
36
|
const int _REF_OFFSET_WIDTH = 2; ;; each cell can have up to 4 refs
|
|
37
37
|
const int _FIELD_INFO_WIDTH = _FIELD_TYPE_WIDTH + _CELL_ID_WIDTH + _DATA_OFFSET_WIDTH + _REF_OFFSET_WIDTH;
|
|
38
38
|
const int _MAX_CLASS_FIELDS = 15; ;; reserve 0xff for the "invalid" object field name
|
|
39
|
-
const int INVALID_CLASS_MEMBER =
|
|
39
|
+
const int INVALID_CLASS_MEMBER = 15;
|
|
40
40
|
const int _HEADER_WIDTH = _BASIC_HEADER_WIDTH + _MAX_CLASS_FIELDS * _FIELD_INFO_WIDTH;
|
|
41
41
|
|
|
42
|
-
;; declarations require a tuple of the form [[
|
|
42
|
+
;; declarations require a tuple of the form [[ type, val ], ...]
|
|
43
43
|
const int FIELD_TYPE_IDX = 0;
|
|
44
44
|
const int FIELD_VAL_IDX = 1;
|
|
45
45
|
|
|
@@ -127,7 +127,7 @@ int cl::typeof(cell $obj) inline method_id {
|
|
|
127
127
|
return $obj.begin_parse().preload_uint(_NAME_WIDTH);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
cell cl::declare(int name, tuple fields) inline {
|
|
130
|
+
cell cl::declare(int name, tuple fields) impure inline {
|
|
131
131
|
;; Initialize a tuple with [null, empty_builder] to store cell builders
|
|
132
132
|
tuple classBuilder = unsafeTuple([null(), begin_cell()]);
|
|
133
133
|
|
|
@@ -139,7 +139,7 @@ cell cl::declare(int name, tuple fields) inline {
|
|
|
139
139
|
;; Initialize tracking variables
|
|
140
140
|
int curDataCell = 1; ;; Current cell for storing data fields
|
|
141
141
|
int curRefCell = 1; ;; Current cell for storing reference fields
|
|
142
|
-
;; root node is special as it only allows two
|
|
142
|
+
;; root node is special as it only allows two ref fields
|
|
143
143
|
int curCellMaxRefs = 2; ;; Max references allowed in current cell
|
|
144
144
|
int curDataOffset = _HEADER_WIDTH; ;; Current bit offset in data cell
|
|
145
145
|
int curRefOffset = 0; ;; Current reference offset in ref cell
|
|
@@ -309,9 +309,10 @@ forall X -> cell cl::set(cell $self, int fieldName, X val) inline method_id {
|
|
|
309
309
|
int fieldCellIndex = headerSlice.cl::getFieldCellIndex::asm(fieldInfoOffset);
|
|
310
310
|
int fieldType = headerSlice.cl::getFieldType::asm(fieldInfoOffset);
|
|
311
311
|
int fieldOffset = headerSlice.cl::getFieldOffset::asm(fieldInfoOffset);
|
|
312
|
-
int fieldRefsOffset = headerSlice.cl::getFieldCellOffset::asm(fieldInfoOffset
|
|
312
|
+
int fieldRefsOffset = headerSlice.cl::getFieldCellOffset::asm(fieldInfoOffset);
|
|
313
313
|
|
|
314
314
|
int fieldWidth = _getTypeWidth(fieldType);
|
|
315
|
+
|
|
315
316
|
slice victim = fieldCellIndex == 0
|
|
316
317
|
? headerSlice
|
|
317
318
|
: headerSlice.preload_ref_at(fieldCellIndex).begin_parse();
|
|
@@ -331,7 +332,8 @@ forall X -> cell cl::set(cell $self, int fieldName, X val) inline method_id {
|
|
|
331
332
|
replacement = replacement
|
|
332
333
|
.store_ref(val.cast_to_cell())
|
|
333
334
|
.store_slice(victim.scutlast(0, victim.slice_refs() - fieldRefsOffset - 1));
|
|
334
|
-
} else {
|
|
335
|
+
} else {
|
|
336
|
+
;; numeric type
|
|
335
337
|
replacement = replacement
|
|
336
338
|
.store_uint(abs(val.cast_to_int()), fieldWidth)
|
|
337
339
|
.store_slice(victim.sskipfirst(fieldOffset + fieldWidth, victim.slice_refs()));
|
|
@@ -357,17 +359,6 @@ const int _FIELD_TYPE_WIDTH = 4; ;; support up to 16 types
|
|
|
357
359
|
const int _CELL_ID_WIDTH = 2; ;; the classlib backend supports up to 4 inner cells including root
|
|
358
360
|
const int _DATA_OFFSET_WIDTH = 10; ;; 1023 bits per cell = 2**10 - 1
|
|
359
361
|
|
|
360
|
-
;; int cl::get<uint>::asm_t( int width, int fieldName, tuple self) asm """
|
|
361
|
-
;; // DUMPSTK // STACK [s, fieldName, width]
|
|
362
|
-
;; 0 INDEX // cell cell_at(tuple t, int index) => STACK [cellResult, fieldName, width]
|
|
363
|
-
;; CTOS // slice begin_parse(cell c) => STACK [sliceResult, fieldName, width]
|
|
364
|
-
;; s1 XCHG0 // STACK [fieldName, sliceResult, width]
|
|
365
|
-
;; 18 MULCONST // STACK [_FIELD_INFO_WIDTH*fieldName, sliceResult, width]
|
|
366
|
-
;; 84 ADDCONST // STACK [_BASIC_HEADER_WIDTH + _FIELD_TYPE_WIDTH + (_FIELD_INFO_WIDTH*fieldName) = fieldInfoOffset, mulRes, sliceResult, width]
|
|
367
|
-
;; s1 s1 s1 XCHG3 // STACK [width, fieldInfoOffset, sliceResult]
|
|
368
|
-
;; SDSUBSTR // STACK [preloadBitsOffsetResult]
|
|
369
|
-
;; 10 PLDU // STACK [fieldCellIndex]
|
|
370
|
-
;; """;
|
|
371
362
|
|
|
372
363
|
int cl::get<uint>(cell $self, int fieldName, int width) inline method_id {
|
|
373
364
|
slice headerSlice = $self.begin_parse();
|
|
@@ -386,19 +377,18 @@ int cl::get<uint>(cell $self, int fieldName, int width) inline method_id {
|
|
|
386
377
|
cell cl::get<cellRef>(cell $self, int fieldName) inline method_id {
|
|
387
378
|
slice headerSlice = $self.begin_parse();
|
|
388
379
|
int fieldInfoOffset = _BASIC_HEADER_WIDTH + (fieldName * _FIELD_INFO_WIDTH);
|
|
389
|
-
int fieldCellIndex = headerSlice.cl::getFieldCellIndex::asm(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
);
|
|
380
|
+
int fieldCellIndex = headerSlice.cl::getFieldCellIndex::asm(fieldInfoOffset);
|
|
381
|
+
int fieldRefIdx = headerSlice.cl::getFieldCellOffset::asm(fieldInfoOffset);
|
|
382
|
+
|
|
383
|
+
if (fieldCellIndex == 0) {
|
|
384
|
+
return headerSlice.preload_ref_at(fieldRefIdx);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return headerSlice
|
|
388
|
+
.preload_ref_at(fieldCellIndex)
|
|
389
|
+
.begin_parse()
|
|
390
|
+
.preload_ref_at(fieldRefIdx)
|
|
391
|
+
;
|
|
402
392
|
}
|
|
403
393
|
|
|
404
394
|
cell cl::get<objRef>(cell $self, int fieldName) inline method_id {
|
|
@@ -645,7 +635,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
645
635
|
;; if the val exists, it is returned
|
|
646
636
|
;; if a val does not exist, null() is returned
|
|
647
637
|
|
|
648
|
-
(int, slice) cl::dict256::getMin<slice>(cell dict256) {
|
|
638
|
+
(int, slice) cl::dict256::getMin<slice>(cell dict256) impure inline {
|
|
649
639
|
if (dict256.cell_is_empty()) {
|
|
650
640
|
return (-1, null());
|
|
651
641
|
}
|
|
@@ -656,7 +646,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
656
646
|
return (-1, null());
|
|
657
647
|
}
|
|
658
648
|
|
|
659
|
-
(int, int) cl::dict256::getMin<uint256>(cell dict256) {
|
|
649
|
+
(int, int) cl::dict256::getMin<uint256>(cell dict256) impure inline {
|
|
660
650
|
if (dict256.cell_is_empty()) {
|
|
661
651
|
return (-1, null());
|
|
662
652
|
}
|
|
@@ -667,7 +657,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
667
657
|
return (-1, null());
|
|
668
658
|
}
|
|
669
659
|
|
|
670
|
-
(int, cell) cl::dict256::getMin<cellRef>(cell dict256) {
|
|
660
|
+
(int, cell) cl::dict256::getMin<cellRef>(cell dict256) impure inline {
|
|
671
661
|
if (dict256.cell_is_empty()) {
|
|
672
662
|
return (-1, null());
|
|
673
663
|
}
|
|
@@ -678,7 +668,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
678
668
|
return (-1, null());
|
|
679
669
|
}
|
|
680
670
|
|
|
681
|
-
(int, slice) cl::dict256::getNext<slice>(cell dict256, int pivot) {
|
|
671
|
+
(int, slice) cl::dict256::getNext<slice>(cell dict256, int pivot) impure inline {
|
|
682
672
|
if (dict256.cell_is_empty()) {
|
|
683
673
|
return (-1, null());
|
|
684
674
|
}
|
|
@@ -689,7 +679,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
689
679
|
return (-1, null());
|
|
690
680
|
}
|
|
691
681
|
|
|
692
|
-
(int, int) cl::dict256::getNext<uint256>(cell dict256, int pivot) {
|
|
682
|
+
(int, int) cl::dict256::getNext<uint256>(cell dict256, int pivot) impure inline {
|
|
693
683
|
if (dict256.cell_is_empty()) {
|
|
694
684
|
return (-1, null());
|
|
695
685
|
}
|
|
@@ -700,7 +690,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
700
690
|
return (-1, null());
|
|
701
691
|
}
|
|
702
692
|
|
|
703
|
-
(int, cell) cl::dict256::getNext<cellRef>(cell dict256, int pivot) {
|
|
693
|
+
(int, cell) cl::dict256::getNext<cellRef>(cell dict256, int pivot) impure inline {
|
|
704
694
|
if (dict256.cell_is_empty()) {
|
|
705
695
|
return (-1, null());
|
|
706
696
|
}
|
|
@@ -711,7 +701,7 @@ cell cl::dict256::delete(cell dict, int key) {
|
|
|
711
701
|
return (-1, null());
|
|
712
702
|
}
|
|
713
703
|
|
|
714
|
-
int cl::dict256::size(cell dict) inline method_id {
|
|
704
|
+
int cl::dict256::size(cell dict) impure inline method_id {
|
|
715
705
|
int count = 0;
|
|
716
706
|
(int pivot, _) = dict.cl::dict256::getMin<slice>();
|
|
717
707
|
while (pivot >= 0) {
|
|
@@ -723,7 +713,7 @@ int cl::dict256::size(cell dict) inline method_id {
|
|
|
723
713
|
|
|
724
714
|
;;; ====================== Nested Dict Helpers ======================
|
|
725
715
|
|
|
726
|
-
forall X -> cell cl::nestedDict256::set(cell $self, int fieldName, int key, X val) inline {
|
|
716
|
+
forall X -> cell cl::nestedDict256::set(cell $self, int fieldName, int key, X val) impure inline {
|
|
727
717
|
return $self.cl::set(
|
|
728
718
|
fieldName,
|
|
729
719
|
$self
|
|
@@ -732,29 +722,29 @@ forall X -> cell cl::nestedDict256::set(cell $self, int fieldName, int key, X va
|
|
|
732
722
|
);
|
|
733
723
|
}
|
|
734
724
|
|
|
735
|
-
cell cl::nestedDict256::setRef(cell $self, int fieldName, int key, cell val) inline {
|
|
725
|
+
cell cl::nestedDict256::setRef(cell $self, int fieldName, int key, cell val) impure inline {
|
|
736
726
|
return $self.cl::set(
|
|
737
727
|
fieldName,
|
|
738
728
|
$self.cl::get<dict256>(fieldName).cl::dict256::setRef(key, val)
|
|
739
729
|
);
|
|
740
730
|
}
|
|
741
731
|
|
|
742
|
-
cell cl::nestedDict256::delete(cell $self, int fieldName, int key) inline {
|
|
732
|
+
cell cl::nestedDict256::delete(cell $self, int fieldName, int key) impure inline {
|
|
743
733
|
return $self.cl::set(
|
|
744
734
|
fieldName,
|
|
745
735
|
$self.cl::get<dict256>(fieldName).cl::dict256::delete(key)
|
|
746
736
|
);
|
|
747
737
|
}
|
|
748
738
|
|
|
749
|
-
(int, int) cl::nestedDict256::get<uint256>(cell $self, int fieldName, int key) inline {
|
|
739
|
+
(int, int) cl::nestedDict256::get<uint256>(cell $self, int fieldName, int key) impure inline {
|
|
750
740
|
return $self.cl::get<dict256>(fieldName).cl::dict256::get<uint256>(key);
|
|
751
741
|
}
|
|
752
742
|
|
|
753
|
-
(slice, int) cl::nestedDict256::get<slice>(cell $self, int fieldName, int key) inline {
|
|
743
|
+
(slice, int) cl::nestedDict256::get<slice>(cell $self, int fieldName, int key) impure inline {
|
|
754
744
|
return $self.cl::get<dict256>(fieldName).cl::dict256::get(key);
|
|
755
745
|
}
|
|
756
746
|
|
|
757
|
-
(cell, int) cl::nestedDict256::get<cellRef>(cell $self, int fieldName, int key) inline {
|
|
747
|
+
(cell, int) cl::nestedDict256::get<cellRef>(cell $self, int fieldName, int key) impure inline {
|
|
758
748
|
(slice s, int exists) = $self.cl::get<dict256>(fieldName).cl::dict256::get(key);
|
|
759
749
|
if (exists) {
|
|
760
750
|
return (s.preload_first_ref(), true);
|
package/src/funC++/constants.fc
CHANGED
|
@@ -10,10 +10,10 @@ const int MAX_U128 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
|
|
|
10
10
|
const int MAX_U256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
|
|
11
11
|
const int MAX_COINS = 1329227995784915872903807060280344575; ;; 2^120 - 1
|
|
12
12
|
|
|
13
|
-
const ADDR_TYPE_NONE = 0;
|
|
14
|
-
const ADDR_TYPE_EXTERN = 1;
|
|
15
|
-
const ADDR_TYPE_STD = 2;
|
|
16
|
-
const ADDR_TYPE_VAR = 3;
|
|
13
|
+
const int ADDR_TYPE_NONE = 0;
|
|
14
|
+
const int ADDR_TYPE_EXTERN = 1;
|
|
15
|
+
const int ADDR_TYPE_STD = 2;
|
|
16
|
+
const int ADDR_TYPE_VAR = 3;
|
|
17
17
|
|
|
18
18
|
const int TRUE = -1;
|
|
19
19
|
const int FALSE = 0;
|
|
@@ -26,39 +26,39 @@ const int SEND_MSG_BOUNCEABLE = 0x18;
|
|
|
26
26
|
const int SEND_MSG_NON_BOUNCEABLE = 0x10;
|
|
27
27
|
|
|
28
28
|
;; MODIFIER
|
|
29
|
-
const NORMAL = 0;
|
|
30
|
-
const PAID_EXTERNALLY = 1;
|
|
31
|
-
const IGNORE_ERRORS = 2;
|
|
29
|
+
const int NORMAL = 0;
|
|
30
|
+
const int PAID_EXTERNALLY = 1;
|
|
31
|
+
const int IGNORE_ERRORS = 2;
|
|
32
32
|
|
|
33
33
|
;; SEND MODES
|
|
34
|
-
const BOUNCE_IF_FAIL = 16;
|
|
35
|
-
const DESTROY_IF_ZERO = 32;
|
|
36
|
-
const CARRY_REMAINING_GAS = 64;
|
|
37
|
-
const CARRY_ALL_BALANCE = 128;
|
|
34
|
+
const int BOUNCE_IF_FAIL = 16;
|
|
35
|
+
const int DESTROY_IF_ZERO = 32;
|
|
36
|
+
const int CARRY_REMAINING_GAS = 64;
|
|
37
|
+
const int CARRY_ALL_BALANCE = 128;
|
|
38
38
|
|
|
39
39
|
;; SENDMSG modes
|
|
40
|
-
const SUB_BALANCE_MSG = 64;
|
|
41
|
-
const SUB_BALANCE_CONTRACT = 128;
|
|
42
|
-
const ONLY_ESTIMATE_FEES = 1024;
|
|
40
|
+
const int SUB_BALANCE_MSG = 64;
|
|
41
|
+
const int SUB_BALANCE_CONTRACT = 128;
|
|
42
|
+
const int ONLY_ESTIMATE_FEES = 1024;
|
|
43
43
|
|
|
44
44
|
;; SEND MODES QUIETED
|
|
45
|
-
const QDESTROY_IF_ZERO = 34;
|
|
46
|
-
const QCARRY_REMAINING_GAS = 66;
|
|
47
|
-
const QCARRY_ALL_BALANCE = 130;
|
|
45
|
+
const int QDESTROY_IF_ZERO = 34;
|
|
46
|
+
const int QCARRY_REMAINING_GAS = 66;
|
|
47
|
+
const int QCARRY_ALL_BALANCE = 130;
|
|
48
48
|
|
|
49
|
-
const RESERVE_EXACTLY = 0;
|
|
50
|
-
const RESERVE_ALL_EXCEPT = 1;
|
|
51
|
-
const RESERVE_AT_MOST = 2;
|
|
52
|
-
const EXTRN_DO_NOT_FAIL = 2;
|
|
53
|
-
const BALANCE_INCREASED = 4;
|
|
54
|
-
const BALANCE_DECREASED = 8;
|
|
49
|
+
const int RESERVE_EXACTLY = 0;
|
|
50
|
+
const int RESERVE_ALL_EXCEPT = 1;
|
|
51
|
+
const int RESERVE_AT_MOST = 2;
|
|
52
|
+
const int EXTRN_DO_NOT_FAIL = 2;
|
|
53
|
+
const int BALANCE_INCREASED = 4;
|
|
54
|
+
const int BALANCE_DECREASED = 8;
|
|
55
55
|
const int RESERVE_BOUNCE_ON_ACTION_FAIL = 16;
|
|
56
56
|
|
|
57
57
|
;; a lot of different constants, because arithmetic manipulation of constants is not optimized
|
|
58
|
-
const MAX_CELL_BITS = 1023;
|
|
59
|
-
const MAX_CELL_BYTES = 127;
|
|
60
|
-
const MAX_CELL_WHOLE_BYTE_BITS = MAX_CELL_BYTES * 8;
|
|
61
|
-
const MAX_CELL_BIT_INDEX = 1022;
|
|
62
|
-
const MAX_CELL_REFS = 4;
|
|
58
|
+
const int MAX_CELL_BITS = 1023;
|
|
59
|
+
const int MAX_CELL_BYTES = 127;
|
|
60
|
+
const int MAX_CELL_WHOLE_BYTE_BITS = MAX_CELL_BYTES * 8;
|
|
61
|
+
const int MAX_CELL_BIT_INDEX = 1022;
|
|
62
|
+
const int MAX_CELL_REFS = 4;
|
|
63
63
|
|
|
64
64
|
const int NULLADDRESS = 0;
|
|
@@ -11,6 +11,62 @@ const int POOO::bitmap = 1;
|
|
|
11
11
|
|
|
12
12
|
const int POOO::ERROR::negativeIndex = 1153;
|
|
13
13
|
|
|
14
|
+
cell POOO::New() impure inline method_id {
|
|
15
|
+
return cl::declare(
|
|
16
|
+
POOO::NAME,
|
|
17
|
+
unsafeTuple([
|
|
18
|
+
[cl::t::uint64, 1], ;; nextEmpty
|
|
19
|
+
[cl::t::cellRef, begin_cell().store_zeroes(MAX_CELL_BITS).end_cell()] ;; bitmap
|
|
20
|
+
])
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const int POOO::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 2);
|
|
25
|
+
const int POOO::_headerFillerBits = _HEADER_WIDTH - POOO::_headerInfoBits;
|
|
26
|
+
const int POOO::_headerInfo = 92590899976783941628;
|
|
27
|
+
|
|
28
|
+
cell POOO::buildFull(int nextEmpty, cell bitmap) impure inline {
|
|
29
|
+
return begin_cell()
|
|
30
|
+
.store_uint(POOO::_headerInfo, POOO::_headerInfoBits) ;; header info
|
|
31
|
+
.store_ones(POOO::_headerFillerBits) ;; header filler
|
|
32
|
+
.store_uint64(nextEmpty) ;; nextEmpty
|
|
33
|
+
.store_ref(bitmap) ;; bitmap
|
|
34
|
+
.end_cell();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
;; ========================== Object Getters ==========================
|
|
38
|
+
|
|
39
|
+
const int POOO::_nextEmptyOffset = _HEADER_WIDTH;
|
|
40
|
+
|
|
41
|
+
int POOO::getNextEmpty(cell $self) impure inline {
|
|
42
|
+
return $self.cellPreloadUint64At(POOO::_nextEmptyOffset);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
int POOO::maxSettableBit(cell $self) impure inline {
|
|
46
|
+
return $self.POOO::getNextEmpty() + MAX_CELL_BIT_INDEX;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
;; ========================== Object Multi-Getters ==========================
|
|
50
|
+
|
|
51
|
+
;; returns (nextEmpty, bitmap.slice)
|
|
52
|
+
(int, slice) POOO::deserialize(cell $self) impure inline {
|
|
53
|
+
slice selfSlice = $self.begin_parse();
|
|
54
|
+
return (
|
|
55
|
+
selfSlice.preloadUint64At(POOO::_nextEmptyOffset),
|
|
56
|
+
selfSlice.preloadRefSliceAt(0)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
;; ========================== Object Utils ==========================
|
|
61
|
+
|
|
62
|
+
int POOO::isBitSet(cell $self, int absoluteIdx) impure inline {
|
|
63
|
+
(int nextEmpty, slice bitmap) = POOO::deserialize($self);
|
|
64
|
+
int relativeIdx = absoluteIdx - nextEmpty;
|
|
65
|
+
return bitmap.preloadBoolAt(relativeIdx);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
;; ========================== Object Setters ==========================
|
|
69
|
+
|
|
14
70
|
;; Algorithm:
|
|
15
71
|
;; 1. Extract the first `index` bits from the original bitmap.
|
|
16
72
|
;; 2. Append a '1' bit to the extracted bits.
|
|
@@ -28,11 +84,11 @@ const int POOO::ERROR::negativeIndex = 1153;
|
|
|
28
84
|
cell POOO::set(cell $self, int absoluteIndex) impure inline method_id {
|
|
29
85
|
throw_if(POOO::ERROR::negativeIndex, absoluteIndex < 0);
|
|
30
86
|
|
|
31
|
-
slice bitmapSlice =
|
|
32
|
-
int nextEmpty = $self.cl::get<uint64>(POOO::nextEmpty);
|
|
87
|
+
(int nextEmpty, slice bitmapSlice) = POOO::deserialize($self);
|
|
33
88
|
if (absoluteIndex < nextEmpty) {
|
|
34
89
|
return $self;
|
|
35
90
|
}
|
|
91
|
+
|
|
36
92
|
int index = absoluteIndex - nextEmpty;
|
|
37
93
|
|
|
38
94
|
(int leadingOnes, slice remainingBitmap) = ldones(
|
|
@@ -42,20 +98,19 @@ cell POOO::set(cell $self, int absoluteIndex) impure inline method_id {
|
|
|
42
98
|
.store_slice(scutlast(bitmapSlice, MAX_CELL_BITS - index - 1, 0))
|
|
43
99
|
.as_slice()
|
|
44
100
|
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.cl::set(POOO::nextEmpty, nextEmpty + leadingOnes);
|
|
101
|
+
|
|
102
|
+
return POOO::buildFull(
|
|
103
|
+
nextEmpty + leadingOnes,
|
|
104
|
+
begin_cell()
|
|
105
|
+
.store_slice(remainingBitmap)
|
|
106
|
+
.store_zeroes(leadingOnes)
|
|
107
|
+
.end_cell()
|
|
108
|
+
);
|
|
54
109
|
}
|
|
55
110
|
|
|
56
111
|
cell POOO::unsafeSetBits(cell $self, int start, int end) impure inline method_id {
|
|
57
|
-
slice bitmapSlice =
|
|
58
|
-
|
|
112
|
+
(int nextEmpty, slice bitmapSlice) = POOO::deserialize($self);
|
|
113
|
+
|
|
59
114
|
int startIndex = start - nextEmpty;
|
|
60
115
|
int endIndex = end - nextEmpty;
|
|
61
116
|
|
|
@@ -66,51 +121,12 @@ cell POOO::unsafeSetBits(cell $self, int start, int end) impure inline method_id
|
|
|
66
121
|
.store_slice(scutlast(bitmapSlice, MAX_CELL_BITS - endIndex, 0))
|
|
67
122
|
.as_slice()
|
|
68
123
|
);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
.cl::set(POOO::nextEmpty, nextEmpty + leadingOnes);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
cell POOO::New() inline method_id {
|
|
81
|
-
return cl::declare(
|
|
82
|
-
POOO::NAME,
|
|
83
|
-
unsafeTuple([
|
|
84
|
-
[cl::t::uint64, 1], ;; nextEmpty
|
|
85
|
-
[cl::t::cellRef, begin_cell().store_zeroes(MAX_CELL_BITS).end_cell()] ;; bitmap
|
|
86
|
-
])
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
cell POOO::NewWithBitsSets(int startingBit, int endingBit) method_id {
|
|
91
|
-
return cl::declare(
|
|
92
|
-
POOO::NAME,
|
|
93
|
-
unsafeTuple([
|
|
94
|
-
[cl::t::uint64, 1],
|
|
95
|
-
[cl::t::cellRef, begin_cell()
|
|
96
|
-
.store_zeroes(1)
|
|
97
|
-
.store_ones(endingBit - startingBit)
|
|
98
|
-
.store_zeroes(MAX_CELL_BITS - endingBit)
|
|
99
|
-
.end_cell()
|
|
100
|
-
]
|
|
101
|
-
])
|
|
124
|
+
|
|
125
|
+
return POOO::buildFull(
|
|
126
|
+
nextEmpty + leadingOnes,
|
|
127
|
+
begin_cell()
|
|
128
|
+
.store_slice(remainingBitmap)
|
|
129
|
+
.store_zeroes(leadingOnes)
|
|
130
|
+
.end_cell()
|
|
102
131
|
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
int POOO::isBitSet(cell $self, int absoluteIdx) inline method_id {
|
|
106
|
-
int relativeIdx = absoluteIdx - $self.cl::get<uint64>(POOO::nextEmpty);
|
|
107
|
-
return $self
|
|
108
|
-
.cl::get<cellRef>(POOO::bitmap)
|
|
109
|
-
.begin_parse()
|
|
110
|
-
.preload_bits_offset(relativeIdx, 1)
|
|
111
|
-
.preload_uint(1) == 1;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
int POOO::maxSettableBit(cell $self) inline method_id {
|
|
115
|
-
return $self.cl::get<uint64>(POOO::nextEmpty) + MAX_CELL_BIT_INDEX;
|
|
116
132
|
}
|
package/src/funC++/stdlib.fc
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
;; Standard library for funC
|
|
2
2
|
;;
|
|
3
3
|
|
|
4
|
+
{-
|
|
5
|
+
This file is part of TON FunC Standard Library.
|
|
6
|
+
|
|
7
|
+
FunC Standard Library is free software: you can redistribute it and/or modify
|
|
8
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
10
|
+
(at your option) any later version.
|
|
11
|
+
|
|
12
|
+
FunC Standard Library is distributed in the hope that it will be useful,
|
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
GNU Lesser General Public License for more details.
|
|
16
|
+
|
|
17
|
+
-}
|
|
18
|
+
|
|
4
19
|
{-
|
|
5
20
|
# Tuple manipulation primitives
|
|
6
21
|
The names and the types are mostly self-explaining.
|
|
@@ -108,7 +123,7 @@ forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP";
|
|
|
108
123
|
int now() asm "NOW";
|
|
109
124
|
|
|
110
125
|
;;; Returns the internal address of the current smart contract as a Slice with a `MsgAddressInt`.
|
|
111
|
-
;;; If necessary, it can be parsed further using primitives such as [
|
|
126
|
+
;;; If necessary, it can be parsed further using primitives such as [parse_std_addr].
|
|
112
127
|
slice my_address() asm "MYADDR";
|
|
113
128
|
|
|
114
129
|
;;; Returns the balance of the smart contract as a tuple consisting of an int
|
|
@@ -229,7 +244,7 @@ cont bless(slice s) impure asm "BLESS";
|
|
|
229
244
|
;;; In other words, the current smart contract agrees to buy some gas to finish the current transaction.
|
|
230
245
|
;;; This action is required to process external messages, which bring no value (hence no gas) with themselves.
|
|
231
246
|
;;;
|
|
232
|
-
;;; For more details check [accept_message effects](https://ton.org/
|
|
247
|
+
;;; For more details check [accept_message effects](https://docs.ton.org/develop/smart-contracts/guidelines/accept).
|
|
233
248
|
() accept_message() impure asm "ACCEPT";
|
|
234
249
|
|
|
235
250
|
;;; Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero.
|
|
@@ -267,10 +282,10 @@ int abs(int x) asm "ABS";
|
|
|
267
282
|
|
|
268
283
|
It is said that a primitive _loads_ some data,
|
|
269
284
|
if it returns the data and the remainder of the slice
|
|
270
|
-
(so it can also be used as [modifying method](https://ton.org/
|
|
285
|
+
(so it can also be used as [modifying method](https://docs.ton.org/develop/func/statements#modifying-methods)).
|
|
271
286
|
|
|
272
287
|
It is said that a primitive _preloads_ some data, if it returns only the data
|
|
273
|
-
(it can be used as [non-modifying method](https://ton.org/
|
|
288
|
+
(it can be used as [non-modifying method](https://docs.ton.org/develop/func/statements#non-modifying-methods)).
|
|
274
289
|
|
|
275
290
|
Unless otherwise stated, loading and preloading primitives read the data from a prefix of the slice.
|
|
276
291
|
-}
|
|
@@ -290,13 +305,13 @@ slice begin_parse(cell c) asm "CTOS";
|
|
|
290
305
|
;;; Preloads the first reference from the slice.
|
|
291
306
|
cell preload_ref(slice s) asm "PLDREF";
|
|
292
307
|
|
|
293
|
-
|
|
308
|
+
{- Functions below are commented because are implemented on compilator level for optimisation -}
|
|
294
309
|
|
|
295
310
|
;;; Loads a signed [len]-bit integer from a slice [s].
|
|
296
311
|
;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX";
|
|
297
312
|
|
|
298
313
|
;;; Loads an unsigned [len]-bit integer from a slice [s].
|
|
299
|
-
(slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX";
|
|
314
|
+
;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX";
|
|
300
315
|
|
|
301
316
|
;;; Preloads a signed [len]-bit integer from a slice [s].
|
|
302
317
|
;; int preload_int(slice s, int len) asm "PLDIX";
|
|
@@ -310,7 +325,7 @@ cell preload_ref(slice s) asm "PLDREF";
|
|
|
310
325
|
;;; Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`.
|
|
311
326
|
;; slice preload_bits(slice s, int len) asm "PLDSLICEX";
|
|
312
327
|
|
|
313
|
-
;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^
|
|
328
|
+
;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^120 - 1`).
|
|
314
329
|
(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS";
|
|
315
330
|
(slice, int) load_coins(slice s) asm( -> 1 0) "LDGRAMS";
|
|
316
331
|
|
|
@@ -337,6 +352,7 @@ cell preload_dict(slice s) asm "PLDDICT";
|
|
|
337
352
|
|
|
338
353
|
;;; Loads a dictionary as [load_dict], but returns only the remainder of the slice.
|
|
339
354
|
slice skip_dict(slice s) asm "SKIPDICT";
|
|
355
|
+
(slice, ()) ~skip_dict(slice s) asm "SKIPDICT";
|
|
340
356
|
|
|
341
357
|
;;; Loads (Maybe ^Cell) from `slice` [s].
|
|
342
358
|
;;; In other words loads 1 bit and if it is true
|
|
@@ -401,7 +417,7 @@ int builder_depth(builder b) asm "BDEPTH";
|
|
|
401
417
|
# Builder primitives
|
|
402
418
|
It is said that a primitive _stores_ a value `x` into a builder `b`
|
|
403
419
|
if it returns a modified version of the builder `b'` with the value `x` stored at the end of it.
|
|
404
|
-
It can be used as [non-modifying method](https://ton.org/
|
|
420
|
+
It can be used as [non-modifying method](https://docs.ton.org/develop/func/statements#non-modifying-methods).
|
|
405
421
|
|
|
406
422
|
All the primitives below first check whether there is enough space in the `builder`,
|
|
407
423
|
and only then check the range of the value being serialized.
|
|
@@ -426,7 +442,7 @@ builder store_ref(builder b, cell c) asm(c b) "STREF";
|
|
|
426
442
|
;;; Stores `slice` [s] into `builder` [b]
|
|
427
443
|
builder store_slice(builder b, slice s) asm "STSLICER";
|
|
428
444
|
|
|
429
|
-
;;; Stores (serializes) an integer [x] in the range `0..2^
|
|
445
|
+
;;; Stores (serializes) an integer [x] in the range `0..2^120 − 1` into `builder` [b].
|
|
430
446
|
;;; The serialization of [x] consists of a 4-bit unsigned big-endian integer `l`,
|
|
431
447
|
;;; which is the smallest integer `l ≥ 0`, such that `x < 2^8l`,
|
|
432
448
|
;;; followed by an `8l`-bit unsigned big-endian representation of [x].
|
|
@@ -611,7 +627,7 @@ int rand(int range) impure asm "RAND";
|
|
|
611
627
|
;;; Returns the current random seed as an unsigned 256-bit Integer.
|
|
612
628
|
int get_seed() impure asm "RANDSEED";
|
|
613
629
|
;;; Sets the random seed to unsigned 256-bit seed.
|
|
614
|
-
() set_seed(int
|
|
630
|
+
() set_seed(int) impure asm "SETRAND";
|
|
615
631
|
;;; Mixes unsigned 256-bit integer x into the random seed r by setting the random seed to sha256 of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r, and the second with the big-endian representation of x.
|
|
616
632
|
() randomize(int x) impure asm "ADDRAND";
|
|
617
633
|
;;; Equivalent to randomize(cur_lt());.
|
|
@@ -619,7 +635,6 @@ int get_seed() impure asm "RANDSEED";
|
|
|
619
635
|
|
|
620
636
|
;;; Checks whether the data parts of two slices coinside
|
|
621
637
|
int equal_slice_bits(slice a, slice b) asm "SDEQ";
|
|
622
|
-
int equal_slices(slice a, slice b) asm "SDEQ";
|
|
623
638
|
|
|
624
639
|
;;; Concatenates two builders
|
|
625
640
|
builder store_builder(builder to, builder from) asm "STBR";
|
package/src/funC++/testutils.fc
CHANGED
|
@@ -61,11 +61,11 @@ cell _garbigify(cell $input, cell garbage) impure {
|
|
|
61
61
|
;; Should never happen as the above checks and returns from all cases
|
|
62
62
|
;; The compiler needs you to return from all possible control flows
|
|
63
63
|
;; and it isn't smart enough to know that this will never be reached.
|
|
64
|
-
|
|
64
|
+
throw("garbigify: this print should never happen"c);
|
|
65
65
|
return empty_cell();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
() profile_gas(var func, tuple args) {
|
|
68
|
+
() profile_gas(var func, tuple args) impure {
|
|
69
69
|
int gas_consumed = get_gas_consumed();
|
|
70
70
|
int gas_consumed_consumed = get_gas_consumed();
|
|
71
71
|
int gas_consumed_of_gas_consumed = gas_consumed_consumed - gas_consumed;
|
package/src/funC++/txnContext.fc
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
global tuple txnContext;
|
|
4
4
|
|
|
5
|
-
const _IS_BOUNCED = 0;
|
|
6
|
-
const _CALLER = 1;
|
|
7
|
-
const _FWD_FEE = 2;
|
|
8
|
-
const _OPCODE = 3;
|
|
9
|
-
const _QUERY_ID = 4;
|
|
10
|
-
const _BALANCE = 5;
|
|
11
|
-
const _MSG_VALUE = 6;
|
|
12
|
-
const _BODY = 7;
|
|
13
|
-
const _RAW_MSG = 8;
|
|
14
|
-
const _ORIGIN = 9;
|
|
15
|
-
const _DONATION_NANOS = 10;
|
|
16
|
-
const _MD = 11;
|
|
17
|
-
const _VALUE_OUTFLOW = 12;
|
|
5
|
+
const int _IS_BOUNCED = 0;
|
|
6
|
+
const int _CALLER = 1;
|
|
7
|
+
const int _FWD_FEE = 2;
|
|
8
|
+
const int _OPCODE = 3;
|
|
9
|
+
const int _QUERY_ID = 4;
|
|
10
|
+
const int _BALANCE = 5;
|
|
11
|
+
const int _MSG_VALUE = 6;
|
|
12
|
+
const int _BODY = 7;
|
|
13
|
+
const int _RAW_MSG = 8;
|
|
14
|
+
const int _ORIGIN = 9;
|
|
15
|
+
const int _DONATION_NANOS = 10;
|
|
16
|
+
const int _MD = 11;
|
|
17
|
+
const int _VALUE_OUTFLOW = 12;
|
|
18
18
|
|
|
19
19
|
int getMsgValue() inline {
|
|
20
20
|
return txnContext.int_at(_MSG_VALUE);
|
|
@@ -84,7 +84,7 @@ cell getMsgData() inline {
|
|
|
84
84
|
slice _sender_address = cs~load_msg_addr();
|
|
85
85
|
cs~load_msg_addr();
|
|
86
86
|
cs~load_coins();
|
|
87
|
-
cs~
|
|
87
|
+
cs~skip_dict();
|
|
88
88
|
cs~load_coins();
|
|
89
89
|
int senderAddress = basechainAddressStdToHashpart(_sender_address);
|
|
90
90
|
|