@layerzerolabs/protocol-stellar-v2 0.2.21 → 0.2.23

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 (328) hide show
  1. package/.turbo/turbo-build.log +347 -271
  2. package/.turbo/turbo-lint.log +277 -208
  3. package/.turbo/turbo-test.log +1700 -1370
  4. package/Cargo.lock +22 -51
  5. package/Cargo.toml +6 -1
  6. package/contracts/common-macros/src/auth.rs +10 -9
  7. package/contracts/common-macros/src/contract_ttl.rs +1 -4
  8. package/contracts/common-macros/src/error.rs +1 -3
  9. package/contracts/common-macros/src/lib.rs +65 -61
  10. package/contracts/common-macros/src/storage.rs +212 -65
  11. package/contracts/common-macros/src/tests/auth.rs +75 -6
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +383 -350
  13. package/contracts/common-macros/src/tests/error.rs +9 -21
  14. package/contracts/common-macros/src/tests/lz_contract.rs +80 -0
  15. package/contracts/common-macros/src/tests/mod.rs +2 -0
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -3
  17. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +28 -1
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap +8 -43
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +6 -29
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__lz_contract__snapshot_generated_lz_contract_code.snap +31 -0
  21. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_extendable__snapshot_generated_ttl_extendable_code.snap +8 -0
  22. package/contracts/common-macros/src/tests/storage/extract_fields.rs +87 -0
  23. package/contracts/common-macros/src/tests/storage/gen_accessor_methods.rs +223 -0
  24. package/contracts/common-macros/src/tests/storage/gen_args.rs +65 -0
  25. package/contracts/common-macros/src/tests/storage/gen_enum_variant.rs +78 -0
  26. package/contracts/common-macros/src/tests/storage/gen_key.rs +108 -0
  27. package/contracts/common-macros/src/tests/storage/gen_params.rs +105 -0
  28. package/contracts/common-macros/src/tests/{storage.rs → storage/generate_storage.rs} +54 -129
  29. package/contracts/common-macros/src/tests/storage/is_primitive_type.rs +48 -0
  30. package/contracts/common-macros/src/tests/storage/mod.rs +16 -0
  31. package/contracts/common-macros/src/tests/storage/parse_default.rs +164 -0
  32. package/contracts/common-macros/src/tests/storage/parse_name.rs +159 -0
  33. package/contracts/common-macros/src/tests/storage/parse_no_ttl_extension.rs +124 -0
  34. package/contracts/common-macros/src/tests/storage/parse_storage_type.rs +174 -0
  35. package/contracts/common-macros/src/tests/storage/snapshots/common_macros__tests__storage__generate_storage__snapshot_generated_storage_code.snap +412 -0
  36. package/contracts/common-macros/src/tests/storage/storage_kind.rs +39 -0
  37. package/contracts/common-macros/src/tests/storage/test_setup.rs +25 -0
  38. package/contracts/common-macros/src/tests/storage/validate_attrs.rs +138 -0
  39. package/contracts/common-macros/src/tests/storage/variant_config.rs +226 -0
  40. package/contracts/common-macros/src/tests/test_helpers.rs +4 -10
  41. package/contracts/common-macros/src/tests/ttl_configurable.rs +2 -2
  42. package/contracts/common-macros/src/tests/ttl_extendable.rs +32 -0
  43. package/contracts/common-macros/src/tests/upgradeable.rs +118 -2
  44. package/contracts/common-macros/src/ttl_configurable.rs +1 -4
  45. package/contracts/common-macros/src/upgradeable.rs +21 -3
  46. package/contracts/endpoint-v2/Cargo.toml +0 -4
  47. package/contracts/endpoint-v2/src/endpoint_v2.rs +37 -17
  48. package/contracts/endpoint-v2/src/errors.rs +26 -1
  49. package/contracts/endpoint-v2/src/interfaces/layerzero_endpoint_v2.rs +1 -1
  50. package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +4 -4
  51. package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
  52. package/contracts/endpoint-v2/src/lib.rs +0 -1
  53. package/contracts/endpoint-v2/src/message_lib_manager.rs +39 -8
  54. package/contracts/endpoint-v2/src/messaging_channel.rs +36 -4
  55. package/contracts/endpoint-v2/src/messaging_composer.rs +18 -4
  56. package/contracts/endpoint-v2/src/storage.rs +9 -1
  57. package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +2 -2
  58. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +1 -1
  59. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  60. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +3 -3
  61. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +5 -5
  62. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +2 -2
  63. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +5 -5
  64. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +3 -3
  65. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +1 -1
  66. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +4 -3
  67. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +7 -2
  68. package/contracts/endpoint-v2/src/tests/messaging_composer/mod.rs +4 -0
  69. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +7 -2
  70. package/contracts/layerzero-views/src/layerzero_view.rs +0 -1
  71. package/contracts/layerzero-views/src/tests/mod.rs +1 -0
  72. package/contracts/layerzero-views/src/tests/types_tests.rs +31 -0
  73. package/contracts/layerzero-views/src/types.rs +2 -3
  74. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/constructor.rs +61 -0
  75. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_impl_ttl_extension.rs +97 -0
  76. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_trait_ttl_extension.rs +99 -0
  77. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/mod.rs +3 -0
  78. package/contracts/macro-integration-tests/tests/runtime/lz_contract/mod.rs +5 -0
  79. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_default.rs +86 -0
  80. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig.rs +47 -0
  81. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig_upgradeable.rs +77 -0
  82. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable.rs +114 -0
  83. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable_no_migration.rs +105 -0
  84. package/contracts/macro-integration-tests/tests/runtime/multisig/admin_entrypoints.rs +242 -0
  85. package/contracts/macro-integration-tests/tests/runtime/multisig/mod.rs +9 -0
  86. package/contracts/macro-integration-tests/tests/runtime/multisig/self_auth.rs +54 -0
  87. package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +13 -0
  88. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +1 -0
  89. package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +70 -1
  90. package/contracts/macro-integration-tests/tests/runtime/ownable/two_step_transfer.rs +219 -0
  91. package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +41 -0
  92. package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +48 -16
  93. package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +10 -0
  94. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +96 -3
  95. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +4 -0
  96. package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/extend_instance_ttl.rs +64 -0
  97. package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/mod.rs +16 -0
  98. package/contracts/macro-integration-tests/tests/runtime/upgradeable/migrate_guard_and_state.rs +305 -0
  99. package/contracts/macro-integration-tests/tests/runtime/upgradeable/mod.rs +3 -0
  100. package/contracts/macro-integration-tests/tests/runtime/upgradeable/no_migration.rs +59 -0
  101. package/contracts/macro-integration-tests/tests/runtime/upgradeable/upgrade_then_migrate.rs +88 -0
  102. package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
  103. package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.rs +6 -0
  104. package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.stderr +7 -0
  105. package/contracts/macro-integration-tests/tests/ui/contract_impl/pass/basic.rs +102 -0
  106. package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.rs +6 -0
  107. package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.stderr +7 -0
  108. package/contracts/macro-integration-tests/tests/ui/contract_trait/pass/basic.rs +83 -0
  109. package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.rs +11 -0
  110. package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.stderr +7 -0
  111. package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.rs +11 -0
  112. package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.stderr +7 -0
  113. package/contracts/macro-integration-tests/tests/ui/error/pass/basic.rs +22 -0
  114. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.rs +6 -0
  115. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.stderr +7 -0
  116. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.rs +20 -0
  117. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.stderr +20 -0
  118. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.rs +8 -0
  119. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.stderr +7 -0
  120. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.rs +10 -0
  121. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.stderr +7 -0
  122. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.rs +20 -0
  123. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.stderr +86 -0
  124. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/basic.rs +45 -0
  125. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig.rs +34 -0
  126. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig_upgradeable.rs +30 -0
  127. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable.rs +39 -0
  128. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable_no_migration.rs +28 -0
  129. package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.rs +8 -0
  130. package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.stderr +7 -0
  131. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.rs +20 -0
  132. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.stderr +12 -0
  133. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.rs +20 -0
  134. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.stderr +5 -0
  135. package/contracts/macro-integration-tests/tests/ui/multisig/pass/basic.rs +49 -0
  136. package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.rs +8 -0
  137. package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.stderr +7 -0
  138. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.rs +19 -0
  139. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.stderr +12 -0
  140. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +1 -1
  141. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +0 -8
  142. package/contracts/macro-integration-tests/tests/ui/ownable/pass/basic.rs +39 -0
  143. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +7 -1
  144. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +1 -1
  145. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +1 -1
  146. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.rs +11 -0
  147. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.stderr +7 -0
  148. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.rs +11 -0
  149. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.stderr +7 -0
  150. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.rs +11 -0
  151. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.stderr +7 -0
  152. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +1 -1
  153. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.rs +13 -0
  154. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.stderr +7 -0
  155. package/contracts/macro-integration-tests/tests/ui/storage/pass/api_surface.rs +102 -0
  156. package/contracts/macro-integration-tests/tests/ui/storage/pass/basic.rs +43 -0
  157. package/contracts/macro-integration-tests/tests/ui/storage/pass/multi_key.rs +38 -0
  158. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.rs +14 -0
  159. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.stderr +71 -0
  160. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.rs +8 -0
  161. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.stderr +7 -0
  162. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/{minimal_contract.rs → basic.rs} +2 -0
  163. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/multisig_contract.rs +28 -0
  164. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/ownable_contract.rs +32 -0
  165. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.rs +8 -0
  166. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.stderr +7 -0
  167. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/basic.rs +23 -0
  168. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/no_user_contractimpl.rs +21 -0
  169. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.rs +11 -0
  170. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.stderr +29 -0
  171. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.rs +20 -0
  172. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.stderr +71 -0
  173. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.rs +10 -0
  174. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.stderr +79 -0
  175. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.rs +8 -0
  176. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.stderr +7 -0
  177. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/basic.rs +43 -0
  178. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/multisig_contract.rs +35 -0
  179. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_migration.rs +30 -0
  180. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_user_contractimpl.rs +29 -0
  181. package/contracts/macro-integration-tests/tests/ui_contract_impl.rs +12 -0
  182. package/contracts/macro-integration-tests/tests/ui_contract_trait.rs +12 -0
  183. package/contracts/macro-integration-tests/tests/ui_lz_contract.rs +11 -0
  184. package/contracts/macro-integration-tests/tests/ui_multisig.rs +11 -0
  185. package/contracts/macro-integration-tests/tests/ui_ttl_extendable.rs +12 -0
  186. package/contracts/macro-integration-tests/tests/ui_upgradeable.rs +11 -0
  187. package/contracts/message-libs/blocked-message-lib/Cargo.toml +1 -1
  188. package/contracts/message-libs/blocked-message-lib/src/lib.rs +4 -1
  189. package/contracts/message-libs/blocked-message-lib/src/tests/blocked_message_lib_tests.rs +108 -0
  190. package/contracts/message-libs/blocked-message-lib/src/tests/mod.rs +4 -0
  191. package/contracts/message-libs/blocked-message-lib/src/tests/setup.rs +40 -0
  192. package/contracts/message-libs/simple-message-lib/src/lib.rs +1 -1
  193. package/contracts/message-libs/simple-message-lib/src/tests/mod.rs +2 -0
  194. package/contracts/message-libs/simple-message-lib/src/tests/setup.rs +124 -0
  195. package/contracts/message-libs/simple-message-lib/src/tests/simple_message_lib_tests.rs +309 -0
  196. package/contracts/message-libs/uln-302/src/errors.rs +21 -0
  197. package/contracts/message-libs/uln-302/src/interfaces/receive_uln.rs +1 -1
  198. package/contracts/message-libs/uln-302/src/receive_uln.rs +6 -4
  199. package/contracts/message-libs/uln-302/src/send_uln.rs +15 -6
  200. package/contracts/message-libs/uln-302/src/storage.rs +5 -5
  201. package/contracts/message-libs/uln-302/src/tests/uln302/get_config.rs +71 -0
  202. package/contracts/message-libs/uln-302/src/tests/uln302/mod.rs +1 -0
  203. package/contracts/message-libs/uln-302/src/uln302.rs +3 -0
  204. package/contracts/oapps/counter/Cargo.toml +2 -0
  205. package/contracts/oapps/counter/integration_tests/mod.rs +1 -0
  206. package/contracts/oapps/counter/integration_tests/setup_sml.rs +6 -4
  207. package/contracts/oapps/counter/integration_tests/setup_uln.rs +12 -5
  208. package/contracts/oapps/counter/integration_tests/test_with_blocked.rs +67 -0
  209. package/contracts/oapps/counter/src/tests/mod.rs +1 -0
  210. package/contracts/oapps/counter/src/tests/test_u256_ext.rs +48 -0
  211. package/contracts/oapps/oapp/src/lib.rs +0 -3
  212. package/contracts/oapps/oapp/src/tests/mod.rs +1 -0
  213. package/contracts/oapps/oft/integration-tests/setup.rs +2 -3
  214. package/contracts/oapps/oft/src/lib.rs +3 -0
  215. package/contracts/oapps/oft/src/tests/extensions/mod.rs +3 -0
  216. package/contracts/oapps/oft/src/tests/extensions/oft_fee.rs +240 -0
  217. package/contracts/oapps/oft/src/tests/extensions/pausable.rs +141 -0
  218. package/contracts/oapps/oft/src/tests/extensions/rate_limiter.rs +447 -0
  219. package/contracts/oapps/oft/src/tests/mod.rs +2 -0
  220. package/contracts/oapps/oft/src/tests/oft_types/lock_unlock.rs +180 -0
  221. package/contracts/oapps/oft/src/tests/oft_types/mod.rs +1 -0
  222. package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -3
  223. package/contracts/oapps/oft-core/src/lib.rs +2 -2
  224. package/contracts/oapps/oft-core/src/tests/mod.rs +1 -1
  225. package/contracts/oapps/oft-core/src/tests/{test_oft_version.rs → test_oft_version_and_approval.rs} +9 -0
  226. package/contracts/oapps/oft-core/src/tests/test_utils.rs +0 -43
  227. package/contracts/upgrader/src/tests/test_upgrader.rs +18 -0
  228. package/contracts/utils/src/auth.rs +2 -2
  229. package/contracts/utils/src/buffer_reader.rs +61 -10
  230. package/contracts/utils/src/buffer_writer.rs +35 -20
  231. package/contracts/utils/src/bytes_ext.rs +1 -2
  232. package/contracts/utils/src/errors.rs +5 -3
  233. package/contracts/utils/src/multisig.rs +59 -36
  234. package/contracts/utils/src/option_ext.rs +3 -3
  235. package/contracts/utils/src/ownable.rs +12 -6
  236. package/contracts/utils/src/tests/auth.rs +179 -0
  237. package/contracts/utils/src/tests/buffer_reader.rs +203 -1
  238. package/contracts/utils/src/tests/buffer_writer.rs +176 -5
  239. package/contracts/utils/src/tests/mod.rs +2 -0
  240. package/contracts/utils/src/tests/multisig.rs +170 -141
  241. package/contracts/utils/src/tests/option_ext.rs +1 -1
  242. package/contracts/utils/src/tests/ownable.rs +156 -161
  243. package/contracts/utils/src/tests/test_helper.rs +21 -1
  244. package/contracts/utils/src/tests/testing_utils.rs +84 -2
  245. package/contracts/utils/src/tests/ttl_configurable.rs +66 -86
  246. package/contracts/utils/src/tests/ttl_extendable.rs +64 -0
  247. package/contracts/utils/src/tests/upgradeable.rs +115 -6
  248. package/contracts/utils/src/ttl_configurable.rs +22 -12
  249. package/contracts/utils/src/ttl_extendable.rs +1 -3
  250. package/contracts/utils/src/upgradeable.rs +21 -24
  251. package/contracts/workers/dvn/src/auth.rs +1 -1
  252. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  253. package/contracts/workers/dvn/src/storage.rs +1 -1
  254. package/contracts/workers/dvn/src/tests/auth.rs +136 -3
  255. package/contracts/workers/dvn/src/tests/mod.rs +0 -1
  256. package/contracts/workers/dvn/src/tests/setup.rs +4 -10
  257. package/contracts/workers/executor-helper/src/tests/executor_helper.rs +279 -0
  258. package/contracts/workers/executor-helper/src/tests/setup.rs +106 -1
  259. package/contracts/workers/worker/src/worker.rs +1 -1
  260. package/docs/oft-guide.md +5 -5
  261. package/package.json +5 -7
  262. package/sdk/.turbo/turbo-test.log +662 -466
  263. package/sdk/LICENSE +23 -0
  264. package/sdk/dist/generated/bml.d.ts +101 -106
  265. package/sdk/dist/generated/bml.js +108 -26
  266. package/sdk/dist/generated/counter.d.ts +123 -484
  267. package/sdk/dist/generated/counter.js +103 -25
  268. package/sdk/dist/generated/dvn.d.ts +141 -699
  269. package/sdk/dist/generated/dvn.js +106 -28
  270. package/sdk/dist/generated/dvn_fee_lib.d.ts +31 -248
  271. package/sdk/dist/generated/dvn_fee_lib.js +27 -24
  272. package/sdk/dist/generated/endpoint.d.ts +158 -836
  273. package/sdk/dist/generated/endpoint.js +107 -29
  274. package/sdk/dist/generated/executor.d.ts +139 -671
  275. package/sdk/dist/generated/executor.js +106 -28
  276. package/sdk/dist/generated/executor_fee_lib.d.ts +109 -264
  277. package/sdk/dist/generated/executor_fee_lib.js +106 -28
  278. package/sdk/dist/generated/executor_helper.d.ts +95 -92
  279. package/sdk/dist/generated/executor_helper.js +103 -25
  280. package/sdk/dist/generated/layerzero_view.d.ts +178 -335
  281. package/sdk/dist/generated/layerzero_view.js +172 -33
  282. package/sdk/dist/generated/oft.d.ts +137 -680
  283. package/sdk/dist/generated/oft.js +103 -25
  284. package/sdk/dist/generated/price_feed.d.ts +45 -444
  285. package/sdk/dist/generated/price_feed.js +27 -24
  286. package/sdk/dist/generated/sml.d.ts +119 -428
  287. package/sdk/dist/generated/sml.js +103 -25
  288. package/sdk/dist/generated/treasury.d.ts +109 -288
  289. package/sdk/dist/generated/treasury.js +103 -25
  290. package/sdk/dist/generated/uln302.d.ts +190 -527
  291. package/sdk/dist/generated/uln302.js +170 -31
  292. package/sdk/dist/generated/upgrader.d.ts +14 -34
  293. package/sdk/dist/generated/upgrader.js +24 -21
  294. package/sdk/package.json +3 -4
  295. package/sdk/test/counter-sml.test.ts +218 -142
  296. package/sdk/test/counter-uln.test.ts +189 -145
  297. package/sdk/test/oft-sml.test.ts +173 -156
  298. package/sdk/test/suites/constants.ts +7 -1
  299. package/sdk/test/suites/globalSetup.ts +140 -74
  300. package/sdk/turbo.json +1 -1
  301. package/tools/ts-bindings-gen/Cargo.toml +4 -4
  302. package/tools/ts-bindings-gen/src/main.rs +4 -0
  303. package/turbo.json +3 -0
  304. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +0 -1072
  305. package/contracts/endpoint-v2/src/constants.rs +0 -52
  306. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +0 -12
  307. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +0 -7
  308. package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +0 -20
  309. package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +0 -15
  310. package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +0 -16
  311. package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +0 -26
  312. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +0 -21
  313. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +0 -12
  314. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +0 -7
  315. package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +0 -14
  316. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +0 -14
  317. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +0 -16
  318. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +0 -15
  319. package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +0 -14
  320. package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +0 -19
  321. package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +0 -15
  322. package/contracts/message-libs/simple-message-lib/src/test.rs +0 -280
  323. package/contracts/oapps/oapp/src/macro_tests/mod.rs +0 -1
  324. package/contracts/workers/dvn/src/tests/multisig/mod.rs +0 -3
  325. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +0 -132
  326. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +0 -109
  327. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +0 -106
  328. /package/contracts/oapps/oapp/src/{macro_tests → tests}/test_macros.rs +0 -0
