@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.19

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 (262) hide show
  1. package/.turbo/turbo-build.log +365 -297
  2. package/.turbo/turbo-lint.log +142 -110
  3. package/.turbo/turbo-test.log +1273 -1222
  4. package/Cargo.lock +20 -5
  5. package/Cargo.toml +4 -1
  6. package/contracts/ERROR_SPEC.md +44 -0
  7. package/contracts/common-macros/src/auth.rs +113 -0
  8. package/contracts/common-macros/src/contract_ttl.rs +84 -0
  9. package/contracts/common-macros/src/lib.rs +181 -30
  10. package/contracts/common-macros/src/lz_contract.rs +83 -0
  11. package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
  13. package/contracts/common-macros/src/tests/mod.rs +2 -2
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
  16. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
  17. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
  21. package/contracts/common-macros/src/ttl_configurable.rs +19 -34
  22. package/contracts/common-macros/src/ttl_extendable.rs +36 -0
  23. package/contracts/common-macros/src/upgradeable.rs +5 -5
  24. package/contracts/common-macros/src/utils.rs +9 -0
  25. package/contracts/endpoint-v2/src/constants.rs +4 -4
  26. package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
  27. package/contracts/endpoint-v2/src/errors.rs +4 -3
  28. package/contracts/endpoint-v2/src/events.rs +1 -1
  29. package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
  30. package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
  31. package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
  32. package/contracts/endpoint-v2/src/storage.rs +1 -1
  33. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
  34. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  38. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
  39. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
  40. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
  41. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
  42. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
  43. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
  44. package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
  45. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
  46. package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
  47. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
  48. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
  49. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
  50. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
  51. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
  52. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
  53. package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
  54. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
  55. package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
  56. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
  57. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
  58. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
  59. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
  60. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
  61. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
  62. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
  63. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
  64. package/contracts/message-libs/treasury/src/errors.rs +2 -2
  65. package/contracts/message-libs/treasury/src/events.rs +1 -1
  66. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
  67. package/contracts/message-libs/treasury/src/storage.rs +1 -1
  68. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
  69. package/contracts/message-libs/treasury/src/treasury.rs +14 -16
  70. package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
  71. package/contracts/message-libs/uln-302/src/send_uln.rs +24 -4
  72. package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
  73. package/contracts/oapps/counter/Cargo.toml +14 -1
  74. package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
  75. package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
  76. package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
  77. package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
  78. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
  79. package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
  80. package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
  81. package/contracts/oapps/counter/src/counter.rs +67 -43
  82. package/contracts/oapps/counter/src/tests/mod.rs +0 -13
  83. package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
  84. package/contracts/oapps/oapp/src/errors.rs +5 -1
  85. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
  86. package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
  87. package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
  88. package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
  89. package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
  90. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
  91. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
  92. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
  93. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
  94. package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
  95. package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
  96. package/contracts/oapps/oft/Cargo.toml +10 -7
  97. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
  98. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
  99. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
  100. package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
  101. package/contracts/oapps/oft/integration-tests/setup.rs +29 -110
  102. package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
  103. package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -14
  104. package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
  105. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
  106. package/contracts/oapps/oft/src/lib.rs +11 -13
  107. package/contracts/oapps/oft/src/oft.rs +147 -225
  108. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -13
  109. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +31 -14
  110. package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
  111. package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
  112. package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
  113. package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +129 -30
  114. package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
  115. package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
  116. package/contracts/oapps/oft-core/src/errors.rs +13 -0
  117. package/contracts/oapps/oft-core/src/lib.rs +18 -0
  118. package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
  119. package/contracts/oapps/{oft → oft-core}/src/storage.rs +2 -0
  120. package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
  121. package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +2 -2
  122. package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
  123. package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -5
  124. package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
  125. package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +78 -37
  126. package/contracts/oapps/oft-core/src/types.rs +58 -0
  127. package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
  128. package/contracts/upgrader/src/lib.rs +4 -4
  129. package/contracts/utils/src/auth.rs +44 -0
  130. package/contracts/utils/src/errors.rs +31 -5
  131. package/contracts/utils/src/lib.rs +3 -0
  132. package/contracts/utils/src/multisig.rs +211 -0
  133. package/contracts/utils/src/ownable.rs +137 -13
  134. package/contracts/utils/src/tests/buffer_reader.rs +6 -6
  135. package/contracts/utils/src/tests/buffer_writer.rs +6 -6
  136. package/contracts/utils/src/tests/bytes_ext.rs +2 -4
  137. package/contracts/utils/src/tests/mod.rs +1 -0
  138. package/contracts/utils/src/tests/multisig.rs +731 -0
  139. package/contracts/utils/src/tests/option_ext.rs +2 -5
  140. package/contracts/utils/src/tests/ownable.rs +456 -7
  141. package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
  142. package/contracts/utils/src/tests/upgradeable.rs +4 -2
  143. package/contracts/utils/src/ttl_configurable.rs +23 -8
  144. package/contracts/utils/src/ttl_extendable.rs +27 -0
  145. package/contracts/utils/src/upgradeable.rs +2 -0
  146. package/contracts/workers/dvn/Cargo.toml +1 -1
  147. package/contracts/workers/dvn/src/auth.rs +7 -7
  148. package/contracts/workers/dvn/src/dvn.rs +10 -38
  149. package/contracts/workers/dvn/src/errors.rs +0 -7
  150. package/contracts/workers/dvn/src/events.rs +1 -14
  151. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  152. package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
  153. package/contracts/workers/dvn/src/storage.rs +3 -13
  154. package/contracts/workers/dvn/src/tests/auth.rs +4 -4
  155. package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
  156. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
  157. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
  158. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
  159. package/contracts/workers/dvn/src/tests/setup.rs +5 -5
  160. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
  161. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
  162. package/contracts/workers/executor/src/auth.rs +80 -16
  163. package/contracts/workers/executor/src/executor.rs +5 -31
  164. package/contracts/workers/executor/src/storage.rs +2 -9
  165. package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
  166. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
  167. package/contracts/workers/executor-helper/Cargo.toml +1 -1
  168. package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
  169. package/contracts/workers/price-feed/Cargo.toml +1 -1
  170. package/contracts/workers/price-feed/src/price_feed.rs +7 -10
  171. package/contracts/workers/worker/src/errors.rs +4 -0
  172. package/contracts/workers/worker/src/tests/worker.rs +7 -6
  173. package/contracts/workers/worker/src/worker.rs +20 -16
  174. package/package.json +7 -5
  175. package/sdk/.turbo/turbo-build.log +1 -0
  176. package/sdk/.turbo/turbo-test.log +1019 -0
  177. package/sdk/dist/generated/bml.d.ts +95 -8
  178. package/sdk/dist/generated/bml.js +95 -36
  179. package/sdk/dist/generated/counter.d.ts +289 -44
  180. package/sdk/dist/generated/counter.js +119 -49
  181. package/sdk/dist/generated/dvn.d.ts +312 -229
  182. package/sdk/dist/generated/dvn.js +144 -83
  183. package/sdk/dist/generated/dvn_fee_lib.d.ts +258 -63
  184. package/sdk/dist/generated/dvn_fee_lib.js +95 -26
  185. package/sdk/dist/generated/endpoint.d.ts +219 -24
  186. package/sdk/dist/generated/endpoint.js +108 -41
  187. package/sdk/dist/generated/executor.d.ts +239 -87
  188. package/sdk/dist/generated/executor.js +135 -63
  189. package/sdk/dist/generated/executor_fee_lib.d.ts +278 -74
  190. package/sdk/dist/generated/executor_fee_lib.js +135 -59
  191. package/sdk/dist/generated/executor_helper.d.ts +163 -21
  192. package/sdk/dist/generated/executor_helper.js +124 -52
  193. package/sdk/dist/generated/oft.d.ts +1842 -0
  194. package/sdk/dist/generated/oft.js +345 -0
  195. package/sdk/dist/generated/price_feed.d.ts +258 -63
  196. package/sdk/dist/generated/price_feed.js +95 -26
  197. package/sdk/dist/generated/sml.d.ts +235 -34
  198. package/sdk/dist/generated/sml.js +126 -53
  199. package/sdk/dist/generated/treasury.d.ts +1016 -0
  200. package/sdk/dist/generated/treasury.js +248 -0
  201. package/sdk/dist/generated/uln302.d.ts +235 -34
  202. package/sdk/dist/generated/uln302.js +126 -53
  203. package/sdk/dist/generated/upgrader.d.ts +17 -2
  204. package/sdk/dist/generated/upgrader.js +19 -1
  205. package/sdk/dist/index.d.ts +2 -1
  206. package/sdk/dist/index.js +2 -1
  207. package/sdk/package.json +6 -3
  208. package/sdk/src/index.ts +2 -1
  209. package/sdk/test/counter-sml.test.ts +376 -0
  210. package/sdk/test/counter-uln.test.ts +493 -0
  211. package/sdk/test/{oft.test.ts → oft-sml.test.ts} +196 -321
  212. package/sdk/test/suites/constants.ts +22 -2
  213. package/sdk/test/suites/globalSetup.ts +450 -0
  214. package/sdk/test/suites/localnet.ts +23 -6
  215. package/sdk/test/upgrader.test.ts +7 -16
  216. package/sdk/test/utils.ts +558 -85
  217. package/sdk/turbo.json +8 -0
  218. package/sdk/vitest.config.ts +21 -0
  219. package/tools/ts-bindings-gen/Cargo.toml +2 -0
  220. package/tools/ts-bindings-gen/src/main.rs +52 -4
  221. package/contracts/common-macros/src/contract_impl.rs +0 -52
  222. package/contracts/common-macros/src/ownable.rs +0 -41
  223. package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
  224. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
  225. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
  226. package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
  227. package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
  228. package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
  229. package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
  230. package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
  231. package/contracts/oapps/oapp-macros/src/util.rs +0 -107
  232. package/contracts/oapps/oft/src/constants.rs +0 -5
  233. package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
  234. package/contracts/oapps/oft/src/errors.rs +0 -8
  235. package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
  236. package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
  237. package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
  238. package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -903
  239. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -749
  240. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -432
  241. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1078
  242. package/contracts/oapps/oft/src/types.rs +0 -38
  243. package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
  244. package/contracts/oapps/oft-std/src/lib.rs +0 -16
  245. package/contracts/oapps/oft-std/src/oft.rs +0 -156
  246. package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
  247. package/contracts/workers/dvn/src/multisig.rs +0 -157
  248. package/sdk/dist/generated/oft_std.d.ts +0 -1544
  249. package/sdk/dist/generated/oft_std.js +0 -271
  250. package/sdk/test/index.test.ts +0 -375
  251. /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
  252. /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
  253. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
  254. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
  255. /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
  256. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
  257. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
  258. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
  259. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
  260. /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
  261. /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
  262. /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
