@layerzerolabs/layerzero-v2-ton 3.0.12-ton.0

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 (251) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +15 -0
  3. package/build/AllStorages.boc +0 -0
  4. package/build/AllStorages.compiled.json +1 -0
  5. package/build/AllStorages.fif +4164 -0
  6. package/build/AllStorages.test.boc +0 -0
  7. package/build/AllStorages.test.compiled.json +1 -0
  8. package/build/AllStorages.test.fif +1831 -0
  9. package/build/BaseContract.test.boc +0 -0
  10. package/build/BaseContract.test.compiled.json +1 -0
  11. package/build/BaseContract.test.fif +3553 -0
  12. package/build/Channel.boc +0 -0
  13. package/build/Channel.compiled.json +1 -0
  14. package/build/Channel.fif +5001 -0
  15. package/build/Channel.permissions.test.boc +0 -0
  16. package/build/Channel.permissions.test.compiled.json +1 -0
  17. package/build/Channel.permissions.test.fif +7569 -0
  18. package/build/ChannelBurn.test.boc +0 -0
  19. package/build/ChannelBurn.test.compiled.json +1 -0
  20. package/build/ChannelBurn.test.fif +7454 -0
  21. package/build/ChannelCommitPacket.test.boc +0 -0
  22. package/build/ChannelCommitPacket.test.compiled.json +1 -0
  23. package/build/ChannelCommitPacket.test.fif +7981 -0
  24. package/build/ChannelConfig.test.boc +0 -0
  25. package/build/ChannelConfig.test.compiled.json +1 -0
  26. package/build/ChannelConfig.test.fif +7442 -0
  27. package/build/ChannelInitialize.test.boc +0 -0
  28. package/build/ChannelInitialize.test.compiled.json +1 -0
  29. package/build/ChannelInitialize.test.fif +7289 -0
  30. package/build/ChannelMsglibIntegration.test.boc +0 -0
  31. package/build/ChannelMsglibIntegration.test.compiled.json +1 -0
  32. package/build/ChannelMsglibIntegration.test.fif +7404 -0
  33. package/build/ChannelMsglibSendCallback.test.boc +0 -0
  34. package/build/ChannelMsglibSendCallback.test.compiled.json +1 -0
  35. package/build/ChannelMsglibSendCallback.test.fif +7711 -0
  36. package/build/ChannelNilify.test.boc +0 -0
  37. package/build/ChannelNilify.test.compiled.json +1 -0
  38. package/build/ChannelNilify.test.fif +7672 -0
  39. package/build/ChannelReceive.test.boc +0 -0
  40. package/build/ChannelReceive.test.compiled.json +1 -0
  41. package/build/ChannelReceive.test.fif +7702 -0
  42. package/build/ChannelReceiveCallback.test.boc +0 -0
  43. package/build/ChannelReceiveCallback.test.compiled.json +1 -0
  44. package/build/ChannelReceiveCallback.test.fif +7549 -0
  45. package/build/ChannelReceiveView.test.boc +0 -0
  46. package/build/ChannelReceiveView.test.compiled.json +1 -0
  47. package/build/ChannelReceiveView.test.fif +7352 -0
  48. package/build/ChannelSend.test.boc +0 -0
  49. package/build/ChannelSend.test.compiled.json +1 -0
  50. package/build/ChannelSend.test.fif +7658 -0
  51. package/build/Classlib.test.boc +0 -0
  52. package/build/Classlib.test.compiled.json +1 -0
  53. package/build/Classlib.test.fif +4728 -0
  54. package/build/Connection.boc +0 -0
  55. package/build/Connection.compiled.json +1 -0
  56. package/build/Connection.fif +3503 -0
  57. package/build/Connection.test.boc +0 -0
  58. package/build/Connection.test.compiled.json +1 -0
  59. package/build/Connection.test.fif +6575 -0
  60. package/build/Controller.assertions.test.boc +0 -0
  61. package/build/Controller.assertions.test.compiled.json +1 -0
  62. package/build/Controller.assertions.test.fif +6130 -0
  63. package/build/Controller.boc +0 -0
  64. package/build/Controller.compiled.json +1 -0
  65. package/build/Controller.fif +3195 -0
  66. package/build/Controller.permissions.test.boc +0 -0
  67. package/build/Controller.permissions.test.compiled.json +1 -0
  68. package/build/Controller.permissions.test.fif +6237 -0
  69. package/build/Controller.test.boc +0 -0
  70. package/build/Controller.test.compiled.json +1 -0
  71. package/build/Controller.test.fif +6400 -0
  72. package/build/Counter.boc +0 -0
  73. package/build/Counter.compiled.json +1 -0
  74. package/build/Counter.fif +4809 -0
  75. package/build/Counter.permissions.test.boc +0 -0
  76. package/build/Counter.permissions.test.compiled.json +1 -0
  77. package/build/Counter.permissions.test.fif +7106 -0
  78. package/build/Counter.setters.test.boc +0 -0
  79. package/build/Counter.setters.test.compiled.json +1 -0
  80. package/build/Counter.setters.test.fif +7083 -0
  81. package/build/Counter.test.boc +0 -0
  82. package/build/Counter.test.compiled.json +1 -0
  83. package/build/Counter.test.fif +7540 -0
  84. package/build/Dvn.boc +0 -0
  85. package/build/Dvn.compiled.json +1 -0
  86. package/build/Dvn.fif +2923 -0
  87. package/build/Dvn.test.boc +0 -0
  88. package/build/Dvn.test.compiled.json +1 -0
  89. package/build/Dvn.test.fif +5753 -0
  90. package/build/Endpoint.boc +0 -0
  91. package/build/Endpoint.compiled.json +1 -0
  92. package/build/Endpoint.fif +3694 -0
  93. package/build/Endpoint.permissions.test.boc +0 -0
  94. package/build/Endpoint.permissions.test.compiled.json +1 -0
  95. package/build/Endpoint.permissions.test.fif +6211 -0
  96. package/build/Endpoint.test.boc +0 -0
  97. package/build/Endpoint.test.compiled.json +1 -0
  98. package/build/Endpoint.test.fif +6899 -0
  99. package/build/EndpointSetEpConfigDefaults.test.boc +0 -0
  100. package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -0
  101. package/build/EndpointSetEpConfigDefaults.test.fif +6529 -0
  102. package/build/Executor.boc +0 -0
  103. package/build/Executor.compiled.json +1 -0
  104. package/build/Executor.fif +2731 -0
  105. package/build/Executor.test.boc +0 -0
  106. package/build/Executor.test.compiled.json +1 -0
  107. package/build/Executor.test.fif +5822 -0
  108. package/build/LzClasses.test.boc +0 -0
  109. package/build/LzClasses.test.compiled.json +1 -0
  110. package/build/LzClasses.test.fif +4457 -0
  111. package/build/LzUtil.test.boc +0 -0
  112. package/build/LzUtil.test.compiled.json +1 -0
  113. package/build/LzUtil.test.fif +1831 -0
  114. package/build/MsgData.test.boc +0 -0
  115. package/build/MsgData.test.compiled.json +1 -0
  116. package/build/MsgData.test.fif +4318 -0
  117. package/build/MsglibPacketCodec.test.boc +0 -0
  118. package/build/MsglibPacketCodec.test.compiled.json +1 -0
  119. package/build/MsglibPacketCodec.test.fif +4851 -0
  120. package/build/MultiSig.boc +0 -0
  121. package/build/MultiSig.compiled.json +1 -0
  122. package/build/MultiSig.fif +727 -0
  123. package/build/MultiSigOrder.boc +0 -0
  124. package/build/MultiSigOrder.compiled.json +1 -0
  125. package/build/MultiSigOrder.fif +650 -0
  126. package/build/PipelinedOutOfOrder.test.boc +0 -0
  127. package/build/PipelinedOutOfOrder.test.compiled.json +1 -0
  128. package/build/PipelinedOutOfOrder.test.fif +2188 -0
  129. package/build/SmlConnection.boc +0 -0
  130. package/build/SmlConnection.compiled.json +1 -0
  131. package/build/SmlConnection.fif +2517 -0
  132. package/build/SmlConnection.permissions.test.boc +0 -0
  133. package/build/SmlConnection.permissions.test.compiled.json +1 -0
  134. package/build/SmlConnection.permissions.test.fif +5497 -0
  135. package/build/SmlConnection.test.boc +0 -0
  136. package/build/SmlConnection.test.compiled.json +1 -0
  137. package/build/SmlConnection.test.fif +5494 -0
  138. package/build/SmlManager.boc +0 -0
  139. package/build/SmlManager.compiled.json +1 -0
  140. package/build/SmlManager.fif +3904 -0
  141. package/build/SmlManager.permissions.test.boc +0 -0
  142. package/build/SmlManager.permissions.test.compiled.json +1 -0
  143. package/build/SmlManager.permissions.test.fif +6018 -0
  144. package/build/SmlManager.test.boc +0 -0
  145. package/build/SmlManager.test.compiled.json +1 -0
  146. package/build/SmlManager.test.fif +6047 -0
  147. package/build/Uln.boc +0 -0
  148. package/build/Uln.compiled.json +1 -0
  149. package/build/Uln.fif +4841 -0
  150. package/build/Uln.test.boc +0 -0
  151. package/build/Uln.test.compiled.json +1 -0
  152. package/build/Uln.test.fif +7077 -0
  153. package/build/UlnManager.boc +0 -0
  154. package/build/UlnManager.compiled.json +1 -0
  155. package/build/UlnManager.fif +3851 -0
  156. package/build/UlnManager.test.boc +0 -0
  157. package/build/UlnManager.test.compiled.json +1 -0
  158. package/build/UlnManager.test.fif +6571 -0
  159. package/build/UlnReceiveConfig.test.boc +0 -0
  160. package/build/UlnReceiveConfig.test.compiled.json +1 -0
  161. package/build/UlnReceiveConfig.test.fif +4413 -0
  162. package/build/UlnSend.test.boc +0 -0
  163. package/build/UlnSend.test.compiled.json +1 -0
  164. package/build/UlnSend.test.fif +6576 -0
  165. package/build/UlnSendConfig.test.boc +0 -0
  166. package/build/UlnSendConfig.test.compiled.json +1 -0
  167. package/build/UlnSendConfig.test.fif +4431 -0
  168. package/build/UlnSendWorkerFactory.test.boc +0 -0
  169. package/build/UlnSendWorkerFactory.test.compiled.json +1 -0
  170. package/build/UlnSendWorkerFactory.test.fif +6683 -0
  171. package/build/UlnUtil.test.boc +0 -0
  172. package/build/UlnUtil.test.compiled.json +1 -0
  173. package/build/UlnUtil.test.fif +5873 -0
  174. package/build/WorkerCore.test.boc +0 -0
  175. package/build/WorkerCore.test.compiled.json +1 -0
  176. package/build/WorkerCore.test.fif +5630 -0
  177. package/build/ZroMinter.boc +0 -0
  178. package/build/ZroMinter.compiled.json +1 -0
  179. package/build/ZroMinter.fif +2300 -0
  180. package/build/ZroWallet.boc +0 -0
  181. package/build/ZroWallet.compiled.json +1 -0
  182. package/build/ZroWallet.fif +2471 -0
  183. package/package.json +64 -0
  184. package/src/classes/lz/Attestation.fc +23 -0
  185. package/src/classes/lz/Config.fc +23 -0
  186. package/src/classes/lz/EpConfig.fc +91 -0
  187. package/src/classes/lz/MsglibInfo.fc +31 -0
  188. package/src/classes/lz/Packet.fc +202 -0
  189. package/src/classes/lz/Path.fc +56 -0
  190. package/src/classes/lz/ReceiveEpConfig.fc +24 -0
  191. package/src/classes/lz/SendEpConfig.fc +18 -0
  192. package/src/classes/lz/SmlJobAssigned.fc +20 -0
  193. package/src/classes/lz/Worker.fc +32 -0
  194. package/src/classes/msgdata/AddMsglib.fc +18 -0
  195. package/src/classes/msgdata/Amount.fc +16 -0
  196. package/src/classes/msgdata/Bool.fc +16 -0
  197. package/src/classes/msgdata/ChannelNonceInfo.fc +18 -0
  198. package/src/classes/msgdata/ClaimUnaccountedPoolFunds.fc +0 -0
  199. package/src/classes/msgdata/CoinsAmount.fc +16 -0
  200. package/src/classes/msgdata/CounterIncrement.fc +24 -0
  201. package/src/classes/msgdata/Deploy.fc +20 -0
  202. package/src/classes/msgdata/ExtendedMd.fc +20 -0
  203. package/src/classes/msgdata/GetMsglibCallback.fc +18 -0
  204. package/src/classes/msgdata/InitEndpoint.fc +16 -0
  205. package/src/classes/msgdata/InitSmlConnection.fc +16 -0
  206. package/src/classes/msgdata/InitUlnConnection.fc +18 -0
  207. package/src/classes/msgdata/LzReceiveStatus.fc +58 -0
  208. package/src/classes/msgdata/LzSend.fc +58 -0
  209. package/src/classes/msgdata/MdAddress.fc +18 -0
  210. package/src/classes/msgdata/MdEid.fc +18 -0
  211. package/src/classes/msgdata/MdObj.fc +18 -0
  212. package/src/classes/msgdata/MessagingReceipt.fc +22 -0
  213. package/src/classes/msgdata/MsglibSendCallback.fc +113 -0
  214. package/src/classes/msgdata/Nonce.fc +16 -0
  215. package/src/classes/msgdata/OptionsExtended.fc +20 -0
  216. package/src/classes/msgdata/OptionsV1.fc +27 -0
  217. package/src/classes/msgdata/OptionsV2.fc +34 -0
  218. package/src/classes/msgdata/PacketId.fc +18 -0
  219. package/src/classes/msgdata/PacketSent.fc +39 -0
  220. package/src/classes/msgdata/SetAddress.fc +16 -0
  221. package/src/classes/msgdata/SetEpConfig.fc +33 -0
  222. package/src/classes/msgdata/SetPeer.fc +18 -0
  223. package/src/classes/msgdata/SetSmlManagerConfig.fc +18 -0
  224. package/src/funC++/abstract/contractMainAbstract.fc +3 -0
  225. package/src/funC++/abstract/handlerAbstract.fc +12 -0
  226. package/src/funC++/actions/call.fc +51 -0
  227. package/src/funC++/actions/deploy.fc +118 -0
  228. package/src/funC++/actions/destroy.fc +28 -0
  229. package/src/funC++/actions/dispatch.fc +57 -0
  230. package/src/funC++/actions/event.fc +69 -0
  231. package/src/funC++/actions/payment.fc +52 -0
  232. package/src/funC++/actions/sendJettons.fc +76 -0
  233. package/src/funC++/actions/utils.fc +49 -0
  234. package/src/funC++/baseInterface.fc +16 -0
  235. package/src/funC++/classlib.fc +819 -0
  236. package/src/funC++/constants.fc +64 -0
  237. package/src/funC++/contractMain.fc +84 -0
  238. package/src/funC++/dataStructures/DeterministicInsertionCircularQueue.fc +155 -0
  239. package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +93 -0
  240. package/src/funC++/handlerCore.fc +30 -0
  241. package/src/funC++/stdlib.fc +625 -0
  242. package/src/funC++/stringlib.fc +75 -0
  243. package/src/funC++/txnContext.fc +126 -0
  244. package/src/funC++/utils.fc +119 -0
  245. package/src/jettons/zro/minter.fc +120 -0
  246. package/src/jettons/zro/op-codes.fc +10 -0
  247. package/src/jettons/zro/params.fc +18 -0
  248. package/src/jettons/zro/utils.fc +33 -0
  249. package/src/jettons/zro/wallet.fc +261 -0
  250. package/tests/baseContractTest.fc +192 -0
  251. package/tests/testMain.fc +135 -0
