@layerzerolabs/layerzero-v2-ton 3.0.27 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/ActionsSerde.test.compiled.json +1 -0
- package/build/AllStorages.compiled.json +1 -1
- package/build/AllStorages.test.compiled.json +1 -1
- package/build/BaseContract.test.compiled.json +1 -1
- package/build/Channel.compiled.json +1 -1
- package/build/Channel.permissions.test.compiled.json +1 -1
- package/build/ChannelBurn.test.compiled.json +1 -1
- package/build/ChannelCommitPacket.test.compiled.json +1 -1
- package/build/ChannelConfig.test.compiled.json +1 -1
- package/build/ChannelInitialize.test.compiled.json +1 -1
- package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
- package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
- package/build/ChannelNilify.test.compiled.json +1 -1
- package/build/ChannelReceive.test.compiled.json +1 -1
- package/build/ChannelReceiveCallback.test.compiled.json +1 -1
- package/build/ChannelReceiveView.test.compiled.json +1 -1
- package/build/ChannelSend.test.compiled.json +1 -1
- package/build/ChannelSerde.test.compiled.json +1 -0
- package/build/Classlib.test.compiled.json +1 -1
- package/build/ComputeDataSizeGas.test.compiled.json +1 -1
- package/build/Connection.compiled.json +1 -1
- package/build/Controller.assertions.test.compiled.json +1 -1
- package/build/Controller.compiled.json +1 -1
- package/build/Controller.permissions.test.compiled.json +1 -1
- package/build/Controller.test.compiled.json +1 -1
- package/build/Counter.compiled.json +1 -1
- package/build/Counter.permissions.test.compiled.json +1 -1
- package/build/Counter.setters.test.compiled.json +1 -1
- package/build/Counter.test.compiled.json +1 -1
- package/build/Dvn.compiled.json +1 -1
- package/build/Dvn.test.compiled.json +1 -1
- package/build/DvnFeeLib.compiled.json +1 -1
- package/build/DvnFeeLibSerde.test.compiled.json +1 -0
- package/build/DvnPermissions.test.compiled.json +1 -1
- package/build/DvnSerde.test.compiled.json +1 -0
- package/build/Endpoint.compiled.json +1 -1
- package/build/Endpoint.permissions.test.compiled.json +1 -1
- package/build/Endpoint.test.compiled.json +1 -1
- package/build/EndpointSerde.test.compiled.json +1 -0
- package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
- package/build/Executor.compiled.json +1 -1
- package/build/Executor.test.compiled.json +1 -1
- package/build/ExecutorFeeLib.compiled.json +1 -1
- package/build/ExecutorFeeLibSerde.test.compiled.json +1 -0
- package/build/ExecutorPermissions.test.compiled.json +1 -1
- package/build/ExecutorSerde.test.compiled.json +1 -0
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzClassesSerde.test.compiled.json +1 -0
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsgDataSerde.test.compiled.json +1 -0
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -0
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
- package/build/PriceFeedCacheSerde.test.compiled.json +1 -0
- package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -0
- package/build/Proxy.compiled.json +1 -1
- package/build/Proxy.permissions.test.compiled.json +1 -1
- package/build/Proxy.test.compiled.json +1 -1
- package/build/SmlConnection.compiled.json +1 -1
- package/build/SmlConnection.permissions.test.compiled.json +1 -1
- package/build/SmlConnection.test.compiled.json +1 -1
- package/build/SmlManager.compiled.json +1 -1
- package/build/SmlManager.permissions.test.compiled.json +1 -1
- package/build/SmlManager.test.compiled.json +1 -1
- package/build/Uln.compiled.json +1 -1
- package/build/Uln.test.compiled.json +1 -1
- package/build/UlnConnection.compiled.json +1 -1
- package/build/UlnConnection.test.compiled.json +1 -1
- package/build/UlnConnectionPermissions.test.compiled.json +1 -1
- package/build/UlnConnectionSerde.test.compiled.json +1 -0
- package/build/UlnManagement.test.compiled.json +1 -1
- package/build/UlnManager.compiled.json +1 -1
- package/build/UlnManager.test.compiled.json +1 -1
- package/build/UlnManagerPermissions.test.compiled.json +1 -1
- package/build/UlnManagerUtil.test.compiled.json +1 -1
- package/build/UlnMsgDataSerde.test.compiled.json +1 -0
- package/build/UlnPermissions.test.compiled.json +1 -1
- package/build/UlnReceiveConfig.test.compiled.json +1 -1
- package/build/UlnSend.test.compiled.json +1 -1
- package/build/UlnSendConfig.test.compiled.json +1 -1
- package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
- package/build/UlnSerde.test.compiled.json +1 -0
- package/build/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -0
- package/build/WorkerCoreSerde.test.compiled.json +1 -0
- package/build/badFeeLib1.test.compiled.json +1 -1
- package/build/badFeeLib10.test.compiled.json +1 -1
- package/build/badFeeLib11.test.compiled.json +1 -1
- package/build/badFeeLib12.test.compiled.json +1 -1
- package/build/badFeeLib2.test.compiled.json +1 -1
- package/build/badFeeLib3.test.compiled.json +1 -1
- package/build/badFeeLib4.test.compiled.json +1 -1
- package/build/badFeeLib5.test.compiled.json +1 -1
- package/build/badFeeLib6.test.compiled.json +1 -1
- package/build/badFeeLib7.test.compiled.json +1 -1
- package/build/badFeeLib8.test.compiled.json +1 -1
- package/build/badFeeLib9.test.compiled.json +1 -1
- package/package.json +2 -1
- package/src/classes/lz/EpConfig.fc +90 -23
- package/src/classes/lz/MsglibInfo.fc +32 -5
- package/src/classes/lz/Packet.fc +109 -48
- package/src/classes/lz/Path.fc +55 -4
- package/src/classes/lz/ReceiveEpConfig.fc +36 -5
- package/src/classes/lz/SendEpConfig.fc +55 -5
- package/src/classes/msgdata/AddMsglib.fc +11 -0
- package/src/classes/msgdata/ChannelNonceInfo.fc +20 -0
- package/src/classes/msgdata/CoinsAmount.fc +8 -0
- package/src/classes/msgdata/Deploy.fc +19 -0
- package/src/classes/msgdata/ExtendedMd.fc +52 -1
- package/src/classes/msgdata/LzReceivePrepare.fc +21 -1
- package/src/classes/msgdata/LzReceiveStatus.fc +72 -1
- package/src/classes/msgdata/LzSend.fc +143 -24
- package/src/classes/msgdata/MdAddress.fc +42 -0
- package/src/classes/msgdata/MdEid.fc +8 -0
- package/src/classes/msgdata/MdObj.fc +32 -0
- package/src/classes/msgdata/MessagingReceipt.fc +34 -1
- package/src/classes/msgdata/MsglibSendCallback.fc +82 -0
- package/src/classes/msgdata/Nonce.fc +30 -0
- package/src/classes/msgdata/OptionsV1.fc +21 -1
- package/src/classes/msgdata/OptionsV2.fc +27 -0
- package/src/classes/msgdata/PacketId.fc +24 -0
- package/src/classes/msgdata/PacketSent.fc +35 -1
- package/src/classes/msgdata/SetAddress.fc +7 -0
- package/src/classes/msgdata/SetEpConfig.fc +17 -0
- package/src/funC++/actions/event.fc +17 -2
- package/src/funC++/actions/utils.fc +2 -2
- package/src/funC++/classlib.fc +33 -43
- package/src/funC++/constants.fc +28 -28
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +75 -59
- package/src/funC++/stdlib.fc +26 -11
- package/src/funC++/testutils.fc +2 -2
- package/src/funC++/txnContext.fc +14 -14
- package/src/funC++/utils.fc +97 -1
- package/src/protocol/channel/handler.fc +247 -189
- package/src/protocol/channel/storage.fc +206 -1
- package/src/protocol/controller/handler.fc +35 -17
- package/src/protocol/controller/main.fc +1 -1
- package/src/protocol/core/abstract/protocolHandler.fc +11 -21
- package/src/protocol/core/baseStorage.fc +24 -0
- package/src/protocol/endpoint/handler.fc +99 -57
- package/src/protocol/endpoint/storage.fc +69 -5
- package/src/protocol/msglibs/BytesEncoder.fc +11 -10
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +1 -4
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +7 -8
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +114 -28
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +84 -107
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +77 -1
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +92 -66
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +113 -6
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +6 -91
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +55 -31
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +13 -9
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +63 -27
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +19 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +55 -6
- package/src/workers/core/abstract/workerHandler.fc +20 -19
- package/src/workers/core/interface.fc +2 -1
- package/src/workers/core/workerCoreStorage.fc +16 -1
- package/src/workers/dvn/handler.fc +67 -26
- package/src/workers/dvn/storage.fc +15 -2
- package/src/workers/executor/handler.fc +18 -6
- package/src/workers/executor/interface.fc +1 -0
- package/src/workers/executor/storage.fc +8 -1
- package/src/workers/msgdata/DropEvent.fc +18 -0
- package/src/workers/msgdata/ExecuteParams.fc +66 -3
- package/src/workers/msgdata/NativeDrop.fc +4 -0
- package/src/workers/msgdata/SetDict.fc +6 -4
- package/src/workers/msgdata/SetQuorum.fc +4 -2
- package/src/workers/msgdata/SignedRequest.fc +8 -0
- package/src/workers/priceFeedCache/handler.fc +21 -27
- package/src/workers/priceFeedCache/storage.fc +16 -1
- package/src/workers/proxy/handler.fc +2 -1
- package/src/workers/proxy/storage.fc +1 -1
- package/tests/baseContractTest.fc +2 -6
- package/tests/baseSerdeTest.fc +117 -0
- package/tests/testMain.fc +2 -2
- package/src/classes/msgdata/Amount.fc +0 -16
- package/src/funC++/actions/destroy.fc +0 -27
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
;; maximum concurrent sendable inflight send requests
|
|
8
8
|
;; must be low to avoid permanent bricking
|
|
9
|
-
const Channel::MAX_SEND_SLOTS = MAX_CELL_BITS;
|
|
9
|
+
const int Channel::MAX_SEND_SLOTS = MAX_CELL_BITS;
|
|
10
10
|
|
|
11
11
|
;; required object name
|
|
12
12
|
const int Channel::NAME = "channel"u;
|
|
@@ -52,4 +52,209 @@ cell Channel::New(int owner, cell $path, int endpointAddress) inline method_id {
|
|
|
52
52
|
[cl::t::coins, 0] ;; Channel::zroBalance
|
|
53
53
|
])
|
|
54
54
|
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
;; ====================== Object Accessors =====================
|
|
58
|
+
|
|
59
|
+
const int Channel::_endpointAddressOffset = _HEADER_WIDTH;
|
|
60
|
+
const int Channel::_outboundNonceOffset = Channel::_endpointAddressOffset + 256;
|
|
61
|
+
const int Channel::_sendRequestIdOffset = Channel::_outboundNonceOffset + 64;
|
|
62
|
+
const int Channel::_zroBalanceOffset = Channel::_sendRequestIdOffset + 64;
|
|
63
|
+
const int Channel::_sliceBits = Channel::_zroBalanceOffset + 128;
|
|
64
|
+
|
|
65
|
+
cell Channel::getPath(cell $self) impure inline {
|
|
66
|
+
return $self.cellPreloadRefAt(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
int Channel::getEndpointAddress(cell $self) impure inline {
|
|
70
|
+
return $self.cellPreloadAddressAt(Channel::_endpointAddressOffset);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
cell Channel::getCommitPOOO(cell $self) impure inline {
|
|
74
|
+
return $self.cellPreloadRefAt(2).cellPreloadRefAt(2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
cell Channel::getExecutePOOO(cell $self) impure inline {
|
|
78
|
+
return $self.cellPreloadRefAt(2).cellPreloadRefAt(3);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
cell Channel::getExecutionQueue(cell $self) impure inline {
|
|
82
|
+
return $self.cellPreloadRefAt(3).cellPreloadRefAt(0);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
int Channel::getZroBalance(cell $self) impure inline {
|
|
86
|
+
return $self.cellPreloadCoinsAt(Channel::_zroBalanceOffset);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
;; (epConfigOApp, commitPOOO, ExecutePOOO, executionQueue)
|
|
90
|
+
(cell, cell, cell, cell) Channel::getCommitPacketInformation(cell $self) impure inline {
|
|
91
|
+
slice selfSlice = $self.begin_parse();
|
|
92
|
+
slice ref2 = selfSlice.preloadRefSliceAt(2);
|
|
93
|
+
return (
|
|
94
|
+
ref2.preloadRefAt(0),
|
|
95
|
+
ref2.preloadRefAt(2),
|
|
96
|
+
ref2.preloadRefAt(3),
|
|
97
|
+
selfSlice.preloadRefAt(3).cellPreloadRefAt(0)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
;; (executePOOO, executionQueue, path)
|
|
102
|
+
(cell, cell, cell) Channel::getExecutePOOOAndExecutionQueueAndPath(cell $self) impure inline {
|
|
103
|
+
slice selfSlice = $self.begin_parse();
|
|
104
|
+
return (
|
|
105
|
+
selfSlice.preloadRefAt(2).cellPreloadRefAt(3),
|
|
106
|
+
selfSlice.preloadRefAt(3).cellPreloadRefAt(0),
|
|
107
|
+
selfSlice.preloadRefAt(1)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
;; (epConfigOapp, path, sendRequestQueue, lastSendRequestId)
|
|
112
|
+
(cell, cell, cell, int) Channel::getSendInformation(cell $self) impure inline {
|
|
113
|
+
slice selfSlice = $self.begin_parse();
|
|
114
|
+
slice ref2 = selfSlice.preloadRefSliceAt(2);
|
|
115
|
+
return (
|
|
116
|
+
ref2.preloadRefAt(0),
|
|
117
|
+
selfSlice.preloadRefAt(1),
|
|
118
|
+
ref2.preloadRefAt(1),
|
|
119
|
+
selfSlice.preloadUint64At(Channel::_sendRequestIdOffset)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
;; (sendRequestQueue, zroBalance, path, outBoundNonce)
|
|
124
|
+
(cell, int, cell, int) Channel::getSendCallbackInformation(cell $self) impure inline {
|
|
125
|
+
slice selfSlice = $self.begin_parse();
|
|
126
|
+
return (
|
|
127
|
+
selfSlice.preloadRefAt(2).cellPreloadRefAt(1), ;; sendRequestQueue
|
|
128
|
+
selfSlice.preloadCoinsAt(Channel::_zroBalanceOffset), ;; zroBalance
|
|
129
|
+
selfSlice.preloadRefAt(1), ;; path
|
|
130
|
+
selfSlice.preloadUint64At(Channel::_outboundNonceOffset) ;; outboundNonce
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
;; (executionQueue, commitPOOO, path)
|
|
135
|
+
(cell, cell, cell) Channel::getLzReceiveLockInformation(cell $self) impure inline {
|
|
136
|
+
slice selfSlice = $self.begin_parse();
|
|
137
|
+
return (
|
|
138
|
+
selfSlice.preloadRefAt(3).cellPreloadRefAt(0), ;; executionQueue
|
|
139
|
+
selfSlice.preloadRefAt(2).cellPreloadRefAt(2), ;; commitPOOO
|
|
140
|
+
selfSlice.preloadRefAt(1) ;; path
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
;; ====================== Object Modifiers =====================
|
|
145
|
+
|
|
146
|
+
cell Channel::setSendRequestQueue(cell $self, cell $sendRequestQueue) impure inline {
|
|
147
|
+
slice selfSlice = $self.begin_parse();
|
|
148
|
+
|
|
149
|
+
slice ref2Slice = selfSlice.preloadRefSliceAt(2);
|
|
150
|
+
cell newRef2 = begin_cell()
|
|
151
|
+
.store_slice(ref2Slice.scutfirst(0, 1))
|
|
152
|
+
.store_ref($sendRequestQueue)
|
|
153
|
+
.store_slice(ref2Slice.scutlast(0, 2))
|
|
154
|
+
.end_cell();
|
|
155
|
+
|
|
156
|
+
return begin_cell()
|
|
157
|
+
.store_slice(selfSlice.scutfirst(Channel::_sliceBits, 2)) ;; store all the bits and the first 2 refs [0, 1]
|
|
158
|
+
.store_ref(newRef2) ;; store the new ref[2] which includes the new sendRequestQueue
|
|
159
|
+
.store_slice(selfSlice.scutlast(0, 1)) ;; store the last ref, ref[3]
|
|
160
|
+
.end_cell();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cell Channel::setExecutePOOO(cell $self, cell $executePOOO) impure inline {
|
|
164
|
+
slice selfSlice = $self.begin_parse();
|
|
165
|
+
|
|
166
|
+
slice ref2Slice = selfSlice.preloadRefSliceAt(2);
|
|
167
|
+
cell newRef2 = begin_cell()
|
|
168
|
+
.store_slice(ref2Slice.scutfirst(0, 3))
|
|
169
|
+
.store_ref($executePOOO)
|
|
170
|
+
.end_cell();
|
|
171
|
+
|
|
172
|
+
return begin_cell()
|
|
173
|
+
.store_slice(selfSlice.scutfirst(Channel::_sliceBits, 2)) ;; store all the bits and the first 2 refs [0, 1]
|
|
174
|
+
.store_ref(newRef2) ;; store the new ref[2] which includes the new executePOOO
|
|
175
|
+
.store_slice(selfSlice.scutlast(0, 1)) ;; store the last ref, ref[3]
|
|
176
|
+
.end_cell();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
cell Channel::setExecutionQueue(cell $self, cell $executionQueue) impure inline {
|
|
180
|
+
slice selfSlice = $self.begin_parse();
|
|
181
|
+
|
|
182
|
+
cell newRef3 = begin_cell()
|
|
183
|
+
.store_ref($executionQueue)
|
|
184
|
+
.end_cell();
|
|
185
|
+
|
|
186
|
+
return begin_cell()
|
|
187
|
+
.store_slice(selfSlice.scutfirst(Channel::_sliceBits, 3)) ;; store all the bits and the first 3 refs [0, 1, 2]
|
|
188
|
+
.store_ref(newRef3) ;; store the new ref[3] which includes the new executionQueue
|
|
189
|
+
.end_cell();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
;; ====================== Object Composite Modifiers =====================
|
|
193
|
+
|
|
194
|
+
cell Channel::setSendRequestQueueAndLastSendRequestId(cell $self, int lastSendRequestId, cell $sendRequestQueue) impure inline {
|
|
195
|
+
slice selfSlice = $self.begin_parse();
|
|
196
|
+
slice ref2Slice = selfSlice.preloadRefSliceAt(2);
|
|
197
|
+
|
|
198
|
+
cell newRef2 = begin_cell()
|
|
199
|
+
.store_slice(ref2Slice.scutfirst(0, 1))
|
|
200
|
+
.store_ref($sendRequestQueue)
|
|
201
|
+
.store_slice(ref2Slice.scutlast(0, 2))
|
|
202
|
+
.end_cell();
|
|
203
|
+
|
|
204
|
+
return begin_cell()
|
|
205
|
+
.store_slice(selfSlice.scutfirst(Channel::_sendRequestIdOffset, 2)) ;; store all the bits before the lastSendRequestId and the first 2 refs [0, 1]
|
|
206
|
+
.store_uint64(lastSendRequestId) ;; store the new lastSendRequestId = ref[2]
|
|
207
|
+
.store_ref(newRef2) ;; store the new ref[2] which includes the new sendRequestQueue
|
|
208
|
+
.store_slice(selfSlice.sskipfirst(Channel::_sendRequestIdOffset + 64, 3)) ;; store the whatever was after the lastSendRequestId and the last ref, only giving back ref[3]
|
|
209
|
+
.end_cell();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
cell Channel::setOutboundNonceAndZroBalance(cell $self, int outboundNonce, int zroBalance) impure inline {
|
|
213
|
+
slice selfSlice = $self.begin_parse();
|
|
214
|
+
|
|
215
|
+
return begin_cell()
|
|
216
|
+
.store_slice(
|
|
217
|
+
selfSlice.scutfirst(Channel::_outboundNonceOffset, 4)
|
|
218
|
+
) ;; store whatever's behind the outbound nonce and all the refs
|
|
219
|
+
.store_uint64(outboundNonce)
|
|
220
|
+
.store_slice(
|
|
221
|
+
selfSlice.subslice(
|
|
222
|
+
Channel::_sendRequestIdOffset, ;; start bits
|
|
223
|
+
0, ;; start refs
|
|
224
|
+
64, ;; bits
|
|
225
|
+
0 ;; refs
|
|
226
|
+
)
|
|
227
|
+
) ;; store the next 64 bits = sendRequestId
|
|
228
|
+
.store_uint128(zroBalance)
|
|
229
|
+
.end_cell();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
cell Channel::setCommitPOOOAndExecutionQueue(cell $self, cell $commitPOOO, cell $executionQueue) impure inline {
|
|
233
|
+
slice selfSlice = $self.begin_parse();
|
|
234
|
+
|
|
235
|
+
slice ref2Slice = selfSlice.preloadRefSliceAt(2);
|
|
236
|
+
cell newRef2 = begin_cell()
|
|
237
|
+
.store_slice(ref2Slice.scutfirst(0, 2)) ;; store the first 2 refs [0, 1]
|
|
238
|
+
.store_ref($commitPOOO) ;; store the new commitPOOO = ref[2]
|
|
239
|
+
.store_slice(ref2Slice.scutlast(0, 1)) ;; store the last ref, ref[3]
|
|
240
|
+
.end_cell();
|
|
241
|
+
|
|
242
|
+
cell newRef3 = begin_cell()
|
|
243
|
+
.store_ref($executionQueue) ;; store the new executionQueue = ref[0]
|
|
244
|
+
.end_cell();
|
|
245
|
+
|
|
246
|
+
return begin_cell()
|
|
247
|
+
.store_slice(selfSlice.scutfirst(Channel::_sliceBits, 2)) ;; store all the bits and the first 3 refs [0, 1]
|
|
248
|
+
.store_ref(newRef2) ;; store the new ref[2] which includes the new commitPOOO
|
|
249
|
+
.store_ref(newRef3) ;; store the new ref[3] which includes the new executionQueue
|
|
250
|
+
.end_cell();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
cell Channel::setPath(cell $self, cell $path) impure inline {
|
|
254
|
+
slice selfSlice = $self.begin_parse();
|
|
255
|
+
return begin_cell()
|
|
256
|
+
.store_ref(selfSlice.preloadRefAt(0))
|
|
257
|
+
.store_ref($path) ;; change ref 1
|
|
258
|
+
.store_slice(sskipfirst(selfSlice, 0, 2)) ;; rest of it stays the same
|
|
259
|
+
.end_cell();
|
|
55
260
|
}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
#include "interface.fc";
|
|
30
30
|
#include "storage.fc";
|
|
31
|
+
#include "../../classes/msgdata/SetEpConfig.fc";
|
|
31
32
|
|
|
32
33
|
;;; ================INTERFACE FUNCTIONS=====================
|
|
33
34
|
|
|
@@ -60,7 +61,7 @@ int _getEventSink() inline {
|
|
|
60
61
|
;; safe for open and public calls
|
|
61
62
|
return ();
|
|
62
63
|
} elseif (op == Controller::OP::SET_EP_CONFIG_OAPP) {
|
|
63
|
-
cell $path = $md.cl::get<objRef>(md::ExtendedMd::obj);
|
|
64
|
+
cell $path = $md.cl::get<objRef>(md::ExtendedMd::obj).lz::Path::sanitize();
|
|
64
65
|
throw_unless(
|
|
65
66
|
Controller::ERROR::onlyOApp,
|
|
66
67
|
getCaller() == $path.cl::get<address>(lz::Path::srcOApp)
|
|
@@ -153,7 +154,8 @@ int _verifyEventSender(int sender, cell $senderStorageInit) impure method_id {
|
|
|
153
154
|
tuple deployEndpoint(cell $deploy) impure inline method_id {
|
|
154
155
|
(cell $storage, tuple actions) = preamble();
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
cell $sanitizedDeploy = $deploy.md::Deploy::sanitize();
|
|
158
|
+
int dstEid = $sanitizedDeploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
157
159
|
throw_if(Controller::ERROR::invalidEid, dstEid == 0);
|
|
158
160
|
|
|
159
161
|
int eid = $storage.cl::get<uint32>(Controller::eid);
|
|
@@ -161,7 +163,7 @@ tuple deployEndpoint(cell $deploy) impure inline method_id {
|
|
|
161
163
|
actions~pushAction<deployAndCall>(
|
|
162
164
|
$storage.cl::get<cellRef>(Controller::endpointCode),
|
|
163
165
|
Endpoint::New(eid, dstEid, getContractAddress()),
|
|
164
|
-
$
|
|
166
|
+
$sanitizedDeploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
165
167
|
BaseInterface::OP::INITIALIZE,
|
|
166
168
|
md::InitEndpoint::New($storage.cl::get<cellRef>(Controller::channelCode)),
|
|
167
169
|
0
|
|
@@ -179,14 +181,15 @@ tuple deployEndpoint(cell $deploy) impure inline method_id {
|
|
|
179
181
|
tuple deployChannel(cell $deploy) impure inline method_id {
|
|
180
182
|
(cell $storage, tuple actions) = preamble();
|
|
181
183
|
|
|
182
|
-
|
|
184
|
+
cell $sanitizedDeploy = $deploy.md::Deploy::sanitize();
|
|
185
|
+
int dstEid = $sanitizedDeploy.cl::get<uint32>(md::Deploy::dstEid);
|
|
183
186
|
|
|
184
187
|
;; create the path object
|
|
185
188
|
cell $path = lz::Path::New(
|
|
186
189
|
$storage.cl::get<uint32>(Controller::eid), ;; srcEid
|
|
187
190
|
getCaller(), ;; srcOApp
|
|
188
191
|
dstEid, ;; dstEid
|
|
189
|
-
$
|
|
192
|
+
$sanitizedDeploy.cl::get<uint256>(md::Deploy::dstOApp) ;; dstOApp
|
|
190
193
|
);
|
|
191
194
|
|
|
192
195
|
;; get the endpoint address
|
|
@@ -195,7 +198,7 @@ tuple deployChannel(cell $deploy) impure inline method_id {
|
|
|
195
198
|
actions~pushAction<deployAndCall>(
|
|
196
199
|
$storage.cl::get<cellRef>(Controller::channelCode),
|
|
197
200
|
Channel::New(getContractAddress(), $path, endpointAddress),
|
|
198
|
-
$
|
|
201
|
+
$sanitizedDeploy.cl::get<coins>(md::Deploy::initialDeposit),
|
|
199
202
|
BaseInterface::OP::INITIALIZE,
|
|
200
203
|
cl::nullObject(),
|
|
201
204
|
0
|
|
@@ -213,11 +216,12 @@ tuple setEpConfigDefaults(cell $mdEid) impure inline method_id {
|
|
|
213
216
|
(_, tuple actions) = preamble();
|
|
214
217
|
|
|
215
218
|
int dstEid = $mdEid.cl::get<uint32>(md::MdEid::eid);
|
|
219
|
+
cell $sanitizedSetEpConfig = $mdEid.cl::get<objRef>(md::MdEid::md).md::SetEpConfig::sanitize();
|
|
216
220
|
|
|
217
221
|
actions~pushAction<call>(
|
|
218
222
|
_calculateEndpointAddress(dstEid),
|
|
219
223
|
Endpoint::OP::SET_EP_CONFIG_DEFAULTS,
|
|
220
|
-
$
|
|
224
|
+
$sanitizedSetEpConfig
|
|
221
225
|
);
|
|
222
226
|
|
|
223
227
|
return actions;
|
|
@@ -234,10 +238,16 @@ tuple setEpConfigOApp(cell $mdObj) impure inline method_id {
|
|
|
234
238
|
(_, tuple actions) = preamble();
|
|
235
239
|
|
|
236
240
|
;; get the path and setEpConfigMd from the md
|
|
237
|
-
cell $
|
|
241
|
+
cell $sanitizedPath = $mdObj.cl::get<objRef>(md::MdObj::obj).lz::Path::sanitize();
|
|
242
|
+
|
|
243
|
+
;; create a sanitized mdObj with the sanitized setEpConfig
|
|
244
|
+
$mdObj = md::MdObj::New(
|
|
245
|
+
$mdObj.cl::get<objRef>(md::MdObj::md).md::SetEpConfig::sanitize(),
|
|
246
|
+
$sanitizedPath
|
|
247
|
+
);
|
|
238
248
|
|
|
239
249
|
actions~pushAction<call>(
|
|
240
|
-
_calculateEndpointAddress($
|
|
250
|
+
_calculateEndpointAddress($sanitizedPath.cl::get<uint32>(lz::Path::dstEid)),
|
|
241
251
|
Endpoint::OP::SET_EP_CONFIG_OAPP,
|
|
242
252
|
$mdObj
|
|
243
253
|
);
|
|
@@ -248,12 +258,14 @@ tuple setEpConfigOApp(cell $mdObj) impure inline method_id {
|
|
|
248
258
|
tuple addMsglib(cell $addMsglibMd) impure inline method_id {
|
|
249
259
|
(_, tuple actions) = preamble();
|
|
250
260
|
|
|
261
|
+
cell $sanitizedAddMsglibMd = $addMsglibMd.md::AddMsglib::sanitize();
|
|
262
|
+
|
|
251
263
|
actions~pushAction<call>(
|
|
252
264
|
_calculateEndpointAddress(
|
|
253
|
-
$
|
|
265
|
+
$sanitizedAddMsglibMd.cl::get<uint32>(md::AddMsglib::dstEid)
|
|
254
266
|
),
|
|
255
267
|
Endpoint::OP::ADD_MSGLIB,
|
|
256
|
-
$
|
|
268
|
+
$sanitizedAddMsglibMd
|
|
257
269
|
);
|
|
258
270
|
|
|
259
271
|
return actions;
|
|
@@ -263,16 +275,18 @@ tuple addMsglib(cell $addMsglibMd) impure inline method_id {
|
|
|
263
275
|
tuple depositZro(cell $path) impure inline method_id {
|
|
264
276
|
(cell $storage, tuple actions) = preamble();
|
|
265
277
|
|
|
278
|
+
cell $sanitizedPath = $path.lz::Path::sanitize();
|
|
279
|
+
|
|
266
280
|
;; The message format of jetton happens to align with funC++
|
|
267
281
|
;; but the jetton token amount is aliased as donationNanos
|
|
268
282
|
int tokenAmount = getDonationNanos();
|
|
269
283
|
setDonationNanos(0);
|
|
270
284
|
|
|
271
285
|
;; get the endpoint address
|
|
272
|
-
int endpointAddress = _calculateEndpointAddress($
|
|
286
|
+
int endpointAddress = _calculateEndpointAddress($sanitizedPath.cl::get<uint32>(lz::Path::dstEid));
|
|
273
287
|
|
|
274
288
|
int channelAddress = computeContractAddress(
|
|
275
|
-
Channel::New(getContractAddress(), $
|
|
289
|
+
Channel::New(getContractAddress(), $sanitizedPath, endpointAddress),
|
|
276
290
|
$storage.cl::get<cellRef>(Controller::channelCode)
|
|
277
291
|
);
|
|
278
292
|
|
|
@@ -288,14 +302,16 @@ tuple depositZro(cell $path) impure inline method_id {
|
|
|
288
302
|
tuple setZroWallet(cell $setAddress) impure inline method_id {
|
|
289
303
|
(cell $storage, tuple actions) = preamble();
|
|
290
304
|
|
|
305
|
+
cell $sanitizedSetAddress = $setAddress.md::SetAddress::sanitize();
|
|
306
|
+
|
|
291
307
|
setContractStorage(
|
|
292
308
|
$storage.cl::set(
|
|
293
309
|
Controller::zroWallet,
|
|
294
|
-
$
|
|
310
|
+
$sanitizedSetAddress.cl::get<address>(md::SetAddress::address)
|
|
295
311
|
)
|
|
296
312
|
);
|
|
297
313
|
|
|
298
|
-
actions~pushAction<event>(Controller::event::ZRO_WALLET_SET, $
|
|
314
|
+
actions~pushAction<event>(Controller::event::ZRO_WALLET_SET, $sanitizedSetAddress);
|
|
299
315
|
return actions;
|
|
300
316
|
}
|
|
301
317
|
|
|
@@ -306,16 +322,18 @@ tuple setZroWallet(cell $setAddress) impure inline method_id {
|
|
|
306
322
|
tuple transferOwnership(cell $setAddress) impure inline {
|
|
307
323
|
(cell $storage, tuple actions) = preamble();
|
|
308
324
|
|
|
325
|
+
cell $sanitizedSetAddress = $setAddress.md::SetAddress::sanitize();
|
|
326
|
+
|
|
309
327
|
setContractStorage(
|
|
310
328
|
$storage.cl::set(
|
|
311
329
|
Controller::tentativeOwner,
|
|
312
|
-
$
|
|
330
|
+
$sanitizedSetAddress.cl::get<address>(md::SetAddress::address)
|
|
313
331
|
)
|
|
314
332
|
);
|
|
315
333
|
|
|
316
334
|
actions~pushAction<event>(
|
|
317
335
|
Controller::event::OWNER_SET_TENTATIVE,
|
|
318
|
-
$
|
|
336
|
+
$sanitizedSetAddress
|
|
319
337
|
);
|
|
320
338
|
|
|
321
339
|
return actions;
|
|
@@ -7,48 +7,45 @@
|
|
|
7
7
|
#include "../baseStorage.fc";
|
|
8
8
|
|
|
9
9
|
int getOwner() impure inline {
|
|
10
|
-
return
|
|
11
|
-
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
12
|
-
.cl::get<address>(BaseStorage::owner);
|
|
10
|
+
return getBaseStorage().BaseStorage::getOwner();
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
cell getInitialStorage() impure inline {
|
|
16
|
-
return
|
|
17
|
-
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
18
|
-
.cl::get<objRef>(BaseStorage::initialStorage);
|
|
14
|
+
return getBaseStorage().BaseStorage::getInitialStorage();
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
;;; ==========================================
|
|
22
18
|
;; Modifiers
|
|
23
19
|
() assertAuthenticated() impure inline {
|
|
24
|
-
cell $baseStorage = getContractStorage().cl::get<objRef>(BASE_STORAGE_INDEX);
|
|
25
20
|
throw_unless(
|
|
26
21
|
BaseInterface::ERROR::notAuthenticated,
|
|
27
|
-
|
|
22
|
+
getBaseStorage().BaseStorage::getAuthenticated()
|
|
28
23
|
);
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
() assertInitialized() impure inline {
|
|
32
|
-
cell $baseStorage = getContractStorage().cl::get<objRef>(BASE_STORAGE_INDEX);
|
|
33
27
|
throw_unless(
|
|
34
28
|
BaseInterface::ERROR::notInitialized,
|
|
35
|
-
|
|
29
|
+
getBaseStorage().BaseStorage::getInitialized()
|
|
36
30
|
);
|
|
37
31
|
}
|
|
38
32
|
|
|
39
33
|
;; assert the ctx sender is the owner of this contract
|
|
40
34
|
;; expects the ctx to be populated. Does not require storage to be loaded
|
|
41
35
|
() assertOwner() impure inline {
|
|
42
|
-
cell $baseStorage = getContractStorage().cl::get<objRef>(BASE_STORAGE_INDEX);
|
|
43
36
|
throw_unless(
|
|
44
37
|
BaseInterface::ERROR::onlyOwner,
|
|
45
|
-
getCaller() ==
|
|
38
|
+
getCaller() == getOwner()
|
|
46
39
|
);
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
;; Step 1: authenticate
|
|
50
43
|
() authenticate() impure {
|
|
51
44
|
assertOwner();
|
|
45
|
+
throw_if(
|
|
46
|
+
BaseInterface::ERROR::alreadyInitialized,
|
|
47
|
+
getBaseStorage().BaseStorage::getInitialized()
|
|
48
|
+
);
|
|
52
49
|
cell $storage = getContractStorage();
|
|
53
50
|
|
|
54
51
|
setContractStorage(
|
|
@@ -67,10 +64,7 @@ cell getInitialStorage() impure inline {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
() authenticateIfNecessary() impure inline {
|
|
70
|
-
if (
|
|
71
|
-
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
72
|
-
.cl::get<bool>(BaseStorage::authenticated) == false
|
|
73
|
-
) {
|
|
67
|
+
if (getBaseStorage().BaseStorage::getAuthenticated() == false) {
|
|
74
68
|
authenticate();
|
|
75
69
|
}
|
|
76
70
|
}
|
|
@@ -80,11 +74,7 @@ cell getInitialStorage() impure inline {
|
|
|
80
74
|
;; Step 2: initialize
|
|
81
75
|
tuple initialize(cell $md) impure inline {
|
|
82
76
|
assertAuthenticated();
|
|
83
|
-
if (
|
|
84
|
-
getContractStorage()
|
|
85
|
-
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
86
|
-
.cl::get<bool>(BaseStorage::initialized)
|
|
87
|
-
) {
|
|
77
|
+
if (getBaseStorage().BaseStorage::getInitialized()) {
|
|
88
78
|
return emptyActions();
|
|
89
79
|
}
|
|
90
80
|
|
|
@@ -30,4 +30,28 @@ cell BaseStorage::New(int owner) inline method_id {
|
|
|
30
30
|
[cl::t::objRef, cl::nullObject()] ;; BaseStorage::initialStorage
|
|
31
31
|
])
|
|
32
32
|
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const int BaseStorage::_ownerOffset = _HEADER_WIDTH;
|
|
36
|
+
const int BaseStorage::_authenticatedOffset = BaseStorage::_ownerOffset + 256;
|
|
37
|
+
const int BaseStorage::_initializedOffset = BaseStorage::_authenticatedOffset + 1;
|
|
38
|
+
|
|
39
|
+
int BaseStorage::getOwner(cell $self) impure inline {
|
|
40
|
+
return $self.cellPreloadAddressAt(BaseStorage::_ownerOffset);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
int BaseStorage::getAuthenticated(cell $self) impure inline {
|
|
44
|
+
return $self.cellPreloadBoolAt(BaseStorage::_authenticatedOffset);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
int BaseStorage::getInitialized(cell $self) impure inline {
|
|
48
|
+
return $self.cellPreloadBoolAt(BaseStorage::_initializedOffset);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
cell BaseStorage::getInitialStorage(cell $self) impure inline {
|
|
52
|
+
return $self.cellPreloadRefAt(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cell getBaseStorage() impure inline method_id {
|
|
56
|
+
return getContractStorage().cellPreloadRefAt(BASE_STORAGE_INDEX);
|
|
33
57
|
}
|