@@ -0,0 +1,128 @@
1
+ //! Code generators for OApp trait implementations.
2
+
3
+ use crate::CustomImpls;
4
+ use heck::ToSnakeCase;
5
+ use proc_macro2::TokenStream;
6
+ use quote::quote;
7
+ use syn::{Ident, ItemStruct};
8
+
9
+ /// Generates a complete OApp implementation with contract attributes and trait implementations.
10
+ ///
11
+ /// This function creates:
12
+ /// - `#[common_macros::lz_contract]` - Wrapper macro that combines:
13
+ /// - `#[soroban_sdk::contract]` - Makes the struct a Soroban contract
14
+ /// - `#[common_macros::ttl_configurable]` - Adds TTL configuration with auth
15
+ /// - `#[common_macros::ttl_extendable]` - Adds manual TTL extension support
16
+ /// - `#[common_macros::ownable]` - Adds single-owner access control
17
+ /// - OAppCore, OAppSenderInternal, OAppReceiver, and OAppOptionsType3 trait implementations
18
+ ///
19
+ /// The `custom` parameter controls which trait implementations are generated vs.
20
+ /// expected to be provided by the user.
21
+ pub fn generate_oapp(item: ItemStruct, custom: CustomImpls) -> TokenStream {
22
+ let core_impl = generate_oapp_core(&item.ident, custom.core);
23
+ let sender_impl = generate_oapp_sender(&item.ident, custom.sender);
24
+ let receiver_impl = generate_oapp_receiver(&item.ident, custom.receiver);
25
+ let options_type3_impl = generate_oapp_options_type3(&item.ident, custom.options_type3);
26
+ quote! {
27
+ #[common_macros::lz_contract]
28
+ #item
29
+
30
+ #core_impl
31
+ #sender_impl
32
+ #receiver_impl
33
+ #options_type3_impl
34
+ }
35
+ }
36
+
37
+ /// Generates the `OAppCore` trait implementation.
38
+ ///
39
+ /// When `custom` is false, generates an empty `impl OAppCore` that uses the trait's
40
+ /// default implementations for peer management and endpoint access.
41
+ fn generate_oapp_core(name: &Ident, custom: bool) -> TokenStream {
42
+ if custom {
43
+ return TokenStream::new();
44
+ }
45
+
46
+ let impl_mod = impl_mod_ident(name, "core");
47
+
48
+ quote! {
49
+ #[doc(hidden)]
50
+ mod #impl_mod {
51
+ use super::*;
52
+ use oapp::oapp_core::OAppCore;
53
+
54
+ #[soroban_sdk::contractimpl(contracttrait)]
55
+ impl OAppCore for #name {}
56
+ }
57
+ }
58
+ }
59
+
60
+ /// Generates the `OAppSenderInternal` trait implementation.
61
+ ///
62
+ /// When `custom` is false, generates an empty `impl OAppSenderInternal` that uses the
63
+ /// trait's default implementations for `__lz_quote` and `__lz_send`.
64
+ fn generate_oapp_sender(name: &Ident, custom: bool) -> TokenStream {
65
+ if custom {
66
+ TokenStream::new()
67
+ } else {
68
+ quote! {
69
+ use oapp::oapp_sender::OAppSenderInternal as _;
70
+
71
+ impl oapp::oapp_sender::OAppSenderInternal for #name {}
72
+ }
73
+ }
74
+ }
75
+
76
+ /// Generates the `OAppReceiver` trait implementation.
77
+ ///
78
+ /// When `custom` is false, generates an empty `impl OAppReceiver` that uses the trait's default
79
+ /// `lz_receive` implementation (which calls `clear_payload_and_transfer` then `__lz_receive`).
80
+ ///
81
+ /// Users must implement `LzReceiveInternal` themselves to provide the `__lz_receive` method.
82
+ fn generate_oapp_receiver(name: &Ident, custom: bool) -> TokenStream {
83
+ if custom {
84
+ return TokenStream::new();
85
+ }
86
+
87
+ let impl_mod = impl_mod_ident(name, "receiver");
88
+
89
+ quote! {
90
+ #[doc(hidden)]
91
+ mod #impl_mod {
92
+ use super::*;
93
+ use oapp::oapp_receiver::OAppReceiver;
94
+
95
+ #[soroban_sdk::contractimpl(contracttrait)]
96
+ impl OAppReceiver for #name {}
97
+ }
98
+ }
99
+ }
100
+
101
+ /// Generates the `OAppOptionsType3` trait implementation.
102
+ ///
103
+ /// When `custom` is false, generates an empty `impl OAppOptionsType3` that uses the
104
+ /// trait's default implementations for enforced options management.
105
+ fn generate_oapp_options_type3(name: &Ident, custom: bool) -> TokenStream {
106
+ if custom {
107
+ return TokenStream::new();
108
+ }
109
+
110
+ let impl_mod = impl_mod_ident(name, "options_type3");
111
+
112
+ quote! {
113
+ #[doc(hidden)]
114
+ mod #impl_mod {
115
+ use super::*;
116
+ use soroban_sdk::Vec;
117
+ use oapp::oapp_options_type3::{EnforcedOptionParam, OAppOptionsType3};
118
+
119
+ #[soroban_sdk::contractimpl(contracttrait)]
120
+ impl OAppOptionsType3 for #name {}
121
+ }
122
+ }
123
+ }
124
+
125
+ /// Creates a unique hidden module identifier for trait implementations.
126
+ fn impl_mod_ident(struct_name: &Ident, trait_name: &str) -> Ident {
127
+ Ident::new(&format!("__oapp_{}_impl_{}", trait_name, struct_name.to_string().to_snake_case()), struct_name.span())
128
+ }
@@ -8,53 +8,51 @@
8
8
  //! The OApp framework provides full bidirectional cross-chain communication:
