@layerzerolabs/protocol-stellar-v2 0.2.12 → 0.2.15

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 (319) hide show
  1. package/.turbo/turbo-build.log +384 -278
  2. package/.turbo/turbo-lint.log +110 -78
  3. package/.turbo/turbo-test.log +1248 -1014
  4. package/Cargo.lock +130 -3
  5. package/Cargo.toml +2 -1
  6. package/contracts/common-macros/src/contract_impl.rs +6 -1
  7. package/contracts/common-macros/src/lib.rs +47 -8
  8. package/contracts/common-macros/src/ownable.rs +7 -25
  9. package/contracts/common-macros/src/storage.rs +1 -1
  10. package/contracts/common-macros/src/tests/contract_impl.rs +5 -0
  11. package/contracts/common-macros/src/tests/mod.rs +1 -0
  12. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap +23 -7
  13. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +5 -25
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +48 -48
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +5 -25
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +21 -0
  17. package/contracts/common-macros/src/tests/upgradeable.rs +31 -0
  18. package/contracts/common-macros/src/ttl_configurable.rs +14 -44
  19. package/contracts/common-macros/src/upgradeable.rs +76 -0
  20. package/contracts/endpoint-v2/src/endpoint_v2.rs +25 -1
  21. package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +175 -8
  22. package/contracts/endpoint-v2/src/tests/endpoint_v2/build_outbound_packet.rs +76 -0
  23. package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +342 -159
  24. package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +3 -15
  25. package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +20 -31
  26. package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +126 -164
  27. package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +1 -0
  28. package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +0 -1
  29. package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +0 -1
  30. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +311 -304
  31. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +423 -96
  32. package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +1 -1
  33. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +47 -20
  34. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +373 -403
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +96 -22
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +61 -9
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +4 -4
  38. package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +8 -11
  39. package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +81 -30
  40. package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +209 -76
  41. package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +0 -1
  42. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library.rs +24 -0
  43. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library_timeout.rs +40 -0
  44. package/contracts/endpoint-v2/src/tests/message_lib_manager/default_send_library.rs +24 -0
  45. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_config.rs +108 -0
  46. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_library_index.rs +52 -0
  47. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_receive_library.rs +92 -0
  48. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_registered_libraries.rs +74 -0
  49. package/contracts/endpoint-v2/src/tests/message_lib_manager/get_send_library.rs +83 -0
  50. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_registered_library.rs +32 -0
  51. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_supported_eid.rs +28 -0
  52. package/contracts/endpoint-v2/src/tests/message_lib_manager/is_valid_receive_library.rs +261 -0
  53. package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +16 -0
  54. package/contracts/endpoint-v2/src/tests/message_lib_manager/receive_library_timeout.rs +62 -0
  55. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +65 -43
  56. package/contracts/endpoint-v2/src/tests/message_lib_manager/registered_libraries_count.rs +42 -0
  57. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +61 -0
  58. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +3 -5
  59. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +59 -0
  60. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +15 -1
  61. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +155 -51
  62. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +114 -92
  63. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +235 -132
  64. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +93 -87
  65. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +346 -245
  66. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +406 -60
  67. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +252 -78
  68. package/contracts/endpoint-v2/src/tests/message_lib_manager/timeout.rs +102 -0
  69. package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +212 -273
  70. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +203 -0
  71. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +94 -0
  72. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +78 -248
  73. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +7 -282
  74. package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +6 -274
  75. package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +3 -2
  76. package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +86 -178
  77. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +328 -212
  78. package/contracts/endpoint-v2/src/tests/messaging_channel/outbound.rs +68 -0
  79. package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +6 -209
  80. package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +207 -159
  81. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +142 -153
  82. package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +6 -179
  83. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +163 -221
  84. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +90 -121
  85. package/contracts/endpoint-v2/src/tests/mock.rs +18 -4
  86. package/contracts/endpoint-v2/src/tests/util/build_payload.rs +4 -70
  87. package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +2 -1
  88. package/contracts/endpoint-v2/src/tests/util/keccak256.rs +17 -106
  89. package/contracts/layerzero-views/Cargo.toml +35 -0
  90. package/contracts/layerzero-views/src/errors.rs +10 -0
  91. package/contracts/layerzero-views/src/layerzero_view.rs +229 -0
  92. package/contracts/layerzero-views/src/lib.rs +38 -0
  93. package/contracts/layerzero-views/src/storage.rs +18 -0
  94. package/contracts/layerzero-views/src/tests/layerzero_view_tests.rs +423 -0
  95. package/contracts/layerzero-views/src/tests/mod.rs +4 -0
  96. package/contracts/layerzero-views/src/tests/setup.rs +377 -0
  97. package/contracts/layerzero-views/src/types.rs +50 -0
  98. package/contracts/macro-integration-tests/Cargo.toml +30 -0
  99. package/contracts/macro-integration-tests/src/lib.rs +1 -0
  100. package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +62 -0
  101. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +22 -0
  102. package/contracts/macro-integration-tests/tests/runtime/ownable/only_owner_guard.rs +97 -0
  103. package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +101 -0
  104. package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +225 -0
  105. package/contracts/macro-integration-tests/tests/runtime/storage/mod.rs +4 -0
  106. package/contracts/macro-integration-tests/tests/runtime/storage/name_override_runtime.rs +52 -0
  107. package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +261 -0
  108. package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +137 -0
  109. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +113 -0
  110. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +50 -0
  111. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +139 -0
  112. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +3 -0
  113. package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
  114. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +12 -0
  115. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +7 -0
  116. package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.rs +12 -0
  117. package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.stderr +7 -0
  118. package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.rs +21 -0
  119. package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.stderr +7 -0
  120. package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.rs +13 -0
  121. package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.stderr +7 -0
  122. package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +20 -0
  123. package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +15 -0
  124. package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +16 -0
  125. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.rs +22 -0
  126. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.stderr +16 -0
  127. package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +26 -0
  128. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +22 -0
  129. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_owner_env_param_variants.rs +46 -0
  130. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.rs +13 -0
  131. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +7 -0
  132. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.rs +13 -0
  133. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +7 -0
  134. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.rs +10 -0
  135. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.stderr +7 -0
  136. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.rs +12 -0
  137. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +7 -0
  138. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.rs +10 -0
  139. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.stderr +7 -0
  140. package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.rs +10 -0
  141. package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.stderr +7 -0
  142. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +12 -0
  143. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +7 -0
  144. package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.rs +13 -0
  145. package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.stderr +7 -0
  146. package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.rs +13 -0
  147. package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.stderr +7 -0
  148. package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +14 -0
  149. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +14 -0
  150. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +16 -0
  151. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +15 -0
  152. package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +14 -0
  153. package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +19 -0
  154. package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +15 -0
  155. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +44 -0
  156. package/contracts/macro-integration-tests/tests/ui_error.rs +11 -0
  157. package/contracts/macro-integration-tests/tests/ui_ownable.rs +11 -0
  158. package/contracts/macro-integration-tests/tests/ui_storage.rs +11 -0
  159. package/contracts/macro-integration-tests/tests/ui_ttl_configurable.rs +12 -0
  160. package/contracts/message-libs/blocked-message-lib/src/lib.rs +17 -17
  161. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +64 -0
  162. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet.rs +58 -0
  163. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet_header.rs +138 -0
  164. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/mod.rs +6 -0
  165. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload.rs +30 -0
  166. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload_hash.rs +15 -0
  167. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/test_helper.rs +39 -0
  168. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_dvn_option.rs +57 -0
  169. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +50 -0
  170. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +74 -0
  171. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +280 -0
  172. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +126 -0
  173. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +48 -0
  174. package/contracts/message-libs/message-lib-common/src/tests/worker_options/mod.rs +7 -0
  175. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +139 -0
  176. package/contracts/message-libs/message-lib-common/src/worker_options.rs +31 -1
  177. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +2 -2
  178. package/contracts/message-libs/treasury/src/errors.rs +0 -1
  179. package/contracts/message-libs/treasury/src/lib.rs +3 -3
  180. package/contracts/message-libs/treasury/src/storage.rs +2 -0
  181. package/contracts/message-libs/treasury/src/treasury.rs +12 -13
  182. package/contracts/message-libs/uln-302/Cargo.toml +1 -1
  183. package/contracts/message-libs/uln-302/src/errors.rs +0 -5
  184. package/contracts/message-libs/uln-302/src/events.rs +5 -6
  185. package/contracts/message-libs/uln-302/src/receive_uln.rs +24 -54
  186. package/contracts/message-libs/uln-302/src/send_uln.rs +89 -135
  187. package/contracts/message-libs/uln-302/src/storage.rs +5 -5
  188. package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +5 -7
  189. package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +3 -3
  190. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +6 -9
  191. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
  192. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +3 -3
  193. package/contracts/message-libs/uln-302/src/tests/setup.rs +9 -0
  194. package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +5 -0
  195. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +1 -2
  196. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +1 -2
  197. package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +37 -55
  198. package/contracts/message-libs/uln-302/src/uln302.rs +8 -5
  199. package/contracts/oapps/counter/src/counter.rs +0 -1
  200. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +306 -224
  201. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +0 -1
  202. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +0 -1
  203. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +0 -1
  204. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +0 -1
  205. package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_core.rs +1 -0
  206. package/contracts/oapps/oft/integration-tests/setup.rs +10 -3
  207. package/contracts/oapps/oft/integration-tests/utils.rs +1 -1
  208. package/contracts/oapps/oft/src/default_oft_impl.rs +9 -3
  209. package/contracts/oapps/oft/src/extensions/oft_fee.rs +5 -5
  210. package/contracts/oapps/oft/src/extensions/pausable.rs +1 -1
  211. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +18 -18
  212. package/contracts/oapps/oft/src/oft.rs +9 -9
  213. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
  214. package/contracts/oapps/oft/src/tests/extensions/setup.rs +26 -11
  215. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +1 -1
  216. package/contracts/oapps/oft/src/tests/test_send.rs +4 -4
  217. package/contracts/oapps/oft/src/tests/test_utils.rs +93 -74
  218. package/contracts/oapps/oft-std/Cargo.toml +6 -0
  219. package/contracts/oapps/oft-std/integration-tests/extensions/mod.rs +3 -0
  220. package/contracts/oapps/oft-std/integration-tests/extensions/test_oft_fee.rs +157 -0
  221. package/contracts/oapps/oft-std/integration-tests/extensions/test_pausable.rs +162 -0
  222. package/contracts/oapps/oft-std/integration-tests/extensions/test_rate_limiter.rs +186 -0
  223. package/contracts/oapps/oft-std/integration-tests/mod.rs +3 -0
  224. package/contracts/oapps/oft-std/integration-tests/setup.rs +245 -0
  225. package/contracts/oapps/oft-std/integration-tests/utils.rs +427 -0
  226. package/contracts/oapps/oft-std/src/lib.rs +12 -1
  227. package/contracts/oapps/oft-std/src/oft.rs +122 -25
  228. package/contracts/upgrader/Cargo.toml +19 -0
  229. package/contracts/upgrader/src/lib.rs +96 -0
  230. package/contracts/upgrader/src/tests/mod.rs +1 -0
  231. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
  232. package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
  233. package/contracts/upgrader/src/tests/test_upgrader.rs +120 -0
  234. package/contracts/utils/src/errors.rs +6 -1
  235. package/contracts/utils/src/lib.rs +2 -1
  236. package/contracts/utils/src/ownable.rs +49 -61
  237. package/contracts/utils/src/tests/mod.rs +3 -1
  238. package/contracts/utils/src/tests/option_ext.rs +21 -0
  239. package/contracts/utils/src/tests/ownable.rs +10 -69
  240. package/contracts/utils/src/tests/ttl_configurable.rs +596 -0
  241. package/contracts/utils/src/tests/upgradeable.rs +288 -0
  242. package/contracts/utils/src/{ttl.rs → ttl_configurable.rs} +67 -52
  243. package/contracts/utils/src/upgradeable.rs +54 -0
  244. package/contracts/workers/dvn/Cargo.toml +1 -1
  245. package/contracts/workers/dvn/src/auth.rs +21 -32
  246. package/contracts/workers/dvn/src/dvn.rs +40 -3
  247. package/contracts/workers/dvn/src/errors.rs +1 -0
  248. package/contracts/workers/dvn/src/multisig.rs +10 -6
  249. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +2 -2
  250. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +4 -4
  251. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -2
  252. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +46 -14
  253. package/contracts/workers/dvn-fee-lib/src/errors.rs +3 -2
  254. package/contracts/workers/dvn-fee-lib/src/lib.rs +5 -11
  255. package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +30 -16
  256. package/contracts/workers/executor/src/executor.rs +16 -2
  257. package/contracts/workers/executor-fee-lib/src/errors.rs +9 -7
  258. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +154 -119
  259. package/contracts/workers/executor-helper/Cargo.toml +0 -5
  260. package/contracts/workers/executor-helper/src/lib.rs +1 -7
  261. package/contracts/workers/price-feed/Cargo.toml +0 -1
  262. package/contracts/workers/price-feed/src/errors.rs +3 -2
  263. package/contracts/workers/price-feed/src/lib.rs +5 -6
  264. package/contracts/workers/price-feed/src/price_feed.rs +39 -17
  265. package/contracts/workers/worker/Cargo.toml +4 -0
  266. package/contracts/workers/worker/src/interfaces/price_feed.rs +3 -3
  267. package/contracts/workers/worker/src/lib.rs +2 -2
  268. package/contracts/workers/worker/src/tests/mod.rs +4 -0
  269. package/contracts/workers/worker/src/tests/setup.rs +147 -0
  270. package/contracts/workers/worker/src/tests/worker.rs +501 -0
  271. package/contracts/workers/worker/src/worker.rs +10 -16
  272. package/package.json +3 -3
  273. package/sdk/dist/generated/bml.d.ts +40 -30
  274. package/sdk/dist/generated/bml.js +16 -11
  275. package/sdk/dist/generated/counter.d.ts +168 -134
  276. package/sdk/dist/generated/counter.js +26 -21
  277. package/sdk/dist/generated/dvn.d.ts +1932 -0
  278. package/sdk/dist/generated/dvn.js +288 -0
  279. package/sdk/dist/generated/dvn_fee_lib.d.ts +615 -0
  280. package/sdk/dist/generated/dvn_fee_lib.js +123 -0
  281. package/sdk/dist/generated/endpoint.d.ts +75 -41
  282. package/sdk/dist/generated/endpoint.js +22 -17
  283. package/sdk/dist/generated/executor.d.ts +1809 -0
  284. package/sdk/dist/generated/executor.js +269 -0
  285. package/sdk/dist/generated/executor_fee_lib.d.ts +999 -0
  286. package/sdk/dist/generated/executor_fee_lib.js +208 -0
  287. package/sdk/dist/generated/executor_helper.d.ts +869 -0
  288. package/sdk/dist/generated/executor_helper.js +187 -0
  289. package/sdk/dist/generated/oft_std.d.ts +1544 -0
  290. package/sdk/dist/generated/oft_std.js +271 -0
  291. package/sdk/dist/generated/price_feed.d.ts +1002 -0
  292. package/sdk/dist/generated/price_feed.js +170 -0
  293. package/sdk/dist/generated/sml.d.ts +75 -41
  294. package/sdk/dist/generated/sml.js +22 -17
  295. package/sdk/dist/generated/uln302.d.ts +79 -60
  296. package/sdk/dist/generated/uln302.js +37 -37
  297. package/sdk/dist/generated/upgrader.d.ts +70 -0
  298. package/sdk/dist/generated/upgrader.js +19 -0
  299. package/sdk/dist/index.d.ts +8 -0
  300. package/sdk/dist/index.js +11 -0
  301. package/sdk/package.json +4 -3
  302. package/sdk/src/index.ts +13 -0
  303. package/sdk/test/index.test.ts +0 -1
  304. package/sdk/test/oft.test.ts +12 -23
  305. package/sdk/test/suites/testUpgradeable.ts +169 -0
  306. package/sdk/test/upgrader.test.ts +309 -0
  307. package/tools/ts-bindings-gen/src/main.rs +11 -1
  308. package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +0 -316
  309. package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +0 -388
  310. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +0 -162
  311. package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +0 -319
  312. package/contracts/utils/src/tests/ttl.rs +0 -421
  313. /package/contracts/{oapp-macros → oapps/oapp-macros}/Cargo.toml +0 -0
  314. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/lib.rs +0 -0
  315. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_full.rs +0 -0
  316. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_options_type3.rs +0 -0
  317. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_receiver.rs +0 -0
  318. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_sender.rs +0 -0
  319. /package/contracts/{oapp-macros → oapps/oapp-macros}/src/util.rs +0 -0
