@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,281 @@
|
|
|
1
|
+
;;; =============================================================
|
|
2
|
+
;; Simple Message Library is intended for testing purposes ONLY
|
|
3
|
+
;; It is purposely left unsecure on nearly every interface
|
|
4
|
+
;;; =============================================================
|
|
5
|
+
|
|
6
|
+
#include "../../../core/abstract/protocolHandler.fc";
|
|
7
|
+
#include "../../../../funC++/baseInterface.fc";
|
|
8
|
+
|
|
9
|
+
#include "../../BytesEncoder.fc";
|
|
10
|
+
|
|
11
|
+
#include "../../../../classes/msgdata/ExtendedMd.fc";
|
|
12
|
+
#include "../../../../classes/msgdata/MdObj.fc";
|
|
13
|
+
#include "../../../../classes/msgdata/MdAddress.fc";
|
|
14
|
+
#include "../../../../classes/msgdata/AddMsglib.fc";
|
|
15
|
+
#include "../../../../classes/msgdata/MsglibSendCallback.fc";
|
|
16
|
+
#include "../../../../classes/msgdata/SetSmlManagerConfig.fc";
|
|
17
|
+
#include "../../../../classes/msgdata/Deploy.fc";
|
|
18
|
+
#include "../../../../classes/msgdata/InitSmlConnection.fc";
|
|
19
|
+
#include "../../../../classes/msgdata/LzSend.fc";
|
|
20
|
+
#include "../../../../classes/lz/Path.fc";
|
|
21
|
+
#include "../../../../classes/lz/MsglibInfo.fc";
|
|
22
|
+
#include "../../../../classes/lz/Packet.fc";
|
|
23
|
+
#include "../../../../classes/lz/SmlJobAssigned.fc";
|
|
24
|
+
|
|
25
|
+
#include "../../../endpoint/storage.fc";
|
|
26
|
+
#include "../../../channel/storage.fc";
|
|
27
|
+
#include "../smlConnection/interface.fc";
|
|
28
|
+
#include "../smlConnection/storage.fc";
|
|
29
|
+
|
|
30
|
+
#include "../../interface.fc";
|
|
31
|
+
#include "../../../interfaces.fc";
|
|
32
|
+
#include "interface.fc";
|
|
33
|
+
#include "storage.fc";
|
|
34
|
+
#include "../../../channel/interface.fc";
|
|
35
|
+
|
|
36
|
+
;;; ====================HELPER FUNCTIONS====================
|
|
37
|
+
|
|
38
|
+
;; Derive the endpoint address for a given destination EID
|
|
39
|
+
int _deriveEndpointAddress(int dstEid) impure inline method_id {
|
|
40
|
+
cell $storage = getContractStorage();
|
|
41
|
+
cell $endpointStorage = Endpoint::New(
|
|
42
|
+
$storage.cl::get<uint32>(SmlManager::eid),
|
|
43
|
+
dstEid,
|
|
44
|
+
$storage.cl::get<address>(SmlManager::controllerAddress)
|
|
45
|
+
);
|
|
46
|
+
return computeContractAddress(
|
|
47
|
+
$endpointStorage,
|
|
48
|
+
$storage.cl::get<cellRef>(SmlManager::endpointCode)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
;; Derive the channel address for a given path
|
|
53
|
+
int _deriveChannelAddress(cell $path) impure inline method_id {
|
|
54
|
+
cell $storage = getContractStorage();
|
|
55
|
+
int dstEid = $path.cl::get<uint32>(lz::Path::dstEid);
|
|
56
|
+
int endpointAddress = _deriveEndpointAddress(dstEid);
|
|
57
|
+
return computeContractAddress(
|
|
58
|
+
Channel::New(
|
|
59
|
+
$storage.cl::get<address>(SmlManager::controllerAddress),
|
|
60
|
+
$path,
|
|
61
|
+
endpointAddress
|
|
62
|
+
),
|
|
63
|
+
$storage.cl::get<cellRef>(SmlManager::channelCode)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
int _deriveConnectionAddress(cell $path) impure inline method_id {
|
|
68
|
+
return computeContractAddress(
|
|
69
|
+
SmlConnection::New(
|
|
70
|
+
getContractAddress(),
|
|
71
|
+
$path
|
|
72
|
+
),
|
|
73
|
+
getContractStorage().cl::get<cellRef>(SmlManager::smlConnectionCode)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
() assertConnection(cell $extendedMd) impure inline {
|
|
78
|
+
throw_unless(
|
|
79
|
+
SmlManager::ERROR::onlyConnection,
|
|
80
|
+
getCaller() == computeContractAddress(
|
|
81
|
+
$extendedMd.cl::get<objRef>(md::ExtendedMd::obj),
|
|
82
|
+
getContractStorage().cl::get<cellRef>(SmlManager::smlConnectionCode)
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
;;; ================INTERFACE FUNCTIONS=====================
|
|
88
|
+
|
|
89
|
+
(cell, tuple) _initialize(cell $md) impure inline {
|
|
90
|
+
return preamble();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
int _getEventSink() inline {
|
|
94
|
+
return getContractAddress();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
;;; ================PERMISSION FUNCTIONS=====================
|
|
98
|
+
|
|
99
|
+
() _checkPermissions(int op, cell $md) impure inline {
|
|
100
|
+
if (
|
|
101
|
+
(op == SmlManager::OP::SET_MSGLIB_CONFIG)
|
|
102
|
+
| (op == SmlManager::OP::SML_MANAGER_COMMIT_PACKET)
|
|
103
|
+
| (op == MsglibManager::OP::GET_MSGLIB_INFO)
|
|
104
|
+
| (op == MsglibManager::OP::DEPLOY_CONNECTION)
|
|
105
|
+
| (op == SmlManager::OP::SML_MANAGER_COMMIT_PACKET_CALLBACK)
|
|
106
|
+
) {
|
|
107
|
+
;; op code
|
|
108
|
+
;; open and public calls
|
|
109
|
+
return ();
|
|
110
|
+
} elseif (
|
|
111
|
+
(op == SmlManager::OP::SML_MANAGER_SEND)
|
|
112
|
+
) {
|
|
113
|
+
;; assert connection
|
|
114
|
+
assertConnection($md);
|
|
115
|
+
} else {
|
|
116
|
+
;; we must put a check for all opcodes to make sure we don't
|
|
117
|
+
;; mistakenly miss an opp code's permissions
|
|
118
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
;;; ==========================HANDLERS=====================================
|
|
123
|
+
|
|
124
|
+
;; @in permissionless
|
|
125
|
+
;; @in_md ExtendedMd { SetSmlManagerConfig, unused, unused }
|
|
126
|
+
tuple setMsglibConfig(cell $mdExtended) impure inline method_id {
|
|
127
|
+
;; permissionless setting of fees, this is NOT safe for a real msglib
|
|
128
|
+
(cell $storage, tuple actions) = preamble();
|
|
129
|
+
|
|
130
|
+
;; These other extended values arent used,
|
|
131
|
+
;; but it makes the config call adhere to the expected interface
|
|
132
|
+
;; Pull the config md from the extendedMd that gets passed
|
|
133
|
+
cell $SmlManagerConfig = $mdExtended.cl::get<objRef>(md::ExtendedMd::md);
|
|
134
|
+
|
|
135
|
+
setContractStorage(
|
|
136
|
+
$storage
|
|
137
|
+
.cl::set(
|
|
138
|
+
SmlManager::nativeFee,
|
|
139
|
+
$SmlManagerConfig.cl::get<coins>(md::SetSmlManagerConfig::nativeFee)
|
|
140
|
+
)
|
|
141
|
+
.cl::set(
|
|
142
|
+
SmlManager::zroFee,
|
|
143
|
+
$SmlManagerConfig.cl::get<coins>(md::SetSmlManagerConfig::zroFee)
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
actions~pushAction<event>(SmlManager::event::SET_MSGLIB_CONFIG, $SmlManagerConfig);
|
|
148
|
+
|
|
149
|
+
return actions;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
;; @in channel/handler.fc/send
|
|
153
|
+
;; @in_md LzSend
|
|
154
|
+
;; @out channel/handler.fc/msglibSendCallback
|
|
155
|
+
;; @out_md msglibSendCallback
|
|
156
|
+
tuple smlManagerSend(cell $extendedMd) impure inline method_id {
|
|
157
|
+
(cell $storage, tuple actions) = preamble();
|
|
158
|
+
|
|
159
|
+
cell $lzSend = $extendedMd.cl::get<objRef>(md::ExtendedMd::md);
|
|
160
|
+
|
|
161
|
+
int nativeFee = $storage.cl::get<coins>(SmlManager::nativeFee);
|
|
162
|
+
|
|
163
|
+
;;--------------------------
|
|
164
|
+
;; PACKET V1 CODEC
|
|
165
|
+
;;--------------------------
|
|
166
|
+
cell $packetObj = $lzSend.cl::get<objRef>(md::LzSend::packet);
|
|
167
|
+
cell packet = BytesEncoder::build<PacketV1>($packetObj)
|
|
168
|
+
.BytesEncoder::serialize();
|
|
169
|
+
|
|
170
|
+
cell $msglibSendCallbackMd = md::MsglibSendCallback::New(
|
|
171
|
+
nativeFee,
|
|
172
|
+
$storage.cl::get<coins>(SmlManager::zroFee),
|
|
173
|
+
$lzSend,
|
|
174
|
+
packet, ;; encoded Packet
|
|
175
|
+
serializePayees(
|
|
176
|
+
unsafeTuple([
|
|
177
|
+
[getContractAddress(), nativeFee]
|
|
178
|
+
])
|
|
179
|
+
),
|
|
180
|
+
PacketV1::nonceOffsetBytes,
|
|
181
|
+
PacketV1::nonceBytes,
|
|
182
|
+
PacketV1::guidOffsetBytes,
|
|
183
|
+
PacketV1::guidBytes,
|
|
184
|
+
lz::SmlJobAssigned::New(nativeFee),
|
|
185
|
+
Channel::NO_ERROR
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
actions~pushAction<call>(
|
|
189
|
+
$extendedMd.cl::get<address>(md::ExtendedMd::forwardingAddress), ;; channelAddress
|
|
190
|
+
Channel::OP::MSGLIB_SEND_CALLBACK,
|
|
191
|
+
md::MdAddress::New(
|
|
192
|
+
$msglibSendCallbackMd,
|
|
193
|
+
getContractAddress()
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
return actions;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
;; @in permissionless external message
|
|
201
|
+
;; @in_md msglibCommitPacket { packet_header: [objRef], message: [cellRef] }
|
|
202
|
+
;; @out_success => smlConnection/handler.fc/msglibConnectionCommitPacket
|
|
203
|
+
;; @out_md_success => ExtendedMd(ep_commit_verification, _, _)
|
|
204
|
+
;; @out_failure => caller (refund, failure)
|
|
205
|
+
tuple smlManagerCommitPacket(cell $mdAddress) impure inline method_id {
|
|
206
|
+
(_, tuple actions) = preamble();
|
|
207
|
+
|
|
208
|
+
cell $packet = $mdAddress.cl::get<objRef>(md::MdAddress::md);
|
|
209
|
+
|
|
210
|
+
int connectionAddress = _deriveConnectionAddress(
|
|
211
|
+
lz::Path::reverse($packet.cl::get<objRef>(lz::Packet::path))
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
;; @notice In Simple Msglib,
|
|
215
|
+
;; we purposely do not verify that the message hash is the same as the stored message hash
|
|
216
|
+
actions~pushAction<call>(
|
|
217
|
+
connectionAddress,
|
|
218
|
+
SmlConnection::OP::SML_CONNECTION_COMMIT_PACKET,
|
|
219
|
+
$mdAddress
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return actions;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
;; @in endpoint/handler.fc/getMsgLib
|
|
226
|
+
;; @in_md AddMsglib
|
|
227
|
+
;; @out endpoint/handler.fc/getMsglibInfoCallback
|
|
228
|
+
;; @out_md MsglibInfo
|
|
229
|
+
tuple getMsgLibInfo(cell $addMsglibMd) impure inline method_id {
|
|
230
|
+
(cell $storage, tuple actions) = preamble();
|
|
231
|
+
|
|
232
|
+
cell $msglibInfo = lz::MsglibInfo::New(
|
|
233
|
+
getContractAddress(), ;; for SML, the manager IS the msglib
|
|
234
|
+
$storage.cl::get<cellRef>(SmlManager::smlConnectionCode),
|
|
235
|
+
SmlConnection::New(
|
|
236
|
+
getContractAddress(), ;; connection is owned by the manager
|
|
237
|
+
lz::Path::endpointPath(
|
|
238
|
+
$storage.cl::get<uint32>(SmlManager::eid),
|
|
239
|
+
$addMsglibMd.cl::get<uint32>(md::AddMsglib::dstEid)
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
actions~pushAction<call>(
|
|
245
|
+
getCaller(),
|
|
246
|
+
Endpoint::OP::GET_MSGLIB_INFO_CALLBACK,
|
|
247
|
+
$msglibInfo
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
return actions;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
;; @in smlConnection
|
|
254
|
+
;; @in_md MdObj { Packet, SmlConnection (initial storage) }
|
|
255
|
+
tuple smlManagerCommitPacketCallback(cell $mdObj) impure inline method_id {
|
|
256
|
+
(cell $storage, tuple actions) = preamble();
|
|
257
|
+
return actions;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
;; @in permissionless (OApp)
|
|
261
|
+
;; @in_md Deploy
|
|
262
|
+
tuple deployConnection(cell $deploy) impure inline method_id {
|
|
263
|
+
(cell $storage, tuple actions) = preamble();
|
|
264
|
+
|
|
265
|
+
cell $path = lz::Path::New(
|
|
266
|
+
$storage.cl::get<uint32>(SmlManager::eid),
|
|
267
|
+
getCaller(),
|
|
268
|
+
$deploy.cl::get<uint32>(md::Deploy::dstEid),
|
|
269
|
+
$deploy.cl::get<address>(md::Deploy::dstOApp)
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
actions~pushAction<deployAndCall>(
|
|
273
|
+
$storage.cl::get<cellRef>(SmlManager::smlConnectionCode),
|
|
274
|
+
SmlConnection::New(getContractAddress(), $path),
|
|
275
|
+
$deploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
276
|
+
BaseInterface::OP::INITIALIZE,
|
|
277
|
+
md::InitSmlConnection::New(_deriveChannelAddress($path)),
|
|
278
|
+
0
|
|
279
|
+
);
|
|
280
|
+
return actions;
|
|
281
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#include "../../../../funC++/constants.fc";
|
|
2
|
+
|
|
3
|
+
const int SmlManager::OP::SET_MSGLIB_CONFIG = "SmlManager::OP::SET_MSGLIB_CONFIG"c;
|
|
4
|
+
const int SmlManager::OP::SML_MANAGER_COMMIT_PACKET_CALLBACK = "SmlManager::OP::SML_MANAGER_COMMIT_PACKET_CALLBACK"c;
|
|
5
|
+
const int SmlManager::OP::SML_MANAGER_COMMIT_PACKET = "SmlManager::OP::SML_MANAGER_COMMIT_PACKET"c;
|
|
6
|
+
|
|
7
|
+
const int SmlManager::OP::SML_MANAGER_SEND = "SmlManager::OP::SML_MANAGER_SEND"c;
|
|
8
|
+
|
|
9
|
+
;; EVENTS
|
|
10
|
+
const int SmlManager::event::SET_MSGLIB_CONFIG = "SET_MSGLIB_CONFIG"u;
|
|
11
|
+
|
|
12
|
+
const int SmlManager::ERROR::packetHeaderNotFound = "packetHeaderNotFound"c & ERRORCODE_MASK;
|
|
13
|
+
const int SmlManager::ERROR::optionsNotEmpty = "optionsNotEmpty"c & ERRORCODE_MASK;
|
|
14
|
+
const int SmlManager::ERROR::onlyConnection = "onlyConnection"c & ERRORCODE_MASK;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#include "handler.fc";
|
|
2
|
+
#include "interface.fc";
|
|
3
|
+
|
|
4
|
+
#include "../../../core/abstract/protocolMain.fc";
|
|
5
|
+
#include "../../interface.fc";
|
|
6
|
+
|
|
7
|
+
tuple _executeOpcode(int op, cell $md) impure inline {
|
|
8
|
+
if (op == SmlManager::OP::SET_MSGLIB_CONFIG) {
|
|
9
|
+
return setMsglibConfig($md);
|
|
10
|
+
} elseif (op == SmlManager::OP::SML_MANAGER_SEND) {
|
|
11
|
+
return smlManagerSend($md);
|
|
12
|
+
} elseif (op == SmlManager::OP::SML_MANAGER_COMMIT_PACKET) {
|
|
13
|
+
return smlManagerCommitPacket($md);
|
|
14
|
+
} elseif (op == SmlManager::OP::SML_MANAGER_COMMIT_PACKET_CALLBACK) {
|
|
15
|
+
return smlManagerCommitPacketCallback($md);
|
|
16
|
+
} elseif (op == MsglibManager::OP::GET_MSGLIB_INFO) {
|
|
17
|
+
return getMsgLibInfo($md);
|
|
18
|
+
} elseif (op == MsglibManager::OP::DEPLOY_CONNECTION) {
|
|
19
|
+
return deployConnection($md);
|
|
20
|
+
} else {
|
|
21
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
22
|
+
}
|
|
23
|
+
return empty_tuple();
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#include "../../../core/baseStorage.fc";
|
|
2
|
+
|
|
3
|
+
const int SmlManager::NAME = "smlMgr"u;
|
|
4
|
+
|
|
5
|
+
const int SmlManager::baseStorage = 0;
|
|
6
|
+
|
|
7
|
+
const int SmlManager::eid = 1;
|
|
8
|
+
const int SmlManager::verison = 2;
|
|
9
|
+
|
|
10
|
+
;; configurations, only owner?
|
|
11
|
+
const int SmlManager::nativeFee = 3;
|
|
12
|
+
const int SmlManager::zroFee = 4;
|
|
13
|
+
|
|
14
|
+
;; Dict256 hash(header) => hash(message)
|
|
15
|
+
const int SmlManager::packets = 5;
|
|
16
|
+
const int SmlManager::controllerAddress = 6;
|
|
17
|
+
const int SmlManager::endpointCode = 7;
|
|
18
|
+
const int SmlManager::channelCode = 8;
|
|
19
|
+
const int SmlManager::smlConnectionCode = 9;
|
|
20
|
+
|
|
21
|
+
;; @owner LayerZero admin EOA
|
|
22
|
+
cell SmlManager::New(int owner, int eid, int version, int controllerAddress, cell endpointCode, cell channelCode, cell smlConnectionCode) method_id {
|
|
23
|
+
return cl::declare(
|
|
24
|
+
SmlManager::NAME,
|
|
25
|
+
unsafeTuple([
|
|
26
|
+
[cl::t::objRef, BaseStorage::New(owner)], ;; SmlManager::baseStorage
|
|
27
|
+
[cl::t::uint32, eid], ;; SmlManager::eid
|
|
28
|
+
[cl::t::uint8, version], ;; SmlManager::version
|
|
29
|
+
[cl::t::coins, 0], ;; SmlManager::nativeFee
|
|
30
|
+
[cl::t::coins, 0], ;; SmlManager::zroFee
|
|
31
|
+
[cl::t::dict256, cl::dict256::New()], ;; SmlManager::packets
|
|
32
|
+
[cl::t::address, controllerAddress], ;; SmlManager::controllerAddress
|
|
33
|
+
[cl::t::cellRef, endpointCode], ;; SmlManager::endpointCode
|
|
34
|
+
[cl::t::cellRef, channelCode], ;; SmlManager::channelCode
|
|
35
|
+
[cl::t::cellRef, smlConnectionCode] ;; SmlManager::smlConnectionCode
|
|
36
|
+
])
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const int UltraLightNode::OP::ULN_CONNECTION_VERIFY_CALLBACK = "UltraLightNode::OP::ULN_CONNECTION_VERIFY_CALLBACK"c;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
;; these numbers *MUST* be updated every time the interface function names change
|
|
2
|
+
;; nativeFee, event
|
|
3
|
+
;; (int, tuple) ulnWorker::quote(cell $storage, cell $borrowedStorage, cell $lzSend) method_id;
|
|
4
|
+
const int UlnWorkerInterface::quote = 107686; ;; ulnWorker::quote
|
|
5
|
+
|
|
6
|
+
;; tuple ulnWorker::setConfig(cell $storage, cell $md) method_id;
|
|
7
|
+
const int UlnWorkerInterface::setConfig = 95983; ;; ulnWorker::setConfig
|
|
8
|
+
|
|
9
|
+
const int UlnWorkerInterface::ERROR::UNKNOWN_OPTIONS = 2047;
|
|
10
|
+
const int UlnWorkerInterface::ERROR::ZERO_LZ_COMPOSE_GAS_PROVIDED = 2046;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
;; 1) If RUNVM successful and M (number of returnable elements is set) it returns M elements. If M not set - returns all.
|
|
2
|
+
;; 2) if RUNVM successful but there is not enough elements on stack (M) it is considered as exception in child VM with exit_code=-3 exit_arg=0.
|
|
3
|
+
;; 3) if RUNVM fails with exception - only one element is returned - exit arg (not to be mistaken with exit_code)
|
|
4
|
+
;; 4) in case of OOG, exit_code = -14 and exit_arg is amount of gas
|
|
5
|
+
|
|
6
|
+
;; RunVM inputs: x_1 ... x_n n code [r] [c4] [c7] [g_l] [g_m] - x'_1
|
|
7
|
+
;; RunVm outputs: x'_m exitcode [data'] [c4'] [c5] [g_c]
|
|
8
|
+
|
|
9
|
+
;; the inputs have to be packed in a tuple
|
|
10
|
+
;; and the number of outputs is set by the nOutputs
|
|
11
|
+
tuple safePackedInputsRunVm(
|
|
12
|
+
tuple inputs,
|
|
13
|
+
int methodIdCRC,
|
|
14
|
+
int nOutputs,
|
|
15
|
+
slice code,
|
|
16
|
+
int gasLimit
|
|
17
|
+
) impure method_id asm """
|
|
18
|
+
// Setup // callerStack: [ inputs, methodIdCRC, nOutputs, code, gasLimit ] ; len(callerStack) = 5
|
|
19
|
+
// // STACK [ ..., inputs, methodIdCRC, nOutputs, code, nOutputs, gasLimit ]
|
|
20
|
+
DEPTH 5 PUSHINT SUB // STACK [ ..., inputs, methodIdCRC, nOutputs, code, gasLimit, len(callerStack) ]
|
|
21
|
+
3 PUSHINT SETGLOBVAR // STACK [ ..., inputs, methodIdCRC, nOutputs, code, gasLimit ]
|
|
22
|
+
// Globvars[3] = len(...)
|
|
23
|
+
|
|
24
|
+
// Arrange the stack for RUNVM
|
|
25
|
+
// nArgs is actually numberOfInputs + 1
|
|
26
|
+
2 PUSHINT // STACK [ ..., inputs, methodIdCRC, nOutputs, code, gasLimit, nArgs ]
|
|
27
|
+
s1 XCHG0 // STACK [ ..., inputs, methodIdCRC, nOutputs, code, nArgs, gasLimit ]
|
|
28
|
+
s1 s3 XCHG // STACK [ ..., inputs, methodIdCRC, nArgs, code, nOutputs, gasLimit ]
|
|
29
|
+
|
|
30
|
+
// Run the given methodId in a sandbox child VM with flag 256 + 8 + 1
|
|
31
|
+
// +1 : set c3 to code
|
|
32
|
+
// +8: take gas limit g_l from stack, return consumed gas g_c
|
|
33
|
+
// +256: pop integer r, return exactly r values from the top of the stack (only if exitcode=0 or 1; if not enough then exitcode=stack_underflow)
|
|
34
|
+
// here, r := nOutputs
|
|
35
|
+
|
|
36
|
+
265 RUNVM
|
|
37
|
+
// STACK [ ..., childStack]
|
|
38
|
+
// childStack is capped at nOutputs
|
|
39
|
+
|
|
40
|
+
// Cleanup the return values
|
|
41
|
+
// 1. Figure out the length of the childStack
|
|
42
|
+
DEPTH // STACK [ ..., childStack, len(...) + len(childStack) ]
|
|
43
|
+
3 PUSHINT GETGLOBVAR // STACK [ ..., childStack, len(...) + len(childStack), len(...) ]
|
|
44
|
+
// calculate len(childStack) = len(currentStack) - len(...)
|
|
45
|
+
SUB ABS // STACK [ ..., childStack, len(childStack) ]
|
|
46
|
+
|
|
47
|
+
// 2. Turn the entire child stack into a tuple
|
|
48
|
+
// Tuplevar takes x1, ..., xn and n, and turns it into a tuple (x1, ..., xn)
|
|
49
|
+
// wouldn't know how many elements to take without the n
|
|
50
|
+
TUPLEVAR // STACK [ ..., tuple[*childStack] ]
|
|
51
|
+
""";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required storage name
|
|
4
|
+
const int lz::Attestation::NAME = "Attest"u;
|
|
5
|
+
|
|
6
|
+
;; field names
|
|
7
|
+
const int lz::Attestation::hash = 0; ;; hash
|
|
8
|
+
const int lz::Attestation::confirmations = 1; ;; uint64
|
|
9
|
+
|
|
10
|
+
const int lz::Attestation::bits = _HEADER_WIDTH + 256 + 64;
|
|
11
|
+
const int lz::Attestation::refs = 0;
|
|
12
|
+
;; As long as the first 128 bits of the header match the below number,
|
|
13
|
+
;; the attestation is parseable by classlib
|
|
14
|
+
const int lz::Attestation::leading16Bytes = 0x417474657374815ED897BFFF;
|
|
15
|
+
|
|
16
|
+
cell lz::Attestation::New(int hash, int confirmations) inline method_id {
|
|
17
|
+
return cl::declare(
|
|
18
|
+
lz::Attestation::NAME,
|
|
19
|
+
unsafeTuple([
|
|
20
|
+
[cl::t::uint256, hash], ;; lz::Attestation::hash
|
|
21
|
+
[cl::t::uint64, confirmations] ;; lz::Attestation::confirmations
|
|
22
|
+
])
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
() lz::Attestation::validate(cell $self) impure inline method_id {
|
|
27
|
+
;; low-level destructuring for efficiency
|
|
28
|
+
slice selfSlice = $self.begin_parse();
|
|
29
|
+
(int bits, int refs) = selfSlice.slice_bits_refs();
|
|
30
|
+
throw_unless(
|
|
31
|
+
cl::ERROR::MALFORMED_OBJECT,
|
|
32
|
+
(bits == lz::Attestation::bits)
|
|
33
|
+
& (refs == lz::Attestation::refs)
|
|
34
|
+
& (selfSlice~load_uint(128) == lz::Attestation::leading16Bytes)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
int lz::Attestation::confirmable(cell $self, int hash, int confirmations) impure inline method_id {
|
|
39
|
+
;; low-level destructuring for efficiency
|
|
40
|
+
slice selfSlice = $self.begin_parse().sdskipfirst(_HEADER_WIDTH);
|
|
41
|
+
|
|
42
|
+
;; Equivalent to the below
|
|
43
|
+
;; ($self.cl::get<uint256>(lz::Attestation::hash) == hash)
|
|
44
|
+
;; & ($self.cl::get<uint64>(lz::Attestation::confirmations) <= confirmations);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
(selfSlice~load_uint256() == hash) & (selfSlice~load_uint64() <= confirmations)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required storage name
|
|
4
|
+
const int DvnFeesPaidEvent::NAME = "DvnFeePaid"u;
|
|
5
|
+
|
|
6
|
+
const int DvnFeesPaidEvent::CONSTS::NULL_WORKER_ID = 0;
|
|
7
|
+
|
|
8
|
+
;; field names
|
|
9
|
+
const int DvnFeesPaidEvent::requiredDVNs = 0;
|
|
10
|
+
const int DvnFeesPaidEvent::optionalDVNs = 1;
|
|
11
|
+
const int DvnFeesPaidEvent::serializedPayees = 2;
|
|
12
|
+
|
|
13
|
+
cell DvnFeesPaidEvent::New(
|
|
14
|
+
cell requiredDVNs,
|
|
15
|
+
cell optionalDVNs,
|
|
16
|
+
cell serializedPayees
|
|
17
|
+
) inline method_id {
|
|
18
|
+
return cl::declare(
|
|
19
|
+
DvnFeesPaidEvent::NAME,
|
|
20
|
+
unsafeTuple([
|
|
21
|
+
[cl::t::objRef, requiredDVNs], ;; DvnFeesPaidEvent::requiredDVNs
|
|
22
|
+
[cl::t::objRef, optionalDVNs], ;; DvnFeesPaidEvent::optionalDVNs
|
|
23
|
+
[cl::t::objRef, serializedPayees] ;; DvnFeesPaidEvent::serializedPayees
|
|
24
|
+
])
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required storage name
|
|
4
|
+
const int ExecutorFeePaidEvent::NAME = "ExcFeePaid"u;
|
|
5
|
+
|
|
6
|
+
const int ExecutorFeePaidEvent::CONSTS::NULL_WORKER_ID = 0;
|
|
7
|
+
|
|
8
|
+
;; field names
|
|
9
|
+
const int ExecutorFeePaidEvent::executorAddress = 0;
|
|
10
|
+
const int ExecutorFeePaidEvent::feePaid = 1;
|
|
11
|
+
|
|
12
|
+
cell ExecutorFeePaidEvent::New(
|
|
13
|
+
int executorAddress,
|
|
14
|
+
int feePaid
|
|
15
|
+
) inline method_id {
|
|
16
|
+
return cl::declare(
|
|
17
|
+
ExecutorFeePaidEvent::NAME,
|
|
18
|
+
unsafeTuple([
|
|
19
|
+
[cl::t::address, executorAddress], ;; ExecutorFeePaidEvent::executorAddress
|
|
20
|
+
[cl::t::coins, feePaid] ;; ExecutorFeePaidEvent::feePaid
|
|
21
|
+
])
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required md name
|
|
4
|
+
const int md::InitUln::NAME = "initUln"u;
|
|
5
|
+
|
|
6
|
+
;; field names
|
|
7
|
+
const int md::InitUln::connectionCode = 0;
|
|
8
|
+
const int md::InitUln::treasuryFeeBps = 1;
|
|
9
|
+
|
|
10
|
+
cell md::InitUln::New(cell connectionCode, int treasuryFeeBps) inline method_id {
|
|
11
|
+
return cl::declare(
|
|
12
|
+
md::InitUln::NAME,
|
|
13
|
+
unsafeTuple([
|
|
14
|
+
[cl::t::cellRef, connectionCode], ;; md::InitUln::connectionCode
|
|
15
|
+
[cl::t::uint16, treasuryFeeBps] ;; md::InitUln::treasuryFeeBps
|
|
16
|
+
])
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
#include "UlnSendConfig.fc";
|
|
4
|
+
#include "UlnReceiveConfig.fc";
|
|
5
|
+
|
|
6
|
+
;; required storage name
|
|
7
|
+
const int md::InitUlnConnection::NAME = "initUlnCon"u;
|
|
8
|
+
|
|
9
|
+
;; field names
|
|
10
|
+
const int md::InitUlnConnection::ulnSendConfigOApp = 0;
|
|
11
|
+
const int md::InitUlnConnection::ulnReceiveConfigOApp = 1;
|
|
12
|
+
const int md::InitUlnConnection::endpointAddress = 2;
|
|
13
|
+
const int md::InitUlnConnection::channelAddress = 3;
|
|
14
|
+
|
|
15
|
+
cell md::InitUlnConnection::New(
|
|
16
|
+
cell $ulnSendConfigOApp,
|
|
17
|
+
cell $ulnReceiveConfigOApp,
|
|
18
|
+
int endpointAddress,
|
|
19
|
+
int channelAddress
|
|
20
|
+
) inline method_id {
|
|
21
|
+
return cl::declare(
|
|
22
|
+
md::InitUlnConnection::NAME,
|
|
23
|
+
unsafeTuple([
|
|
24
|
+
[cl::t::objRef, $ulnSendConfigOApp], ;; md::InitUlnConnection::ulnSendConfigOApp
|
|
25
|
+
[cl::t::objRef, $ulnReceiveConfigOApp], ;; md::InitUlnConnection::ulnReceiveConfigOApp
|
|
26
|
+
[cl::t::address, endpointAddress], ;; md::InitUlnConnection::endpointAddress
|
|
27
|
+
[cl::t::address, channelAddress] ;; md::InitUlnConnection::channelAddress
|
|
28
|
+
])
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
cell md::InitUlnConnection::NewOnlyConfig(
|
|
33
|
+
cell $ulnSendConfigOApp,
|
|
34
|
+
cell $ulnReceiveConfigOApp
|
|
35
|
+
) inline method_id {
|
|
36
|
+
return md::InitUlnConnection::New(
|
|
37
|
+
$ulnSendConfigOApp,
|
|
38
|
+
$ulnReceiveConfigOApp,
|
|
39
|
+
NULLADDRESS,
|
|
40
|
+
NULLADDRESS
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
;; Ensure the Uln receive config does not contain garbage bits etc. that would cause
|
|
45
|
+
;; undefined behaviors in the protocol
|
|
46
|
+
cell InitUlnConnection::sanitize(cell $initUlnConnection) impure {
|
|
47
|
+
cell $ulnSendConfigOApp = $initUlnConnection
|
|
48
|
+
.cl::get<objRef>(md::InitUlnConnection::ulnSendConfigOApp);
|
|
49
|
+
cell $ulnReceiveConfigOApp = $initUlnConnection
|
|
50
|
+
.cl::get<objRef>(md::InitUlnConnection::ulnReceiveConfigOApp);
|
|
51
|
+
int endpointAddress = $initUlnConnection
|
|
52
|
+
.cl::get<address>(md::InitUlnConnection::endpointAddress);
|
|
53
|
+
int channelAddress = $initUlnConnection
|
|
54
|
+
.cl::get<address>(md::InitUlnConnection::channelAddress);
|
|
55
|
+
|
|
56
|
+
return md::InitUlnConnection::New(
|
|
57
|
+
UlnSendConfig::sanitize($ulnSendConfigOApp),
|
|
58
|
+
UlnReceiveConfig::sanitize($ulnReceiveConfigOApp),
|
|
59
|
+
endpointAddress,
|
|
60
|
+
channelAddress
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required md name
|
|
4
|
+
const int md::InitUlnManager::NAME = "InitUlnMgr"u;
|
|
5
|
+
|
|
6
|
+
;; field names
|
|
7
|
+
const int md::InitUlnManager::endpointCode = 0;
|
|
8
|
+
const int md::InitUlnManager::channelCode = 1;
|
|
9
|
+
|
|
10
|
+
cell md::InitUlnManager::New(cell endpointCode, cell channelCode) inline method_id {
|
|
11
|
+
return cl::declare(
|
|
12
|
+
md::InitUlnManager::NAME,
|
|
13
|
+
unsafeTuple([
|
|
14
|
+
[cl::t::cellRef, endpointCode], ;; md::InitUlnManager::endpointCode
|
|
15
|
+
[cl::t::cellRef, channelCode] ;; md::InitUlnManager::channelCode
|
|
16
|
+
])
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required md name
|
|
4
|
+
const int md::RentRefill::NAME = "RentRefill"u;
|
|
5
|
+
|
|
6
|
+
;; field names
|
|
7
|
+
const int md::RentRefill::address = 0;
|
|
8
|
+
const int md::RentRefill::amount = 1;
|
|
9
|
+
|
|
10
|
+
cell md::RentRefill::New(int address, int amount) inline method_id {
|
|
11
|
+
return cl::declare(
|
|
12
|
+
md::RentRefill::NAME,
|
|
13
|
+
unsafeTuple([
|
|
14
|
+
[cl::t::address, address], ;; md::RentRefill::address
|
|
15
|
+
[cl::t::coins, amount] ;; md::RentRefill::amount
|
|
16
|
+
])
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#include "../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
;; required md name
|
|
4
|
+
const int md::SetAdminWorkerAddresses::NAME = "adminwork"u;
|
|
5
|
+
|
|
6
|
+
;; field names
|
|
7
|
+
|
|
8
|
+
;; AddressList
|
|
9
|
+
const int md::SetAdminWorkerAddresses::adminWorkers = 0;
|
|
10
|
+
|
|
11
|
+
cell md::SetAdminWorkerAddresses::New(cell adminWorkers) inline method_id {
|
|
12
|
+
return cl::declare(
|
|
13
|
+
md::SetAdminWorkerAddresses::NAME,
|
|
14
|
+
unsafeTuple([
|
|
15
|
+
[cl::t::cellRef, adminWorkers] ;; md::SetAdminWorkerAddresses::adminWorkers
|
|
16
|
+
])
|
|
17
|
+
);
|
|
18
|
+
}
|