@layerzerolabs/protocol-stellar-v2 0.2.13 → 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
@@ -1,6 +1,7 @@
1
1
  use crate::{errors::ExecutorFeeLibError, executor_option};
2
- use common_macros::contract_impl;
2
+ use common_macros::{contract_impl, ownable, ttl_configurable, upgradeable};
3
3
  use soroban_sdk::{assert_with_error, contract, Address, Bytes, Env};
4
+ use utils::upgradeable::UpgradeableInternal;
4
5
  use worker::{FeeParams, IExecutorFeeLib, LayerZeroPriceFeedClient};
5
6
 
6
7
  // ============================================================================
@@ -11,7 +12,7 @@ use worker::{FeeParams, IExecutorFeeLib, LayerZeroPriceFeedClient};
11
12
  const V1_EID_THRESHOLD: u32 = 30000;
12
13
 
13
14
  /// Basis points denominator (10000 = 100%).
14
- const BPS_DENOMINATOR: i128 = 10000;
15
+ const BPS_DENOMINATOR: u128 = 10000;
15
16
 
16
17
  /// Overhead percentage for ordered execution (102 = 2% overhead).
17
18
  const ORDERED_EXECUTION_OVERHEAD_PERCENT: u128 = 102;
@@ -25,123 +26,15 @@ const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
25
26
  /// and current gas prices from the price feed. Handles fee multipliers, margins, and
26
27
  /// native token value conversions.
27
28
  #[contract]
29
+ #[ownable]
30
+ #[ttl_configurable]
31
+ #[upgradeable]
28
32
  pub struct ExecutorFeeLib;
29
33
 
30
34
  #[contract_impl]
