@layerzerolabs/layerzero-v2-ton 3.0.19-ton.0 → 3.0.19-ton.1
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 +6 -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/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/DvnPermissions.test.compiled.json +1 -1
- 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/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/ExecutorPermissions.test.compiled.json +1 -1
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.permissions.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- 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/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/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/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- 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 +5 -5
- package/src/classes/msgdata/LzReceiveStatus.fc +0 -1
- package/src/funC++/actions/call.fc +1 -0
- package/src/funC++/actions/deploy.fc +0 -1
- package/src/funC++/actions/destroy.fc +0 -1
- package/src/funC++/actions/dispatch.fc +0 -1
- package/src/funC++/actions/event.fc +0 -1
- package/src/funC++/actions/payment.fc +0 -1
- package/src/funC++/actions/sendJettons.fc +0 -1
- package/src/funC++/actions/utils.fc +0 -2
- package/src/funC++/baseInterface.fc +0 -2
- package/src/funC++/classlib.fc +0 -36
- package/src/funC++/contractMain.fc +2 -8
- package/src/funC++/dataStructures/DeterministicInsertionCircularQueue.fc +0 -1
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +0 -1
- package/src/funC++/handlerCore.fc +2 -6
- package/src/funC++/stringlib.fc +0 -2
- package/src/funC++/testutils.fc +0 -1
- package/src/funC++/txnContext.fc +1 -1
- package/src/funC++/utils.fc +35 -0
- package/src/protocol/channel/callbackOpcodes.fc +10 -0
- package/src/protocol/channel/handler.fc +1032 -0
- package/src/protocol/channel/interface.fc +60 -0
- package/src/protocol/channel/main.fc +39 -0
- package/src/protocol/channel/storage.fc +55 -0
- package/src/protocol/controller/handler.fc +347 -0
- package/src/protocol/controller/interface.fc +25 -0
- package/src/protocol/controller/main.fc +29 -0
- package/src/protocol/controller/storage.fc +31 -0
- package/src/protocol/core/abstract/protocolHandler.fc +110 -0
- package/src/protocol/core/abstract/protocolMain.fc +30 -0
- package/src/protocol/core/baseStorage.fc +1 -2
- package/src/protocol/endpoint/handler.fc +426 -0
- package/src/protocol/endpoint/interface.fc +20 -0
- package/src/protocol/endpoint/main.fc +23 -0
- package/src/protocol/interfaces.fc +4 -0
- package/src/protocol/msglibs/BytesDecoder.fc +135 -0
- package/src/protocol/msglibs/BytesEncoder.fc +150 -0
- package/src/protocol/msglibs/interface.fc +16 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/handler.fc +125 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/interface.fc +3 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/main.fc +19 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/storage.fc +20 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +281 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/interface.fc +14 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/main.fc +24 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/storage.fc +38 -0
- package/src/protocol/msglibs/ultralightnode/callbackOpcodes.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/feeLibUtils.fc +51 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +49 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +62 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnManager.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/RentRefill.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/TreasuryFeeBps.fc +16 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +249 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +27 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +170 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +21 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +16 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibEvents.fc +58 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +56 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +803 -0
- package/src/protocol/msglibs/ultralightnode/uln/interface.fc +63 -0
- package/src/protocol/msglibs/ultralightnode/uln/main.fc +37 -0
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +43 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +600 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/interface.fc +36 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/main.fc +32 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +49 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +141 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +495 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/interface.fc +59 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/main.fc +40 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/storage.fc +44 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/common.fc +27 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +80 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/main.fc +4 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +123 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/main.fc +4 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +29 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/main.fc +3 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/main.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +39 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/ulnSendWorkerV1.fc +363 -0
- package/src/workers/core/abstract/workerHandler.fc +150 -0
- package/src/workers/core/interface.fc +25 -0
- package/src/workers/core/workerCoreStorage.fc +44 -0
- package/src/workers/dvn/handler.fc +332 -0
- package/src/workers/dvn/interface.fc +25 -0
- package/src/workers/dvn/main.fc +36 -0
- package/src/workers/dvn/storage.fc +27 -0
- package/src/workers/executor/handler.fc +110 -0
- package/src/workers/executor/interface.fc +19 -0
- package/src/workers/executor/main.fc +26 -0
- package/src/workers/executor/storage.fc +19 -0
- package/src/workers/msgdata/ExecuteParams.fc +29 -0
- package/src/workers/msgdata/NativeDrop.fc +16 -0
- package/src/workers/msgdata/ProxyMessage.fc +20 -0
- package/src/workers/msgdata/SetDict.fc +20 -0
- package/src/workers/msgdata/SetQuorum.fc +20 -0
- package/src/workers/msgdata/SignedRequest.fc +18 -0
- package/src/workers/priceFeedCache/handler.fc +114 -0
- package/src/workers/priceFeedCache/interface.fc +4 -0
- package/src/workers/priceFeedCache/main.fc +25 -0
- package/src/workers/priceFeedCache/storage.fc +21 -0
- package/src/workers/proxy/handler.fc +81 -0
- package/src/workers/proxy/interface.fc +11 -0
- package/src/workers/proxy/main.fc +17 -0
- package/src/workers/proxy/storage.fc +21 -0
- package/tests/testMain.fc +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#include "interface.fc";
|
|
2
|
+
|
|
3
|
+
#include "../msgdata/UlnReceiveConfig.fc";
|
|
4
|
+
#include "../msgdata/UlnSendConfig.fc";
|
|
5
|
+
|
|
6
|
+
#include "../../../core/baseStorage.fc";
|
|
7
|
+
|
|
8
|
+
#include "../../../../funC++/dataStructures/PipelinedOutOfOrder.fc";
|
|
9
|
+
|
|
10
|
+
const int UlnConnection::MAX_HASH_LOOKUPS = 1023;
|
|
11
|
+
|
|
12
|
+
const int UlnConnection::NAME = "connection"u;
|
|
13
|
+
|
|
14
|
+
const int UlnConnection::baseStorage = 0;
|
|
15
|
+
const int UlnConnection::path = 1;
|
|
16
|
+
;; the channel address is set during the initialize call
|
|
17
|
+
const int UlnConnection::endpointAddress = 2;
|
|
18
|
+
const int UlnConnection::channelAddress = 3;
|
|
19
|
+
const int UlnConnection::ulnAddress = 4;
|
|
20
|
+
|
|
21
|
+
;; EVM struct ExecutorConfig
|
|
22
|
+
;; uint32 maxMessageSize;
|
|
23
|
+
;; address executor;
|
|
24
|
+
const int UlnConnection::UlnSendConfigOApp = 5; ;; UlnSendConfig
|
|
25
|
+
const int UlnConnection::UlnReceiveConfigOApp = 6; ;; UlnReceiveConfig
|
|
26
|
+
;; breaking from EVM, we are using a fixed size array for the DVN verifications, and DVNs can
|
|
27
|
+
;; only verify a packet for a specific inbound nonce range.
|
|
28
|
+
const int UlnConnection::hashLookups = 7; ;; map nonce -> map dvnAddress -> {hash,confirmations}
|
|
29
|
+
const int UlnConnection::firstUnexecutedNonce = 8; ;; first nonce that has not been executed
|
|
30
|
+
const int UlnConnection::commitPOOO = 9;
|
|
31
|
+
|
|
32
|
+
;; @owner ulnManager
|
|
33
|
+
cell UlnConnection::New(int owner, cell $path, int ulnAddress) method_id {
|
|
34
|
+
return cl::declare(
|
|
35
|
+
UlnConnection::NAME,
|
|
36
|
+
unsafeTuple([
|
|
37
|
+
[cl::t::objRef, BaseStorage::New(owner)], ;; UlnConnection::baseStorage
|
|
38
|
+
[cl::t::objRef, $path], ;; UlnConnection::path
|
|
39
|
+
[cl::t::address, NULLADDRESS], ;; UlnConnection::endpointAddress
|
|
40
|
+
[cl::t::address, NULLADDRESS], ;; UlnConnection::channelAddress
|
|
41
|
+
[cl::t::address, ulnAddress], ;; UlnConnection::ulnAddress
|
|
42
|
+
[cl::t::objRef, UlnSendConfig::NewWithDefaults()], ;; UlnConnection::UlnSendConfigOApp
|
|
43
|
+
[cl::t::objRef, UlnReceiveConfig::NewWithDefaults()], ;; UlnConnection::UlnReceiveConfigOApp
|
|
44
|
+
[cl::t::dict256, cl::dict256::New()], ;; UlnConnection::hashLookups
|
|
45
|
+
[cl::t::uint64, 1], ;; UlnConnection::firstUnexecutedNonce
|
|
46
|
+
[cl::t::objRef, empty_cell()] ;; UlnConnection::commitPOOO
|
|
47
|
+
])
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#include "interface.fc";
|
|
2
|
+
|
|
3
|
+
#include "../msgdata/Attestation.fc";
|
|
4
|
+
#include "../msgdata/UlnReceiveConfig.fc";
|
|
5
|
+
#include "../msgdata/UlnSendConfig.fc";
|
|
6
|
+
|
|
7
|
+
;;; ===============================GETTERS===========================
|
|
8
|
+
|
|
9
|
+
cell UlnConnection::utils::getHashLookup(cell $self, int nonce, int dvnAddress) impure inline {
|
|
10
|
+
cell hashLookups = $self.cl::get<dict256>(UlnConnection::hashLookups);
|
|
11
|
+
|
|
12
|
+
(cell addressLookup, int exists) = hashLookups.cl::dict256::get<cellRef>(nonce);
|
|
13
|
+
ifnot (exists) {
|
|
14
|
+
return cl::nullObject();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
(cell $attestation, int exists) = addressLookup.cl::dict256::get<cellRef>(dvnAddress);
|
|
18
|
+
ifnot (exists) {
|
|
19
|
+
return cl::nullObject();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return $attestation;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
;;; ===============================SETTERS===========================
|
|
26
|
+
|
|
27
|
+
cell UlnConnection::utils::setHashLookup(
|
|
28
|
+
cell $self,
|
|
29
|
+
int nonce,
|
|
30
|
+
int dvnAddress,
|
|
31
|
+
cell $attestation
|
|
32
|
+
) impure inline {
|
|
33
|
+
cell hashLookups = $self.cl::get<dict256>(UlnConnection::hashLookups);
|
|
34
|
+
(cell addressLookup, _) = hashLookups.cl::dict256::get<cellRef>(nonce);
|
|
35
|
+
|
|
36
|
+
;; insert the attestation
|
|
37
|
+
addressLookup = addressLookup.cl::dict256::setRef(
|
|
38
|
+
dvnAddress,
|
|
39
|
+
$attestation
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
;; save the attestation hash
|
|
43
|
+
hashLookups = hashLookups.cl::dict256::setRef(nonce, addressLookup);
|
|
44
|
+
|
|
45
|
+
return $self.cl::set(
|
|
46
|
+
UlnConnection::hashLookups,
|
|
47
|
+
hashLookups.cl::dict256::setRef(nonce, addressLookup)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
cell UlnConnection::utils::deleteNonceAttestations(
|
|
52
|
+
cell $self,
|
|
53
|
+
int nonce
|
|
54
|
+
) impure inline {
|
|
55
|
+
cell hashLookups = $self.cl::get<dict256>(UlnConnection::hashLookups);
|
|
56
|
+
;; delete is safe to call on a non-existent key
|
|
57
|
+
hashLookups = hashLookups.cl::dict256::delete(nonce);
|
|
58
|
+
return $self.cl::set(
|
|
59
|
+
UlnConnection::hashLookups,
|
|
60
|
+
hashLookups
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
;;; ===============================CHECKERS===========================
|
|
65
|
+
|
|
66
|
+
;; returns true if the attestations are valid (meets the dvn threshold and confirmations)
|
|
67
|
+
int UlnConnection::utils::isCommittable(
|
|
68
|
+
cell $self,
|
|
69
|
+
cell $defaultUlnReceiveConfig,
|
|
70
|
+
int nonce,
|
|
71
|
+
int hash
|
|
72
|
+
) impure inline {
|
|
73
|
+
cell hashLookups = $self.cl::get<dict256>(UlnConnection::hashLookups);
|
|
74
|
+
(cell addressLookup, int exists) = hashLookups.cl::dict256::get<cellRef>(nonce);
|
|
75
|
+
ifnot (exists) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
;; retrieve the DVNs from the config
|
|
80
|
+
(
|
|
81
|
+
cell requiredDVNs,
|
|
82
|
+
cell optionalDVNs,
|
|
83
|
+
int optionalDVNThreshold,
|
|
84
|
+
int requiredConfirmations,
|
|
85
|
+
_,
|
|
86
|
+
int isValid
|
|
87
|
+
) = UlnReceiveConfig::utils::getCommitConfig(
|
|
88
|
+
$self.cl::get<objRef>(UlnConnection::UlnReceiveConfigOApp),
|
|
89
|
+
$defaultUlnReceiveConfig
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
ifnot (isValid) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
slice requiredDVNsSlice = requiredDVNs.begin_parse();
|
|
97
|
+
;; iterate the requiredDVNs and make sure each has set the proper hash and confirmations
|
|
98
|
+
int address = requiredDVNsSlice~AddressList::next();
|
|
99
|
+
while (address > NULLADDRESS) {
|
|
100
|
+
(cell $attestation, int exists) = addressLookup.cl::dict256::get<cellRef>(address);
|
|
101
|
+
;; if it doesn't exist it means we don't have the required DVN's attestation
|
|
102
|
+
ifnot (exists) {
|
|
103
|
+
return false;
|
|
104
|
+
} elseifnot ($attestation.lz::Attestation::confirmable(hash, requiredConfirmations)) {
|
|
105
|
+
;; attestation hash...
|
|
106
|
+
;; (1) doesn't match the hash passed in
|
|
107
|
+
;; OR (2) the attestation confirmations are fewer than the required confirmations
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
address = requiredDVNsSlice~AddressList::next();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (optionalDVNThreshold == 0) {
|
|
114
|
+
;; if we don't have any optional DVNs, we're done
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
slice optionalDVNsSlice = optionalDVNs.begin_parse();
|
|
119
|
+
;; iterate the optionalDVNs and make sure each has set the proper hash and confirmations
|
|
120
|
+
int address = optionalDVNsSlice~AddressList::next();
|
|
121
|
+
int count = 0;
|
|
122
|
+
|
|
123
|
+
while (address > NULLADDRESS) {
|
|
124
|
+
(cell $attestation, int attestationExists) = addressLookup.cl::dict256::get<cellRef>(address);
|
|
125
|
+
;; if the attestation matches the hash and is greater than or equal to the confirmations
|
|
126
|
+
;; we're looking for, increment the counter
|
|
127
|
+
if (attestationExists) {
|
|
128
|
+
if ($attestation.lz::Attestation::confirmable(hash, requiredConfirmations)) {
|
|
129
|
+
count = count + 1;
|
|
130
|
+
}
|
|
131
|
+
if (count == optionalDVNThreshold) {
|
|
132
|
+
;; early exit if we hit the optional DVN threshold
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
address = optionalDVNsSlice~AddressList::next();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
;; threshold not met, return false
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
#include "../../../core/abstract/protocolHandler.fc";
|
|
2
|
+
#include "../../../interfaces.fc";
|
|
3
|
+
|
|
4
|
+
#include "../uln/interface.fc";
|
|
5
|
+
#include "../ulnConnection/interface.fc";
|
|
6
|
+
|
|
7
|
+
#include "../../../channel/storage.fc";
|
|
8
|
+
#include "../../../endpoint/storage.fc";
|
|
9
|
+
#include "../../../endpoint/interface.fc";
|
|
10
|
+
|
|
11
|
+
#include "../../../../funC++/classlib.fc";
|
|
12
|
+
#include "../../../../funC++/txnContext.fc";
|
|
13
|
+
#include "../../../../funC++/utils.fc";
|
|
14
|
+
#include "../../../../classes/lz/Path.fc";
|
|
15
|
+
#include "../../../../classes/lz/MsglibInfo.fc";
|
|
16
|
+
#include "../../../../classes/msgdata/CoinsAmount.fc";
|
|
17
|
+
#include "../../../../classes/msgdata/Deploy.fc";
|
|
18
|
+
#include "../../../../classes/msgdata/MdAddress.fc";
|
|
19
|
+
#include "../../../../classes/msgdata/AddMsglib.fc";
|
|
20
|
+
#include "../../../../classes/msgdata/MdEid.fc";
|
|
21
|
+
#include "../../../../classes/msgdata/MdObj.fc";
|
|
22
|
+
#include "../../../../classes/msgdata/Bool.fc";
|
|
23
|
+
#include "../../../../classes/msgdata/SetAddress.fc";
|
|
24
|
+
|
|
25
|
+
#include "../msgdata/UlnWorkerFeelibInfo.fc";
|
|
26
|
+
#include "../msgdata/InitUln.fc";
|
|
27
|
+
#include "../msgdata/InitUlnConnection.fc";
|
|
28
|
+
#include "../msgdata/InitUlnManager.fc";
|
|
29
|
+
#include "../msgdata/SetAdminWorkerAddresses.fc";
|
|
30
|
+
#include "../msgdata/TreasuryFeeBps.fc";
|
|
31
|
+
#include "../msgdata/UlnWorkerFeelibBytecode.fc";
|
|
32
|
+
|
|
33
|
+
#include "interface.fc";
|
|
34
|
+
#include "storage.fc";
|
|
35
|
+
|
|
36
|
+
;;; ================INTERFACE FUNCTIONS=====================
|
|
37
|
+
|
|
38
|
+
(cell, tuple) _initialize(cell $initUlnManager) impure inline {
|
|
39
|
+
(cell $storage, tuple actions) = preamble();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
$storage
|
|
43
|
+
.cl::set(
|
|
44
|
+
UlnManager::endpointCode,
|
|
45
|
+
$initUlnManager.cl::get<cellRef>(md::InitUlnManager::endpointCode)
|
|
46
|
+
)
|
|
47
|
+
.cl::set(
|
|
48
|
+
UlnManager::channelCode,
|
|
49
|
+
$initUlnManager.cl::get<cellRef>(md::InitUlnManager::channelCode)
|
|
50
|
+
),
|
|
51
|
+
actions
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
int _getEventSink() impure inline {
|
|
56
|
+
return getContractAddress();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
() _assertOAppPath(cell $mdObj) impure inline {
|
|
60
|
+
cell $path = $mdObj.cl::get<objRef>(md::MdObj::obj);
|
|
61
|
+
cell $sanitizedPath = lz::Path::sanitize($path);
|
|
62
|
+
throw_unless(
|
|
63
|
+
UlnManager::ERROR::invalidPath,
|
|
64
|
+
getCaller() == $sanitizedPath.cl::get<address>(lz::Path::srcOApp)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
() assertTentativeOwner() impure inline {
|
|
69
|
+
throw_unless(
|
|
70
|
+
UlnManager::ERROR::onlyTentativeOwner,
|
|
71
|
+
getCaller() == getContractStorage().cl::get<address>(UlnManager::tentativeOwner)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
;;; ================PERMISSION FUNCTIONS=====================
|
|
76
|
+
|
|
77
|
+
() _checkPermissions(int op, cell $md) impure inline {
|
|
78
|
+
if (
|
|
79
|
+
(op == UlnManager::OP::DEPLOY_ULN)
|
|
80
|
+
| (op == UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG)
|
|
81
|
+
| (op == UlnManager::OP::SET_DEFAULT_ULN_SEND_CONFIG)
|
|
82
|
+
| (op == UlnManager::OP::REGISTER_WORKER_FEELIB_BYTECODE)
|
|
83
|
+
| (op == UlnManager::OP::CLAIM_TREASURY_FEES)
|
|
84
|
+
| (op == UlnManager::OP::SET_ADMIN_WORKERS)
|
|
85
|
+
| (op == UlnManager::OP::SET_ULN_TREASURY_FEE_BPS)
|
|
86
|
+
| (op == UlnManager::OP::TRANSFER_OWNERSHIP)
|
|
87
|
+
) {
|
|
88
|
+
;; open to only owner
|
|
89
|
+
return assertOwner();
|
|
90
|
+
} elseif (
|
|
91
|
+
(op == MsglibManager::OP::GET_MSGLIB_INFO)
|
|
92
|
+
| (op == MsglibManager::OP::DEPLOY_CONNECTION)
|
|
93
|
+
| (op == UlnManager::OP::ADD_ULN_WORKER)
|
|
94
|
+
) {
|
|
95
|
+
;; open and public calls
|
|
96
|
+
return ();
|
|
97
|
+
} elseif (
|
|
98
|
+
(op == UlnManager::OP::SET_OAPP_ULN_RECEIVE_CONFIG)
|
|
99
|
+
| (op == UlnManager::OP::SET_OAPP_ULN_SEND_CONFIG)
|
|
100
|
+
) {
|
|
101
|
+
return _assertOAppPath($md);
|
|
102
|
+
} elseif (op == UlnManager::OP::CLAIM_OWNERSHIP) {
|
|
103
|
+
return assertTentativeOwner();
|
|
104
|
+
} else {
|
|
105
|
+
;; we must put a check for all opcodes to make sure we don't
|
|
106
|
+
;; mistakenly miss an opcode's permissions
|
|
107
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
;;; ==========================HELPER FUNCTIONS=====================================
|
|
112
|
+
|
|
113
|
+
int _calculateUlnAddress(cell $storage, int dstEid) impure inline method_id {
|
|
114
|
+
throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
|
|
115
|
+
return computeContractAddress(
|
|
116
|
+
Uln::New(getContractAddress(), $storage.cl::get<uint32>(UlnManager::eid), dstEid),
|
|
117
|
+
$storage.cl::get<cellRef>(UlnManager::ulnCode)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
int _calculateEndpointAddress(cell $storage, int dstEid) impure inline method_id {
|
|
122
|
+
throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
|
|
123
|
+
return computeContractAddress(
|
|
124
|
+
Endpoint::New(
|
|
125
|
+
$storage.cl::get<uint32>(UlnManager::eid),
|
|
126
|
+
dstEid,
|
|
127
|
+
$storage.cl::get<address>(UlnManager::controllerAddress)
|
|
128
|
+
),
|
|
129
|
+
$storage.cl::get<cellRef>(UlnManager::endpointCode)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
int _calculateChannelAddress(cell $storage, cell $path) impure inline method_id {
|
|
134
|
+
return computeContractAddress(
|
|
135
|
+
Channel::New(
|
|
136
|
+
$storage.cl::get<address>(UlnManager::controllerAddress),
|
|
137
|
+
$path,
|
|
138
|
+
_calculateEndpointAddress($storage, $path.cl::get<uint32>(lz::Path::dstEid))
|
|
139
|
+
),
|
|
140
|
+
$storage.cl::get<cellRef>(UlnManager::channelCode)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
int _calculateUlnConnectionAddress(cell $storage, cell $path) impure inline method_id {
|
|
145
|
+
return computeContractAddress(
|
|
146
|
+
UlnConnection::New(
|
|
147
|
+
getContractAddress(),
|
|
148
|
+
$path,
|
|
149
|
+
_calculateUlnAddress($storage, $path.cl::get<uint32>(lz::Path::dstEid))
|
|
150
|
+
),
|
|
151
|
+
$storage.cl::get<cellRef>(UlnManager::ulnConnectionCode)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
;;; ==========================HANDLERS=====================================
|
|
156
|
+
|
|
157
|
+
;; @in_opcode UlnManager::OP::DEPLOY_ULN
|
|
158
|
+
;; @in_md todo { eid }
|
|
159
|
+
;; @permissions only-owner
|
|
160
|
+
;; @out_actions deploy the uln for this particular eid
|
|
161
|
+
tuple deployUln(cell $deploy) impure inline method_id {
|
|
162
|
+
(cell $storage, tuple actions) = preamble();
|
|
163
|
+
|
|
164
|
+
int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
165
|
+
throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
|
|
166
|
+
|
|
167
|
+
actions~pushAction<deployAndCall>(
|
|
168
|
+
$storage.cl::get<cellRef>(UlnManager::ulnCode),
|
|
169
|
+
Uln::New(
|
|
170
|
+
getContractAddress(),
|
|
171
|
+
$storage.cl::get<uint32>(UlnManager::eid),
|
|
172
|
+
dstEid
|
|
173
|
+
),
|
|
174
|
+
$deploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
175
|
+
BaseInterface::OP::INITIALIZE,
|
|
176
|
+
$deploy.cl::get<objRef>(md::Deploy::extraInfo).cl::set(
|
|
177
|
+
md::InitUln::connectionCode,
|
|
178
|
+
$storage.cl::get<cellRef>(UlnManager::ulnConnectionCode)
|
|
179
|
+
),
|
|
180
|
+
0
|
|
181
|
+
);
|
|
182
|
+
return actions;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
;; @in_opcode MsglibManager::OP::DEPLOY_CONNECTION
|
|
186
|
+
;; @in_md todo { oApp_path, shard }
|
|
187
|
+
;; @permissions seeded by caller address
|
|
188
|
+
;; @out_actions deploy the connection for this particular oApp path
|
|
189
|
+
tuple deployUlnConnection(cell $deploy) impure inline method_id {
|
|
190
|
+
(cell $storage, tuple actions) = preamble();
|
|
191
|
+
|
|
192
|
+
int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
193
|
+
|
|
194
|
+
throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
|
|
195
|
+
|
|
196
|
+
cell $path = lz::Path::New(
|
|
197
|
+
$storage.cl::get<uint32>(UlnManager::eid),
|
|
198
|
+
getCaller(),
|
|
199
|
+
dstEid,
|
|
200
|
+
$deploy.cl::get<address>(md::Deploy::dstOApp)
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
cell $ulnConnection = UlnConnection::New(
|
|
204
|
+
getContractAddress(),
|
|
205
|
+
$path,
|
|
206
|
+
_calculateUlnAddress($storage, dstEid)
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
cell $initUlnConnection = $deploy.cl::get<objRef>(md::Deploy::extraInfo)
|
|
210
|
+
.cl::set(md::InitUlnConnection::endpointAddress, _calculateEndpointAddress($storage, dstEid))
|
|
211
|
+
.cl::set(md::InitUlnConnection::channelAddress, _calculateChannelAddress($storage, $path));
|
|
212
|
+
|
|
213
|
+
actions~pushAction<deployAndCall>(
|
|
214
|
+
$storage.cl::get<cellRef>(UlnManager::ulnConnectionCode),
|
|
215
|
+
$ulnConnection,
|
|
216
|
+
$deploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
217
|
+
BaseInterface::OP::INITIALIZE,
|
|
218
|
+
InitUlnConnection::sanitize($initUlnConnection),
|
|
219
|
+
0
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return actions;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
tuple getMsglibInfo(cell $addMsglibMd) impure inline method_id {
|
|
226
|
+
(cell $storage, tuple actions) = preamble();
|
|
227
|
+
|
|
228
|
+
int dstEid = $addMsglibMd.cl::get<uint32>(md::AddMsglib::dstEid);
|
|
229
|
+
throw_if(UlnManager::ERROR::invalidEid, dstEid == 0);
|
|
230
|
+
|
|
231
|
+
int ulnAddress = _calculateUlnAddress(
|
|
232
|
+
$storage,
|
|
233
|
+
dstEid
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
actions~pushAction<call>(
|
|
237
|
+
getCaller(),
|
|
238
|
+
Endpoint::OP::GET_MSGLIB_INFO_CALLBACK,
|
|
239
|
+
lz::MsglibInfo::New(
|
|
240
|
+
ulnAddress,
|
|
241
|
+
$storage.cl::get<cellRef>(UlnManager::ulnConnectionCode),
|
|
242
|
+
UlnConnection::New(
|
|
243
|
+
getContractAddress(),
|
|
244
|
+
lz::Path::endpointPath(
|
|
245
|
+
$storage.cl::get<uint32>(UlnManager::eid),
|
|
246
|
+
dstEid
|
|
247
|
+
),
|
|
248
|
+
ulnAddress
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
return actions;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
;; @in_opcode UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG
|
|
257
|
+
tuple setDefaultUlnSendConfig(cell $mdEid) impure inline method_id {
|
|
258
|
+
(cell $storage, tuple actions) = preamble();
|
|
259
|
+
cell $UlnSendConfig = $mdEid.cl::get<objRef>(md::MdEid::md);
|
|
260
|
+
|
|
261
|
+
actions~pushAction<call>(
|
|
262
|
+
_calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid)),
|
|
263
|
+
Uln::OP::SET_DEFAULT_ULN_SEND_CONFIG,
|
|
264
|
+
$UlnSendConfig
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return actions;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
;; @in_opcode UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG
|
|
271
|
+
tuple setDefaultUlnReceiveConfig(cell $mdEid) impure inline method_id {
|
|
272
|
+
(cell $storage, tuple actions) = preamble();
|
|
273
|
+
cell $UlnReceiveConfig = $mdEid.cl::get<objRef>(md::MdEid::md);
|
|
274
|
+
|
|
275
|
+
actions~pushAction<call>(
|
|
276
|
+
_calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid)),
|
|
277
|
+
Uln::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG,
|
|
278
|
+
$UlnReceiveConfig
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
return actions;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
;; @in_opcode UlnManager::OP::SET_CONNECTION_ULN_CONFIG
|
|
285
|
+
tuple setOAppUlnReceiveConfig(cell $mdObj) impure inline method_id {
|
|
286
|
+
(cell $storage, tuple actions) = preamble();
|
|
287
|
+
|
|
288
|
+
cell $sendPath = $mdObj.cl::get<objRef>(md::MdObj::obj);
|
|
289
|
+
|
|
290
|
+
actions~pushAction<call>(
|
|
291
|
+
_calculateUlnConnectionAddress($storage, $sendPath),
|
|
292
|
+
UlnConnection::OP::SET_OAPP_ULN_RECEIVE_CONFIG,
|
|
293
|
+
$mdObj.cl::get<objRef>(md::MdObj::md)
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
return actions;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
;; @in_opcode UlnManager::OP::SET_CONNECTION_ULN_CONFIG
|
|
300
|
+
tuple setOAppUlnSendConfig(cell $mdObj) impure inline method_id {
|
|
301
|
+
(cell $storage, tuple actions) = preamble();
|
|
302
|
+
|
|
303
|
+
cell $sendPath = $mdObj.cl::get<objRef>(md::MdObj::obj);
|
|
304
|
+
|
|
305
|
+
actions~pushAction<call>(
|
|
306
|
+
_calculateUlnConnectionAddress($storage, $sendPath),
|
|
307
|
+
UlnConnection::OP::SET_OAPP_ULN_SEND_CONFIG,
|
|
308
|
+
$mdObj.cl::get<objRef>(md::MdObj::md)
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
return actions;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
;; @in_opcode UlnManager::OP::ADD_ULN_WORKER_INFO
|
|
315
|
+
tuple registerWorkerFeelibBytecode(cell $ulnWorkerFeelibBytecode) impure inline method_id {
|
|
316
|
+
(cell $storage, tuple actions) = preamble();
|
|
317
|
+
|
|
318
|
+
cell bytecode = $ulnWorkerFeelibBytecode
|
|
319
|
+
.cl::get<cellRef>(md::UlnWorkerFeelibBytecode::bytecode);
|
|
320
|
+
|
|
321
|
+
cell $newStorage = $storage
|
|
322
|
+
.cl::nestedDict256::setRef(
|
|
323
|
+
UlnManager::workerFeelibBytecodes,
|
|
324
|
+
bytecode.cell_hash(),
|
|
325
|
+
bytecode
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
(_, _, _, int success) = compute_data_size?(
|
|
329
|
+
$newStorage.cl::get<dict256>(UlnManager::workerFeelibBytecodes),
|
|
330
|
+
UlnManager::CONST::MAX_CUMULATIVE_BYTECODE_CELLS
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
setContractStorage($newStorage);
|
|
334
|
+
|
|
335
|
+
throw_unless(UlnManager::ERROR::feelibBytecodesExceeded, success);
|
|
336
|
+
|
|
337
|
+
return actions;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
tuple addWorkerFeelibToUln(cell $UlnWorkerFeelibInfo) impure inline method_id {
|
|
341
|
+
(cell $storage, tuple actions) = preamble();
|
|
342
|
+
|
|
343
|
+
cell $sanitizedUlnWorkerFeelibInfo = UlnWorkerFeelibInfo::sanitize(
|
|
344
|
+
$UlnWorkerFeelibInfo
|
|
345
|
+
).cl::set(UlnWorkerFeelibInfo::workerAddress, getCaller());
|
|
346
|
+
;; invariant: checkPermissions guarantees that getCaller() == $UlnWorkerFeelibInfo.workerAddress
|
|
347
|
+
int bytecodeId = $sanitizedUlnWorkerFeelibInfo
|
|
348
|
+
.cl::get<cellRef>(UlnWorkerFeelibInfo::workerFeelibBytecode)
|
|
349
|
+
.cell_hash();
|
|
350
|
+
|
|
351
|
+
(_, int bytecodeExists) = $storage
|
|
352
|
+
.cl::nestedDict256::get<cellRef>(UlnManager::workerFeelibBytecodes, bytecodeId);
|
|
353
|
+
|
|
354
|
+
throw_unless(UlnManager::ERROR::invalidWorkerInfo, bytecodeExists);
|
|
355
|
+
|
|
356
|
+
;; only admin workers can add to the admin workers list on the uln
|
|
357
|
+
int useAdminSlot = $sanitizedUlnWorkerFeelibInfo.cl::get<bool>(UlnWorkerFeelibInfo::isAdmin);
|
|
358
|
+
if (useAdminSlot) {
|
|
359
|
+
throw_unless(
|
|
360
|
+
UlnManager::ERROR::invalidWorkerInfo,
|
|
361
|
+
AddressList::includes(
|
|
362
|
+
getCaller(),
|
|
363
|
+
$storage.cl::get<cellRef>(UlnManager::adminWorkers).begin_parse()
|
|
364
|
+
)
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
actions~pushAction<call>(
|
|
369
|
+
_calculateUlnAddress(
|
|
370
|
+
$storage,
|
|
371
|
+
$sanitizedUlnWorkerFeelibInfo.cl::get<uint32>(UlnWorkerFeelibInfo::dstEid)
|
|
372
|
+
),
|
|
373
|
+
Uln::OP::UPDATE_WORKER_FEELIB,
|
|
374
|
+
$sanitizedUlnWorkerFeelibInfo
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
return actions;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
tuple setAdminWorkers(cell $setAdminWorkerAddresses) impure inline method_id {
|
|
381
|
+
(cell $storage, tuple actions) = preamble();
|
|
382
|
+
cell adminWorkers = $setAdminWorkerAddresses
|
|
383
|
+
.cl::get<cellRef>(md::SetAdminWorkerAddresses::adminWorkers);
|
|
384
|
+
|
|
385
|
+
throw_unless(
|
|
386
|
+
UlnManager::ERROR::invalidAdminWorkerList,
|
|
387
|
+
AddressList::isValid(adminWorkers, UlnManager::CONST::MAX_ADMIN_WORKERS)
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
setContractStorage(
|
|
391
|
+
$storage.cl::set(UlnManager::adminWorkers, adminWorkers)
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
actions~pushAction<event>(
|
|
395
|
+
UlnManager::event::ADMIN_WORKERS_SET,
|
|
396
|
+
$setAdminWorkerAddresses
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
return actions;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
tuple claimTreasuryFees(cell $coinsAmount) impure inline method_id {
|
|
403
|
+
(cell $storage, tuple actions) = preamble();
|
|
404
|
+
|
|
405
|
+
int claimAmount = $coinsAmount.cl::get<coins>(md::CoinsAmount::amount);
|
|
406
|
+
(int myStateCellCount, int myStateBitCount) = getContractStateSize(
|
|
407
|
+
my_code(),
|
|
408
|
+
getContractStorage()
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
int minimumStorageFee = get_storage_fee(
|
|
412
|
+
BASECHAIN,
|
|
413
|
+
UlnManager::CONST::minRentSeconds,
|
|
414
|
+
myStateBitCount,
|
|
415
|
+
myStateCellCount
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
;; Ensure the owner cannot rug the contract by pulling out all the rent
|
|
419
|
+
throw_if(
|
|
420
|
+
UlnManager::ERROR::insufficientBalance,
|
|
421
|
+
(getInitialContractBalance() - storage_fees() - claimAmount) < minimumStorageFee
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
actions~pushAction<payment>(getOrigin(), claimAmount, claimAmount);
|
|
425
|
+
|
|
426
|
+
return actions;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
tuple setUlnTreasuryFeeBps(cell $mdEid) impure inline method_id {
|
|
430
|
+
(cell $storage, tuple actions) = preamble();
|
|
431
|
+
int ulnAddress = _calculateUlnAddress($storage, $mdEid.cl::get<uint32>(md::MdEid::eid));
|
|
432
|
+
cell $treasuryFeeBps = $mdEid.cl::get<objRef>(md::MdAddress::md);
|
|
433
|
+
actions~pushAction<call>(
|
|
434
|
+
ulnAddress,
|
|
435
|
+
Uln::OP::SET_TREASURY_FEE_BPS,
|
|
436
|
+
$treasuryFeeBps
|
|
437
|
+
);
|
|
438
|
+
return actions;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
;; This will override an existing tentative owner
|
|
443
|
+
;; Becuase we assert that the 'claimOwnership' can't be done by the 'null' address, it means
|
|
444
|
+
;; if we want to burn the ownership, we will need to set it to a contract which only has ability to
|
|
445
|
+
;; claim, but nothing else. This effectively burns it.
|
|
446
|
+
tuple transferOwnership(cell $setAddress) impure inline {
|
|
447
|
+
(cell $storage, tuple actions) = preamble();
|
|
448
|
+
|
|
449
|
+
setContractStorage(
|
|
450
|
+
$storage.cl::set(
|
|
451
|
+
UlnManager::tentativeOwner,
|
|
452
|
+
$setAddress.cl::get<address>(md::SetAddress::address)
|
|
453
|
+
)
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
actions~pushAction<event>(
|
|
457
|
+
UlnManager::event::OWNER_SET_TENTATIVE,
|
|
458
|
+
$setAddress
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
return actions;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
tuple claimOwnership(cell $emptyMd) impure inline {
|
|
465
|
+
(cell $storage, tuple actions) = preamble();
|
|
466
|
+
|
|
467
|
+
;; permissions check guarantees newOwner == $storage.tentativeOwner
|
|
468
|
+
int newOwner = $storage.cl::get<address>(UlnManager::tentativeOwner);
|
|
469
|
+
|
|
470
|
+
;; this should be caught by the permission check, BUT let's be super safe about this
|
|
471
|
+
throw_if(UlnManager::ERROR::nullTentativeOwner, newOwner == NULLADDRESS);
|
|
472
|
+
|
|
473
|
+
;; erase the tentative owner AND set that tentative owner to the actual owner
|
|
474
|
+
setContractStorage(
|
|
475
|
+
$storage
|
|
476
|
+
.cl::set(UlnManager::tentativeOwner, NULLADDRESS)
|
|
477
|
+
.cl::set(
|
|
478
|
+
UlnManager::baseStorage,
|
|
479
|
+
$storage
|
|
480
|
+
.cl::get<objRef>(UlnManager::baseStorage)
|
|
481
|
+
.cl::set(BaseStorage::owner, newOwner)
|
|
482
|
+
)
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
actions~pushAction<event>(
|
|
486
|
+
UlnManager::event::OWNER_SET,
|
|
487
|
+
md::SetAddress::New(newOwner)
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
return actions;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
(int, int, int) version() impure method_id {
|
|
494
|
+
return (3, 0, 2);
|
|
495
|
+
}
|