@layerzerolabs/layerzero-v2-ton 3.0.27 → 3.0.28

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.
Files changed (199) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/ActionsSerde.test.compiled.json +1 -0
  3. package/build/AllStorages.compiled.json +1 -1
  4. package/build/AllStorages.test.compiled.json +1 -1
  5. package/build/BaseContract.test.compiled.json +1 -1
  6. package/build/Channel.compiled.json +1 -1
  7. package/build/Channel.permissions.test.compiled.json +1 -1
  8. package/build/ChannelBurn.test.compiled.json +1 -1
  9. package/build/ChannelCommitPacket.test.compiled.json +1 -1
  10. package/build/ChannelConfig.test.compiled.json +1 -1
  11. package/build/ChannelInitialize.test.compiled.json +1 -1
  12. package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
  13. package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
  14. package/build/ChannelNilify.test.compiled.json +1 -1
  15. package/build/ChannelReceive.test.compiled.json +1 -1
  16. package/build/ChannelReceiveCallback.test.compiled.json +1 -1
  17. package/build/ChannelReceiveView.test.compiled.json +1 -1
  18. package/build/ChannelSend.test.compiled.json +1 -1
  19. package/build/ChannelSerde.test.compiled.json +1 -0
  20. package/build/Classlib.test.compiled.json +1 -1
  21. package/build/ComputeDataSizeGas.test.compiled.json +1 -1
  22. package/build/Connection.compiled.json +1 -1
  23. package/build/Controller.assertions.test.compiled.json +1 -1
  24. package/build/Controller.compiled.json +1 -1
  25. package/build/Controller.permissions.test.compiled.json +1 -1
  26. package/build/Controller.test.compiled.json +1 -1
  27. package/build/Counter.compiled.json +1 -1
  28. package/build/Counter.permissions.test.compiled.json +1 -1
  29. package/build/Counter.setters.test.compiled.json +1 -1
  30. package/build/Counter.test.compiled.json +1 -1
  31. package/build/Dvn.compiled.json +1 -1
  32. package/build/Dvn.test.compiled.json +1 -1
  33. package/build/DvnFeeLib.compiled.json +1 -1
  34. package/build/DvnFeeLibSerde.test.compiled.json +1 -0
  35. package/build/DvnPermissions.test.compiled.json +1 -1
  36. package/build/DvnSerde.test.compiled.json +1 -0
  37. package/build/Endpoint.compiled.json +1 -1
  38. package/build/Endpoint.permissions.test.compiled.json +1 -1
  39. package/build/Endpoint.test.compiled.json +1 -1
  40. package/build/EndpointSerde.test.compiled.json +1 -0
  41. package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
  42. package/build/Executor.compiled.json +1 -1
  43. package/build/Executor.test.compiled.json +1 -1
  44. package/build/ExecutorFeeLib.compiled.json +1 -1
  45. package/build/ExecutorFeeLibSerde.test.compiled.json +1 -0
  46. package/build/ExecutorPermissions.test.compiled.json +1 -1
  47. package/build/ExecutorSerde.test.compiled.json +1 -0
  48. package/build/LzClasses.test.compiled.json +1 -1
  49. package/build/LzClassesSerde.test.compiled.json +1 -0
  50. package/build/LzUtil.test.compiled.json +1 -1
  51. package/build/MsgData.test.compiled.json +1 -1
  52. package/build/MsgDataSerde.test.compiled.json +1 -0
  53. package/build/MsglibPacketCodec.test.compiled.json +1 -1
  54. package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
  55. package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -0
  56. package/build/PriceFeedCache.compiled.json +1 -1
  57. package/build/PriceFeedCache.test.compiled.json +1 -1
  58. package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
  59. package/build/PriceFeedCacheSerde.test.compiled.json +1 -0
  60. package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -0
  61. package/build/Proxy.compiled.json +1 -1
  62. package/build/Proxy.permissions.test.compiled.json +1 -1
  63. package/build/Proxy.test.compiled.json +1 -1
  64. package/build/SmlConnection.compiled.json +1 -1
  65. package/build/SmlConnection.permissions.test.compiled.json +1 -1
  66. package/build/SmlConnection.test.compiled.json +1 -1
  67. package/build/SmlManager.compiled.json +1 -1
  68. package/build/SmlManager.permissions.test.compiled.json +1 -1
  69. package/build/SmlManager.test.compiled.json +1 -1
  70. package/build/Uln.compiled.json +1 -1
  71. package/build/Uln.test.compiled.json +1 -1
  72. package/build/UlnConnection.compiled.json +1 -1
  73. package/build/UlnConnection.test.compiled.json +1 -1
  74. package/build/UlnConnectionPermissions.test.compiled.json +1 -1
  75. package/build/UlnConnectionSerde.test.compiled.json +1 -0
  76. package/build/UlnManagement.test.compiled.json +1 -1
  77. package/build/UlnManager.compiled.json +1 -1
  78. package/build/UlnManager.test.compiled.json +1 -1
  79. package/build/UlnManagerPermissions.test.compiled.json +1 -1
  80. package/build/UlnManagerUtil.test.compiled.json +1 -1
  81. package/build/UlnMsgDataSerde.test.compiled.json +1 -0
  82. package/build/UlnPermissions.test.compiled.json +1 -1
  83. package/build/UlnReceiveConfig.test.compiled.json +1 -1
  84. package/build/UlnSend.test.compiled.json +1 -1
  85. package/build/UlnSendConfig.test.compiled.json +1 -1
  86. package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
  87. package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
  88. package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
  89. package/build/UlnSerde.test.compiled.json +1 -0
  90. package/build/UlnUtil.test.compiled.json +1 -1
  91. package/build/WorkerCore.test.compiled.json +1 -1
  92. package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -0
  93. package/build/WorkerCoreSerde.test.compiled.json +1 -0
  94. package/build/badFeeLib1.test.compiled.json +1 -1
  95. package/build/badFeeLib10.test.compiled.json +1 -1
  96. package/build/badFeeLib11.test.compiled.json +1 -1
  97. package/build/badFeeLib12.test.compiled.json +1 -1
  98. package/build/badFeeLib2.test.compiled.json +1 -1
  99. package/build/badFeeLib3.test.compiled.json +1 -1
  100. package/build/badFeeLib4.test.compiled.json +1 -1
  101. package/build/badFeeLib5.test.compiled.json +1 -1
  102. package/build/badFeeLib6.test.compiled.json +1 -1
  103. package/build/badFeeLib7.test.compiled.json +1 -1
  104. package/build/badFeeLib8.test.compiled.json +1 -1
  105. package/build/badFeeLib9.test.compiled.json +1 -1
  106. package/package.json +1 -1
  107. package/src/classes/lz/EpConfig.fc +90 -23
  108. package/src/classes/lz/MsglibInfo.fc +32 -5
  109. package/src/classes/lz/Packet.fc +109 -48
  110. package/src/classes/lz/Path.fc +55 -4
  111. package/src/classes/lz/ReceiveEpConfig.fc +36 -5
  112. package/src/classes/lz/SendEpConfig.fc +55 -5
  113. package/src/classes/msgdata/AddMsglib.fc +11 -0
  114. package/src/classes/msgdata/ChannelNonceInfo.fc +20 -0
  115. package/src/classes/msgdata/CoinsAmount.fc +8 -0
  116. package/src/classes/msgdata/Deploy.fc +19 -0
  117. package/src/classes/msgdata/ExtendedMd.fc +52 -1
  118. package/src/classes/msgdata/LzReceivePrepare.fc +21 -1
  119. package/src/classes/msgdata/LzReceiveStatus.fc +72 -1
  120. package/src/classes/msgdata/LzSend.fc +143 -24
  121. package/src/classes/msgdata/MdAddress.fc +42 -0
  122. package/src/classes/msgdata/MdEid.fc +8 -0
  123. package/src/classes/msgdata/MdObj.fc +32 -0
  124. package/src/classes/msgdata/MessagingReceipt.fc +34 -1
  125. package/src/classes/msgdata/MsglibSendCallback.fc +82 -0
  126. package/src/classes/msgdata/Nonce.fc +30 -0
  127. package/src/classes/msgdata/OptionsV1.fc +21 -1
  128. package/src/classes/msgdata/OptionsV2.fc +27 -0
  129. package/src/classes/msgdata/PacketId.fc +24 -0
  130. package/src/classes/msgdata/PacketSent.fc +35 -1
  131. package/src/classes/msgdata/SetAddress.fc +7 -0
  132. package/src/classes/msgdata/SetEpConfig.fc +17 -0
  133. package/src/funC++/actions/event.fc +17 -2
  134. package/src/funC++/actions/utils.fc +2 -2
  135. package/src/funC++/classlib.fc +33 -43
  136. package/src/funC++/constants.fc +28 -28
  137. package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +75 -59
  138. package/src/funC++/stdlib.fc +26 -11
  139. package/src/funC++/testutils.fc +2 -2
  140. package/src/funC++/txnContext.fc +14 -14
  141. package/src/funC++/utils.fc +97 -1
  142. package/src/protocol/channel/handler.fc +247 -189
  143. package/src/protocol/channel/storage.fc +206 -1
  144. package/src/protocol/controller/handler.fc +35 -17
  145. package/src/protocol/controller/main.fc +1 -1
  146. package/src/protocol/core/abstract/protocolHandler.fc +11 -21
  147. package/src/protocol/core/baseStorage.fc +24 -0
  148. package/src/protocol/endpoint/handler.fc +99 -57
  149. package/src/protocol/endpoint/storage.fc +69 -5
  150. package/src/protocol/msglibs/BytesEncoder.fc +11 -10
  151. package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +1 -4
  152. package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +1 -0
  153. package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +7 -8
  154. package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +20 -0
  155. package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +15 -0
  156. package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
  157. package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +1 -1
  158. package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +6 -0
  159. package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +20 -0
  160. package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +114 -28
  161. package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +51 -1
  162. package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +1 -1
  163. package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +10 -0
  164. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +6 -0
  165. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +51 -1
  166. package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +15 -0
  167. package/src/protocol/msglibs/ultralightnode/uln/handler.fc +84 -107
  168. package/src/protocol/msglibs/ultralightnode/uln/storage.fc +77 -1
  169. package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +92 -66
  170. package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +113 -6
  171. package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +6 -91
  172. package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +55 -31
  173. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +13 -9
  174. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +23 -0
  175. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +63 -27
  176. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +19 -0
  177. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +55 -6
  178. package/src/workers/core/abstract/workerHandler.fc +20 -19
  179. package/src/workers/core/interface.fc +2 -1
  180. package/src/workers/core/workerCoreStorage.fc +16 -1
  181. package/src/workers/dvn/handler.fc +67 -26
  182. package/src/workers/dvn/storage.fc +15 -2
  183. package/src/workers/executor/handler.fc +18 -6
  184. package/src/workers/executor/interface.fc +1 -0
  185. package/src/workers/executor/storage.fc +8 -1
  186. package/src/workers/msgdata/DropEvent.fc +18 -0
  187. package/src/workers/msgdata/ExecuteParams.fc +66 -3
  188. package/src/workers/msgdata/NativeDrop.fc +4 -0
  189. package/src/workers/msgdata/SetDict.fc +6 -4
  190. package/src/workers/msgdata/SetQuorum.fc +4 -2
  191. package/src/workers/msgdata/SignedRequest.fc +8 -0
  192. package/src/workers/priceFeedCache/handler.fc +21 -27
  193. package/src/workers/priceFeedCache/storage.fc +16 -1
  194. package/src/workers/proxy/handler.fc +2 -1
  195. package/src/workers/proxy/storage.fc +1 -1
  196. package/tests/baseContractTest.fc +2 -6
  197. package/tests/testMain.fc +2 -2
  198. package/src/classes/msgdata/Amount.fc +0 -16
  199. package/src/funC++/actions/destroy.fc +0 -27