9
9
  //!
10
10
  //! - **OAppCore**: Foundation for all OApp functionality (peer management, endpoint access)
11
- //! - **OAppSender**: Enables sending cross-chain messages through LayerZero
12
- //! - **OAppReceiver**: Handles incoming cross-chain messages
11
+ //! - **OAppSenderInternal**: Enables sending cross-chain messages through LayerZero
12
+ //! - **LzReceiveInternal**: Internal trait for message handling logic
13
+ //! - **OAppReceiver**: Handles incoming cross-chain messages (has default `lz_receive` impl)
13
14
  //! - **OAppOptionsType3**: Manages enforced options for message execution parameters
14
15
  //!
15
- //! ## Available Macros
16
+ //! ## Usage
16
17
  //!
17
18
  //! ### `#[oapp]`
18
19
  //! The main macro that provides Core + Sender + Receiver + OptionsType3 functionality.
19
20
  //! This is the only macro you need for cross-chain communication.
20
21
  //!
21
- //! ### `#[oapp_manual_impl(...)]`
22
- //! A marker attribute to indicate which trait implementations should be manually provided
23
- //! by the user instead of using default implementations.
22
+ //! ### Custom Implementations
24
23
  //!
25
- //! ## Manual Implementation Control
26
- //!
27
- //! By default, `#[oapp]` generates default trait implementations. Use `#[oapp_manual_impl(...)]`
28
- //! to customize specific behaviors:
24
+ //! By default, `#[oapp]` generates default trait implementations. Use `#[oapp(custom = [...])]`
25
+ //! to provide your own custom implementations for specific traits:
29
26
  //!
