@layerzerolabs/layerzero-v2-ton 3.0.59 → 3.0.60

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 (204) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/AllStorages.compiled.json +1 -1
  3. package/build/BaseContract.test.compiled.json +1 -1
  4. package/build/Channel.compiled.json +1 -1
  5. package/build/Channel.permissions.test.compiled.json +1 -1
  6. package/build/ChannelBurn.test.compiled.json +1 -1
  7. package/build/ChannelBurnDefaultConfig.test.compiled.json +1 -0
  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/ChannelNilifyDefaultConfig.test.compiled.json +1 -0
  15. package/build/ChannelReceive.test.compiled.json +1 -1
  16. package/build/ChannelReceiveCallback.test.compiled.json +1 -1
  17. package/build/ChannelReceiveView.test.compiled.json +1 -1
  18. package/build/ChannelSend.test.compiled.json +1 -1
  19. package/build/ChannelSerde.test.compiled.json +1 -1
  20. package/build/Classlib.test.compiled.json +1 -1
  21. package/build/ComputeDataSizeGas.test.compiled.json +1 -1
  22. package/build/Connection.compiled.json +1 -1
  23. package/build/Controller.assertions.test.compiled.json +1 -1
  24. package/build/Controller.compiled.json +1 -1
  25. package/build/Controller.permissions.test.compiled.json +1 -1
  26. package/build/Controller.test.compiled.json +1 -1
  27. package/build/Counter.compiled.json +1 -1
  28. package/build/Counter.permissions.test.compiled.json +1 -1
  29. package/build/Counter.setters.test.compiled.json +1 -1
  30. package/build/Counter.test.compiled.json +1 -1
  31. package/build/Dvn.compiled.json +1 -1
  32. package/build/Dvn.test.compiled.json +1 -1
  33. package/build/DvnFeeLibSerde.test.compiled.json +1 -1
  34. package/build/DvnPermissions.test.compiled.json +1 -1
  35. package/build/DvnSerde.test.compiled.json +1 -1
  36. package/build/Endpoint.permissions.test.compiled.json +1 -1
  37. package/build/Endpoint.test.compiled.json +1 -1
  38. package/build/EndpointSerde.test.compiled.json +1 -1
  39. package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
  40. package/build/Executor.compiled.json +1 -1
  41. package/build/Executor.test.compiled.json +1 -1
  42. package/build/ExecutorFeeLib.compiled.json +1 -1
  43. package/build/ExecutorFeeLibSerde.test.compiled.json +1 -1
  44. package/build/ExecutorPermissions.test.compiled.json +1 -1
  45. package/build/ExecutorSerde.test.compiled.json +1 -1
  46. package/build/LzClasses.test.compiled.json +1 -1
  47. package/build/LzClassesSerde.test.compiled.json +1 -1
  48. package/build/LzUtil.test.compiled.json +1 -1
  49. package/build/MsgData.test.compiled.json +1 -1
  50. package/build/MsgDataSerde.test.compiled.json +1 -1
  51. package/build/MsglibPacketCodec.test.compiled.json +1 -1
  52. package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -1
  53. package/build/PriceFeedCache.compiled.json +1 -1
  54. package/build/PriceFeedCache.test.compiled.json +1 -1
  55. package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
  56. package/build/PriceFeedCacheSerde.test.compiled.json +1 -1
  57. package/build/PriceFeedFeeLibArbitrum.test.compiled.json +1 -1
  58. package/build/PriceFeedFeeLibDefault.test.compiled.json +1 -1
  59. package/build/PriceFeedFeeLibOptimism.test.compiled.json +1 -1
  60. package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -1
  61. package/build/Proxy.compiled.json +1 -1
  62. package/build/Proxy.permissions.test.compiled.json +1 -1
  63. package/build/Proxy.test.compiled.json +1 -1
  64. package/build/SmlConnection.permissions.test.compiled.json +1 -1
  65. package/build/SmlConnection.test.compiled.json +1 -1
  66. package/build/SmlManager.permissions.test.compiled.json +1 -1
  67. package/build/SmlManager.test.compiled.json +1 -1
  68. package/build/TxnContext.test.compiled.json +1 -1
  69. package/build/Uln.compiled.json +1 -1
  70. package/build/Uln.test.compiled.json +1 -1
  71. package/build/UlnConnection.compiled.json +1 -1
  72. package/build/UlnConnection.test.compiled.json +1 -1
  73. package/build/UlnConnectionPermissions.test.compiled.json +1 -1
  74. package/build/UlnConnectionSerde.test.compiled.json +1 -1
  75. package/build/UlnManagement.test.compiled.json +1 -1
  76. package/build/UlnManager.compiled.json +1 -1
  77. package/build/UlnManager.test.compiled.json +1 -1
  78. package/build/UlnManagerPermissions.test.compiled.json +1 -1
  79. package/build/UlnManagerUtil.test.compiled.json +1 -1
  80. package/build/UlnMsgDataSerde.test.compiled.json +1 -1
  81. package/build/UlnPermissions.test.compiled.json +1 -1
  82. package/build/UlnReceiveConfig.test.compiled.json +1 -1
  83. package/build/UlnSend.test.compiled.json +1 -1
  84. package/build/UlnSendConfig.test.compiled.json +1 -1
  85. package/build/UlnSendWithArbDvnFeeLib.test.compiled.json +1 -1
  86. package/build/UlnSendWithArbExecFeeLib.test.compiled.json +1 -1
  87. package/build/UlnSendWithDefaultDvnFeeLib.test.compiled.json +1 -1
  88. package/build/UlnSendWithDefaultExecFeeLib.test.compiled.json +1 -1
  89. package/build/UlnSendWithOpDvnFeeLib.test.compiled.json +1 -1
  90. package/build/UlnSendWithOpExecFeeLib.test.compiled.json +1 -1
  91. package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
  92. package/build/UlnSerde.test.compiled.json +1 -1
  93. package/build/UlnUtil.test.compiled.json +1 -1
  94. package/build/WorkerCore.test.compiled.json +1 -1
  95. package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -1
  96. package/build/WorkerCoreSerde.test.compiled.json +1 -1
  97. package/build/badFeeLib1.test.compiled.json +1 -1
  98. package/build/badFeeLib10.test.compiled.json +1 -1
  99. package/build/badFeeLib11.test.compiled.json +1 -1
  100. package/build/badFeeLib12.test.compiled.json +1 -1
  101. package/build/badFeeLib2.test.compiled.json +1 -1
  102. package/build/badFeeLib3.test.compiled.json +1 -1
  103. package/build/badFeeLib4.test.compiled.json +1 -1
  104. package/build/badFeeLib5.test.compiled.json +1 -1
  105. package/build/badFeeLib6.test.compiled.json +1 -1
  106. package/build/badFeeLib7.test.compiled.json +1 -1
  107. package/build/badFeeLib8.test.compiled.json +1 -1
  108. package/build/badFeeLib9.test.compiled.json +1 -1
  109. package/package.json +1 -1
  110. package/src/classes/lz/Config.fc +1 -1
  111. package/src/classes/lz/EpConfig.fc +2 -2
  112. package/src/classes/lz/MsglibInfo.fc +1 -1
  113. package/src/classes/lz/Packet.fc +3 -3
  114. package/src/classes/lz/SendEpConfig.fc +1 -1
  115. package/src/classes/msgdata/AddMsglib.fc +1 -1
  116. package/src/classes/msgdata/Bool.fc +1 -1
  117. package/src/classes/msgdata/ChannelNonceInfo.fc +1 -1
  118. package/src/classes/msgdata/CoinsAmount.fc +1 -1
  119. package/src/classes/msgdata/CounterIncrement.fc +1 -1
  120. package/src/classes/msgdata/Deploy.fc +1 -1
  121. package/src/classes/msgdata/GetMsglibCallback.fc +1 -1
  122. package/src/classes/msgdata/InitEndpoint.fc +1 -1
  123. package/src/classes/msgdata/LzReceivePrepare.fc +1 -1
  124. package/src/classes/msgdata/LzReceiveStatus.fc +1 -1
  125. package/src/classes/msgdata/LzSend.fc +1 -1
  126. package/src/classes/msgdata/MdEid.fc +1 -1
  127. package/src/classes/msgdata/MdObj.fc +1 -1
  128. package/src/classes/msgdata/MessagingReceipt.fc +1 -1
  129. package/src/classes/msgdata/MsglibSendCallback.fc +3 -3
  130. package/src/classes/msgdata/Nonce.fc +1 -1
  131. package/src/classes/msgdata/OptionsExtended.fc +1 -1
  132. package/src/classes/msgdata/OptionsV1.fc +1 -1
  133. package/src/classes/msgdata/OptionsV2.fc +1 -1
  134. package/src/classes/msgdata/PacketId.fc +1 -1
  135. package/src/classes/msgdata/SetAddress.fc +1 -1
  136. package/src/classes/msgdata/SetEpConfig.fc +1 -1
  137. package/src/classes/msgdata/SetPeer.fc +1 -1
  138. package/src/funC++/actions/RawCall.fc +4 -4
  139. package/src/funC++/actions/call.fc +4 -4
  140. package/src/funC++/actions/deploy.fc +4 -4
  141. package/src/funC++/actions/event.fc +2 -2
  142. package/src/funC++/actions/payment.fc +4 -4
  143. package/src/funC++/actions/sendJettons.fc +6 -6
  144. package/src/funC++/actions/utils.fc +1 -1
  145. package/src/funC++/classlib.fc +30 -30
  146. package/src/funC++/dataStructures/AddressList.fc +1 -1
  147. package/src/funC++/dataStructures/DeterministicInsertionCircularQueue.fc +6 -6
  148. package/src/funC++/stringlib.fc +7 -7
  149. package/src/funC++/txnContext.fc +10 -10
  150. package/src/funC++/utils.fc +5 -5
  151. package/src/protocol/channel/handler.fc +3 -3
  152. package/src/protocol/channel/storage.fc +1 -1
  153. package/src/protocol/controller/handler.fc +2 -0
  154. package/src/protocol/controller/storage.fc +1 -1
  155. package/src/protocol/core/baseStorage.fc +1 -1
  156. package/src/protocol/endpoint/handler.fc +4 -4
  157. package/src/protocol/msglibs/BytesDecoder.fc +5 -5
  158. package/src/protocol/msglibs/BytesEncoder.fc +7 -7
  159. package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +1 -1
  160. package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +1 -1
  161. package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +1 -1
  162. package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
  163. package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +2 -2
  164. package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnManager.fc +1 -1
  165. package/src/protocol/msglibs/ultralightnode/msgdata/RentRefill.fc +1 -1
  166. package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +1 -1
  167. package/src/protocol/msglibs/ultralightnode/msgdata/TreasuryFeeBps.fc +1 -1
  168. package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +1 -1
  169. package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +1 -1
  170. package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +1 -1
  171. package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +1 -1
  172. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +1 -1
  173. package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +1 -1
  174. package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +1 -1
  175. package/src/protocol/msglibs/ultralightnode/uln/handler.fc +2 -3
  176. package/src/protocol/msglibs/ultralightnode/uln/storage.fc +1 -1
  177. package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +14 -5
  178. package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +1 -1
  179. package/src/protocol/msglibs/ultralightnode/ulnManager/storage.fc +1 -1
  180. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +1 -1
  181. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +1 -1
  182. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +4 -6
  183. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +1 -1
  184. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/maliciousFeeLib/handler.fc +1 -1
  185. package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +1 -1
  186. package/src/workers/core/abstract/workerHandler.fc +6 -5
  187. package/src/workers/core/workerCoreStorage.fc +1 -1
  188. package/src/workers/dvn/handler.fc +3 -3
  189. package/src/workers/dvn/storage.fc +1 -1
  190. package/src/workers/executor/handler.fc +16 -4
  191. package/src/workers/executor/interface.fc +2 -0
  192. package/src/workers/executor/main.fc +4 -0
  193. package/src/workers/executor/storage.fc +1 -1
  194. package/src/workers/msgdata/ClaimTon.fc +1 -1
  195. package/src/workers/msgdata/ExecuteParams.fc +7 -7
  196. package/src/workers/msgdata/NativeDrop.fc +1 -1
  197. package/src/workers/msgdata/SetDict.fc +1 -1
  198. package/src/workers/msgdata/SetQuorum.fc +1 -1
  199. package/src/workers/msgdata/SignedRequest.fc +1 -1
  200. package/src/workers/priceFeedCache/storage.fc +1 -1
  201. package/src/workers/proxy/handler.fc +2 -12
  202. package/src/workers/proxy/storage.fc +1 -1
  203. package/tests/baseContractTest.fc +10 -0
  204. package/src/classes/lz/Worker.fc +0 -32
