@layerzerolabs/protocol-stellar-v2 0.2.13 → 0.2.18

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 (435) hide show
  1. package/.turbo/turbo-build.log +484 -337
  2. package/.turbo/turbo-lint.log +126 -56
  3. package/.turbo/turbo-test.log +1403 -984
  4. package/Cargo.lock +142 -3
  5. package/Cargo.toml +5 -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 +219 -29
  10. package/contracts/common-macros/src/lz_contract.rs +83 -0
  11. package/contracts/common-macros/src/storage.rs +1 -1
  12. package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
  13. package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
  14. package/contracts/common-macros/src/tests/mod.rs +3 -2
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
  17. 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
  18. 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} +26 -10
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +48 -48
  21. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -41
  22. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +21 -0
  23. package/contracts/common-macros/src/tests/upgradeable.rs +31 -0
  24. package/contracts/common-macros/src/ttl_configurable.rs +21 -66
  25. package/contracts/common-macros/src/ttl_extendable.rs +36 -0
  26. package/contracts/common-macros/src/upgradeable.rs +76 -0
  27. package/contracts/common-macros/src/utils.rs +9 -0
  28. package/contracts/endpoint-v2/src/constants.rs +4 -4
  29. package/contracts/endpoint-v2/src/endpoint_v2.rs +58 -36
  30. package/contracts/endpoint-v2/src/errors.rs +4 -3
  31. package/contracts/endpoint-v2/src/events.rs +1 -1
  32. package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
  33. package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
  34. package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
  35. package/contracts/endpoint-v2/src/storage.rs +1 -1
  36. package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +175 -8
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/build_outbound_packet.rs +76 -0
  38. package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +342 -159
  39. package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +3 -15
  40. package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +20 -31
  41. package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +126 -164
  42. package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +1 -0
  43. package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +0 -1
  44. package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +0 -1
  45. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +311 -304
  46. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +423 -96
  47. package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +1 -1
  48. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +47 -20
  49. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +373 -403
  50. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +96 -22
  51. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +62 -10
  52. package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +4 -4
  53. package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +8 -11
  54. package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +81 -30
  55. package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +209 -76
  56. package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +0 -1
  57. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library.rs +24 -0
  58. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library_timeout.rs +40 -0
  59. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_send_library.rs +24 -0
  60. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_config.rs +108 -0
  61. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_library_index.rs +52 -0
  62. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_receive_library.rs +92 -0
  63. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_registered_libraries.rs +74 -0
  64. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_send_library.rs +83 -0
  65. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_registered_library.rs +32 -0
  66. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_supported_eid.rs +28 -0
  67. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_valid_receive_library.rs +261 -0
  68. package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +16 -0
  69. package/contracts/endpoint-v2/src/tests/message_lib_manager/receive_library_timeout.rs +62 -0
  70. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +65 -43
  71. package/contracts/endpoint-v2/src/tests/message_lib_manager/registered_libraries_count.rs +42 -0
  72. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +61 -0
  73. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +4 -6
  74. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +59 -0
  75. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +16 -2
  76. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +155 -51
  77. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +114 -92
  78. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +235 -132
  79. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +93 -87
  80. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +346 -245
  81. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +406 -60
  82. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +252 -78
  83. package/contracts/endpoint-v2/src/tests/message_lib_manager/timeout.rs +102 -0
  84. package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +212 -273
  85. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +203 -0
  86. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +94 -0
  87. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +78 -248
  88. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +7 -282
  89. package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +6 -274
  90. package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +3 -2
  91. package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +86 -178
  92. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +328 -212
  93. package/contracts/endpoint-v2/src/tests/messaging_channel/outbound.rs +68 -0
  94. package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +6 -209
  95. package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +207 -159
  96. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +142 -153
  97. package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +6 -179
  98. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +163 -221
  99. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +90 -121
  100. package/contracts/endpoint-v2/src/tests/mock.rs +18 -4
  101. package/contracts/endpoint-v2/src/tests/util/build_payload.rs +4 -70
  102. package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +2 -1
  103. package/contracts/endpoint-v2/src/tests/util/keccak256.rs +17 -106
  104. package/contracts/layerzero-views/Cargo.toml +35 -0
  105. package/contracts/layerzero-views/src/errors.rs +10 -0
  106. package/contracts/layerzero-views/src/layerzero_view.rs +226 -0
  107. package/contracts/layerzero-views/src/lib.rs +38 -0
  108. package/contracts/layerzero-views/src/storage.rs +18 -0
  109. package/contracts/layerzero-views/src/tests/layerzero_view_tests.rs +423 -0
  110. package/contracts/layerzero-views/src/tests/mod.rs +4 -0
  111. package/contracts/layerzero-views/src/tests/setup.rs +377 -0
  112. package/contracts/layerzero-views/src/types.rs +50 -0
  113. package/contracts/macro-integration-tests/Cargo.toml +30 -0
  114. package/contracts/macro-integration-tests/src/lib.rs +1 -0
  115. package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +62 -0
  116. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +22 -0
  117. package/contracts/macro-integration-tests/tests/runtime/ownable/only_auth_guard.rs +97 -0
  118. package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +101 -0
  119. package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +225 -0
  120. package/contracts/macro-integration-tests/tests/runtime/storage/mod.rs +4 -0
  121. package/contracts/macro-integration-tests/tests/runtime/storage/name_override_runtime.rs +52 -0
  122. package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +261 -0
  123. package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +137 -0
  124. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +113 -0
  125. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +139 -0
  126. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +2 -0
  127. package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
  128. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +12 -0
  129. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +7 -0
  130. package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.rs +12 -0
  131. package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.stderr +7 -0
  132. package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.rs +21 -0
  133. package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.stderr +7 -0
  134. package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.rs +13 -0
  135. package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.stderr +7 -0
  136. package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +20 -0
  137. package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +15 -0
  138. package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +16 -0
  139. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +22 -0
  140. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +16 -0
  141. package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +26 -0
  142. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +21 -0
  143. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +46 -0
  144. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.rs +13 -0
  145. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +7 -0
  146. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.rs +13 -0
  147. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +7 -0
  148. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.rs +10 -0
  149. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.stderr +7 -0
  150. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.rs +12 -0
  151. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +7 -0
  152. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.rs +10 -0
  153. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.stderr +7 -0
  154. package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.rs +10 -0
  155. package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.stderr +7 -0
  156. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +12 -0
  157. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +7 -0
  158. package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.rs +13 -0
  159. package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.stderr +7 -0
  160. package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.rs +13 -0
  161. package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.stderr +7 -0
  162. package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +14 -0
  163. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +14 -0
  164. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +16 -0
  165. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +15 -0
  166. package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +14 -0
  167. package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +19 -0
  168. package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +15 -0
  169. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +44 -0
  170. package/contracts/macro-integration-tests/tests/ui_error.rs +11 -0
  171. package/contracts/macro-integration-tests/tests/ui_ownable.rs +11 -0
  172. package/contracts/macro-integration-tests/tests/ui_storage.rs +11 -0
  173. package/contracts/macro-integration-tests/tests/ui_ttl_configurable.rs +12 -0
  174. package/contracts/message-libs/blocked-message-lib/src/lib.rs +17 -17
  175. package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
  176. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +64 -0
  177. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet.rs +58 -0
  178. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet_header.rs +138 -0
  179. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/mod.rs +6 -0
  180. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload.rs +30 -0
  181. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload_hash.rs +15 -0
  182. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/test_helper.rs +39 -0
  183. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_dvn_option.rs +57 -0
  184. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +49 -0
  185. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +73 -0
  186. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +280 -0
  187. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +126 -0
  188. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +48 -0
  189. package/contracts/message-libs/message-lib-common/src/tests/worker_options/mod.rs +7 -0
  190. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +139 -0
  191. package/contracts/message-libs/message-lib-common/src/worker_options.rs +31 -1
  192. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
  193. package/contracts/message-libs/treasury/src/errors.rs +2 -3
  194. package/contracts/message-libs/treasury/src/events.rs +1 -1
  195. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
  196. package/contracts/message-libs/treasury/src/lib.rs +3 -3
  197. package/contracts/message-libs/treasury/src/storage.rs +3 -1
  198. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
  199. package/contracts/message-libs/treasury/src/treasury.rs +23 -26
  200. package/contracts/message-libs/uln-302/Cargo.toml +1 -1
  201. package/contracts/message-libs/uln-302/src/errors.rs +0 -5
  202. package/contracts/message-libs/uln-302/src/events.rs +5 -6
  203. package/contracts/message-libs/uln-302/src/receive_uln.rs +37 -56
  204. package/contracts/message-libs/uln-302/src/send_uln.rs +112 -138
  205. package/contracts/message-libs/uln-302/src/storage.rs +5 -5
  206. package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +5 -7
  207. package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +3 -3
  208. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +6 -9
  209. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
  210. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +3 -3
  211. package/contracts/message-libs/uln-302/src/tests/setup.rs +9 -0
  212. package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +5 -0
  213. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +1 -2
  214. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +1 -2
  215. package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +37 -55
  216. package/contracts/message-libs/uln-302/src/uln302.rs +10 -25
  217. package/contracts/oapps/counter/Cargo.toml +14 -1
  218. package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
  219. package/contracts/oapps/counter/integration_tests/setup_sml.rs +169 -0
  220. package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
  221. package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
  222. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
  223. package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
  224. package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
  225. package/contracts/oapps/counter/src/counter.rs +67 -44
  226. package/contracts/oapps/counter/src/tests/mod.rs +0 -13
  227. package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
  228. package/contracts/oapps/oapp/src/errors.rs +5 -1
  229. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +318 -221
  230. package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
  231. package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
  232. package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
  233. package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
  234. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -9
  235. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -18
  236. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -8
  237. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -16
  238. package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
  239. package/contracts/oapps/oapp-macros/src/lib.rs +211 -0
  240. package/contracts/oapps/oft/integration-tests/setup.rs +34 -9
  241. package/contracts/oapps/oft/integration-tests/utils.rs +1 -1
  242. package/contracts/oapps/oft/src/errors.rs +6 -1
  243. package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -13
  244. package/contracts/oapps/oft/src/extensions/pausable.rs +5 -5
  245. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +23 -23
  246. package/contracts/oapps/oft/src/lib.rs +4 -2
  247. package/contracts/oapps/oft/src/oft.rs +31 -71
  248. package/contracts/oapps/oft/src/oft_impl.rs +201 -0
  249. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +2 -4
  250. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -4
  251. package/contracts/oapps/oft/src/storage.rs +2 -0
  252. package/contracts/oapps/oft/src/tests/extensions/setup.rs +60 -31
  253. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +5 -3
  254. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +5 -3
  255. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +6 -4
  256. package/contracts/oapps/oft/src/tests/test_decimals.rs +2 -2
  257. package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +1 -2
  258. package/contracts/oapps/oft/src/tests/test_send.rs +4 -4
  259. package/contracts/oapps/oft/src/tests/test_utils.rs +122 -81
  260. package/contracts/oapps/oft/src/types.rs +20 -0
  261. package/contracts/oapps/oft-std/Cargo.toml +6 -0
  262. package/contracts/oapps/oft-std/integration-tests/extensions/mod.rs +3 -0
  263. package/contracts/oapps/oft-std/integration-tests/extensions/test_oft_fee.rs +157 -0
  264. package/contracts/oapps/oft-std/integration-tests/extensions/test_pausable.rs +162 -0
  265. package/contracts/oapps/oft-std/integration-tests/extensions/test_rate_limiter.rs +186 -0
  266. package/contracts/oapps/oft-std/integration-tests/mod.rs +3 -0
  267. package/contracts/oapps/{counter/integration_tests → oft-std/integration-tests}/setup.rs +76 -30
  268. package/contracts/oapps/oft-std/integration-tests/utils.rs +427 -0
  269. package/contracts/oapps/oft-std/src/lib.rs +12 -1
  270. package/contracts/oapps/oft-std/src/oft.rs +141 -26
  271. package/contracts/upgrader/Cargo.toml +19 -0
  272. package/contracts/upgrader/src/lib.rs +96 -0
  273. package/contracts/upgrader/src/tests/mod.rs +1 -0
  274. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
  275. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
  276. package/contracts/upgrader/src/tests/test_upgrader.rs +120 -0
  277. package/contracts/utils/src/auth.rs +44 -0
  278. package/contracts/utils/src/errors.rs +32 -5
  279. package/contracts/utils/src/lib.rs +5 -1
  280. package/contracts/utils/src/multisig.rs +211 -0
  281. package/contracts/utils/src/ownable.rs +50 -60
  282. package/contracts/utils/src/tests/buffer_reader.rs +6 -6
  283. package/contracts/utils/src/tests/buffer_writer.rs +6 -6
  284. package/contracts/utils/src/tests/bytes_ext.rs +2 -4
  285. package/contracts/utils/src/tests/mod.rs +4 -1
  286. package/contracts/utils/src/tests/multisig.rs +731 -0
  287. package/contracts/utils/src/tests/option_ext.rs +18 -0
  288. package/contracts/utils/src/tests/ownable.rs +22 -70
  289. package/contracts/utils/src/tests/ttl_configurable.rs +607 -0
  290. package/contracts/utils/src/tests/upgradeable.rs +290 -0
  291. package/contracts/utils/src/ttl_configurable.rs +153 -0
  292. package/contracts/utils/src/ttl_extendable.rs +27 -0
  293. package/contracts/utils/src/upgradeable.rs +56 -0
  294. package/contracts/workers/dvn/Cargo.toml +2 -2
  295. package/contracts/workers/dvn/src/auth.rs +24 -35
  296. package/contracts/workers/dvn/src/dvn.rs +23 -14
  297. package/contracts/workers/dvn/src/errors.rs +1 -7
  298. package/contracts/workers/dvn/src/events.rs +1 -14
  299. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  300. package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
  301. package/contracts/workers/dvn/src/storage.rs +3 -13
  302. package/contracts/workers/dvn/src/tests/auth.rs +4 -4
  303. package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
  304. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
  305. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
  306. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
  307. package/contracts/workers/dvn/src/tests/setup.rs +5 -5
  308. package/contracts/workers/dvn-fee-lib/Cargo.toml +0 -1
  309. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +45 -16
  310. package/contracts/workers/dvn-fee-lib/src/errors.rs +3 -2
  311. package/contracts/workers/dvn-fee-lib/src/lib.rs +5 -11
  312. package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +30 -16
  313. package/contracts/workers/executor/src/auth.rs +80 -16
  314. package/contracts/workers/executor/src/executor.rs +17 -29
  315. package/contracts/workers/executor/src/storage.rs +2 -9
  316. package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
  317. package/contracts/workers/executor-fee-lib/src/errors.rs +9 -7
  318. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +153 -121
  319. package/contracts/workers/executor-helper/Cargo.toml +1 -6
  320. package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
  321. package/contracts/workers/executor-helper/src/lib.rs +1 -7
  322. package/contracts/workers/price-feed/Cargo.toml +1 -2
  323. package/contracts/workers/price-feed/src/errors.rs +3 -2
  324. package/contracts/workers/price-feed/src/lib.rs +5 -6
  325. package/contracts/workers/price-feed/src/price_feed.rs +42 -23
  326. package/contracts/workers/worker/Cargo.toml +4 -0
  327. package/contracts/workers/worker/src/errors.rs +4 -0
  328. package/contracts/workers/worker/src/interfaces/price_feed.rs +3 -3
  329. package/contracts/workers/worker/src/lib.rs +2 -2
  330. package/contracts/workers/worker/src/tests/mod.rs +4 -0
  331. package/contracts/workers/worker/src/tests/setup.rs +147 -0
  332. package/contracts/workers/worker/src/tests/worker.rs +502 -0
  333. package/contracts/workers/worker/src/worker.rs +28 -30
  334. package/package.json +8 -5
  335. package/sdk/.turbo/turbo-build.log +1 -0
  336. package/sdk/.turbo/turbo-test.log +1009 -0
  337. package/sdk/dist/generated/bml.d.ts +104 -37
  338. package/sdk/dist/generated/bml.js +83 -42
  339. package/sdk/dist/generated/counter.d.ts +334 -175
  340. package/sdk/dist/generated/counter.js +109 -63
  341. package/sdk/dist/generated/dvn.d.ts +1985 -0
  342. package/sdk/dist/generated/dvn.js +326 -0
  343. package/sdk/dist/generated/dvn_fee_lib.d.ts +690 -0
  344. package/sdk/dist/generated/dvn_fee_lib.js +163 -0
  345. package/sdk/dist/generated/endpoint.d.ts +155 -46
  346. package/sdk/dist/generated/endpoint.js +93 -50
  347. package/sdk/dist/generated/executor.d.ts +1841 -0
  348. package/sdk/dist/generated/executor.js +312 -0
  349. package/sdk/dist/generated/executor_fee_lib.d.ts +1083 -0
  350. package/sdk/dist/generated/executor_fee_lib.js +255 -0
  351. package/sdk/dist/generated/executor_helper.d.ts +981 -0
  352. package/sdk/dist/generated/executor_helper.js +236 -0
  353. package/sdk/dist/generated/oft_std.d.ts +1722 -0
  354. package/sdk/dist/generated/oft_std.js +316 -0
  355. package/sdk/dist/generated/price_feed.d.ts +1077 -0
  356. package/sdk/dist/generated/price_feed.js +210 -0
  357. package/sdk/dist/generated/sml.d.ts +171 -56
  358. package/sdk/dist/generated/sml.js +111 -62
  359. package/sdk/dist/generated/treasury.d.ts +896 -0
  360. package/sdk/dist/generated/treasury.js +219 -0
  361. package/sdk/dist/generated/uln302.d.ts +175 -75
  362. package/sdk/dist/generated/uln302.js +126 -82
  363. package/sdk/dist/generated/upgrader.d.ts +70 -0
  364. package/sdk/dist/generated/upgrader.js +19 -0
  365. package/sdk/dist/index.d.ts +10 -0
  366. package/sdk/dist/index.js +14 -0
  367. package/sdk/dist/wasm/blocked-message-lib.d.ts +1 -0
  368. package/sdk/dist/wasm/blocked-message-lib.js +2 -0
  369. package/sdk/dist/wasm/counter.d.ts +1 -0
  370. package/sdk/dist/wasm/counter.js +2 -0
  371. package/sdk/dist/wasm/dvn-fee-lib.d.ts +1 -0
  372. package/sdk/dist/wasm/dvn-fee-lib.js +2 -0
  373. package/sdk/dist/wasm/dvn.d.ts +1 -0
  374. package/sdk/dist/wasm/dvn.js +2 -0
  375. package/sdk/dist/wasm/endpoint-v2.d.ts +1 -0
  376. package/sdk/dist/wasm/endpoint-v2.js +2 -0
  377. package/sdk/dist/wasm/executor-fee-lib.d.ts +1 -0
  378. package/sdk/dist/wasm/executor-fee-lib.js +2 -0
  379. package/sdk/dist/wasm/executor-helper.d.ts +1 -0
  380. package/sdk/dist/wasm/executor-helper.js +2 -0
  381. package/sdk/dist/wasm/executor.d.ts +1 -0
  382. package/sdk/dist/wasm/executor.js +2 -0
  383. package/sdk/dist/wasm/layerzero-views.d.ts +1 -0
  384. package/sdk/dist/wasm/layerzero-views.js +2 -0
  385. package/sdk/dist/wasm/oft-std.d.ts +1 -0
  386. package/sdk/dist/wasm/oft-std.js +2 -0
  387. package/sdk/dist/wasm/price-feed.d.ts +1 -0
  388. package/sdk/dist/wasm/price-feed.js +2 -0
  389. package/sdk/dist/wasm/simple-message-lib.d.ts +1 -0
  390. package/sdk/dist/wasm/simple-message-lib.js +2 -0
  391. package/sdk/dist/wasm/treasury.d.ts +1 -0
  392. package/sdk/dist/wasm/treasury.js +2 -0
  393. package/sdk/dist/wasm/uln302.d.ts +1 -0
  394. package/sdk/dist/wasm/uln302.js +2 -0
  395. package/sdk/dist/wasm/upgrader.d.ts +1 -0
  396. package/sdk/dist/wasm/upgrader.js +2 -0
  397. package/sdk/dist/wasm.d.ts +15 -0
  398. package/sdk/dist/wasm.js +15 -0
  399. package/sdk/package.json +7 -4
  400. package/sdk/src/index.ts +17 -0
  401. package/sdk/test/counter-sml.test.ts +376 -0
  402. package/sdk/test/counter-uln.test.ts +493 -0
  403. package/sdk/test/{oft.test.ts → oft-sml.test.ts} +187 -323
  404. package/sdk/test/suites/constants.ts +22 -2
  405. package/sdk/test/suites/dummyContractClient.ts +169 -0
  406. package/sdk/test/suites/globalSetup.ts +450 -0
  407. package/sdk/test/suites/localnet.ts +23 -6
  408. package/sdk/test/upgrader.test.ts +300 -0
  409. package/sdk/test/utils.ts +558 -85
  410. package/sdk/vitest.config.ts +21 -0
  411. package/tools/ts-bindings-gen/src/main.rs +12 -1
  412. package/turbo.json +2 -0
  413. package/contracts/common-macros/src/contract_impl.rs +0 -47
  414. package/contracts/common-macros/src/ownable.rs +0 -59
  415. package/contracts/common-macros/src/tests/contract_impl.rs +0 -381
  416. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -32
  417. package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +0 -316
  418. package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +0 -388
  419. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +0 -162
  420. package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +0 -319
  421. package/contracts/oapp-macros/src/lib.rs +0 -154
  422. package/contracts/oapp-macros/src/oapp_core.rs +0 -40
  423. package/contracts/oapp-macros/src/oapp_full.rs +0 -21
  424. package/contracts/oapp-macros/src/oapp_options_type3.rs +0 -31
  425. package/contracts/oapp-macros/src/oapp_receiver.rs +0 -48
  426. package/contracts/oapp-macros/src/oapp_sender.rs +0 -21
  427. package/contracts/oapp-macros/src/util.rs +0 -107
  428. package/contracts/oapps/oft/src/constants.rs +0 -5
  429. package/contracts/oapps/oft/src/default_oft_impl.rs +0 -146
  430. package/contracts/utils/src/tests/ttl.rs +0 -421
  431. package/contracts/utils/src/ttl.rs +0 -123
  432. package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
  433. package/contracts/workers/dvn/src/multisig.rs +0 -153
  434. package/sdk/test/index.test.ts +0 -376
  435. /package/contracts/{oapp-macros → oapps/oapp-macros}/Cargo.toml +0 -0