30
27
  //! Supported options:
31
- //! - `core` - Manually implement `OAppCore`
32
- //! - `sender` - Manually implement `OAppSender`
33
- //! - `receiver` - Manually implement `OAppReceiver` (useful for custom `next_nonce`, etc.)
34
- //! - `options_type3` - Manually implement `OAppOptionsType3`
28
+ //! - `core` - Custom implement `OAppCore`
29
+ //! - `sender` - Custom implement `OAppSenderInternal`
30
+ //! - `receiver` - Custom implement `OAppReceiver` (useful for custom `next_nonce`, etc.)
31
+ //! - `options_type3` - Custom implement `OAppOptionsType3`
35
32
  //!
36
33
  //! ## Examples
37
34
  //!
38
35
  //! ### Full OApp with Default Implementations
39
36
  //!
40
37
  //! ```ignore
38
+ //! use oapp::oapp_receiver::LzReceiveInternal;
41
39
  //! use oapp_macros::oapp;
42
40
  //!
43
41
  //! #[oapp]
44
42
  //! struct MyOApp;
45
43
  //!
46
- //! // Only __lz_receive must be implemented as an inherent method
47
- //! impl MyOApp {
44
+ //! // Implement LzReceiveInternal to handle incoming messages
45
+ //! impl LzReceiveInternal for MyOApp {
48
46
  //! fn __lz_receive(
49
47
  //! env: &Env,
50
- //! executor: &Address,
51
48
  //! origin: &Origin,
52
49
  //! guid: &BytesN<32>,
53
50
  //! message: &Bytes,
54
51
  //! extra_data: &Bytes,
52
+ //! executor: &Address,
55
53
  //! value: i128,
56
54
  //! ) {
57
- //! // Your message handling logic (verify_and_clear_payload already called)
55
+ //! // Your message handling logic (clear_payload_and_transfer already called)
58
56
  //! }
59
57
  //! }
60
58
  //! ```
@@ -62,8 +60,9 @@
62
60
  //! ### OApp with Custom Core Version
63
61
  //!
64
62
  //! ```ignore
