@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.
Files changed (200) hide show
  1. package/CHANGELOG.md +12 -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 +2 -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/baseSerdeTest.fc +117 -0
  198. package/tests/testMain.fc +2 -2
  199. package/src/classes/msgdata/Amount.fc +0 -16
  200. package/src/funC++/actions/destroy.fc +0 -27
@@ -1,5 +1,6 @@
1
1
  #include "../../BytesEncoder.fc";
2
2
 
3
+
3
4
  #include "../feeLibInterface.fc";
4
5
  #include "../feeLibUtils.fc";
5
6
 
@@ -64,14 +65,12 @@ int _getEventSink() impure {
64
65
  }
65
66
 
66
67
  () assertConnection(cell $ulnSendMd) impure inline {
67
- cell connectionCode = getContractStorage().cl::get<cellRef>(Uln::connectionCode);
68
+ cell connectionCode = getContractStorage().Uln::getConnectionCode();
68
69
 
69
- cell $connectionInitialStorage = $ulnSendMd
70
- .cl::get<objRef>(md::UlnSend::connectionInitialStorage);
70
+ cell $connectionInitialStorage = $ulnSendMd.md::UlnSend::getConnectionInitialStorage();
71
71
 
72
- int providedUlnManagerAddress = $connectionInitialStorage
73
- .cl::get<objRef>(BASE_STORAGE_INDEX)
74
- .cl::get<address>(BaseStorage::owner);
72
+ int providedUlnManagerAddress =
73
+ UlnConnection::getBaseStorage($connectionInitialStorage).BaseStorage::getOwner();
75
74
 
76
75
  ;; By construction, if the bytecode is valid and the uln manager address is correct,
77
76
  ;; then the uln address cannot be incorrect (assuming no bug in the ULN connection bytecode).
@@ -99,11 +98,12 @@ cell _failedMsglibSendCallback(cell $lzSend) impure inline {
99
98
  }
100
99
 
101
100
  cell _quote(cell $ulnSendMd, cell $storage) impure inline {
102
- cell $lzSend = $ulnSendMd.cl::get<objRef>(md::UlnSend::lzSend);
101
+ (
102
+ cell $lzSend,
103
+ cell $customUlnSendConfig
104
+ ) = $ulnSendMd.md::UlnSend::getLzSendAndCustomUlnSendConfig();
103
105
 
104
- int ownerAddress = $storage
105
- .cl::get<objRef>(BASE_STORAGE_INDEX)
106
- .cl::get<address>(BaseStorage::owner);
106
+ cell $defaultUlnSendConfig = $storage.Uln::getDefaultUlnSendConfig();
107
107
 
108
108
  (
109
109
  int quoteGasLimit,
@@ -114,18 +114,21 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
114
114
  int confirmations,
115
115
  int isValid
116
116
  ) = lz::UlnSendConfig::resolveUlnSendConfig(
117
- $ulnSendMd.cl::get<objRef>(md::UlnSend::customUlnSendConfig),
118
- $storage.cl::get<objRef>(Uln::defaultUlnSendConfig)
117
+ $customUlnSendConfig,
118
+ $defaultUlnSendConfig
119
119
  );
120
120
 
121
121
  ifnot (isValid) {
122
- return md::MdAddress::New(
123
- _failedMsglibSendCallback($lzSend),
124
- ownerAddress
125
- );
122
+ return _failedMsglibSendCallback($lzSend);
126
123
  }
127
124
 
128
- int messageBytes = lz::Packet::_messageBytes($lzSend.cl::get<objRef>(md::LzSend::packet));
125
+ (
126
+ cell $packet,
127
+ cell $extraOptions,
128
+ cell $enforcedOptions
129
+ ) = $lzSend.md::LzSend::getQuoteInformation();
130
+
131
+ int messageBytes = lz::Packet::_messageBytes($packet);
129
132
 
130
133
  tuple returnStack = unsafeTuple([null()]);
131
134
 
@@ -139,8 +142,8 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
139
142
  optionalDVNs,
140
143
  confirmations,
141
144
  messageBytes,
142
- $lzSend.cl::get<objRef>(md::LzSend::extraOptions),
143
- $lzSend.cl::get<objRef>(md::LzSend::enforcedOptions)
145
+ $extraOptions,
146
+ $enforcedOptions
144
147
  ]),
145
148
  _quoteWorkersMethodId,
