@layerzerolabs/protocol-stellar-v2 0.2.19 → 0.2.21

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 (249) hide show
  1. package/.turbo/turbo-build.log +795 -791
  2. package/.turbo/turbo-lint.log +325 -155
  3. package/.turbo/turbo-test.log +1398 -1277
  4. package/Cargo.lock +122 -111
  5. package/Cargo.toml +32 -16
  6. package/contracts/common-macros/Cargo.toml +7 -7
  7. package/contracts/common-macros/src/auth.rs +18 -37
  8. package/contracts/common-macros/src/contract_ttl.rs +18 -7
  9. package/contracts/common-macros/src/lib.rs +31 -14
  10. package/contracts/common-macros/src/lz_contract.rs +38 -7
  11. package/contracts/common-macros/src/storage.rs +251 -292
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +1 -1
  13. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +6 -12
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +12 -17
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap +2 -1
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +2 -7
  17. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +20 -14
  18. package/contracts/common-macros/src/tests/upgradeable.rs +26 -4
  19. package/contracts/common-macros/src/ttl_configurable.rs +2 -10
  20. package/contracts/common-macros/src/ttl_extendable.rs +2 -10
  21. package/contracts/common-macros/src/upgradeable.rs +61 -26
  22. package/contracts/common-macros/src/utils.rs +0 -9
  23. package/contracts/endpoint-v2/src/lib.rs +3 -2
  24. package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +2 -2
  25. package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +3 -3
  26. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +4 -4
  27. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +17 -5
  28. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  29. package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +2 -2
  30. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +2 -2
  31. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +6 -6
  32. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +67 -37
  33. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +5 -5
  34. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +44 -54
  35. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +7 -7
  36. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +8 -8
  37. package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +3 -3
  38. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +4 -4
  39. package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +3 -3
  40. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +2 -2
  41. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +3 -3
  42. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +2 -2
  43. package/contracts/layerzero-views/Cargo.toml +0 -1
  44. package/contracts/layerzero-views/src/layerzero_view.rs +1 -13
  45. package/contracts/macro-integration-tests/Cargo.toml +5 -15
  46. package/contracts/macro-integration-tests/tests/runtime/oapp/mod.rs +48 -0
  47. package/contracts/macro-integration-tests/tests/runtime/oapp/oapp_core.rs +170 -0
  48. package/contracts/macro-integration-tests/tests/runtime/oapp/options_type3.rs +154 -0
  49. package/contracts/macro-integration-tests/tests/runtime/oapp/receiver.rs +338 -0
  50. package/contracts/macro-integration-tests/tests/runtime/oapp/sender.rs +435 -0
  51. package/contracts/macro-integration-tests/tests/runtime.rs +1 -0
  52. package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.rs +8 -0
  53. package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.stderr +5 -0
  54. package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.rs +8 -0
  55. package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.stderr +71 -0
  56. package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.rs +10 -0
  57. package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.stderr +5 -0
  58. package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.rs +8 -0
  59. package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.stderr +5 -0
  60. package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.rs +8 -0
  61. package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.stderr +5 -0
  62. package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_all.rs +38 -0
  63. package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_single_trait.rs +96 -0
  64. package/contracts/macro-integration-tests/tests/ui/oapp/pass/minimal_contract.rs +64 -0
  65. package/contracts/macro-integration-tests/tests/ui/oapp/pass/struct_with_fields.rs +46 -0
  66. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +8 -0
  67. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +1 -1
  68. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +1 -1
  69. package/contracts/macro-integration-tests/tests/ui_oapp.rs +11 -0
  70. package/contracts/message-libs/message-lib-common/Cargo.toml +0 -1
  71. package/contracts/message-libs/message-lib-common/src/errors.rs +1 -1
  72. package/contracts/message-libs/treasury/Cargo.toml +0 -2
  73. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +2 -2
  74. package/contracts/message-libs/uln-302/src/events.rs +4 -0
  75. package/contracts/message-libs/uln-302/src/send_uln.rs +22 -6
  76. package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +2 -2
  77. package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +2 -2
  78. package/contracts/message-libs/uln-302/src/tests/receive_uln302/verify.rs +2 -2
  79. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_executor_config.rs +2 -2
  80. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +2 -2
  81. package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +21 -67
  82. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
  83. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +2 -2
  84. package/contracts/oapps/counter/Cargo.toml +5 -6
  85. package/contracts/oapps/counter/integration_tests/setup_uln.rs +1 -1
  86. package/contracts/oapps/counter/integration_tests/utils.rs +19 -12
  87. package/contracts/oapps/oapp/src/errors.rs +1 -1
  88. package/contracts/oapps/oapp/src/interfaces/mod.rs +3 -0
  89. package/contracts/oapps/oapp/src/interfaces/oapp_msg_inspector.rs +47 -0
  90. package/contracts/oapps/oapp/src/lib.rs +1 -0
  91. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +4 -4
  92. package/contracts/oapps/oapp/src/oapp_core.rs +5 -5
  93. package/contracts/oapps/oapp/src/oapp_options_type3.rs +12 -4
  94. package/contracts/oapps/oapp/src/oapp_receiver.rs +14 -9
  95. package/contracts/oapps/oapp/src/tests/mod.rs +4 -4
  96. package/contracts/oapps/oapp/src/tests/oapp_core.rs +223 -0
  97. package/contracts/oapps/oapp/src/tests/oapp_options_type3.rs +240 -0
  98. package/contracts/oapps/oapp/src/tests/oapp_receiver.rs +381 -0
  99. package/contracts/oapps/oapp/src/tests/oapp_sender.rs +569 -0
  100. package/contracts/oapps/oapp-macros/Cargo.toml +8 -4
  101. package/contracts/oapps/oapp-macros/src/generators.rs +9 -34
  102. package/contracts/oapps/oapp-macros/src/lib.rs +3 -0
  103. package/contracts/oapps/oapp-macros/src/tests/mod.rs +2 -0
  104. package/contracts/oapps/oapp-macros/src/tests/oapp.rs +88 -0
  105. package/contracts/oapps/oapp-macros/src/tests/parse_custom_impls.rs +86 -0
  106. package/contracts/oapps/oapp-macros/src/tests/snapshots/oapp_macros__tests__oapp__snapshot_generate_oapp.snap +103 -0
  107. package/contracts/oapps/oft/integration-tests/utils.rs +28 -8
  108. package/contracts/oapps/oft/src/extensions/oft_fee.rs +153 -75
  109. package/contracts/oapps/oft/src/extensions/pausable.rs +61 -12
  110. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +198 -134
  111. package/contracts/oapps/oft/src/oft.rs +45 -50
  112. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
  113. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +4 -26
  114. package/contracts/oapps/oft-core/Cargo.toml +1 -4
  115. package/contracts/oapps/oft-core/integration-tests/setup.rs +3 -3
  116. package/contracts/oapps/oft-core/integration-tests/utils.rs +21 -3
  117. package/contracts/oapps/oft-core/src/errors.rs +3 -2
  118. package/contracts/oapps/oft-core/src/events.rs +6 -0
  119. package/contracts/oapps/oft-core/src/lib.rs +1 -1
  120. package/contracts/oapps/oft-core/src/oft_core.rs +341 -246
  121. package/contracts/oapps/oft-core/src/storage.rs +7 -3
  122. package/contracts/oapps/oft-core/src/tests/mod.rs +1 -0
  123. package/contracts/oapps/oft-core/src/tests/test_decimals.rs +37 -2
  124. package/contracts/oapps/oft-core/src/tests/test_lz_receive.rs +2 -2
  125. package/contracts/oapps/oft-core/src/tests/test_msg_inspector.rs +323 -0
  126. package/contracts/oapps/oft-core/src/tests/test_send.rs +2 -2
  127. package/contracts/oapps/oft-core/src/tests/test_utils.rs +61 -16
  128. package/contracts/upgrader/src/lib.rs +30 -57
  129. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
  130. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
  131. package/contracts/upgrader/src/tests/test_upgrader.rs +44 -35
  132. package/contracts/utils/Cargo.toml +0 -1
  133. package/contracts/utils/src/buffer_reader.rs +1 -0
  134. package/contracts/utils/src/errors.rs +4 -2
  135. package/contracts/utils/src/multisig.rs +17 -8
  136. package/contracts/utils/src/ownable.rs +6 -6
  137. package/contracts/utils/src/testing_utils.rs +124 -54
  138. package/contracts/utils/src/tests/multisig.rs +12 -12
  139. package/contracts/utils/src/tests/ownable.rs +6 -6
  140. package/contracts/utils/src/tests/testing_utils.rs +50 -167
  141. package/contracts/utils/src/tests/ttl_configurable.rs +5 -5
  142. package/contracts/utils/src/tests/upgradeable.rs +372 -175
  143. package/contracts/utils/src/ttl_configurable.rs +13 -7
  144. package/contracts/utils/src/upgradeable.rs +48 -23
  145. package/contracts/workers/dvn/Cargo.toml +6 -6
  146. package/contracts/workers/dvn/src/auth.rs +12 -42
  147. package/contracts/workers/dvn/src/dvn.rs +15 -40
  148. package/contracts/workers/dvn/src/errors.rs +0 -1
  149. package/contracts/workers/dvn/src/interfaces/dvn.rs +35 -0
  150. package/contracts/workers/dvn/src/lib.rs +4 -3
  151. package/contracts/workers/dvn/src/tests/auth.rs +1 -1
  152. package/contracts/workers/dvn/src/tests/dvn.rs +19 -15
  153. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +2 -4
  154. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +1 -3
  155. package/contracts/workers/dvn/src/tests/setup.rs +5 -9
  156. package/contracts/workers/dvn-fee-lib/Cargo.toml +2 -2
  157. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +38 -22
  158. package/contracts/workers/dvn-fee-lib/src/lib.rs +12 -2
  159. package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +17 -16
  160. package/contracts/workers/executor/Cargo.toml +4 -0
  161. package/contracts/workers/executor/src/executor.rs +15 -36
  162. package/contracts/workers/executor/src/lib.rs +2 -2
  163. package/contracts/workers/executor/src/tests/auth.rs +394 -0
  164. package/contracts/workers/executor/src/tests/executor.rs +410 -0
  165. package/contracts/workers/executor/src/tests/mod.rs +3 -0
  166. package/contracts/workers/executor/src/tests/setup.rs +250 -0
  167. package/contracts/workers/executor-fee-lib/Cargo.toml +7 -1
  168. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +62 -15
  169. package/contracts/workers/executor-fee-lib/src/executor_option.rs +28 -1
  170. package/contracts/workers/executor-fee-lib/src/lib.rs +11 -2
  171. package/contracts/workers/executor-fee-lib/src/tests/executor_fee_lib.rs +701 -0
  172. package/contracts/workers/executor-fee-lib/src/tests/executor_option.rs +370 -0
  173. package/contracts/workers/executor-fee-lib/src/tests/mod.rs +4 -0
  174. package/contracts/workers/executor-fee-lib/src/tests/setup.rs +60 -0
  175. package/contracts/workers/executor-helper/Cargo.toml +0 -1
  176. package/contracts/workers/executor-helper/src/lib.rs +3 -0
  177. package/contracts/workers/executor-helper/src/tests/executor_helper.rs +184 -0
  178. package/contracts/workers/executor-helper/src/tests/mod.rs +2 -0
  179. package/contracts/workers/executor-helper/src/tests/setup.rs +366 -0
  180. package/contracts/workers/fee-lib-interfaces/Cargo.toml +14 -0
  181. package/contracts/workers/{worker/src/interfaces/mod.rs → fee-lib-interfaces/src/lib.rs} +4 -3
  182. package/contracts/workers/price-feed/Cargo.toml +7 -1
  183. package/contracts/workers/price-feed/src/events.rs +1 -1
  184. package/contracts/workers/price-feed/src/lib.rs +12 -4
  185. package/contracts/workers/price-feed/src/price_feed.rs +5 -21
  186. package/contracts/workers/price-feed/src/storage.rs +1 -1
  187. package/contracts/workers/price-feed/src/tests/mod.rs +2 -0
  188. package/contracts/workers/price-feed/src/tests/price_feed.rs +869 -0
  189. package/contracts/workers/price-feed/src/tests/setup.rs +70 -0
  190. package/contracts/workers/price-feed/src/types.rs +1 -1
  191. package/contracts/workers/worker/src/errors.rs +1 -4
  192. package/contracts/workers/worker/src/lib.rs +0 -2
  193. package/contracts/workers/worker/src/storage.rs +32 -29
  194. package/contracts/workers/worker/src/tests/setup.rs +2 -8
  195. package/contracts/workers/worker/src/tests/worker.rs +96 -74
  196. package/contracts/workers/worker/src/worker.rs +75 -75
  197. package/docs/error-spec.md +55 -0
  198. package/docs/layerzero-v2-on-stellar.md +447 -0
  199. package/docs/oapp-guide.md +212 -0
  200. package/docs/oft-guide.md +314 -0
  201. package/package.json +3 -3
  202. package/sdk/.turbo/turbo-test.log +268 -263
  203. package/sdk/dist/generated/bml.d.ts +12 -4
  204. package/sdk/dist/generated/bml.js +9 -7
  205. package/sdk/dist/generated/counter.d.ts +306 -298
  206. package/sdk/dist/generated/counter.js +48 -46
  207. package/sdk/dist/generated/dvn.d.ts +450 -411
  208. package/sdk/dist/generated/dvn.js +66 -64
  209. package/sdk/dist/generated/dvn_fee_lib.d.ts +294 -338
  210. package/sdk/dist/generated/dvn_fee_lib.js +33 -64
  211. package/sdk/dist/generated/endpoint.d.ts +108 -100
  212. package/sdk/dist/generated/endpoint.js +21 -19
  213. package/sdk/dist/generated/executor.d.ts +414 -370
  214. package/sdk/dist/generated/executor.js +58 -55
  215. package/sdk/dist/generated/executor_fee_lib.d.ts +333 -377
  216. package/sdk/dist/generated/executor_fee_lib.js +34 -65
  217. package/sdk/dist/generated/executor_helper.d.ts +26 -190
  218. package/sdk/dist/generated/executor_helper.js +23 -28
  219. package/sdk/dist/generated/layerzero_view.d.ts +1271 -0
  220. package/sdk/dist/generated/layerzero_view.js +294 -0
  221. package/sdk/dist/generated/oft.d.ts +408 -385
  222. package/sdk/dist/generated/oft.js +89 -92
  223. package/sdk/dist/generated/price_feed.d.ts +385 -429
  224. package/sdk/dist/generated/price_feed.js +50 -81
  225. package/sdk/dist/generated/sml.d.ts +108 -100
  226. package/sdk/dist/generated/sml.js +21 -19
  227. package/sdk/dist/generated/treasury.d.ts +108 -100
  228. package/sdk/dist/generated/treasury.js +21 -19
  229. package/sdk/dist/generated/uln302.d.ts +108 -100
  230. package/sdk/dist/generated/uln302.js +23 -21
  231. package/sdk/dist/generated/upgrader.d.ts +189 -18
  232. package/sdk/dist/generated/upgrader.js +84 -4
  233. package/sdk/dist/index.d.ts +1 -0
  234. package/sdk/dist/index.js +2 -0
  235. package/sdk/package.json +1 -1
  236. package/sdk/src/index.ts +3 -0
  237. package/sdk/test/oft-sml.test.ts +4 -4
  238. package/sdk/test/suites/localnet.ts +84 -20
  239. package/sdk/test/upgrader.test.ts +2 -3
  240. package/tools/ts-bindings-gen/src/main.rs +2 -1
  241. package/contracts/ERROR_SPEC.md +0 -44
  242. package/contracts/endpoint-v2/ARCHITECTURE.md +0 -233
  243. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +0 -175
  244. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +0 -212
  245. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +0 -153
  246. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +0 -294
  247. /package/contracts/workers/{worker/src/interfaces → fee-lib-interfaces/src}/dvn_fee_lib.rs +0 -0
  248. /package/contracts/workers/{worker/src/interfaces → fee-lib-interfaces/src}/executor_fee_lib.rs +0 -0
  249. /package/contracts/workers/{worker/src/interfaces → fee-lib-interfaces/src}/price_feed.rs +0 -0
