@layerzerolabs/layerzero-v2-ton 3.0.27 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/ActionsSerde.test.compiled.json +1 -0
- package/build/AllStorages.compiled.json +1 -1
- package/build/AllStorages.test.compiled.json +1 -1
- package/build/BaseContract.test.compiled.json +1 -1
- package/build/Channel.compiled.json +1 -1
- package/build/Channel.permissions.test.compiled.json +1 -1
- package/build/ChannelBurn.test.compiled.json +1 -1
- package/build/ChannelCommitPacket.test.compiled.json +1 -1
- package/build/ChannelConfig.test.compiled.json +1 -1
- package/build/ChannelInitialize.test.compiled.json +1 -1
- package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
- package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
- package/build/ChannelNilify.test.compiled.json +1 -1
- package/build/ChannelReceive.test.compiled.json +1 -1
- package/build/ChannelReceiveCallback.test.compiled.json +1 -1
- package/build/ChannelReceiveView.test.compiled.json +1 -1
- package/build/ChannelSend.test.compiled.json +1 -1
- package/build/ChannelSerde.test.compiled.json +1 -0
- package/build/Classlib.test.compiled.json +1 -1
- package/build/ComputeDataSizeGas.test.compiled.json +1 -1
- package/build/Connection.compiled.json +1 -1
- package/build/Controller.assertions.test.compiled.json +1 -1
- package/build/Controller.compiled.json +1 -1
- package/build/Controller.permissions.test.compiled.json +1 -1
- package/build/Controller.test.compiled.json +1 -1
- package/build/Counter.compiled.json +1 -1
- package/build/Counter.permissions.test.compiled.json +1 -1
- package/build/Counter.setters.test.compiled.json +1 -1
- package/build/Counter.test.compiled.json +1 -1
- package/build/Dvn.compiled.json +1 -1
- package/build/Dvn.test.compiled.json +1 -1
- package/build/DvnFeeLib.compiled.json +1 -1
- package/build/DvnFeeLibSerde.test.compiled.json +1 -0
- package/build/DvnPermissions.test.compiled.json +1 -1
- package/build/DvnSerde.test.compiled.json +1 -0
- package/build/Endpoint.compiled.json +1 -1
- package/build/Endpoint.permissions.test.compiled.json +1 -1
- package/build/Endpoint.test.compiled.json +1 -1
- package/build/EndpointSerde.test.compiled.json +1 -0
- package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
- package/build/Executor.compiled.json +1 -1
- package/build/Executor.test.compiled.json +1 -1
- package/build/ExecutorFeeLib.compiled.json +1 -1
- package/build/ExecutorFeeLibSerde.test.compiled.json +1 -0
- package/build/ExecutorPermissions.test.compiled.json +1 -1
- package/build/ExecutorSerde.test.compiled.json +1 -0
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzClassesSerde.test.compiled.json +1 -0
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsgDataSerde.test.compiled.json +1 -0
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -0
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
- package/build/PriceFeedCacheSerde.test.compiled.json +1 -0
- package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -0
- package/build/Proxy.compiled.json +1 -1
- package/build/Proxy.permissions.test.compiled.json +1 -1
- package/build/Proxy.test.compiled.json +1 -1
- package/build/SmlConnection.compiled.json +1 -1
- package/build/SmlConnection.permissions.test.compiled.json +1 -1
- package/build/SmlConnection.test.compiled.json +1 -1
- package/build/SmlManager.compiled.json +1 -1
- package/build/SmlManager.permissions.test.compiled.json +1 -1
- package/build/SmlManager.test.compiled.json +1 -1
- package/build/Uln.compiled.json +1 -1
- package/build/Uln.test.compiled.json +1 -1
- package/build/UlnConnection.compiled.json +1 -1
- package/build/UlnConnection.test.compiled.json +1 -1
- package/build/UlnConnectionPermissions.test.compiled.json +1 -1
- package/build/UlnConnectionSerde.test.compiled.json +1 -0
- package/build/UlnManagement.test.compiled.json +1 -1
- package/build/UlnManager.compiled.json +1 -1
- package/build/UlnManager.test.compiled.json +1 -1
- package/build/UlnManagerPermissions.test.compiled.json +1 -1
- package/build/UlnManagerUtil.test.compiled.json +1 -1
- package/build/UlnMsgDataSerde.test.compiled.json +1 -0
- package/build/UlnPermissions.test.compiled.json +1 -1
- package/build/UlnReceiveConfig.test.compiled.json +1 -1
- package/build/UlnSend.test.compiled.json +1 -1
- package/build/UlnSendConfig.test.compiled.json +1 -1
- package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
- package/build/UlnSerde.test.compiled.json +1 -0
- package/build/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -0
- package/build/WorkerCoreSerde.test.compiled.json +1 -0
- package/build/badFeeLib1.test.compiled.json +1 -1
- package/build/badFeeLib10.test.compiled.json +1 -1
- package/build/badFeeLib11.test.compiled.json +1 -1
- package/build/badFeeLib12.test.compiled.json +1 -1
- package/build/badFeeLib2.test.compiled.json +1 -1
- package/build/badFeeLib3.test.compiled.json +1 -1
- package/build/badFeeLib4.test.compiled.json +1 -1
- package/build/badFeeLib5.test.compiled.json +1 -1
- package/build/badFeeLib6.test.compiled.json +1 -1
- package/build/badFeeLib7.test.compiled.json +1 -1
- package/build/badFeeLib8.test.compiled.json +1 -1
- package/build/badFeeLib9.test.compiled.json +1 -1
- package/package.json +2 -1
- package/src/classes/lz/EpConfig.fc +90 -23
- package/src/classes/lz/MsglibInfo.fc +32 -5
- package/src/classes/lz/Packet.fc +109 -48
- package/src/classes/lz/Path.fc +55 -4
- package/src/classes/lz/ReceiveEpConfig.fc +36 -5
- package/src/classes/lz/SendEpConfig.fc +55 -5
- package/src/classes/msgdata/AddMsglib.fc +11 -0
- package/src/classes/msgdata/ChannelNonceInfo.fc +20 -0
- package/src/classes/msgdata/CoinsAmount.fc +8 -0
- package/src/classes/msgdata/Deploy.fc +19 -0
- package/src/classes/msgdata/ExtendedMd.fc +52 -1
- package/src/classes/msgdata/LzReceivePrepare.fc +21 -1
- package/src/classes/msgdata/LzReceiveStatus.fc +72 -1
- package/src/classes/msgdata/LzSend.fc +143 -24
- package/src/classes/msgdata/MdAddress.fc +42 -0
- package/src/classes/msgdata/MdEid.fc +8 -0
- package/src/classes/msgdata/MdObj.fc +32 -0
- package/src/classes/msgdata/MessagingReceipt.fc +34 -1
- package/src/classes/msgdata/MsglibSendCallback.fc +82 -0
- package/src/classes/msgdata/Nonce.fc +30 -0
- package/src/classes/msgdata/OptionsV1.fc +21 -1
- package/src/classes/msgdata/OptionsV2.fc +27 -0
- package/src/classes/msgdata/PacketId.fc +24 -0
- package/src/classes/msgdata/PacketSent.fc +35 -1
- package/src/classes/msgdata/SetAddress.fc +7 -0
- package/src/classes/msgdata/SetEpConfig.fc +17 -0
- package/src/funC++/actions/event.fc +17 -2
- package/src/funC++/actions/utils.fc +2 -2
- package/src/funC++/classlib.fc +33 -43
- package/src/funC++/constants.fc +28 -28
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +75 -59
- package/src/funC++/stdlib.fc +26 -11
- package/src/funC++/testutils.fc +2 -2
- package/src/funC++/txnContext.fc +14 -14
- package/src/funC++/utils.fc +97 -1
- package/src/protocol/channel/handler.fc +247 -189
- package/src/protocol/channel/storage.fc +206 -1
- package/src/protocol/controller/handler.fc +35 -17
- package/src/protocol/controller/main.fc +1 -1
- package/src/protocol/core/abstract/protocolHandler.fc +11 -21
- package/src/protocol/core/baseStorage.fc +24 -0
- package/src/protocol/endpoint/handler.fc +99 -57
- package/src/protocol/endpoint/storage.fc +69 -5
- package/src/protocol/msglibs/BytesEncoder.fc +11 -10
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +1 -4
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +7 -8
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +114 -28
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +84 -107
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +77 -1
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +92 -66
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +113 -6
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +6 -91
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +55 -31
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +13 -9
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +63 -27
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +19 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +55 -6
- package/src/workers/core/abstract/workerHandler.fc +20 -19
- package/src/workers/core/interface.fc +2 -1
- package/src/workers/core/workerCoreStorage.fc +16 -1
- package/src/workers/dvn/handler.fc +67 -26
- package/src/workers/dvn/storage.fc +15 -2
- package/src/workers/executor/handler.fc +18 -6
- package/src/workers/executor/interface.fc +1 -0
- package/src/workers/executor/storage.fc +8 -1
- package/src/workers/msgdata/DropEvent.fc +18 -0
- package/src/workers/msgdata/ExecuteParams.fc +66 -3
- package/src/workers/msgdata/NativeDrop.fc +4 -0
- package/src/workers/msgdata/SetDict.fc +6 -4
- package/src/workers/msgdata/SetQuorum.fc +4 -2
- package/src/workers/msgdata/SignedRequest.fc +8 -0
- package/src/workers/priceFeedCache/handler.fc +21 -27
- package/src/workers/priceFeedCache/storage.fc +16 -1
- package/src/workers/proxy/handler.fc +2 -1
- package/src/workers/proxy/storage.fc +1 -1
- package/tests/baseContractTest.fc +2 -6
- package/tests/baseSerdeTest.fc +117 -0
- package/tests/testMain.fc +2 -2
- package/src/classes/msgdata/Amount.fc +0 -16
- package/src/funC++/actions/destroy.fc +0 -27
|
@@ -57,7 +57,8 @@ int _getEventSink() impure inline {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
() _assertOAppPath(cell $mdObj) impure inline {
|
|
60
|
-
cell $
|
|
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 = $
|
|
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
|
-
$
|
|
180
|
+
$sanitizedDeploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
179
181
|
BaseInterface::OP::INITIALIZE,
|
|
180
|
-
$
|
|
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 = $
|
|
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
|
-
$
|
|
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 = $
|
|
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
|
-
$
|
|
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 $
|
|
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 = $
|
|
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 $
|
|
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, $
|
|
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 $
|
|
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, $
|
|
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 = $
|
|
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
|
-
$
|
|
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
|
-
|
|
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
|
-
$
|
|
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
|
|
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
|
|
348
|
-
|
|
349
|
-
|
|
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
|
|
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
|
-
$
|
|
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 = $
|
|
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
|
-
|
|
436
|
-
|
|
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
|
-
$
|
|
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
|
-
$
|
|
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
|
-
(
|
|
19
|
-
| (
|
|
20
|
-
| cl::
|
|
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.
|
|
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.
|
|
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::
|
|
65
|
+
) = PriceFeedFeelib::deserialize($priceFeedStorage);
|
|
65
66
|
|
|
66
|
-
int
|
|
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
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
totalGas += lzReceiveBaseGas
|
|
17
|
-
+ $options.cl::get<uint256>(md::OptionsV1::lzReceiveGas);
|
|
20
|
+
int optionsType = cl::typeof($options);
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 +
|
|
53
|
+
totalGas += lzReceiveBaseGas + lzReceiveGas;
|
|
31
54
|
|
|
32
|
-
totalDstAmount +=
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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.
|
|
77
|
-
|
|
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
|
-
|
|
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::
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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(
|
|
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 =
|
|
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,
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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.
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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 =
|
|
147
|
-
.cl::get<cellRef>(WorkerCoreStorage::admins)
|
|
148
|
-
.begin_parse();
|
|
149
|
+
slice adminSlice = getAdmins().begin_parse();
|
|
149
150
|
return adminSlice~AddressList::next();
|
|
150
151
|
}
|