@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
@@ -5,21 +5,26 @@
5
5
 
6
6
  extern crate self as oft;
7
7
 
8
- use crate::default_oft_impl::{default_quote_oft, default_quote_send};
9
- use crate::errors::OFTError;
10
- use crate::extensions::oft_fee::{OFTFee, OFTFeeInternal};
11
- use crate::extensions::pausable::{OFTPausable, OFTPausableInternal};
12
- use crate::extensions::rate_limiter::{Direction, RateLimiter, RateLimiterInternal};
13
- use crate::oft::{oft_initialize, OFTInner, OFT};
14
- use crate::storage::OFTStorage;
15
- use crate::tests::test_utils::{
16
- create_recipient_address, DummyToken, MockEndpointWithCompose, MockEndpointWithComposeClient, DEFAULT_NATIVE_FEE,
17
- DEFAULT_SHARED_DECIMALS, DEFAULT_ZRO_FEE, INITIAL_MINT_AMOUNT,
8
+ use crate::{
9
+ errors::OFTError,
10
+ extensions::{
11
+ oft_fee::{OFTFee, OFTFeeInternal},
12
+ pausable::{OFTPausable, OFTPausableInternal},
13
+ rate_limiter::{Direction, RateLimiter, RateLimiterInternal},
14
+ },
15
+ initialize_oft,
16
+ oft::{OFTInternal, OFT},
17
+ oft_impl::{self, quote_oft, quote_send},
18
+ storage::OFTStorage,
19
+ tests::test_utils::{
20
+ create_recipient_address, DummyToken, MockEndpointWithCompose, MockEndpointWithComposeClient,
21
+ DEFAULT_NATIVE_FEE, DEFAULT_SHARED_DECIMALS, DEFAULT_ZRO_FEE, INITIAL_MINT_AMOUNT,
22
+ },
23
+ types::{OFTFeeDetail, OFTLimit, OFTReceipt, SendParam},
24
+ utils::remove_dust,
18
25
  };
19
- use crate::types::{OFTFeeDetail, OFTLimit, OFTReceipt, SendParam};
20
- use crate::utils::remove_dust;
21
26
  use endpoint_v2::{LayerZeroReceiverClient, MessagingFee, MessagingReceipt, Origin};
22
- use oapp::oapp_core::OAppCoreClient;
27
+ use oapp::{oapp_core::OAppCoreClient, oapp_receiver::LzReceiveInternal};
23
28
  use soroban_sdk::{
24
29
  assert_with_error, bytes, contractimpl, log,
25
30
  testutils::{Ledger, MockAuth, MockAuthInvoke},
@@ -33,6 +38,20 @@ use soroban_sdk::{
33
38
  #[oapp_macros::oapp]
34
39
  pub struct ExtensiveOFT;
35
40
 
41
+ impl LzReceiveInternal for ExtensiveOFT {
42
+ fn __lz_receive(
43
+ env: &Env,
44
+ origin: &Origin,
45
+ guid: &BytesN<32>,
46
+ message: &Bytes,
47
+ extra_data: &Bytes,
48
+ executor: &Address,
49
+ value: i128,
50
+ ) {
51
+ oft_impl::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
52
+ }
53
+ }
54
+
36
55
  #[contractimpl]
37
56
  impl ExtensiveOFT {
38
57
  pub fn __constructor(
@@ -43,7 +62,7 @@ impl ExtensiveOFT {
43
62
  delegate: &Option<Address>,
44
63
  shared_decimals: u32,
45
64
  ) {
46
- oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals);
65
+ initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals);
47
66
  }
48
67
  }
49
68
 
@@ -55,7 +74,7 @@ impl OFT for ExtensiveOFT {
55
74
  send_param: &crate::types::SendParam,
56
75
  ) -> (OFTLimit, soroban_sdk::Vec<OFTFeeDetail>, OFTReceipt) {
57
76
  Self::__assert_not_paused(env);
58
- let (_, fee_details, oft_receipt) = default_quote_oft::<Self>(env, send_param);
77
+ let (_, fee_details, oft_receipt) = quote_oft::<Self>(env, send_param);
59
78
  let capacity = Self::rate_limit_capacity(env, &Direction::Outbound, send_param.dst_eid);
60
79
  let oft_limit = OFTLimit { min_amount_ld: 0, max_amount_ld: capacity };
61
80
  (oft_limit, fee_details, oft_receipt)
@@ -68,36 +87,46 @@ impl OFT for ExtensiveOFT {
68
87
  pay_in_zro: bool,
69
88
  ) -> endpoint_v2::MessagingFee {
70
89
  Self::__assert_not_paused(env);
71
- default_quote_send::<Self>(env, sender, send_param, pay_in_zro)
90
+ quote_send::<Self>(env, sender, send_param, pay_in_zro)
72
91
  }
73
92
  }
74
93
 
75
94
  // Internal OFT implementation - NOT exposed as contract endpoints
76
- impl OFTInner for ExtensiveOFT {
95
+ impl OFTInternal for ExtensiveOFT {
77
96
  fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
97
+ // 1. Pausable check
78
98
  Self::__assert_not_paused(env);
79
- Self::__try_consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, amount_ld);
80
- Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, amount_ld);
99
+
100
+ // 2. Core debit logic
81
101
  let oft_receipt = crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid);
82
- Self::__transfer_fee(
83
- env,
84
- &Self::token(env),
85
- sender,
86
- oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld,
87
- );
102
+
103
+ // 3. Rate limit checks
104
+ Self::__consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, oft_receipt.amount_received_ld);
105
+ Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, oft_receipt.amount_received_ld);
106
+
107
+ // 4. Charge fee
108
+ Self::__charge_fee(env, &Self::token(env), sender, oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld);
109
+
88
110
  oft_receipt
