@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
@@ -57,7 +57,8 @@ int _getEventSink() impure inline {
57
57
  }
58
58
 
59
59
  () _assertOAppPath(cell $mdObj) impure inline {
60
- cell $path = $mdObj.cl::get<objRef>(md::MdObj::obj);
60
+ cell $sanitizedMdObj = $mdObj.md::MdObj::sanitize();
61
+ cell $path = $sanitizedMdObj.cl::get<objRef>(md::MdObj::obj);
61
62
  cell $sanitizedPath = lz::Path::sanitize($path);
62
63
  throw_unless(
63
64
  UlnManager::ERROR::invalidPath,
@@ -164,8 +165,9 @@ int _calculateUlnConnectionAddress(cell $storage, cell $path) impure inline meth
164
165
  ;; @out_actions deploy the uln for this particular eid
165
166
  tuple deployUln(cell $deploy) impure inline method_id {
166
167
  (cell $storage, tuple actions) = preamble();
168
+ cell $sanitizedDeploy = $deploy.md::Deploy::NewWithExtraInfo::sanitize();
167
169
 
168
- int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
170
+ int dstEid = $sanitizedDeploy.cl::get<uint32>(md::Deploy::dstEid);
169
171
  throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
170
172
 
171
173
  actions~pushAction<deployAndCall>(
@@ -175,9 +177,9 @@ tuple deployUln(cell $deploy) impure inline method_id {
175
177
  $storage.cl::get<uint32>(UlnManager::eid),
176
178
  dstEid
177
179
  ),
178
- $deploy.cl::get<coins>(md::Deploy::initialDeposit),
180
+ $sanitizedDeploy.cl::get<coins>(md::Deploy::initialDeposit),
179
181
  BaseInterface::OP::INITIALIZE,
180
- $deploy.cl::get<objRef>(md::Deploy::extraInfo).cl::set(
182
+ $sanitizedDeploy.cl::get<objRef>(md::Deploy::extraInfo).cl::set(
181
183
  md::InitUln::connectionCode,
182
184
  $storage.cl::get<cellRef>(UlnManager::ulnConnectionCode)
183
185
  ),
@@ -192,8 +194,9 @@ tuple deployUln(cell $deploy) impure inline method_id {
192
194
  ;; @out_actions deploy the connection for this particular oApp path
193
195
  tuple deployUlnConnection(cell $deploy) impure inline method_id {
194
196
  (cell $storage, tuple actions) = preamble();
197
+ cell $sanitizedDeploy = $deploy.md::Deploy::NewWithExtraInfo::sanitize();
195
198
 
196
- int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
199
+ int dstEid = $sanitizedDeploy.cl::get<uint32>(md::Deploy::dstEid);
197
200
 
198
201
  throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
199
202
 
@@ -201,7 +204,7 @@ tuple deployUlnConnection(cell $deploy) impure inline method_id {
201
204
  $storage.cl::get<uint32>(UlnManager::eid),
202
205
  getCaller(),
203
206
  dstEid,
204
- $deploy.cl::get<address>(md::Deploy::dstOApp)
207
+ $sanitizedDeploy.cl::get<address>(md::Deploy::dstOApp)
205
208
  );
206
209
 
207
210
  cell $ulnConnection = UlnConnection::New(
@@ -210,26 +213,27 @@ tuple deployUlnConnection(cell $deploy) impure inline method_id {
210
213
  _calculateUlnAddress($storage, dstEid)
211
214
  );
212
215
 
213
- cell $initUlnConnection = $deploy.cl::get<objRef>(md::Deploy::extraInfo)
216
+ cell $initUlnConnection = $sanitizedDeploy.cl::get<objRef>(md::Deploy::extraInfo)
214
217
  .cl::set(md::InitUlnConnection::endpointAddress, _calculateEndpointAddress($storage, dstEid))
215
218
  .cl::set(md::InitUlnConnection::channelAddress, _calculateChannelAddress($storage, $path));
216
219
 
217
220
  actions~pushAction<deployAndCall>(
218
221
  $storage.cl::get<cellRef>(UlnManager::ulnConnectionCode),
219
222
  $ulnConnection,
220
- $deploy.cl::get<coins>(md::Deploy::initialDeposit),
223
+ $sanitizedDeploy.cl::get<coins>(md::Deploy::initialDeposit),
221
224
  BaseInterface::OP::INITIALIZE,
222
- InitUlnConnection::sanitize($initUlnConnection),
225
+ md::InitUlnConnection::sanitize($initUlnConnection),
223
226
  0
224
227
  );
225
228
 
226
229
  return actions;
227
230
  }
228
231
 
229
- tuple getMsglibInfo(cell $addMsglibMd) impure inline method_id {
232
+ tuple getMsglibInfo(cell $addMsglib) impure inline method_id {
230
233
  (cell $storage, tuple actions) = preamble();
234
+ cell $sanitizedAddMsglib = $addMsglib.md::AddMsglib::sanitize();
231
235
 
232
- int dstEid = $addMsglibMd.cl::get<uint32>(md::AddMsglib::dstEid);
236
+ int dstEid = $sanitizedAddMsglib.cl::get<uint32>(md::AddMsglib::dstEid);
233
237
  throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
234
238
 
235
239
  int ulnAddress = _calculateUlnAddress(
@@ -260,10 +264,12 @@ tuple getMsglibInfo(cell $addMsglibMd) impure inline method_id {
260
264
  ;; @in_opcode UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG
261
265
  tuple setDefaultUlnSendConfig(cell $mdEid) impure inline method_id {
262
266
  (cell $storage, tuple actions) = preamble();
263
- cell $UlnSendConfig = $mdEid.cl::get<objRef>(md::MdEid::md);
267
+ cell $sanitizedMdEid = $mdEid.md::MdEid::sanitize();
268
+
269
+ cell $UlnSendConfig = $sanitizedMdEid.cl::get<objRef>(md::MdEid::md);
264
270
 
265
271
  actions~pushAction<call>(
266
- _calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid)),
272
+ _calculateUlnAddress($storage, $sanitizedMdEid.cl::get<uint32>(md::MdEid::eid)),
267
273
  Uln::OP::SET_DEFAULT_ULN_SEND_CONFIG,
268
274
  $UlnSendConfig
269
275
  );
@@ -274,10 +280,12 @@ tuple setDefaultUlnSendConfig(cell $mdEid) impure inline method_id {
274
280
  ;; @in_opcode UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG
275
281
  tuple setDefaultUlnReceiveConfig(cell $mdEid) impure inline method_id {
276
282
  (cell $storage, tuple actions) = preamble();
277
- cell $UlnReceiveConfig = $mdEid.cl::get<objRef>(md::MdEid::md);
283
+ cell $sanitizedMdEid = $mdEid.md::MdEid::sanitize();
284
+
285
+ cell $UlnReceiveConfig = $sanitizedMdEid.cl::get<objRef>(md::MdEid::md);
278
286
 
279
287
  actions~pushAction<call>(
280
- _calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid)),
288
+ _calculateUlnAddress($storage, $sanitizedMdEid.cl::get<uint32>(md::MdEid::eid)),
281
289
  Uln::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG,
282
290
  $UlnReceiveConfig
283
291
  );
@@ -288,13 +296,16 @@ tuple setDefaultUlnReceiveConfig(cell $mdEid) impure inline method_id {
288
296
  ;; @in_opcode UlnManager::OP::SET_CONNECTION_ULN_CONFIG
289
297
  tuple setOAppUlnReceiveConfig(cell $mdObj) impure inline method_id {
290
298
  (cell $storage, tuple actions) = preamble();
299
+ cell $sanitizedMdObj = $mdObj.md::MdObj::sanitize();
291
300
 
292
- cell $sendPath = $mdObj.cl::get<objRef>(md::MdObj::obj);
301
+ cell $sendPath = $sanitizedMdObj
302
+ .cl::get<objRef>(md::MdObj::obj)
303
+ .lz::Path::sanitize();
293
304
 
294
305
  actions~pushAction<call>(
295
306
  _calculateUlnConnectionAddress($storage, $sendPath),
296
307
  UlnConnection::OP::SET_OAPP_ULN_RECEIVE_CONFIG,
297
- $mdObj.cl::get<objRef>(md::MdObj::md)
308
+ $sanitizedMdObj.cl::get<objRef>(md::MdObj::md)
298
309
  );
299
310
 
300
311
  return actions;
@@ -303,13 +314,16 @@ tuple setOAppUlnReceiveConfig(cell $mdObj) impure inline method_id {
303
314
  ;; @in_opcode UlnManager::OP::SET_CONNECTION_ULN_CONFIG
304
315
  tuple setOAppUlnSendConfig(cell $mdObj) impure inline method_id {
305
316
  (cell $storage, tuple actions) = preamble();
306
-
307
- cell $sendPath = $mdObj.cl::get<objRef>(md::MdObj::obj);
317
+ cell $sanitizedMdObj = $mdObj.md::MdObj::sanitize();
318
+
319
+ cell $sendPath = $sanitizedMdObj
320
+ .cl::get<objRef>(md::MdObj::obj)
321
+ .lz::Path::sanitize();
308
322
 
309
323
  actions~pushAction<call>(
310
324
  _calculateUlnConnectionAddress($storage, $sendPath),
311
325
  UlnConnection::OP::SET_OAPP_ULN_SEND_CONFIG,
312
- $mdObj.cl::get<objRef>(md::MdObj::md)
326
+ $sanitizedMdObj.cl::get<objRef>(md::MdObj::md)
313
327
  );
314
328
 
315
329
  return actions;
@@ -319,7 +333,10 @@ tuple setOAppUlnSendConfig(cell $mdObj) impure inline method_id {
319
333
  tuple registerWorkerFeelibBytecode(cell $ulnWorkerFeelibBytecode) impure inline method_id {
320
334
  (cell $storage, tuple actions) = preamble();
321
335
 
322
- cell bytecode = $ulnWorkerFeelibBytecode
336
+ cell $sanitizedUlnWorkerFeelibBytecode = $ulnWorkerFeelibBytecode
337
+ .md::UlnWorkerFeelibBytecode::sanitize();
338
+
339
+ cell bytecode = $sanitizedUlnWorkerFeelibBytecode
323
340
  .cl::get<cellRef>(md::UlnWorkerFeelibBytecode::bytecode);
324
341
 
325
342
  cell $newStorage = $storage
@@ -344,9 +361,10 @@ tuple registerWorkerFeelibBytecode(cell $ulnWorkerFeelibBytecode) impure inline
344
361
  tuple addWorkerFeelibToUln(cell $UlnWorkerFeelibInfo) impure inline method_id {
345
362
  (cell $storage, tuple actions) = preamble();
346
363
 
347
- cell $sanitizedUlnWorkerFeelibInfo = UlnWorkerFeelibInfo::sanitize(
348
- $UlnWorkerFeelibInfo
349
- ).cl::set(UlnWorkerFeelibInfo::workerAddress, getCaller());
364
+ cell $sanitizedUlnWorkerFeelibInfo = $UlnWorkerFeelibInfo
365
+ .UlnWorkerFeelibInfo::sanitize()
366
+ .cl::set(UlnWorkerFeelibInfo::workerAddress, getCaller());
367
+
350
368
  ;; invariant: checkPermissions guarantees that getCaller() == $UlnWorkerFeelibInfo.workerAddress
351
369
  int bytecodeId = $sanitizedUlnWorkerFeelibInfo
352
370
  .cl::get<cellRef>(UlnWorkerFeelibInfo::workerFeelibBytecode)
@@ -383,7 +401,9 @@ tuple addWorkerFeelibToUln(cell $UlnWorkerFeelibInfo) impure inline method_id {
383
401
 
384
402
  tuple setAdminWorkers(cell $setAdminWorkerAddresses) impure inline method_id {
385
403
  (cell $storage, tuple actions) = preamble();
386
- cell adminWorkers = $setAdminWorkerAddresses
404
+ cell $sanitizedSetAdminWorkerAddresses = $setAdminWorkerAddresses.md::SetAdminWorkerAddresses::sanitize();
405
+
406
+ cell adminWorkers = $sanitizedSetAdminWorkerAddresses
387
407
  .cl::get<cellRef>(md::SetAdminWorkerAddresses::adminWorkers);
388
408
 
389
409
  throw_unless(
@@ -397,7 +417,7 @@ tuple setAdminWorkers(cell $setAdminWorkerAddresses) impure inline method_id {
397
417
 
398
418
  actions~pushAction<event>(
399
419
  UlnManager::event::ADMIN_WORKERS_SET,
400
- $setAdminWorkerAddresses
420
+ $sanitizedSetAdminWorkerAddresses
401
421
  );
402
422
 
403
423
  return actions;
@@ -405,8 +425,9 @@ tuple setAdminWorkers(cell $setAdminWorkerAddresses) impure inline method_id {
405
425
 
406
426
  tuple claimTreasuryFees(cell $coinsAmount) impure inline method_id {
407
427
  (cell $storage, tuple actions) = preamble();
428
+ cell $sanitizedCoinsAmount = $coinsAmount.md::CoinsAmount::sanitize();
408
429
 
409
- int claimAmount = $coinsAmount.cl::get<coins>(md::CoinsAmount::amount);
430
+ int claimAmount = $sanitizedCoinsAmount.cl::get<coins>(md::CoinsAmount::amount);
410
431
  (int myStateCellCount, int myStateBitCount) = getContractStateSize(
411
432
  my_code(),
412
433
  getContractStorage()
@@ -432,8 +453,10 @@ tuple claimTreasuryFees(cell $coinsAmount) impure inline method_id {
432
453
 
433
454
  tuple setUlnTreasuryFeeBps(cell $mdEid) impure inline method_id {
434
455
  (cell $storage, tuple actions) = preamble();
435
- int ulnAddress = _calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid));
436
- cell $treasuryFeeBps = $mdEid.cl::get<objRef>(md::MdAddress::md);
456
+ cell $sanitizedMdEid = $mdEid.md::MdEid::sanitize();
457
+
458
+ int ulnAddress = _calculateUlnAddress($storage, $sanitizedMdEid.cl::get<uint32>(md::MdEid::eid));
459
+ cell $treasuryFeeBps = $sanitizedMdEid.cl::get<objRef>(md::MdEid::md);
437
460
  actions~pushAction<call>(
438
461
  ulnAddress,
439
462
  Uln::OP::SET_TREASURY_FEE_BPS,
@@ -448,17 +471,18 @@ tuple setUlnTreasuryFeeBps(cell $mdEid) impure inline method_id {
448
471
  ;; claim, but nothing else. This effectively burns it.
449
472
  tuple transferOwnership(cell $setAddress) impure inline {
450
473
  (cell $storage, tuple actions) = preamble();
474
+ cell $sanitizedSetAddress = $setAddress.md::SetAddress::sanitize();
451
475
 
452
476
  setContractStorage(
453
477
  $storage.cl::set(
454
478
  UlnManager::tentativeOwner,
455
- $setAddress.cl::get<address>(md::SetAddress::address)
479
+ $sanitizedSetAddress.cl::get<address>(md::SetAddress::address)
456
480
  )
457
481
  );
458
482
 
459
483
  actions~pushAction<event>(
460
484
  UlnManager::event::OWNER_SET_TENTATIVE,
461
- $setAddress
485
+ $sanitizedSetAddress
462
486
  );
463
487
 
464
488
  return actions;
@@ -14,10 +14,11 @@ const int DvnFeelib::VERIFY_BYTES_ULN = 288;
14
14
 
15
15
  ;; just validate options
16
16
  () _decodeOption(cell $options) impure inline_ref {
17
+ int optionsType = cl::typeof($options);
17
18
  if (
18
- (cl::typeof($options) == md::OptionsV1::NAME)
19
- | (cl::typeof($options) == md::OptionsV2::NAME)
20
- | cl::isNullObject($options)
19
+ (optionsType == md::OptionsV1::NAME)
20
+ | (optionsType == md::OptionsV2::NAME)
21
+ | (optionsType == cl::NULL_CLASS_NAME)
21
22
  ) {
22
23
  return ();
23
24
  } else {
@@ -33,7 +34,7 @@ const int DvnFeelib::VERIFY_BYTES_ULN = 288;
33
34
  }
34
35
 
35
36
  int _getCallDataSize(cell $myStorage) impure inline_ref {
36
- int quorum = $myStorage.cl::get<uint64>(DvnFeelib::quorum);
37
+ int quorum = $myStorage.DvnFeelib::getQuorum();
37
38
 
38
39
  int totalSignatureBytes = DvnFeelib::SIGNATURE_RAW_BYTES * quorum;
39
40
  ;; align on 32-byte boundary
@@ -47,7 +48,7 @@ int _getCallDataSize(cell $myStorage) impure inline_ref {
47
48
  tuple ulnWorker::quote(tuple inputs) method_id {
48
49
  cell $myStorage = inputs.cell_at(0);
49
50
  cell $priceFeedInfo = inputs.cell_at(1);
50
- cell $priceFeedStorage = $priceFeedInfo.cl::get<objRef>(UlnWorkerFeelibInfo::workerFeelibStorage);
51
+ cell $priceFeedStorage = $priceFeedInfo.UlnWorkerFeelibInfo::getWorkerFeeLibStorage();
51
52
  ;; cell $path = inputs.cell_at(2);
52
53
  ;; int confirmations = inputs.int_at(3);
53
54
  ;; int packetBytes = inputs.int_at(4);
@@ -61,16 +62,19 @@ tuple ulnWorker::quote(tuple inputs) method_id {
61
62
  int gasPriceInUnit,
62
63
  int gasPerByte,
63
64
  int nativePriceUsd
64
- ) = PriceFeedFeelib::utils::deserializeStorage($priceFeedStorage);
65
+ ) = PriceFeedFeelib::deserialize($priceFeedStorage);
65
66
 
66
- int totalGas = $myStorage.cl::get<uint64>(DvnFeelib::gas) + (_getCallDataSize($myStorage) * gasPerByte);
67
+ (int gas, int multiplierBps, int floorMarginUSD) = DvnFeelib::getGasMultiplierBpsAndFloorMarginUSD($myStorage);
68
+
69
+ int totalGas = gas + (_getCallDataSize($myStorage) * gasPerByte);
67
70
  ;; the gas fee in units of remote gas token (e.g., WEI for ETH)
68
71
  int gasFeeInUnit = totalGas * gasPriceInUnit;
69
72
 
73
+
70
74
  int totalGasFee = _applyPremiumAndFloor(
71
75
  _remoteToNanoton(gasFeeInUnit, priceRatio),
72
- $myStorage.cl::get<uint16>(DvnFeelib::multiplierBps),
73
- $myStorage.cl::get<coins>(DvnFeelib::floorMarginUSD),
76
+ multiplierBps,
77
+ floorMarginUSD,
74
78
  nativePriceUsd
75
79
  );
76
80
 
@@ -1,4 +1,6 @@
1
1
  #include "../../../../../funC++/classlib.fc";
2
+ #include "../../../../../funC++/stdlib.fc";
3
+ #include "../../../../../funC++/utils.fc";
2
4
 
3
5
  const int DvnFeelib::NAME = "UlnDvnFl"u;
4
6
 
@@ -24,3 +26,24 @@ cell DvnFeelib::New(
24
26
  ])
25
27
  );
26
28
  }
29
+
30
+ ;; ============================== Object Getters ==============================
31
+
32
+ const int DvnFeeLib::_quorumOffset = _HEADER_WIDTH;
33
+ const int DvnFeeLib::_gasOffset = DvnFeeLib::_quorumOffset + 64;
34
+ const int DvnFeeLib::_multiplierBpsOffset = DvnFeeLib::_gasOffset + 64;
35
+ const int DvnFeeLib::_floorMarginUSDOffset = DvnFeeLib::_multiplierBpsOffset + 16;
36
+
37
+ int DvnFeelib::getQuorum(cell $self) impure inline {
38
+ return $self.cellPreloadUint64At(DvnFeeLib::_quorumOffset);
39
+ }
40
+
41
+ ;; (gas, multiplierBps, floorMarginUSD)
42
+ (int, int, int) DvnFeelib::getGasMultiplierBpsAndFloorMarginUSD(cell $self) impure inline {
43
+ slice selfSlice = $self.begin_parse();
44
+ return (
45
+ selfSlice.preloadUint64At(DvnFeeLib::_gasOffset),
46
+ selfSlice.preloadUint16At(DvnFeeLib::_multiplierBpsOffset),
47
+ selfSlice.preloadCoinsAt(DvnFeeLib::_floorMarginUSDOffset)
48
+ );
49
+ }
@@ -1,3 +1,4 @@
1
+ #include "../../../../../classes/lz/Path.fc";
1
2
  #include "../../../../../classes/msgdata/OptionsV1.fc";
2
3
  #include "../../../../../classes/msgdata/OptionsV2.fc";
3
4
 
@@ -8,35 +9,57 @@
8
9
  #include "../common.fc";
9
10
  #include "storage.fc";
10
11
 
11
- (int, int) _decodeOption(int lzReceiveBaseGas, int lzComposeBaseGas, cell $options) impure inline {
12
+ int isV1Eid(int eid) impure inline {
13
+ return (eid < 30000);
14
+ }
15
+
16
+ (int, int) _decodeOption(int lzReceiveBaseGas, int lzComposeBaseGas, cell $options, cell $path) impure inline {
12
17
  int totalGas = 0;
13
18
  int totalDstAmount = 0;
14
19
 
15
- if (cl::typeof($options) == md::OptionsV1::NAME) {
16
- totalGas += lzReceiveBaseGas
17
- + $options.cl::get<uint256>(md::OptionsV1::lzReceiveGas);
20
+ int optionsType = cl::typeof($options);
18
21
 
19
- totalDstAmount += $options.cl::get<uint256>(md::OptionsV1::lzReceiveValue)
20
- + $options.cl::get<uint256>(md::OptionsV1::nativeDropAmount);
21
- } elseif (cl::typeof($options) == md::OptionsV2::NAME) {
22
- int lzComposeGas = $options.cl::get<uint256>(md::OptionsV2::lzComposeGas);
23
- int lzComposeValue = $options.cl::get<uint256>(md::OptionsV2::lzComposeValue);
22
+ if (optionsType == md::OptionsV1::NAME) {
23
+ (
24
+ int lzReceiveGas,
25
+ int lzReceiveValue,
26
+ int nativeDropAmount
27
+ ) = $options.md::OptionsV1::decodeCoins();
28
+
29
+ ;; LayerZero V1 does not support value on lzReceive
30
+ throw_if(
31
+ UlnWorkerInterface::ERROR::INVALID_OPTIONS,
32
+ (lzReceiveValue > 0) & isV1Eid($path.lz::Path::getDstEid())
33
+ );
34
+
35
+ totalGas += lzReceiveBaseGas + lzReceiveGas;
36
+
37
+ totalDstAmount += lzReceiveValue + nativeDropAmount;
38
+
39
+ } elseif (optionsType == md::OptionsV2::NAME) {
40
+ (
41
+ int lzComposeGas,
42
+ int lzComposeValue,
43
+ int lzReceiveGas,
44
+ int lzReceiveValue,
45
+ int nativeDropAmount
46
+ ) = $options.md::OptionsV2::decodeCoins();
24
47
 
25
48
  throw_if(
26
49
  UlnWorkerInterface::ERROR::ZERO_LZ_COMPOSE_GAS_PROVIDED,
27
50
  (lzComposeGas == 0) & (lzComposeValue > 0)
28
51
  );
29
52
 
30
- totalGas += lzReceiveBaseGas + $options.cl::get<uint256>(md::OptionsV2::lzReceiveGas);
53
+ totalGas += lzReceiveBaseGas + lzReceiveGas;
31
54
 
32
- totalDstAmount += $options.cl::get<uint256>(md::OptionsV2::lzReceiveValue)
33
- + $options.cl::get<uint256>(md::OptionsV2::nativeDropAmount);
55
+ totalDstAmount += lzReceiveValue + nativeDropAmount;
34
56
 
35
57
  if (lzComposeGas > 0) {
36
58
  totalGas += lzComposeGas + lzComposeBaseGas;
37
59
  totalDstAmount += lzComposeValue;
38
60
  }
39
- } elseif (cl::isNullObject($options)) {
61
+
62
+ } elseif (optionsType == cl::NULL_CLASS_NAME) {
40
63
  return (0, 0);
41
64
  } else {
42
65
  throw(UlnWorkerInterface::ERROR::UNKNOWN_OPTIONS);
@@ -49,19 +72,31 @@
49
72
  int lzReceiveBaseGas,
50
73
  int lzComposeBaseGas,
51
74
  cell $extraOptions,
52
- cell $enforcedOptions
75
+ cell $enforcedOptions,
76
+ cell $path
53
77
  ) impure inline {
54
78
  int totalGas = 0;
55
79
  int totalDstAmount = 0;
56
80
 
57
81
  ifnot ($extraOptions.cl::isNullObject()) {
58
- (int _totalGas, int _totalDstAmount) = _decodeOption(lzReceiveBaseGas, lzComposeBaseGas, $extraOptions);
82
+ (int _totalGas, int _totalDstAmount) = _decodeOption(
83
+ lzReceiveBaseGas,
84
+ lzComposeBaseGas,
85
+ $extraOptions,
86
+ $path
87
+ );
88
+
59
89
  totalGas += _totalGas;
60
90
  totalDstAmount += _totalDstAmount;
61
91
  }
62
92
 
63
93
  ifnot ($enforcedOptions.cl::isNullObject()) {
64
- (int _totalGas, int _totalDstAmount) = _decodeOption(lzReceiveBaseGas, lzComposeBaseGas, $enforcedOptions);
94
+ (int _totalGas, int _totalDstAmount) = _decodeOption(
95
+ lzReceiveBaseGas,
96
+ lzComposeBaseGas,
97
+ $enforcedOptions,
98
+ $path
99
+ );
65
100
  totalGas += _totalGas;
66
101
  totalDstAmount += _totalDstAmount;
67
102
  }
@@ -73,31 +108,32 @@
73
108
  tuple ulnWorker::quote(tuple inputs) impure method_id {
74
109
  cell $myStorage = inputs.cell_at(0);
75
110
  cell $priceFeedInfo = inputs.cell_at(1);
76
- cell $priceFeedStorage = $priceFeedInfo.cl::get<objRef>(UlnWorkerFeelibInfo::workerFeelibStorage);
77
- ;; cell $path = inputs.cell_at(2);
111
+ cell $priceFeedStorage = $priceFeedInfo.UlnWorkerFeelibInfo::getWorkerFeeLibStorage();
112
+ cell $path = inputs.cell_at(2);
78
113
  ;; int confirmations = inputs.int_at(3);
79
114
  int packetBytes = inputs.int_at(4);
80
115
  cell $extraOptions = inputs.cell_at(5);
81
116
  cell $enforcedOptions = inputs.cell_at(6);
82
117
 
83
- int multiplierBps = $myStorage.cl::get<uint16>(ExecutorFeelib::multiplierBps);
118
+ (
119
+ int lzReceiveBaseGas,
120
+ int multiplierBps,
121
+ int floorMarginUSD,
122
+ _,
123
+ int lzComposeBaseGas
124
+ ) = ExecutorFeelib::deserializeStorage($myStorage);
84
125
 
85
126
  (
86
127
  int totalRemoteGas,
87
128
  int totalRemoteValue
88
- ) = _decodeOptions(
89
- $myStorage.cl::get<uint64>(ExecutorFeelib::lzReceiveBaseGas),
90
- $myStorage.cl::get<uint64>(ExecutorFeelib::lzComposeBaseGas),
91
- $extraOptions,
92
- $enforcedOptions
93
- );
129
+ ) = _decodeOptions(lzReceiveBaseGas, lzComposeBaseGas, $extraOptions, $enforcedOptions, $path);
94
130
 
95
131
  (
96
132
  int priceRatio,
97
133
  int gasPriceInUnit,
98
134
  int gasPerByte,
99
135
  int nativePriceUsd
100
- ) = PriceFeedFeelib::utils::deserializeStorage($priceFeedStorage);
136
+ ) = PriceFeedFeelib::deserialize($priceFeedStorage);
101
137
 
102
138
  ;; simple calculation of gas per byte
103
139
  int gasForCalldata = packetBytes * gasPerByte;
@@ -107,7 +143,7 @@ tuple ulnWorker::quote(tuple inputs) impure method_id {
107
143
  int totalGasFeeInNanoton = _applyPremiumAndFloor(
108
144
  _remoteToNanoton(totalGasFeeInUnit, priceRatio),
109
145
  multiplierBps,
110
- $myStorage.cl::get<coins>(ExecutorFeelib::floorMarginUSD),
146
+ floorMarginUSD,
111
147
  nativePriceUsd
112
148
  );
113
149
 
@@ -27,3 +27,22 @@ cell ExecutorFeelib::New(
27
27
  ])
28
28
  );
29
29
  }
30
+
31
+ ;; ============================== Object Getters =========================================
32
+
33
+ const int ExecutorFeelib::_lzReceiveBaseGasOffset = _HEADER_WIDTH;
34
+ const int ExecutorFeelib::_multiplierBpsOffset = ExecutorFeelib::_lzReceiveBaseGasOffset + 64;
35
+ const int ExecutorFeelib::_floorMarginUSDOffset = ExecutorFeelib::_multiplierBpsOffset + 16;
36
+ const int ExecutorFeelib::_nativeCapOffset = ExecutorFeelib::_floorMarginUSDOffset + 128;
37
+ const int ExecutorFeelib::_lzComposeBaseGasOffset = ExecutorFeelib::_nativeCapOffset + 128;
38
+
39
+ (int, int, int, int, int) ExecutorFeelib::deserializeStorage(cell $storage) impure inline {
40
+ slice selfSlice = $storage.begin_parse();
41
+ return (
42
+ selfSlice.preloadUint64At(ExecutorFeelib::_lzReceiveBaseGasOffset),
43
+ selfSlice.preloadUint16At(ExecutorFeelib::_multiplierBpsOffset),
44
+ selfSlice.preloadCoinsAt(ExecutorFeelib::_floorMarginUSDOffset),
45
+ selfSlice.preloadCoinsAt(ExecutorFeelib::_nativeCapOffset),
46
+ selfSlice.preloadUint64At(ExecutorFeelib::_lzComposeBaseGasOffset)
47
+ );
48
+ }
@@ -28,12 +28,61 @@ cell PriceFeedFeelib::New(
28
28
  );
29
29
  }
30
30
 
31
- (int, int, int, int) PriceFeedFeelib::utils::deserializeStorage(cell $storage) inline {
32
- ;; todo: optimize
31
+ const int PriceFeedFeelib::_priceRatioOffset = _HEADER_WIDTH;
32
+ const int PriceFeedFeelib::_gasPriceInUnitOffset = PriceFeedFeelib::_priceRatioOffset + 128;
33
+ const int PriceFeedFeelib::_gasPerByteOffset = PriceFeedFeelib::_gasPriceInUnitOffset + 64;
34
+ const int PriceFeedFeelib::_nativePriceUsdOffset = PriceFeedFeelib::_gasPerByteOffset + 32;
35
+
36
+
37
+ ;; ============================== Object Getters =========================================
38
+
39
+ ;; nativePriceUsd
40
+ int PriceFeedFeelib::getNativePriceUsd(cell $self) impure inline {
41
+ return $self.cellPreloadCoinsAt(PriceFeedFeelib::_nativePriceUsdOffset);
42
+ }
43
+
44
+ ;; ============================== Object Multi-Getters =========================================
45
+
46
+ ;; (priceRatio, gasPriceInUnit, gasPerByte)
47
+ (int, int, int) PriceFeedFeelib::utils::getFirstThreeFields(cell $self) impure inline {
48
+ ;; slice selfSlice = $self.begin_parse().skip_bits(_HEADER_WIDTH);
49
+ slice selfSlice = $self.begin_parse();
33
50
  return (
34
- $storage.cl::get<coins>(PriceFeedFeelib::priceRatio),
35
- $storage.cl::get<uint64>(PriceFeedFeelib::gasPriceInUnit),
36
- $storage.cl::get<uint32>(PriceFeedFeelib::gasPerByte),
37
- $storage.cl::get<coins>(PriceFeedFeelib::nativePriceUsd)
51
+ selfSlice.preloadCoinsAt(PriceFeedFeelib::_priceRatioOffset),
52
+ selfSlice.preloadUint64At(PriceFeedFeelib::_gasPriceInUnitOffset),
53
+ selfSlice.preloadUint32At(PriceFeedFeelib::_gasPerByteOffset)
38
54
  );
55
+ }
56
+
57
+ ;; (priceRatio, gasPriceInUnit, gasPerByte, nativePriceUsd)
58
+ (int, int, int, int) PriceFeedFeelib::deserialize(cell $storage) impure inline {
59
+ slice selfSlice = $storage.begin_parse();
60
+ return (
61
+ selfSlice.preloadCoinsAt(PriceFeedFeelib::_priceRatioOffset),
62
+ selfSlice.preloadUint64At(PriceFeedFeelib::_gasPriceInUnitOffset),
63
+ selfSlice.preloadUint32At(PriceFeedFeelib::_gasPerByteOffset),
64
+ selfSlice.preloadCoinsAt(PriceFeedFeelib::_nativePriceUsdOffset)
65
+ );
66
+ }
67
+
68
+ cell PriceFeedFeelib::setNativePriceUsd(cell $self, int nativePriceUsd) impure inline {
69
+ slice selfSlice = $self.begin_parse();
70
+ return begin_cell()
71
+ .store_slice(selfSlice.scutfirst(PriceFeedFeelib::_nativePriceUsdOffset, 0)) ;; everything up to nativePriceUsd
72
+ .store_uint128(nativePriceUsd) ;; new nativePriceUsd
73
+ .end_cell();
74
+ }
75
+
76
+ ;; ============================== Object Setters =========================================
77
+
78
+ ;; (priceRatio, gasPriceInUnit, gasPerByte)
79
+ cell PriceFeedFeelib::setFirstThreeFields(cell $self, int priceRatio, int gasPriceInUnit, int gasPerByte) impure inline {
80
+ slice selfSlice = $self.begin_parse();
81
+ return begin_cell()
82
+ .store_slice(selfSlice.scutfirst(_HEADER_WIDTH, 0)) ;; header
83
+ .store_uint128(priceRatio) ;; new priceRatio
84
+ .store_uint64(gasPriceInUnit) ;; new gasPriceInUnit
85
+ .store_uint32(gasPerByte) ;; new gasPerByte
86
+ .store_slice(selfSlice.scutlast(128, 0)) ;; last 128 bits = old nativePriceUsd
87
+ .end_cell();
39
88
  }
@@ -32,10 +32,12 @@ tuple _newAction<event>(int topic, cell $body) impure inline {
32
32
  () assertInitialized() impure inline { }
33
33
 
34
34
  () assertAdmin() impure inline {
35
- cell $admins = getCoreStorage().cl::get<cellRef>(WorkerCoreStorage::admins);
36
35
  throw_unless(
37
36
  Worker::ERROR::onlyAdmin,
38
- AddressList::includes(getCaller(), $admins.begin_parse())
37
+ AddressList::includes(
38
+ getCaller(),
39
+ getAdmins().begin_parse()
40
+ )
39
41
  );
40
42
  }
41
43
 
@@ -55,7 +57,7 @@ tuple initialize(cell $mdAddress) impure inline {
55
57
  ;;; =================================== EVENT FUNCTIONS =================================
56
58
 
57
59
  int _getEventSink() impure inline method_id {
58
- int eventSink = getCoreStorage().cl::get<address>(WorkerCoreStorage::proxy);
60
+ int eventSink = getProxyAddress();
59
61
  if (eventSink == NULLADDRESS) {
60
62
  return getContractAddress();
61
63
  }
@@ -64,7 +66,7 @@ int _getEventSink() impure inline method_id {
64
66
 
65
67
  int verifyEventOrigin(int address) method_id {
66
68
  return AddressList::includes(
67
- address, getCoreStorage().cl::get<objRef>(WorkerCoreStorage::admins).begin_parse()
69
+ address, getAdmins().begin_parse()
68
70
  );
69
71
  }
70
72
 
@@ -82,10 +84,12 @@ tuple _claimTon(tuple actions, cell $coinsAmount) impure {
82
84
  }
83
85
 
84
86
  tuple _callContract(tuple actions, cell $executeParams) impure inline {
87
+ (int target, int opcode, cell callData) = $executeParams.md::ExecuteParams::getActionArgs();
88
+
85
89
  actions~pushAction<call>(
86
- $executeParams.cl::get<address>(md::ExecuteParams::target),
87
- $executeParams.cl::get<uint32>(md::ExecuteParams::opcode),
88
- $executeParams.cl::get<objRef>(md::ExecuteParams::callData)
90
+ target,
91
+ opcode,
92
+ callData
89
93
  );
90
94
 
91
95
  return actions;
@@ -120,7 +124,8 @@ tuple _setProxyAddress(tuple actions, int newProxyAddress) impure {
120
124
 
121
125
  tuple _callViaProxy(tuple actions, cell $executeParams) impure {
122
126
  ;; only these opcodes are allowed to be called from the worker to the proxy
123
- int opcode = $executeParams.cl::get<uint32>(md::ExecuteParams::opcode);
127
+ int opcode = $executeParams.md::ExecuteParams::getOpcode();
128
+
124
129
  throw_unless(
125
130
  Worker::ERROR::invalidSignedOpcode,
126
131
  (opcode == Uln::OP::UPDATE_WORKER_FEELIB)
@@ -129,22 +134,18 @@ tuple _callViaProxy(tuple actions, cell $executeParams) impure {
129
134
  | (opcode == Worker::OP::CLAIM_TON)
130
135
  );
131
136
 
132
- return _callContract(
133
- actions,
134
- md::ExecuteParams::New(
135
- getProxyAddress(),
136
- $executeParams,
137
- 0,
138
- Proxy::OP::CALL_CONTRACT
139
- )
137
+ actions~pushAction<call>(
138
+ getProxyAddress(),
139
+ Proxy::OP::CALL_CONTRACT,
140
+ $executeParams
140
141
  );
142
+
143
+ return actions;
141
144
  }
142
145
 
143
146
  ;;; =================================== VIEW FUNCTIONS =================================
144
147
 
145
148
  int getLatestAdmin() impure method_id {
146
- slice adminSlice = getCoreStorage()
147
- .cl::get<cellRef>(WorkerCoreStorage::admins)
148
- .begin_parse();
149
+ slice adminSlice = getAdmins().begin_parse();
149
150
  return adminSlice~AddressList::next();
150
151
  }