@@ -1,4 +1,5 @@
1
1
  use crate::{
2
+ self as oft,
2
3
  extensions::{
3
4
  oft_fee::{OFTFee, OFTFeeInternal},
4
5
  pausable::{OFTPausable, OFTPausableInternal},
@@ -7,15 +8,18 @@ use crate::{
7
8
  oft_types::{lock_unlock, mint_burn, OftType},
8
9
  };
9
10
  use common_macros::{contract_impl, storage};
10
- use endpoint_v2::{MessagingFee, Origin};
11
- use oapp::oapp_receiver::LzReceiveInternal;
12
11
  use oapp_macros::oapp;
13
12
  use oft_core::{
14
13
  errors::OFTError,
14
+ impl_oft_lz_receive,
15
15
  types::{OFTFeeDetail, OFTLimit, OFTReceipt, SendParam},
16
16
  utils as oft_utils, OFTCore, OFTInternal,
17
17
  };
18
- use soroban_sdk::{assert_with_error, vec, Address, Bytes, BytesN, Env, Vec};
18
+ use soroban_sdk::{assert_with_error, vec, Address, Bytes, Env, Vec};
19
+
20
+ // =========================================================================
21
+ // Storage
22
+ // =========================================================================
19
23
 
20
24
  #[storage]
21
25
  enum OFTStorage {
@@ -23,9 +27,16 @@ enum OFTStorage {
23
27
  OftType,
24
28
  }
25
29
 
30
+ // =========================================================================
31
+ // OFT Contract
32
+ // =========================================================================
33
+
26
34
  #[oapp]
27
35
  pub struct OFT;
28
36
 
37
+ // LzReceiveInternal implementation using default OFT receive logic
38
+ impl_oft_lz_receive!(OFT);
39
+
29
40
  #[contract_impl]
30
41
  impl OFT {
31
42
  pub fn __constructor(
@@ -37,7 +48,7 @@ impl OFT {
37
48
  shared_decimals: u32,
38
49
  oft_type: OftType,
39
50
  ) {
40
- oft_core::initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals);
51
+ Self::__initialize_oft(env, owner, token, endpoint, delegate, shared_decimals);
41
52
  OFTStorage::set_oft_type(env, &oft_type);
42
53
  }
43
54
 
@@ -51,9 +62,7 @@ impl OFT {
51
62
  #[contract_impl(contracttrait)]
52
63
  impl OFTCore for OFT {
53
64
  fn quote_oft(env: &Env, send_param: &SendParam) -> (OFTLimit, Vec<OFTFeeDetail>, OFTReceipt) {
54
- Self::__assert_not_paused(env);
55
-
56
- let oft_receipt = Self::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
65
+ let (_, _, oft_receipt) = Self::__quote_oft(env, send_param);
57
66
 
58
67
  // fee details (only include if there's an actual fee)
59
68
  let fee_amount_ld = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
@@ -69,26 +78,31 @@ impl OFTCore for OFT {
69
78
 
70
79
  (oft_limit, fee_details, oft_receipt)
71
80
  }
72
-
73
- fn quote_send(env: &Env, sender: &Address, send_param: &SendParam, pay_in_zro: bool) -> MessagingFee {
74
- Self::__assert_not_paused(env);
75
- oft_core::quote_send::<Self>(env, sender, send_param, pay_in_zro)
76
- }
77
81
  }
78
82
 
79
83
  /// OFT behavior for standard OFT with extension hooks
80
84
  impl OFTInternal for OFT {
85
+ /// Overrides default to add pausable check and fee calculation.
86
+ ///
87
+ /// Dust handling (consistent with EVM):
88
+ /// - fee = 0: dust stays with sender
89
+ /// - fee > 0: dust goes to fee recipient (included in charged fee)
81
90
  fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
82
- let conversion_rate = Self::decimal_conversion_rate(env);
91
+ Self::__assert_not_paused(env);
83
92
 
84
- // Apply the fee before dust removal to ensure the fee is calculated on the full amount and dust is not transferred
93
+ let conversion_rate = Self::__decimal_conversion_rate(env);
85
94
  let fee = Self::__fee_view(env, dst_eid, amount_ld);
86
- let amount_after_fee = amount_ld - fee;
87
- let amount_received_ld = oft_utils::remove_dust(amount_after_fee, conversion_rate);
88
95
 
89
- // amount_sent_ld = what recipient receives + fee charged
90
- // Dust is excluded (stays with sender)
91
- let amount_sent_ld = amount_received_ld + fee;
96
+ let (amount_sent_ld, amount_received_ld) = if fee == 0 {
97
+ // No fee: dust stays with sender (default OFT behavior)
98
+ let amount_sent_ld = oft_utils::remove_dust(amount_ld, conversion_rate);
99
+ (amount_sent_ld, amount_sent_ld)
100
+ } else {
101
+ // With fee: match EVM OFTFee behavior
102
+ // - dust is included in charged fee (goes to fee recipient)
103
+ let amount_received_ld = oft_utils::remove_dust(amount_ld - fee, conversion_rate);
104
+ (amount_ld, amount_received_ld)
105
+ };
92
106
 
93
107
  assert_with_error!(env, amount_received_ld >= min_amount_ld, OFTError::SlippageExceeded);
94
108
 
@@ -96,78 +110,59 @@ impl OFTInternal for OFT {
96
110
  }
97
111
 
98
112
  fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
99
- // 1. Pausable check
100
- Self::__assert_not_paused(env);
101
-
102
- // 2. Core debit logic (based on oft_type)
113
+ // Core debit logic (based on oft_type)
103
114
  let oft_receipt = match Self::oft_type(env) {
104
115
  OftType::LockUnlock => lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid),
105
116
  OftType::MintBurn => mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid),
106
117
  };
107
118
 
108
- // 3. Rate limit checks (using amount_received_ld - the actual cross-chain amount)
119
+ // Rate limit checks (using amount_received_ld - the actual cross-chain amount)
109
120
  Self::__consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, oft_receipt.amount_received_ld);
110
121
  Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, oft_receipt.amount_received_ld);
111
122
 
112
- // 4. Charge fee
123
+ // Charge fee
113
124
  let fee = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
114
- Self::__charge_fee(env, &Self::token(env), sender, fee);
125
+ Self::__charge_fee(env, &Self::__token(env), sender, fee);
115
126
 
116
127
  oft_receipt
117
128
  }
118
129
 
119
130
  fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
120
- // 1. Pausable check
131
+ // Pausable check
121
132
  Self::__assert_not_paused(env);
122
133
 
123
- // 2. Core credit logic (based on mode)
134
+ // Core credit logic (based on mode)
124
135
  let amount_credited = match Self::oft_type(env) {
125
136
  OftType::LockUnlock => lock_unlock::credit::<Self>(env, to, amount_ld, src_eid),
126
137
  OftType::MintBurn => mint_burn::credit::<Self>(env, to, amount_ld, src_eid),
127
138
  };
128
139
 
129
- // 3. Rate limit checks (using amount_credited - the actual credited amount)
130
- Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_credited);
131
- Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_credited);
140
+ // Rate limit checks
141
+ Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_ld);
142
+ Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_ld);
132
143
 