89
111
  }
90
112
 
91
113
  fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
114
+ // 1. Pausable check
92
115
  Self::__assert_not_paused(env);
93
- Self::__try_consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_ld);
94
- Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_ld);
95
- crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
116
+
117
+ // 2. Core credit logic
118
+ let amount_credited = crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid);
119
+
120
+ // 3. Rate limit checks
121
+ Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_credited);
122
+ Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_credited);
123
+
124
+ amount_credited
96
125
  }
97
126
 
98
127
  fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
99
128
  let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap();
100
- let amount_after_fee = Self::__apply_fee(env, dst_eid, amount_ld);
129
+ let amount_after_fee = Self::__fee_view(env, dst_eid, amount_ld);
101
130
  let amount_received_ld = remove_dust(amount_after_fee, conversion_rate);
102
131
  // Note: when no fee is applied, amount_send_ld is equal to amount_received_ld
103
132
  // this is to align the behavior with the fee extensions on other VMs
@@ -699,7 +728,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
699
728
  let fee_amount = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
700
729
 
701
730
  // Mock auth order must match contract execution order:
702
- // 1. Transfer fee (__transfer_fee) - happens before burn
731
+ // 1. Transfer fee (__charge_fee) - happens before burn
703
732
  // 2. Burn tokens (amount_received_ld, not amount_sent_ld)
704
733
  // 3. Transfer native/zro fees (__lz_send)