65
- //! #[oapp]
66
- //! #[oapp_manual_impl(core)]
63
+ //! use oapp::oapp_receiver::LzReceiveInternal;
64
+ //!
65
+ //! #[oapp(custom = [core])]
67
66
  //! struct MyOApp;
68
67
  //!
69
68
  //! #[contractimpl(contracttrait)]
@@ -74,7 +73,7 @@
74
73
  //! }
75
74
  //! }
76
75
  //!
77
- //! impl MyOApp {
76
+ //! impl LzReceiveInternal for MyOApp {
78
77
  //! fn __lz_receive(...) { /* ... */ }
79
78
  //! }
80
79
  //! ```
@@ -82,73 +81,131 @@
82
81
  //! ### OApp with Custom Receiver (e.g., ordered delivery)
83
82
  //!
84
83
  //! ```ignore
85
- //! use oapp::oapp_receiver::{OAppReceiver, verify_and_clear_payload};
84
+ //! use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
86
85
  //!
87
- //! #[oapp]
88
- //! #[oapp_manual_impl(receiver)]
86
+ //! #[oapp(custom = [receiver])]
89
87
  //! struct MyOrderedOApp;
90
88
  //!
89
+ //! impl LzReceiveInternal for MyOrderedOApp {
90
+ //! fn __lz_receive(env: &Env, origin: &Origin, guid: &BytesN<32>, ...) {
91
+ //! // Your message handling logic
92
+ //! }
93
+ //! }
94
+ //!
91
95
  //! #[contractimpl(contracttrait)]
92
96
  //! impl OAppReceiver for MyOrderedOApp {
93
97
  //! fn next_nonce(env: &Env, src_eid: u32, sender: &BytesN<32>) -> u64 {
94
98
  //! // Custom nonce logic for ordered delivery
95
99
  //! Storage::max_received_nonce(env, src_eid, sender) + 1
96
100
  //! }
97
- //! fn lz_receive(env: &Env, executor: &Address, origin: &Origin, ...) {
98
- //! verify_and_clear_payload::<Self>(env, executor, origin, guid, message, value);
99
- //! // Your message handling logic
100
- //! }
101
+ //! // lz_receive uses default impl which calls clear_payload_and_transfer then __lz_receive
101
102
  //! }
102
103
  //! ```
103
104
  //!
104
- //! ### OApp with Multiple Manual Implementations
105
+ //! ### OApp with Multiple Custom Implementations
105
106
  //!
106
107
  //! ```ignore
107
- //! #[oapp]
108
- //! #[oapp_manual_impl(core, sender, options_type3)]
108
+ //! use oapp::oapp_receiver::LzReceiveInternal;
109
+ //!
110
+ //! #[oapp(custom = [core, sender, options_type3])]
109
111
  //! struct MyCustomOApp;
110
112
  //!
111
113
  //! #[contractimpl(contracttrait)]
112
114
  //! #[common_macros::ownable]
113
115
  //! impl OAppCore for MyCustomOApp { /* ... */ }
114
- //! impl OAppSender for MyCustomOApp { /* ... */ }
116
+ //! impl OAppSenderInternal for MyCustomOApp { /* ... */ }
115
117
  //! #[contractimpl(contracttrait)]
116
118
  //! impl OAppOptionsType3 for MyCustomOApp { /* ... */ }
117
119
  //!
118
- //! impl MyCustomOApp {
120
+ //! impl LzReceiveInternal for MyCustomOApp {
119
121
  //! fn __lz_receive(...) { /* ... */ }
120
122
  //! }
121
123
  //! ```
122
124
 
123
- use crate::util::parse_struct;
124
- use proc_macro::TokenStream;
125
+ mod generators;
125
126
 
126
- mod oapp_core;
127
- mod oapp_full;
128
- mod oapp_options_type3;
129
- mod oapp_receiver;
130
- mod oapp_sender;
131
- mod util;
127
+ use proc_macro::TokenStream;
128
+ use syn::{
129
+ bracketed,
130
+ parse::{Parse, ParseStream},
131
+ punctuated::Punctuated,
132
+ Error, Ident, ItemStruct, Token,
133
+ };
132
134
 
133
135
  /// Derives a complete OApp: `#[contract]` + `#[ownable]` + Core + Sender + Receiver + OptionsType3.
134
136
  ///
135
- /// You must implement `__lz_receive` as an inherent method. See module docs for examples.
137
+ /// ## Usage
138
+ ///
139
+ /// ```ignore
140
+ /// // Default: generates all trait implementations
141
+ /// #[oapp]
142
+ /// struct MyOApp;
143
+ ///
144
+ /// // Provide custom implementations for specific traits
145
+ /// #[oapp(custom = [core, receiver])]
146
+ /// struct MyCustomOApp;
147
+ /// ```
148
+ ///
149
+ /// ## Custom Options
150
+ /// - `core` - Manually implement `OAppCore`
151
+ /// - `sender` - Manually implement `OAppSenderInternal`
152
+ /// - `receiver` - Manually implement `OAppReceiver`
153
+ /// - `options_type3` - Manually implement `OAppOptionsType3`
154
+ ///
155
+ /// You must implement `LzReceiveInternal` for your struct. See module docs for examples.
136
156
  #[proc_macro_attribute]