133
144
  amount_credited
134
145
  }
135
146
  }
136
147
 
137
- /// LzReceiveInternal implementation using default OFT receive logic
138
- impl LzReceiveInternal for OFT {
139
- fn __lz_receive(
140
- env: &Env,
141
- origin: &Origin,
142
- guid: &BytesN<32>,
143
- message: &Bytes,
144
- extra_data: &Bytes,
145
- executor: &Address,
146
- value: i128,
147
- ) {
148
- oft_core::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
149
- }
150
- }
151
-
152
- // ==================== Extension Trait Implementations ====================
148
+ // =========================================================================
149
+ // Extension Trait Implementations
150
+ // =========================================================================
153
151
 
154
152
  /// Pausable extension - allows pausing/unpausing the OFT
155
153
  /// Default state: unpaused (all operations allowed)
156
154
  #[contract_impl(contracttrait)]
157
155
  impl OFTPausable for OFT {}
158
-
159
156
  impl OFTPausableInternal for OFT {}
160
157
 
161
158
  /// OFT Fee extension - allows collecting fees on transfers
162
159
  /// Default state: 0 BPS (no fee collected)
163
160
  #[contract_impl(contracttrait)]
164
161
  impl OFTFee for OFT {}
165
-
166
162
  impl OFTFeeInternal for OFT {}