@@ -0,0 +1,33 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ ;; required storage name
4
+ const int md::SetEpConfig::NAME = "SetEpCfg"u;
5
+
6
+ ;; 'md::SetEpConfig::useDefaults' is ONLY used during the oapp config set flow.
7
+ ;; When setting 'epConfigDefaults' as the owner, the flag doesnt matter, because call is for defaults
8
+
9
+ ;; field names
10
+ const int md::SetEpConfig::useDefaults = 0;
11
+ const int md::SetEpConfig::sendMsglibManager = 1;
12
+ const int md::SetEpConfig::receiveMsglibManager = 2;
13
+ const int md::SetEpConfig::timeoutReceiveMsglibManager = 3;
14
+ const int md::SetEpConfig::timeoutReceiveMsglibExpiry = 4;
15
+
16
+ cell md::SetEpConfig::New(
17
+ int useDefaults,
18
+ int sendMsglibManager,
19
+ int receiveMsglibManager,
20
+ int timeoutReceiveMsglibManager,
21
+ int timeoutReceiveMsglibExpiry
22
+ ) inline method_id {
23
+ return cl::declare(
24
+ md::SetEpConfig::NAME,
25
+ unsafeTuple([
26
+ [cl::t::bool, useDefaults], ;; md::SetEpConfig::useDefaults
27
+ [cl::t::address, sendMsglibManager], ;; md::SetEpConfig::sendMsglibManager
28
+ [cl::t::address, receiveMsglibManager], ;; md::SetEpConfig::receiveMsglibManager
29
+ [cl::t::address, timeoutReceiveMsglibManager], ;; md::SetEpConfig::timeoutReceiveMsglibManager
30
+ [cl::t::uint64, timeoutReceiveMsglibExpiry] ;; md::SetEpConfig::timeoutReceiveMsglibExpiry
31
+ ])
32
+ );
33
+ }
@@ -0,0 +1,18 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ ;; required storage name
4
+ const int md::SetPeer::NAME = "setPeer"u;
5
+
6
+ ;; field names
7
+ const int md::SetPeer::eid = 0;
8
+ const int md::SetPeer::peer = 1;
9
+
10
+ cell md::SetPeer::New(int eid, int peer) inline method_id {
11
+ return cl::declare(
12
+ md::SetPeer::NAME,
13
+ unsafeTuple([
14
+ [cl::t::uint32, eid], ;; md::SetPeer::eid
15
+ [cl::t::uint256, peer] ;; md::SetPeer::peer
16
+ ])
17
+ );
18
+ }
@@ -0,0 +1,18 @@
1
+ #include "../../funC++/classlib.fc";
2
+
3
+ ;; required storage name
4
+ const int md::SetSmlManagerConfig::NAME = "setSmlCfg"u;
5
+
6
+ ;; field names
7
+ const int md::SetSmlManagerConfig::nativeFee = 0;
8
+ const int md::SetSmlManagerConfig::zroFee = 1;
9
+
10
+ cell md::SetSmlManagerConfig::New(int nativeFee, int zroFee) inline method_id {
11
+ return cl::declare(
12
+ md::SetSmlManagerConfig::NAME,
13
+ unsafeTuple([
14
+ [cl::t::coins, nativeFee], ;; md::SetSmlManagerConfig::nativeFee
15
+ [cl::t::coins, zroFee] ;; md::SetSmlManagerConfig::zroFee
16
+ ])
17
+ );
18
+ }
@@ -0,0 +1,3 @@
1
+ ;; todo: comments
2
+ tuple _executeOpcode(int op, cell $md) impure inline;
3
+ int _executeAction(int actionType, tuple action) impure inline;
@@ -0,0 +1,12 @@
1
+ ;; todo: comments
2
+ () assertInitialized() impure inline;
3
+
4
+ () checkPermissions(int op, cell $md) impure inline;
5
+
6
+ tuple initialize(cell $md) impure inline;
7
+
8
+ () authenticateIfNecessary() impure inline;
9
+
10
+ () assertOwner() impure inline;
11
+ () _checkPermissions(int op, cell $md) impure inline;
12
+
@@ -0,0 +1,51 @@
1
+ #include "utils.fc";
2
+ #include "../stdlib.fc";
3
+ #include "../stringlib.fc";
4
+
5
+ const int action::call::NAME = "actionCall"u;
6
+
7
+ const int action::call::to = 1;
8
+ const int action::call::opcode = 2;
9
+ const int action::call::md = 3;
10
+
11
+ ;; Call a method on the contract at address `to` with the given message data `md`
12
+ ;; optionally provide value provisioned from this contract's balance
13
+ ;; @terminal
14
+ tuple action::call::New(int to, int opcode, cell $md) inline {
15
+ return unsafeTuple([action::call::NAME, to, opcode, $md]);
16
+ }
17
+
18
+ ;; returns true if equals
19
+ int action::call::equals(tuple self, tuple other) {
20
+ int equalMdField = compareObjectFields(self.cell_at(action::call::md), other.cell_at(action::call::md));
21
+ return (
22
+ (self.int_at(0) == other.int_at(0)) ;; NAME
23
+ & (self.int_at(action::call::to) == other.int_at(action::call::to))
24
+ & (self.int_at(action::call::opcode) == other.int_at(action::call::opcode))
25
+ & (equalMdField == -1)
26
+ );
27
+ }
28
+
29
+ ;; overloaded when you want to pass 0 outflowNanos
30
+ tuple _newAction<call>(int to, int opcode, cell $body) inline {
31
+ return action::call::New(to, opcode, $body);
32
+ }
33
+
34
+ ;; overloaded when you want to pass 0 outflowNanos
35
+ (tuple, ()) ~pushAction<call>(tuple actions, int to, int opcode, cell $body) inline {
36
+ return (actions.tpush(_newAction<call>(to, opcode, $body)), ());
37
+ }
38
+
39
+ int executeCall(tuple callAction) impure inline {
40
+ sendTerminalAction(
41
+ callAction.int_at(action::call::to),
42
+ buildLayerzeroMessageBody(
43
+ 0,
44
+ callAction.int_at(action::call::opcode),
45
+ callAction.cell_at(action::call::md)
46
+ ),
47
+ null(),
48
+ NORMAL
49
+ );
50
+ return false;
51
+ }
@@ -0,0 +1,118 @@
1
+ #include "utils.fc";
2
+ #include "../stdlib.fc";
3
+
4
+ ;;; =======================================================
5
+ ;; Deploys a contract defined by the given code and storage object,
6
+ ;; and calls the contract with the given message data.
7
+ ;; Typical usage will be to deploy and initialize
8
+ ;;; =======================================================
9
+ const int action::deploy::NAME = "deploy"u;
10
+
11
+ const int action::deploy::code = 1;
12
+ const int action::deploy::storage = 2;
13
+ const int action::deploy::donationNanos = 3;
14
+ const int action::deploy::opcode = 4;
15
+ const int action::deploy::md = 5;
16
+ ;; @info reserve donationNanos nanoton as the deployed contract's rent + value
17
+ ;; @info in addition to the message value, use from_balance nanoton
18
+ ;; from the contract's balance to pay for the deploy
19
+ ;; @info e.g., if from_balance == outflowNanos, the entire rent is paid from the deployer
20
+ ;; contract's balance
21
+ const int action::deploy::outflowNanos = 6;
22
+
23
+ ;; @terminal
24
+ tuple action::deploy::New(
25
+ cell code,
26
+ cell $storage,
27
+ int donationNanos,
28
+ int opcode,
29
+ cell $md,
30
+ int outflowNanos
31
+ ) inline {
32
+ return unsafeTuple(
33
+ [action::deploy::NAME, code, $storage, donationNanos, opcode, $md, outflowNanos]
34
+ );
35
+ }
36
+
37
+ int action::deploy::equals(tuple self, tuple other) {
38
+ int equalDataField = compareObjectFields(
39
+ self.cell_at(action::deploy::storage),
40
+ other.cell_at(action::deploy::storage)
41
+ );
42
+ int equalMdField = compareObjectFields(
43
+ self.cell_at(action::deploy::md),
44
+ other.cell_at(action::deploy::md)
45
+ );
46
+ return (
47
+ (self.int_at(0) == other.int_at(0)) ;; NAME
48
+ & (self.cell_at( action::deploy::code ).cell_hash() == other.cell_at( action::deploy::code ).cell_hash())
49
+ & (equalDataField == -1)
50
+ & (self.int_at(action::deploy::donationNanos) == other.int_at(action::deploy::donationNanos))
51
+ & (self.int_at(action::deploy::opcode) == other.int_at(action::deploy::opcode))
52
+ & (equalMdField == -1)
53
+ & (self.int_at(action::deploy::outflowNanos) == other.int_at(action::deploy::outflowNanos))
54
+ );
55
+ }
56
+
57
+ tuple _newAction<deployAndCall>(
58
+ cell code,
59
+ cell $storage,
60
+ int donationNanos,
61
+ int opcode,
62
+ cell $md,
63
+ int outflowNanos
64
+ ) inline {
65
+ return action::deploy::New(
66
+ code,
67
+ $storage,
68
+ donationNanos,
69
+ opcode,
70
+ $md,
71
+ outflowNanos
72
+ );
73
+ }
74
+
75
+ (tuple, ()) ~pushAction<deployAndCall>(
76
+ tuple actions,
77
+ cell code,
78
+ cell $storage,
79
+ int donationNanos,
80
+ int opcode,
81
+ cell $md,
82
+ int outflowNanos
83
+ ) inline {
84
+ return (
85
+ actions
86
+ .tpush(_newAction<deployAndCall>(
87
+ code,
88
+ $storage,
89
+ donationNanos,
90
+ opcode,
91
+ $md,
92
+ outflowNanos
93
+ )),
94
+ ()
95
+ );
96
+ }
97
+
98
+ int executeDeploy(tuple action) impure inline {
99
+ cell $storageObj = action.cell_at(action::deploy::storage);
100
+ cell codeCell = action.cell_at(action::deploy::code);
101
+
102
+ sendTerminalAction(
103
+ computeContractAddress($storageObj, codeCell),
104
+ buildLayerzeroMessageBody(
105
+ action.int_at(action::deploy::donationNanos),
106
+ action.int_at(action::deploy::opcode),
107
+ action.cell_at(action::deploy::md)
108
+ ),
109
+ begin_cell()
110
+ .store_uint(6, 5)
111
+ .store_ref(codeCell)
112
+ .store_ref($storageObj)
113
+ .end_cell(),
114
+ NORMAL
115
+ );
116
+
117
+ return false;
118
+ }
@@ -0,0 +1,28 @@
1
+ #include "utils.fc";
2
+ #include "../stdlib.fc";
3
+
4
+ const int action::destroy::NAME = "destroy"u;
5
+
6
+ const int action::destroy::to = 1;
7
+ const int action::destroy::opcode = 2;
8
+ const int action::destroy::md = 3;
9
+
10
+ ;; @terminal
11
+ tuple action::destroy::New(int to, int opcode, cell $md) inline {
12
+ return unsafeTuple([action::destroy::NAME, to, opcode, $md]);
13
+ }
14
+
15
+ ;; returns true if equals
16
+ int action::destroy::equals(tuple self, tuple other) {
17
+ int equalMdField = compareObjectFields(
18
+ self.cell_at(action::destroy::md),
19
+ other.cell_at(action::destroy::md)
20
+ );
21
+
22
+ return (
23
+ (self.int_at(0) == other.int_at(0)) ;; NAME
24
+ & (self.int_at(action::destroy::to) == other.int_at(action::destroy::to))
25
+ & (self.int_at(action::destroy::opcode) == other.int_at(action::destroy::opcode))
26
+ & (equalMdField == -1)
27
+ );
28
+ }
@@ -0,0 +1,57 @@
1
+ #include "utils.fc";
2
+ #include "../stdlib.fc";
3
+
4
+ #include "call.fc";
5
+
6
+ const int action::dispatch::NAME = "dispatch"u;
7
+
8
+ const int action::dispatch::to = 1;
9
+ const int action::dispatch::opcode = 2;
10
+ const int action::dispatch::md = 3;
11
+ const int action::dispatch::gasNanos = 4;
12
+
13
+ ;; Call a method on the contract at address `to` with the given message data `md`
14
+ ;; optionally provide value provisioned from this contract's balance
15
+ ;; @terminal
16
+ tuple action::dispatch::New(int to, int opcode, cell $md, int gasNanos) inline {
17
+ return unsafeTuple([action::dispatch::NAME, to, opcode, $md, gasNanos]);
18
+ }
19
+
20
+ ;; returns true if equals
21
+ int action::dispatch::equals(tuple self, tuple other) {
22
+ int equalMdField = compareObjectFields(
23
+ self.cell_at(action::dispatch::md),
24
+ other.cell_at(action::dispatch::md)
25
+ );
26
+ return (
27
+ (self.int_at(0) == other.int_at(0 )) ;; NAME
28
+ & (self.int_at(action::dispatch::to) == other.int_at(action::dispatch::to))
29
+ & (self.int_at(action::dispatch::opcode) == other.int_at(action::dispatch::opcode))
30
+ & (equalMdField == -1)
31
+ & (self.int_at(action::dispatch::gasNanos) == other.int_at(action::dispatch::gasNanos))
32
+ );
33
+ }
34
+
35
+ tuple _newAction<dispatch>(int to, int opcode, cell $body, int gasNanos) inline {
36
+ return action::dispatch::New(to, opcode, $body, gasNanos);
37
+ }
38
+
39
+ ;; overloaded when you want to pass 0 outflowNanos
40
+ (tuple, ()) ~pushAction<dispatch>(tuple actions, int to, int opcode, cell $body, int gasNanos) inline {
41
+ return (actions.tpush(_newAction<dispatch>(to, opcode, $body, gasNanos)), ());
42
+ }
43
+
44
+ int executeDispatch(tuple dispatchAction) {
45
+ sendNonTerminalAction(
46
+ SEND_MSG_BOUNCEABLE,
47
+ dispatchAction.int_at(action::dispatch::gasNanos),
48
+ dispatchAction.int_at(action::call::to),
49
+ buildLayerzeroMessageBody(
50
+ 0,
51
+ dispatchAction.int_at(action::call::opcode),
52
+ dispatchAction.cell_at(action::call::md)
53
+ ),
54
+ NORMAL
55
+ );
56
+ return true;
57
+ }
@@ -0,0 +1,69 @@
1
+ #include "../baseInterface.fc";
2
+ #include "../classlib.fc";
3
+ #include "utils.fc";
4
+
5
+ const int action::event::NAME = "event"u;
6
+
7
+ const int action::event::bodyIndex = 1;
8
+
9
+ const int action::event::topic = 0;
10
+ const int action::event::body = 1;
11
+ const int action::event::initialStorage = 2;
12
+
13
+ ;; Interface function you must implement to get the event sink
14
+ int _getEventSink() impure inline;
15
+
16
+ ;; @info Events in LZ contracts are internal messages to an event sink
17
+ ;; where the resulting transaction always reverts
18
+ ;; @non-terminal
19
+ tuple action::event::New(int topic, cell $body, cell $initialStorage) inline method_id {
20
+ cell $eventObj = cl::declare(
21
+ action::event::NAME,
22
+ unsafeTuple([
23
+ [cl::t::uint256, topic],
24
+ [cl::t::objRef, $body],
25
+ [cl::t::objRef, $initialStorage]
26
+ ])
27
+ );
28
+ return unsafeTuple([action::event::NAME, $eventObj]);
29
+ }
30
+
31
+ ;; returns true if equals
32
+ int action::event::equals(tuple self, tuple other) {
33
+ int equalEventObj = compareObjectFields(
34
+ self.cell_at(action::event::bodyIndex),
35
+ other.cell_at(action::event::bodyIndex)
36
+ );
37
+
38
+ return (
39
+ (self.int_at(0) == other.int_at(0)) ;; NAME
40
+ & (equalEventObj == -1)
41
+ );
42
+ }
43
+
44
+ ;; interface this function because it requires passing the 'getInitialStorage' from the baseHandler
45
+ ;; tuple _newAction<event>(int topic, cell $body) impure inline {
46
+ ;; return action::event::New(topic, $body, getInitialStorage());
47
+ ;; }
48
+
49
+ tuple _newAction<event>(int topic, cell $body) impure inline;
50
+
51
+ (tuple, ()) ~pushAction<event>(tuple actions, int topic, cell $body) impure inline {
52
+ return (actions.tpush(_newAction<event>(topic, $body)), ());
53
+ }
54
+
55
+ int executeEvent(tuple action) impure inline {
56
+ ;; send event to event sink
57
+ sendNonTerminalAction(
58
+ SEND_MSG_NON_BOUNCEABLE,
59
+ 0,
60
+ _getEventSink(),
61
+ buildLayerzeroMessageBody(
62
+ 0,
63
+ BaseInterface::OP::EVENT,
64
+ action.cell_at(action::event::bodyIndex)
65
+ ),
66
+ PAID_EXTERNALLY
67
+ );
68
+ return true;
69
+ }
@@ -0,0 +1,52 @@
1
+ #include "utils.fc";
2
+ #include "../stdlib.fc";
3
+
4
+ const int action::payment::NAME = "payment"u;
5
+
6
+ ;; @info the address to pay
7
+ const int action::payment::toAddress = 1;
8
+ ;; @info the amount to pay, in nanotons
9
+ const int action::payment::amount = 2;
10
+ ;; @info the amount of value to provision from this contract's balance
11
+ const int action::payment::outflowNanos = 3;
12
+
13
+ ;; @non-terminal
14
+ tuple action::payment::New(int toAddress, int amount, int outflowNanos) inline {
15
+ return unsafeTuple([action::payment::NAME, toAddress, amount, outflowNanos]);
16
+ }
17
+
18
+ ;; returns true if equals
19
+ int action::payment::equals(tuple self, tuple other) {
20
+ return (
21
+ (self.int_at(0) == other.int_at(0)) ;; NAME
22
+ & (self.int_at(action::payment::toAddress) == other.int_at(action::payment::toAddress))
23
+ & (self.int_at(action::payment::amount) == other.int_at(action::payment::amount))
24
+ & (self.int_at(action::payment::outflowNanos) == other.int_at(action::payment::outflowNanos))
25
+ );
26
+ }
27
+
28
+ tuple _newAction<payment>(int toAddress, int amount, int outflowNanos) inline {
29
+ return action::payment::New(toAddress, amount, outflowNanos);
30
+ }
31
+
32
+ (tuple, ()) ~pushAction<payment>(tuple actions, int toAddress, int amount, int outflowNanos) inline {
33
+ if (outflowNanos > 0) {
34
+ actions = actions
35
+ .tset(ACTIONS_OUTFLOW, actions.int_at(ACTIONS_OUTFLOW) + outflowNanos);
36
+ }
37
+ return (actions.tpush(_newAction<payment>(toAddress, amount, outflowNanos)), ());
38
+ }
39
+
40
+ int executePayment(tuple action) impure inline {
41
+ sendNonTerminalAction(
42
+ SEND_MSG_NON_BOUNCEABLE,
43
+ get_forward_fee(BASECHAIN, 0, 1) +
44
+ action.int_at(action::payment::amount),
45
+ action.int_at(action::payment::toAddress),
46
+ empty_cell(),
47
+ NORMAL
48
+ );
49
+
50
+ ;; TODO-riley comment the purpose of this return value
51
+ return true;
52
+ }
@@ -0,0 +1,76 @@
1
+ #include "../stdlib.fc";
2
+ #include "utils.fc";
3
+
4
+ const int action::sendJettons::NAME = "sendJetton"u;
5
+
6
+ ;; @info the wallet of this contract's jetton wallet
7
+ const int action::sendJettons::walletAddress = 1;
8
+ ;; @info the address to pay
9
+ const int action::sendJettons::toAddress = 2;
10
+
11
+ ;; @info the amount to pay
12
+ const int action::sendJettons::amount = 3;
13
+
14
+ const int action::sendJettons::responseAddress = 4;
15
+
16
+ ;; Op codes:
17
+ ;; This because we cannot import it directly, this is effectively
18
+ ;; const op::transfer_notification = 0x7362d09c;
19
+ ;; const op::transfer = 0xf8a7ea5;
20
+ const int Jetton::OP::TRANSFER_NOTIFICATION = 0x7362d09c;
21
+ const int Jetton::OP::TRANSFER = 0xf8a7ea5;
22
+
23
+ ;; @terminal
24
+ tuple action::sendJettons::New(int walletAddress, int toAddress, int amount, int responseAddress) inline {
25
+ return unsafeTuple([action::sendJettons::NAME, walletAddress, toAddress, amount, responseAddress]);
26
+ }
27
+
28
+ ;; returns true if equals
29
+ int action::sendJettons::equals(tuple self, tuple other) {
30
+ return (
31
+ (self.int_at(0) == other.int_at(0)) ;; NAME
32
+ & (self.int_at(action::sendJettons::walletAddress) == other.int_at(action::sendJettons::walletAddress))
33
+ & (self.int_at(action::sendJettons::toAddress) == other.int_at(action::sendJettons::toAddress))
34
+ & (self.int_at(action::sendJettons::amount) == other.int_at(action::sendJettons::amount))
35
+ & (self.int_at(action::sendJettons::responseAddress) == other.int_at(action::sendJettons::responseAddress))
36
+ );
37
+ }
38
+
39
+ tuple _newAction<sendJettons>(int walletAddress, int toAddress, int amount, int responseAddress) inline {
40
+ return action::sendJettons::New(walletAddress, toAddress, amount, responseAddress);
41
+ }
42
+
43
+ (tuple, ()) ~pushAction<sendJettons>(
44
+ tuple actions,
45
+ int walletAddress,
46
+ int toAddress,
47
+ int amount,
48
+ int responseAddress
49
+ ) inline {
50
+ return (actions.tpush(_newAction<sendJettons>(walletAddress, toAddress, amount, responseAddress)), ());
51
+ }
52
+
53
+ cell buildJettonMessageBody(int toAddress, int amount, int responseAddress) inline {
54
+ return beginTonMessage(Jetton::OP::TRANSFER) ;; opcode, query_id
55
+ .store_coins(amount) ;; jetton amount
56
+ .store_slice(hashpartToBasechainAddressStd(toAddress)) ;; to address address
57
+ .store_slice(hashpartToBasechainAddressStd(responseAddress)) ;; response address
58
+ .store_maybe_ref(null()) ;; custom_payload
59
+ .store_coins(0) ;; forward_ton_amount
60
+ .store_maybe_ref(null()) ;; either_forward_payload is stored as a maybe_ref
61
+ .end_cell();
62
+ }
63
+
64
+ int executeSendJettons(tuple dispatchAction) {
65
+ sendTerminalAction(
66
+ dispatchAction.int_at(action::sendJettons::walletAddress),
67
+ buildJettonMessageBody(
68
+ dispatchAction.int_at(action::sendJettons::toAddress),
69
+ dispatchAction.int_at(action::sendJettons::amount),
70
+ dispatchAction.int_at(action::sendJettons::responseAddress)
71
+ ),
72
+ null(),
73
+ NORMAL
74
+ );
75
+ return false;
76
+ }
@@ -0,0 +1,49 @@
1
+ #include "../utils.fc";
2
+ #include "../stdlib.fc";
3
+ #include "../txnContext.fc";
4
+
5
+ ;; Small file for now, but a placeholder for generic actions utility functions
6
+
7
+ const int ACTIONS_OUTFLOW = 0;
8
+
9
+ tuple emptyActions() inline {
10
+ return unsafeTuple([0]);
11
+ }
12
+
13
+ ;;; ======================================================================================
14
+ ;; @info terminal actions are always sent using all non-reserved balance on the contract
15
+ () sendTerminalAction(int toAddress, cell messageBody, cell stateInit, int extraFlags) impure inline {
16
+ builder b = begin_cell()
17
+ .store_uint(SEND_MSG_BOUNCEABLE, 6)
18
+ .store_slice(hashpartToBasechainAddressStd(toAddress))
19
+ .store_coins(0);
20
+ b = stateInit.is_null()
21
+ ? b.store_uint(1, 107)
22
+ : b.store_uint(7, 108).store_ref(stateInit);
23
+ send_raw_message(b.store_ref(messageBody).end_cell(), CARRY_ALL_BALANCE | extraFlags);
24
+ }
25
+
26
+ ;; @info non-terminal actions must specify the amount of funds to send
27
+ () sendNonTerminalAction(int bounceable, int amount, int toAddress, cell messageBody, int extraFlags) impure inline {
28
+ cell msg = begin_cell()
29
+ .store_uint(bounceable, 6)
30
+ .store_slice(hashpartToBasechainAddressStd(toAddress))
31
+ .store_coins(amount)
32
+ .store_uint(1, 107)
33
+ .store_ref(messageBody)
34
+ .end_cell();
35
+ send_raw_message(msg, extraFlags);
36
+ }
37
+ ;; @param donationNanos: the amount of TON that the sender intended to be
38
+ ;; withheld within our contract
39
+ ;; @info baseHandler::refund_addr is the last known "origin" of a message
40
+ ;; flow, and is used to refund the sender if the handler does not
41
+ ;; use all remaining value from the in_message
42
+ cell buildLayerzeroMessageBody(int donationNanos, int opcode, cell $md) inline {
43
+ cell ret = beginTonMessage(opcode)
44
+ .store_coins(donationNanos)
45
+ .store_slice(getOriginStd())
46
+ .store_ref($md)
47
+ .end_cell();
48
+ return ret;
49
+ }
@@ -0,0 +1,16 @@
1
+ #include "constants.fc";
2
+
3
+ const int BaseInterface::event::AUTHENTICATED = "AUTHENTICATED"u;
4
+ const int BaseInterface::event::INITIALIZED = "INITIALIZED"u;
5
+
6
+ const int BaseInterface::ERROR::notAuthenticated = "BaseInterface::ERROR::notAuthenticated"c & ERRORCODE_MASK;
7
+ const int BaseInterface::ERROR::onlyOwner = "BaseInterface::ERROR::onlyOwner"c & ERRORCODE_MASK;
8
+ const int BaseInterface::ERROR::notInitialized = "BaseInterface::ERROR::notInitialized"c & ERRORCODE_MASK;
9
+ const int BaseInterface::ERROR::alreadyInitialized = "BaseInterface::ERROR::alreadyInitialized"c & ERRORCODE_MASK;
10
+ const int BaseInterface::ERROR::invalidOpcode = "BaseInterface::ERROR::invalidOpcode"c & ERRORCODE_MASK;
11
+ const int BaseInterface::ERROR::eventEmitted = "BaseInterface::ERROR::eventEmitted"c & ERRORCODE_MASK;
12
+ const int BaseInterface::ERROR::invalidActionType = "BaseInterface::ERROR::invalidActionType"c & ERRORCODE_MASK;
13
+ const int BaseInterface::ERROR::invalidEventSource = "BaseInterface::ERROR::invalidEventSource"c & ERRORCODE_MASK;
14
+
15
+ const int BaseInterface::OP::INITIALIZE = "BaseInterface::OP::INITIALIZE"c;
16
+ const int BaseInterface::OP::EVENT = "BaseInterface::OP::EVENT"c;