@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
package/src/classes/lz/Packet.fc
CHANGED
|
@@ -31,66 +31,58 @@ cell lz::Packet::New(cell $path, cell message, int nonce) inline method_id {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const int lz::Packet::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 4);
|
|
35
|
+
const int lz::Packet::_headerFillerBits = _HEADER_WIDTH - lz::Packet::_headerInfoBits;
|
|
36
|
+
const int lz::Packet::_headerInfo = 417359019239977417716476838698419835;
|
|
37
|
+
|
|
38
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
39
|
+
cell lz::Packet::build(cell $path, cell message, int nonce) inline method_id {
|
|
40
|
+
return begin_cell()
|
|
41
|
+
.store_uint(lz::Packet::_headerInfo, lz::Packet::_headerInfoBits) ;; header info
|
|
42
|
+
.store_ones(lz::Packet::_headerFillerBits) ;; header filler
|
|
43
|
+
.store_ref($path) ;; path
|
|
44
|
+
.store_ref(message) ;; message
|
|
45
|
+
.store_uint64(nonce) ;; nonce
|
|
46
|
+
.store_uint256(0) ;; guid (default = 0)
|
|
47
|
+
.end_cell();
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
;;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
(int sliceBits, int sliceRefs) = messageSlice.slice_bits_refs();
|
|
42
|
-
int messageBytes = sliceBits / 8;
|
|
43
|
-
while (sliceRefs > 0) {
|
|
44
|
-
messageSlice = messageSlice.preload_first_ref().begin_parse();
|
|
45
|
-
(sliceBits, sliceRefs) = messageSlice.slice_bits_refs();
|
|
46
|
-
messageBytes += (sliceBits / 8);
|
|
47
|
-
}
|
|
48
|
-
return messageBytes;
|
|
50
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
51
|
+
cell lz::Packet::nonceless(cell $path, cell message) inline method_id {
|
|
52
|
+
return lz::Packet::build($path, message, 0);
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} else {
|
|
59
|
-
throw_if(
|
|
60
|
-
lz::Packet::ERROR::INVALID_MESSAGE,
|
|
61
|
-
(sliceRefs != 1) | (sliceBits != MAX_CELL_WHOLE_BYTE_BITS)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
messageSlice = messageSlice.preload_first_ref().begin_parse();
|
|
65
|
-
}
|
|
66
|
-
throw(lz::Packet::ERROR::INVALID_MESSAGE);
|
|
55
|
+
;; ====================== Object Accessors =====================
|
|
56
|
+
|
|
57
|
+
const int lz::Packet::_nonceOffset = _HEADER_WIDTH;
|
|
58
|
+
const int lz::Packet::_guidOffset = lz::Packet::_nonceOffset + 64;
|
|
59
|
+
|
|
60
|
+
cell lz::Packet::getPath(cell $self) impure inline {
|
|
61
|
+
return $self.cellPreloadRefAt(0);
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
lz::Packet::MAX_SEND_MESSAGE_CELLS
|
|
73
|
-
);
|
|
64
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
65
|
+
cell lz::Packet::getMessage(cell $self) impure inline {
|
|
66
|
+
return $self.cellPreloadRefAt(1);
|
|
74
67
|
}
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
lz::Packet::
|
|
78
|
-
$self.cl::get<cellRef>(lz::Packet::message),
|
|
79
|
-
lz::Packet::MAX_RECEIVE_MESSAGE_CELLS
|
|
80
|
-
);
|
|
69
|
+
int lz::Packet::getNonce(cell $self) impure inline {
|
|
70
|
+
return $self.cellPreloadUint64At(lz::Packet::_nonceOffset);
|
|
81
71
|
}
|
|
82
72
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
73
|
+
;; returns (path, message, nonce, guid)
|
|
74
|
+
(cell, cell, int, int) lz::Packet::deserialize(cell $self) impure inline {
|
|
75
|
+
slice $selfSlice = $self.begin_parse();
|
|
76
|
+
return (
|
|
77
|
+
$selfSlice.preloadRefAt(0),
|
|
78
|
+
$selfSlice.preloadRefAt(1),
|
|
79
|
+
$selfSlice.preloadUint64At(lz::Packet::_nonceOffset),
|
|
80
|
+
$selfSlice.preloadUint256At(lz::Packet::_guidOffset)
|
|
91
81
|
);
|
|
92
82
|
}
|
|
93
83
|
|
|
84
|
+
;; ====================== Object Composite Modifiers =====================
|
|
85
|
+
|
|
94
86
|
;; NOTE: this assumes that the placement of the first field is before the second field
|
|
95
87
|
cell lz::Packet::replaceTwoFieldsAtOffsets(
|
|
96
88
|
cell encodedPacket,
|
|
@@ -212,4 +204,73 @@ cell lz::Packet::replaceTwoFieldsAtOffsets(
|
|
|
212
204
|
}
|
|
213
205
|
|
|
214
206
|
return curCell;
|
|
215
|
-
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
cell lz::Packet::setNonceAndGuid(cell $self, int nonce, int guid) impure inline {
|
|
210
|
+
return begin_cell()
|
|
211
|
+
.store_slice($self.begin_parse().scutfirst(lz::Packet::_nonceOffset, 2)) ;; keep the header and the first two refs
|
|
212
|
+
.store_uint64(nonce)
|
|
213
|
+
.store_uint256(guid)
|
|
214
|
+
.end_cell();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
;; ====================== Object Utilities =====================
|
|
218
|
+
|
|
219
|
+
int lz::Packet::calculateGuid(cell $path, int nonce) inline method_id {
|
|
220
|
+
(int srcEid, int srcOApp, int dstEid, int dstOApp) = $path.lz::Path::deserialize();
|
|
221
|
+
return keccak256Builder(
|
|
222
|
+
begin_cell()
|
|
223
|
+
.store_uint64(nonce)
|
|
224
|
+
.store_uint32(srcEid)
|
|
225
|
+
.store_uint256(srcOApp)
|
|
226
|
+
.store_uint32(dstEid)
|
|
227
|
+
.store_uint256(dstOApp)
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
;; ====================== Object Validators =====================
|
|
232
|
+
|
|
233
|
+
;; assumes that the message is a valid single-linked list
|
|
234
|
+
int lz::Packet::_messageBytes(cell $self) impure inline {
|
|
235
|
+
slice messageSlice = $self.lz::Packet::getMessage().begin_parse();
|
|
236
|
+
(int sliceBits, int sliceRefs) = messageSlice.slice_bits_refs();
|
|
237
|
+
int messageBytes = sliceBits / 8;
|
|
238
|
+
while (sliceRefs > 0) {
|
|
239
|
+
messageSlice = messageSlice.preload_first_ref().begin_parse();
|
|
240
|
+
(sliceBits, sliceRefs) = messageSlice.slice_bits_refs();
|
|
241
|
+
messageBytes += (sliceBits / 8);
|
|
242
|
+
}
|
|
243
|
+
return messageBytes;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
() lz::Packet::_assertValidLinkedList(cell head, int maxLen) impure inline {
|
|
247
|
+
slice messageSlice = head.begin_parse();
|
|
248
|
+
repeat (maxLen) {
|
|
249
|
+
(int sliceBits, int sliceRefs) = messageSlice.slice_bits_refs();
|
|
250
|
+
if (sliceRefs == 0) {
|
|
251
|
+
throw_if(lz::Packet::ERROR::INVALID_MESSAGE, sliceBits % 8 != 0);
|
|
252
|
+
return ();
|
|
253
|
+
} else {
|
|
254
|
+
throw_if(
|
|
255
|
+
lz::Packet::ERROR::INVALID_MESSAGE,
|
|
256
|
+
(sliceRefs != 1) | (sliceBits != MAX_CELL_WHOLE_BYTE_BITS)
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
messageSlice = messageSlice.preload_first_ref().begin_parse();
|
|
260
|
+
}
|
|
261
|
+
throw(lz::Packet::ERROR::INVALID_MESSAGE);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
() lz::Packet::assertValidSendMessage(cell $self) impure inline {
|
|
265
|
+
lz::Packet::_assertValidLinkedList(
|
|
266
|
+
$self.lz::Packet::getMessage(),
|
|
267
|
+
lz::Packet::MAX_SEND_MESSAGE_CELLS
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
() lz::Packet::assertValidReceiveMessage(cell $self) impure inline {
|
|
272
|
+
lz::Packet::_assertValidLinkedList(
|
|
273
|
+
$self.lz::Packet::getMessage(),
|
|
274
|
+
lz::Packet::MAX_RECEIVE_MESSAGE_CELLS
|
|
275
|
+
);
|
|
276
|
+
}
|
package/src/classes/lz/Path.fc
CHANGED
|
@@ -15,7 +15,7 @@ const int lz::Path::dstOApp = 3;
|
|
|
15
15
|
;; a context-free way to refer to the two ends of the channel.
|
|
16
16
|
;; The direction is inferred by the context of the contract (send vs receive).
|
|
17
17
|
;; The srcOApp is the 256-bit hashpart of a standard address.
|
|
18
|
-
cell lz::Path::New(int srcEid, int srcOApp, int dstEid, int dstOApp) inline method_id {
|
|
18
|
+
cell lz::Path::New(int srcEid, int srcOApp, int dstEid, int dstOApp) impure inline method_id {
|
|
19
19
|
return cl::declare(
|
|
20
20
|
lz::Path::NAME,
|
|
21
21
|
unsafeTuple([
|
|
@@ -27,7 +27,23 @@ cell lz::Path::New(int srcEid, int srcOApp, int dstEid, int dstOApp) inline meth
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const int lz::Path::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 4);
|
|
31
|
+
const int lz::Path::_headerFillerBits = _HEADER_WIDTH - lz::Path::_headerInfoBits;
|
|
32
|
+
const int lz::Path::_headerInfo = 8903714975572488637007080065659;
|
|
33
|
+
|
|
34
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
35
|
+
cell lz::Path::build(int srcEid, int srcOApp, int dstEid, int dstOApp) impure inline {
|
|
36
|
+
return begin_cell()
|
|
37
|
+
.store_uint(lz::Path::_headerInfo, lz::Path::_headerInfoBits) ;; header info
|
|
38
|
+
.store_ones(lz::Path::_headerFillerBits) ;; header filler
|
|
39
|
+
.store_uint32(srcEid)
|
|
40
|
+
.store_uint256(srcOApp)
|
|
41
|
+
.store_uint32(dstEid)
|
|
42
|
+
.store_uint256(dstOApp)
|
|
43
|
+
.end_cell();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
cell lz::Path::endpointPath(int srcEid, int dstEid) impure inline {
|
|
31
47
|
return lz::Path::New(srcEid, NULLADDRESS, dstEid, NULLADDRESS);
|
|
32
48
|
}
|
|
33
49
|
|
|
@@ -37,12 +53,47 @@ cell lz::Path::reverse(cell $path) inline {
|
|
|
37
53
|
int dstEid = $path.cl::get<uint32>(lz::Path::dstEid);
|
|
38
54
|
int dstOapp = $path.cl::get<address>(lz::Path::dstOApp);
|
|
39
55
|
return lz::Path::New(dstEid, dstOapp, srcEid, srcOapp);
|
|
40
|
-
|
|
41
56
|
}
|
|
42
57
|
|
|
58
|
+
;; ====================== Object Getters =====================
|
|
59
|
+
|
|
43
60
|
const int lz::Path::_srcEidOffset = _HEADER_WIDTH;
|
|
44
61
|
const int lz::Path::_srcOAppOffset = lz::Path::_srcEidOffset + 32;
|
|
45
62
|
const int lz::Path::_dstEidOffset = lz::Path::_srcOAppOffset + 256;
|
|
63
|
+
const int lz::Path::_dstOAppOffset = lz::Path::_dstEidOffset + 32;
|
|
64
|
+
|
|
65
|
+
int lz::Path::getSrcOApp(cell $self) impure inline {
|
|
66
|
+
return $self.cellPreloadAddressAt(lz::Path::_srcOAppOffset);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
;; ====================== Storage Composite Accessors =====================
|
|
70
|
+
|
|
71
|
+
int lz::Path::getDstEid(cell $self) impure inline {
|
|
72
|
+
return $self.cellPreloadUint32At(lz::Path::_dstEidOffset);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
;; (srcEid, dstEid)
|
|
76
|
+
(int, int) lz::Path::getEidAndDstEid(cell $self) impure inline {
|
|
77
|
+
slice $selfSlice = $self.begin_parse();
|
|
78
|
+
return (
|
|
79
|
+
$selfSlice.preloadUint32At(lz::Path::_srcEidOffset),
|
|
80
|
+
$selfSlice.preloadUint32At(lz::Path::_dstEidOffset)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
;; (srcEid, srcOApp, dstEid, dstOApp)
|
|
85
|
+
(int, int, int, int) lz::Path::deserialize(cell $self) impure inline {
|
|
86
|
+
slice $selfSlice = $self.begin_parse();
|
|
87
|
+
return (
|
|
88
|
+
$selfSlice.preloadUint32At(lz::Path::_srcEidOffset),
|
|
89
|
+
$selfSlice.preloadAddressAt(lz::Path::_srcOAppOffset),
|
|
90
|
+
$selfSlice.preloadUint32At(lz::Path::_dstEidOffset),
|
|
91
|
+
$selfSlice.preloadAddressAt(lz::Path::_dstOAppOffset)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
;; ====================== Object Mutators =====================
|
|
96
|
+
|
|
46
97
|
;; low-level optimized version
|
|
47
98
|
;; original: 12k gas
|
|
48
99
|
;; optimized: 1k gas
|
|
@@ -62,4 +113,4 @@ cell lz::Path::sanitize(cell $path) impure {
|
|
|
62
113
|
$path.cl::get<uint32>(lz::Path::dstEid),
|
|
63
114
|
$path.cl::get<address>(lz::Path::dstOApp)
|
|
64
115
|
);
|
|
65
|
-
}
|
|
116
|
+
}
|
|
@@ -4,21 +4,52 @@
|
|
|
4
4
|
const int lz::ReceiveEpConfig::NAME = "RcvEpCfg"u;
|
|
5
5
|
|
|
6
6
|
;; field names
|
|
7
|
-
const int lz::ReceiveEpConfig::
|
|
8
|
-
const int lz::ReceiveEpConfig::
|
|
7
|
+
const int lz::ReceiveEpConfig::receiveMsglibConnection = 0;
|
|
8
|
+
const int lz::ReceiveEpConfig::timeoutReceiveMsglibConnection = 1;
|
|
9
9
|
const int lz::ReceiveEpConfig::expiry = 2;
|
|
10
10
|
|
|
11
11
|
cell lz::ReceiveEpConfig::New(
|
|
12
12
|
int receiveMsglibConnectionAddress,
|
|
13
13
|
int timeoutReceiveMsglibConnectionAddress,
|
|
14
14
|
int expiry
|
|
15
|
-
) inline method_id {
|
|
15
|
+
) impure inline method_id {
|
|
16
16
|
return cl::declare(
|
|
17
17
|
lz::ReceiveEpConfig::NAME,
|
|
18
18
|
unsafeTuple([
|
|
19
|
-
[cl::t::address, receiveMsglibConnectionAddress], ;; lz::ReceiveEpConfig::
|
|
20
|
-
[cl::t::address, timeoutReceiveMsglibConnectionAddress], ;; lz::ReceiveEpConfig::
|
|
19
|
+
[cl::t::address, receiveMsglibConnectionAddress], ;; lz::ReceiveEpConfig::receiveMsglibConnection
|
|
20
|
+
[cl::t::address, timeoutReceiveMsglibConnectionAddress], ;; lz::ReceiveEpConfig::timeoutReceiveMsglibConnection
|
|
21
21
|
[cl::t::uint64, expiry] ;; lz::ReceiveEpConfig::expiry
|
|
22
22
|
])
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
;; ====================== Object Builders =====================
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const int lz::ReceiveEpConfig::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 3);
|
|
30
|
+
const int lz::ReceiveEpConfig::_headerFillerBits = _HEADER_WIDTH - lz::ReceiveEpConfig::_headerInfoBits;
|
|
31
|
+
const int lz::ReceiveEpConfig::_headerInfo = 106946417840994430288387571463327099;
|
|
32
|
+
|
|
33
|
+
cell lz::ReceiveEpConfig::build(
|
|
34
|
+
int receiveMsglibConnectionAddress,
|
|
35
|
+
int timeoutReceiveMsglibConnectionAddress,
|
|
36
|
+
int expiry
|
|
37
|
+
) impure inline {
|
|
38
|
+
return begin_cell()
|
|
39
|
+
.store_uint(lz::ReceiveEpConfig::_headerInfo, lz::ReceiveEpConfig::_headerInfoBits) ;; header info
|
|
40
|
+
.store_ones(lz::ReceiveEpConfig::_headerFillerBits) ;; header filler
|
|
41
|
+
.store_uint256(receiveMsglibConnectionAddress) ;; cl::t::uint256
|
|
42
|
+
.store_uint256(timeoutReceiveMsglibConnectionAddress) ;; cl::t::uint256
|
|
43
|
+
.store_uint64(expiry) ;; cl::t::uint64
|
|
44
|
+
.end_cell();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
;; ====================== Object Getters =====================
|
|
48
|
+
|
|
49
|
+
const int lz::ReceiveEpConfig::_receiveMsglibConnectionOffset = _HEADER_WIDTH;
|
|
50
|
+
const int lz::ReceiveEpConfig::_timeoutReceiveMsglibConnectionOffset = lz::ReceiveEpConfig::_receiveMsglibConnectionOffset + 256;
|
|
51
|
+
const int lz::ReceiveEpConfig::_expiryOffset = lz::ReceiveEpConfig::_timeoutReceiveMsglibConnectionOffset + 256;
|
|
52
|
+
|
|
53
|
+
int lz::ReceiveEpConfig::getReceiveMsglibConnection(cell $self) impure inline {
|
|
54
|
+
return $self.cellPreloadAddressAt(lz::ReceiveEpConfig::_receiveMsglibConnectionOffset);
|
|
55
|
+
}
|
|
@@ -4,15 +4,65 @@
|
|
|
4
4
|
const int lz::SendEpConfig::NAME = "SendEpCfg"u;
|
|
5
5
|
|
|
6
6
|
;; field names
|
|
7
|
-
const int lz::SendEpConfig::
|
|
8
|
-
const int lz::SendEpConfig::
|
|
7
|
+
const int lz::SendEpConfig::sendMsglibManager = 0;
|
|
8
|
+
const int lz::SendEpConfig::sendMsglib = 1;
|
|
9
|
+
const int lz::SendEpConfig::sendMsglibConnection = 2;
|
|
9
10
|
|
|
10
|
-
cell lz::SendEpConfig::New(int
|
|
11
|
+
cell lz::SendEpConfig::New(int sendMsglibManager, int sendMsglib, int sendMsglibConnection) inline method_id {
|
|
11
12
|
return cl::declare(
|
|
12
13
|
lz::SendEpConfig::NAME,
|
|
13
14
|
unsafeTuple([
|
|
14
|
-
[cl::t::address,
|
|
15
|
-
[cl::t::address,
|
|
15
|
+
[cl::t::address, sendMsglibManager], ;; lz::SendEpConfig::sendMsglibManager
|
|
16
|
+
[cl::t::address, sendMsglib], ;; lz::SendEpConfig::sendMsglib
|
|
17
|
+
[cl::t::address, sendMsglibConnection] ;; lz::SendEpConfig::sendMsglibConnection
|
|
16
18
|
])
|
|
17
19
|
);
|
|
18
20
|
}
|
|
21
|
+
|
|
22
|
+
;; ====================== Object Builders =====================
|
|
23
|
+
|
|
24
|
+
;; everything fits in the root cell
|
|
25
|
+
const int lz::SendEpConfig::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 3);
|
|
26
|
+
const int lz::SendEpConfig::_headerFillerBits = _HEADER_WIDTH - lz::SendEpConfig::_headerInfoBits;
|
|
27
|
+
const int lz::SendEpConfig::_headerInfo = 27713146160555717952182050613837570051;
|
|
28
|
+
|
|
29
|
+
cell lz::SendEpConfig::build(int sendMsglibManager, int sendMsglib, int sendMsglibConnection) impure inline {
|
|
30
|
+
return begin_cell()
|
|
31
|
+
.store_uint(lz::SendEpConfig::_headerInfo, lz::SendEpConfig::_headerInfoBits)
|
|
32
|
+
.store_ones(lz::SendEpConfig::_headerFillerBits)
|
|
33
|
+
.store_uint256(sendMsglibManager)
|
|
34
|
+
.store_uint256(sendMsglib)
|
|
35
|
+
.store_ref(empty_cell())
|
|
36
|
+
.store_ref(empty_cell())
|
|
37
|
+
.store_ref(
|
|
38
|
+
begin_cell()
|
|
39
|
+
.store_uint256(sendMsglibConnection)
|
|
40
|
+
.end_cell()
|
|
41
|
+
)
|
|
42
|
+
.end_cell();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
;; root cell offsets
|
|
46
|
+
const int lz::SendEpConfig::_sendMsglibManagerOffset = _HEADER_WIDTH;
|
|
47
|
+
const int lz::SendEpConfig::_sendMsglibOffset = _HEADER_WIDTH + 256;
|
|
48
|
+
|
|
49
|
+
;; ref[2] offsets
|
|
50
|
+
const int lz::SendEpConfig::_sendMsglibConnectionOffset = 0;
|
|
51
|
+
|
|
52
|
+
;; ====================== Object Getters =====================
|
|
53
|
+
|
|
54
|
+
int lz::SendEpConfig::getSendMsglib(cell $self) impure inline {
|
|
55
|
+
return $self.cellPreloadAddressAt(lz::SendEpConfig::_sendMsglibOffset);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
;; ====================== Object Multi-Getters =====================
|
|
59
|
+
|
|
60
|
+
;; (sendMsglibManager, sendMsglib, sendMsglibConnection)
|
|
61
|
+
(int, int, int) lz::SendEpConfig::deserialize(cell $self) impure inline {
|
|
62
|
+
slice selfSlice = $self.begin_parse();
|
|
63
|
+
return (
|
|
64
|
+
selfSlice.preloadAddressAt(lz::SendEpConfig::_sendMsglibManagerOffset),
|
|
65
|
+
selfSlice.preloadAddressAt(lz::SendEpConfig::_sendMsglibOffset),
|
|
66
|
+
selfSlice.preloadRefAt(2).cellPreloadAddressAt(lz::SendEpConfig::_sendMsglibConnectionOffset)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -15,4 +15,15 @@ cell md::AddMsglib::New(int msglibManagerAddress, int dstEid) inline method_id {
|
|
|
15
15
|
[cl::t::uint32, dstEid] ;; md::AddMsglib::dstEid
|
|
16
16
|
])
|
|
17
17
|
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
;; Ensure AddMsglib doesn't have garbage bits that would cause undefined behaviors in the protocol
|
|
21
|
+
cell md::AddMsglib::sanitize(cell $addMsglib) impure inline_ref {
|
|
22
|
+
int msglibManagerAddress = $addMsglib.cl::get<address>(md::AddMsglib::msglibManagerAddress);
|
|
23
|
+
int dstEid = $addMsglib.cl::get<uint32>(md::AddMsglib::dstEid);
|
|
24
|
+
|
|
25
|
+
return md::AddMsglib::New(
|
|
26
|
+
msglibManagerAddress,
|
|
27
|
+
dstEid
|
|
28
|
+
);
|
|
18
29
|
}
|
|
@@ -16,3 +16,23 @@ cell md::ChannelNonceInfo::New(int nonce, int firstUnexecutedNonce) inline metho
|
|
|
16
16
|
])
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
;; ====================== Object Getters =====================
|
|
21
|
+
|
|
22
|
+
const int md::ChannelNonceInfo::_nonceOffset = _HEADER_WIDTH;
|
|
23
|
+
const int md::ChannelNonceInfo::_firstUnexecutedNonceOffset = md::ChannelNonceInfo::_nonceOffset + 64;
|
|
24
|
+
|
|
25
|
+
(int, int) md::ChannelNonceInfo::deserialize(cell $self) impure inline {
|
|
26
|
+
slice selfSlice = $self.begin_parse();
|
|
27
|
+
return (
|
|
28
|
+
selfSlice.preloadUint64At(md::ChannelNonceInfo::_nonceOffset),
|
|
29
|
+
selfSlice.preloadUint64At(md::ChannelNonceInfo::_firstUnexecutedNonceOffset)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
cell md::ChannelNonceInfo::sanitize(cell $self) impure inline_ref {
|
|
34
|
+
int nonce = $self.cl::get<uint64>(md::ChannelNonceInfo::nonce);
|
|
35
|
+
int firstUnexecutedNonce = $self.cl::get<uint64>(md::ChannelNonceInfo::firstUnexecutedNonce);
|
|
36
|
+
|
|
37
|
+
return md::ChannelNonceInfo::New(nonce, firstUnexecutedNonce);
|
|
38
|
+
}
|
|
@@ -13,4 +13,12 @@ cell md::CoinsAmount::New(int amount) inline method_id {
|
|
|
13
13
|
[cl::t::coins, amount] ;; md::CoinsAmount::amount
|
|
14
14
|
])
|
|
15
15
|
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
;; ========================== Sanitize ==========================
|
|
19
|
+
|
|
20
|
+
cell md::CoinsAmount::sanitize(cell $self) impure {
|
|
21
|
+
int amount = $self.cl::get<coins>(md::CoinsAmount::amount);
|
|
22
|
+
|
|
23
|
+
return md::CoinsAmount::New(amount);
|
|
16
24
|
}
|
|
@@ -30,3 +30,22 @@ cell md::Deploy::NewWithExtraInfo(
|
|
|
30
30
|
return md::Deploy::New(initialDeposit, dstEid, dstOApp)
|
|
31
31
|
.cl::set(md::Deploy::extraInfo, $extraInfo);
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
;; ========================== Sanitize ==========================
|
|
35
|
+
|
|
36
|
+
cell md::Deploy::sanitize(cell $self) impure {
|
|
37
|
+
int initialDeposit = $self.cl::get<coins>(md::Deploy::initialDeposit);
|
|
38
|
+
int dstEid = $self.cl::get<uint32>(md::Deploy::dstEid);
|
|
39
|
+
int dstOApp = $self.cl::get<uint256>(md::Deploy::dstOApp);
|
|
40
|
+
|
|
41
|
+
return md::Deploy::New(initialDeposit, dstEid, dstOApp);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
cell md::Deploy::NewWithExtraInfo::sanitize(cell $self) impure {
|
|
45
|
+
int initialDeposit = $self.cl::get<coins>(md::Deploy::initialDeposit);
|
|
46
|
+
int dstEid = $self.cl::get<uint32>(md::Deploy::dstEid);
|
|
47
|
+
int dstOApp = $self.cl::get<uint256>(md::Deploy::dstOApp);
|
|
48
|
+
cell $extraInfo = $self.cl::get<objRef>(md::Deploy::extraInfo);
|
|
49
|
+
|
|
50
|
+
return md::Deploy::NewWithExtraInfo(initialDeposit, dstEid, dstOApp, $extraInfo);
|
|
51
|
+
}
|
|
@@ -8,7 +8,7 @@ const int md::ExtendedMd::md = 0;
|
|
|
8
8
|
const int md::ExtendedMd::obj = 1;
|
|
9
9
|
const int md::ExtendedMd::forwardingAddress = 2;
|
|
10
10
|
|
|
11
|
-
cell md::ExtendedMd::New(cell $md, cell $obj, int forwardingAddress) inline method_id {
|
|
11
|
+
cell md::ExtendedMd::New(cell $md, cell $obj, int forwardingAddress) impure inline method_id {
|
|
12
12
|
return cl::declare(
|
|
13
13
|
md::ExtendedMd::NAME,
|
|
14
14
|
unsafeTuple([
|
|
@@ -17,4 +17,55 @@ cell md::ExtendedMd::New(cell $md, cell $obj, int forwardingAddress) inline meth
|
|
|
17
17
|
[cl::t::address, forwardingAddress] ;; md::ExtendedMd::forwardingAddress
|
|
18
18
|
])
|
|
19
19
|
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const int md::ExtendedMd::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 3);
|
|
23
|
+
const int md::ExtendedMd::_headerFillerBits = _HEADER_WIDTH - md::ExtendedMd::_headerInfoBits;
|
|
24
|
+
const int md::ExtendedMd::_headerInfo = 8632157695553525919024050567799415113083;
|
|
25
|
+
|
|
26
|
+
cell md::ExtendedMd::build(cell $md, cell $obj, int forwardingAddress) impure inline {
|
|
27
|
+
return begin_cell()
|
|
28
|
+
.store_uint(md::ExtendedMd::_headerInfo, md::ExtendedMd::_headerInfoBits) ;; header info
|
|
29
|
+
.store_ones(md::ExtendedMd::_headerFillerBits) ;; header filler
|
|
30
|
+
.store_ref($md) ;; md::ExtendedMd::md
|
|
31
|
+
.store_ref($obj) ;; md::ExtendedMd::obj
|
|
32
|
+
.store_uint256(forwardingAddress) ;; md::ExtendedMd::forwardingAddress
|
|
33
|
+
.end_cell();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
;; ====================== Object Getters =====================
|
|
37
|
+
|
|
38
|
+
const int md::ExtendedMd::_forwardingAddressOffset = _HEADER_WIDTH;
|
|
39
|
+
|
|
40
|
+
cell md::ExtendedMd::getObj(cell $self) impure inline {
|
|
41
|
+
return $self.cellPreloadRefAt(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
;; ====================== Object Multi-Getters =====================
|
|
45
|
+
|
|
46
|
+
(cell, int) md::ExtendedMd::getMdAndForwardingAddress(cell $self) impure inline {
|
|
47
|
+
slice selfSlice = $self.begin_parse();
|
|
48
|
+
return (
|
|
49
|
+
selfSlice.preloadRefAt(0),
|
|
50
|
+
selfSlice.preloadAddressAt(md::ExtendedMd::_forwardingAddressOffset)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
(cell, cell, int) md::ExtendedMd::deserialize(cell $self) impure inline {
|
|
55
|
+
slice selfSlice = $self.begin_parse();
|
|
56
|
+
return (
|
|
57
|
+
selfSlice.preloadRefAt(0),
|
|
58
|
+
selfSlice.preloadRefAt(1),
|
|
59
|
+
selfSlice.preloadAddressAt(md::ExtendedMd::_forwardingAddressOffset)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
;; ====================== Sanitize =====================
|
|
64
|
+
|
|
65
|
+
cell md::ExtendedMd::sanitize(cell $extendedMd) impure {
|
|
66
|
+
cell $md = $extendedMd.cl::get<objRef>(md::ExtendedMd::md);
|
|
67
|
+
cell $obj = $extendedMd.cl::get<objRef>(md::ExtendedMd::obj);
|
|
68
|
+
int forwardingAddress = $extendedMd.cl::get<address>(md::ExtendedMd::forwardingAddress);
|
|
69
|
+
|
|
70
|
+
return md::ExtendedMd::New($md, $obj, forwardingAddress);
|
|
20
71
|
}
|
|
@@ -15,4 +15,24 @@ cell md::LzReceivePrepare::New(int nonce, int nanotons) method_id {
|
|
|
15
15
|
[cl::t::coins, nanotons] ;; md::LzReceivePrepare::nanotons
|
|
16
16
|
])
|
|
17
17
|
);
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
;; ====================== Object Getters =====================
|
|
21
|
+
|
|
22
|
+
const int md::LzReceivePrepare::_nonceOffset = _HEADER_WIDTH;
|
|
23
|
+
const int md::LzReceivePrepare::_nanotonsOffset = md::LzReceivePrepare::_nonceOffset + 64;
|
|
24
|
+
|
|
25
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
26
|
+
int md::LzReceivePrepare::getNanotons(cell $self) impure inline {
|
|
27
|
+
return $self.cellPreloadCoinsAt(md::LzReceivePrepare::_nanotonsOffset);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
;; ====================== Object Multi-Getters =====================
|
|
31
|
+
|
|
32
|
+
(int, int) md::LzReceivePrepare::deserialize(cell $self) impure inline {
|
|
33
|
+
slice selfSlice = $self.begin_parse();
|
|
34
|
+
return (
|
|
35
|
+
selfSlice.preloadUint64At(md::LzReceivePrepare::_nonceOffset),
|
|
36
|
+
selfSlice.preloadCoinsAt(md::LzReceivePrepare::_nanotonsOffset)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -13,7 +13,7 @@ const int md::LzReceiveStatus::sender = 5;
|
|
|
13
13
|
const int md::LzReceiveStatus::packet = 6;
|
|
14
14
|
const int md::LzReceiveStatus::executionStatus = 7;
|
|
15
15
|
|
|
16
|
-
cell md::LzReceiveStatus::New(int success, int nonce) inline method_id {
|
|
16
|
+
cell md::LzReceiveStatus::New(int success, int nonce) impure inline method_id {
|
|
17
17
|
return cl::declare(
|
|
18
18
|
md::LzReceiveStatus::NAME,
|
|
19
19
|
unsafeTuple([
|
|
@@ -54,4 +54,75 @@ cell md::LzReceiveStatus::NewFull(
|
|
|
54
54
|
[cl::t::uint8, executionStatus] ;; md::LzReceiveAlert::executionStatus
|
|
55
55
|
])
|
|
56
56
|
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
;; ====================== Object Builders =====================
|
|
60
|
+
|
|
61
|
+
const int md::LzReceiveStatus::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 8);
|
|
62
|
+
const int md::LzReceiveStatus::_headerFillerBits = _HEADER_WIDTH - md::LzReceiveStatus::_headerInfoBits;
|
|
63
|
+
const int md::LzReceiveStatus::_headerInfo = 31461150238884194531671275676859177915085721713836393515717807231;
|
|
64
|
+
|
|
65
|
+
;; this function is unused by the protocol but will be used by OApps
|
|
66
|
+
cell md::LzReceiveStatus::build(
|
|
67
|
+
int success,
|
|
68
|
+
int nonce
|
|
69
|
+
) impure inline method_id {
|
|
70
|
+
return begin_cell()
|
|
71
|
+
.store_uint(md::LzReceiveStatus::_headerInfo, md::LzReceiveStatus::_headerInfoBits) ;; header info
|
|
72
|
+
.store_ones(md::LzReceiveStatus::_headerFillerBits) ;; header filler
|
|
73
|
+
.store_bool(success) ;; bool[0]
|
|
74
|
+
.store_uint64(nonce) ;; uint64[1]
|
|
75
|
+
.store_uint128(0) ;; coins[2]
|
|
76
|
+
.store_uint256(NULLADDRESS) ;; address[3]
|
|
77
|
+
.store_uint8(0) ;; uint8[4]
|
|
78
|
+
.store_ref(cl::nullObject()) ;; ref[0]
|
|
79
|
+
.store_ref(cl::nullObject()) ;; ref[1]
|
|
80
|
+
.store_ref(
|
|
81
|
+
begin_cell()
|
|
82
|
+
.store_ref(cl::nullObject()) ;; ref[2]
|
|
83
|
+
.end_cell()
|
|
84
|
+
)
|
|
85
|
+
.end_cell();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
;; ====================== Object Multi-Getters =====================
|
|
90
|
+
|
|
91
|
+
const int md::LzReceiveStatus::_successOffset = _HEADER_WIDTH;
|
|
92
|
+
const int md::LzReceiveStatus::_nonceOffset = md::LzReceiveStatus::_successOffset + 1;
|
|
93
|
+
const int md::LzReceiveStatus::_valueOffset = md::LzReceiveStatus::_nonceOffset + 64;
|
|
94
|
+
const int md::LzReceiveStatus::_senderOffset = md::LzReceiveStatus::_valueOffset + 128;
|
|
95
|
+
const int md::LzReceiveStatus::_executionStatusOffset = md::LzReceiveStatus::_senderOffset + 256;
|
|
96
|
+
const int md::LzReceiveStatus::_extraDataOffset = md::LzReceiveStatus::_executionStatusOffset + 8;
|
|
97
|
+
|
|
98
|
+
(int, int) md::LzReceiveStatus::getSuccessAndNonce(cell $self) impure inline {
|
|
99
|
+
slice $selfSlice = $self.begin_parse();
|
|
100
|
+
return (
|
|
101
|
+
$selfSlice.preloadBoolAt(md::LzReceiveStatus::_successOffset),
|
|
102
|
+
$selfSlice.preloadUint64At(md::LzReceiveStatus::_nonceOffset)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
;; ========================== Sanitize ==========================
|
|
107
|
+
|
|
108
|
+
cell md::LzReceiveStatus::NewFull::sanitize(cell $self) impure {
|
|
109
|
+
int success = $self.cl::get<bool>(md::LzReceiveStatus::success);
|
|
110
|
+
int nonce = $self.cl::get<uint64>(md::LzReceiveStatus::nonce);
|
|
111
|
+
int value = $self.cl::get<coins>(md::LzReceiveStatus::value);
|
|
112
|
+
cell extraData = $self.cl::get<cellRef>(md::LzReceiveStatus::extraData);
|
|
113
|
+
cell reason = $self.cl::get<cellRef>(md::LzReceiveStatus::reason);
|
|
114
|
+
int sender = $self.cl::get<address>(md::LzReceiveStatus::sender);
|
|
115
|
+
cell $packet = $self.cl::get<objRef>(md::LzReceiveStatus::packet);
|
|
116
|
+
int executionStatus = $self.cl::get<uint8>(md::LzReceiveStatus::executionStatus);
|
|
117
|
+
|
|
118
|
+
return md::LzReceiveStatus::NewFull(
|
|
119
|
+
success,
|
|
120
|
+
nonce,
|
|
121
|
+
value,
|
|
122
|
+
extraData,
|
|
123
|
+
reason,
|
|
124
|
+
sender,
|
|
125
|
+
$packet,
|
|
126
|
+
executionStatus
|
|
127
|
+
);
|
|
57
128
|
}
|