167
163
 
168
164
  /// Rate Limiter extension - allows rate limiting transfers
169
165
  /// Default state: not set (rate_limit_capacity returns i128::MAX)
170
166
  #[contract_impl(contracttrait)]
171
167
  impl RateLimiter for OFT {}
172
-
173
168
  impl RateLimiterInternal for OFT {}
@@ -4,7 +4,7 @@
4
4
  //! tokens from the contract on credit (receive).
5
5
  //! Used for OFT adapters that wrap existing tokens.
6
6
 
7
- use oft_core::{oft_core::OFTCore, types::OFTReceipt};
7
+ use oft_core::{types::OFTReceipt, OFTCore};
8
8
  use soroban_sdk::{token::TokenClient, Address, Env};
9
9
 
10
10
  /// Debit tokens using LockUnlock OFT type (locks tokens in contract).
@@ -3,30 +3,8 @@
3
3
  //! This OFT type burns tokens on debit (send) and mints tokens on credit (receive).
4
4
  //! Used when the OFT contract has mint/burn authority over the token.
5
5
 
6
- use oft_core::{oft_core::OFTCore, types::OFTReceipt};
7
- use soroban_sdk::{contractclient, Address, Env};
8
-
9
- /// Contract interface for mint and burn token operations.
10
- ///
11
- /// This interface abstracts the token mint/burn functionality, allowing different
12
- /// token implementations (e.g., StellarAssetContract, custom tokens) to be used
13
- /// with the MintBurn OFT.
14
- #[contractclient(name = "MintBurnTokenClient")]
15
- pub trait MintBurnToken {
16
- /// Mints tokens to the specified address.
17
- ///
18
- /// # Parameters
19
- /// * `to` - The address to mint tokens to
20
- /// * `amount` - The amount of tokens to mint (must be non-negative)
21
- fn mint(env: Env, to: Address, amount: i128);
22
-
23
- /// Burns tokens from the specified address.
24
- ///
25
- /// # Parameters
26
- /// * `from` - The address to burn tokens from
27
- /// * `amount` - The amount of tokens to burn (must be non-negative)
28
- fn burn(env: Env, from: Address, amount: i128);
29
- }
6
+ use oft_core::{types::OFTReceipt, OFTCore};
7
+ use soroban_sdk::{token::StellarAssetClient, Address, Env};
30
8
 