137
- pub fn oapp(_attr: TokenStream, item: TokenStream) -> TokenStream {
138
- let (name, item, disable_config) = match parse_struct(item) {
139
- Ok(result) => result,
140
- Err(e) => return e,
141
- };
142
- oapp_full::generate_impl(&name, item, disable_config).into()
157
+ pub fn oapp(attr: TokenStream, item: TokenStream) -> TokenStream {
158
+ let custom = syn::parse_macro_input!(attr as CustomImpls);
159
+ let item_struct = syn::parse_macro_input!(item as ItemStruct);
160
+ generators::generate_oapp(item_struct, custom).into()
143
161
  }
144
162
 
145
- /// Marker attribute to skip generating specific trait implementations.
146
- ///
147
- /// Supported options: `core`, `sender`, `receiver`, `options_type3`
163
+ /// Specifies which OApp trait implementations the user will provide themselves.
148
164
  ///
149
- /// Example: `#[oapp_manual_impl(core, receiver)]` skips generating
150
- /// `OAppCore` and `OAppReceiver` implementations.
151
- #[proc_macro_attribute]
152
- pub fn oapp_manual_impl(_attr: TokenStream, item: TokenStream) -> TokenStream {
153
- item
165
+ /// Parsed from `#[oapp(custom = [...])]`. When a field is `true`, the macro skips
166
+ /// generating that trait implementation, allowing the user to provide their own.
167
+ #[derive(Debug, Clone, Copy, Default)]
168
+ struct CustomImpls {
169
+ pub core: bool,
170
+ pub sender: bool,
171
+ pub receiver: bool,
172
+ pub options_type3: bool,
173
+ }
174
+
175
+ impl Parse for CustomImpls {
176
+ fn parse(input: ParseStream) -> syn::Result<Self> {
177
+ if input.is_empty() {
178
+ return Ok(Self::default());
179
+ }
180
+
181
+ let key: Ident = input.parse()?;
182
+ if key != "custom" {
183
+ return Err(Error::new(key.span(), "expected `custom`"));
184
+ }
185
+
186
+ input.parse::<Token![=]>()?;
187
+
188
+ let content;
189
+ bracketed!(content in input);
190
+
191
+ let idents = Punctuated::<Ident, Token![,]>::parse_terminated(&content)?;
192
+ let mut custom_impls = Self::default();
193
+
194
+ for ident in idents {
195
+ match ident.to_string().as_str() {
196
+ "core" => custom_impls.core = true,
197
+ "sender" => custom_impls.sender = true,
198
+ "receiver" => custom_impls.receiver = true,
199
+ "options_type3" => custom_impls.options_type3 = true,
200
+ _ => {
201
+ return Err(Error::new(
202
+ ident.span(),
203
+ "expected one of `core`, `sender`, `receiver`, `options_type3`",
204
+ ));
205
+ }
206
+ }
207
+ }
208
+
209
+ Ok(custom_impls)
210
+ }
154
211
  }
@@ -5,15 +5,22 @@ edition.workspace = true
5
5
  license.workspace = true
6
6
 
7
7
  [lib]
8
- crate-type = ["rlib"]
8
+ crate-type = ["cdylib", "rlib"]
9
9
  doctest = false
10
10
 
11
+ [features]
12
+ library = []
13
+ testutils = []
14
+
11
15
  [dependencies]
12
16
  soroban-sdk = { workspace = true }
13
- endpoint-v2 = { workspace = true, features = ["library"] }
17
+ cfg-if = { workspace = true }
14
18
  utils = { workspace = true }
15
- oapp = { workspace = true }
16
19
  common-macros = { workspace = true }
20
+ endpoint-v2 = { workspace = true, features = ["library"] }
21
+ oapp = { workspace = true }
22
+ oapp-macros = { workspace = true }
23
+ oft-core = { workspace = true }
17
24
 
18
25
  [dev-dependencies]
19
26
  soroban-sdk = { workspace = true, features = ["testutils"] }
@@ -21,7 +28,3 @@ simple-message-lib = { workspace = true }
21
28
  message-lib-common = { workspace = true, features = ["testutils"] }
22
29
  endpoint-v2 = { workspace = true, features = ["testutils"] }
23
30
  utils = { workspace = true, features = ["testutils"] }
24
- insta = { workspace = true }
25
- oapp-macros = { workspace = true }
26
- stellar-macros = { workspace = true }
27
- stellar-tokens = { workspace = true }
@@ -8,10 +8,9 @@
8
8
  use crate::integration_tests::{
9
9
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
10
10
  utils::{
11
- address_to_peer_bytes32, create_send_param, lz_receive, mint_to,
12
- quote_oft, quote_send, scan_packet_sent_event, send, send_with_fee,
13
- set_default_fee_bps, set_fee_bps, set_fee_deposit_address, token_balance,
14
- transfer_sac_admin, validate_packet,
11
+ address_to_peer_bytes32, create_send_param, lz_receive, mint_to, quote_oft, quote_send,
12
+ scan_packet_sent_event, send, send_with_fee, set_default_fee_bps, set_fee_bps, set_fee_deposit_address,
13
+ token_balance, transfer_sac_admin, validate_packet,
15
14
  },
16
15
  };
17
16
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
@@ -6,9 +6,8 @@
6
6
  use crate::integration_tests::{
7
7
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
8
8
  utils::{
9
- address_to_peer_bytes32, create_send_param, is_paused, lz_receive, mint_to,
10
- quote_oft, quote_send, scan_packet_sent_event, send, set_paused, transfer_sac_admin,
11
- try_lz_receive, try_send, validate_packet,
9
+ address_to_peer_bytes32, create_send_param, is_paused, lz_receive, mint_to, quote_oft, quote_send,
10
+ scan_packet_sent_event, send, set_paused, transfer_sac_admin, try_lz_receive, try_send, validate_packet,
12
11
  },
13
12
  };
14
13
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
@@ -3,6 +3,7 @@
3
3
  //! Tests verify that the RateLimiter extension properly enforces rate limits
4
4
  //! on cross-chain transfers. Uses real EndpointV2 and SimpleMessageLib.
5
5
 
6
+ use crate::extensions::rate_limiter::Direction;
6
7
  use crate::integration_tests::{
7
8
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
8
9
  utils::{
@@ -11,7 +12,6 @@ use crate::integration_tests::{
11
12
  try_send, validate_packet,
12
13
  },
13
14
  };
14
- use oft::extensions::rate_limiter::Direction;
15
15
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
16
16
 
17
17
  /// Test e2e send without rate limit (default - unlimited)
@@ -1,3 +1,3 @@
1
+ pub mod extensions;
1
2
  pub mod setup;
2
- pub mod test_with_sml;
3
3
  pub mod utils;
@@ -1,123 +1,39 @@
1
- //! Integration test setup for OFT.
1
+ //! Integration test setup for OFT-STD with real EndpointV2 and SimpleMessageLib.
2
2
  //!
3
- //! This file contains TestOFT contract and test setup utilities.
3
+ //! This file contains test setup utilities for OFT-STD with all extensions enabled.
4
4
 
5
- extern crate self as oft;
6
5
  extern crate std;
7
6
 
8
- use crate::integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address};
9
- use common_macros::contract_impl;
10
- use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer};
11
- use oft::oft::{oft_initialize, OFTClient, OFTInternal, OFT};
12
- use oft::storage::OFTStorage;
13
- use oft::types::OFTReceipt;
7
+ use crate::{
8
+ integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address},
9
+ oft::{OFTClient, OFT},
10
+ oft_types::OftType,
11
+ };
12
+ use endpoint_v2::{EndpointV2, EndpointV2Client};
14
13
  use simple_message_lib::{SimpleMessageLib, SimpleMessageLibClient};