@@ -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
- cell lz::Path::endpointPath(int srcEid, int dstEid) inline {
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::receiveMsglibConnectionAddress = 0;
8
- const int lz::ReceiveEpConfig::timeoutReceiveMsglibConnectionAddress = 1;
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::receiveMsglibConnectionAddress
20
- [cl::t::address, timeoutReceiveMsglibConnectionAddress], ;; lz::ReceiveEpConfig::timeoutReceiveMsglibConnectionAddress
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::sendMsglibAddress = 0;
8
- const int lz::SendEpConfig::sendMsglibConnectionAddress = 1;
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 sendMsglibAddress, int sendMsglibConnectionAddress) inline method_id {
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, sendMsglibAddress], ;; lz::SendEpConfig::sendMsglibAddress
15
- [cl::t::address, sendMsglibConnectionAddress] ;; lz::SendEpConfig::sendMsglibConnectionAddress
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
  }
@@ -1,31 +1,34 @@
1
1
  #include "../../funC++/classlib.fc";
2
+ #include "../lz/Packet.fc";
2
3
 
3
4
  ;; required storage name
4
5
  const int md::LzSend::NAME = "lzSend"u;
5
6
 
6
7
  ;; field names
7
8
  const int md::LzSend::sendRequestId = 0;
8
- const int md::LzSend::sendMsglib = 1;
9
- const int md::LzSend::sendMsglibConnection = 2;
10
- const int md::LzSend::packet = 3;
11
- const int md::LzSend::nativeFee = 4;
12
- const int md::LzSend::zroFee = 5;
13
- const int md::LzSend::extraOptions = 6;
14
- const int md::LzSend::enforcedOptions = 7;
15
- const int md::LzSend::callbackData = 8;
9
+ const int md::LzSend::sendMsglibManager = 1;
10
+ const int md::LzSend::sendMsglib = 2;
11
+ const int md::LzSend::sendMsglibConnection = 3;
12
+ const int md::LzSend::packet = 4;
13
+ const int md::LzSend::nativeFee = 5;
14
+ const int md::LzSend::zroFee = 6;
15
+ const int md::LzSend::extraOptions = 7;
16
+ const int md::LzSend::enforcedOptions = 8;
17
+ const int md::LzSend::callbackData = 9;
16
18
 