31
9
  /// Debit tokens using MintBurn OFT type (burns tokens from sender).
32
10
  ///
@@ -47,7 +25,7 @@ pub fn debit<T: OFTCore>(
47
25
  dst_eid: u32,
48
26
  ) -> OFTReceipt {
49
27
  let receipt = T::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
50
- MintBurnTokenClient::new(env, &T::token(env)).burn(sender, &receipt.amount_received_ld);
28
+ StellarAssetClient::new(env, &T::token(env)).burn(sender, &receipt.amount_received_ld);
51
29
  receipt
52
30
  }
53
31
 
@@ -62,6 +40,6 @@ pub fn debit<T: OFTCore>(
62
40
  /// # Returns
63
41
  /// The amount credited
64
42
  pub fn credit<T: OFTCore>(env: &Env, to: &Address, amount_ld: i128, _src_eid: u32) -> i128 {
65
- MintBurnTokenClient::new(env, &T::token(env)).mint(to, &amount_ld);
43
+ StellarAssetClient::new(env, &T::token(env)).mint(to, &amount_ld);
66
44
  amount_ld
67
45
  }
@@ -21,7 +21,4 @@ simple-message-lib = { workspace = true }
21
21
  message-lib-common = { workspace = true, features = ["testutils"] }
22
22
  endpoint-v2 = { workspace = true, features = ["testutils"] }
23
23
  utils = { workspace = true, features = ["testutils"] }
24
- insta = { workspace = true }
25
- oapp-macros = { workspace = true }
26
- stellar-macros = { workspace = true }
27
- stellar-tokens = { workspace = true }
24
+ oapp-macros = { workspace = true }
@@ -7,7 +7,7 @@ extern crate std;
7
7
  use crate::{
8
8
  self as oft_core,
9
9
  integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address},
10
- oft_core::{initialize_oft, lz_receive, OFTClient, OFTCore, OFTInternal},
10
+ oft_core::{OFTClient, OFTCore, OFTInternal},
11
11
  storage::OFTStorage,
12
12
  types::OFTReceipt,
13
13
  };