15
- use soroban_sdk::contractimpl;
16
14
  use soroban_sdk::{
17
- contract, contracttype, log, symbol_short,
15
+ contract, contractimpl, log,
18
16
  testutils::{Address as _, MockAuth, MockAuthInvoke},
19
- token::{StellarAssetClient, TokenClient},
20
- Address, Bytes, BytesN, Env, IntoVal,
17
+ token::TokenClient,
18
+ Address, BytesN, Env, IntoVal,
21
19
  };
22
20
 
23
21
  // ============================================================================
24
- // Test OFT Contract
22
+ // Dummy Recipient - used to create valid contract addresses for recipients
25
23
  // ============================================================================
26
24
 
27
- #[oapp_macros::oapp]
28
- pub struct TestOFT;
29
-
30
- #[contract_impl]
31
- impl TestOFT {
32
- pub fn __constructor(
33
- env: &Env,
34
- token: &Address,
35
- owner: &Address,
36
- endpoint: &Address,
37
- delegate: &Option<Address>,
38
- shared_decimals: u32,
39
- ) {
40
- oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
41
- }
42
- }
43
-
44
- #[contractimpl(contracttrait)]
45
- impl OFT for TestOFT {}
46
-
47
- impl OFTInternal for TestOFT {
48
- fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
49
- // Get the receipt (handles decimal conversion, fees, etc.)
50
- let receipt = Self::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
51
- // Actually burn tokens from sender
52
- StellarAssetClient::new(env, &OFTStorage::token(env).unwrap()).burn(sender, &receipt.amount_sent_ld);
53
- receipt
54
- }
55
-
56
- fn __credit(env: &Env, to: &Address, amount_ld: i128, _src_eid: u32) -> i128 {
57
- // Actually mint tokens to recipient
58
- StellarAssetClient::new(env, &OFTStorage::token(env).unwrap()).mint(to, &amount_ld);
59
- amount_ld
60
- }
61
- }
62
-
63
- // ============================================================================
64
- // Dummy Composer for testing compose messages
65
- // ============================================================================
66
-
67
- #[contracttype]
68
- pub struct ComposeMessage {
69
- pub executor: Address,
70
- pub from: Address,
71
- pub guid: BytesN<32>,
72
- pub index: u32,
73
- pub message: Bytes,
74
- pub extra_data: Bytes,
75
- pub value: i128,
76
- }
77
-
78
25
  #[contract]