@@ -30,7 +30,7 @@ const int UlnConnection::hashLookups = 8; ;; map nonce -> map dvnAddress -> {has
30
30
  const int UlnConnection::commitPOOO = 9;
31
31
 
32
32
  ;; @owner ulnManager
33
- cell UlnConnection::New(int owner, cell $path, int ulnAddress) method_id {
33
+ cell UlnConnection::New(int owner, cell $path, int ulnAddress) impure method_id {
34
34
  return cl::declare(
35
35
  UlnConnection::NAME,
36
36
  unsafeTuple([
@@ -25,7 +25,7 @@ cell UlnManager::New(
25
25
  cell connectionCode,
26
26
  int controllerAddress,
27
27
  int eid
28
- ) method_id {
28
+ ) impure inline method_id {
29
29
  return cl::declare(
30
30
  UlnManager::NAME,
31
31
  unsafeTuple([
@@ -53,7 +53,7 @@ int _getCallDataSize(cell $myStorage) impure inline_ref {
53
53
  return DvnFeelib::EXECUTE_FIXED_BYTES + DvnFeelib::VERIFY_BYTES_ULN + totalSignatureBytes + 32;
54
54
  }
55
55
 
56
- tuple ulnWorker::quote(tuple inputs) method_id {
56
+ tuple ulnWorker::quote(tuple inputs) impure method_id {
57
57
  cell $myStorage = inputs.cell_at(0);
58
58
  cell $priceFeedInfo = inputs.cell_at(1);
59
59
  ;; cell $path = inputs.cell_at(2);
@@ -15,7 +15,7 @@ cell DvnFeelib::New(
15
15
  int remoteGas,
16
16
  int multiplierBps,
17
17
  int floorMarginUSD
18
- ) method_id {
18
+ ) impure inline method_id {
19
19
  return cl::declare(
20
20
  DvnFeelib::NAME,
21
21
  unsafeTuple([
@@ -16,7 +16,7 @@ int isV1Eid(int eid) impure inline {
16
16
  return (eid < 30000);
17
17
  }
18
18
 
19
- (int, int) _decodeOption(int lzReceiveBaseGas, int lzComposeBaseGas, cell $options, cell $path) impure inline {
19
+ (int, int) _decodeOption(int lzComposeBaseGas, cell $options, cell $path) impure inline {
20
20
  int totalGas = 0;
21
21
  int totalDstAmount = 0;
22
22
 
@@ -35,7 +35,7 @@ int isV1Eid(int eid) impure inline {
35
35
  (lzReceiveValue > 0) & isV1Eid($path.lz::Path::getDstEid())
36
36
  );
37
37
 
38
- totalGas += lzReceiveBaseGas + lzReceiveGas;
38
+ totalGas += lzReceiveGas;
39
39
 
40
40
  totalDstAmount += lzReceiveValue + nativeDropAmount;
41
41
 
@@ -53,7 +53,7 @@ int isV1Eid(int eid) impure inline {
53
53
  (lzComposeGas == 0) & (lzComposeValue > 0)
54
54
  );
55
55
 
56
- totalGas += lzReceiveBaseGas + lzReceiveGas;
56
+ totalGas += lzReceiveGas;
57
57
 
58
58
  totalDstAmount += lzReceiveValue + nativeDropAmount;
59
59
 
@@ -83,7 +83,6 @@ int isV1Eid(int eid) impure inline {
83
83
 
84
84
  ifnot ($extraOptions.cl::isNullObject()) {
85
85
  (int _totalGas, int _totalDstAmount) = _decodeOption(
86
- lzReceiveBaseGas,
87
86
  lzComposeBaseGas,
88
87
  $extraOptions,
89
88
  $path
@@ -95,7 +94,6 @@ int isV1Eid(int eid) impure inline {
95
94
 
96
95
  ifnot ($enforcedOptions.cl::isNullObject()) {
97
96
  (int _totalGas, int _totalDstAmount) = _decodeOption(
98
- lzReceiveBaseGas,
99
97
  lzComposeBaseGas,
100
98
  $enforcedOptions,
101
99
  $path
@@ -104,7 +102,7 @@ int isV1Eid(int eid) impure inline {
104
102
  totalDstAmount += _totalDstAmount;
105
103
  }
106
104
 
107
- return (totalGas, totalDstAmount);
105
+ return (totalGas + lzReceiveBaseGas, totalDstAmount);
108
106
  }
109
107
 
110
108
  ;; current gas consumed: 16276
@@ -15,7 +15,7 @@ cell ExecutorFeelib::New(
15
15
  int floorMarginUSD,
16
16
  int nativeCap,
17
17
  int lzComposeBaseGas
18
- ) method_id {
18
+ ) impure inline method_id {
19
19
  return cl::declare(
20
20
  ExecutorFeelib::NAME,
21
21
  unsafeTuple([
@@ -1,6 +1,6 @@
1
1
  #include "../../../../../funC++/utils.fc";
2
2
 
3
- tuple ulnWorker::quote(tuple inputs) method_id {
3
+ tuple ulnWorker::quote(tuple inputs) impure method_id {
4
4
  int x = 0;
5
5
  while (true) {
6
6
  x += 1;
@@ -20,7 +20,7 @@ cell PriceFeedFeelib::New(
20
20
  int nativePriceUsd,
21
21
  cell arbitrumExtension,
22
22
  cell optimismExtension
23
- ) method_id {
23
+ ) impure method_id {
24
24
  return cl::declare(
25
25
  PriceFeedFeelib::NAME,
26
26
  unsafeTuple([
@@ -104,14 +104,15 @@ tuple _claimTon(tuple actions, cell $claimTon) impure {
104
104
  }
105
105
 
106
106
  tuple _claimTonFromProxy(tuple actions, cell $claimTon) impure {
107
- actions~pushAction<call>(
108
- getProxyAddress(),
109
- Worker::OP::CLAIM_TON,
107
+ ;; event needs to be emitted before the call because call is a terminal action
108
+ actions~pushAction<event>(
109
+ Worker::event::CLAIMED_TON_FROM_PROXY,
110
110
  $claimTon
111
111
  );
112
112
 
113
- actions~pushAction<event>(
114
- Worker::event::CLAIMED_TON_FROM_PROXY,
113
+ actions~pushAction<call>(
114
+ getProxyAddress(),
115
+ Worker::OP::CLAIM_TON,
115
116
  $claimTon
116
117
  );
117
118
 
@@ -20,7 +20,7 @@ const int WorkerCoreStorage::version = 2;
20
20
  ;; a context-free way to refer to the two ends of the channel.
21
21
  ;; The direction is inferred by the context of the contract (send vs receive).
22
22
  ;; The srcOApp is the 256-bit hashpart of a standard address.
23
- cell WorkerCoreStorage::New(cell admins, int proxy, int version) inline method_id {
23
+ cell WorkerCoreStorage::New(cell admins, int proxy, int version) impure inline method_id {
24
24
  return cl::declare(
25
25
  WorkerCoreStorage::NAME,
26
26
  unsafeTuple([
@@ -46,7 +46,7 @@
46
46
  }
47
47
 
48
48
  ;;; Encodes [uint256 x1, uint256 x2] into a cell which represents the 64-byte public key
49
- cell encodePublicKey(int x1, int x2) inline method_id {
49
+ cell encodePublicKey(int x1, int x2) impure inline method_id {
50
50
  return begin_cell()
51
51
  .store_uint256(x1)
52
52
  .store_uint256(x2)
@@ -385,8 +385,8 @@ tuple setAdmins(cell $addressList) impure inline {
385
385
  return _setAdmins(emptyActions(), $addressList);
386
386
  }
387
387
 
388
- tuple claimTon(cell $coinsAmount) impure inline {
389
- return _claimTon(emptyActions(), $coinsAmount);
388
+ tuple claimTon(cell $claimTon) impure inline {
389
+ return _claimTon(emptyActions(), $claimTon);
390
390
  }
391
391
 
392
392
  tuple claimTonFromProxy(cell $claimTon) impure inline {
@@ -12,7 +12,7 @@ const int Dvn::setVerifiersNonce = 4;
12
12
  const int Dvn::setAdminsByQuorumNonce = 5;
13
13
 
14
14
  ;; @owner manager
15
- cell Dvn::New(cell admins, int version, int quorum, cell verifiers) method_id {
15
+ cell Dvn::New(cell admins, int version, int quorum, cell verifiers) impure inline method_id {
16
16
  return cl::declare(
17
17
  Dvn::NAME,
18
18
  unsafeTuple([
@@ -65,13 +65,25 @@ tuple _executorNativeDrop(tuple actions, cell $mdNativeDrop) impure inline {
65
65
  tuple _executorLzReceivePrepare(tuple actions, cell $executeParams) impure inline {
66
66
  int opcode = $executeParams.md::ExecuteParams::getOpcode();
67
67
  throw_unless(
68
- Worker::ERROR::invalidSignedOpcode,
68
+ Worker::ERROR::invalidOpcode,
69
69
  opcode == Channel::OP::LZ_RECEIVE_PREPARE
70
70
  );
71
71
 
72
72
  return _callContract(actions, $executeParams);
73
73
  }
74
74
 
75
+ tuple executorCommitPacket(cell $executeParams) impure inline {
76
+ tuple actions = emptyActions();
77
+ int opcode = $executeParams.md::ExecuteParams::getOpcode();
78
+
79
+ throw_unless(
80
+ Worker::ERROR::invalidOpcode,
81
+ opcode == Uln::OP::ULN_COMMIT_PACKET
82
+ );
83
+
84
+ return _callContract(actions, $executeParams);
85
+ }
86
+
75
87
  tuple executorNativeDrop(cell $mdNativeDrop) impure inline {
76
88
  return _executorNativeDrop(emptyActions(), $mdNativeDrop);
77
89
  }
@@ -84,13 +96,13 @@ tuple executorLzReceivePrepare(cell $executeParams) impure inline {
84
96
  ;; obj: $executeParams for lzReceivePrepare
85
97
  tuple executorNativeDropAndLzReceivePrepare(cell $mdObj) impure inline {
86
98
  (
87
- cell $lzReceivePrepareMd,
99
+ cell $executeParams,
88
100
  cell $nativeDropMd
89
101
  ) = $mdObj.md::MdObj::deserialize();
90
102
 
91
103
  return emptyActions()
92
104
  ._executorNativeDrop($nativeDropMd)
93
- ._executorLzReceivePrepare($lzReceivePrepareMd);
105
+ ._executorLzReceivePrepare($executeParams);
94
106
  }
95
107
 
96
108
  tuple executorLzReceiveAlert(cell $executeParams) impure inline {
@@ -98,7 +110,7 @@ tuple executorLzReceiveAlert(cell $executeParams) impure inline {
98
110
 
99
111
  int opcode = $executeParams.md::ExecuteParams::getOpcode();
100
112
  throw_unless(
101
- Worker::ERROR::invalidSignedOpcode,
113
+ Worker::ERROR::invalidOpcode,
102
114
  opcode == Channel::OP::EMIT_LZ_RECEIVE_ALERT
103
115
  );
104
116
 
@@ -6,6 +6,8 @@ const int Executor::OP::NATIVE_DROP = "Executor::OP::NATIVE_DROP"c;
6
6
 
7
7
  const int Executor::OP::LZ_RECEIVE_PREPARE = "Executor::OP::LZ_RECEIVE_PREPARE"c;
8
8
 
9
+ const int Executor::OP::COMMIT_PACKET = "Executor::OP::COMMIT_PACKET"c;
10
+
9
11
  ;; Native drop a batch of native tokens and execute a packet
10
12
  const int Executor::OP::NATIVE_DROP_AND_LZ_RECEIVE_PREPARE = "Executor::OP::NATIVE_DROP_AND_LZ_RECEIVE_PREPARE"c;
11
13
 
@@ -8,6 +8,8 @@ tuple _executeOpcode(int op, cell $md) impure inline {
8
8
  return executorNativeDrop($md);
9
9
  } elseif (op == Executor::OP::NATIVE_DROP_AND_LZ_RECEIVE_PREPARE) {
10
10
  return executorNativeDropAndLzReceivePrepare($md);
11
+ } elseif (op == Executor::OP::LZ_RECEIVE_PREPARE) {
12
+ return executorLzReceivePrepare($md);
11
13
  } elseif (op == Executor::OP::LZ_RECEIVE_ALERT) {
12
14
  return executorLzReceiveAlert($md);
13
15
  } elseif (op == Worker::OP::SET_ADMINS) {
@@ -24,6 +26,8 @@ tuple _executeOpcode(int op, cell $md) impure inline {
24
26
  return emptyActions();
25
27
  } elseif (op == Executor::OP::SET_NATIVE_DROP_TOTAL_CAP) {
26
28
  return setNativeDropTotalCap($md);
29
+ } elseif (op == Executor::OP::COMMIT_PACKET) {
30
+ return executorCommitPacket($md);
27
31
  }
28
32
  throw(BaseInterface::ERROR::invalidOpcode);
29
33
  return empty_tuple();
@@ -8,7 +8,7 @@ const int Executor::workerCoreStorage = 0; ;; = WORKER_CORE_STORAGE_IDX
8
8
  const int Executor::nativeDropTotalCap = 1;
9
9
 
10
10
  ;; @owner manager
11
- cell Executor::New(cell admins, int version, int nativeDropTotalCap) method_id {
11
+ cell Executor::New(cell admins, int version, int nativeDropTotalCap) impure inline method_id {
12
12
  return cl::declare(
13
13
  Executor::NAME,
14
14
  unsafeTuple([
@@ -7,7 +7,7 @@ const int md::ClaimTon::NAME = "claimTon"u;
7
7
  const int md::ClaimTon::amount = 0;
8
8
  const int md::ClaimTon::target = 1;
9
9
 
10
- cell md::ClaimTon::New(int amount, int target) inline method_id {
10
+ cell md::ClaimTon::New(int amount, int target) impure inline method_id {
11
11
  return cl::declare(
12
12
  md::ClaimTon::NAME,
13
13
  unsafeTuple([
@@ -23,20 +23,20 @@ cell md::ExecuteParams::New(
23
23
  int expiration,
24
24
  int opcode,
25
25
  int forwardingAddress
26
- ) method_id {
26
+ ) impure inline method_id {
27
27
  return cl::declare(
28
28
  md::ExecuteParams::NAME,
29
29
  unsafeTuple([
30
- [cl::t::address, target], ;; md::ExecuteParams::target
31
- [cl::t::objRef, callData], ;; md::ExecuteParams::callData
32
- [cl::t::uint64, expiration], ;; md::ExecuteParams::expiration
33
- [cl::t::uint32, opcode], ;; md::ExecuteParams::opcode
30
+ [cl::t::address, target], ;; md::ExecuteParams::target
31
+ [cl::t::objRef, callData], ;; md::ExecuteParams::callData
32
+ [cl::t::uint64, expiration], ;; md::ExecuteParams::expiration
33
+ [cl::t::uint32, opcode], ;; md::ExecuteParams::opcode
34
34
  [cl::t::address, forwardingAddress] ;; md::ExecuteParams::forwardingAddress
35
35
  ])
36
36
  );
37
37
  }
38
38
 
39
- ;; ========================== Object Builders=====================================
39
+ ;; ========================== Object Builders===========================w==========
40
40
 
41
41
  const int md::ExecuteParams::_headerInfoBits = _BASIC_HEADER_WIDTH + (_FIELD_INFO_WIDTH * 5);
42
42
  const int md::ExecuteParams::_headerFillerBits = _HEADER_WIDTH - md::ExecuteParams::_headerInfoBits;
@@ -47,7 +47,7 @@ cell md::ExecuteParams::build(
47
47
  int expiration,
48
48
  int opcode,
49
49
  int forwardingAddress
50
- ) inline {
50
+ ) impure inline {
51
51
  return begin_cell()
52
52
  .store_uint(593196021158614130743421175296147950525415477349115, md::ExecuteParams::_headerInfoBits)
53
53
  .store_ones(md::ExecuteParams::_headerFillerBits)
@@ -8,7 +8,7 @@ const int md::NativeDrop::payees = 0;
8
8
  const int md::NativeDrop::packetId = 1;
9
9
  const int md::NativeDrop::msglib = 2;
10
10
 
11
- cell md::NativeDrop::New(cell payees, cell $packetId, int msglib) inline method_id {
11
+ cell md::NativeDrop::New(cell payees, cell $packetId, int msglib) impure inline method_id {
12
12
  return cl::declare(
13
13
  md::NativeDrop::NAME,
14
14
  unsafeTuple([
@@ -9,7 +9,7 @@ const int md::SetDict::opcode = 1;
9
9
  const int md::SetDict::dict = 2;
10
10
  const int md::SetDict::target = 3;
11
11
 
12
- cell md::SetDict::New(int nonce, int opcode, cell _dict, int target) inline method_id {
12
+ cell md::SetDict::New(int nonce, int opcode, cell _dict, int target) impure inline method_id {
13
13
  return cl::declare(
14
14
  md::SetDict::NAME,
15
15
  unsafeTuple([
@@ -9,7 +9,7 @@ const int md::SetQuorum::opcode = 1;
9
9
  const int md::SetQuorum::quorum = 2;
10
10
  const int md::SetQuorum::target = 3;
11
11
 
12
- cell md::SetQuorum::New(int nonce, int opcode, int quorum, int target) inline method_id {
12
+ cell md::SetQuorum::New(int nonce, int opcode, int quorum, int target) impure inline method_id {
13
13
  return cl::declare(
14
14
  md::SetQuorum::NAME,
15
15
  unsafeTuple([
@@ -7,7 +7,7 @@ const int md::SignedRequest::NAME = "sgndReq"u;
7
7
  const int md::SignedRequest::request = 0;
8
8
  const int md::SignedRequest::signatures = 1;
9
9
 
10
- cell md::SignedRequest::New(cell $request, cell signatures) method_id {
10
+ cell md::SignedRequest::New(cell $request, cell signatures) impure inline method_id {
11
11
  return cl::declare(
12
12
  md::SignedRequest::NAME,
13
13
  unsafeTuple([
@@ -13,7 +13,7 @@ const int PriceFeedCache::priceFeedFeeLibStorage = 1;
13
13
  const int PriceFeedCache::dstEid = 2; ;; sharding key, unused in actual logic
14
14
 
15
15
  ;; @owner manager
16
- cell PriceFeedCache::New(cell admins, int version, cell $priceFeedFeeLib, int dstEid) method_id {
16
+ cell PriceFeedCache::New(cell admins, int version, cell $priceFeedFeeLib, int dstEid) impure inline method_id {
17
17
  return cl::declare(
18
18
  PriceFeedCache::NAME,
19
19
  unsafeTuple([
@@ -11,22 +11,12 @@
11
11
 
12
12
  ;;; ==========================PERMISSION FUNCTIONS=================================
13
13
 
14
- () assertLatestAdmin() impure inline {
15
- throw_unless(
16
- Proxy::ERROR::NOT_LATEST_ADMIN,
17
- getCaller() == getLatestAdmin()
18
- );
19
- }
20
-
21
14
  ;; this is special in proxy, only the people in the address book can call 'callContract'
22
15
  () _checkPermissions(int op, cell $md) impure inline {
23
16
  if (
24
- (op == Proxy::OP::CALL_CONTRACT)
25
- | (op == Proxy::OP::EMIT_EVENT)
26
- ) {
27
- return assertLatestAdmin();
28
- } elseif (
29
17
  (op == Worker::OP::SET_ADMINS)
18
+ | (op == Proxy::OP::CALL_CONTRACT)
19
+ | (op == Proxy::OP::EMIT_EVENT)
30
20
  | (op == Worker::OP::CLAIM_TON)
31
21
  | (op == Proxy::OP::TOGGLE_CALLBACK)
32
22
  ) {
@@ -10,7 +10,7 @@ const int Proxy::workerCoreStorage = 0; ;; = WORKER_CORE_STORAGE_IDX
10
10
  const int Proxy::callbackEnabled = 1;
11
11
 
12
12
  ;; @owner manager
13
- cell Proxy::New(cell admins, int version) method_id {
13
+ cell Proxy::New(cell admins, int version) impure inline method_id {
14
14
  return cl::declare(
15
15
  Proxy::NAME,
16
16
  unsafeTuple([
@@ -70,6 +70,7 @@ cell baseTest::prepare(tuple args) impure {
70
70
 
71
71
  ;; Check that each action matches the expected action
72
72
  int index = 1;
73
+ int terminalActionEncountered = false;
73
74
  tuple terminalIndices = empty_tuple();
74
75
  while (index < numActions) {
75
76
  tuple actualAction = actions.tuple_at(index);
@@ -79,13 +80,16 @@ cell baseTest::prepare(tuple args) impure {
79
80
  }
80
81
  int actionType = actualAction.int_at(0);
81
82
  int equal = false;
83
+ int isCurrentActionTerminal = false;
82
84
 
83
85
  if (actionType == action::deploy::NAME) {
84
86
  terminalIndices = terminalIndices.tpush(index);
85
87
  equal = action::deploy::equals(actualAction, expectedAction);
88
+ isCurrentActionTerminal = true;
86
89
  } elseif (actionType == action::call::NAME) {
87
90
  terminalIndices = terminalIndices.tpush(index);
88
91
  equal = action::call::equals(actualAction, expectedAction);
92
+ isCurrentActionTerminal = true;
89
93
  } elseif (actionType == action::dispatch::NAME) {
90
94
  equal = action::dispatch::equals(actualAction, expectedAction);
91
95
  } elseif (actionType == action::payment::NAME) {
@@ -94,13 +98,19 @@ cell baseTest::prepare(tuple args) impure {
94
98
  equal = action::event::equals(actualAction, expectedAction);
95
99
  } elseif (actionType == action::sendJettons::NAME) {
96
100
  equal = action::sendJettons::equals(actualAction, expectedAction);
101
+ isCurrentActionTerminal = true;
97
102
  } elseif (actionType == action::rawCall::NAME) {
98
103
  equal = action::rawCall::equals(actualAction, expectedAction);
104
+ isCurrentActionTerminal = true;
99
105
  }
100
106
  ifnot (equal) {
101
107
  test::throwError("action incorrect: ".str::concatInt(index));
102
108
  }
109
+ if (terminalActionEncountered & (~ isCurrentActionTerminal)) {
110
+ test::throwError("terminal before non-terminal: ".str::concatInt(index));
111
+ }
103
112
  index += 1;
113
+ terminalActionEncountered = terminalActionEncountered | isCurrentActionTerminal;
104
114
  }
105
115
  if (terminalIndices.tlen() > 1) {
106
116
  test::throwError("Multiple terminal actions");
@@ -1,32 +0,0 @@
1
- #include "../../funC++/classlib.fc";
2
-
3
- ;; required storage name
4
- const int lz::Worker::NAME = "Worker"u;
5
-
6
- ;; field names
7
- const int lz::Worker::owner = 0; ;; key
8
- ;; allowlist of workers who are allowed to view my storage
9
- const int lz::Worker::viewAllowlist = 1;
10
- ;; list of workers whose storage I depend on
11
- const int lz::Worker::viewDependencies = 2;
12
- const int lz::Worker::bytecodeLibrary = 3; ;; library cell
13
- const int lz::Worker::storage = 4;
14
-
15
- ;; In all blockchains with atomic cross-contract call, we can use src/dst/sender/receiver
16
- ;; because the send channel doesn't exist (it's just a nonce).
17
- ;; In TON, we need both send/receive channels, so we use local/remote to provide
18
- ;; a context-free way to refer to the two ends of the channel.
19
- ;; The direction is inferred by the context of the contract (send vs receive).
20
- ;; The srcOApp is the 256-bit hashpart of a standard address.
21
- cell lz::Worker::New(int owner, int priceFeedAddress, cell bytecode, cell $storage) inline method_id {
22
- return cl::declare(
23
- lz::Worker::NAME,
24
- unsafeTuple([
25
- [cl::t::address, owner], ;; lz::Worker::owner
26
- [cl::t::dict256, cl::dict256::New()], ;; lz::Worker::viewAllowlist
27
- [cl::t::dict256, cl::dict256::New()], ;; lz::Worker::viewDependencies
28
- [cl::t::cellRef, bytecode], ;; lz::Worker::bytecodeLibrary
29
- [cl::t::objRef, $storage] ;; lz::Worker::storage
30
- ])
31
- );
32
- }