@@ -39,7 +39,7 @@ impl LzReceiveInternal for TestOFT {
39
39
  executor: &Address,
40
40
  value: i128,
41
41
  ) {
42
- lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
42
+ <Self as OFTInternal>::__receive(env, origin, guid, message, extra_data, executor, value)
43
43
  }
44
44
  }
45
45
 
@@ -53,7 +53,7 @@ impl TestOFT {
53
53
  delegate: &Option<Address>,
54
54
  shared_decimals: u32,
55
55
  ) {
56
- initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
56
+ Self::__initialize_oft(env, owner, token, endpoint, delegate, shared_decimals)
57
57
  }
58
58
  }
59
59
 
@@ -155,10 +155,28 @@ pub fn lz_compose(
155
155
 
156
156
  // returns (encoded_payload, options, send_library)
157
157
  pub fn scan_packet_sent_event(env: &Env, endpoint: &Address) -> Option<(Bytes, Bytes, Address)> {
158
+ use soroban_sdk::TryFromVal;
159
+
158
160
  let mut packet = None;
159
- for (emitter, topics, data) in env.events().all() {
160
- let packet_sent_symbol = Symbol::new(env, "packet_sent").to_val();
161
- if emitter == *endpoint && topics.contains(packet_sent_symbol) {
161
+ let events = env.events().all().filter_by_contract(endpoint);
162
+ for event in events.events().iter() {
163
+ let v0 = match &event.body {
164
+ soroban_sdk::xdr::ContractEventBody::V0(v0) => v0,
165
+ };
166
+
167
+ // Check if this is a packet_sent event by looking at topics
168
+ let mut is_packet_sent = false;
169
+ for topic in v0.topics.iter() {
170
+ if let Ok(sym) = Symbol::try_from_val(env, topic) {
171
+ if sym == Symbol::new(env, "packet_sent") {
172
+ is_packet_sent = true;
173
+ break;
174
+ }
175
+ }
176
+ }
177
+
178
+ if is_packet_sent {
179
+ let data: Val = Val::try_from_val(env, &v0.data).unwrap();
162
180
  let map: Map<Symbol, Val> = data.into_val(env);
163
181
 
164
182
  let encoded_payload: Bytes = map.get(Symbol::new(env, "encoded_packet")).unwrap().into_val(env);
@@ -1,12 +1,13 @@
1
1
  use common_macros::contract_error;
2
2
 
3
3
  // OFT library error codes: 3000-3099
4
- // See ERROR_SPEC.md for allocation rules
4
+ // See docs/error-spec.md for allocation rules
5
5
 
6
6
  /// OFTError: 3000-3099
7
7
  #[contract_error]
8
8
  pub enum OFTError {
9
- InvalidLocalDecimals = 3000,
9
+ InvalidAmount = 3000,
10
+ InvalidLocalDecimals,
10
11
  NotInitialized,
11
12
  Overflow,
12
13
  SlippageExceeded,
@@ -18,3 +18,9 @@ pub struct OFTReceived {
18
18
  pub to: Address,
19
19
  pub amount_received_ld: i128,
20
20
  }
21
+
22
+ #[contractevent]
23
+ #[derive(Clone, Debug, Eq, PartialEq)]
24
+ pub struct MsgInspectorSet {
25
+ pub inspector: Option<Address>,
26
+ }
@@ -3,7 +3,7 @@
3
3
  pub mod codec;
4
4
  pub mod errors;
5
5
  pub mod events;
6
- pub mod oft_core;
6
+ mod oft_core;
7
7
  pub mod storage;
8
8
  pub mod types;
9
9
  pub mod utils;