17
19
  cell md::LzSend::New(
18
- int nativeFee,
19
- int zroFee,
20
- cell $extraOptions,
21
- cell $enforcedOptions,
22
- cell $packet,
23
- cell callbackData
20
+ int nativeFee,
21
+ int zroFee,
22
+ cell $extraOptions,
23
+ cell $enforcedOptions,
24
+ cell $packet,
25
+ cell callbackData
24
26
  ) inline method_id {
25
27
  return cl::declare(
26
28
  md::LzSend::NAME,
27
29
  unsafeTuple([
28
30
  [cl::t::uint64, 0], ;; md::LzSend::sendRequestId
31
+ [cl::t::address, NULLADDRESS], ;; md::LzSend::sendMsglibManager
29
32
  [cl::t::address, NULLADDRESS], ;; md::lzSend::sendMsglib
30
33
  [cl::t::address, NULLADDRESS], ;; md::lzSend::sendMsglibConnection
31
34
  [cl::t::objRef, $packet], ;; md::LzSend::packet
@@ -38,21 +41,137 @@ cell md::LzSend::New(
38
41
  );
39
42
  }
40
43
 
41
- const md::lzSend::requestInfoWidth = _HEADER_WIDTH + 64 + 256 + 256;
42
- ;; low-level hacking to set these 3 fields in LzSend
43
- ;; saves about 7000 gas
44
- cell md::lzSend::fillRequestInfo(
45
- cell $lzSend,
44
+ const int md::LzSend::_headerPostNameBits = 180;
45
+ const int md::LzSend::_headerFillerBits = _HEADER_WIDTH - (md::LzSend::_headerPostNameBits + _NAME_WIDTH);
46
+ const int md::LzSend::_headerInfo = 582890735024998957421269964955452773563747974476099581;
47
+
48
+ ;; ========================== Object Builders ==========================
49
+
50
+ ;; this function is unused by the protocol but will be used by OApps
51
+ cell md::LzSend::build(
52
+ int nativeFee,
53
+ int zroFee,
54
+ cell $extraOptions,
55
+ cell $enforcedOptions,
56
+ cell $packet,
57
+ cell callbackData
58
+ ) impure inline {
59
+ return begin_cell()
60
+ .store_uint(md::LzSend::NAME, _NAME_WIDTH)
61
+ .store_uint(md::LzSend::_headerInfo, md::LzSend::_headerPostNameBits)
62
+ .store_ones(md::LzSend::_headerFillerBits)
63
+ .store_uint64(0) ;; sendRequestId
64
+ .store_uint256(NULLADDRESS) ;; sendMsglibManager
65
+ .store_uint256(NULLADDRESS) ;; sendMsglib
66
+ .store_ref($packet)
67
+ .store_ref($extraOptions)
68
+ .store_ref(
69
+ begin_cell()
70
+ .store_uint256(NULLADDRESS) ;; sendMsglibConnection
71
+ .store_uint128(nativeFee) ;; nativeFee
72
+ .store_uint128(zroFee) ;; zroFee
73
+ .store_ref($enforcedOptions) ;; enforcedOptions
74
+ .store_ref(callbackData) ;; callbackData
75
+ .end_cell()
76
+ )
77
+ .end_cell();
78
+ }
79
+
80
+ ;; ====================== Object Accessors =====================
81
+
82
+ ;; in root cell
83
+ const int md::LzSend::_sendRequestIdffset = _HEADER_WIDTH;
84
+ const int md::LzSend::_sendMsglibManagerOffset = md::LzSend::_sendRequestIdffset + 64;
85
+ const int md::LzSend::_sendMsglibOffset = md::LzSend::_sendMsglibManagerOffset + 256;
86
+
87
+ ;; in ref[2]
88
+ const int md::LzSend::_sendMsglibConnectionOffset = 0;
89
+ const int md::LzSend::_nativeFeeOffset = md::LzSend::_sendMsglibConnectionOffset + 256;
90
+ const int md::LzSend::_zroFeeOffset = md::LzSend::_nativeFeeOffset + 128;
91
+
92
+ int md::LzSend::getSendMsglib(cell $self) impure inline {
93
+ return $self.cellPreloadAddressAt(md::LzSend::_sendMsglibOffset);
94
+ }
95
+
96
+ cell md::LzSend::getPacket(cell $self) impure inline {
97
+ return $self.cellPreloadRefAt(0);
98
+ }
99
+
100
+ ;; gets the path from the packet inside the LzSend
101
+ cell md::LzSend::getPath(cell $self) impure inline {
102
+ return $self.cellPreloadRefAt(0).cellPreloadRefAt(0);
103
+ }
104
+
105
+ ;; (requestId, nativeFee, zroFee, extraOptions, enforcedOptions)
106
+ (int, int, int, cell, cell) md::LzSend::deserializeSendCallback(cell $self) impure inline {
107
+ slice selfSlice = $self.begin_parse();
108
+ slice ref2Slice = selfSlice.preloadRefSliceAt(2);
109
+ return (
110
+ selfSlice.preloadUint64At(md::LzSend::_sendRequestIdffset),
111
+ ref2Slice.preloadCoinsAt(md::LzSend::_nativeFeeOffset),
112
+ ref2Slice.preloadCoinsAt(md::LzSend::_zroFeeOffset),
113
+ selfSlice.preloadRefAt(1),
114
+ ref2Slice.preloadRefAt(0)
115
+ );
116
+ }
117
+
118
+ ;; (packet, extraOptions, enforcedOptions)
119
+ (cell, cell, cell) md::LzSend::getQuoteInformation(cell $self) impure inline {
120
+ return (
121
+ $self.cellPreloadRefAt(0),
122
+ $self.cellPreloadRefAt(1),
123
+ $self.cellPreloadRefAt(2).cellPreloadRefAt(0)
124
+ );
125
+ }
126
+
127
+ int md::LzSend::getSendMsglibManager(cell $self) impure inline {
128
+ return $self.cellPreloadAddressAt(md::LzSend::_sendMsglibManagerOffset);
129
+ }
130
+
131
+ ;; ====================== Object Composite Modifiers =====================
132
+
133
+ const int md::lzSend::requestInfoWidth = _HEADER_WIDTH + 64 + 256 + 256;
134
+ ;; Can't easily store a slice constant because the header isn't byte-aligned
135
+ const int md::lzSend::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 10);
136
+ const int md::lzSend::_headerPrefix = 11424049401754228397633815938683071207390004427712457772775726065407;
137
+ const int md::lzSend::_headerSuffix = 17331160549995323848587739135;
138
+ const int md::lzSend::_headerTrailingBits = _HEADER_WIDTH - 256;
139
+
140
+ cell md::LzSend::fillRequestInfo(
141
+ cell $self,
46
142
  int requestId,
143
+ int sendMsglibManager,
47
144
  int sendMsglib,
48
145
  int sendMsglibConnection
49
- ) inline method_id {
50
- slice lzSendSlice = $lzSend.begin_parse();
146
+ ) impure inline method_id {
147
+ slice selfslice = $self.begin_parse();
148
+ slice ref2Slice = selfslice.preloadRefSliceAt(2);
149
+
150
+ ;; Fill in the fields AND overwrite the entire header to match the expected format
51
151
  return begin_cell()
52
- .store_slice(lzSendSlice.scutfirst(_HEADER_WIDTH, 0))
152
+ .store_uint256(md::lzSend::_headerPrefix)
153
+ .store_uint(md::lzSend::_headerSuffix, md::lzSend::_headerTrailingBits)
154
+ .store_slice(selfslice.scutfirst(0, 2))
53
155
  .store_uint64(requestId)
156
+ .store_uint256(sendMsglibManager)
54
157
  .store_uint256(sendMsglib)
55
- .store_uint256(sendMsglibConnection)
56
- .store_slice(lzSendSlice.sskipfirst(md::lzSend::requestInfoWidth, 0))
158
+ .store_ref(
159
+ begin_cell()
160
+ .store_uint256(sendMsglibConnection)
161
+ .store_slice(ref2Slice.sskipfirst(md::LzSend::_nativeFeeOffset, 0))
162
+ .end_cell()
163
+ )
164
+ .end_cell();
165
+ }
166
+
167
+ cell md::LzSend::setPacketNonceAndGuid(cell $self, int packetNonce, int packetGuid) impure inline {
168
+ slice selfSlice = $self.begin_parse();
169
+
170
+ cell $newPacket = selfSlice~load_ref()
171
+ .lz::Packet::setNonceAndGuid(packetNonce, packetGuid);
172
+
173
+ return begin_cell()
174
+ .store_ref($newPacket)
175
+ .store_slice(selfSlice)
57
176
  .end_cell();
58
177
  }