@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.
Files changed (206) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/AllStorages.compiled.json +1 -1
  3. package/build/AllStorages.test.compiled.json +1 -1
  4. package/build/BaseContract.test.compiled.json +1 -1
  5. package/build/Channel.compiled.json +1 -1
  6. package/build/Channel.permissions.test.compiled.json +1 -1
  7. package/build/ChannelBurn.test.compiled.json +1 -1
  8. package/build/ChannelCommitPacket.test.compiled.json +1 -1
  9. package/build/ChannelConfig.test.compiled.json +1 -1
  10. package/build/ChannelInitialize.test.compiled.json +1 -1
  11. package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
  12. package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
  13. package/build/ChannelNilify.test.compiled.json +1 -1
  14. package/build/ChannelReceive.test.compiled.json +1 -1
  15. package/build/ChannelReceiveCallback.test.compiled.json +1 -1
  16. package/build/ChannelReceiveView.test.compiled.json +1 -1
  17. package/build/ChannelSend.test.compiled.json +1 -1
  18. package/build/Classlib.test.compiled.json +1 -1
  19. package/build/ComputeDataSizeGas.test.compiled.json +1 -1
  20. package/build/Connection.compiled.json +1 -1
  21. package/build/Controller.assertions.test.compiled.json +1 -1
  22. package/build/Controller.compiled.json +1 -1
  23. package/build/Controller.permissions.test.compiled.json +1 -1
  24. package/build/Controller.test.compiled.json +1 -1
  25. package/build/Counter.compiled.json +1 -1
  26. package/build/Counter.permissions.test.compiled.json +1 -1
  27. package/build/Counter.setters.test.compiled.json +1 -1
  28. package/build/Counter.test.compiled.json +1 -1
  29. package/build/Dvn.compiled.json +1 -1
  30. package/build/Dvn.test.compiled.json +1 -1
  31. package/build/DvnFeeLib.compiled.json +1 -1
  32. package/build/DvnPermissions.test.compiled.json +1 -1
  33. package/build/Endpoint.compiled.json +1 -1
  34. package/build/Endpoint.permissions.test.compiled.json +1 -1
  35. package/build/Endpoint.test.compiled.json +1 -1
  36. package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
  37. package/build/Executor.compiled.json +1 -1
  38. package/build/Executor.test.compiled.json +1 -1
  39. package/build/ExecutorFeeLib.compiled.json +1 -1
  40. package/build/ExecutorPermissions.test.compiled.json +1 -1
  41. package/build/LzClasses.test.compiled.json +1 -1
  42. package/build/LzUtil.test.compiled.json +1 -1
  43. package/build/MsgData.test.compiled.json +1 -1
  44. package/build/MsglibPacketCodec.test.compiled.json +1 -1
  45. package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
  46. package/build/PriceFeedCache.compiled.json +1 -1
  47. package/build/PriceFeedCache.permissions.test.compiled.json +1 -1
  48. package/build/PriceFeedCache.test.compiled.json +1 -1
  49. package/build/Proxy.compiled.json +1 -1
  50. package/build/Proxy.permissions.test.compiled.json +1 -1
  51. package/build/Proxy.test.compiled.json +1 -1
  52. package/build/SmlConnection.compiled.json +1 -1
  53. package/build/SmlConnection.permissions.test.compiled.json +1 -1
  54. package/build/SmlConnection.test.compiled.json +1 -1
  55. package/build/SmlManager.compiled.json +1 -1
  56. package/build/SmlManager.permissions.test.compiled.json +1 -1
  57. package/build/SmlManager.test.compiled.json +1 -1
  58. package/build/Uln.compiled.json +1 -1
  59. package/build/Uln.test.compiled.json +1 -1
  60. package/build/UlnConnection.compiled.json +1 -1
  61. package/build/UlnConnection.test.compiled.json +1 -1
  62. package/build/UlnConnectionPermissions.test.compiled.json +1 -1
  63. package/build/UlnManagement.test.compiled.json +1 -1
  64. package/build/UlnManager.compiled.json +1 -1
  65. package/build/UlnManager.test.compiled.json +1 -1
  66. package/build/UlnManagerPermissions.test.compiled.json +1 -1
  67. package/build/UlnManagerUtil.test.compiled.json +1 -1
  68. package/build/UlnPermissions.test.compiled.json +1 -1
  69. package/build/UlnReceiveConfig.test.compiled.json +1 -1
  70. package/build/UlnSend.test.compiled.json +1 -1
  71. package/build/UlnSendConfig.test.compiled.json +1 -1
  72. package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
  73. package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
  74. package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
  75. package/build/UlnUtil.test.compiled.json +1 -1
  76. package/build/WorkerCore.test.compiled.json +1 -1
  77. package/build/badFeeLib1.test.compiled.json +1 -1
  78. package/build/badFeeLib10.test.compiled.json +1 -1
  79. package/build/badFeeLib11.test.compiled.json +1 -1
  80. package/build/badFeeLib12.test.compiled.json +1 -1
  81. package/build/badFeeLib2.test.compiled.json +1 -1
  82. package/build/badFeeLib3.test.compiled.json +1 -1
  83. package/build/badFeeLib4.test.compiled.json +1 -1
  84. package/build/badFeeLib5.test.compiled.json +1 -1
  85. package/build/badFeeLib6.test.compiled.json +1 -1
  86. package/build/badFeeLib7.test.compiled.json +1 -1
  87. package/build/badFeeLib8.test.compiled.json +1 -1
  88. package/build/badFeeLib9.test.compiled.json +1 -1
  89. package/package.json +5 -5
  90. package/src/classes/msgdata/LzReceiveStatus.fc +0 -1
  91. package/src/funC++/actions/call.fc +1 -0
  92. package/src/funC++/actions/deploy.fc +0 -1
  93. package/src/funC++/actions/destroy.fc +0 -1
  94. package/src/funC++/actions/dispatch.fc +0 -1
  95. package/src/funC++/actions/event.fc +0 -1
  96. package/src/funC++/actions/payment.fc +0 -1
  97. package/src/funC++/actions/sendJettons.fc +0 -1
  98. package/src/funC++/actions/utils.fc +0 -2
  99. package/src/funC++/baseInterface.fc +0 -2
  100. package/src/funC++/classlib.fc +0 -36
  101. package/src/funC++/contractMain.fc +2 -8
  102. package/src/funC++/dataStructures/DeterministicInsertionCircularQueue.fc +0 -1
  103. package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +0 -1
  104. package/src/funC++/handlerCore.fc +2 -6
  105. package/src/funC++/stringlib.fc +0 -2
  106. package/src/funC++/testutils.fc +0 -1
  107. package/src/funC++/txnContext.fc +1 -1
  108. package/src/funC++/utils.fc +35 -0
  109. package/src/protocol/channel/callbackOpcodes.fc +10 -0
  110. package/src/protocol/channel/handler.fc +1032 -0
  111. package/src/protocol/channel/interface.fc +60 -0
  112. package/src/protocol/channel/main.fc +39 -0
  113. package/src/protocol/channel/storage.fc +55 -0
  114. package/src/protocol/controller/handler.fc +347 -0
  115. package/src/protocol/controller/interface.fc +25 -0
  116. package/src/protocol/controller/main.fc +29 -0
  117. package/src/protocol/controller/storage.fc +31 -0
  118. package/src/protocol/core/abstract/protocolHandler.fc +110 -0
  119. package/src/protocol/core/abstract/protocolMain.fc +30 -0
  120. package/src/protocol/core/baseStorage.fc +1 -2
  121. package/src/protocol/endpoint/handler.fc +426 -0
  122. package/src/protocol/endpoint/interface.fc +20 -0
  123. package/src/protocol/endpoint/main.fc +23 -0
  124. package/src/protocol/interfaces.fc +4 -0
  125. package/src/protocol/msglibs/BytesDecoder.fc +135 -0
  126. package/src/protocol/msglibs/BytesEncoder.fc +150 -0
  127. package/src/protocol/msglibs/interface.fc +16 -0
  128. package/src/protocol/msglibs/simpleMsglib/smlConnection/handler.fc +125 -0
  129. package/src/protocol/msglibs/simpleMsglib/smlConnection/interface.fc +3 -0
  130. package/src/protocol/msglibs/simpleMsglib/smlConnection/main.fc +19 -0
  131. package/src/protocol/msglibs/simpleMsglib/smlConnection/storage.fc +20 -0
  132. package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +281 -0
  133. package/src/protocol/msglibs/simpleMsglib/smlManager/interface.fc +14 -0
  134. package/src/protocol/msglibs/simpleMsglib/smlManager/main.fc +24 -0
  135. package/src/protocol/msglibs/simpleMsglib/smlManager/storage.fc +38 -0
  136. package/src/protocol/msglibs/ultralightnode/callbackOpcodes.fc +1 -0
  137. package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +10 -0
  138. package/src/protocol/msglibs/ultralightnode/feeLibUtils.fc +51 -0
  139. package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +49 -0
  140. package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +26 -0
  141. package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +23 -0
  142. package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +18 -0
  143. package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +62 -0
  144. package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnManager.fc +18 -0
  145. package/src/protocol/msglibs/ultralightnode/msgdata/RentRefill.fc +18 -0
  146. package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +18 -0
  147. package/src/protocol/msglibs/ultralightnode/msgdata/TreasuryFeeBps.fc +16 -0
  148. package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +26 -0
  149. package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +249 -0
  150. package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +27 -0
  151. package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +170 -0
  152. package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +21 -0
  153. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +16 -0
  154. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibEvents.fc +58 -0
  155. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +56 -0
  156. package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +18 -0
  157. package/src/protocol/msglibs/ultralightnode/uln/handler.fc +803 -0
  158. package/src/protocol/msglibs/ultralightnode/uln/interface.fc +63 -0
  159. package/src/protocol/msglibs/ultralightnode/uln/main.fc +37 -0
  160. package/src/protocol/msglibs/ultralightnode/uln/storage.fc +43 -0
  161. package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +600 -0
  162. package/src/protocol/msglibs/ultralightnode/ulnConnection/interface.fc +36 -0
  163. package/src/protocol/msglibs/ultralightnode/ulnConnection/main.fc +32 -0
  164. package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +49 -0
  165. package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +141 -0
  166. package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +495 -0
  167. package/src/protocol/msglibs/ultralightnode/ulnManager/interface.fc +59 -0
  168. package/src/protocol/msglibs/ultralightnode/ulnManager/main.fc +40 -0
  169. package/src/protocol/msglibs/ultralightnode/ulnManager/storage.fc +44 -0
  170. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/common.fc +27 -0
  171. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +80 -0
  172. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/main.fc +4 -0
  173. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +26 -0
  174. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +123 -0
  175. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/main.fc +4 -0
  176. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +29 -0
  177. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/main.fc +3 -0
  178. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/main.fc +1 -0
  179. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +39 -0
  180. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/ulnSendWorkerV1.fc +363 -0
  181. package/src/workers/core/abstract/workerHandler.fc +150 -0
  182. package/src/workers/core/interface.fc +25 -0
  183. package/src/workers/core/workerCoreStorage.fc +44 -0
  184. package/src/workers/dvn/handler.fc +332 -0
  185. package/src/workers/dvn/interface.fc +25 -0
  186. package/src/workers/dvn/main.fc +36 -0
  187. package/src/workers/dvn/storage.fc +27 -0
  188. package/src/workers/executor/handler.fc +110 -0
  189. package/src/workers/executor/interface.fc +19 -0
  190. package/src/workers/executor/main.fc +26 -0
  191. package/src/workers/executor/storage.fc +19 -0
  192. package/src/workers/msgdata/ExecuteParams.fc +29 -0
  193. package/src/workers/msgdata/NativeDrop.fc +16 -0
  194. package/src/workers/msgdata/ProxyMessage.fc +20 -0
  195. package/src/workers/msgdata/SetDict.fc +20 -0
  196. package/src/workers/msgdata/SetQuorum.fc +20 -0
  197. package/src/workers/msgdata/SignedRequest.fc +18 -0
  198. package/src/workers/priceFeedCache/handler.fc +114 -0
  199. package/src/workers/priceFeedCache/interface.fc +4 -0
  200. package/src/workers/priceFeedCache/main.fc +25 -0
  201. package/src/workers/priceFeedCache/storage.fc +21 -0
  202. package/src/workers/proxy/handler.fc +81 -0
  203. package/src/workers/proxy/interface.fc +11 -0
  204. package/src/workers/proxy/main.fc +17 -0
  205. package/src/workers/proxy/storage.fc +21 -0
  206. package/tests/testMain.fc +0 -1