@@ -1,23 +1,22 @@
1
- use crate as oapp;
2
- use crate::errors::OAppError;
3
- use crate::oapp_core::OAppCoreStorage;
4
- use crate::tests::test_oapp_core::DummyEndpoint;
1
+ use crate::{
2
+ self as oapp, errors::OAppError, oapp_core::OAppCoreStorage, oapp_receiver::LzReceiveInternal,
3
+ tests::test_oapp_core::DummyEndpoint,
4
+ };
5
5
  use endpoint_v2::Origin;
6
6
  use soroban_sdk::{assert_with_error, contractimpl, testutils::Address as _, Address, Bytes, BytesN, Env};
7
7
  use utils::option_ext::OptionExt;
8
- use utils::ownable::Ownable;
9
8
 
10
9
  #[oapp_macros::oapp]
11
10
  pub struct DummyOAppReceiver;
12
11
 
13
- impl DummyOAppReceiver {
12
+ impl LzReceiveInternal for DummyOAppReceiver {
14
13
  fn __lz_receive(
15
14
  _env: &Env,
16
- _executor: &Address,
17
15
  _origin: &Origin,
18
16
  _guid: &BytesN<32>,
19
17
  _message: &Bytes,
20
18
  _extra_data: &Bytes,
19
+ _executor: &Address,
21
20
  _value: i128,
22
21
  ) {
23
22
  // do nothing
@@ -27,7 +26,7 @@ impl DummyOAppReceiver {
27
26
  #[contractimpl]
28
27
  impl DummyOAppReceiver {
29
28
  pub fn __constructor(env: &Env, owner: &Address, endpoint: &Address) {
30
- oapp::oapp_core::oapp_initialize::<Self>(env, owner, endpoint, &None);
29
+ oapp::oapp_core::initialize_oapp::<Self>(env, owner, endpoint, &None);
31
30
  }
32
31
 
33
32
  pub fn assert_allowed_peer(env: &Env, origin: &Origin) {
@@ -1,13 +1,11 @@
1
- use crate as oapp;
2
- use crate::errors::OAppError;
3
- use endpoint_v2::{MessagingFee, MessagingParams, MessagingReceipt};
1
+ use crate::{self as oapp, errors::OAppError, oapp_receiver::LzReceiveInternal};
2
+ use endpoint_v2::{MessagingFee, MessagingParams, MessagingReceipt, Origin};
4
3
  use soroban_sdk::{
5
4
  contract, contractimpl, symbol_short,
6
5
  testutils::{Address as _, MockAuth, MockAuthInvoke},
7
6
  token::{StellarAssetClient, TokenClient},
8
7
  Address, Bytes, BytesN, Env, IntoVal,
9
8
  };
10
- use utils::ownable::Ownable;
11
9
 
12
10
  // Mock Endpoint contract
13
11
  #[contract]
@@ -50,14 +48,14 @@ impl MockEndpoint {
50
48
  #[oapp_macros::oapp]
51
49
  pub struct DummyOAppSender;
52
50
 
53
- impl DummyOAppSender {
51
+ impl LzReceiveInternal for DummyOAppSender {
54
52
  fn __lz_receive(
55
53
  _env: &Env,
56
- _executor: &Address,
57
- _origin: &endpoint_v2::Origin,
54
+ _origin: &Origin,
58
55
  _guid: &BytesN<32>,
59
56
  _message: &Bytes,
60
57
  _extra_data: &Bytes,
58
+ _executor: &Address,
61
59
  _value: i128,
62
60
  ) {
63
61
  // Not used in sender tests
@@ -67,11 +65,11 @@ impl DummyOAppSender {
67
65
  #[contractimpl]
68
66
  impl DummyOAppSender {
69
67
  pub fn __constructor(env: &Env, owner: &Address, endpoint: &Address) {
70
- oapp::oapp_core::oapp_initialize::<Self>(env, owner, endpoint, &None);
68
+ oapp::oapp_core::initialize_oapp::<Self>(env, owner, endpoint, &None);
71
69
  }
72
70
 
73
71
  pub fn quote(env: &Env, dst_eid: u32, message: &Bytes, options: &Bytes, pay_in_zro: bool) -> MessagingFee {
74
- Self::lz_quote(env, dst_eid, message, options, pay_in_zro)
72
+ Self::__quote(env, dst_eid, message, options, pay_in_zro)
75
73
  }
76
74
 
77
75
  pub fn send(
@@ -84,17 +82,17 @@ impl DummyOAppSender {
84
82
  refund_address: &Address,
85
83
  ) -> MessagingReceipt {
86
84
  sender.require_auth();
87
- Self::lz_send(env, sender, dst_eid, message, options, fee, refund_address)
85
+ Self::__lz_send(env, dst_eid, message, options, sender, fee, refund_address)
88
86
  }
89
87
 
90
- pub fn pay_native_fee(env: &Env, payer: &Address, native_fee: i128) {
91
- payer.require_auth();
92
- Self::pay_native(env, payer, native_fee)
88
+ pub fn pay_native_fee(env: &Env, fee_payer: &Address, native_fee: i128) {
89
+ fee_payer.require_auth();
90
+ Self::__pay_native(env, fee_payer, native_fee)
93
91
  }
94
92
 
95
- pub fn pay_zro_fee(env: &Env, payer: &Address, zro_fee: i128) {
96
- payer.require_auth();
97
- Self::pay_zro(env, payer, zro_fee)
93
+ pub fn pay_zro_fee(env: &Env, fee_payer: &Address, zro_fee: i128) {
94
+ fee_payer.require_auth();
95
+ Self::__pay_zro(env, fee_payer, zro_fee)
98
96
  }
99
97
  }
100
98
 
@@ -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
+ }
@@ -0,0 +1,211 @@
1
+ //! # OApp Procedural Macros
2
+ //!
3
+ //! This crate provides the `#[oapp]` procedural macro for implementing LayerZero OApp
4
+ //! (Omnichain Application) functionality on Soroban smart contracts.
5
+ //!
6
+ //! ## Overview
7
+ //!
8
+ //! The OApp framework provides full bidirectional cross-chain communication:
9
+ //!
10
+ //! - **OAppCore**: Foundation for all OApp functionality (peer management, endpoint access)
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)
14
+ //! - **OAppOptionsType3**: Manages enforced options for message execution parameters
15
+ //!
16
+ //! ## Usage
17
+ //!
18
+ //! ### `#[oapp]`
19
+ //! The main macro that provides Core + Sender + Receiver + OptionsType3 functionality.
20
+ //! This is the only macro you need for cross-chain communication.
21
+ //!
22
+ //! ### Custom Implementations
23
+ //!
24
+ //! By default, `#[oapp]` generates default trait implementations. Use `#[oapp(custom = [...])]`
25
+ //! to provide your own custom implementations for specific traits:
26
+ //!
27
+ //! Supported options:
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`
32
+ //!
33
+ //! ## Examples
34
+ //!
35
+ //! ### Full OApp with Default Implementations
36
+ //!
37
+ //! ```ignore
38
+ //! use oapp::oapp_receiver::LzReceiveInternal;
39
+ //! use oapp_macros::oapp;
40
+ //!
41
+ //! #[oapp]
42
+ //! struct MyOApp;
43
+ //!
44
+ //! // Implement LzReceiveInternal to handle incoming messages
45
+ //! impl LzReceiveInternal for MyOApp {
46
+ //! fn __lz_receive(
47
+ //! env: &Env,
48
+ //! origin: &Origin,
49
+ //! guid: &BytesN<32>,
50
+ //! message: &Bytes,
51
+ //! extra_data: &Bytes,
52
+ //! executor: &Address,
53
+ //! value: i128,
54
+ //! ) {
55
+ //! // Your message handling logic (clear_payload_and_transfer already called)
56
+ //! }
57
+ //! }
58
+ //! ```
59
+ //!
60
+ //! ### OApp with Custom Core Version
61
+ //!
62
+ //! ```ignore
63
+ //! use oapp::oapp_receiver::LzReceiveInternal;
64
+ //!
65
+ //! #[oapp(custom = [core])]
66
+ //! struct MyOApp;
67
+ //!
68
+ //! #[contractimpl(contracttrait)]
69
+ //! #[common_macros::ownable]
70
+ //! impl OAppCore for MyOApp {
71
+ //! fn oapp_version(_env: &Env) -> (u64, u64) {
72
+ //! (1, 1) // Custom version
73
+ //! }
74
+ //! }
75
+ //!
76
+ //! impl LzReceiveInternal for MyOApp {
77
+ //! fn __lz_receive(...) { /* ... */ }
78
+ //! }
79
+ //! ```
80
+ //!
81
+ //! ### OApp with Custom Receiver (e.g., ordered delivery)
82
+ //!
83
+ //! ```ignore
84
+ //! use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
85
+ //!
86
+ //! #[oapp(custom = [receiver])]
87
+ //! struct MyOrderedOApp;
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
+ //!
95
+ //! #[contractimpl(contracttrait)]
96
+ //! impl OAppReceiver for MyOrderedOApp {
97
+ //! fn next_nonce(env: &Env, src_eid: u32, sender: &BytesN<32>) -> u64 {
98
+ //! // Custom nonce logic for ordered delivery
99
+ //! Storage::max_received_nonce(env, src_eid, sender) + 1
100
+ //! }
101
+ //! // lz_receive uses default impl which calls clear_payload_and_transfer then __lz_receive
102
+ //! }
103
+ //! ```
104
+ //!
105
+ //! ### OApp with Multiple Custom Implementations
106
+ //!
107
+ //! ```ignore
108
+ //! use oapp::oapp_receiver::LzReceiveInternal;
109
+ //!
110
+ //! #[oapp(custom = [core, sender, options_type3])]
111
+ //! struct MyCustomOApp;
112
+ //!
113
+ //! #[contractimpl(contracttrait)]
114
+ //! #[common_macros::ownable]
115
+ //! impl OAppCore for MyCustomOApp { /* ... */ }
116
+ //! impl OAppSenderInternal for MyCustomOApp { /* ... */ }
117
+ //! #[contractimpl(contracttrait)]
118
+ //! impl OAppOptionsType3 for MyCustomOApp { /* ... */ }
119
+ //!
120
+ //! impl LzReceiveInternal for MyCustomOApp {
121
+ //! fn __lz_receive(...) { /* ... */ }
122
+ //! }
123
+ //! ```
124
+
125
+ mod generators;
126
+
127
+ use proc_macro::TokenStream;
128
+ use syn::{
129
+ bracketed,
130
+ parse::{Parse, ParseStream},
131
+ punctuated::Punctuated,
132
+ Error, Ident, ItemStruct, Token,
133
+ };
134
+
135
+ /// Derives a complete OApp: `#[contract]` + `#[ownable]` + Core + Sender + Receiver + OptionsType3.
136
+ ///
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.
156
+ #[proc_macro_attribute]
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()
161
+ }
162
+
163
+ /// Specifies which OApp trait implementations the user will provide themselves.
164
+ ///
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
+ }
211
+ }
@@ -7,14 +7,18 @@ extern crate std;
7
7
 
8
8
  use crate::integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address};
9
9
  use common_macros::contract_impl;
10
- use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer};
11
- use oft::oft::{oft_initialize, OFTClient, OFTInner, OFT};
12
- use oft::storage::OFTStorage;
13
- use oft::types::OFTReceipt;
10
+ use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer, Origin};
11
+ use oapp::oapp_receiver::LzReceiveInternal;
12
+ use oft::{
13
+ initialize_oft,
14
+ oft::{OFTClient, OFTInternal, OFT},
15
+ oft_impl,
16
+ storage::OFTStorage,
17
+ types::OFTReceipt,
18
+ };
14
19
  use simple_message_lib::{SimpleMessageLib, SimpleMessageLibClient};
15
- use soroban_sdk::contractimpl;
16
20
  use soroban_sdk::{
17
- contract, contracttype, log, symbol_short,
21
+ contract, contractimpl, contracttype, log, symbol_short,
18
22
  testutils::{Address as _, MockAuth, MockAuthInvoke},
19
23
  token::{StellarAssetClient, TokenClient},
20
24
  Address, Bytes, BytesN, Env, IntoVal,
@@ -27,17 +31,38 @@ use soroban_sdk::{
27
31
  #[oapp_macros::oapp]
28
32
  pub struct TestOFT;
29
33
 
34
+ impl LzReceiveInternal for TestOFT {
35
+ fn __lz_receive(
36
+ env: &Env,
37
+ origin: &Origin,
38
+ guid: &BytesN<32>,
39
+ message: &Bytes,
40
+ extra_data: &Bytes,
41
+ executor: &Address,
42
+ value: i128,
43
+ ) {
44
+ oft_impl::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
45
+ }
46
+ }
47
+
30
48
  #[contract_impl]
31
49
  impl TestOFT {
32
- pub fn __constructor(env: &Env, token: &Address, owner: &Address, endpoint: &Address, delegate: &Option<Address>, shared_decimals: u32) {
33
- oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
50
+ pub fn __constructor(
51
+ env: &Env,
52
+ token: &Address,
53
+ owner: &Address,
54
+ endpoint: &Address,
55
+ delegate: &Option<Address>,
56
+ shared_decimals: u32,
57
+ ) {
58
+ initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
34
59
  }
35
60
  }
36
61
 
37
62
  #[contractimpl(contracttrait)]
38
63
  impl OFT for TestOFT {}
39
64
 
40
- impl OFTInner for TestOFT {
65
+ impl OFTInternal for TestOFT {
41
66
  fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
42
67
  // Get the receipt (handles decimal conversion, fees, etc.)
43
68
  let receipt = Self::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
@@ -74,7 +74,7 @@ pub fn send(
74
74
  MockAuthInvoke {
75
75
  contract: &chain.oft_token,
76
76
  fn_name: "burn",
77
- args: (sender, &oft_receipt.amount_sent_ld).into_val(env),
77
+ args: (sender, &oft_receipt.amount_received_ld).into_val(env),
78
78
  sub_invokes: &[],
79
79
  },
80
80
  ],
@@ -1,8 +1,13 @@
1
1
  use common_macros::contract_error;
2
2
 
3
+ // OFT library error codes: 3000-3099
4
+ // See ERROR_SPEC.md for allocation rules
5
+
6
+ /// OFTError: 3000-3099
3
7
  #[contract_error]
4
8
  pub enum OFTError {
5
- InvalidLocalDecimals = 2100,
9
+ InvalidLocalDecimals = 3000,
10
+ NotInitialized,
6
11
  Overflow,
7
12
  SlippageExceeded,
8
13
  }
@@ -1,5 +1,5 @@
1
- use common_macros::{contract_error, only_owner, storage};
2
- use soroban_sdk::{assert_with_error, contractevent, contracttrait, token::TokenClient, Address, Env};
1
+ use common_macros::{contract_error, contract_trait, only_auth, storage};
2
+ use soroban_sdk::{assert_with_error, contractevent, token::TokenClient, Address, Env};
3
3
  use utils::{option_ext::OptionExt, ownable::Ownable};
4
4
 
5
5
  /// Base fee in basis points (10,000 BPS = 100%)
@@ -52,9 +52,9 @@ pub struct FeeDepositAddressSet {
52
52
  pub fee_deposit_address: Address,
53
53
  }
54
54
 
55
- #[contracttrait]
55
+ #[contract_trait]
56
56
  pub trait OFTFee: OFTFeeInternal + Ownable + Sized {
57
- #[only_owner]
57
+ #[only_auth]
58
58
  fn set_default_fee_bps(env: &Env, default_fee_bps: u64) {
59
59
  assert_with_error!(env, default_fee_bps <= BASE_FEE_BPS, OFTFeeError::InvalidFeeBps);
60
60
  let current_default = OFTFeeStorage::default_fee_bps(env);
@@ -63,7 +63,7 @@ pub trait OFTFee: OFTFeeInternal + Ownable + Sized {
63
63
  DefaultFeeBpsSet { fee_bps: default_fee_bps }.publish(env);
64
64
  }
65
65
 
66
- #[only_owner]
66
+ #[only_auth]
67
67
  fn set_fee_bps(env: &Env, dst_eid: u32, fee_bps: u64) {
68
68
  assert_with_error!(env, fee_bps <= BASE_FEE_BPS, OFTFeeError::InvalidFeeBps);
69
69
  if OFTFeeStorage::has_fee_bps(env, dst_eid) {
@@ -74,14 +74,14 @@ pub trait OFTFee: OFTFeeInternal + Ownable + Sized {
74
74
  FeeBpsSet { dst_eid, fee_bps }.publish(env);
75
75
  }
76
76
 
77
- #[only_owner]
77
+ #[only_auth]
78
78
  fn unset_fee_bps(env: &Env, dst_eid: u32) {
79
79
  assert_with_error!(env, OFTFeeStorage::has_fee_bps(env, dst_eid), OFTFeeError::NotFound);
80
80
  OFTFeeStorage::remove_fee_bps(env, dst_eid);
81
81
  FeeBpsUnset { dst_eid }.publish(env);
82
82
  }
83
83
 
84
- #[only_owner]
84
+ #[only_auth]
85
85
  fn set_fee_deposit_address(env: &Env, fee_deposit_address: Address) {
86
86
  if let Some(current_address) = OFTFeeStorage::fee_deposit_address(env) {
87
87
  assert_with_error!(env, current_address != fee_deposit_address, OFTFeeError::SameValue);
@@ -118,7 +118,7 @@ pub trait OFTFee: OFTFeeInternal + Ownable + Sized {
118
118
  /// Internal trait for OFT fee operations used by OFT hooks.
119
119
  /// Contains only truly internal methods that are called from OFTInner implementations.
120
120
  pub trait OFTFeeInternal {
121
- /// Applies the configured fee to the given amount and returns the amount after fee deduction.
121
+ /// Calculates the amount after fee deduction (read-only, mirrors `__debit_view`).
122
122
  /// Used internally by `__debit_view` to calculate amount after fee.
123
123
  ///
124
124
  /// # Arguments
@@ -127,7 +127,7 @@ pub trait OFTFeeInternal {
127
127
  ///
128
128
  /// # Returns
129
129
  /// The amount after fee deduction (original amount - calculated fee)
130
- fn __apply_fee(env: &Env, dst_eid: u32, amount_ld: i128) -> i128 {
130
+ fn __fee_view(env: &Env, dst_eid: u32, amount_ld: i128) -> i128 {
131
131
  // Calculate effective fee (destination-specific or default)
132
132
  let fee_bps = if OFTFeeStorage::has_fee_bps(env, dst_eid) {
133
133
  OFTFeeStorage::fee_bps(env, dst_eid).unwrap()
@@ -147,15 +147,15 @@ pub trait OFTFeeInternal {
147
147
  amount_ld - preliminary_fee
148
148
  }
149
149
 
150
- /// Transfers the fee amount from sender to the fee deposit address.
151
- /// Used internally by `__debit` to collect the fee after calculating the debit amounts.
150
+ /// Charges the fee by transferring the fee amount from sender to the fee deposit address.
151
+ /// Used internally by `__debit` to collect the fee (mirrors `__debit`).
152
152
  ///
153
153
  /// # Arguments
154
154
  /// * `token` - The token address to transfer
155
155
  /// * `sender` - The sender address to transfer fee from
156
156
  /// * `fee_amount` - The fee amount to transfer
157
- fn __transfer_fee(env: &Env, token: &Address, sender: &Address, fee_amount: i128) {
158
- if fee_amount > 0 {
157
+ fn __charge_fee(env: &Env, token: &Address, sender: &Address, fee_amount: i128) {
158
+ if fee_amount != 0 {
159
159
  assert_with_error!(
160
160
  env,
161
161
  OFTFeeStorage::fee_deposit_address(env).is_some(),
@@ -1,5 +1,5 @@
1
- use common_macros::{contract_error, only_owner, storage};
2
- use soroban_sdk::{assert_with_error, contractevent, contracttrait, Env};
1
+ use common_macros::{contract_error, contract_trait, only_auth, storage};
2
+ use soroban_sdk::{assert_with_error, contractevent, Env};
3
3
  use utils::ownable::Ownable;
4
4
 
5
5
  #[storage]
@@ -21,9 +21,9 @@ pub struct PausedSet {
21
21
  pub paused: bool,
22
22
  }
23
23
 
24
- #[contracttrait]
24
+ #[contract_trait]
25
25
  pub trait OFTPausable: OFTPausableInternal + Ownable + Sized {
26
- #[only_owner]
26
+ #[only_auth]
27
27
  fn set_paused(env: &Env, paused: bool) {
28
28
  let current_paused = OFTPausableStorage::paused(env);
29
29
  assert_with_error!(env, current_paused != paused, OFTPausableError::PauseStatusUnchanged);
@@ -37,7 +37,7 @@ pub trait OFTPausable: OFTPausableInternal + Ownable + Sized {
37
37
  }
38
38
 
39
39
  /// Internal trait for pausable operations used by OFT hooks.
40
- /// Contains only truly internal methods that are called from OFTInner implementations.
40
+ /// Contains only truly internal methods that are called from OFTInternal implementations.
41
41
  pub trait OFTPausableInternal {
42
42
  /// Asserts that the OFT is not paused, panics otherwise.
43
43
  /// Used internally by `send`, `quote_send`, and `__lz_receive` to enforce pause state.