@@ -61,10 +61,9 @@ impl Parse for UpgradeableConfig {
61
61
  pub fn generate_upgradeable_impl(attr: TokenStream, input: TokenStream) -> TokenStream {
62
62
  let config: UpgradeableConfig =
63
63
  syn::parse2(attr).unwrap_or_else(|e| panic!("failed to parse upgradeable config: {}", e));
64
- let item_struct: ItemStruct =
65
- syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
66
- let name = &item_struct.ident;
64
+ let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
67
65
 
66
+ let name = &item_struct.ident;
68
67
  let binver = set_binver_from_env();
69
68
 
70
69
  // Generate default UpgradeableInternal impl only when no_migration is set
@@ -109,3 +108,22 @@ fn set_binver_from_env() -> TokenStream {
109
108
  _ => quote! {},
110
109
  }
111
110
  }
111
+
112
+ #[cfg(test)]
113
+ mod tests {
114
+ use std::env;
115
+
116
+ use super::*;
117
+
118
+ #[test]
119
+ fn test_set_binver_from_env_zero_version() {
120
+ // Set version to 0.0.0
121
+ env::set_var("CARGO_PKG_VERSION", "0.0.0");
122
+
123
+ let result = set_binver_from_env();
124
+ let result_str = result.to_string();
125
+
126
+ // Should return empty tokens
127
+ assert_eq!(result_str.trim(), "");
128
+ }
129
+ }
@@ -12,10 +12,6 @@ doctest = false
12
12
  [features]
13
13
  library = []
14
14
  testutils = []
15
- # Network selection
16
- mainnet = []
17
- testnet = []
18
- sandbox = []
19
15
 
20
16
  [dependencies]
21
17
  cfg-if = { workspace = true }
@@ -1,5 +1,4 @@
1
1
  use crate::{
2
- constants::{NATIVE_TOKEN, STELLAR_EID},
3
2
  errors::EndpointError,
4
3
  events::{DelegateSet, LzReceiveAlert, PacketDelivered, PacketSent, PacketVerified, ZroSet},
5
4
  interfaces::{ILayerZeroEndpointV2, IMessageLibManager, IMessagingChannel, MessagingFee, MessagingReceipt, Origin},
@@ -17,8 +16,10 @@ pub struct EndpointV2;
17
16
 
18
17
  #[contract_impl]
19
18
  impl EndpointV2 {
20
- pub fn __constructor(env: &Env, owner: &Address) {
19
+ pub fn __constructor(env: &Env, owner: &Address, eid: u32, native_token: &Address) {
21
20
  Self::init_owner(env, owner);
21
+ EndpointStorage::set_eid(env, &eid);
22
+ EndpointStorage::set_native_token(env, native_token);
22
23
  }
23
24
 
24
25
  /// Recovers tokens sent to this contract by mistake.
@@ -49,7 +50,10 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
49
50
  let nonce = Self::outbound_nonce(env, sender, *dst_eid, receiver) + 1;
50
51
  let packet = Self::build_outbound_packet(env, sender, *dst_eid, receiver, message, nonce);
51
52
 
52
- SendLibClient::new(env, &send_lib).quote(&packet, options, pay_in_zro)
53
+ let fee = SendLibClient::new(env, &send_lib).quote(&packet, options, pay_in_zro);
54
+ assert_with_error!(env, fee.native_fee >= 0 && fee.zro_fee >= 0, EndpointError::InvalidFeeAmount);
55
+
56
+ fee
53
57
  }
54
58
 
55
59
  /// Sends a cross-chain message to a destination endpoint.
@@ -155,8 +159,8 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
155
159
  // ============================================================================================
156
160
 
157
161
  /// Returns the endpoint ID.
158
- fn eid(_env: &Env) -> u32 {
159
- STELLAR_EID
162
+ fn eid(env: &Env) -> u32 {
163
+ EndpointStorage::eid(env).unwrap()
160
164
  }
161
165
 
162
166
  /// Checks if a messaging path can be/has been initialized for the given origin and receiver.
@@ -174,7 +178,7 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
174
178
 
175
179
  /// Returns the native token address used for fee payments.
176
180
  fn native_token(env: &Env) -> Address {
177
- Address::from_str(env, NATIVE_TOKEN)
181
+ EndpointStorage::native_token(env).unwrap()
178
182
  }
179
183
 
180
184
  /// Returns the ZRO token address if set.
@@ -216,7 +220,7 @@ impl EndpointV2 {
216
220
  }
217
221
 
218
222
  /// Requires authorization from either the OApp itself or its delegate.
219
- pub(crate) fn require_oapp_auth(env: &Env, caller: &Address, oapp: &Address) {
223
+ fn require_oapp_auth(env: &Env, caller: &Address, oapp: &Address) {
220
224
  assert_with_error!(
221
225
  env,
222
226
  caller == oapp || Self::delegate(env, oapp).as_ref() == Some(caller),
@@ -235,7 +239,7 @@ impl EndpointV2 {
235
239
  ///
236
240
  /// # Returns
237
241
  /// The total `MessagingFee` paid (native_fee + zro_fee)
238
- pub(crate) fn pay_messaging_fees(
242
+ fn pay_messaging_fees(
239
243
  env: &Env,
240
244
  pay_in_zro: bool,
241
245
  native_fee_recipients: &Vec<FeeRecipient>,
@@ -255,9 +259,9 @@ impl EndpointV2 {
255
259
  assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
256
260
  if r.amount > 0 {
257
261
  assert_with_error!(env, native_fee_supplied >= r.amount, EndpointError::InsufficientNativeFee);
258
- native_token_client.transfer(&this_contract, &r.to, &r.amount);
259
262
  native_fee_supplied -= r.amount;
260
263
  fee_paid.native_fee += r.amount;
264
+ native_token_client.transfer(&this_contract, &r.to, &r.amount);
261
265
  }
262
266
  });
263
267
  // Refund remaining native fees
@@ -284,9 +288,9 @@ impl EndpointV2 {
284
288
  assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
285
289
  if r.amount > 0 {
286
290
  assert_with_error!(env, zro_fee_supplied >= r.amount, EndpointError::InsufficientZroFee);
287
- zro_client.transfer(&this_contract, &r.to, &r.amount);
288
291
  zro_fee_supplied -= r.amount;
289
292
  fee_paid.zro_fee += r.amount;
293
+ zro_client.transfer(&this_contract, &r.to, &r.amount);
290
294
  }
291
295
  });
292
296
  // Refund remaining ZRO fees
@@ -299,6 +303,13 @@ impl EndpointV2 {
299
303
  }
300
304
  }
301
305
 
306
+ #[path = "message_lib_manager.rs"]
307
+ mod message_lib_manager;
308
+ #[path = "messaging_channel.rs"]
309
+ mod messaging_channel;
310
+ #[path = "messaging_composer.rs"]
311
+ mod messaging_composer;
312
+
302
313
  // ============================================================================
303
314
  // Test-only Functions
304
315
  // ============================================================================
@@ -319,12 +330,21 @@ mod test {
319
330
  ) -> OutboundPacket {
320
331
  Self::build_outbound_packet(env, sender, dst_eid, receiver, message, nonce)
321
332
  }
333
+
334
+ /// Test-only wrapper for require_oapp_auth.
335
+ pub fn require_oapp_auth_for_test(env: &Env, caller: &Address, oapp: &Address) {
336
+ Self::require_oapp_auth(env, caller, oapp)
337
+ }
338
+
339
+ /// Test-only wrapper for pay_messaging_fees.
340
+ pub fn pay_messaging_fees_for_test(
341
+ env: &Env,
342
+ pay_in_zro: bool,
343
+ native_fee_recipients: &Vec<FeeRecipient>,
344
+ zro_fee_recipients: &Vec<FeeRecipient>,
345
+ refund_address: &Address,
346
+ ) -> MessagingFee {
347
+ Self::pay_messaging_fees(env, pay_in_zro, native_fee_recipients, zro_fee_recipients, refund_address)
348
+ }
322
349
  }
323
350
  }
324
-
325
- #[path = "message_lib_manager.rs"]
326
- mod message_lib_manager;
327
- #[path = "messaging_channel.rs"]
328
- mod messaging_channel;
329
- #[path = "messaging_composer.rs"]
330
- mod messaging_composer;
@@ -2,29 +2,54 @@ use common_macros::contract_error;
2
2
 
3
3
  #[contract_error]
4
4
  pub enum EndpointError {
5
+ /// Library is already registered with the endpoint
5
6
  AlreadyRegistered,
7
+ /// Compose message already exists for this GUID and index
6
8
  ComposeExists,
9
+ /// Compose message not found for the given GUID and index
7
10
  ComposeNotFound,
11
+ /// Default receive library is not set for the source endpoint
8
12
  DefaultReceiveLibUnavailable,
13
+ /// Default send library is not set for the destination endpoint
9
14
  DefaultSendLibUnavailable,
15
+ /// Supplied native token fee is less than required
10
16
  InsufficientNativeFee,
17
+ /// Supplied ZRO token fee is less than required
11
18
  InsufficientZroFee,
12
- InvalidFeeAmount,
19
+ /// Timeout expiry is invalid (already expired)
13
20
  InvalidExpiry,
21
+ /// Fee amount is invalid (negative)
22
+ InvalidFeeAmount,
23
+ /// Compose index exceeds maximum allowed value
14
24
  InvalidIndex,
25
+ /// Nonce is invalid for the requested operation
15
26
  InvalidNonce,
27
+ /// Payload hash is invalid (empty hash not allowed)
16
28
  InvalidPayloadHash,
29
+ /// Receive library is not valid for the receiver and source endpoint
17
30
  InvalidReceiveLibrary,
31
+ /// Operation requires a non-default (custom) library
18
32
  OnlyNonDefaultLib,
33
+ /// Library must support receiving messages
19
34
  OnlyReceiveLib,
35
+ /// Library must be registered with the endpoint
20
36
  OnlyRegisteredLib,
37
+ /// Library must support sending messages
21
38
  OnlySendLib,
39
+ /// Messaging path cannot be initialized for the given origin
22
40
  PathNotInitializable,
41
+ /// Message cannot be verified for the given origin
23
42
  PathNotVerifiable,
43
+ /// Payload hash does not match the stored hash
24
44
  PayloadHashNotFound,
45
+ /// New value is the same as existing value
25
46
  SameValue,
47
+ /// Caller is not authorized (not OApp or delegate)
26
48
  Unauthorized,
49
+ /// Endpoint ID is not supported by the library
27
50
  UnsupportedEid,
51
+ /// ZRO fee must be greater than zero when pay_in_zro is true
28
52
  ZeroZroFee,
53
+ /// ZRO token address is not set
29
54
  ZroUnavailable,
30
55
  }
@@ -122,7 +122,7 @@ pub trait ILayerZeroEndpointV2: IMessageLibManager + IMessagingChannel + IMessag
122
122
  /// * `origin` - The origin of the message
123
123
  /// * `receiver` - The OApp address
124
124
  /// * `guid` - The message GUID
125
- /// * `gas` - The gas provided for execution
125
+ /// * `gas` - The fee provided for execution (named "gas" for cross-chain interface consistency, though Stellar uses fees not gas)
126
126
  /// * `value` - The value provided for execution
127
127
  /// * `message` - The message content
128
128
  /// * `extra_data` - Additional data for execution
@@ -4,9 +4,9 @@ use soroban_sdk::{contractclient, contracttype, Address, Bytes, Env, Vec};
4
4
  #[contracttype]
5
5
  #[derive(Clone, Debug, Eq, PartialEq)]
6
6
  pub struct Timeout {
7
- /// The new library address to transition to.
7
+ /// The old library address that remains valid during the grace period.
8
8
  pub lib: Address,
9
- /// Unix timestamp when the timeout expires.
9
+ /// Unix timestamp in seconds when the timeout expires.
10
10
  pub expiry: u64,
11
11
  }
12
12
 
@@ -144,7 +144,7 @@ pub trait IMessageLibManager {
144
144
  ///
145
145
  /// # Arguments
146
146
  /// * `caller` - The caller address, must be the OApp or its delegate
147
- /// * `sender` - The receiver OApp address
147
+ /// * `sender` - The sender OApp address
148
148
  /// * `dst_eid` - The destination endpoint ID
149
149
  /// * `new_lib` - The library address, or `None` to use the default
150
150
  fn set_send_library(env: &Env, caller: &Address, sender: &Address, dst_eid: u32, new_lib: &Option<Address>);
@@ -152,7 +152,7 @@ pub trait IMessageLibManager {
152
152
  /// Returns the effective send library for an OApp and destination endpoint.
153
153
  ///
154
154
  /// # Arguments
155
- /// * `sender` - The receiver OApp address
155
+ /// * `sender` - The sender OApp address
156
156
  /// * `dst_eid` - The destination endpoint ID
157
157
  fn get_send_library(env: &Env, sender: &Address, dst_eid: u32) -> ResolvedLibrary;
158
158
 
@@ -33,7 +33,7 @@ pub trait IMessagingComposer {
33
33
  /// * `to` - The composer address
34
34
  /// * `guid` - The message GUID
35
35
  /// * `index` - The compose message index
36
- /// * `gas` - The gas provided for execution
36
+ /// * `gas` - The fee provided for execution (named "gas" for cross-chain interface consistency, though Stellar uses fees not gas)
37
37
  /// * `value` - The value provided for execution
38
38
  /// * `message` - The composed message content
39
39
  /// * `extra_data` - Additional data for execution
@@ -45,7 +45,7 @@ pub trait IMessagingComposer {
45
45
  to: &Address,
46
46
  guid: &BytesN<32>,
47
47
  index: u32,
48
- gas: i128, // TODO: should rename to fee cuz there's no gas in stellar
48
+ gas: i128,
49
49
  value: i128,
50
50
  message: &Bytes,
51
51
  extra_data: &Bytes,
@@ -1,6 +1,5 @@
1
1
  #![no_std]
2
2
 
3
- pub mod constants;
4
3
  pub mod events;
5
4
  pub mod util;
6
5
 
@@ -28,7 +28,7 @@ impl IMessageLibManager for EndpointV2 {
28
28
  let index = Self::registered_libraries_count(env);
29
29
  EndpointStorage::set_library_to_index(env, new_lib, &index);
30
30
  EndpointStorage::set_index_to_library(env, index, new_lib);
31
- EndpointStorage::set_registered_library_count(env, &(index + 1)); // increment the registered library count
31
+ EndpointStorage::set_registered_libraries_count(env, &(index + 1)); // increment the registered library count
32
32
 
33
33
  LibraryRegistered { new_lib: new_lib.clone() }.publish(env);
34
34
  }
@@ -159,7 +159,7 @@ impl IMessageLibManager for EndpointV2 {
159
159
  ) {
160
160
  Self::require_oapp_auth(env, caller, receiver);
161
161
 
162
- // Only if receive_library is set, we can set the timeout
162
+ // OApp can only set timeout for non-default receive libraries
163
163
  let ResolvedLibrary { lib: _, is_default } = Self::get_receive_library(env, receiver, src_eid);
164
164
  assert_with_error!(env, !is_default, EndpointError::OnlyNonDefaultLib);
165
165
 
@@ -197,12 +197,12 @@ impl IMessageLibManager for EndpointV2 {
197
197
 
198
198
  /// Returns the number of registered message libraries.
199
199
  fn registered_libraries_count(env: &Env) -> u32 {
200
- EndpointStorage::registered_library_count(env)
200
+ EndpointStorage::registered_libraries_count(env)
201
201
  }
202
202
 
203
203
  /// Returns a list of registered message libraries within the specified range.
204
204
  fn get_registered_libraries(env: &Env, start: u32, max_count: u32) -> Vec<Address> {
205
- let count = EndpointStorage::registered_library_count(env);
205
+ let count = EndpointStorage::registered_libraries_count(env);
206
206
  if count == 0 || start >= count {
207
207
  return vec![env];
208
208
  }
@@ -296,18 +296,18 @@ impl IMessageLibManager for EndpointV2 {
296
296
 
297
297
  impl EndpointV2 {
298
298
  /// Requires a message library to be registered.
299
- pub(crate) fn require_registered(env: &Env, lib: &Address) {
299
+ fn require_registered(env: &Env, lib: &Address) {
300
300
  assert_with_error!(env, Self::is_registered_library(env, lib), EndpointError::OnlyRegisteredLib);
301
301
  }
302
302
 
303
303
  /// Requires an endpoint ID to be supported.
304
- pub(crate) fn require_supported_eid(env: &Env, lib: &Address, eid: u32) {
304
+ fn require_supported_eid(env: &Env, lib: &Address, eid: u32) {
305
305
  let is_supported = MessageLibClient::new(env, lib).is_supported_eid(&eid);
306
306
  assert_with_error!(env, is_supported, EndpointError::UnsupportedEid);
307
307
  }
308
308
 
309
309
  /// Requires a library to be a registered send library and supported for the given endpoint ID.
310
- pub(crate) fn require_send_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
310
+ fn require_send_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
311
311
  Self::require_registered(env, lib);
312
312
 
313
313
  let message_lib_type = MessageLibClient::new(env, lib).message_lib_type();
@@ -321,7 +321,7 @@ impl EndpointV2 {
321
321
  }
322
322
 
323
323
  /// Requires a library to be a registered receive library and supported for the given endpoint ID.
324
- pub(crate) fn require_receive_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
324
+ fn require_receive_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
325
325
  Self::require_registered(env, lib);
326
326
 
327
327
  let message_lib_type = MessageLibClient::new(env, lib).message_lib_type();
@@ -334,3 +334,34 @@ impl EndpointV2 {
334
334
  Self::require_supported_eid(env, lib, eid);
335
335
  }
336
336
  }
337
+
338
+ // ============================================================================
339
+ // Test-only Functions
340
+ // ============================================================================
341
+
342
+ #[cfg(test)]
343
+ mod test {
344
+ use super::*;
345
+
346
+ impl EndpointV2 {
347
+ /// Test-only wrapper for require_registered.
348
+ pub fn require_registered_for_test(env: &Env, lib: &Address) {
349
+ Self::require_registered(env, lib)
350
+ }
351
+
352
+ /// Test-only wrapper for require_supported_eid.
353
+ pub fn require_supported_eid_for_test(env: &Env, lib: &Address, eid: u32) {
354
+ Self::require_supported_eid(env, lib, eid)
355
+ }
356
+
357
+ /// Test-only wrapper for require_send_lib_for_eid.
358
+ pub fn require_send_lib_for_eid_for_test(env: &Env, lib: &Address, eid: u32) {
359
+ Self::require_send_lib_for_eid(env, lib, eid)
360
+ }
361
+
362
+ /// Test-only wrapper for require_receive_lib_for_eid.
363
+ pub fn require_receive_lib_for_eid_for_test(env: &Env, lib: &Address, eid: u32) {
364
+ Self::require_receive_lib_for_eid(env, lib, eid)
365
+ }
366
+ }
367
+ }
@@ -1,6 +1,5 @@
1
1
  use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
2
2
  use crate::{
3
- constants::{EMPTY_PAYLOAD_HASH_BYTES, NIL_PAYLOAD_HASH_BYTES},
4
3
  errors::EndpointError,
5
4
  events::{InboundNonceSkipped, PacketBurnt, PacketNilified},
6
5
  interfaces::{ILayerZeroEndpointV2, IMessagingChannel},
@@ -10,6 +9,12 @@ use crate::{
10
9
  use common_macros::contract_impl;
11
10
  use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
12
11
 
12
+ /// Represents an empty payload hash (equivalent to bytes32(uint256(0)) in Solidity)
13
+ const EMPTY_PAYLOAD_HASH_BYTES: [u8; 32] = [0u8; 32];
14
+
15
+ /// Represents a nilified payload hash (equivalent to bytes32(type(uint256).max) in Solidity)
16
+ const NIL_PAYLOAD_HASH_BYTES: [u8; 32] = [0xffu8; 32];
17
+
13
18
  #[contract_impl]
14
19
  impl IMessagingChannel for EndpointV2 {
15
20
  /// Skips the next expected inbound nonce without verifying.
@@ -72,7 +77,7 @@ impl IMessagingChannel for EndpointV2 {
72
77
  let cur_payload_hash = Self::inbound_payload_hash(env, receiver, src_eid, sender, nonce);
73
78
  assert_with_error!(env, cur_payload_hash.as_ref() == Some(payload_hash), EndpointError::PayloadHashNotFound);
74
79
 
75
- // Check if nonce is greater than lazy nonce
80
+ // Check if nonce is at or below the lazy nonce
76
81
  let lazy_nonce = Self::lazy_inbound_nonce(env, receiver, src_eid, sender);
77
82
  assert_with_error!(env, nonce <= lazy_nonce, EndpointError::InvalidNonce);
78
83
 
@@ -187,6 +192,12 @@ impl EndpointV2 {
187
192
  /// Note: This function does not change `inbound_nonce`, it only changes
188
193
  /// the `lazy_inbound_nonce` up to the provided nonce.
189
194
  ///
195
+ /// # EVM Alignment
196
+ /// This implementation aligns with the EVM endpoint behavior. Executors should call
197
+ /// `clear` from lower nonce to higher nonce sequentially. This ensures the range check
198
+ /// `(current_nonce + 1..=nonce)` remains small, avoiding long iteration when verifying
199
+ /// that all intermediate nonces have been verified.
200
+ ///
190
201
  /// # Arguments
191
202
  /// * `receiver` - The receiver OApp address
192
203
  /// * `src_eid` - The source endpoint ID
@@ -221,12 +232,33 @@ impl EndpointV2 {
221
232
  }
222
233
 
223
234
  /// Represents an empty payload hash
224
- pub(crate) fn empty_payload_hash(env: &Env) -> BytesN<32> {
235
+ fn empty_payload_hash(env: &Env) -> BytesN<32> {
225
236
  BytesN::from_array(env, &EMPTY_PAYLOAD_HASH_BYTES)
226
237
  }
227
238
 
228
239
  /// Represents a nilified payload hash
229
- pub(crate) fn nil_payload_hash(env: &Env) -> BytesN<32> {
240
+ fn nil_payload_hash(env: &Env) -> BytesN<32> {
230
241
  BytesN::from_array(env, &NIL_PAYLOAD_HASH_BYTES)
231
242
  }
232
243
  }
244
+
245
+ // ============================================================================
246
+ // Test-only Functions
247
+ // ============================================================================
248
+
249
+ #[cfg(test)]
250
+ mod test {
251
+ use super::*;
252
+
253
+ impl EndpointV2 {
254
+ /// Test-only wrapper for empty_payload_hash.
255
+ pub fn empty_payload_hash_for_test(env: &Env) -> BytesN<32> {
256
+ Self::empty_payload_hash(env)
257
+ }
258
+
259
+ /// Test-only wrapper for nil_payload_hash.
260
+ pub fn nil_payload_hash_for_test(env: &Env) -> BytesN<32> {
261
+ Self::nil_payload_hash(env)
262
+ }
263
+ }
264
+ }
@@ -1,6 +1,5 @@
1
1
  use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
2
2
  use crate::{
3
- constants::{MAX_COMPOSE_INDEX, RECEIVED_MESSAGE_HASH_BYTES},
4
3
  errors::EndpointError,
5
4
  events::{ComposeDelivered, ComposeSent, LzComposeAlert},
6
5
  storage::EndpointStorage,
@@ -10,6 +9,13 @@ use crate::{
10
9
  use common_macros::contract_impl;
11
10
  use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
12
11
 
12
+ /// Represents a received message hash marker (equivalent to bytes32(uint256(1)) in Solidity)
13
+ const RECEIVED_MESSAGE_HASH_BYTES: [u8; 32] =
14
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
15
+
16
+ /// Represents the maximum compose index (equivalent to uint16.max in Solidity)
17
+ const MAX_COMPOSE_INDEX: u32 = u16::MAX as u32;
18
+
13
19
  #[contract_impl]
14
20
  impl IMessagingComposer for EndpointV2 {
15
21
  /// Sends a composed message from an OApp to a composer.
@@ -18,7 +24,7 @@ impl IMessagingComposer for EndpointV2 {
18
24
  /// With the same GUID, the OApp can send compose to multiple composers at the same time.
19
25
  fn send_compose(env: &Env, from: &Address, to: &Address, guid: &BytesN<32>, index: u32, message: &Bytes) {
20
26
  from.require_auth();
21
- assert_with_error!(env, index <= MAX_COMPOSE_INDEX, EndpointError::InvalidIndex);
27
+ assert_compose_index(env, index);
22
28
 
23
29
  let compose_queue = Self::compose_queue(env, from, to, guid, index);
24
30
  assert_with_error!(env, compose_queue.is_none(), EndpointError::ComposeExists);
@@ -34,12 +40,16 @@ impl IMessagingComposer for EndpointV2 {
34
40
  /// This is a PULL mode versus the PUSH mode of `lz_compose`.
35
41
  fn clear_compose(env: &Env, composer: &Address, from: &Address, guid: &BytesN<32>, index: u32, message: &Bytes) {
36
42
  composer.require_auth();
37
- assert_with_error!(env, index <= MAX_COMPOSE_INDEX, EndpointError::InvalidIndex);
43
+ assert_compose_index(env, index);
38
44
 
39
45
  let expected_hash = Self::compose_queue(env, from, composer, guid, index);
40
46
  let actual_hash = keccak256(env, message);
41
47
  assert_with_error!(env, expected_hash == Some(actual_hash), EndpointError::ComposeNotFound);
42
48
 
49
+ // Marks the message as received to prevent reentrancy.
50
+ // Cannot just delete the value, otherwise the message can be sent again and could result
51
+ // in some undefined behaviour even though the sender (composing OApp) is implicitly fully
52
+ // trusted by the composer. e.g. sender may not even realize it has such a bug.
43
53
  let received_hash = BytesN::from_array(env, &RECEIVED_MESSAGE_HASH_BYTES);
44
54
  EndpointStorage::set_compose_queue(env, from, composer, guid, index, &received_hash);
45
55
 
@@ -63,7 +73,7 @@ impl IMessagingComposer for EndpointV2 {
63
73
  reason: &Bytes,
64
74
  ) {
65
75
  executor.require_auth();
66
- assert_with_error!(env, index <= MAX_COMPOSE_INDEX, EndpointError::InvalidIndex);
76
+ assert_compose_index(env, index);
67
77
  LzComposeAlert {
68
78
  executor: executor.clone(),
69
79
  from: from.clone(),
@@ -88,3 +98,7 @@ impl IMessagingComposer for EndpointV2 {
88
98
  EndpointStorage::compose_queue(env, from, to, guid, index)
89
99
  }
90
100
  }
101
+
102
+ fn assert_compose_index(env: &Env, index: u32) {
103
+ assert_with_error!(env, index <= MAX_COMPOSE_INDEX, EndpointError::InvalidIndex);
104
+ }
@@ -4,6 +4,14 @@ use soroban_sdk::{Address, BytesN};
4
4
 
5
5
  #[storage]
6
6
  pub enum EndpointStorage {
7
+ /// The endpoint ID for this chain
8
+ #[instance(u32)]
9
+ Eid,
10
+
11
+ /// The native token address used for messaging fee payments
12
+ #[instance(Address)]
13
+ NativeToken,
14
+
7
15
  /// The ZRO token address
8
16
  #[instance(Address)]
9
17
  Zro,
@@ -37,7 +45,7 @@ pub enum EndpointStorage {
37
45
  /// The number of registered libraries
38
46
  #[instance(u32)]
39
47
  #[default(0)]
40
- RegisteredLibraryCount,
48
+ RegisteredLibrariesCount,
41
49
 
42
50
  /// The mapping of library to index
43
51
  #[persistent(u32)]
@@ -40,9 +40,9 @@ pub fn setup<'a>() -> TestSetup<'a> {
40
40
  let zro_token_client = StellarAssetClient::new(&env, &zro_token_address);
41
41
 
42
42
  // Deploy the endpoint contract
43
- let contract_id = env.register(EndpointV2, (&owner,));
43
+ let eid: u32 = 30400; // Test EID
44
+ let contract_id = env.register(EndpointV2, (&owner, eid, &native_token_address));
44
45
  let endpoint_client = EndpointV2Client::new(&env, &contract_id);
45
- let eid = endpoint_client.eid();
46
46
 
47
47
  TestSetup { eid, endpoint_client, env, owner, contract_id, native_token_client, zro_token_client }
48
48
  }
@@ -23,7 +23,7 @@ fn pay_messaging_fees(
23
23
  let env = &context.env;
24
24
  let endpoint_addr = &context.endpoint_client.address;
25
25
  env.as_contract(endpoint_addr, || {
26
- EndpointV2::pay_messaging_fees(env, pay_in_zro, native_fee_recipients, zro_fee_recipients, refund_address)
26
+ EndpointV2::pay_messaging_fees_for_test(env, pay_in_zro, native_fee_recipients, zro_fee_recipients, refund_address)
27
27
  })
28
28
  }
29
29
 
@@ -30,7 +30,7 @@ fn test_require_oapp_auth_unauthorized() {
30
30
 
31
31
  // Unauthorized address (not oapp itself and not delegate) should fail with Unauthorized error
32
32
  env.as_contract(&endpoint_client.address, || {
33
- EndpointV2::require_oapp_auth(env, &unauthorized, &oapp);
33
+ EndpointV2::require_oapp_auth_for_test(env, &unauthorized, &oapp);
34
34
  });
35
35
  }
36
36
 
@@ -51,6 +51,6 @@ fn test_require_oapp_auth_wrong_delegate() {
51
51
 
52
52
  // Wrong delegate (not the actual delegate) should fail with Unauthorized error
53
53
  env.as_contract(&endpoint_client.address, || {
54
- EndpointV2::require_oapp_auth(env, &wrong_delegate, &oapp);
54
+ EndpointV2::require_oapp_auth_for_test(env, &wrong_delegate, &oapp);
55
55
  });
56
56
  }
@@ -45,7 +45,7 @@ fn test_register_library() {
45
45
  let stored_lib = storage::EndpointStorage::index_to_library(env, 0);
46
46
  assert_eq!(stored_lib, Some(lib_clone.clone()));
47
47
 
48
- let new_count = storage::EndpointStorage::registered_library_count(env);
48
+ let new_count = storage::EndpointStorage::registered_libraries_count(env);
49
49
  assert_eq!(new_count, 1);
50
50
 
51
51
  let has_library = storage::EndpointStorage::has_library_to_index(env, &lib_clone);
@@ -90,7 +90,7 @@ fn test_register_library_is_unsupported_interface() {
90
90
 
91
91
  // Verify no partial storage updates.
92
92
  env.as_contract(&endpoint_client.address, || {
93
- assert_eq!(storage::EndpointStorage::registered_library_count(env), 0);
93
+ assert_eq!(storage::EndpointStorage::registered_libraries_count(env), 0);
94
94
  assert_eq!(storage::EndpointStorage::library_to_index(env, &invalid_lib), None);
95
95
  assert!(!storage::EndpointStorage::has_library_to_index(env, &invalid_lib));
96
96
  });
@@ -144,7 +144,7 @@ fn test_register_multiple_libraries_assigns_sequential_indices_and_orders_result
144
144
  let lib0c = lib0.clone();
145
145
  let lib1c = lib1.clone();
146
146
  env.as_contract(&endpoint_client.address, || {
147
- assert_eq!(storage::EndpointStorage::registered_library_count(env), 2);
147
+ assert_eq!(storage::EndpointStorage::registered_libraries_count(env), 2);
148
148
  assert_eq!(storage::EndpointStorage::library_to_index(env, &lib0c), Some(0));
149
149
  assert_eq!(storage::EndpointStorage::library_to_index(env, &lib1c), Some(1));
150
150
  assert_eq!(storage::EndpointStorage::index_to_library(env, 0), Some(lib0c));