@@ -0,0 +1,20 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ ;; required storage name
4
+ const int md::SetQuorum::NAME = "setQuorum"u;
5
+
6
+ ;; field names
7
+ const int md::SetQuorum::nonce = 0;
8
+ const int md::SetQuorum::opcode = 1;
9
+ const int md::SetQuorum::quorum = 2;
10
+
11
+ cell md::SetQuorum::New(int nonce, int opcode, int quorum) inline method_id {
12
+ return cl::declare(
13
+ md::SetQuorum::NAME,
14
+ unsafeTuple([
15
+ [cl::t::uint64, nonce], ;; md::SetQuorum::nonce
16
+ [cl::t::uint64, opcode], ;; md::SetQuorum::opcode
17
+ [cl::t::uint64, quorum] ;; md::SetQuorum::quorum
18
+ ])
19
+ );
20
+ }
@@ -0,0 +1,18 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ ;; required storage name
4
+ const int md::SignedRequest::NAME = "sgndReq"u;
5
+
6
+ ;; field names
7
+ const int md::SignedRequest::request = 0;
8
+ const int md::SignedRequest::signatures = 1;
9
+
10
+ cell md::SignedRequest::New(cell $request, cell signatures) method_id {
11
+ return cl::declare(
12
+ md::SignedRequest::NAME,
13
+ unsafeTuple([
14
+ [cl::t::objRef, $request], ;; md::SignedRequest::request
15
+ [cl::t::dict256, signatures] ;; md::SignedRequest::signaturesk
16
+ ])
17
+ );
18
+ }
@@ -0,0 +1,114 @@
1
+ #include "../core/abstract/workerHandler.fc";
2
+
3
+ #include "../core/interface.fc";
4
+
5
+ #include "../../funC++/handlerCore.fc";
6
+
7
+ #include "../../classes/msgdata/MdAddress.fc";
8
+
9
+ #include "../msgdata/ExecuteParams.fc";
10
+
11
+ #include "../proxy/interface.fc";
12
+ #include "../../protocol/channel/interface.fc";
13
+ #include "../../protocol/msglibs/ultralightnode/uln/interface.fc";
14
+
15
+ #include "../../protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc";
16
+
17
+ #include "interface.fc";
18
+ #include "storage.fc";
19
+
20
+ ;;; ==========================PERMISSION FUNCTIONS=================================
21
+
22
+ ;; any of the admins can update the priceFeed cache -> priceFeedFeeLib
23
+ ;; but only the owner can call "callContract" from the priceFeedCache
24
+ () _checkPermissions(int op, cell $md) impure inline {
25
+ if (op == Proxy::OP::HANDLE_CALLBACK) {
26
+ return ();
27
+ }
28
+ return assertAdmin();
29
+ }
30
+
31
+ ;;; ==========================HANDLERS=====================================
32
+
33
+ tuple claimTon(cell $coinsAmount) impure inline {
34
+ return _claimTon(emptyActions(), $coinsAmount);
35
+ }
36
+
37
+ tuple updatePrice(cell $mdAddress) impure inline {
38
+ (cell $storage, tuple actions) = preamble();
39
+
40
+ cell $ulnPriceFeed = $mdAddress.cl::get<objRef>(md::MdAddress::md);
41
+
42
+ cell $pfStorage = $storage
43
+ .cl::get<objRef>(PriceFeedCache::priceFeedFeeLibStorage)
44
+ .cl::set(
45
+ PriceFeedFeelib::priceRatio,
46
+ $ulnPriceFeed.cl::get<coins>(PriceFeedFeelib::priceRatio)
47
+ )
48
+ .cl::set(
49
+ PriceFeedFeelib::gasPriceInUnit,
50
+ $ulnPriceFeed.cl::get<uint64>(PriceFeedFeelib::gasPriceInUnit)
51
+ )
52
+ .cl::set(
53
+ PriceFeedFeelib::gasPerByte,
54
+ $ulnPriceFeed.cl::get<uint32>(PriceFeedFeelib::gasPerByte)
55
+ );
56
+
57
+ setContractStorage(
58
+ $storage.cl::set(PriceFeedCache::priceFeedFeeLibStorage, $pfStorage)
59
+ );
60
+
61
+ ;; call into the proxy to update the priceFeedFeeLib
62
+ return _callViaProxy(
63
+ actions,
64
+ md::ExecuteParams::New(
65
+ $mdAddress.cl::get<address>(md::MdAddress::address), ;; target address, usually the uln
66
+ $pfStorage, ;; new priceFeedFeeLib storage
67
+ 0,
68
+ Uln::OP::UPDATE_WORKER_FEELIB
69
+ )
70
+ );
71
+ }
72
+
73
+ tuple updateNativePrice(cell $mdAddress) impure inline {
74
+ (cell $storage, tuple actions) = preamble();
75
+
76
+ cell $ulnPriceFeed = $mdAddress.cl::get<objRef>(md::MdAddress::md);
77
+
78
+ cell $pfStorage = $storage
79
+ .cl::get<objRef>(PriceFeedCache::priceFeedFeeLibStorage)
80
+ .cl::set(
81
+ PriceFeedFeelib::nativePriceUsd,
82
+ $ulnPriceFeed.cl::get<coins>(PriceFeedFeelib::nativePriceUsd)
83
+ );
84
+
85
+ setContractStorage(
86
+ $storage.cl::set(PriceFeedCache::priceFeedFeeLibStorage, $pfStorage)
87
+ );
88
+
89
+ ;; call into the proxy to update the priceFeedFeeLib
90
+ return _callViaProxy(
91
+ actions,
92
+ md::ExecuteParams::New(
93
+ $mdAddress.cl::get<address>(md::MdAddress::address), ;; target address, usually the uln
94
+ $pfStorage, ;; new priceFeedFeeLib storage
95
+ 0,
96
+ Uln::OP::UPDATE_WORKER_FEELIB
97
+ )
98
+ );
99
+ }
100
+
101
+ tuple callViaProxy(cell $executeParams) impure inline {
102
+ return _callViaProxy(emptyActions(), $executeParams);
103
+ }
104
+
105
+ tuple setAdmins(cell $addressList) impure inline {
106
+ return _setAdmins(emptyActions(), $addressList);
107
+ }
108
+
109
+ tuple setProxy(cell $setAddress) impure inline {
110
+ return _setProxyAddress(
111
+ emptyActions(),
112
+ $setAddress.cl::get<address>(md::SetAddress::address)
113
+ );
114
+ }
@@ -0,0 +1,4 @@
1
+ ;;; ==========================OPCODES=====================================
2
+
3
+ const int PriceFeedCache::OP::UPDATE_PRICE = "PriceFeedCache::OP::UPDATE_PRICE"c;
4
+ const int PriceFeedCache::OP::UPDATE_NATIVE_PRICE = "PriceFeedCache::OP::UPDATE_NATIVE_PRICE"c;
@@ -0,0 +1,25 @@
1
+ #include "../../protocol/core/abstract/protocolMain.fc";
2
+
3
+ #include "handler.fc";
4
+ #include "interface.fc";
5
+
6
+
7
+ tuple _executeOpcode(int op, cell $md) impure inline {
8
+ if (op == PriceFeedCache::OP::UPDATE_PRICE) {
9
+ return updatePrice($md);
10
+ } elseif (op == PriceFeedCache::OP::UPDATE_NATIVE_PRICE) {
11
+ return updateNativePrice($md);
12
+ } elseif (op == Worker::OP::CALL_VIA_PROXY) {
13
+ return callViaProxy($md);
14
+ } elseif (op == Worker::OP::SET_ADMINS) {
15
+ return setAdmins($md);
16
+ } elseif (op == Worker::OP::CLAIM_TON) {
17
+ return claimTon($md);
18
+ } elseif (op == Worker::OP::SET_PROXY) {
19
+ return setProxy($md);
20
+ } elseif (op == Proxy::OP::HANDLE_CALLBACK) {
21
+ return emptyActions();
22
+ }
23
+ throw(BaseInterface::ERROR::invalidOpcode);
24
+ return empty_tuple();
25
+ }
@@ -0,0 +1,21 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ #include "../core/workerCoreStorage.fc";
4
+
5
+ ;; required object name
6
+ const int PriceFeedCache::NAME = "pfCache"u;
7
+
8
+ ;; field names
9
+ const int PriceFeedCache::workerCoreStorage = 0;
10
+ const int PriceFeedCache::priceFeedFeeLibStorage = 1;
11
+
12
+ ;; @owner manager
13
+ cell PriceFeedCache::New(cell admins, int version, cell $priceFeedFeeLib) method_id {
14
+ return cl::declare(
15
+ PriceFeedCache::NAME,
16
+ unsafeTuple([
17
+ [cl::t::objRef, WorkerCoreStorage::New(admins, NULLADDRESS, version)], ;; PriceFeedCache::workerCoreStorage
18
+ [cl::t::objRef, $priceFeedFeeLib] ;; PriceFeedCache::priceFeedFeeLibStorage
19
+ ])
20
+ );
21
+ }
@@ -0,0 +1,81 @@
1
+ #include "../core/abstract/workerHandler.fc";
2
+ #include "../core/interface.fc";
3
+
4
+ #include "../../classes/msgdata/MdAddress.fc";
5
+ #include "../../classes/msgdata/Bool.fc";
6
+
7
+ #include "../msgdata/ProxyMessage.fc";
8
+
9
+ #include "../../protocol/msglibs/ultralightnode/uln/interface.fc";
10
+
11
+ #include "./interface.fc";
12
+ #include "./storage.fc";
13
+
14
+ ;;; ==========================PERMISSION FUNCTIONS=================================
15
+
16
+ () assertLatestAdmin() impure inline {
17
+ throw_unless(
18
+ Proxy::ERROR::NOT_LATEST_ADMIN,
19
+ getCaller() == getLatestAdmin()
20
+ );
21
+ }
22
+
23
+ ;; this is special in proxy, only the people in the address book can call 'callContract'
24
+ () _checkPermissions(int op, cell $md) impure inline {
25
+ if (op == Proxy::OP::CALL_CONTRACT) {
26
+ return assertLatestAdmin();
27
+ } elseif (
28
+ (op == Worker::OP::SET_ADMINS)
29
+ | (op == Worker::OP::CLAIM_TON)
30
+ | (op == Proxy::OP::TOGGLE_CALLBACK)
31
+ ) {
32
+ return assertAdmin();
33
+ }
34
+ return ();
35
+ }
36
+
37
+ ;;; ==========================HANDLERS=====================================
38
+
39
+ tuple setAdmins(cell $addressList) impure inline {
40
+ return _setAdmins(emptyActions(), $addressList);
41
+ }
42
+
43
+ tuple claimTon(cell $coinsAmount) impure inline {
44
+ return _claimTon(emptyActions(), $coinsAmount);
45
+ }
46
+
47
+ tuple callContract(cell $executeParams) impure inline {
48
+ return _callContract(emptyActions(), $executeParams);
49
+ }
50
+
51
+ tuple callback(cell $md) impure inline {
52
+ (cell $storage, tuple actions) = preamble();
53
+
54
+ if ($storage.cl::get<bool>(Proxy::callbackEnabled)) {
55
+ actions~pushAction<call>(
56
+ getLatestAdmin(),
57
+ Proxy::OP::HANDLE_CALLBACK,
58
+ md::ExecuteParams::New(
59
+ getCaller(),
60
+ $md,
61
+ 0,
62
+ getOpcode()
63
+ )
64
+ );
65
+ }
66
+
67
+ return actions;
68
+ }
69
+
70
+ tuple toggleCallback(cell $boolMd) impure inline {
71
+ (cell $storage, tuple actions) = preamble();
72
+
73
+ setContractStorage(
74
+ $storage.cl::set(
75
+ Proxy::callbackEnabled,
76
+ $boolMd.cl::get<bool>(md::Bool::bool)
77
+ )
78
+ );
79
+
80
+ return actions;
81
+ }
@@ -0,0 +1,11 @@
1
+ ;;; ==========================OPCODES=====================================
2
+ const int Proxy::OP::CALL_CONTRACT = "Proxy::OP::CALL_CONTRACT"c;
3
+
4
+ ;; this is the opcode that we will "send out" of proxy to specify the callback
5
+ ;; note that every other opcode that's namespaced by some contract is handled by the contract itself
6
+ ;; but in this case, this opcode is handled by the target contract
7
+ const int Proxy::OP::HANDLE_CALLBACK = "Proxy::OP::HANDLE_CALLBACK"c;
8
+
9
+ const int Proxy::OP::TOGGLE_CALLBACK = "Proxy::OP::TOGGLE_CALLBACK"c;
10
+
11
+ const int Proxy::ERROR::NOT_LATEST_ADMIN = 1919;
@@ -0,0 +1,17 @@
1
+ #include "../../protocol/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 == Worker::OP::SET_ADMINS) {
8
+ return setAdmins($md);
9
+ } elseif (op == Worker::OP::CLAIM_TON) {
10
+ return claimTon($md);
11
+ } elseif (op == Proxy::OP::CALL_CONTRACT) {
12
+ return callContract($md);
13
+ } elseif (op == Proxy::OP::TOGGLE_CALLBACK) {
14
+ return toggleCallback($md);
15
+ }
16
+ return callback($md);
17
+ }
@@ -0,0 +1,21 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ #include "../core/workerCoreStorage.fc";
4
+
5
+ ;; required object name
6
+ const int Proxy::NAME = "pfProxy"u;
7
+
8
+ ;; field names
9
+ const int Proxy::workerCoreStorage = 0; ;; = WORKER_CORE_STORAGE_IDX
10
+ const int Proxy::callbackEnabled = 1;
11
+
12
+ ;; @owner manager
13
+ cell Proxy::New(cell admins, int version) method_id {
14
+ return cl::declare(
15
+ Proxy::NAME,
16
+ unsafeTuple([
17
+ [cl::t::objRef, WorkerCoreStorage::New(admins, NULLADDRESS, version)], ;; Proxy::workerCoreStorage
18
+ [cl::t::bool, false] ;; Proxy::callbackEnabled
19
+ ])
20
+ );
21
+ }
package/tests/testMain.fc CHANGED
@@ -1,6 +1,5 @@
1
1
  #include "../src/funC++/classlib.fc";
2
2
  #include "../src/funC++/txnContext.fc";
3
- #include "../src/funC++/utils.fc";
4
3
 
5
4
  global slice base_error_msg;
6
5
  ;; const int do_profile = -1; ;; doesn't compile with true