31
35
  impl ExecutorFeeLib {
32
- // ========================================================================
33
- // Internal Functions
34
- // ========================================================================
35
-
36
- /// Decodes executor options and calculates total gas and native value.
37
- ///
38
- /// Parses encoded executor options, accumulates gas requirements (including
39
- /// compose calls and ordered execution overhead), and returns the total native
40
- /// value and gas needed.
41
- ///
42
- /// # Arguments
43
- /// * `options` - Encoded executor options bytes
44
- /// * `dst_eid` - Destination endpoint ID
45
- /// * `lz_receive_base_gas` - Base gas for lzReceive execution
46
- /// * `lz_compose_base_gas` - Base gas per lzCompose call
47
- /// * `native_cap` - Maximum allowed native token value
48
- ///
49
- /// # Returns
50
- /// Tuple of (total_native_value, total_gas).
51
- fn decode_executor_options(
52
- env: &Env,
53
- options: &Bytes,
54
- dst_eid: u32,
55
- lz_receive_base_gas: u64,
56
- lz_compose_base_gas: u64,
57
- native_cap: u128,
58
- ) -> (u128, u128) {
59
- let options_agg = executor_option::parse_executor_options(env, options, Self::is_v1_eid(dst_eid), native_cap);
60
-
61
- let mut total_gas = (lz_receive_base_gas as u128)
62
- + options_agg.total_gas
63
- + ((lz_compose_base_gas as u128) * (options_agg.num_lz_compose as u128));
64
-
65
- if options_agg.ordered {
66
- total_gas = (total_gas * ORDERED_EXECUTION_OVERHEAD_PERCENT) / 100;
67
- }
68
-
69
- (options_agg.total_value, total_gas)
70
- }
71
-
72
- /// Returns the effective multiplier in basis points.
73
- ///
74
- /// Uses destination-specific multiplier if set, otherwise falls back to default multiplier.
75
- ///
76
- /// # Arguments
77
- /// * `params` - Fee parameters containing multiplier settings
78
- ///
79
- /// # Returns
80
- /// Effective multiplier in basis points.
81
- fn get_effective_multiplier_bps(params: &FeeParams) -> u32 {
82
- if params.multiplier_bps == 0 {
83
- params.default_multiplier_bps
84
- } else {
85
- params.multiplier_bps
86
- }
87
- }
88
-
89
- /// Applies premium (multiplier and margin) to gas fee.
90
- ///
91
- /// Calculates fee with multiplier and floor margin, returning the maximum of both
92
- /// to ensure profitability.
93
- ///
94
- /// # Arguments
95
- /// * `fee` - Base gas fee
96
- /// * `multiplier_bps` - Fee multiplier in basis points
97
- /// * `margin_usd` - Minimum margin in USD (scaled)
98
- /// * `native_price_usd` - Native token price in USD (scaled)
99
- ///
100
- /// # Returns
101
- /// Fee with premium applied (max of multiplier fee and margin fee).
102
- fn apply_premium_to_gas(fee: i128, multiplier_bps: u32, margin_usd: u128, native_price_usd: u128) -> i128 {
103
- let fee_with_multiplier = (fee * multiplier_bps as i128) / BPS_DENOMINATOR;
104
-
105
- if native_price_usd == 0 || margin_usd == 0 {
106
- return fee_with_multiplier;
107
- }
108
-
109
- let fee_with_margin = ((margin_usd * NATIVE_DECIMALS_RATE) / native_price_usd) as i128 + fee;
110
-
111
- fee_with_margin.max(fee_with_multiplier)
112
- }
113
-
114
- /// Converts native value and applies premium multiplier.
115
- ///
116
- /// Converts value using price ratio and applies multiplier in basis points.
117
- ///
118
- /// # Arguments
119
- /// * `value` - Native value to convert
120
- /// * `ratio` - Price ratio numerator
121
- /// * `denom` - Price ratio denominator
122
- /// * `multiplier_bps` - Fee multiplier in basis points
123
- ///
124
- /// # Returns
125
- /// Converted and multiplied value, or 0 if input value is 0.
126
- fn convert_and_apply_premium_to_value(value: u128, ratio: u128, denom: u128, multiplier_bps: u32) -> i128 {
127
- if value == 0 {
128
- return 0;
129
- }
130
- let converted = (value * ratio) / denom;
131
- ((converted * multiplier_bps as u128) / BPS_DENOMINATOR as u128) as i128
132
- }
133
-
134
- /// Checks if an endpoint ID is a V1 endpoint.
135
- ///
136
- /// V1 endpoints (EID < 30000) have restrictions on executor options.
137
- ///
138
- /// # Arguments
139
- /// * `eid` - Endpoint ID to check
140
- ///
141
- /// # Returns
142
- /// `true` if the endpoint is a V1 endpoint, `false` otherwise.
143
- fn is_v1_eid(eid: u32) -> bool {
144
- eid < V1_EID_THRESHOLD
36
+ pub fn __constructor(env: &Env, owner: &Address) {
37
+ Self::init_owner(env, owner);
145
38
  }
146
39
  }
147
40
 
@@ -170,7 +63,7 @@ impl IExecutorFeeLib for ExecutorFeeLib {
170
63
  fn get_fee(env: &Env, _executor: &Address, params: &FeeParams) -> i128 {
171
64
  assert_with_error!(env, params.lz_receive_base_gas != 0, ExecutorFeeLibError::EidNotSupported);
172
65
 
173
- let (total_value, total_gas) = Self::decode_executor_options(
66
+ let (total_value, total_gas) = decode_executor_options(
174
67
  env,
175
68
  &params.options,
176
69
  params.dst_eid,
@@ -186,16 +79,18 @@ impl IExecutorFeeLib for ExecutorFeeLib {
186
79
  &total_gas,
187
80
  );
188
81
 
189
- let multiplier_bps = Self::get_effective_multiplier_bps(params);
82
+ let multiplier_bps = get_effective_multiplier_bps(params);
190
83
 
191
- let mut fee = Self::apply_premium_to_gas(
84
+ let mut fee = apply_premium_to_gas(
85
+ env,
192
86
  fee_estimate.total_gas_fee,
193
87
  multiplier_bps,
194
88
  params.floor_margin_usd,
195
89
  fee_estimate.native_price_usd,
196
90
  );
197
91
 
198
- fee += Self::convert_and_apply_premium_to_value(
92
+ fee += convert_and_apply_premium_to_value(
93
+ env,
199
94
  total_value,
200
95
  fee_estimate.price_ratio,
201
96
  fee_estimate.price_ratio_denominator,
@@ -213,3 +108,143 @@ impl IExecutorFeeLib for ExecutorFeeLib {
213
108
  (1, 1)
214
109
  }
215
110
  }
111
+
112
+ // ============================================================================
113
+ // Upgradeable Implementation
114
+ // ============================================================================
115
+
116
+ impl UpgradeableInternal for ExecutorFeeLib {
117
+ type MigrationData = ();
118
+
119
+ fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
120
+ // No migration logic needed for initial upgrade capability
121
+ }
122
+ }
123
+
124
+ // ========================================================================
125
+ // Helper Functions
126
+ // ========================================================================
127
+
128
+ /// Decodes executor options and calculates total gas and native value.
129
+ ///
130
+ /// Parses encoded executor options, accumulates gas requirements (including
131
+ /// compose calls and ordered execution overhead), and returns the total native
132
+ /// value and gas needed.
133
+ ///
134
+ /// # Arguments
135
+ /// * `options` - Encoded executor options bytes
136
+ /// * `dst_eid` - Destination endpoint ID
137
+ /// * `lz_receive_base_gas` - Base gas for lzReceive execution
138
+ /// * `lz_compose_base_gas` - Base gas per lzCompose call
139
+ /// * `native_cap` - Maximum allowed native token value
140
+ ///
141
+ /// # Returns
142
+ /// Tuple of (total_native_value, total_gas).
143
+ fn decode_executor_options(
144
+ env: &Env,
145
+ options: &Bytes,
146
+ dst_eid: u32,
147
+ lz_receive_base_gas: u64,
148
+ lz_compose_base_gas: u64,
149
+ native_cap: u128,
150
+ ) -> (u128, u128) {
151
+ let options_agg = executor_option::parse_executor_options(env, options, is_v1_eid(dst_eid), native_cap);
152
+
153
+ let mut total_gas = (lz_receive_base_gas as u128)
154
+ + options_agg.total_gas
155
+ + ((lz_compose_base_gas as u128) * (options_agg.num_lz_compose as u128));
156
+
157
+ if options_agg.ordered {
158
+ total_gas = (total_gas * ORDERED_EXECUTION_OVERHEAD_PERCENT) / 100;
159
+ }
160
+
161
+ (options_agg.total_value, total_gas)
162
+ }
163
+
164
+ /// Returns the effective multiplier in basis points.
165
+ ///
166
+ /// Uses destination-specific multiplier if set, otherwise falls back to default multiplier.
167
+ ///
168
+ /// # Arguments
169
+ /// * `params` - Fee parameters containing multiplier settings
170
+ ///
171
+ /// # Returns
172
+ /// Effective multiplier in basis points.
173
+ fn get_effective_multiplier_bps(params: &FeeParams) -> u32 {
174
+ if params.multiplier_bps == 0 {
175
+ params.default_multiplier_bps
176
+ } else {
177
+ params.multiplier_bps
178
+ }
179
+ }
180
+
181
+ /// Applies premium (multiplier and margin) to gas fee.
182
+ ///
183
+ /// Calculates fee with multiplier and floor margin, returning the maximum of both
184
+ /// to ensure profitability.
185
+ ///
186
+ /// # Arguments
187
+ /// * `fee` - Base gas fee
188
+ /// * `multiplier_bps` - Fee multiplier in basis points
189
+ /// * `margin_usd` - Minimum margin in USD (scaled)
190
+ /// * `native_price_usd` - Native token price in USD (scaled)
191
+ ///
192
+ /// # Example(scaled to 10^20)
193
+ /// With margin_usd = $0.01 (0.01 * 10^20), native_price_usd = $0.32 (0.32 * 10^20), fee = 0:
194
+ /// fee_with_margin = ((0.01 * 10^20 * 10^7) / (0.32 * 10^20)) + 0 = 312_500 stroops (0.03125 XLM)
195
+ ///
196
+ /// # Returns
197
+ /// Fee with premium applied (max of multiplier fee and margin fee).
198
+ fn apply_premium_to_gas(env: &Env, fee: i128, multiplier_bps: u32, margin_usd: u128, native_price_usd: u128) -> i128 {
199
+ assert_with_error!(env, fee >= 0, ExecutorFeeLibError::InvalidFee);
200
+
201
+ let fee_with_multiplier = safe_u128_to_i128(env, (fee as u128 * multiplier_bps as u128) / BPS_DENOMINATOR);
202
+
203
+ if native_price_usd == 0 || margin_usd == 0 {
204
+ return fee_with_multiplier;
205
+ }
206
+
207
+ let margin_in_native = (margin_usd * NATIVE_DECIMALS_RATE) / native_price_usd;
208
+ let fee_with_margin = safe_u128_to_i128(env, margin_in_native) + fee;
209
+
210
+ fee_with_margin.max(fee_with_multiplier)
211
+ }
212
+
213
+ /// Converts native value and applies premium multiplier.
214
+ ///
215
+ /// Converts value using price ratio and applies multiplier in basis points.
216
+ ///
217
+ /// # Arguments
218
+ /// * `value` - Native value to convert
219
+ /// * `ratio` - Price ratio numerator
220
+ /// * `denom` - Price ratio denominator
221
+ /// * `multiplier_bps` - Fee multiplier in basis points
222
+ ///
223
+ /// # Returns
224
+ /// Converted and multiplied value, or 0 if input value is 0.
225
+ fn convert_and_apply_premium_to_value(env: &Env, value: u128, ratio: u128, denom: u128, multiplier_bps: u32) -> i128 {
226
+ if value == 0 {
227
+ return 0;
228
+ }
229
+ let converted = (value * ratio) / denom;
230
+ safe_u128_to_i128(env, (converted * multiplier_bps as u128) / BPS_DENOMINATOR)
231
+ }
232
+
233
+ /// Checks if an endpoint ID is a V1 endpoint.
234
+ ///
235
+ /// V1 endpoints (EID < 30000) have restrictions on executor options.
236
+ ///
237
+ /// # Arguments
238
+ /// * `eid` - Endpoint ID to check
239
+ ///
240
+ /// # Returns
241
+ /// `true` if the endpoint is a V1 endpoint, `false` otherwise.
242
+ fn is_v1_eid(eid: u32) -> bool {
243
+ eid < V1_EID_THRESHOLD
244
+ }
245
+
246
+ /// Safely converts u128 to i128, panicking if value exceeds i128::MAX.
247
+ fn safe_u128_to_i128(env: &Env, value: u128) -> i128 {
248
+ assert_with_error!(env, value <= i128::MAX as u128, ExecutorFeeLibError::Overflow);
249
+ value as i128
250
+ }
@@ -9,12 +9,7 @@ publish = false
9
9
  crate-type = ["cdylib"]
10
10
  doctest = false
11
11
 
12
- [features]
13
- library = []
14
- testutils = []
15
-
16
12
  [dependencies]
17
- cfg-if = { workspace = true }
18
13
  soroban-sdk = { workspace = true }
19
14
  # workspace dependencies
20
15
  common-macros = { workspace = true }
@@ -2,10 +2,4 @@
2
2
 
3
3
  mod executor_helper;
4
4
 
5
- cfg_if::cfg_if! {
6
- // Include implementation when NOT in library mode, OR when testutils is enabled (for tests)
7
- if #[cfg(any(not(feature = "library"), feature = "testutils"))] {
8
-
9
- pub use executor_helper::*;
10
- }
11
- }
5
+ pub use executor_helper::*;
@@ -11,7 +11,6 @@ doctest = false
11
11
 
12
12
  [dependencies]
13
13
  soroban-sdk = { workspace = true }
14
- endpoint-v2 = { workspace = true, features = ["library"] }
15
14
  utils = { workspace = true }
16
15
  worker = { workspace = true }
17
16
  common-macros = { workspace = true }
@@ -2,8 +2,9 @@ use common_macros::contract_error;
2
2
 
3
3
  #[contract_error]
4
4
  pub enum PriceFeedError {
5
- OnlyPriceUpdater,
6
5
  InvalidDenominator,
7
- NotAnOpStack,
8
6
  NoPrice,
7
+ NotAnOpStack,
8
+ OnlyPriceUpdater,
9
+ Overflow,
9
10
  }
@@ -1,11 +1,10 @@
1
1
  #![no_std]
2
2
 
3
- mod errors;
4
- mod events;
5
- mod price_feed;
6
3
  mod storage;
7
- mod types;
8
4
 
9
- pub use errors::*;
5
+ pub mod errors;
6
+ pub mod events;
7
+ pub mod price_feed;
8
+ pub mod types;
9
+
10
10
  pub use price_feed::{LzPriceFeed, LzPriceFeedClient};
11
- pub use types::*;
@@ -1,6 +1,6 @@
1
- use common_macros::{only_owner, ttl_configurable};
2
- use soroban_sdk::{assert_with_error, contract, contractimpl, panic_with_error, Address, Env, Vec};
3
- use utils::ownable::Ownable;
1
+ use common_macros::{contract_impl, only_owner, ownable, ttl_configurable, upgradeable};
2
+ use soroban_sdk::{assert_with_error, contract, panic_with_error, Address, Env, Vec};
3
+ use utils::upgradeable::UpgradeableInternal;
4
4
  use worker::{FeeEstimate, ILayerZeroPriceFeed, Price};
5
5
 
6
6
  use crate::{
@@ -11,10 +11,12 @@ use crate::{
11
11
  };
12
12
 
13
13
  #[contract]
14
+ #[ownable]
14
15
  #[ttl_configurable]
16
+ #[upgradeable]
15
17
  pub struct LzPriceFeed;
16
18
 
17
- #[contractimpl]
19
+ #[contract_impl]
18
20
  impl LzPriceFeed {
19
21
  pub fn __constructor(env: &Env, owner: &Address, price_updater: &Address) {
20
22
  Self::init_owner(env, owner);
@@ -23,7 +25,7 @@ impl LzPriceFeed {
23
25
  }
24
26
  }
25
27
 
26
- #[contractimpl]
28
+ #[contract_impl]
27
29
  impl ILayerZeroPriceFeed for LzPriceFeed {
28
30
  /// Estimate fee with detailed breakdown by endpoint ID
29
31
  /// Corresponds to estimateFeeByEid in PriceFeed.sol
@@ -49,6 +51,8 @@ impl ILayerZeroPriceFeed for LzPriceFeed {
49
51
  let price_ratio_denominator = Self::get_price_ratio_denominator(env);
50
52
  let native_price_usd = Self::native_token_price_usd(env);
51
53
 
54
+ assert_with_error!(env, fee <= i128::MAX as u128, PriceFeedError::Overflow);
55
+
52
56
  FeeEstimate { total_gas_fee: fee as i128, price_ratio, price_ratio_denominator, native_price_usd }
53
57
  }
54
58
 
@@ -58,9 +62,8 @@ impl ILayerZeroPriceFeed for LzPriceFeed {
58
62
  }
59
63
 
60
64
  /// Get the price for a destination EID.
61
- fn get_price(env: &Env, dst_eid: u32) -> Price {
65
+ fn get_price(env: &Env, dst_eid: u32) -> Option<Price> {
62
66
  PriceFeedStorage::default_model_price(env, dst_eid)
63
- .unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice))
64
67
  }
65
68
 
66
69
  /// Get the price ratio denominator.
@@ -69,7 +72,7 @@ impl ILayerZeroPriceFeed for LzPriceFeed {
69
72
  }
70
73
  }
71
74
 
72
- #[contractimpl]
75
+ #[contract_impl]
73
76
  impl LzPriceFeed {
74
77
  // ========================================================================
75
78
  // Owner Functions
@@ -78,7 +81,11 @@ impl LzPriceFeed {
78
81
  /// Set price updater status (owner only)
79
82
  #[only_owner]
80
83
  pub fn set_price_updater(env: &Env, updater: &Address, active: bool) {
81
- PriceFeedStorage::set_price_updater(env, updater, &active);
84
+ if active {
85
+ PriceFeedStorage::set_price_updater(env, updater, &true);
86
+ } else {
87
+ PriceFeedStorage::remove_price_updater(env, updater);
88
+ }
82
89
  PriceUpdaterSet { updater: updater.clone(), active }.publish(env);
83
90
  }
84
91
 
@@ -141,8 +148,8 @@ impl LzPriceFeed {
141
148
  // ========================================================================
142
149
 
143
150
  /// Check if an address is an active price updater
144
- pub fn price_updater(env: &Env, updater: &Address) -> bool {
145
- PriceFeedStorage::price_updater(env, updater)
151
+ pub fn is_price_updater(env: &Env, updater: &Address) -> bool {
152
+ PriceFeedStorage::has_price_updater(env, updater)
146
153
  }
147
154
 
148
155
  /// Get the Arbitrum compression percent
@@ -172,7 +179,7 @@ impl LzPriceFeed {
172
179
 
173
180
  /// Estimate fee with default model
174
181
  fn estimate_fee_with_default_model(env: &Env, dst_eid: u32, calldata_size: u32, gas: u128) -> (u128, u128) {
175
- let price = Self::get_price(env, dst_eid);
182
+ let price = Self::get_price(env, dst_eid).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
176
183
 
177
184
  // assuming the _gas includes (1) the 21,000 overhead and (2) not the calldata gas
178
185
  let gas_for_calldata = (calldata_size as u128) * (price.gas_per_byte as u128);
@@ -187,13 +194,15 @@ impl LzPriceFeed {
187
194
  let ethereum_id = Self::get_l1_lookup_id_for_optimism_model(env, dst_eid);
188
195
 
189
196
  // L1 fee (Ethereum)
190
- let ethereum_price = Self::get_price(env, ethereum_id);
197
+ let ethereum_price =
198
+ Self::get_price(env, ethereum_id).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
191
199
  let gas_for_l1_calldata = ((calldata_size as u128) * (ethereum_price.gas_per_byte as u128)) + 3188; // 2100 + 68 * 16
192
200
  let l1_fee = gas_for_l1_calldata * (ethereum_price.gas_price_in_unit as u128);
193
201
 
194
202
  // L2 fee (Optimism)
195
- let optimism_price = Self::get_price(env, dst_eid);
196
- let gas_for_l2_calldata: u128 = (calldata_size as u128) * (optimism_price.gas_per_byte as u128);
203
+ let optimism_price =
204
+ Self::get_price(env, dst_eid).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
205
+ let gas_for_l2_calldata = (calldata_size as u128) * (optimism_price.gas_per_byte as u128);
197
206
  let l2_fee = (gas_for_l2_calldata + gas) * (optimism_price.gas_price_in_unit as u128);
198
207
 
199
208
  let price_ratio_denom = Self::get_price_ratio_denominator(env);
@@ -206,7 +215,8 @@ impl LzPriceFeed {
206
215
 
207
216
  /// Estimate fee with Arbitrum model
208
217
  fn estimate_fee_with_arbitrum_model(env: &Env, dst_eid: u32, calldata_size: u32, gas: u128) -> (u128, u128) {
209
- let arbitrum_price = Self::get_price(env, dst_eid);
218
+ let arbitrum_price =
219
+ Self::get_price(env, dst_eid).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
210
220
 
211
221
  let arbitrum_price_ext = Self::arbitrum_price_ext(env);
212
222
 
@@ -260,6 +270,18 @@ impl LzPriceFeed {
260
270
  }
261
271
 
262
272
  // Check if caller is an active price updater
263
- assert_with_error!(env, Self::price_updater(env, caller), PriceFeedError::OnlyPriceUpdater);
273
+ assert_with_error!(env, Self::is_price_updater(env, caller), PriceFeedError::OnlyPriceUpdater);
274
+ }
275
+ }
276
+
277
+ // ============================================================================
278
+ // Upgradeable Implementation
279
+ // ============================================================================
280
+
281
+ impl UpgradeableInternal for LzPriceFeed {
282
+ type MigrationData = ();
283
+
284
+ fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
285
+ // No migration logic needed for initial upgrade capability
264
286
  }
265
287
  }
@@ -13,3 +13,7 @@ doctest = false
13
13
  soroban-sdk = { workspace = true }
14
14
  utils = { workspace = true }
15
15
  common-macros = { workspace = true }
16
+
17
+ [dev-dependencies]
18
+ soroban-sdk = { workspace = true, features = ["testutils"] }
19
+ utils = { workspace = true, features = ["testutils"] }
@@ -49,7 +49,7 @@ pub trait ILayerZeroPriceFeed {
49
49
  /// Returns the USD price of the source chain native token.
50
50
  ///
51
51
  /// # Returns
52
- /// Native token price in USD (scaled by appropriate decimals).
52
+ /// Native token price in USD (scaled by appropriate denominator).
53
53
  fn native_token_price_usd(env: &Env) -> u128;
54
54
 
55
55
  /// Returns gas price information for a destination endpoint.
@@ -58,8 +58,8 @@ pub trait ILayerZeroPriceFeed {
58
58
  /// * `dst_eid` - Destination endpoint ID (chain identifier)
59
59
  ///
60
60
  /// # Returns
61
- /// `Price` containing price_ratio, gas_price_in_unit, and gas_per_byte.
62
- fn get_price(env: &Env, dst_eid: u32) -> Price;
61
+ /// `Some(Price)` containing price_ratio, gas_price_in_unit, and gas_per_byte, or `None` if not set.
62
+ fn get_price(env: &Env, dst_eid: u32) -> Option<Price>;
63
63
 
64
64
  /// Returns the denominator used for price ratio calculations.
65
65
  ///
@@ -10,5 +10,5 @@ mod worker;
10
10
  pub use interfaces::*;
11
11
  pub use worker::*;
12
12
 
13
- // #[cfg(test)]
14
- // mod tests;
13
+ #[cfg(test)]
14
+ mod tests;
@@ -0,0 +1,4 @@
1
+ extern crate std;
2
+
3
+ mod setup;
4
+ mod worker;