146
149
  1,
@@ -151,16 +154,10 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
151
154
 
152
155
  cell $msglibSendCallback = returnStack.cell_at(0);
153
156
  ifnot ($msglibSendCallback.is_cell()) {
154
- return md::MdAddress::New(
155
- _failedMsglibSendCallback($lzSend),
156
- ownerAddress
157
- );
157
+ return _failedMsglibSendCallback($lzSend);
158
158
  }
159
159
 
160
- return md::MdAddress::New(
161
- $msglibSendCallback,
162
- ownerAddress
163
- );
160
+ return $msglibSendCallback;
164
161
  }
165
162
 
166
163
  ;; caller is responsible for asserting the worker exists
@@ -183,23 +180,22 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
183
180
  cell $extraOptions,
184
181
  cell $enforcedOptions
185
182
  ) impure inline_ref method_id {
186
- (cell $workerInfo, int workerExists) = $storage.cl::nestedDict256::get<cellRef>(
187
- Uln::workerFeelibInfos,
188
- workerAddress
189
- );
183
+ cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
184
+
185
+ (cell $workerInfo, int workerExists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
190
186
  ifnot (workerExists) {
191
187
  return (-1, null());
192
188
  }
193
189
 
190
+ ( int friendWorkerAddress,
191
+ cell $workerFeelibStorage,
192
+ cell workerFeelibBytecode
193
+ ) = $workerInfo.UlnWorkerFeelibInfo::getQuoteWorkerInformation();
194
+
194
195
  (cell $friendInfo, int friendExists) = ($workerInfo, true);
195
- int friendWorkerAddress = $workerInfo
196
- .cl::get<address>(UlnWorkerFeelibInfo::friendWorkerAddress);
197
196
 
198
197
  ifnot (friendWorkerAddress == NULLADDRESS) {
199
- ($friendInfo, friendExists) = $storage.cl::nestedDict256::get<cellRef>(
200
- Uln::workerFeelibInfos,
201
- friendWorkerAddress
202
- );
198
+ ($friendInfo, friendExists) = $workerFeelibInfos.cl::dict256::get<cellRef>(friendWorkerAddress);
203
199
  }
204
200
  ifnot (friendExists) {
205
201
  return (-1, null());
@@ -208,7 +204,7 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
208
204
  tuple returnStack = safePackedInputsRunVm(
209
205
  unsafeTuple(
210
206
  [
211
- $workerInfo.cl::get<objRef>(UlnWorkerFeelibInfo::workerFeelibStorage),
207
+ $workerFeelibStorage,
212
208
  $friendInfo,
213
209
  $path,
214
210
  confirmations,
@@ -219,7 +215,7 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
219
215
  ),
220
216
  UlnWorkerInterface::quote,
221
217
  1,
222
- $workerInfo.cl::get<cellRef>(UlnWorkerFeelibInfo::workerFeelibBytecode).begin_parse(),
218
+ workerFeelibBytecode.begin_parse(),
223
219
  MAX_U32 ;; gas limit doesn't matter for the inner call
224
220
  );
225
221
 
@@ -267,8 +263,8 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
267
263
  slice requiredDVNs = requiredDVNsCell.begin_parse();
268
264
  slice optionalDVNs = optionalDVNsCell.begin_parse();
269
265
 
270
- cell $packet = $lzSend.cl::get<objRef>(md::LzSend::packet);
271
- cell $path = $packet.cl::get<cellRef>(lz::Packet::path);
266
+ cell $packet = $lzSend.md::LzSend::getPacket();
267
+ cell $path = $packet.lz::Packet::getPath();
272
268
 
273
269
  tuple payeesInfo = empty_tuple();
274
270
  tuple workerEvents = UlnWorkerFeelibEventsBuilder::create();
@@ -319,7 +315,7 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
319
315
  }
320
316
 
321
317
  ;; create the dvnPaidEvent
322
- cell $dvnsFeesPaidEvent = DvnFeesPaidEvent::New(
318
+ cell $dvnsFeesPaidEvent = DvnFeesPaidEvent::build(
323
319
  requiredDVNsCell,
324
320
  optionalDVNsCell,
325
321
  serializePayees(payeesInfo)
@@ -348,18 +344,16 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
348
344
  .UlnWorkerFeelibEventsBuilder::push(executor, eventBody);
349
345
 
350
346
  ;; create the executorPaidEvent
351
- cell $executorFeePaidEvent = ExecutorFeePaidEvent::New(executor, executorFee);
347
+ cell $executorFeePaidEvent = ExecutorFeePaidEvent::build(executor, executorFee);
352
348
 
353
349
  ;; Handle treasury fee
354
- int treasuryFee = totalNativeFee * $storage.cl::get<uint16>(Uln::treasuryFeeBps) / 10000;
350
+ (int owner, int treasuryFeeBps) = $storage.Uln::getQuoteWorkersInformation();
351
+ int treasuryFee = totalNativeFee * treasuryFeeBps / 10000;
355
352
  payeesInfo = payeesInfo.tpush(
356
- unsafeTuple([
357
- $storage.cl::get<objRef>(BASE_STORAGE_INDEX).cl::get<address>(BaseStorage::owner),
358
- treasuryFee
359
- ])
353
+ unsafeTuple([owner, treasuryFee])
360
354
  );
361
355
 
362
- cell ret = md::MsglibSendCallback::New(
356
+ cell ret = md::MsglibSendCallback::build(
363
357
  totalNativeFee + treasuryFee,
364
358
  0,
365
359
  $lzSend,
@@ -369,7 +363,7 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
369
363
  PacketV1::nonceBytes,
370
364
  PacketV1::guidOffsetBytes,
371
365
  PacketV1::guidBytes,
372
- UlnEvents::New(
366
+ UlnEvents::build(
373
367
  UlnWorkerFeelibEvents::FromBuilder(workerEvents),
374
368
  $dvnsFeesPaidEvent,
375
369
  $executorFeePaidEvent
@@ -418,7 +412,7 @@ tuple ulnQuote(cell $ulnSendMd) impure inline method_id {
418
412
  (cell $storage, tuple actions) = preamble();
419
413
 
420
414
  actions~pushAction<call>(
421
- $ulnSendMd.cl::get<address>(md::UlnSend::forwardingAddress),
415
+ $ulnSendMd.md::UlnSend::getForwardingAddress(),
422
416
  Msglib::OP::RETURN_QUOTE,
423
417
  _quote($ulnSendMd, $storage)
424
418
  );
@@ -430,7 +424,7 @@ tuple ulnSend(cell $ulnSendMd) impure inline method_id {
430
424
  (cell $storage, tuple actions) = preamble();
431
425
 
432
426
  actions~pushAction<call>(
433
- $ulnSendMd.cl::get<address>(md::UlnSend::forwardingAddress),
427
+ $ulnSendMd.md::UlnSend::getForwardingAddress(),
434
428
  Channel::OP::MSGLIB_SEND_CALLBACK,
435
429
  _quote($ulnSendMd, $storage)
436
430
  );
@@ -446,12 +440,14 @@ tuple ulnSend(cell $ulnSendMd) impure inline method_id {
446
440
  tuple ulnCommitPacket(cell $mdAddress) impure inline method_id {
447
441
  (cell $storage, tuple actions) = preamble();
448
442
 
443
+ (cell $packet, int ulnConnectionAddress) = $mdAddress.md::MdAddress::deserialize();
444
+
449
445
  actions~pushAction<call>(
450
- $mdAddress.cl::get<address>(md::MdAddress::address),
446
+ ulnConnectionAddress,
451
447
  UlnConnection::OP::ULN_CONNECTION_COMMIT_PACKET,
452
- md::MdObj::New(
453
- $mdAddress.cl::get<objRef>(md::MdAddress::md),
454
- $storage.cl::get<objRef>(Uln::defaultUlnReceiveConfig)
448
+ md::MdObj::build(
449
+ $packet,
450
+ $storage.Uln::getDefaultUlnReceiveConfig()
455
451
  )
456
452
  );
457
453
 
@@ -468,12 +464,14 @@ tuple ulnCommitPacket(cell $mdAddress) impure inline method_id {
468
464
  tuple ulnVerify(cell $mdAddress) impure inline method_id {
469
465
  (cell $storage, tuple actions) = preamble();
470
466
 
467
+ (cell $md, int ulnConnectionAddress) = md::MdAddress::deserialize($mdAddress);
468
+
471
469
  actions~pushAction<call>(
472
- $mdAddress.cl::get<address>(md::MdAddress::address),
470
+ ulnConnectionAddress,
473
471
  UlnConnection::OP::ULN_CONNECTION_VERIFY,
474
- md::ExtendedMd::New(
475
- $mdAddress.cl::get<objRef>(md::MdAddress::md),
476
- $storage.cl::get<objRef>(Uln::defaultUlnReceiveConfig),
472
+ md::ExtendedMd::build(
473
+ $md,
474
+ $storage.Uln::getDefaultUlnReceiveConfig(),
477
475
  getCaller()
478
476
  )
479
477
  );
@@ -481,28 +479,26 @@ tuple ulnVerify(cell $mdAddress) impure inline method_id {
481
479
  return actions;
482
480
  }
483
481
 
484
- () _setWorkerInfo(cell $workerFeelibInfo) impure inline_ref {
482
+ () _setWorkerInfo(cell $workerFeelibInfos, cell $workerInfo) impure inline_ref {
485
483
  cell $storage = getContractStorage();
486
- int workerAddress = $workerFeelibInfo.cl::get<address>(UlnWorkerFeelibInfo::workerAddress);
484
+ int workerAddress = $workerInfo.UlnWorkerFeelibInfo::getWorkerAddress();
487
485
 
488
486
  ;; Restrict the size of the new storage to prevent DoS of our contract storage.
489
487
  ;; The total worker bytecode size is capped by UlnManager::CONST::MAX_CUMULATIVE_BYTECODE_CELLS
490
488
  ;; and enforced by the UlnManager, so here the only thing we need to check is the storage size
491
489
  ;; of the workers, excluding their bytecode
492
490
  (_, _, _, int success) = compute_data_size?(
493
- $workerFeelibInfo.cl::set(UlnWorkerFeelibInfo::workerFeelibBytecode, empty_cell()),
491
+ $workerInfo.UlnWorkerFeelibInfo::setWorkerFeeLibBytecode(empty_cell()),
494
492
  Uln::WorkerFeelibInfo::MaxCells
495
493
  );
496
494
 
497
495
  throw_unless(Uln::ERROR::invalidWorkerStorage, success);
498
496
 
499
497
  setContractStorage(
500
- $storage
501
- .cl::nestedDict256::setRef(
502
- Uln::workerFeelibInfos,
503
- workerAddress,
504
- $workerFeelibInfo
505
- )
498
+ $storage.Uln::updateWorkerFeelibInfos(
499
+ workerAddress,
500
+ $workerInfo
501
+ )
506
502
  );
507
503
  }
508
504
 
@@ -510,11 +506,9 @@ tuple updateWorkerFeelib(cell $UlnWorkerFeelibInfo) impure inline method_id {
510
506
  (cell $storage, tuple actions) = preamble();
511
507
  int workerAddress = $UlnWorkerFeelibInfo.cl::get<address>(UlnWorkerFeelibInfo::workerAddress);
512
508
 
513
- (cell $existingWorkerFeelibInfo, int exists) = cl::nestedDict256::get<cellRef>(
514
- $storage,
515
- Uln::workerFeelibInfos,
516
- workerAddress
517
- );
509
+ cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
510
+
511
+ (cell $existingWorkerFeelibInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
518
512
 
519
513
  ifnot (exists) {
520
514
  int isAdmin = $UlnWorkerFeelibInfo.cl::get<bool>(UlnWorkerFeelibInfo::isAdmin);
@@ -564,7 +558,7 @@ tuple updateWorkerFeelib(cell $UlnWorkerFeelibInfo) impure inline method_id {
564
558
  );
565
559
  }
566
560
 
567
- _setWorkerInfo($UlnWorkerFeelibInfo);
561
+ _setWorkerInfo($workerFeelibInfos, $UlnWorkerFeelibInfo);
568
562
 
569
563
  actions~pushAction<event>(
570
564
  Uln::event::ULN_WORKER_REGISTERED,
@@ -601,31 +595,17 @@ tuple deregisterWorkerFeelib(cell $empty) impure inline method_id {
601
595
  tuple setWorkerFeelibStorage(cell $newStorage) impure inline method_id {
602
596
  (cell $storage, tuple actions) = preamble();
603
597
 
604
- int workerAddress = getCaller();
598
+ cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
605
599
 
606
- (cell $workerInfo, int exists) = $storage.cl::nestedDict256::get<cellRef>(
607
- Uln::workerFeelibInfos,
608
- workerAddress
609
- );
600
+ int workerAddress = getCaller();
610
601
 
602
+ (cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
611
603
  throw_unless(Uln::ERROR::nonexistentWorker, exists);
612
604
 
613
- cell $updatedWorkerInfo = $workerInfo.cl::set(
614
- UlnWorkerFeelibInfo::workerFeelibStorage,
615
- $newStorage
616
- );
605
+ cell $updatedWorkerInfo = $workerInfo
606
+ .UlnWorkerFeelibInfo::setWorkerFeeLibStorage($newStorage);
617
607
 
618
- ;; _setWorkerInfo does size assertions on worker storage
619
- _setWorkerInfo($updatedWorkerInfo);
620
-
621
- setContractStorage(
622
- $storage
623
- .cl::nestedDict256::setRef(
624
- Uln::workerFeelibInfos,
625
- workerAddress,
626
- $updatedWorkerInfo
627
- )
628
- );
608
+ _setWorkerInfo($workerFeelibInfos, $updatedWorkerInfo);
629
609
 
630
610
  actions~pushAction<event>(
631
611
  Uln::event::ULN_WORKER_STORAGE_SET,
@@ -644,19 +624,18 @@ tuple setWorkerFeelibStorage(cell $newStorage) impure inline method_id {
644
624
  tuple refillWorkerRent(cell $rentRefill) {
645
625
  (cell $storage, tuple actions) = preamble();
646
626
 
627
+ cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
628
+
647
629
  int workerAddress = $rentRefill.cl::get<address>(md::RentRefill::address);
648
630
  int amount = $rentRefill.cl::get<coins>(md::RentRefill::amount);
649
- (cell $workerInfo, int exists) = cl::nestedDict256::get<cellRef>(
650
- $storage,
651
- Uln::workerFeelibInfos,
652
- workerAddress
653
- );
631
+ (cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
654
632
 
655
633
  throw_unless(Uln::ERROR::nonexistentWorker, exists);
656
634
 
657
635
  int currentRentBalance = $workerInfo.cl::get<coins>(UlnWorkerFeelibInfo::rentBalance);
658
636
 
659
637
  _setWorkerInfo(
638
+ $workerFeelibInfos,
660
639
  $workerInfo.cl::set(UlnWorkerFeelibInfo::rentBalance, currentRentBalance + amount)
661
640
  );
662
641
 
@@ -677,9 +656,9 @@ tuple refillWorkerRent(cell $rentRefill) {
677
656
  tuple collectWorkerRent(cell $setAddress) impure inline method_id {
678
657
  (cell $storage, tuple actions) = preamble();
679
658
 
680
- (cell $workerInfo, int exists) = cl::nestedDict256::get<cellRef>(
681
- $storage,
682
- Uln::workerFeelibInfos,
659
+ cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
660
+
661
+ (cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(
683
662
  $setAddress.cl::get<address>(md::SetAddress::address)
684
663
  );
685
664
 
@@ -704,7 +683,7 @@ tuple collectWorkerRent(cell $setAddress) impure inline method_id {
704
683
  .cl::set(UlnWorkerFeelibInfo::lastRentTimestamp, currentTimestamp);
705
684
 
706
685
  ;; update workerInfo in storage
707
- _setWorkerInfo($workerInfo);
686
+ _setWorkerInfo($workerFeelibInfos, $workerInfo);
708
687
 
709
688
  actions~pushAction<event>(
710
689
  Uln::event::ULN_COLLECT_WORKER_RENT,
@@ -795,7 +774,7 @@ tuple garbageCollectInvalidAttestations(cell $mdAddress) impure inline method_id
795
774
  actions~pushAction<call>(
796
775
  $mdAddress.cl::get<address>(md::MdAddress::address),
797
776
  UlnConnection::OP::GARBAGE_COLLECT_INVALID_ATTESTATIONS,
798
- md::MdObj::New(
777
+ md::MdObj::build(
799
778
  $mdAddress.cl::get<objRef>(md::MdAddress::md),
800
779
  $storage.cl::get<objRef>(Uln::defaultUlnReceiveConfig)
801
780
  )
@@ -804,8 +783,6 @@ tuple garbageCollectInvalidAttestations(cell $mdAddress) impure inline method_id
804
783
  return actions;
805
784
  }
806
785
 
807
- ;; todo-thomas: I'm not sure if we can read tensors (or tuples for that matter)
808
- ;; from the view functions using the RPC call, maybe it should be one integer?
809
786
  (int, int, int) version() impure method_id {
810
787
  return (3, 0, 2);
811
788
  }
@@ -40,4 +40,80 @@ cell Uln::New(int owner, int eid, int dstEid) method_id {
40
40
  [cl::t::uint16, 0] ;; Uln::remainingAdminWorkerSlots
41
41
  ])
42
42
  );
43
- }
43
+ }
44
+
45
+ ;; ============================== Object Getters ==============================
46
+
47
+ const int Uln::_eidOffset = _HEADER_WIDTH;
48
+ const int Uln::_dstEidOffset = Uln::_eidOffset + 32;
49
+ const int Uln::_treasuryFeeBpsOffset = Uln::_dstEidOffset + 32;
50
+ const int Uln::_remainingWorkerSlotsOffset = Uln::_treasuryFeeBpsOffset + 16;
51
+ const int Uln::_remainingAdminWorkerSlotsOffset = Uln::_remainingWorkerSlotsOffset + 16;
52
+ const int Uln::_sliceBits = Uln::_remainingAdminWorkerSlotsOffset + 16;
53
+
54
+ cell Uln::getDefaultUlnReceiveConfig(cell $self) impure inline {
55
+ return $self.cellPreloadRefAt(1);
56
+ }
57
+
58
+ cell Uln::getConnectionCode(cell $self) impure inline {
59
+ return $self.cellPreloadRefAt(2).cellPreloadRefAt(1);
60
+ }
61
+
62
+ cell Uln::getWorkerFeelibInfos(cell $self) impure inline {
63
+ return $self.cellPreloadRefAt(2).cellPreloadRefAt(2);
64
+ }
65
+
66
+ ;; ============================== Object Multi-Getters ==============================
67
+
68
+ ;; (owner, defaultUlnSendConfig)
69
+ cell Uln::getDefaultUlnSendConfig(cell $self) impure inline {
70
+ slice selfSlice = $self.begin_parse();
71
+ return selfSlice.preloadRefAt(2).cellPreloadRefAt(0); ;; defaultUlnSendConfig
72
+ }
73
+
74
+ ;; (treasuryFeeBps, owner)
75
+ (int, int) Uln::getQuoteWorkersInformation(cell $self) impure inline {
76
+ slice selfSlice = $self.begin_parse();
77
+ return (
78
+ selfSlice.preloadRefAt(0).BaseStorage::getOwner(), ;; baseStorage.Owner
79
+ selfSlice.preloadUint16At(Uln::_treasuryFeeBpsOffset) ;; treasuryFeeBps
80
+ );
81
+ }
82
+
83
+ ;; ============================== Object Setters ==============================
84
+
85
+ cell Uln::setWorkerFeelibInfos(cell $self, cell $workerFeelibInfos) impure inline {
86
+ slice selfSlice = $self.begin_parse();
87
+
88
+ slice ref2_slice = selfSlice.preloadRefSliceAt(2);
89
+ cell new_ref2 = begin_cell()
90
+ .store_slice(ref2_slice.scutfirst(0, 2))
91
+ .store_ref($workerFeelibInfos)
92
+ .end_cell();
93
+
94
+ return begin_cell()
95
+ .store_slice(selfSlice.scutfirst(Uln::_sliceBits, 2))
96
+ .store_ref(new_ref2)
97
+ .end_cell();
98
+ }
99
+
100
+ ;; updates the worker feelib info for the given [worker address, new worker feelib info]
101
+ ;; and returns the new storage
102
+ cell Uln::updateWorkerFeelibInfos(cell $self, int workerAddress, cell $workerFeelibInfo) impure inline {
103
+ slice selfSlice = $self.begin_parse();
104
+
105
+ slice ref2_slice = selfSlice.preloadRefSliceAt(2);
106
+ cell $workerFeelibInfos = ref2_slice
107
+ .preloadRefAt(2)
108
+ .cl::dict256::setRef(workerAddress, $workerFeelibInfo);
109
+
110
+ cell new_ref2 = begin_cell()
111
+ .store_slice(ref2_slice.scutfirst(0, 2))
112
+ .store_ref($workerFeelibInfos)
113
+ .end_cell();
114
+
115
+ return begin_cell()
116
+ .store_slice(selfSlice.scutfirst(Uln::_sliceBits, 2))
117
+ .store_ref(new_ref2)
118
+ .end_cell();
119
+ }