@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,12 +8,14 @@
8
8
  use crate::{
9
9
  errors::DvnError, events::SetDstConfig, storage::DvnStorage, Call, DstConfig, DstConfigParam, IMultisig, IDVN,
10
10
  };
11
- use common_macros::{contract_impl, ttl_configurable};
11
+ use common_macros::{contract_impl, ttl_configurable, upgradeable};
12
12
  use endpoint_v2::FeeRecipient;
13
13
  use message_lib_common::interfaces::ILayerZeroDVN;
14
+ use soroban_sdk::panic_with_error;
14
15
  use soroban_sdk::{contract, xdr::ToXdr, Address, Bytes, BytesN, Env, Vec};
15
- use utils::buffer_writer::BufferWriter;
16
16
  use utils::option_ext::OptionExt;
17
+ use utils::{buffer_writer::BufferWriter, ownable::Ownable};
18
+ use utils::upgradeable::UpgradeableInternal;
17
19
  use worker::{
18
20
  assert_acl, assert_not_paused, assert_supported_message_lib, init_worker, require_admin_auth, set_admin_by_admin,
19
21
  set_admin_by_owner, DvnFeeLibClient, DvnFeeParams, Worker,
@@ -25,6 +27,7 @@ use worker::{
25
27
  /// The contract owns itself, allowing the multisig quorum to authorize operations.
26
28
  #[contract]
27
29
  #[ttl_configurable]
30
+ #[upgradeable]
28
31
  pub struct LzDVN;
29
32
 
30
33
  // ============================================================================
@@ -58,7 +61,6 @@ impl LzDVN {
58
61
  deposit_address: &Address,
59
62
  ) {
60
63
  Self::init_multisig(env, signers, threshold);
61
- Self::init_owner(env, &env.current_contract_address());
62
64
  init_worker::<Self>(
63
65
  env,
64
66
  admins,
@@ -200,9 +202,44 @@ impl ILayerZeroDVN for LzDVN {
200
202
  // Worker Implementation
201
203
  // ============================================================================
202
204
 
205
+ /// Worker trait implementation using default methods for pause, admin, ACL, and fee configuration.
203
206
  #[contract_impl(contracttrait)]
204
207
  impl Worker for LzDVN {}
205
208
 
209
+ // ============================================================================
210
+ // Upgradeable Implementation
211
+ // ============================================================================
212
+
213
+ impl UpgradeableInternal for LzDVN {
214
+ type MigrationData = ();
215
+
216
+ fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
217
+ // No migration logic needed for initial upgrade capability
218
+ }
219
+ }
220
+
221
+ // ============================================================================
222
+ // Ownable impl for LzDVN
223
+ // ============================================================================
224
+
225
+ /// Self-owning contract: the DVN owns itself.
226
+ ///
227
+ /// This allows multisig quorum approval to serve as owner authorization.
228
+ /// Ownership transfer and renouncement are disabled since the contract is self-owned.
229
+ impl Ownable for LzDVN {
230
+ fn owner(env: &Env) -> Option<Address> {
231
+ Some(env.current_contract_address())
232
+ }
233
+
234
+ fn transfer_ownership(env: &Env, _new_owner: &Address) {
235
+ panic_with_error!(env, DvnError::InvalidInvocation);
236
+ }
237
+
238
+ fn renounce_ownership(env: &Env) {
239
+ panic_with_error!(env, DvnError::InvalidInvocation);
240
+ }
241
+ }
242
+
206
243
  // ============================================================================
207
244
  // Include SubModules
208
245
  // ============================================================================
@@ -5,6 +5,7 @@ pub enum DvnError {
5
5
  AuthDataExpired,
6
6
  EidNotSupported,
7
7
  HashAlreadyUsed,
8
+ InvalidInvocation,
8
9
  InvalidSigner,
9
10
  InvalidVid,
10
11
  NonContractInvoke,
@@ -10,6 +10,7 @@ use crate::{
10
10
  events::{SignerSet, ThresholdSet},
11
11
  storage::DvnStorage,
12
12
  };
13
+ use common_macros::only_owner;
13
14
  use soroban_sdk::assert_with_error;
14
15
 
15
16
  // ============================================================================
@@ -18,9 +19,9 @@ use soroban_sdk::assert_with_error;
18
19
 
19
20
  #[contract_impl]
20
21
  impl IMultisig for LzDVN {
21
- /// Adds or removes a signer. Requires contract self-authorization (quorum).
22
+ /// Adds or removes a signer. Requires multisig approval.
23
+ #[only_owner]
22
24
  fn set_signer(env: &Env, signer: &BytesN<20>, active: bool) {
23
- env.current_contract_address().require_auth();
24
25
  if active {
25
26
  Self::add_signer(env, signer);
26
27
  } else {
@@ -28,10 +29,9 @@ impl IMultisig for LzDVN {
28
29
  }
29
30
  }
30
31
 
31
- /// Updates the signature threshold. Requires contract self-authorization (quorum).
32
+ /// Updates the signature threshold. Requires multisig approval.
33
+ #[only_owner]
32
34
  fn set_threshold(env: &Env, threshold: u32) {
33
- env.current_contract_address().require_auth();
34
-
35
35
  assert_with_error!(env, threshold > 0, DvnError::ZeroThreshold);
36
36
  assert_with_error!(env, Self::total_signers(env) >= threshold, DvnError::TotalSignersLessThanThreshold);
37
37
 
@@ -40,6 +40,10 @@ impl IMultisig for LzDVN {
40
40
  ThresholdSet { threshold }.publish(env);
41
41
  }
42
42
 
43
+ // ================================================================
44
+ // View Functions
45
+ // ================================================================
46
+
43
47
  /// Returns the list of all registered signers.
44
48
  fn get_signers(env: &Env) -> Vec<BytesN<20>> {
45
49
  DvnStorage::signers(env)
@@ -94,7 +98,7 @@ impl IMultisig for LzDVN {
94
98
  impl LzDVN {
95
99
  /// Initializes the multisig with a set of signers and threshold.
96
100
  /// Called during contract construction.
97
- pub fn init_multisig(env: &Env, signers: &Vec<BytesN<20>>, threshold: u32) {
101
+ pub(super) fn init_multisig(env: &Env, signers: &Vec<BytesN<20>>, threshold: u32) {
98
102
  signers.iter().for_each(|signer| Self::add_signer(env, &signer));
99
103
  Self::set_threshold(env, threshold);
100
104
  }
@@ -90,7 +90,7 @@ fn test_set_threshold_with_no_signers_fails() {
90
90
  }
91
91
 
92
92
  #[test]
93
- #[should_panic(expected = "Error(Contract, #13)")] // DvnError::ZeroThreshold
93
+ #[should_panic(expected = "Error(Contract, #14)")] // DvnError::ZeroThreshold
94
94
  fn test_constructor_threshold_zero_panics() {
95
95
  let env = Env::default();
96
96
  env.mock_all_auths();
@@ -99,7 +99,7 @@ fn test_constructor_threshold_zero_panics() {
99
99
  }
100
100
 
101
101
  #[test]
102
- #[should_panic(expected = "Error(Contract, #11)")] // DvnError::TotalSignersLessThanThreshold
102
+ #[should_panic(expected = "Error(Contract, #12)")] // DvnError::TotalSignersLessThanThreshold
103
103
  fn test_constructor_signers_less_than_threshold_panics() {
104
104
  let env = Env::default();
105
105
  env.mock_all_auths();
@@ -59,7 +59,7 @@ fn test_verify_signatures_raw_v_path() {
59
59
  }
60
60
 
61
61
  #[test]
62
- #[should_panic(expected = "Error(Contract, #10)")] // DvnError::SignerNotFound
62
+ #[should_panic(expected = "Error(Contract, #11)")] // DvnError::SignerNotFound
63
63
  fn test_verify_signatures_with_wrong_signer() {
64
64
  let setup = TestSetup::new(1);
65
65
  let digest = hash(&setup.env, b"test");
@@ -71,7 +71,7 @@ fn test_verify_signatures_with_wrong_signer() {
71
71
  }
72
72
 
73
73
  #[test]
74
- #[should_panic(expected = "Error(Contract, #8)")] // DvnError::SignatureError
74
+ #[should_panic(expected = "Error(Contract, #9)")] // DvnError::SignatureError
75
75
  fn test_verify_signatures_insufficient_signatures() {
76
76
  let setup = TestSetup::new(2);
77
77
  let digest = hash(&setup.env, b"insufficient");
@@ -82,7 +82,7 @@ fn test_verify_signatures_insufficient_signatures() {
82
82
  }
83
83
 
84
84
  #[test]
85
- #[should_panic(expected = "Error(Contract, #12)")] // DvnError::UnsortedSigners
85
+ #[should_panic(expected = "Error(Contract, #13)")] // DvnError::UnsortedSigners
86
86
  fn test_verify_signatures_duplicate_signer() {
87
87
  let setup = TestSetup::new(2);
88
88
  let digest = hash(&setup.env, b"duplicate");
@@ -94,7 +94,7 @@ fn test_verify_signatures_duplicate_signer() {
94
94
  }
95
95
 
96
96
  #[test]
97
- #[should_panic(expected = "Error(Contract, #13)")] // DvnError::ZeroThreshold
97
+ #[should_panic(expected = "Error(Contract, #14)")] // DvnError::ZeroThreshold
98
98
  fn test_verify_signatures_threshold_zero() {
99
99
  let setup = TestSetup::new(1);
100
100
  // Force threshold to 0 via storage to hit ZeroThreshold branch
@@ -10,11 +10,10 @@ library = []
10
10
  testutils = []
11
11
 
12
12
  [lib]
13
- crate-type = ["cdylib", "rlib"]
13
+ crate-type = ["cdylib"]
14
14
  doctest = false
15
15
 
16
16
  [dependencies]
17
- cfg-if = "1.0"
18
17
  soroban-sdk = { workspace = true }
19
18
  common-macros = { workspace = true }
20
19
  message-lib-common = { workspace = true }
@@ -1,6 +1,7 @@
1
- use crate::DvnFeeLibError;
2
- use common_macros::contract_impl;
1
+ use crate::errors::DvnFeeLibError;
2
+ use common_macros::{contract_impl, ownable, ttl_configurable, upgradeable};
3
3
  use soroban_sdk::{assert_with_error, contract, Address, Env};
4
+ use utils::upgradeable::UpgradeableInternal;
4
5
  use worker::{DvnFeeParams, IDvnFeeLib, LayerZeroPriceFeedClient};
5
6
 
6
7
  // ============================================================================
@@ -11,13 +12,13 @@ use worker::{DvnFeeParams, IDvnFeeLib, LayerZeroPriceFeedClient};
11
12
  pub(crate) const BPS_BASE: i128 = 10000;
12
13
 
13
14
  /// Fixed bytes for execute function call.
14
- pub(crate) const EXECUTE_FIXED_BYTES: u64 = 260;
15
+ pub(crate) const EXECUTE_FIXED_BYTES: u32 = 260;
15
16
 
16
17
  /// Raw signature bytes length (65 bytes: 64 for signature + 1 for recovery ID).
17
- pub(crate) const SIGNATURE_RAW_BYTES: u64 = 65;
18
+ pub(crate) const SIGNATURE_RAW_BYTES: u32 = 65;
18
19
 
19
20
  /// Verify function bytes (padded).
20
- pub(crate) const VERIFY_BYTES: u64 = 288;
21
+ pub(crate) const VERIFY_BYTES: u32 = 288;
21
22
 
22
23
  /// Native token decimal rate for XLM (10^7 stroops per XLM).
23
24
  pub(crate) const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
@@ -28,29 +29,37 @@ pub(crate) const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
28
29
  /// and current gas prices from the price feed. Handles fee multipliers and
29
30
  /// floor margins.
30
31
  #[contract]
32
+ #[ownable]
33
+ #[ttl_configurable]
34
+ #[upgradeable]
31
35
  pub struct DvnFeeLib;
32
36
 
37
+ #[contract_impl]
38
+ impl DvnFeeLib {
39
+ pub fn __constructor(env: &Env, owner: &Address) {
40
+ Self::init_owner(env, owner);
41
+ }
42
+ }
43
+
33
44
  #[contract_impl]
34
45
  impl IDvnFeeLib for DvnFeeLib {
35
46
  fn get_fee(env: &Env, _dvn: &Address, params: &DvnFeeParams) -> i128 {
36
- assert_with_error!(env, params.gas > 0, DvnFeeLibError::InvalidGas);
47
+ assert_with_error!(env, params.gas != 0, DvnFeeLibError::EidNotSupported);
37
48
  assert_with_error!(env, params.options.is_empty(), DvnFeeLibError::InvalidDVNOptions);
38
49
 
39
- let call_data_size = get_call_data_size(params.quorum as u64);
40
- let call_data_size_u32 =
41
- u32::try_from(call_data_size).expect("call data size should comfortably fit into u32 for WASM");
50
+ let call_data_size = get_call_data_size(params.quorum);
42
51
 
43
52
  // Get estimated fee from price feed
44
53
  let price_feed_client = LayerZeroPriceFeedClient::new(env, &params.price_feed);
45
54
  let fee_result = price_feed_client.estimate_fee_by_eid(
46
55
  &env.current_contract_address(),
47
56
  &params.dst_eid,
48
- &call_data_size_u32,
57
+ &call_data_size,
49
58
  &params.gas,
50
59
  );
51
- assert_with_error!(env, fee_result.total_gas_fee >= 0, DvnFeeLibError::NegativeFee);
52
60
 
53
61
  apply_premium(
62
+ env,
54
63
  fee_result.total_gas_fee,
55
64
  params.multiplier_bps,
56
65
  params.default_multiplier_bps,
@@ -60,6 +69,18 @@ impl IDvnFeeLib for DvnFeeLib {
60
69
  }
61
70
  }
62
71
 
72
+ // ============================================================================
73
+ // Upgradeable Implementation
74
+ // ============================================================================
75
+
76
+ impl UpgradeableInternal for DvnFeeLib {
77
+ type MigrationData = ();
78
+
79
+ fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
80
+ // No migration logic needed for initial upgrade capability
81
+ }
82
+ }
83
+
63
84
  // ============================================================================
64
85
  // Internal Helper Functions
65
86
  // ============================================================================
@@ -79,19 +100,24 @@ impl IDvnFeeLib for DvnFeeLib {
79
100
  /// # Returns
80
101
  /// Fee with premium applied (max of multiplier fee and margin fee).
81
102
  pub(crate) fn apply_premium(
103
+ env: &Env,
82
104
  fee: i128,
83
105
  multiplier_bps: u32,
84
106
  default_multiplier_bps: u32,
85
107
  floor_margin_usd: u128,
86
108
  native_price_usd: u128,
87
109
  ) -> i128 {
88
- let effective_multiplier_bps = if multiplier_bps == 0 { default_multiplier_bps } else { multiplier_bps };
110
+ assert_with_error!(env, fee >= 0, DvnFeeLibError::InvalidFee);
89
111
 
112
+ let effective_multiplier_bps = if multiplier_bps == 0 { default_multiplier_bps } else { multiplier_bps };
90
113
  let fee_with_multiplier = fee * (effective_multiplier_bps as i128) / BPS_BASE;
91
114
  if native_price_usd == 0 || floor_margin_usd == 0 {
92
115
  return fee_with_multiplier;
93
116
  }
94
- let fee_with_floor_margin = fee + (floor_margin_usd * NATIVE_DECIMALS_RATE / native_price_usd) as i128;
117
+
118
+ let floor_margin_in_native = safe_u128_to_i128(env, floor_margin_usd * NATIVE_DECIMALS_RATE / native_price_usd);
119
+ let fee_with_floor_margin = fee + floor_margin_in_native;
120
+
95
121
  fee_with_floor_margin.max(fee_with_multiplier)
96
122
  }
97
123
 
@@ -105,10 +131,16 @@ pub(crate) fn apply_premium(
105
131
  ///
106
132
  /// # Returns
107
133
  /// Total calldata size in bytes.
108
- pub(crate) fn get_call_data_size(quorum: u64) -> u64 {
134
+ pub(crate) fn get_call_data_size(quorum: u32) -> u32 {
109
135
  let mut total_signature_bytes = quorum * SIGNATURE_RAW_BYTES;
110
136
  if !total_signature_bytes.is_multiple_of(32) {
111
137
  total_signature_bytes = total_signature_bytes - (total_signature_bytes % 32) + 32;
112
138
  }
113
139
  EXECUTE_FIXED_BYTES + VERIFY_BYTES + total_signature_bytes + 32
114
140
  }
141
+
142
+ /// Safely converts u128 to i128, panicking if value exceeds i128::MAX.
143
+ fn safe_u128_to_i128(env: &Env, value: u128) -> i128 {
144
+ assert_with_error!(env, value <= i128::MAX as u128, DvnFeeLibError::Overflow);
145
+ value as i128
146
+ }
@@ -2,7 +2,8 @@ use common_macros::contract_error;
2
2
 
3
3
  #[contract_error]
4
4
  pub enum DvnFeeLibError {
5
+ EidNotSupported,
5
6
  InvalidDVNOptions,
6
- InvalidGas,
7
- NegativeFee,
7
+ InvalidFee,
8
+ Overflow,
8
9
  }
@@ -1,17 +1,11 @@
1
1
  #![no_std]
2
- #[cfg(test)]
3
- extern crate std;
4
-
5
- mod errors;
6
2
 
7
- pub use errors::*;
3
+ pub mod dvn_fee_lib;
4
+ pub mod errors;
8
5
 
9
- cfg_if::cfg_if! {
10
- if #[cfg(any(not(feature = "library"), feature = "testutils"))] {
11
- mod dvn_fee_lib;
12
- pub use dvn_fee_lib::DvnFeeLib;
13
- }
14
- }
6
+ pub use dvn_fee_lib::{DvnFeeLib, DvnFeeLibClient};
15
7
 
8
+ #[cfg(test)]
9
+ extern crate std;
16
10
  #[cfg(test)]
17
11
  mod tests;
@@ -18,66 +18,73 @@ fn get_call_data_size_pads_signatures() {
18
18
 
19
19
  #[test]
20
20
  fn apply_premium_multiplier_only_both_zero() {
21
+ let env = Env::default();
21
22
  let fee = 1_000i128;
22
23
  let multiplier_bps = 15_000u32;
23
24
  // multiplier_bps is non-zero, so default_multiplier_bps is ignored
24
- let result = apply_premium(fee, multiplier_bps, 10_000, 0, 0);
25
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, 0, 0);
25
26
  assert_eq!(result, fee * multiplier_bps as i128 / BPS_BASE);
26
27
  }
27
28
 
28
29
  #[test]
29
30
  fn apply_premium_multiplier_only_native_price_zero() {
31
+ let env = Env::default();
30
32
  let fee = 1_000i128;
31
33
  let multiplier_bps = 15_000u32;
32
- let result = apply_premium(fee, multiplier_bps, 10_000, 100, 0);
34
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, 100, 0);
33
35
  assert_eq!(result, fee * multiplier_bps as i128 / BPS_BASE);
34
36
  }
35
37
 
36
38
  #[test]
37
39
  fn apply_premium_multiplier_only_floor_margin_zero() {
40
+ let env = Env::default();
38
41
  let fee = 1_000i128;
39
42
  let multiplier_bps = 15_000u32;
40
- let result = apply_premium(fee, multiplier_bps, 10_000, 0, NATIVE_DECIMALS_RATE);
43
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, 0, NATIVE_DECIMALS_RATE);
41
44
  assert_eq!(result, fee * multiplier_bps as i128 / BPS_BASE);
42
45
  }
43
46
 
44
47
  #[test]
45
48
  fn apply_premium_uses_default_when_multiplier_zero() {
49
+ let env = Env::default();
46
50
  let fee = 1_000i128;
47
51
  let default_bps = 12_000u32;
48
52
  // multiplier_bps is 0, so default_multiplier_bps should be used
49
- let result = apply_premium(fee, 0, default_bps, 0, 0);
53
+ let result = apply_premium(&env, fee, 0, default_bps, 0, 0);
50
54
  assert_eq!(result, fee * default_bps as i128 / BPS_BASE);
51
55
  }
52
56
 
53
57
  #[test]
54
58
  fn apply_premium_floor_margin_wins() {
59
+ let env = Env::default();
55
60
  let fee = 1_000i128;
56
61
  let multiplier_bps = 10_000u32;
57
62
  let floor_margin_usd = 10u128;
58
63
  let native_price_usd = NATIVE_DECIMALS_RATE;
59
64
 
60
- let result = apply_premium(fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
65
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
61
66
  assert_eq!(result, fee + floor_margin_usd as i128);
62
67
  }
63
68
 
64
69
  #[test]
65
70
  fn apply_premium_multiplier_wins_over_small_floor() {
71
+ let env = Env::default();
66
72
  let fee = 1_000i128;
67
73
  let multiplier_bps = 12_000u32;
68
74
  let floor_margin_usd = 1u128;
69
75
  let native_price_usd = NATIVE_DECIMALS_RATE;
70
76
 
71
- let result = apply_premium(fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
77
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
72
78
  assert_eq!(result, 1_200);
73
79
  }
74
80
 
75
81
  #[test]
76
- #[should_panic(expected = "Error(Contract, #2)")] // DvnFeeLibError::InvalidGas
82
+ #[should_panic(expected = "Error(Contract, #1)")] // DvnFeeLibError::EidNotSupported
77
83
  fn get_fee_panics_when_gas_zero() {
78
84
  let env = Env::default();
79
85
  env.mock_all_auths();
80
- let fee_lib_addr = env.register(DvnFeeLib, ());
86
+ let owner = Address::generate(&env);
87
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
81
88
  let params = DvnFeeParams {
82
89
  sender: Address::generate(&env),
83
90
  dst_eid: 1,
@@ -95,11 +102,12 @@ fn get_fee_panics_when_gas_zero() {
95
102
  }
96
103
 
97
104
  #[test]
98
- #[should_panic(expected = "Error(Contract, #1)")] // DvnFeeLibError::InvalidDVNOptions
105
+ #[should_panic(expected = "Error(Contract, #2)")] // DvnFeeLibError::InvalidDVNOptions
99
106
  fn get_fee_panics_when_options_not_empty() {
100
107
  let env = Env::default();
101
108
  env.mock_all_auths();
102
- let fee_lib_addr = env.register(DvnFeeLib, ());
109
+ let owner = Address::generate(&env);
110
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
103
111
  let mut options = Bytes::new(&env);
104
112
  options.push_back(1u8);
105
113
 
@@ -171,7 +179,8 @@ impl MockPriceFeedNegative {
171
179
  fn get_fee_success_path() {
172
180
  let env = Env::default();
173
181
  env.mock_all_auths();
174
- let fee_lib_addr = env.register(DvnFeeLib, ());
182
+ let owner = Address::generate(&env);
183
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
175
184
  let params = DvnFeeParams {
176
185
  sender: Address::generate(&env),
177
186
  dst_eid: 7,
@@ -194,7 +203,8 @@ fn get_fee_success_path() {
194
203
  fn get_fee_uses_default_multiplier_when_zero() {
195
204
  let env = Env::default();
196
205
  env.mock_all_auths();
197
- let fee_lib_addr = env.register(DvnFeeLib, ());
206
+ let owner = Address::generate(&env);
207
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
198
208
 
199
209
  // multiplier_bps = 0, default_multiplier_bps = 12000 (1.2x)
200
210
  // MockPriceFeed returns fee=100, so result = 100 * 12000 / 10000 = 120
@@ -220,7 +230,8 @@ fn get_fee_uses_default_multiplier_when_zero() {
220
230
  fn get_fee_prefers_dst_multiplier_over_default() {
221
231
  let env = Env::default();
222
232
  env.mock_all_auths();
223
- let fee_lib_addr = env.register(DvnFeeLib, ());
233
+ let owner = Address::generate(&env);
234
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
224
235
 
225
236
  // multiplier_bps = 15000 (1.5x), default_multiplier_bps = 10000 (1.0x)
226
237
  // MockPriceFeed returns fee=100, so result = 100 * 15000 / 10000 = 150
@@ -247,7 +258,8 @@ fn get_fee_prefers_dst_multiplier_over_default() {
247
258
  fn get_fee_panics_when_price_feed_returns_negative_fee() {
248
259
  let env = Env::default();
249
260
  env.mock_all_auths();
250
- let fee_lib_addr = env.register(DvnFeeLib, ());
261
+ let owner = Address::generate(&env);
262
+ let fee_lib_addr = env.register(DvnFeeLib, (&owner,));
251
263
  let params = DvnFeeParams {
252
264
  sender: Address::generate(&env),
253
265
  dst_eid: 7,
@@ -267,18 +279,20 @@ fn get_fee_panics_when_price_feed_returns_negative_fee() {
267
279
  #[test]
268
280
  #[should_panic]
269
281
  fn apply_premium_panics_on_overflow() {
282
+ let env = Env::default();
270
283
  let fee = i128::MAX / 2;
271
284
  let multiplier_bps = 20_000u32;
272
- apply_premium(fee, multiplier_bps, 10_000, u128::MAX, 1);
285
+ apply_premium(&env, fee, multiplier_bps, 10_000, u128::MAX, 1);
273
286
  }
274
287
 
275
288
  #[test]
276
289
  fn apply_premium_floor_margin_truncates() {
290
+ let env = Env::default();
277
291
  let fee = 0i128;
278
292
  let multiplier_bps = 10_000u32;
279
293
  let floor_margin_usd = 1u128;
280
294
  let native_price_usd = NATIVE_DECIMALS_RATE * 3 / 2;
281
295
 
282
- let result = apply_premium(fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
296
+ let result = apply_premium(&env, fee, multiplier_bps, 10_000, floor_margin_usd, native_price_usd);
283
297
  assert_eq!(result, 0);
284
298
  }
@@ -5,12 +5,12 @@ use crate::{
5
5
  storage::ExecutorStorage,
6
6
  NativeDropParams,
7
7
  };
8
- use common_macros::{contract_impl, only_owner, ttl_configurable};
8
+ use common_macros::{contract_impl, only_owner, ownable, ttl_configurable, upgradeable};
9
9
  use endpoint_v2::{FeeRecipient, LayerZeroEndpointV2Client, Origin};
10
10
  use message_lib_common::interfaces::ILayerZeroExecutor;
11
11
  use soroban_sdk::{contract, token::TokenClient, vec, Address, Bytes, BytesN, Env, Symbol, Vec};
12
12
  use utils::option_ext::OptionExt;
13
- use utils::ownable::Ownable;
13
+ use utils::upgradeable::UpgradeableInternal;
14
14
  use worker::{
15
15
  assert_acl, assert_not_paused, assert_supported_message_lib, init_worker, require_admin_auth, set_admin_by_owner,
16
16
  ExecutorFeeLibClient, FeeParams, Worker,
@@ -19,6 +19,8 @@ use worker::{
19
19
  /// LayerZero Executor contract for cross-chain message execution.
20
20
  #[contract]
21
21
  #[ttl_configurable]
22
+ #[upgradeable]
23
+ #[ownable]
22
24
  pub struct LzExecutor;
23
25
 
24
26
  #[contract_impl]
@@ -227,6 +229,18 @@ impl ILayerZeroExecutor for LzExecutor {
227
229
  #[contract_impl(contracttrait)]
228
230
  impl Worker for LzExecutor {}
229
231
 
232
+ // ============================================================================
233
+ // Upgradeable Implementation
234
+ // ============================================================================
235
+
236
+ impl UpgradeableInternal for LzExecutor {
237
+ type MigrationData = ();
238
+
239
+ fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
240
+ // No migration logic needed for initial upgrade capability
241
+ }
242
+ }
243
+
230
244
  // ============================================================================
231
245
  // Include SubModules
232
246
  // ============================================================================
@@ -2,14 +2,16 @@ use common_macros::contract_error;
2
2
 
3
3
  #[contract_error]
4
4
  pub enum ExecutorFeeLibError {
5
+ EidNotSupported,
6
+ InvalidExecutorOptions,
7
+ InvalidFee,
8
+ InvalidLzComposeOption,
9
+ InvalidLzReceiveOption,
10
+ InvalidNativeDropOption,
11
+ NativeAmountExceedsCap,
5
12
  NoOptions,
13
+ Overflow,
6
14
  UnsupportedOptionType,
7
- ZeroLzReceiveGasProvided,
8
15
  ZeroLzComposeGasProvided,
9
- NativeAmountExceedsCap,
10
- InvalidLzReceiveOption,
11
- InvalidNativeDropOption,
12
- InvalidLzComposeOption,
13
- InvalidExecutorOptions,
14
- EidNotSupported,
16
+ ZeroLzReceiveGasProvided,
15
17
  }