79
- pub struct DummyComposer;
80
-
81
- #[contract_impl]
82
- impl DummyComposer {
83
- pub fn __constructor(env: &Env, endpoint: &Address) {
84
- env.storage().instance().set(&symbol_short!("endpoint"), endpoint);
85
- }
26
+ pub struct DummyRecipient;
86
27
 
87
- pub fn compose_message(env: &Env) -> Option<ComposeMessage> {
88
- env.storage().instance().get(&symbol_short!("msg"))
89
- }
28
+ #[contractimpl]
29
+ impl DummyRecipient {
30
+ pub fn __constructor(_env: &Env) {}
90
31
  }
91
32
 
92
- #[contract_impl]
93
- impl ILayerZeroComposer for DummyComposer {
94
- fn lz_compose(
95
- env: &Env,
96
- executor: &Address,
97
- from: &Address,
98
- guid: &BytesN<32>,
99
- index: u32,
100
- message: &Bytes,
101
- extra_data: &Bytes,
102
- value: i128,
103
- ) {
104
- let endpoint_address: Address = env.storage().instance().get(&symbol_short!("endpoint")).unwrap();
105
- let endpoint = endpoint_v2::MessagingComposerClient::new(env, &endpoint_address);
106
- endpoint.clear_compose(&env.current_contract_address(), from, guid, &index, message);
107
-
108
- env.storage().instance().set(
109
- &symbol_short!("msg"),
110
- &ComposeMessage {
111
- executor: executor.clone(),
112
- from: from.clone(),
113
- guid: guid.clone(),
114
- index,
115
- message: message.clone(),
116
- extra_data: extra_data.clone(),
117
- value,
118
- },
119
- );
120
- }
33
+ /// Creates a valid recipient address by deploying a dummy contract.
34
+ /// Use this in tests when the address needs to pass the `.exists()` check.
35
+ pub fn create_recipient_address(env: &Env) -> Address {
36
+ env.register(DummyRecipient, ())
121
37
  }
122
38
 
123
39
  // ============================================================================
@@ -128,16 +44,16 @@ pub struct ChainSetup<'a> {
128
44
  pub eid: u32,
129
45
  pub owner: Address,
130
46
  pub native_token: Address,
47
+ pub zro_token: Address,
131
48
  pub oft_token: Address,
132
49
  pub endpoint: EndpointV2Client<'a>,
133
50
  pub sml: SimpleMessageLibClient<'a>,
134
51
  pub oft: OFTClient<'a>,
135
- pub composer: DummyComposerClient<'a>,
52
+ pub fee_collector: Address,
136
53
  }
137
54
 
138
55
  pub struct TestSetup<'a> {
139
56
  pub env: Env,
140
-
141
57
  pub chain_a: ChainSetup<'a>,
142
58
  pub chain_b: ChainSetup<'a>,
143
59
  }
@@ -145,9 +61,13 @@ pub struct TestSetup<'a> {
145
61
  fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
146
62
  let owner = Address::generate(env);
147
63
 
64
+ // Create native token FIRST - this must match the endpoint's NATIVE_TOKEN constant
148
65
  let sac = env.register_stellar_asset_contract_v2(owner.clone());
149
66
  let native_token = sac.address();
150
67
 
68
+ // Generate fee_collector AFTER native_token to not affect the address derivation
69
+ let fee_collector = Address::generate(env);
70
+
151
71
  // Create ZRO token
152
72
  let zro_sac = env.register_stellar_asset_contract_v2(owner.clone());
153
73
  let zro_token = zro_sac.address();
@@ -161,13 +81,12 @@ fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
161
81
  let sml_address = env.register(SimpleMessageLib, (&owner, &endpoint_address, &fee_recipient));
162
82
  let delegate: Option<Address> = Some(owner.clone());
163
83
  let shared_decimals: u32 = 6; // Default shared decimals
164
- let oft_address = env.register(TestOFT, (&oft_token, &owner, &endpoint_address, &delegate, &shared_decimals));
165
- let composer_address = env.register(DummyComposer, (&endpoint_address,));
84
+ let mode = OftType::MintBurn;
85
+ let oft_address = env.register(OFT, (&oft_token, &owner, &endpoint_address, &delegate, &shared_decimals, &mode));
166
86
 
167
87
  let endpoint = EndpointV2Client::new(env, &endpoint_address);
168
88
  let sml = SimpleMessageLibClient::new(env, &sml_address);
169
89
  let oft = OFTClient::new(env, &oft_address);
170
- let composer = DummyComposerClient::new(env, &composer_address);
171
90
 
172
91
  // Set ZRO token in endpoint
173
92
  env.mock_auths(&[MockAuth {
@@ -184,7 +103,7 @@ fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
184
103
  register_library(env, &owner, &endpoint, &sml.address);
185
104
 
186
105
  let eid = endpoint.eid();
187
- ChainSetup { eid, owner, native_token, oft_token, endpoint, sml, oft, composer }
106
+ ChainSetup { eid, owner, native_token, zro_token, oft_token, endpoint, sml, oft, fee_collector }
188
107
  }
189
108
 
190
109
  pub fn setup<'a>() -> TestSetup<'a> {