705
734
  self.env.mock_auths(&[MockAuth {
@@ -709,7 +738,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
709
738
  fn_name: "send",
710
739
  args: (sender, send_param, fee, refund_address).into_val(self.env),
711
740
  sub_invokes: &[
712
- // 1. Transfer fee to fee deposit address - happens in __transfer_fee (BEFORE burn)
741
+ // 1. Transfer fee to fee deposit address - happens in __charge_fee (BEFORE burn)
713
742
  MockAuthInvoke {
714
743
  contract: &self.token,
715
744
  fn_name: "transfer",
@@ -6,9 +6,11 @@
6
6
  //! - Fee deduction and transfer in send
7
7
  //! - Fee deposit address configuration
8
8
 
9
- use crate::extensions::oft_fee::OFTFeeError;
10
- use crate::tests::test_utils::{create_origin, create_recipient_address, encode_oft_message};
11
- use crate::utils::address_to_bytes32;
9
+ use crate::{
10
+ extensions::oft_fee::OFTFeeError,
11
+ tests::test_utils::{create_origin, create_recipient_address, encode_oft_message},
12
+ utils::address_to_bytes32,
13
+ };
12
14
  use endpoint_v2::MessagingFee;
13
15
  use soroban_sdk::{testutils::Address as _, Address, Bytes, BytesN, Env, IntoVal};
14
16
 
@@ -6,9 +6,11 @@
6
6
  //! - `quote_send` is blocked
7
7
  //! - `quote_oft` works (view function, not blocked)
8
8
 
9
- use crate::extensions::pausable::OFTPausableError;
10
- use crate::tests::test_utils::{create_origin, create_recipient_address, encode_oft_message};
11
- use crate::utils::address_to_bytes32;
9
+ use crate::{
10
+ extensions::pausable::OFTPausableError,
11
+ tests::test_utils::{create_origin, create_recipient_address, encode_oft_message},
12
+ utils::address_to_bytes32,
13
+ };
12
14
  use endpoint_v2::MessagingFee;
13
15
  use soroban_sdk::{testutils::Address as _, Address, Bytes, BytesN, Env, IntoVal};
14
16
 
@@ -7,9 +7,11 @@
7
7
  //! - Rate limit enforcement on lz_receive (inbound)
8
8
  //! - Capacity release on opposite direction
9
9
 
10
- use crate::extensions::rate_limiter::{Direction, RateLimitError};
11
- use crate::tests::test_utils::{create_origin, create_recipient_address, encode_oft_message};
12
- use crate::utils::address_to_bytes32;
10
+ use crate::{
11
+ extensions::rate_limiter::{Direction, RateLimitError},
12
+ tests::test_utils::{create_origin, create_recipient_address, encode_oft_message},
13
+ utils::address_to_bytes32,
14
+ };
13
15
  use endpoint_v2::MessagingFee;
14
16
  use soroban_sdk::{
15
17
  testutils::{Address as _, Ledger as _},
@@ -376,7 +378,7 @@ fn test_consume_rate_limit_when_capacity_exactly_zero() {
376
378
  assert_eq!(setup.rate_limit_capacity(&Direction::Outbound, dst_eid), 0);
377
379
 
378
380
  // Try to send a small amount - should fail because capacity is exactly 0
379
- // This tests the branch where capacity = 0 (limit <= in_flight) in __try_consume_rate_limit_capacity
381
+ // This tests the branch where capacity = 0 (limit <= in_flight) in __consume_rate_limit_capacity
380
382
  // Use amount that survives dust removal (conversion_rate = 10)
381
383
  let small_amount = 100i128;
382
384
  setup.fund_tokens(&sender, small_amount);
@@ -17,7 +17,7 @@ fn test_decimal_conversion_rate() {
17
17
  }
18
18
 
19
19
  #[test]
20
- #[should_panic(expected = "Error(Contract, #2100)")] // InvalidLocalDecimals
20
+ #[should_panic(expected = "Error(Contract, #3000)")] // InvalidLocalDecimals
21
21
  fn test_invalid_local_decimals() {
22
22
  let env = Env::default();
23
23
  OFTTestSetupBuilder::new(&env).with_token_decimals(5).with_shared_decimals(6).build();
@@ -34,7 +34,7 @@ fn test_to_ld_overflow() {
34
34
  }
35
35
 
36
36
  #[test]
37
- #[should_panic(expected = "Error(Contract, #2101)")] // Overflow
37
+ #[should_panic(expected = "Error(Contract, #3002)")] // Overflow
38
38
  fn test_to_sd_overflow() {
39
39
  let env = Env::default();
40
40
 
@@ -1,5 +1,4 @@
1
- use crate::codec::oft_msg_codec::OFTMessage;
2
- use crate::utils::address_to_bytes32;
1
+ use crate::{codec::oft_msg_codec::OFTMessage, utils::address_to_bytes32};
3
2
  use soroban_sdk::{testutils::Address as _, Address, Bytes, BytesN, Env};
4
3
 
5
4
  #[test]
@@ -749,7 +749,7 @@ fn test_giving_partial_authorization_with_burn_wrong_arguments() {
749
749
  sub_invokes: &[MockAuthInvoke {
750
750
  contract: &setup.token,
751
751
  fn_name: "burn",
752
- args: (&sender, &oft_receipt.amount_sent_ld + 1).into_val(&env),
752
+ args: (&sender, &oft_receipt.amount_received_ld + 1).into_val(&env),
753
753
  sub_invokes: &[],
754
754
  }],
755
755
  },
@@ -794,7 +794,7 @@ fn test_giving_partial_authorization_without_native_fee_authorizations() {
794
794
  sub_invokes: &[MockAuthInvoke {
795
795
  contract: &setup.token,
796
796
  fn_name: "burn",
797
- args: (&sender, &oft_receipt.amount_sent_ld).into_val(&env),
797
+ args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
798
798
  sub_invokes: &[],
799
799
  }],
800
800
  },
@@ -840,7 +840,7 @@ fn test_giving_partial_authorization_without_zro_fee_authorizations() {
840
840
  MockAuthInvoke {
841
841
  contract: &setup.token,
842
842
  fn_name: "burn",
843
- args: (&sender, &oft_receipt.amount_sent_ld).into_val(&env),
843
+ args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
844
844
  sub_invokes: &[],
845
845
  },
846
846
  MockAuthInvoke {
@@ -893,7 +893,7 @@ fn test_giving_full_authorization() {
893
893
  MockAuthInvoke {
894
894
  contract: &setup.token,
895
895
  fn_name: "burn",
896
- args: (&sender, &oft_receipt.amount_sent_ld).into_val(&env),
896
+ args: (&sender, &oft_receipt.amount_received_ld).into_val(&env),
897
897
  sub_invokes: &[],
898
898
  },
899
899
  MockAuthInvoke {
@@ -2,21 +2,19 @@
2
2
  //!
3
3
  //! This module provides common test contracts and helpers used across multiple test files.
4
4
 
5
- extern crate self as oft;
6
-
7
- use crate::codec::oft_msg_codec::OFTMessage;
8
- use crate::oft::{oft_initialize, OFTClient, OFTInner, OFT};
9
- use crate::types::{OFTReceipt, SendParam};
5
+ use crate::{
6
+ codec::oft_msg_codec::OFTMessage,
7
+ oft::OFTClient,
8
+ types::{OFTReceipt, SendParam},
9
+ };
10
10
  use endpoint_v2::{LayerZeroReceiverClient, MessagingFee, MessagingParams, MessagingReceipt, Origin};
11
11
  use oapp::oapp_core::OAppCoreClient;
12
- use oapp::oapp_receiver::OAppReceiver;
13
- use oapp_macros::oapp_manual_impl;
14
- use soroban_sdk::{address_payload::AddressPayload, log, String};
15
12
  use soroban_sdk::{
16
- bytes, contract, contractimpl, symbol_short,
13
+ address_payload::AddressPayload,
14
+ bytes, contract, contractimpl, log, symbol_short,
17
15
  testutils::{Address as _, MockAuth, MockAuthInvoke},
18
16
  token::{StellarAssetClient, TokenClient},
19
- Address, Bytes, BytesN, Env, IntoVal, Symbol,
17
+ Address, Bytes, BytesN, Env, IntoVal, String, Symbol,
20
18
  };
21
19
  use stellar_macros::default_impl;
22
20
  use stellar_tokens::fungible::{Base, FungibleToken};
@@ -103,84 +101,125 @@ pub fn create_origin(src_eid: u32, sender: &BytesN<32>, nonce: u64) -> Origin {
103
101
  Origin { src_eid, sender: sender.clone(), nonce }
104
102
  }
105
103
 
106
- // ==================== Test OFT Contract ====================
107
-
108
- #[oapp_macros::oapp]
109
- pub struct TestMintBurnOFT;
110
-
111
- #[contractimpl]
112
- impl TestMintBurnOFT {
113
- pub fn __constructor(
114
- env: &Env,
115
- token: &Address,
116
- owner: &Address,
117
- endpoint: &Address,
118
- delegate: &Option<Address>,
119
- shared_decimals: u32,
120
- ) {
121
- oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
122
- }
123
- }
124
-
125
- #[contractimpl(contracttrait)]
126
- impl OFT for TestMintBurnOFT {}
127
-
128
- impl OFTInner for TestMintBurnOFT {
129
- fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
130
- crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
104
+ // ==================== Test OFT Contracts ====================
105
+
106
+ mod test_mint_burn_oft {
107
+ extern crate self as oft;
108
+
109
+ use crate::initialize_oft;
110
+ use crate::oft::{OFTInternal, OFT};
111
+ use crate::oft_impl;
112
+ use crate::types::OFTReceipt;
113
+ use endpoint_v2::Origin;
114
+ use oapp::oapp_receiver::LzReceiveInternal;
115
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
116
+
117
+ #[oapp_macros::oapp]
118
+ pub struct TestMintBurnOFT;
119
+
120
+ #[contractimpl]
121
+ impl TestMintBurnOFT {
122
+ pub fn __constructor(
123
+ env: &Env,
124
+ token: &Address,
125
+ owner: &Address,
126
+ endpoint: &Address,
127
+ delegate: &Option<Address>,
128
+ shared_decimals: u32,
129
+ ) {
130
+ initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
131
+ }
131
132
  }
132
133
 
133
- fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
134
- crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
134
+ #[contractimpl(contracttrait)]
135
+ impl OFT for TestMintBurnOFT {}
136
+
137
+ impl LzReceiveInternal for TestMintBurnOFT {
138
+ fn __lz_receive(
139
+ env: &Env,
140
+ origin: &Origin,
141
+ guid: &BytesN<32>,
142
+ message: &Bytes,
143
+ extra_data: &Bytes,
144
+ executor: &Address,
145
+ value: i128,
146
+ ) {
147
+ oft_impl::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
148
+ }
135
149
  }
136
- }
137
150
 
138
- #[oapp_macros::oapp]
139
- #[oapp_manual_impl(receiver)]
140
- pub struct TestLockUnlockOFT;
151
+ impl OFTInternal for TestMintBurnOFT {
152
+ fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
153
+ crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
154
+ }
141
155
 
142
- #[contractimpl]
143
- impl TestLockUnlockOFT {
144
- pub fn __constructor(
145
- env: &Env,
146
- token: &Address,
147
- owner: &Address,
148
- endpoint: &Address,
149
- delegate: &Option<Address>,
150
- shared_decimals: u32,
151
- ) {
152
- oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
156
+ fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
157
+ crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
158
+ }
153
159
  }
154
160
  }
155
-
156
- #[contractimpl(contracttrait)]
157
- impl OFT for TestLockUnlockOFT {}
158
-
159
- #[contractimpl(contracttrait)]
160
- impl OAppReceiver for TestLockUnlockOFT {
161
- fn lz_receive(
162
- env: &Env,
163
- executor: &Address,
164
- origin: &Origin,
165
- guid: &BytesN<32>,
166
- message: &Bytes,
167
- extra_data: &Bytes,
168
- value: i128,
169
- ) {
170
- oapp::oapp_receiver::verify_and_clear_payload::<Self>(env, executor, origin, guid, message, value);
171
- Self::__lz_receive(env, executor, origin, guid, message, extra_data, value);
161
+ pub use test_mint_burn_oft::TestMintBurnOFT;
162
+
163
+ mod test_lock_unlock_oft {
164
+ extern crate self as oft;
165
+
166
+ use crate::initialize_oft;
167
+ use crate::oft::{OFTInternal, OFT};
168
+ use crate::oft_impl;
169
+ use crate::types::OFTReceipt;
170
+ use endpoint_v2::Origin;
171
+ use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
172
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
173
+
174
+ #[oapp_macros::oapp(custom = [receiver])]
175
+ pub struct TestLockUnlockOFT;
176
+
177
+ #[contractimpl]
178
+ impl TestLockUnlockOFT {
179
+ pub fn __constructor(
180
+ env: &Env,
181
+ token: &Address,
182
+ owner: &Address,
183
+ endpoint: &Address,
184
+ delegate: &Option<Address>,
185
+ shared_decimals: u32,
186
+ ) {
187
+ initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
188
+ }
172
189
  }
173
- }
174
190
 
175
- impl OFTInner for TestLockUnlockOFT {
176
- fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
177
- crate::oft_types::lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
191
+ #[contractimpl(contracttrait)]
192
+ impl OFT for TestLockUnlockOFT {}
193
+
194
+ impl LzReceiveInternal for TestLockUnlockOFT {
195
+ fn __lz_receive(
196
+ env: &Env,
197
+ origin: &Origin,
198
+ guid: &BytesN<32>,
199
+ message: &Bytes,
200
+ extra_data: &Bytes,
201
+ executor: &Address,
202
+ value: i128,
203
+ ) {
204
+ oft_impl::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
205
+ }
178
206
  }
179
207
 
180
- fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
181
- crate::oft_types::lock_unlock::credit::<Self>(env, to, amount_ld, src_eid)
208
+ // Custom receiver to demonstrate overriding next_nonce or other methods
209
+ #[contractimpl(contracttrait)]
210
+ impl OAppReceiver for TestLockUnlockOFT {}
211
+
212
+ impl OFTInternal for TestLockUnlockOFT {
213
+ fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
214
+ crate::oft_types::lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
215
+ }
216
+
217
+ fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
218
+ crate::oft_types::lock_unlock::credit::<Self>(env, to, amount_ld, src_eid)
219
+ }
182
220
  }
183
221
  }
222
+ pub use test_lock_unlock_oft::TestLockUnlockOFT;
184
223
 
185
224
  // ==================== Dummy Contracts ====================
186
225
 
@@ -248,12 +287,12 @@ impl MockEndpointWithCompose {
248
287
  env.storage().instance().set(&symbol_short!("zro"), &zro_token);
249
288
  }
250
289
 
251
- /// Returns the native token address (required by OAppSender)
290
+ /// Returns the native token address (required by OAppSenderInternal)
252
291
  pub fn native_token(env: Env) -> Address {
253
292
  env.storage().instance().get(&symbol_short!("ntk")).unwrap()
254
293
  }
255
294
 
256
- /// Returns the ZRO token address (required by OAppSender)
295
+ /// Returns the ZRO token address (required by OAppSenderInternal)
257
296
  pub fn zro(env: Env) -> Option<Address> {
258
297
  env.storage().instance().get(&symbol_short!("zro"))
259
298
  }
@@ -664,17 +703,18 @@ impl<'a> OFTTestSetup<'a> {
664
703
  oft_receipt: &OFTReceipt,
665
704
  ) -> (MessagingReceipt, OFTReceipt) {
666
705
  // Token operation sub-invoke differs based on OFT type
706
+ // Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
667
707
  let token_sub_invoke = match self.oft_type {
668
708
  OFTType::MintBurn => MockAuthInvoke {
669
709
  contract: &self.token,
670
710
  fn_name: "burn",
671
- args: (sender, &oft_receipt.amount_sent_ld).into_val(self.env),
711
+ args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
672
712
  sub_invokes: &[],
673
713
  },
674
714
  OFTType::LockUnlock => MockAuthInvoke {
675
715
  contract: &self.token,
676
716
  fn_name: "transfer",
677
- args: (sender, &self.oft.address, &oft_receipt.amount_sent_ld).into_val(self.env),
717
+ args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
678
718
  sub_invokes: &[],
679
719
  },
680
720
  };
@@ -718,17 +758,18 @@ impl<'a> OFTTestSetup<'a> {
718
758
  Result<soroban_sdk::Error, soroban_sdk::InvokeError>,
719
759
  > {
720
760
  // Token operation sub-invoke differs based on OFT type
761
+ // Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
721
762
  let token_sub_invoke = match self.oft_type {
722
763
  OFTType::MintBurn => MockAuthInvoke {
723
764
  contract: &self.token,
724
765
  fn_name: "burn",
725
- args: (sender, &oft_receipt.amount_sent_ld).into_val(self.env),
766
+ args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
726
767
  sub_invokes: &[],
727
768
  },
728
769
  OFTType::LockUnlock => MockAuthInvoke {
729
770
  contract: &self.token,
730
771
  fn_name: "transfer",
731
- args: (sender, &self.oft.address, &oft_receipt.amount_sent_ld).into_val(self.env),
772
+ args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
732
773
  sub_invokes: &[],
733
774
  },
734
775
  };
@@ -1,15 +1,28 @@
1
1
  use soroban_sdk::{contracttype, Bytes, BytesN};
2
2
 
3
+ /// Message type for simple OFT send
4
+ pub const SEND: u32 = 1;
5
+
6
+ /// Message type for OFT send with compose functionality
7
+ pub const SEND_AND_CALL: u32 = 2;
8
+
3
9
  /// Parameters for sending OFT tokens cross-chain
4
10
  #[contracttype]
5
11
  #[derive(Clone, PartialEq, Eq, Debug)]
6
12
  pub struct SendParam {
13
+ /// The destination endpoint ID
7
14
  pub dst_eid: u32,
15
+ /// The recipient address on the destination chain (32 bytes)
8
16
  pub to: BytesN<32>,
17
+ /// The amount to send in local decimals
9
18
  pub amount_ld: i128,
19
+ /// The minimum amount to receive in local decimals (slippage protection)
10
20
  pub min_amount_ld: i128,
21
+ /// Additional options for the LayerZero message (Optional)
11
22
  pub extra_options: Bytes,
23
+ /// Compose message to execute on the destination (Optional)
12
24
  pub compose_msg: Bytes,
25
+ /// OFT command for custom behavior (Optional)
13
26
  pub oft_cmd: Bytes,
14
27
  }
15
28
 
@@ -17,7 +30,9 @@ pub struct SendParam {
17
30
  #[contracttype]
18
31
  #[derive(Clone, PartialEq, Eq, Debug)]
19
32
  pub struct OFTLimit {
33
+ /// The minimum amount to send in local decimals
20
34
  pub min_amount_ld: i128,
35
+ /// The maximum amount to send in local decimals
21
36
  pub max_amount_ld: i128,
22
37
  }
23
38
 
@@ -25,7 +40,9 @@ pub struct OFTLimit {
25
40
  #[contracttype]
26
41
  #[derive(Clone, PartialEq, Eq, Debug)]
27
42
  pub struct OFTReceipt {
43
+ /// The amount sent in local decimals
28
44
  pub amount_sent_ld: i128,
45
+ /// The amount received in local decimals on the remote
29
46
  pub amount_received_ld: i128,
30
47
  }
31
48
 
@@ -33,6 +50,9 @@ pub struct OFTReceipt {
33
50
  #[contracttype]
34
51
  #[derive(Clone, PartialEq, Eq, Debug)]
35
52
  pub struct OFTFeeDetail {
53
+ /// The amount of the fee in local decimals. Positive values represent fees charged,
54
+ /// while negative values represent rewards given.
36
55
  pub fee_amount_ld: i128,
56
+ /// The description of the fee
37
57
  pub description: Bytes,
38
58
  }
@@ -17,3 +17,9 @@ common-macros = { workspace = true }
17
17
  oapp-macros = { workspace = true }
18
18
  oft = { workspace = true }
19
19
 
20
+ [dev-dependencies]
21
+ soroban-sdk = { workspace = true, features = ["testutils"] }
22
+ simple-message-lib = { workspace = true }
23
+ message-lib-common = { workspace = true, features = ["testutils"] }
24
+ endpoint-v2 = { workspace = true, features = ["testutils"] }
25
+ utils = { workspace = true, features = ["testutils"] }
@@ -0,0 +1,3 @@
1
+ mod test_oft_fee;
2
+ mod test_pausable;
3
+ mod test_rate_limiter;