@@ -8,7 +8,7 @@ extern crate std;
8
8
  use crate::integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address};
9
9
  use common_macros::contract_impl;
10
10
  use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer};
11
- use oft::oft::{oft_initialize, OFTClient, OFTInner, OFT};
11
+ use oft::oft::{oft_initialize, OFTClient, OFTInternal, OFT};
12
12
  use oft::storage::OFTStorage;
13
13
  use oft::types::OFTReceipt;
14
14
  use simple_message_lib::{SimpleMessageLib, SimpleMessageLibClient};
@@ -29,7 +29,14 @@ pub struct TestOFT;
29
29
 
30
30
  #[contract_impl]
31
31
  impl TestOFT {
32
- pub fn __constructor(env: &Env, token: &Address, owner: &Address, endpoint: &Address, delegate: &Option<Address>, shared_decimals: u32) {
32
+ pub fn __constructor(
33
+ env: &Env,
34
+ token: &Address,
35
+ owner: &Address,
36
+ endpoint: &Address,
37
+ delegate: &Option<Address>,
38
+ shared_decimals: u32,
39
+ ) {
33
40
  oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
34
41
  }
35
42
  }
@@ -37,7 +44,7 @@ impl TestOFT {
37
44
  #[contractimpl(contracttrait)]
38
45
  impl OFT for TestOFT {}
39
46
 
40
- impl OFTInner for TestOFT {
47
+ impl OFTInternal for TestOFT {
41
48
  fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
42
49
  // Get the receipt (handles decimal conversion, fees, etc.)
43
50
  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
  ],
@@ -62,7 +62,7 @@ pub fn default_lz_receive<T>(
62
62
  _extra_data: &Bytes,
63
63
  _value: i128,
64
64
  ) where
65
- T: crate::oft::OFTInner,
65
+ T: crate::oft::OFTInternal,
66
66
  {
67
67
  let oft_msg = OFTMessage::decode(message);
68
68
  let send_to = resolve_address(env, &oft_msg.send_to);
@@ -91,11 +91,17 @@ pub fn default_lz_receive<T>(
91
91
  /// Returns (OFTLimit, fee details, receipt with estimated amounts).
92
92
  pub fn default_quote_oft<T>(env: &Env, send_param: &SendParam) -> (OFTLimit, Vec<OFTFeeDetail>, OFTReceipt)
93
93
  where
94
- T: crate::oft::OFTInner,
94
+ T: crate::oft::OFTInternal,
95
95
  {
96
96
  let oft_receipt = T::__debit_view(env, send_param.amount_ld, send_param.min_amount_ld, send_param.dst_eid);
97
97
  let oft_fee_details = if oft_receipt.amount_sent_ld > oft_receipt.amount_received_ld {
98
- vec![env, OFTFeeDetail { fee_amount_ld: oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld, description: Bytes::from_array(env, b"OFT Fee") }]
98
+ vec![
99
+ env,
100
+ OFTFeeDetail {
101
+ fee_amount_ld: oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld,
102
+ description: Bytes::from_array(env, b"OFT Fee"),
103
+ },
104
+ ]
99
105
  } else {
100
106
  vec![env]
101
107
  };
@@ -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,14 +147,14 @@ 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) {
157
+ fn __charge_fee(env: &Env, token: &Address, sender: &Address, fee_amount: i128) {
158
158
  if fee_amount > 0 {
159
159
  assert_with_error!(
160
160
  env,
@@ -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.
@@ -77,6 +77,16 @@ fn calculate_in_flight(env: &Env, direction: &Direction, eid: u32) -> i128 {
77
77
  }
78
78
  }
79
79
 
80
+ /// Checkpoints the current in-flight amount by applying decay and updating timestamp.
81
+ /// Used internally before modifying rate limit state.
82
+ fn checkpoint_rate_limit_in_flight(env: &Env, direction: &Direction, eid: u32) {
83
+ let in_flight = calculate_in_flight(env, direction, eid);
84
+ let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
85
+ rate_limit.in_flight_on_last_update = in_flight;
86
+ rate_limit.last_update = env.ledger().timestamp();
87
+ RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
88
+ }
89
+
80
90
  #[contracttrait]
81
91
  pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
82
92
  #[only_owner]
@@ -90,7 +100,7 @@ pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
90
100
  limit != rate_limit_data.limit || window_seconds != rate_limit_data.window_seconds,
91
101
  RateLimitError::SameValue
92
102
  );
93
- Self::__checkpoint_rate_limit_in_flight(env, direction, eid);
103
+ checkpoint_rate_limit_in_flight(env, direction, eid);
94
104
  let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
95
105
  rate_limit.limit = limit;
96
106
  rate_limit.window_seconds = window_seconds;
@@ -146,18 +156,18 @@ pub trait RateLimiter: RateLimiterInternal + Ownable + Sized {
146
156
  }
147
157
 
148
158
  /// Internal trait for rate limiter operations used by OFT hooks.
149
- /// Contains only truly internal methods that are called from OFTInner implementations.
159
+ /// Contains only truly internal methods that are called from OFTInternal implementations.
150
160
  pub trait RateLimiterInternal {
151
- /// Tries to consume the specified amount from the rate limit capacity.
152
- /// Used internally by `send` and `__lz_receive` to enforce rate limits.
161
+ /// Consumes the specified amount from the rate limit capacity.
162
+ /// Used internally by `__debit` and `__credit` to enforce rate limits.
153
163
  ///
154
164
  /// # Errors
155
165
  /// * `ExceededRateLimit` - If the amount exceeds the available capacity.
156
- fn __try_consume_rate_limit_capacity(env: &Env, direction: &Direction, eid: u32, amount: i128) {
166
+ fn __consume_rate_limit_capacity(env: &Env, direction: &Direction, eid: u32, amount: i128) {
157
167
  if !RateLimitStorage::has_rate_limit(env, direction, eid) {
158
168
  return;
159
169
  }
160
- Self::__checkpoint_rate_limit_in_flight(env, direction, eid);
170
+ checkpoint_rate_limit_in_flight(env, direction, eid);
161
171
  let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
162
172
  // Check against remaining capacity (limit - current in_flight), not total limit
163
173
  let capacity = if rate_limit.limit > rate_limit.in_flight_on_last_update {
@@ -173,12 +183,12 @@ pub trait RateLimiterInternal {
173
183
  }
174
184
 
175
185
  /// Releases the specified amount back to the rate limit capacity.
176
- /// Used internally by `__lz_receive` to release outbound capacity on inbound messages.
186
+ /// Used internally by `__credit` to release outbound capacity on inbound messages.
177
187
  fn __release_rate_limit_capacity(env: &Env, direction: &Direction, eid: u32, amount: i128) {
178
188
  if !RateLimitStorage::has_rate_limit(env, direction, eid) {
179
189
  return;
180
190
  }
181
- Self::__checkpoint_rate_limit_in_flight(env, direction, eid);
191
+ checkpoint_rate_limit_in_flight(env, direction, eid);
182
192
  let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
183
193
  if amount >= rate_limit.in_flight_on_last_update {
184
194
  rate_limit.in_flight_on_last_update = 0;
@@ -187,14 +197,4 @@ pub trait RateLimiterInternal {
187
197
  }
188
198
  RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
189
199
  }
190
-
191
- /// Checkpoints the current in-flight amount by applying decay and updating timestamp.
192
- /// Used internally before modifying rate limit state.
193
- fn __checkpoint_rate_limit_in_flight(env: &Env, direction: &Direction, eid: u32) {
194
- let in_flight = calculate_in_flight(env, direction, eid);
195
- let mut rate_limit = RateLimitStorage::rate_limit(env, direction, eid).unwrap();
196
- rate_limit.in_flight_on_last_update = in_flight;
197
- rate_limit.last_update = env.ledger().timestamp();
198
- RateLimitStorage::set_rate_limit(env, direction, eid, &rate_limit);
199
- }
200
200
  }
@@ -1,14 +1,14 @@
1
1
  //! OFT traits - the main interface for OFT contracts.
2
2
  //!
3
3
  //! This module provides two traits:
4
- //! - `OFTInner`: Internal methods NOT exposed as contract endpoints (`__debit`, `__credit`, etc.)
4
+ //! - `OFTInternal`: Internal methods NOT exposed as contract endpoints (`__debit`, `__credit`, etc.)
5
5
  //! - `OFT`: Public methods exposed as contract endpoints (using `#[contracttrait]`)
6
6
  //!
7
7
  //! ## Usage
8
8
  //!
9
9
  //! ```ignore
10
10
  //! use oapp_macros::{oapp, oapp_options_type3};
11
- //! use oft::oft::{oft_initialize, OFTInner, OFT};
11
+ //! use oft::oft::{oft_initialize, OFTInternal, OFT};
12
12
  //!
13
13
  //! #[oapp]
14
14
  //! pub struct MyOFT;
@@ -26,7 +26,7 @@
26
26
  //!
27
27
  //! // Internal methods - NOT exposed as contract endpoints
28
28
  //! // IMPORTANT: Do NOT use #[contractimpl] here to keep methods internal
29
- //! impl OFTInner for MyOFT {
29
+ //! impl OFTInternal for MyOFT {
30
30
  //! fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
31
31
  //! // Your debit logic (e.g., burn or lock tokens)
32
32
  //! oft::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
@@ -80,7 +80,7 @@ pub fn oft_initialize<T: OFT + OwnableInitializer>(
80
80
  }
81
81
 
82
82
  // =====================================================
83
- // OFTInner Trait (NOT exposed as contract endpoints)
83
+ // OFTInternal Trait (NOT exposed as contract endpoints)
84
84
  // =====================================================
85
85
 
86
86
  /// Internal OFT trait containing methods that should NOT be exposed as contract endpoints.
@@ -90,18 +90,18 @@ pub fn oft_initialize<T: OFT + OwnableInitializer>(
90
90
  ///
91
91
  /// ```ignore
92
92
  /// // Correct - methods stay internal
93
- /// impl OFTInner for MyOFT { ... }
93
+ /// impl OFTInternal for MyOFT { ... }
94
94
  ///
95
95
  /// // WRONG - would expose methods as endpoints
96
96
  /// #[contractimpl]
97
- /// impl OFTInner for MyOFT { ... }
97
+ /// impl OFTInternal for MyOFT { ... }
98
98
  /// ```
99
99
  ///
100
100
  /// Internal OFT trait for token debit/credit operations.
101
101
  ///
102
102
  /// This trait contains only the internal token operations. The OApp supertraits
103
103
  /// are on `OFT` instead, keeping this trait focused on token logic.
104
- pub trait OFTInner: OAppCore {
104
+ pub trait OFTInternal: OAppCore {
105
105
  // =========================================================================
106
106
  // Required Methods (no defaults - user MUST implement)
107
107
  // =========================================================================
@@ -175,9 +175,9 @@ pub trait OFTInner: OAppCore {
175
175
  /// contract endpoints. Users implement this with `#[contractimpl(contracttrait)]`.
176
176
  ///
177
177
  /// Internal methods like `__debit`, `__credit`, `__debit_view`, and `__build_msg_and_options`
178
- /// are in the `OFTInner` trait and are NOT exposed as contract endpoints.
178
+ /// are in the `OFTInternal` trait and are NOT exposed as contract endpoints.
179
179
  #[contracttrait(client_name = "OFTClient")]
180
- pub trait OFT: OFTInner + OAppReceiver + OAppSender + OAppOptionsType3 {
180
+ pub trait OFT: OFTInternal + OAppReceiver + OAppSender + OAppOptionsType3 {
181
181
  /// Retrieves the token address associated with this OFT.
182
182
  fn token(env: &Env) -> Address {
183
183
  OFTStorage::token(env).unwrap()
@@ -22,7 +22,7 @@ use crate::types::OFTReceipt;
22
22
  /// `OFTReceipt` containing the amount sent and amount received
23
23
  pub fn debit<T: OFT>(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
24
24
  let receipt: OFTReceipt = T::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
25
- TokenClient::new(env, &T::token(env)).transfer(sender, env.current_contract_address(), &receipt.amount_sent_ld);
25
+ TokenClient::new(env, &T::token(env)).transfer(sender, env.current_contract_address(), &receipt.amount_received_ld);
26
26
  receipt
27
27
  }
28
28
 
@@ -10,7 +10,7 @@ use crate::errors::OFTError;
10
10
  use crate::extensions::oft_fee::{OFTFee, OFTFeeInternal};
11
11
  use crate::extensions::pausable::{OFTPausable, OFTPausableInternal};
12
12
  use crate::extensions::rate_limiter::{Direction, RateLimiter, RateLimiterInternal};
13
- use crate::oft::{oft_initialize, OFTInner, OFT};
13
+ use crate::oft::{oft_initialize, OFTInternal, OFT};
14
14
  use crate::storage::OFTStorage;
15
15
  use crate::tests::test_utils::{
16
16
  create_recipient_address, DummyToken, MockEndpointWithCompose, MockEndpointWithComposeClient, DEFAULT_NATIVE_FEE,
@@ -73,31 +73,46 @@ impl OFT for ExtensiveOFT {
73
73
  }
74
74
 
75
75
  // Internal OFT implementation - NOT exposed as contract endpoints
76
- impl OFTInner for ExtensiveOFT {
76
+ impl OFTInternal for ExtensiveOFT {
77
77
  fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
78
+ // 1. Pausable check
78
79
  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);
80
+
81
+ // 2. Core debit logic
81
82
  let oft_receipt = crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid);
82
- Self::__transfer_fee(
83
+
84
+ // 3. Rate limit checks
85
+ Self::__consume_rate_limit_capacity(env, &Direction::Outbound, dst_eid, oft_receipt.amount_received_ld);
86
+ Self::__release_rate_limit_capacity(env, &Direction::Inbound, dst_eid, oft_receipt.amount_received_ld);
87
+
88
+ // 4. Charge fee
89
+ Self::__charge_fee(
83
90
  env,
84
91
  &Self::token(env),
85
92
  sender,
86
93
  oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld,
87
94
  );
95
+
88
96
  oft_receipt
89
97
  }
90
98
 
91
99
  fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
100
+ // 1. Pausable check
92
101
  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)
102
+
103
+ // 2. Core credit logic
104
+ let amount_credited = crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid);
105
+
106
+ // 3. Rate limit checks
107
+ Self::__consume_rate_limit_capacity(env, &Direction::Inbound, src_eid, amount_credited);
108
+ Self::__release_rate_limit_capacity(env, &Direction::Outbound, src_eid, amount_credited);
109
+
110
+ amount_credited
96
111
  }
97
112
 
98
113
  fn __debit_view(env: &Env, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
99
114
  let conversion_rate = OFTStorage::decimal_conversion_rate(env).unwrap();
100
- let amount_after_fee = Self::__apply_fee(env, dst_eid, amount_ld);
115
+ let amount_after_fee = Self::__fee_view(env, dst_eid, amount_ld);
101
116
  let amount_received_ld = remove_dust(amount_after_fee, conversion_rate);
102
117
  // Note: when no fee is applied, amount_send_ld is equal to amount_received_ld
103
118
  // this is to align the behavior with the fee extensions on other VMs
@@ -699,7 +714,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
699
714
  let fee_amount = oft_receipt.amount_sent_ld - oft_receipt.amount_received_ld;
700
715
 
701
716
  // Mock auth order must match contract execution order:
702
- // 1. Transfer fee (__transfer_fee) - happens before burn
717
+ // 1. Transfer fee (__charge_fee) - happens before burn
703
718
  // 2. Burn tokens (amount_received_ld, not amount_sent_ld)
704
719
  // 3. Transfer native/zro fees (__lz_send)
705
720
  self.env.mock_auths(&[MockAuth {
@@ -709,7 +724,7 @@ impl<'a> ExtensiveOFTTestSetup<'a> {
709
724
  fn_name: "send",
710
725
  args: (sender, send_param, fee, refund_address).into_val(self.env),
711
726
  sub_invokes: &[
712
- // 1. Transfer fee to fee deposit address - happens in __transfer_fee (BEFORE burn)
727
+ // 1. Transfer fee to fee deposit address - happens in __charge_fee (BEFORE burn)
713
728
  MockAuthInvoke {
714
729
  contract: &self.token,
715
730
  fn_name: "transfer",
@@ -376,7 +376,7 @@ fn test_consume_rate_limit_when_capacity_exactly_zero() {
376
376
  assert_eq!(setup.rate_limit_capacity(&Direction::Outbound, dst_eid), 0);
377
377
 
378
378
  // 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
379
+ // This tests the branch where capacity = 0 (limit <= in_flight) in __consume_rate_limit_capacity
380
380
  // Use amount that survives dust removal (conversion_rate = 10)
381
381
  let small_amount = 100i128;
382
382
  setup.fund_tokens(&sender, small_amount);
@@ -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,15 +2,11 @@
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
5
  use crate::codec::oft_msg_codec::OFTMessage;
8
- use crate::oft::{oft_initialize, OFTClient, OFTInner, OFT};
6
+ use crate::oft::OFTClient;
9
7
  use crate::types::{OFTReceipt, SendParam};
10
8
  use endpoint_v2::{LayerZeroReceiverClient, MessagingFee, MessagingParams, MessagingReceipt, Origin};
11
9
  use oapp::oapp_core::OAppCoreClient;
12
- use oapp::oapp_receiver::OAppReceiver;
13
- use oapp_macros::oapp_manual_impl;
14
10
  use soroban_sdk::{address_payload::AddressPayload, log, String};
15
11
  use soroban_sdk::{
16
12
  bytes, contract, contractimpl, symbol_short,
@@ -103,84 +99,105 @@ pub fn create_origin(src_eid: u32, sender: &BytesN<32>, nonce: u64) -> Origin {
103
99
  Origin { src_eid, sender: sender.clone(), nonce }
104
100
  }
105
101
 
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)
102
+ // ==================== Test OFT Contracts ====================
103
+
104
+ mod test_mint_burn_oft {
105
+ extern crate self as oft;
106
+
107
+ use crate::oft::{oft_initialize, OFTInternal, OFT};
108
+ use crate::types::OFTReceipt;
109
+ use soroban_sdk::{contractimpl, Address, Env};
110
+
111
+ #[oapp_macros::oapp]
112
+ pub struct TestMintBurnOFT;
113
+
114
+ #[contractimpl]
115
+ impl TestMintBurnOFT {
116
+ pub fn __constructor(
117
+ env: &Env,
118
+ token: &Address,
119
+ owner: &Address,
120
+ endpoint: &Address,
121
+ delegate: &Option<Address>,
122
+ shared_decimals: u32,
123
+ ) {
124
+ oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
125
+ }
122
126
  }
123
- }
124
127
 
125
- #[contractimpl(contracttrait)]
126
- impl OFT for TestMintBurnOFT {}
128
+ #[contractimpl(contracttrait)]
129
+ impl OFT for TestMintBurnOFT {}
127
130
 
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)
131
- }
131
+ impl OFTInternal for TestMintBurnOFT {
132
+ fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
133
+ crate::oft_types::mint_burn::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
134
+ }
132
135
 
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)
136
+ fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
137
+ crate::oft_types::mint_burn::credit::<Self>(env, to, amount_ld, src_eid)
138
+ }
135
139
  }
136
140
  }
137
-
138
- #[oapp_macros::oapp]
139
- #[oapp_manual_impl(receiver)]
140
- pub struct TestLockUnlockOFT;
141
-
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)
141
+ pub use test_mint_burn_oft::TestMintBurnOFT;
142
+
143
+ mod test_lock_unlock_oft {
144
+ extern crate self as oft;
145
+
146
+ use crate::oft::{oft_initialize, OFTInternal, OFT};
147
+ use crate::types::OFTReceipt;
148
+ use endpoint_v2::Origin;
149
+ use oapp::oapp_receiver::OAppReceiver;
150
+ use oapp_macros::oapp_manual_impl;
151
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
152
+
153
+ #[oapp_macros::oapp]
154
+ #[oapp_manual_impl(receiver)]
155
+ pub struct TestLockUnlockOFT;
156
+
157
+ #[contractimpl]
158
+ impl TestLockUnlockOFT {
159
+ pub fn __constructor(
160
+ env: &Env,
161
+ token: &Address,
162
+ owner: &Address,
163
+ endpoint: &Address,
164
+ delegate: &Option<Address>,
165
+ shared_decimals: u32,
166
+ ) {
167
+ oft_initialize::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
168
+ }
153
169
  }
154
- }
155
-
156
- #[contractimpl(contracttrait)]
157
- impl OFT for TestLockUnlockOFT {}
158
170
 
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);
171
+ #[contractimpl(contracttrait)]
172
+ impl OFT for TestLockUnlockOFT {}
173
+
174
+ #[contractimpl(contracttrait)]
175
+ impl OAppReceiver for TestLockUnlockOFT {
176
+ fn lz_receive(
177
+ env: &Env,
178
+ executor: &Address,
179
+ origin: &Origin,
180
+ guid: &BytesN<32>,
181
+ message: &Bytes,
182
+ extra_data: &Bytes,
183
+ value: i128,
184
+ ) {
185
+ oapp::oapp_receiver::verify_and_clear_payload::<Self>(env, executor, origin, guid, message, value);
186
+ Self::__lz_receive(env, executor, origin, guid, message, extra_data, value);
187
+ }
172
188
  }
173
- }
174
189
 
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)
178
- }
190
+ impl OFTInternal for TestLockUnlockOFT {
191
+ fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
192
+ crate::oft_types::lock_unlock::debit::<Self>(env, sender, amount_ld, min_amount_ld, dst_eid)
193
+ }
179
194
 
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)
195
+ fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
196
+ crate::oft_types::lock_unlock::credit::<Self>(env, to, amount_ld, src_eid)
197
+ }
182
198
  }
183
199
  }
200
+ pub use test_lock_unlock_oft::TestLockUnlockOFT;
184
201
 
185
202
  // ==================== Dummy Contracts ====================
186
203
 
@@ -664,17 +681,18 @@ impl<'a> OFTTestSetup<'a> {
664
681
  oft_receipt: &OFTReceipt,
665
682
  ) -> (MessagingReceipt, OFTReceipt) {
666
683
  // Token operation sub-invoke differs based on OFT type
684
+ // Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
667
685
  let token_sub_invoke = match self.oft_type {
668
686
  OFTType::MintBurn => MockAuthInvoke {
669
687
  contract: &self.token,
670
688
  fn_name: "burn",
671
- args: (sender, &oft_receipt.amount_sent_ld).into_val(self.env),
689
+ args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
672
690
  sub_invokes: &[],
673
691
  },
674
692
  OFTType::LockUnlock => MockAuthInvoke {
675
693
  contract: &self.token,
676
694
  fn_name: "transfer",
677
- args: (sender, &self.oft.address, &oft_receipt.amount_sent_ld).into_val(self.env),
695
+ args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
678
696
  sub_invokes: &[],
679
697
  },
680
698
  };
@@ -718,17 +736,18 @@ impl<'a> OFTTestSetup<'a> {
718
736
  Result<soroban_sdk::Error, soroban_sdk::InvokeError>,
719
737
  > {
720
738
  // Token operation sub-invoke differs based on OFT type
739
+ // Both MintBurn and LockUnlock use amount_received_ld (after fee/dust removal)
721
740
  let token_sub_invoke = match self.oft_type {
722
741
  OFTType::MintBurn => MockAuthInvoke {
723
742
  contract: &self.token,
724
743
  fn_name: "burn",
725
- args: (sender, &oft_receipt.amount_sent_ld).into_val(self.env),
744
+ args: (sender, &oft_receipt.amount_received_ld).into_val(self.env),
726
745
  sub_invokes: &[],
727
746
  },
728
747
  OFTType::LockUnlock => MockAuthInvoke {
729
748
  contract: &self.token,
730
749
  fn_name: "transfer",
731
- args: (sender, &self.oft.address, &oft_receipt.amount_sent_ld).into_val(self.env),
750
+ args: (sender, &self.oft.address, &oft_receipt.amount_received_ld).into_val(self.env),
732
751
  sub_invokes: &[],
733
752
  },
734
753
  };
@@ -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;