@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,60 @@
|
|
|
1
|
+
#include "callbackOpcodes.fc";
|
|
2
|
+
|
|
3
|
+
;; Opcodes
|
|
4
|
+
const int Channel::OP::SET_EP_CONFIG_OAPP = "Channel::OP::SET_EP_CONFIG_OAPP"c;
|
|
5
|
+
const int Channel::OP::MSGLIB_SEND_CALLBACK = "Channel::OP::MSGLIB_SEND_CALLBACK"c;
|
|
6
|
+
const int Channel::OP::CHANNEL_SEND = "Channel::OP::CHANNEL_SEND"c;
|
|
7
|
+
const int Channel::OP::CHANNEL_COMMIT_PACKET = "Channel::OP::CHANNEL_COMMIT_PACKET"c;
|
|
8
|
+
const int Channel::OP::LZ_RECEIVE_PREPARE = "Channel::OP::LZ_RECEIVE_PREPARE"c;
|
|
9
|
+
const int Channel::OP::DEPOSIT_ZRO = "Channel::OP::DEPOSIT_ZRO"c;
|
|
10
|
+
const int Channel::OP::NILIFY = "Channel::OP::NILIFY"c;
|
|
11
|
+
const int Channel::OP::BURN = "Channel::OP::BURN"c;
|
|
12
|
+
const int Channel::OP::FORCE_ABORT = "Channel::OP::FORCE_ABORT"c;
|
|
13
|
+
const int Channel::OP::LZ_RECEIVE_LOCK = "Channel::OP::LZ_RECEIVE_LOCK"c;
|
|
14
|
+
const int Channel::OP::SYNC_MSGLIB_CONNECTION = "Channel::OP::SYNC_MSGLIB_CONNECTION"c;
|
|
15
|
+
const int Channel::OP::LZ_RECEIVE_EXECUTE_CALLBACK = "Channel::OP::LZ_RECEIVE_EXECUTE_CALLBACK"c;
|
|
16
|
+
const int Channel::OP::NOTIFY_PACKET_EXECUTED = "Channel::OP::NOTIFY_PACKET_EXECUTED"c;
|
|
17
|
+
const int Channel::OP::EMIT_LZ_RECEIVE_ALERT = "Channel::OP::EMIT_LZ_RECEIVE_ALERT"c;
|
|
18
|
+
|
|
19
|
+
;; EVENTS
|
|
20
|
+
const int Channel::event::EP_CFG_OAPP_SET = "Channel::event::EP_CFG_OAPP_SET"u;
|
|
21
|
+
const int Channel::event::PACKET_SENT = "Channel::event::PACKET_SENT"u;
|
|
22
|
+
const int Channel::event::PACKET_COMMITTED = "Channel::event::PACKET_COMMITTED"u;
|
|
23
|
+
const int Channel::event::PACKET_NILIFIED = "Channel::event::PACKET_NILIFIED"u;
|
|
24
|
+
const int Channel::event::PACKET_BURNED = "Channel::event::PACKET_BURNED"u;
|
|
25
|
+
const int Channel::event::DELIVERED = "Channel::event::DELIVERED"u;
|
|
26
|
+
const int Channel::event::LZ_RECEIVE_ALERT = "Channel::event::LZ_RECEIVE_ALERT"u;
|
|
27
|
+
const int Channel::event::NOT_EXECUTABLE = "Channel::event::NOT_EXECUTABLE"u;
|
|
28
|
+
const int Channel::event::ZRO_DEPOSITED = "Channel::event::ZRO_DEPOSITED"u;
|
|
29
|
+
|
|
30
|
+
;; ERRORS
|
|
31
|
+
const int Channel::ERROR::onlyEndpoint = 129;
|
|
32
|
+
const int Channel::ERROR::onlyOApp = 130;
|
|
33
|
+
const int Channel::ERROR::onlyApprovedSendMsglib = 131;
|
|
34
|
+
const int Channel::ERROR::onlyApprovedReceiveMsglib = 132;
|
|
35
|
+
const int Channel::ERROR::invalidNonce = 133;
|
|
36
|
+
const int Channel::ERROR::cannotAbortSend = 134;
|
|
37
|
+
const int Channel::ERROR::sendAborted = 135;
|
|
38
|
+
const int Channel::ERROR::notEnoughNative = 136;
|
|
39
|
+
const int Channel::ERROR::notEnoughZroToken = 137;
|
|
40
|
+
const int Channel::ERROR::sendQueueCongested = 138;
|
|
41
|
+
const int Channel::ERROR::notEnoughZroTokenBalance = 139;
|
|
42
|
+
const int Channel::ERROR::notCommittable = 140;
|
|
43
|
+
const int Channel::ERROR::notExecutable = 141;
|
|
44
|
+
const int Channel::ERROR::notExecuting = 142;
|
|
45
|
+
const int Channel::ERROR::wrongPath = 143;
|
|
46
|
+
const int Channel::NO_ERROR = 0;
|
|
47
|
+
|
|
48
|
+
;; States for view function and packet executability management
|
|
49
|
+
const int ExecutionStatus::uncommitted = 0;
|
|
50
|
+
const int ExecutionStatus::committedNotExecutable = 1;
|
|
51
|
+
const int ExecutionStatus::executable = 2;
|
|
52
|
+
const int ExecutionStatus::executed = 3;
|
|
53
|
+
const int ExecutionStatus::executing = 4; ;; new state
|
|
54
|
+
const int ExecutionStatus::committed = 8; ;; only used internally
|
|
55
|
+
|
|
56
|
+
const int ExecutionQueue::uncommitted = 0;
|
|
57
|
+
const int ExecutionQueue::executing = 1;
|
|
58
|
+
const int ExecutionQueue::committed = 2;
|
|
59
|
+
|
|
60
|
+
const int SendRequestQueue::sending = 1;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include "../core/abstract/protocolMain.fc";
|
|
2
|
+
|
|
3
|
+
#include "handler.fc";
|
|
4
|
+
#include "interface.fc";
|
|
5
|
+
|
|
6
|
+
tuple _executeOpcode(int op, cell $md) impure inline {
|
|
7
|
+
if (op == Channel::OP::SET_EP_CONFIG_OAPP) {
|
|
8
|
+
return setEpConfigOApp($md);
|
|
9
|
+
} elseif (op == Channel::OP::CHANNEL_SEND) {
|
|
10
|
+
return channelSend($md);
|
|
11
|
+
} elseif (op == Channel::OP::MSGLIB_SEND_CALLBACK) {
|
|
12
|
+
return msglibSendCallback($md);
|
|
13
|
+
} elseif (op == Channel::OP::CHANNEL_COMMIT_PACKET) {
|
|
14
|
+
return channelCommitPacket($md);
|
|
15
|
+
} elseif (op == Channel::OP::LZ_RECEIVE_PREPARE) {
|
|
16
|
+
return lzReceivePrepare($md);
|
|
17
|
+
} elseif (op == Channel::OP::LZ_RECEIVE_LOCK) {
|
|
18
|
+
return lzReceiveLock($md);
|
|
19
|
+
} elseif (op == Channel::OP::LZ_RECEIVE_EXECUTE_CALLBACK) {
|
|
20
|
+
return lzReceiveExecuteCallback($md);
|
|
21
|
+
} elseif (op == Channel::OP::DEPOSIT_ZRO) {
|
|
22
|
+
return depositZro($md);
|
|
23
|
+
} elseif (op == Channel::OP::NILIFY) {
|
|
24
|
+
return nilify($md);
|
|
25
|
+
} elseif (op == Channel::OP::BURN) {
|
|
26
|
+
return burn($md);
|
|
27
|
+
} elseif (op == Channel::OP::FORCE_ABORT) {
|
|
28
|
+
return forceAbort($md);
|
|
29
|
+
} elseif (op == Channel::OP::SYNC_MSGLIB_CONNECTION) {
|
|
30
|
+
return syncMsglibConnection($md);
|
|
31
|
+
} elseif (op == Channel::OP::NOTIFY_PACKET_EXECUTED) {
|
|
32
|
+
return notifyPacketExecuted($md);
|
|
33
|
+
} elseif (op == Channel::OP::EMIT_LZ_RECEIVE_ALERT) {
|
|
34
|
+
return emitLzReceiveAlert($md);
|
|
35
|
+
} else {
|
|
36
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
37
|
+
}
|
|
38
|
+
return empty_tuple();
|
|
39
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#include "../../funC++/dataStructures/PipelinedOutOfOrder.fc";
|
|
2
|
+
|
|
3
|
+
#include "../../classes/lz/EpConfig.fc";
|
|
4
|
+
|
|
5
|
+
#include "../core/baseStorage.fc";
|
|
6
|
+
|
|
7
|
+
;; maximum concurrent sendable inflight send requests
|
|
8
|
+
;; must be low to avoid permanent bricking
|
|
9
|
+
const Channel::MAX_SEND_SLOTS = MAX_CELL_BITS;
|
|
10
|
+
|
|
11
|
+
;; required object name
|
|
12
|
+
const int Channel::NAME = "channel"u;
|
|
13
|
+
|
|
14
|
+
;; field names
|
|
15
|
+
;; Init state (sharding key)
|
|
16
|
+
const int Channel::baseStorage = 0;
|
|
17
|
+
const int Channel::path = 1;
|
|
18
|
+
|
|
19
|
+
;; Both send and receive channel state
|
|
20
|
+
const int Channel::endpointAddress = 2;
|
|
21
|
+
const int Channel::epConfigOApp = 3;
|
|
22
|
+
|
|
23
|
+
;; Send channel state
|
|
24
|
+
const int Channel::outboundNonce = 4;
|
|
25
|
+
const int Channel::sendRequestQueue = 5;
|
|
26
|
+
const int Channel::lastSendRequestId = 6;
|
|
27
|
+
|
|
28
|
+
;; Receive channel state
|
|
29
|
+
const int Channel::commitPOOO = 7;
|
|
30
|
+
|
|
31
|
+
;; Used to track the commit verification queue / capacity
|
|
32
|
+
const int Channel::executePOOO = 8;
|
|
33
|
+
const int Channel::executionQueue = 9;
|
|
34
|
+
|
|
35
|
+
const int Channel::zroBalance = 10;
|
|
36
|
+
|
|
37
|
+
;; @owner manager
|
|
38
|
+
cell Channel::New(int owner, cell $path, int endpointAddress) inline method_id {
|
|
39
|
+
return cl::declare(
|
|
40
|
+
Channel::NAME,
|
|
41
|
+
unsafeTuple([
|
|
42
|
+
[cl::t::objRef, BaseStorage::New(owner)], ;; Channel::baseStorage
|
|
43
|
+
[cl::t::objRef, $path], ;; Channel::path
|
|
44
|
+
[cl::t::address, endpointAddress], ;; Channel::endpointAddress
|
|
45
|
+
[cl::t::objRef, lz::EpConfig::NewWithDefaults()], ;; Channel::epConfigOApp
|
|
46
|
+
[cl::t::uint64, 0], ;; Channel::outboundNonce
|
|
47
|
+
[cl::t::dict256, empty_cell()], ;; Channel::sendRequestQueue
|
|
48
|
+
[cl::t::uint64, 0], ;; Channel::sendRequestId
|
|
49
|
+
[cl::t::objRef, POOO::New()], ;; Channel::commitPOOO
|
|
50
|
+
[cl::t::objRef, POOO::New()], ;; Channel::executePOOO
|
|
51
|
+
[cl::t::cellRef, empty_cell()], ;; Channel::executionQueue (DICQ)
|
|
52
|
+
[cl::t::coins, 0] ;; Channel::zroBalance
|
|
53
|
+
])
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
;;; ===============================================================
|
|
2
|
+
;; The controller is only used for deployment and configuration.
|
|
3
|
+
;; Controller handlers are not necessarily gas efficient, as they
|
|
4
|
+
;; are expected to be called infrequently.
|
|
5
|
+
;; No dictionaries exist in the controller, so there is no risk of
|
|
6
|
+
;; gas usage increasing over time and resulting in DoS due to the 1m gas
|
|
7
|
+
;; limit.
|
|
8
|
+
;;; ===============================================================
|
|
9
|
+
|
|
10
|
+
#include "../core/abstract/protocolHandler.fc";
|
|
11
|
+
|
|
12
|
+
#include "../../classes/lz/Path.fc";
|
|
13
|
+
|
|
14
|
+
#include "../../classes/msgdata/Deploy.fc";
|
|
15
|
+
#include "../../classes/msgdata/ExtendedMd.fc";
|
|
16
|
+
#include "../../classes/msgdata/CoinsAmount.fc";
|
|
17
|
+
#include "../../classes/msgdata/AddMsglib.fc";
|
|
18
|
+
#include "../../classes/msgdata/InitEndpoint.fc";
|
|
19
|
+
#include "../../classes/msgdata/MdEid.fc";
|
|
20
|
+
#include "../../classes/msgdata/MdObj.fc";
|
|
21
|
+
#include "../../classes/msgdata/SetAddress.fc";
|
|
22
|
+
|
|
23
|
+
#include "../core/baseStorage.fc";
|
|
24
|
+
|
|
25
|
+
#include "../channel/storage.fc";
|
|
26
|
+
#include "../endpoint/storage.fc";
|
|
27
|
+
#include "../interfaces.fc";
|
|
28
|
+
|
|
29
|
+
#include "interface.fc";
|
|
30
|
+
#include "storage.fc";
|
|
31
|
+
|
|
32
|
+
;;; ================INTERFACE FUNCTIONS=====================
|
|
33
|
+
|
|
34
|
+
(cell, tuple) _initialize(cell $md) impure inline {
|
|
35
|
+
return preamble();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
;; should be the protocol owner's zro wallet
|
|
39
|
+
int _getZroWalletAddress() inline method_id {
|
|
40
|
+
return getContractStorage().cl::get<address>(Controller::zroWallet);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
() assertTentativeOwner() impure inline {
|
|
44
|
+
throw_unless(
|
|
45
|
+
Controller::ERROR::onlyTentativeOwner,
|
|
46
|
+
getCaller() == getContractStorage().cl::get<address>(Controller::tentativeOwner)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
int _getEventSink() inline {
|
|
51
|
+
return getContractAddress();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
;;; ================PERMISSION FUNCTIONS=====================
|
|
55
|
+
|
|
56
|
+
() _checkPermissions(int op, cell $md) impure inline {
|
|
57
|
+
if (op == Controller::OP::DEPLOY_CHANNEL) {
|
|
58
|
+
;; Controller::OP::DEPLOY_CHANNEL determines the initial storage of
|
|
59
|
+
;; the deployed channel by the caller address, making this opcode
|
|
60
|
+
;; safe for open and public calls
|
|
61
|
+
return ();
|
|
62
|
+
} elseif (op == Controller::OP::SET_EP_CONFIG_OAPP) {
|
|
63
|
+
cell $path = $md.cl::get<objRef>(md::ExtendedMd::obj);
|
|
64
|
+
throw_unless(
|
|
65
|
+
Controller::ERROR::onlyOApp,
|
|
66
|
+
getCaller() == $path.cl::get<uint256>(lz::Path::srcOApp)
|
|
67
|
+
);
|
|
68
|
+
} elseif (
|
|
69
|
+
(op == Controller::OP::DEPLOY_ENDPOINT)
|
|
70
|
+
| (op == Controller::OP::ADD_MSGLIB)
|
|
71
|
+
| (op == Controller::OP::SET_EP_CONFIG_DEFAULTS)
|
|
72
|
+
| (op == Controller::OP::SET_ZRO_WALLET)
|
|
73
|
+
| (op == Controller::OP::TRANSFER_OWNERSHIP)
|
|
74
|
+
) {
|
|
75
|
+
return assertOwner();
|
|
76
|
+
} elseif (op == Controller::OP::CLAIM_OWNERSHIP) {
|
|
77
|
+
return assertTentativeOwner();
|
|
78
|
+
} elseif (op == Controller::OP::EXCESSES) {
|
|
79
|
+
throw_unless(Controller::ERROR::onlyZroWallet, getCaller() == _getZroWalletAddress());
|
|
80
|
+
} else {
|
|
81
|
+
;; Any other opcodes will throw, to limit possibility of unexpected behaviors
|
|
82
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
;;; ==========================HELPER FUNCTIONS=====================================
|
|
87
|
+
|
|
88
|
+
int _calculateEndpointAddress(int dstEid) impure inline method_id {
|
|
89
|
+
throw_if(Controller::ERROR::invalidEid, dstEid == 0);
|
|
90
|
+
|
|
91
|
+
return computeContractAddress(
|
|
92
|
+
Endpoint::New(
|
|
93
|
+
getContractStorage().cl::get<uint32>(Controller::eid),
|
|
94
|
+
dstEid,
|
|
95
|
+
getContractAddress()
|
|
96
|
+
),
|
|
97
|
+
getContractStorage().cl::get<cellRef>(Controller::endpointCode)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
;;; ==========================VIEW FUNCTIONS=====================================
|
|
102
|
+
|
|
103
|
+
;; _verifyEventSender is used by offchain entities to verify that an event emitted
|
|
104
|
+
;; by the controller was sent by a protocol contract (endpoint or channel).
|
|
105
|
+
;; Each event transaction includes the storage init of the event emitting contract,
|
|
106
|
+
;; which is used to verify the sender is the contract they claim to be.
|
|
107
|
+
|
|
108
|
+
;; Returns true if the event originates from a protocol contract.
|
|
109
|
+
;; returns false if the event does not originate from a protocol contract.
|
|
110
|
+
int _verifyEventSender(int sender, cell $senderStorageInit) impure method_id {
|
|
111
|
+
cell $storage = getContractStorage();
|
|
112
|
+
|
|
113
|
+
int storageType = cl::typeof($senderStorageInit);
|
|
114
|
+
int senderOwner = $senderStorageInit
|
|
115
|
+
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
116
|
+
.cl::get<address>(BaseStorage::owner);
|
|
117
|
+
|
|
118
|
+
;; If senderOwner != controller address, then this event sender might be using the correct
|
|
119
|
+
;; bytecode and storage but be part of a different LayerZero protocol deployment owned
|
|
120
|
+
;; by a different signer.
|
|
121
|
+
throw_if(BaseInterface::ERROR::invalidEventSource, senderOwner != getContractAddress());
|
|
122
|
+
|
|
123
|
+
if (storageType == Endpoint::NAME) {
|
|
124
|
+
cell endpointCode = $storage.cl::get<cellRef>(Controller::endpointCode);
|
|
125
|
+
throw_unless(
|
|
126
|
+
BaseInterface::ERROR::invalidEventSource,
|
|
127
|
+
sender == computeContractAddress($senderStorageInit, endpointCode)
|
|
128
|
+
);
|
|
129
|
+
} elseif (storageType == Channel::NAME) {
|
|
130
|
+
cell channelCode = $storage.cl::get<cellRef>(Controller::channelCode);
|
|
131
|
+
throw_unless(
|
|
132
|
+
BaseInterface::ERROR::invalidEventSource,
|
|
133
|
+
sender == computeContractAddress($senderStorageInit, channelCode)
|
|
134
|
+
);
|
|
135
|
+
} else {
|
|
136
|
+
throw(BaseInterface::ERROR::invalidEventSource);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
;;; ==========================HANDLERS=====================================
|
|
143
|
+
|
|
144
|
+
;; @in owner EOA
|
|
145
|
+
;; @in_md deployEndpoint
|
|
146
|
+
;; @out endpoint/handler.fc
|
|
147
|
+
;; @out_md deployAndCall(endpointInitData, endpointCode, endpoint_initialize)
|
|
148
|
+
;; @permissions only owner
|
|
149
|
+
tuple deployEndpoint(cell $deploy) impure inline method_id {
|
|
150
|
+
(cell $storage, tuple actions) = preamble();
|
|
151
|
+
|
|
152
|
+
int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
153
|
+
throw_if(Controller::ERROR::invalidEid, dstEid == 0);
|
|
154
|
+
|
|
155
|
+
int eid = $storage.cl::get<uint32>(Controller::eid);
|
|
156
|
+
|
|
157
|
+
actions~pushAction<deployAndCall>(
|
|
158
|
+
$storage.cl::get<cellRef>(Controller::endpointCode),
|
|
159
|
+
Endpoint::New(eid, dstEid, getContractAddress()),
|
|
160
|
+
$deploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
161
|
+
BaseInterface::OP::INITIALIZE,
|
|
162
|
+
md::InitEndpoint::New($storage.cl::get<cellRef>(Controller::channelCode)),
|
|
163
|
+
0
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return actions;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
;; @in oApp
|
|
170
|
+
;; @in_md deployChannel
|
|
171
|
+
;; @out channel/handler.fc
|
|
172
|
+
;; @out_md deployAndCall(endpoint_state_init, endpointCode, channel_initialize)
|
|
173
|
+
;; @note: There's no need to check for permissions here because ctx.SENDER is derived from the oApp.
|
|
174
|
+
;; @permissionless
|
|
175
|
+
tuple deployChannel(cell $deploy) impure inline method_id {
|
|
176
|
+
(cell $storage, tuple actions) = preamble();
|
|
177
|
+
|
|
178
|
+
int dstEid = $deploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
179
|
+
|
|
180
|
+
;; create the path object
|
|
181
|
+
cell $path = lz::Path::New(
|
|
182
|
+
$storage.cl::get<uint32>(Controller::eid), ;; srcEid
|
|
183
|
+
getCaller(), ;; srcOApp
|
|
184
|
+
dstEid, ;; dstEid
|
|
185
|
+
$deploy.cl::get<uint256>(md::Deploy::dstOApp) ;; dstOApp
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
;; get the endpoint address
|
|
189
|
+
int endpointAddress = _calculateEndpointAddress(dstEid);
|
|
190
|
+
|
|
191
|
+
actions~pushAction<deployAndCall>(
|
|
192
|
+
$storage.cl::get<cellRef>(Controller::channelCode),
|
|
193
|
+
Channel::New(getContractAddress(), $path, endpointAddress),
|
|
194
|
+
$deploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
195
|
+
BaseInterface::OP::INITIALIZE,
|
|
196
|
+
cl::nullObject(),
|
|
197
|
+
0
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
return actions;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
;; @in owner EOA
|
|
204
|
+
;; @in_md setEpConfigDefaults
|
|
205
|
+
;; @out endpoint/handler.fc/setEpConfigDefaults
|
|
206
|
+
;; @out_md setEpConfig
|
|
207
|
+
;; @permissions only owner
|
|
208
|
+
tuple setEpConfigDefaults(cell $mdEid) impure inline method_id {
|
|
209
|
+
(_, tuple actions) = preamble();
|
|
210
|
+
|
|
211
|
+
int dstEid = $mdEid.cl::get<uint32>(md::MdEid::eid);
|
|
212
|
+
|
|
213
|
+
actions~pushAction<call>(
|
|
214
|
+
_calculateEndpointAddress(dstEid),
|
|
215
|
+
Endpoint::OP::SET_EP_CONFIG_DEFAULTS,
|
|
216
|
+
$mdEid.cl::get<objRef>(md::MdEid::md)
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
return actions;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
;; @in OApp contract
|
|
223
|
+
;; @in_md ExtendedMd(path, setEpConfig)
|
|
224
|
+
;; @out endpoint/handler.fc/setEpConfig
|
|
225
|
+
;; @out_md ExtendedMd(channelAddress, setEpConfig)
|
|
226
|
+
;; @note: There's no need to check for permissions here because ctx.SENDER is derived from the oApp.
|
|
227
|
+
;; Any configuration changes made will only impact the `oApp` that invokes this function.
|
|
228
|
+
;; @permissionless
|
|
229
|
+
tuple setEpConfigOApp(cell $mdObj) impure inline method_id {
|
|
230
|
+
(_, tuple actions) = preamble();
|
|
231
|
+
|
|
232
|
+
;; get the path and setEpConfigMd from the md
|
|
233
|
+
cell $path = $mdObj.cl::get<objRef>(md::MdObj::obj);
|
|
234
|
+
|
|
235
|
+
actions~pushAction<call>(
|
|
236
|
+
_calculateEndpointAddress($path.cl::get<uint32>(lz::Path::dstEid)),
|
|
237
|
+
Endpoint::OP::SET_EP_CONFIG_OAPP,
|
|
238
|
+
$mdObj
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
return actions;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
tuple addMsglib(cell $addMsglibMd) impure inline method_id {
|
|
245
|
+
(_, tuple actions) = preamble();
|
|
246
|
+
|
|
247
|
+
actions~pushAction<call>(
|
|
248
|
+
_calculateEndpointAddress(
|
|
249
|
+
$addMsglibMd.cl::get<uint32>(md::AddMsglib::dstEid)
|
|
250
|
+
),
|
|
251
|
+
Endpoint::OP::ADD_MSGLIB,
|
|
252
|
+
$addMsglibMd
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
return actions;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
;; only controller zro wallet
|
|
259
|
+
tuple depositZro(cell $path) impure inline method_id {
|
|
260
|
+
(cell $storage, tuple actions) = preamble();
|
|
261
|
+
|
|
262
|
+
;; The message format of jetton happens to align with funC++
|
|
263
|
+
;; but the jetton token amount is aliased as donationNanos
|
|
264
|
+
int tokenAmount = getDonationNanos();
|
|
265
|
+
setDonationNanos(0);
|
|
266
|
+
|
|
267
|
+
;; get the endpoint address
|
|
268
|
+
int endpointAddress = _calculateEndpointAddress($path.cl::get<uint32>(lz::Path::dstEid));
|
|
269
|
+
|
|
270
|
+
int channelAddress = computeContractAddress(
|
|
271
|
+
Channel::New(getContractAddress(), $path, endpointAddress),
|
|
272
|
+
$storage.cl::get<cellRef>(Controller::channelCode)
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
actions~pushAction<call>(
|
|
276
|
+
channelAddress,
|
|
277
|
+
Channel::OP::DEPOSIT_ZRO,
|
|
278
|
+
md::CoinsAmount::New(tokenAmount)
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
return actions;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
tuple setZroWallet(cell $setAddress) impure inline method_id {
|
|
285
|
+
(cell $storage, tuple actions) = preamble();
|
|
286
|
+
|
|
287
|
+
setContractStorage(
|
|
288
|
+
$storage.cl::set(
|
|
289
|
+
Controller::zroWallet,
|
|
290
|
+
$setAddress.cl::get<address>(md::SetAddress::address)
|
|
291
|
+
)
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
actions~pushAction<event>(Controller::event::ZRO_WALLET_SET, $setAddress);
|
|
295
|
+
return actions;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
;; This will override an existing tentative owner
|
|
299
|
+
;; Becuase we assert that the 'claimOwnership' can't be done by the 'null' address, it means
|
|
300
|
+
;; if we want to burn the ownership, we will need to set it to a contract which only has ability to
|
|
301
|
+
;; claim, but nothing else. This effectively burns it.
|
|
302
|
+
tuple transferOwnership(cell $setAddress) impure inline {
|
|
303
|
+
(cell $storage, tuple actions) = preamble();
|
|
304
|
+
|
|
305
|
+
setContractStorage(
|
|
306
|
+
$storage.cl::set(
|
|
307
|
+
Controller::tentativeOwner,
|
|
308
|
+
$setAddress.cl::get<address>(md::SetAddress::address)
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
actions~pushAction<event>(
|
|
313
|
+
Controller::event::OWNER_SET_TENTATIVE,
|
|
314
|
+
$setAddress
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
return actions;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
tuple claimOwnership(cell $emptyMd) impure inline {
|
|
321
|
+
(cell $storage, tuple actions) = preamble();
|
|
322
|
+
|
|
323
|
+
;; permissions check guarantees newOwner == $storage.tentativeOwner
|
|
324
|
+
int newOwner = $storage.cl::get<address>(Controller::tentativeOwner);
|
|
325
|
+
|
|
326
|
+
;; this should be caught by the permission check, BUT let's be super safe about this
|
|
327
|
+
throw_if(Controller::ERROR::nullTentativeOwner, newOwner == NULLADDRESS);
|
|
328
|
+
|
|
329
|
+
;; erase the tentative owner AND set that tentative owner to the actual owner
|
|
330
|
+
setContractStorage(
|
|
331
|
+
$storage
|
|
332
|
+
.cl::set(Controller::tentativeOwner, NULLADDRESS)
|
|
333
|
+
.cl::set(
|
|
334
|
+
Controller::baseStorage,
|
|
335
|
+
$storage
|
|
336
|
+
.cl::get<objRef>(Controller::baseStorage)
|
|
337
|
+
.cl::set(BaseStorage::owner, newOwner)
|
|
338
|
+
)
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
actions~pushAction<event>(
|
|
342
|
+
Controller::event::OWNER_SET,
|
|
343
|
+
md::SetAddress::New(newOwner)
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
return actions;
|
|
347
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const int MAX_MSGLIBS = 255;
|
|
2
|
+
|
|
3
|
+
;; OPCODES
|
|
4
|
+
const int Controller::OP::DEPLOY_ENDPOINT = "Controller::OP::DEPLOY_ENDPOINT"c;
|
|
5
|
+
const int Controller::OP::DEPLOY_CHANNEL = "Controller::OP::DEPLOY_CHANNEL"c;
|
|
6
|
+
const int Controller::OP::SET_EP_CONFIG_DEFAULTS = "Controller::OP::SET_EP_CONFIG_DEFAULTS"c;
|
|
7
|
+
const int Controller::OP::SET_EP_CONFIG_OAPP = "Controller::OP::SET_EP_CONFIG_OAPP"c;
|
|
8
|
+
const int Controller::OP::ADD_MSGLIB = "Controller::OP::ADD_MSGLIB"c;
|
|
9
|
+
const int Controller::OP::DEPOSIT_ZRO = "Controller::OP::DEPOSIT_ZRO"c;
|
|
10
|
+
const int Controller::OP::SET_ZRO_WALLET = "Controller::OP::SET_ZRO_WALLET"c;
|
|
11
|
+
const int Controller::OP::EXCESSES = 0xd53276db; ;; op::excesses: 0xd53276db
|
|
12
|
+
const int Controller::OP::TRANSFER_OWNERSHIP = "Controller::OP::TRANSFER_OWNERSHIP"c;
|
|
13
|
+
const int Controller::OP::CLAIM_OWNERSHIP = "Controller::OP::CLAIM_OWNERSHIP"c;
|
|
14
|
+
|
|
15
|
+
;; EVENT
|
|
16
|
+
const int Controller::event::ZRO_WALLET_SET = "Controller::event::ZRO_WALLT_SET"u;
|
|
17
|
+
const int Controller::event::OWNER_SET = "Controller::event::OWNER_SET"u;
|
|
18
|
+
const int Controller::event::OWNER_SET_TENTATIVE = "Controller::event::OWNERSET_TENT"u;
|
|
19
|
+
|
|
20
|
+
;; ERRORS
|
|
21
|
+
const int Controller::ERROR::onlyOApp = 65;
|
|
22
|
+
const int Controller::ERROR::invalidEid = 66;
|
|
23
|
+
const int Controller::ERROR::onlyZroWallet = 67;
|
|
24
|
+
const int Controller::ERROR::onlyTentativeOwner = 68;
|
|
25
|
+
const int Controller::ERROR::nullTentativeOwner = 69;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include "../core/abstract/protocolMain.fc";
|
|
2
|
+
|
|
3
|
+
#include "handler.fc";
|
|
4
|
+
#include "interface.fc";
|
|
5
|
+
|
|
6
|
+
tuple _executeOpcode(int op, cell $md) impure inline {
|
|
7
|
+
if (op == Controller::OP::DEPLOY_ENDPOINT) {
|
|
8
|
+
return deployEndpoint($md);
|
|
9
|
+
} elseif (op == Controller::OP::DEPLOY_CHANNEL) {
|
|
10
|
+
return deployChannel($md);
|
|
11
|
+
} elseif (op == Controller::OP::SET_EP_CONFIG_DEFAULTS) {
|
|
12
|
+
return setEpConfigDefaults($md);
|
|
13
|
+
} elseif (op == Controller::OP::SET_EP_CONFIG_OAPP) {
|
|
14
|
+
return setEpConfigOApp($md);
|
|
15
|
+
} elseif (op == Controller::OP::ADD_MSGLIB) {
|
|
16
|
+
return addMsglib($md);
|
|
17
|
+
} elseif (op == Controller::OP::SET_ZRO_WALLET) {
|
|
18
|
+
return setZroWallet($md);
|
|
19
|
+
} elseif (op == Controller::OP::EXCESSES) {
|
|
20
|
+
return depositZro($md);
|
|
21
|
+
} elseif (op == Controller::OP::TRANSFER_OWNERSHIP) {
|
|
22
|
+
return transferOwnership($md);
|
|
23
|
+
} elseif (op == Controller::OP::CLAIM_OWNERSHIP) {
|
|
24
|
+
return claimOwnership($md);
|
|
25
|
+
} else {
|
|
26
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
27
|
+
}
|
|
28
|
+
return empty_tuple();
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#include "../../funC++/constants.fc";
|
|
2
|
+
|
|
3
|
+
#include "../core/baseStorage.fc";
|
|
4
|
+
|
|
5
|
+
const int Controller::NAME = "controller"u;
|
|
6
|
+
|
|
7
|
+
const int Controller::baseStorage = 0;
|
|
8
|
+
const int Controller::eid = 1;
|
|
9
|
+
|
|
10
|
+
;; Bytecodes
|
|
11
|
+
const int Controller::endpointCode = 2;
|
|
12
|
+
const int Controller::channelCode = 3;
|
|
13
|
+
;; Zro wallet
|
|
14
|
+
const int Controller::zroWallet = 4;
|
|
15
|
+
;; tentative owner
|
|
16
|
+
const int Controller::tentativeOwner = 5;
|
|
17
|
+
|
|
18
|
+
;; @owner Protocol admin EOA
|
|
19
|
+
cell Controller::New(int owner, int eid, cell endpointCode, cell channelCode) method_id {
|
|
20
|
+
return cl::declare(
|
|
21
|
+
Controller::NAME,
|
|
22
|
+
unsafeTuple([
|
|
23
|
+
[cl::t::objRef, BaseStorage::New(owner)], ;; Controller::baseStorage
|
|
24
|
+
[cl::t::uint32, eid], ;; Controller::eid
|
|
25
|
+
[cl::t::cellRef, endpointCode], ;; Controller::endpointCode
|
|
26
|
+
[cl::t::cellRef, channelCode], ;; Controller::channelCode
|
|
27
|
+
[cl::t::address, NULLADDRESS], ;; Controller::zroWallet
|
|
28
|
+
[cl::t::address, NULLADDRESS] ;; Controller::tentativeOwner
|
|
29
|
+
])
|
|
30
|
+
);
|
|
31
|
+
}
|