@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.19

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 (262) hide show
  1. package/.turbo/turbo-build.log +365 -297
  2. package/.turbo/turbo-lint.log +142 -110
  3. package/.turbo/turbo-test.log +1273 -1222
  4. package/Cargo.lock +20 -5
  5. package/Cargo.toml +4 -1
  6. package/contracts/ERROR_SPEC.md +44 -0
  7. package/contracts/common-macros/src/auth.rs +113 -0
  8. package/contracts/common-macros/src/contract_ttl.rs +84 -0
  9. package/contracts/common-macros/src/lib.rs +181 -30
  10. package/contracts/common-macros/src/lz_contract.rs +83 -0
  11. package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
  13. package/contracts/common-macros/src/tests/mod.rs +2 -2
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
  16. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
  17. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
  21. package/contracts/common-macros/src/ttl_configurable.rs +19 -34
  22. package/contracts/common-macros/src/ttl_extendable.rs +36 -0
  23. package/contracts/common-macros/src/upgradeable.rs +5 -5
  24. package/contracts/common-macros/src/utils.rs +9 -0
  25. package/contracts/endpoint-v2/src/constants.rs +4 -4
  26. package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
  27. package/contracts/endpoint-v2/src/errors.rs +4 -3
  28. package/contracts/endpoint-v2/src/events.rs +1 -1
  29. package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
  30. package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
  31. package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
  32. package/contracts/endpoint-v2/src/storage.rs +1 -1
  33. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
  34. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  38. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
  39. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
  40. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
  41. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
  42. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
  43. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
  44. package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
  45. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
  46. package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
  47. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
  48. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
  49. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
  50. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
  51. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
  52. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
  53. package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
  54. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
  55. package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
  56. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
  57. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
  58. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
  59. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
  60. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
  61. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
  62. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
  63. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
  64. package/contracts/message-libs/treasury/src/errors.rs +2 -2
  65. package/contracts/message-libs/treasury/src/events.rs +1 -1
  66. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
  67. package/contracts/message-libs/treasury/src/storage.rs +1 -1
  68. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
  69. package/contracts/message-libs/treasury/src/treasury.rs +14 -16
  70. package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
  71. package/contracts/message-libs/uln-302/src/send_uln.rs +24 -4
  72. package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
  73. package/contracts/oapps/counter/Cargo.toml +14 -1
  74. package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
  75. package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
  76. package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
  77. package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
  78. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
  79. package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
  80. package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
  81. package/contracts/oapps/counter/src/counter.rs +67 -43
  82. package/contracts/oapps/counter/src/tests/mod.rs +0 -13
  83. package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
  84. package/contracts/oapps/oapp/src/errors.rs +5 -1
  85. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
  86. package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
  87. package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
  88. package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
  89. package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
  90. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
  91. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
  92. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
  93. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
  94. package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
  95. package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
  96. package/contracts/oapps/oft/Cargo.toml +10 -7
  97. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
  98. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
  99. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
  100. package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
  101. package/contracts/oapps/oft/integration-tests/setup.rs +29 -110
  102. package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
  103. package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -14
  104. package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
  105. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
  106. package/contracts/oapps/oft/src/lib.rs +11 -13
  107. package/contracts/oapps/oft/src/oft.rs +147 -225
  108. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -13
  109. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +31 -14
  110. package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
  111. package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
  112. package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
  113. package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +129 -30
  114. package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
  115. package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
  116. package/contracts/oapps/oft-core/src/errors.rs +13 -0
  117. package/contracts/oapps/oft-core/src/lib.rs +18 -0
  118. package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
  119. package/contracts/oapps/{oft → oft-core}/src/storage.rs +2 -0
  120. package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
  121. package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +2 -2
  122. package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
  123. package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -5
  124. package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
  125. package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +78 -37
  126. package/contracts/oapps/oft-core/src/types.rs +58 -0
  127. package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
  128. package/contracts/upgrader/src/lib.rs +4 -4
  129. package/contracts/utils/src/auth.rs +44 -0
  130. package/contracts/utils/src/errors.rs +31 -5
  131. package/contracts/utils/src/lib.rs +3 -0
  132. package/contracts/utils/src/multisig.rs +211 -0
  133. package/contracts/utils/src/ownable.rs +137 -13
  134. package/contracts/utils/src/tests/buffer_reader.rs +6 -6
  135. package/contracts/utils/src/tests/buffer_writer.rs +6 -6
  136. package/contracts/utils/src/tests/bytes_ext.rs +2 -4
  137. package/contracts/utils/src/tests/mod.rs +1 -0
  138. package/contracts/utils/src/tests/multisig.rs +731 -0
  139. package/contracts/utils/src/tests/option_ext.rs +2 -5
  140. package/contracts/utils/src/tests/ownable.rs +456 -7
  141. package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
  142. package/contracts/utils/src/tests/upgradeable.rs +4 -2
  143. package/contracts/utils/src/ttl_configurable.rs +23 -8
  144. package/contracts/utils/src/ttl_extendable.rs +27 -0
  145. package/contracts/utils/src/upgradeable.rs +2 -0
  146. package/contracts/workers/dvn/Cargo.toml +1 -1
  147. package/contracts/workers/dvn/src/auth.rs +7 -7
  148. package/contracts/workers/dvn/src/dvn.rs +10 -38
  149. package/contracts/workers/dvn/src/errors.rs +0 -7
  150. package/contracts/workers/dvn/src/events.rs +1 -14
  151. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  152. package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
  153. package/contracts/workers/dvn/src/storage.rs +3 -13
  154. package/contracts/workers/dvn/src/tests/auth.rs +4 -4
  155. package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
  156. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
  157. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
  158. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
  159. package/contracts/workers/dvn/src/tests/setup.rs +5 -5
  160. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
  161. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
  162. package/contracts/workers/executor/src/auth.rs +80 -16
  163. package/contracts/workers/executor/src/executor.rs +5 -31
  164. package/contracts/workers/executor/src/storage.rs +2 -9
  165. package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
  166. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
  167. package/contracts/workers/executor-helper/Cargo.toml +1 -1
  168. package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
  169. package/contracts/workers/price-feed/Cargo.toml +1 -1
  170. package/contracts/workers/price-feed/src/price_feed.rs +7 -10
  171. package/contracts/workers/worker/src/errors.rs +4 -0
  172. package/contracts/workers/worker/src/tests/worker.rs +7 -6
  173. package/contracts/workers/worker/src/worker.rs +20 -16
  174. package/package.json +7 -5
  175. package/sdk/.turbo/turbo-build.log +1 -0
  176. package/sdk/.turbo/turbo-test.log +1019 -0
  177. package/sdk/dist/generated/bml.d.ts +95 -8
  178. package/sdk/dist/generated/bml.js +95 -36
  179. package/sdk/dist/generated/counter.d.ts +289 -44
  180. package/sdk/dist/generated/counter.js +119 -49
  181. package/sdk/dist/generated/dvn.d.ts +312 -229
  182. package/sdk/dist/generated/dvn.js +144 -83
  183. package/sdk/dist/generated/dvn_fee_lib.d.ts +258 -63
  184. package/sdk/dist/generated/dvn_fee_lib.js +95 -26
  185. package/sdk/dist/generated/endpoint.d.ts +219 -24
  186. package/sdk/dist/generated/endpoint.js +108 -41
  187. package/sdk/dist/generated/executor.d.ts +239 -87
  188. package/sdk/dist/generated/executor.js +135 -63
  189. package/sdk/dist/generated/executor_fee_lib.d.ts +278 -74
  190. package/sdk/dist/generated/executor_fee_lib.js +135 -59
  191. package/sdk/dist/generated/executor_helper.d.ts +163 -21
  192. package/sdk/dist/generated/executor_helper.js +124 -52
  193. package/sdk/dist/generated/oft.d.ts +1842 -0
  194. package/sdk/dist/generated/oft.js +345 -0
  195. package/sdk/dist/generated/price_feed.d.ts +258 -63
  196. package/sdk/dist/generated/price_feed.js +95 -26
  197. package/sdk/dist/generated/sml.d.ts +235 -34
  198. package/sdk/dist/generated/sml.js +126 -53
  199. package/sdk/dist/generated/treasury.d.ts +1016 -0
  200. package/sdk/dist/generated/treasury.js +248 -0
  201. package/sdk/dist/generated/uln302.d.ts +235 -34
  202. package/sdk/dist/generated/uln302.js +126 -53
  203. package/sdk/dist/generated/upgrader.d.ts +17 -2
  204. package/sdk/dist/generated/upgrader.js +19 -1
  205. package/sdk/dist/index.d.ts +2 -1
  206. package/sdk/dist/index.js +2 -1
  207. package/sdk/package.json +6 -3
  208. package/sdk/src/index.ts +2 -1
  209. package/sdk/test/counter-sml.test.ts +376 -0
  210. package/sdk/test/counter-uln.test.ts +493 -0
  211. package/sdk/test/{oft.test.ts → oft-sml.test.ts} +196 -321
  212. package/sdk/test/suites/constants.ts +22 -2
  213. package/sdk/test/suites/globalSetup.ts +450 -0
  214. package/sdk/test/suites/localnet.ts +23 -6
  215. package/sdk/test/upgrader.test.ts +7 -16
  216. package/sdk/test/utils.ts +558 -85
  217. package/sdk/turbo.json +8 -0
  218. package/sdk/vitest.config.ts +21 -0
  219. package/tools/ts-bindings-gen/Cargo.toml +2 -0
  220. package/tools/ts-bindings-gen/src/main.rs +52 -4
  221. package/contracts/common-macros/src/contract_impl.rs +0 -52
  222. package/contracts/common-macros/src/ownable.rs +0 -41
  223. package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
  224. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
  225. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
  226. package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
  227. package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
  228. package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
  229. package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
  230. package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
  231. package/contracts/oapps/oapp-macros/src/util.rs +0 -107
  232. package/contracts/oapps/oft/src/constants.rs +0 -5
  233. package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
  234. package/contracts/oapps/oft/src/errors.rs +0 -8
  235. package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
  236. package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
  237. package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
  238. package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -903
  239. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -749
  240. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -432
  241. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1078
  242. package/contracts/oapps/oft/src/types.rs +0 -38
  243. package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
  244. package/contracts/oapps/oft-std/src/lib.rs +0 -16
  245. package/contracts/oapps/oft-std/src/oft.rs +0 -156
  246. package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
  247. package/contracts/workers/dvn/src/multisig.rs +0 -157
  248. package/sdk/dist/generated/oft_std.d.ts +0 -1544
  249. package/sdk/dist/generated/oft_std.js +0 -271
  250. package/sdk/test/index.test.ts +0 -375
  251. /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
  252. /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
  253. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
  254. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
  255. /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
  256. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
  257. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
  258. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
  259. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
  260. /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
  261. /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
  262. /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
@@ -0,0 +1,24 @@
1
+ ---
2
+ source: contracts/common-macros/src/tests/auth.rs
3
+ assertion_line: 18
4
+ expression: formatted
5
+ ---
6
+ pub struct MyContract;
7
+ use utils::{auth::Auth as _, ownable::{Ownable as _, OwnableInitializer as _}};
8
+ #[doc(hidden)]
9
+ mod __ownable_impl_my_contract {
10
+ use super::*;
11
+ use utils::{
12
+ auth::Auth, errors::OwnableError, option_ext::OptionExt as _,
13
+ ownable::{Ownable, OwnableInitializer},
14
+ };
15
+ impl OwnableInitializer for MyContract {}
16
+ #[common_macros::contract_impl]
17
+ impl Auth for MyContract {
18
+ fn authorizer(env: &soroban_sdk::Env) -> soroban_sdk::Address {
19
+ <Self as Ownable>::owner(env).unwrap_or_panic(env, OwnableError::OwnerNotSet)
20
+ }
21
+ }
22
+ #[common_macros::contract_impl(contracttrait)]
23
+ impl Ownable for MyContract {}
24
+ }
@@ -1,12 +1,12 @@
1
1
  ---
2
- source: contracts/common-macros/src/tests/ownable.rs
3
- assertion_line: 48
2
+ source: contracts/common-macros/src/tests/auth.rs
3
+ assertion_line: 67
4
4
  expression: combined
5
5
  ---
6
6
  // === Borrowed Env (&Env) ===
7
7
 
8
8
  pub(crate) async fn admin_action<T: Clone>(env: &Env, value: T) -> Result<T, Error> {
9
- utils::ownable::require_owner_auth::<Self>(env);
9
+ utils::auth::require_auth::<Self>(env);
10
10
  Ok(value.clone())
11
11
  }
12
12
 
@@ -14,6 +14,6 @@ pub(crate) async fn admin_action<T: Clone>(env: &Env, value: T) -> Result<T, Err
14
14
  // === Owned Env (Env) ===
15
15
 
16
16
  pub(crate) async fn admin_action<T: Clone>(env: Env, value: T) -> Result<T, Error> {
17
- utils::ownable::require_owner_auth::<Self>(&env);
17
+ utils::auth::require_auth::<Self>(&env);
18
18
  Ok(value.clone())
19
19
  }
@@ -1,5 +1,5 @@
1
1
  ---
2
- source: contracts/common-macros/src/tests/contract_impl.rs
2
+ source: contracts/common-macros/src/tests/contract_ttl.rs
3
3
  assertion_line: 109
4
4
  expression: combined
5
5
  ---
@@ -79,8 +79,8 @@ impl SomeTrait for MyContract {
79
79
  value * 4
80
80
  }
81
81
  /// Trait method with macro attribute - should have TTL extension
82
- #[common_macros::only_owner]
83
- fn trait_method_with_only_owner_attribute(env: Env, value: u32) -> u32 {
82
+ #[common_macros::only_auth]
83
+ fn trait_method_with_only_auth_attribute(env: Env, value: u32) -> u32 {
84
84
  if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(
85
85
  &env,
86
86
  ) {
@@ -0,0 +1,69 @@
1
+ ---
2
+ source: contracts/common-macros/src/tests/contract_ttl.rs
3
+ assertion_line: 75
4
+ expression: combined
5
+ ---
6
+ // === Trait (no attr) ===
7
+
8
+ #[soroban_sdk::contracttrait]
9
+ pub trait MyTrait: Sized {
10
+ /// Default method with Env - should have TTL extension
11
+ fn default_with_env(env: Env, value: u32) -> u32 {
12
+ if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(
13
+ &env,
14
+ ) {
15
+ env.storage()
16
+ .instance()
17
+ .extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
18
+ }
19
+ value * 2
20
+ }
21
+ /// Default method with qualified Env path - should have TTL extension
22
+ fn with_qualified_env(env: soroban_sdk::Env) -> u32 {
23
+ if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(
24
+ &env,
25
+ ) {
26
+ env.storage()
27
+ .instance()
28
+ .extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
29
+ }
30
+ 42
31
+ }
32
+ /// Default method with Env not as first parameter - should have TTL extension
33
+ fn env_second(value: u32, env: &Env) -> u32 {
34
+ if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(
35
+ env,
36
+ ) {
37
+ env.storage()
38
+ .instance()
39
+ .extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
40
+ }
41
+ value * 2
42
+ }
43
+ /// Default method without Env - should NOT have TTL extension
44
+ fn default_without_env(value: u32) -> u32 {
45
+ value * 4
46
+ }
47
+ /// Abstract method with Env - should NOT have TTL extension (no body)
48
+ fn abstract_with_env(env: Env, value: u32) -> u32;
49
+ /// Abstract method without Env - should NOT have TTL extension (no body)
50
+ fn abstract_without_env(value: u32) -> u32;
51
+ }
52
+
53
+
54
+ // === Trait (crate attr) ===
55
+
56
+ #[soroban_sdk::contracttrait(crate = "other_sdk")]
57
+ pub trait AnotherTrait {
58
+ /// Default method with Env - should have TTL extension
59
+ fn method_with_env(env: &Env, value: u32) -> u32 {
60
+ if let Some(instance_ttl) = utils::ttl_configurable::TtlConfigStorage::instance(
61
+ env,
62
+ ) {
63
+ env.storage()
64
+ .instance()
65
+ .extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
66
+ }
67
+ value * 3
68
+ }
69
+ }
@@ -1,29 +1,15 @@
1
1
  ---
2
2
  source: contracts/common-macros/src/tests/ttl_configurable.rs
3
- assertion_line: 20
4
3
  expression: formatted
5
4
  ---
6
5
  pub struct MyContract {
7
6
  some_field: u32,
8
7
  }
9
- use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
10
- use utils::ownable::Ownable as _;
11
- /// Implement the `TtlConfigurable` trait for the contract with default implementations.
12
- #[common_macros::contract_impl(contracttrait)]
13
- impl TtlConfigurable for MyContract {}
14
- /// Uses `soroban_sdk::contractimpl` directly instead of `common_macros::contract_impl`
15
- /// because `contract_impl` automatically extends TTL on every invocation. Since this
16
- /// impl block provides manual TTL extension control, auto-extension would be redundant
17
- /// and could mask the intended behavior of `extend_instance_ttl`.
18
- #[soroban_sdk::contractimpl]
19
- impl MyContract {
20
- /// Extends the instance TTL.
21
- ///
22
- /// # Arguments
23
- ///
24
- /// * `threshold` - The threshold to extend the TTL.
25
- /// * `extend_to` - The TTL to extend to.
26
- pub fn extend_instance_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
27
- env.storage().instance().extend_ttl(threshold, extend_to);
28
- }
8
+ use utils::ttl_configurable::TtlConfigurable as _;
9
+ #[doc(hidden)]
10
+ mod __ttl_configurable_impl_my_contract {
11
+ use super::*;
12
+ use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
13
+ #[common_macros::contract_impl(contracttrait)]
14
+ impl TtlConfigurable for MyContract {}
29
15
  }
@@ -10,11 +10,11 @@ type MigrationData = <MyContract as utils::upgradeable::UpgradeableInternal>::Mi
10
10
  /// Implement the Upgradeable trait for the contract.
11
11
  #[common_macros::contract_impl]
12
12
  impl utils::upgradeable::Upgradeable for MyContract {
13
- #[common_macros::only_owner]
13
+ #[common_macros::only_auth]
14
14
  fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
15
15
  utils::upgradeable::upgrade(env, new_wasm_hash)
16
16
  }
17
- #[common_macros::only_owner]
17
+ #[common_macros::only_auth]
18
18
  fn migrate(env: &soroban_sdk::Env, migration_data: &MigrationData) {
19
19
  utils::upgradeable::migrate::<Self>(env, migration_data)
20
20
  }
@@ -1,50 +1,35 @@
1
1
  //! TtlConfigurable macro for Stellar smart contracts.
2
2
 
3
+ use crate::utils;
3
4
  use proc_macro2::TokenStream;
4
5
  use quote::quote;
6
+ use syn::ItemStruct;
5
7
 
6
8
  /// Generates the `TtlConfigurable` trait implementation for a contract.
7
9
  ///
8
- /// This macro:
9
- /// - Implements `TtlConfigurable` using the trait's default methods (which include owner auth)
10
- /// - Adds an `extend_instance_ttl` helper for manual TTL extension
10
+ /// This macro implements `TtlConfigurable` using the trait's default methods (which include auth).
11
11
  ///
12
- /// The contract must also implement `Ownable` (typically via `#[ownable]`).
12
+ /// The contract must also implement `Auth` (typically via `#[ownable]` or `Multisig`).
13
+ ///
14
+ /// For manual TTL extension functionality, use the `#[ttl_extendable]` macro which provides
15
+ /// the `extend_instance_ttl` function.
13
16
  pub fn generate_ttl_configurable_impl(input: TokenStream) -> TokenStream {
14
- let item_struct: syn::ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
17
+ let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
15
18
  let name = &item_struct.ident;
19
+ let impl_mod = utils::impl_mod_ident(name, "ttl_configurable");
16
20
 
17
- let trait_impl = quote! {
18
- use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
19
- use utils::ownable::Ownable as _;
21
+ quote! {
22
+ #item_struct
20
23
 
21
- /// Implement the `TtlConfigurable` trait for the contract with default implementations.
22
- #[common_macros::contract_impl(contracttrait)]
23
- impl TtlConfigurable for #name {}
24
- };
24
+ use utils::ttl_configurable::TtlConfigurable as _;
25
25
 
26
- let inherent_impl = quote! {
27
- /// Uses `soroban_sdk::contractimpl` directly instead of `common_macros::contract_impl`
28
- /// because `contract_impl` automatically extends TTL on every invocation. Since this
29
- /// impl block provides manual TTL extension control, auto-extension would be redundant
30
- /// and could mask the intended behavior of `extend_instance_ttl`.
31
- #[soroban_sdk::contractimpl]
32
- impl #name {
33
- /// Extends the instance TTL.
34
- ///
35
- /// # Arguments
36
- ///
37
- /// * `threshold` - The threshold to extend the TTL.
38
- /// * `extend_to` - The TTL to extend to.
39
- pub fn extend_instance_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
40
- env.storage().instance().extend_ttl(threshold, extend_to);
41
- }
42
- }
43
- };
26
+ #[doc(hidden)]
27
+ mod #impl_mod {
28
+ use super::*;
29
+ use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
44
30
 
45
- quote! {
46
- #item_struct
47
- #trait_impl
48
- #inherent_impl
31
+ #[common_macros::contract_impl(contracttrait)]
32
+ impl TtlConfigurable for #name {}
33
+ }
49
34
  }
50
35
  }
@@ -0,0 +1,36 @@
1
+ //! TtlExtendable macro for Stellar smart contracts.
2
+
3
+ use crate::utils;
4
+ use proc_macro2::TokenStream;
5
+ use quote::quote;
6
+ use syn::ItemStruct;
7
+
8
+ /// Generates the TtlExtendable trait implementation from the `#[ttl_extendable]` attribute macro.
9
+ ///
10
+ /// This macro implements the `TtlExtendable` trait for a contract struct,
11
+ /// providing a public `extend_instance_ttl` function for manual TTL extension.
12
+ ///
13
+ /// Uses `soroban_sdk::contractimpl` directly instead of `common_macros::contract_impl`
14
+ /// because `contract_impl` automatically extends TTL on every invocation. Since this
15
+ /// impl block provides manual TTL extension control, auto-extension would be redundant
16
+ /// and could mask the intended behavior of `extend_instance_ttl`.
17
+ pub fn generate_ttl_extendable_impl(input: TokenStream) -> TokenStream {
18
+ let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
19
+ let name = &item_struct.ident;
20
+ let impl_mod = utils::impl_mod_ident(name, "ttl_extendable");
21
+
22
+ quote! {
23
+ #item_struct
24
+
25
+ use utils::ttl_extendable::TtlExtendable as _;
26
+
27
+ #[doc(hidden)]
28
+ mod #impl_mod {
29
+ use super::*;
30
+ use utils::ttl_extendable::TtlExtendable;
31
+
32
+ #[soroban_sdk::contractimpl(contracttrait)]
33
+ impl TtlExtendable for #name {}
34
+ }
35
+ }
36
+ }
@@ -10,16 +10,16 @@ use syn::ItemStruct;
10
10
  ///
11
11
  /// # Behavior
12
12
  ///
13
- /// - Implements the `upgrade` and `migrate` functions with owner-based access control.
13
+ /// - Implements the `upgrade` and `migrate` functions with auth-based access control.
14
14
  /// - Sets the contract crate version as `"binver"` metadata using
15
15
  /// `soroban_sdk::contractmeta!`. Gets the crate version via the env variable
16
16
  /// `CARGO_PKG_VERSION` which corresponds to the "version" attribute in
17
17
  /// Cargo.toml. If no such attribute or if it is "0.0.0", skips this step.
18
- /// - Requires the contract to implement `Ownable` and `UpgradeableInternal` traits.
18
+ /// - Requires the contract to implement `Auth` and `UpgradeableInternal` traits.
19
19
  ///
20
20
  /// # Example
21
21
  /// ```ignore
22
- /// #[ownable]
22
+ /// #[ownable] // or implement Multisig for self-owning contracts
23
23
  /// #[upgradeable]
24
24
  /// pub struct MyContract;
25
25
  /// ```
@@ -40,12 +40,12 @@ pub fn generate_upgradeable_impl(input: TokenStream) -> TokenStream {
40
40
  /// Implement the Upgradeable trait for the contract.
41
41
  #[common_macros::contract_impl]
42
42
  impl utils::upgradeable::Upgradeable for #name {
43
- #[common_macros::only_owner]
43
+ #[common_macros::only_auth]
44
44
  fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
45
45
  utils::upgradeable::upgrade(env, new_wasm_hash)
46
46
  }
47
47
 
48
- #[common_macros::only_owner]
48
+ #[common_macros::only_auth]
49
49
  fn migrate(env: &soroban_sdk::Env, migration_data: &MigrationData) {
50
50
  utils::upgradeable::migrate::<Self>(env, migration_data)
51
51
  }
@@ -1,3 +1,4 @@
1
+ use heck::ToSnakeCase;
1
2
  use proc_macro2::TokenStream;
2
3
  use quote::quote;
3
4
  use syn::{punctuated::Punctuated, token::Comma, FnArg, Ident, Pat, Type, TypePath};
@@ -54,3 +55,11 @@ pub fn is_env_type(ty: &Type) -> bool {
54
55
  fn is_reference_type(ty: &Type) -> bool {
55
56
  matches!(ty, Type::Reference(_))
56
57
  }
58
+
59
+ /// Creates a unique hidden module identifier for trait implementations.
60
+ ///
61
+ /// Generates a module name in the format `__{trait_name}_impl_{struct_name}` to avoid
62
+ /// name collisions when multiple traits are implemented for the same struct.
63
+ pub fn impl_mod_ident(struct_name: &Ident, trait_name: &str) -> Ident {
64
+ Ident::new(&format!("__{}_impl_{}", trait_name, struct_name.to_string().to_snake_case()), struct_name.span())
65
+ }
@@ -7,7 +7,7 @@ cfg_if::cfg_if! {
7
7
  if #[cfg(any(test, feature = "testutils"))] {
8
8
  /// Stellar Endpoint ID for unit test environment.
9
9
  /// TODO: This is a placeholder value for testing purposes.
10
- pub const STELLAR_EID: u32 = 30111;
10
+ pub const STELLAR_EID: u32 = 30400;
11
11
 
12
12
  /// Native token address for unit test environment.
13
13
  pub const NATIVE_TOKEN: &str = "CBEPDNVYXQGWB5YUBXKJWYJA7OXTZW5LFLNO5JRRGE6Z6C5OSUZPCCEL";
@@ -15,7 +15,7 @@ cfg_if::cfg_if! {
15
15
  } else if #[cfg(feature = "testnet")] {
16
16
  /// Stellar Endpoint ID for testnet environment.
17
17
  /// TODO: Confirm this EID value with LayerZero before testnet deployment.
18
- pub const STELLAR_EID: u32 = 20111;
18
+ pub const STELLAR_EID: u32 = 20400;
19
19
 
20
20
  /// Native token address for testnet (Stellar testnet XLM wrapper).
21
21
  pub const NATIVE_TOKEN: &str = "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
@@ -23,7 +23,7 @@ cfg_if::cfg_if! {
23
23
  } else if #[cfg(feature = "sandbox")] {
24
24
  /// Stellar Endpoint ID for sandbox environment.
25
25
  /// TODO: Confirm this EID value with LayerZero before sandbox deployment.
26
- pub const STELLAR_EID: u32 = 30111;
26
+ pub const STELLAR_EID: u32 = 30400;
27
27
 
28
28
  /// Native token address for sandbox environment.
29
29
  pub const NATIVE_TOKEN: &str = "CDMLFMKMMD7MWZP3FKUBZPVHTUEDLSX4BYGYKH4GCESXYHS3IHQ4EIG4";
@@ -31,7 +31,7 @@ cfg_if::cfg_if! {
31
31
  } else {
32
32
  /// Stellar Endpoint ID for mainnet environment.
33
33
  /// TODO: Confirm this EID value with LayerZero before mainnet deployment.
34
- pub const STELLAR_EID: u32 = 30111;
34
+ pub const STELLAR_EID: u32 = 30400;
35
35
 
36
36
  /// Native token address for mainnet (Stellar mainnet XLM wrapper).
37
37
  pub const NATIVE_TOKEN: &str = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
@@ -1,28 +1,18 @@
1
1
  use crate::{
2
- constants::{
3
- EMPTY_PAYLOAD_HASH_BYTES, MAX_COMPOSE_INDEX, NATIVE_TOKEN, NIL_PAYLOAD_HASH_BYTES, RECEIVED_MESSAGE_HASH_BYTES,
4
- STELLAR_EID,
5
- },
2
+ constants::{NATIVE_TOKEN, STELLAR_EID},
6
3
  errors::EndpointError,
7
- events::{
8
- ComposeDelivered, ComposeSent, DefaultReceiveLibTimeoutSet, DefaultReceiveLibrarySet, DefaultSendLibrarySet,
9
- DelegateSet, InboundNonceSkipped, LibraryRegistered, LzComposeAlert, LzReceiveAlert, PacketBurnt,
10
- PacketDelivered, PacketNilified, PacketSent, PacketVerified, ReceiveLibrarySet, ReceiveLibraryTimeoutSet,
11
- SendLibrarySet, ZROSet,
12
- },
4
+ events::{DelegateSet, LzReceiveAlert, PacketDelivered, PacketSent, PacketVerified, ZroSet},
13
5
  interfaces::{ILayerZeroEndpointV2, IMessageLibManager, IMessagingChannel, MessagingFee, MessagingReceipt, Origin},
14
6
  storage::EndpointStorage,
15
- util::{build_payload, compute_guid, keccak256},
16
- FeeRecipient, FeesAndPacket, IMessagingComposer, LayerZeroReceiverClient, MessageLibClient, MessageLibType,
17
- MessagingParams, OutboundPacket, ResolvedLibrary, SendLibClient, SetConfigParam, Timeout,
7
+ util::{build_payload, compute_guid},
8
+ FeeRecipient, FeesAndPacket, LayerZeroReceiverClient, MessagingParams, OutboundPacket, ResolvedLibrary,
9
+ SendLibClient,
18
10
  };
19
- use common_macros::{contract_impl, only_owner, ownable, ttl_configurable};
20
- use soroban_sdk::{assert_with_error, contract, token::TokenClient, vec, Address, Bytes, BytesN, Env, Vec};
11
+ use common_macros::{contract_impl, lz_contract, only_auth};
12
+ use soroban_sdk::{assert_with_error, token::TokenClient, Address, Bytes, BytesN, Env, Vec};
21
13
  use utils::option_ext::OptionExt;
22
14
 
23
- #[contract]
24
- #[ttl_configurable]
25
- #[ownable]
15
+ #[lz_contract]
26
16
  pub struct EndpointV2;
27
17
 
28
18
  #[contract_impl]
@@ -37,7 +27,7 @@ impl EndpointV2 {
37
27
  /// * `token` - The token address to recover
38
28
  /// * `to` - The address to send the token to
39
29
  /// * `amount` - The amount to send
40
- #[only_owner]
30
+ #[only_auth]
41
31
  pub fn recover_token(env: &Env, token: &Address, to: &Address, amount: i128) {
42
32
  TokenClient::new(env, token).transfer(&env.current_contract_address(), to, &amount);
43
33
  }
@@ -51,7 +41,7 @@ impl EndpointV2 {
51
41
  impl ILayerZeroEndpointV2 for EndpointV2 {
52
42
  /// Quotes the messaging fee for sending a cross-chain message.
53
43
  fn quote(env: &Env, sender: &Address, params: &MessagingParams) -> MessagingFee {
54
- assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZROUnavailable);
44
+ assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZroUnavailable);
55
45
 
56
46
  let MessagingParams { dst_eid, receiver, message, options, pay_in_zro } = params;
57
47
  let ResolvedLibrary { lib: send_lib, .. } = Self::get_send_library(env, sender, *dst_eid);
@@ -67,7 +57,7 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
67
57
  /// OApp sender needs to transfer the fees to the endpoint before sending the message
68
58
  fn send(env: &Env, sender: &Address, params: &MessagingParams, refund_address: &Address) -> MessagingReceipt {
69
59
  sender.require_auth();
70
- assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZROUnavailable);
60
+ assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZroUnavailable);
71
61
 
72
62
  let MessagingParams { dst_eid, receiver, message, options, pay_in_zro } = params;
73
63
  let ResolvedLibrary { lib: send_library, .. } = Self::get_send_library(env, sender, *dst_eid);
@@ -147,10 +137,10 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
147
137
  }
148
138
 
149
139
  /// Sets the ZRO token address for fee payments.
150
- #[only_owner]
140
+ #[only_auth]
151
141
  fn set_zro(env: &Env, zro: &Address) {
152
142
  EndpointStorage::set_zro(env, zro);
153
- ZROSet { zro: zro.clone() }.publish(env);
143
+ ZroSet { zro: zro.clone() }.publish(env);
154
144
  }
155
145
 
156
146
  /// Sets or removes a delegate address that can act on behalf of the OApp.
@@ -258,11 +248,17 @@ impl EndpointV2 {
258
248
  // Pay native fees
259
249
  let native_token_client = TokenClient::new(env, &Self::native_token(env));
260
250
  let mut native_fee_supplied = native_token_client.balance(&this_contract);
261
- native_fee_recipients.iter().filter(|r| r.amount > 0).for_each(|r| {
262
- assert_with_error!(env, native_fee_supplied >= r.amount, EndpointError::InsufficientNativeFee);
263
- native_token_client.transfer(&this_contract, &r.to, &r.amount);
264
- native_fee_supplied -= r.amount;
265
- fee_paid.native_fee += r.amount;
251
+ native_fee_recipients.iter().for_each(|r| {
252
+ // Fee amounts are modeled as non-negative values. The field type is i128 for
253
+ // compatibility with token APIs, but negative fees are always invalid and rejected
254
+ // here, while zero amounts are treated as a no-op (skipped by the check below).
255
+ assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
256
+ if r.amount > 0 {
257
+ assert_with_error!(env, native_fee_supplied >= r.amount, EndpointError::InsufficientNativeFee);
258
+ native_token_client.transfer(&this_contract, &r.to, &r.amount);
259
+ native_fee_supplied -= r.amount;
260
+ fee_paid.native_fee += r.amount;
261
+ }
266
262
  });
267
263
  // Refund remaining native fees
268
264
  if native_fee_supplied > 0 {
@@ -271,7 +267,7 @@ impl EndpointV2 {
271
267
 
272
268
  // Pay ZRO fees
273
269
  if pay_in_zro {
274
- let zro_addr = Self::zro(env).unwrap_or_panic(env, EndpointError::ZROUnavailable);
270
+ let zro_addr = Self::zro(env).unwrap_or_panic(env, EndpointError::ZroUnavailable);
275
271
  let zro_client = TokenClient::new(env, &zro_addr);
276
272
 
277
273
  // If pay_in_zro is true, the supplied fee must be greater than 0 to prevent a race condition
@@ -279,13 +275,19 @@ impl EndpointV2 {
279
275
  // being sent and the tx being mined. if the required zro fee is 0 and the old zro token would be
280
276
  // locked in the contract instead of being refunded
281
277
  let mut zro_fee_supplied = zro_client.balance(&this_contract);
282
- assert_with_error!(env, zro_fee_supplied > 0, EndpointError::ZeroZROFee);
283
-
284
- zro_fee_recipients.iter().filter(|r| r.amount > 0).for_each(|r| {
285
- assert_with_error!(env, zro_fee_supplied >= r.amount, EndpointError::InsufficientZROFee);
286
- zro_client.transfer(&this_contract, &r.to, &r.amount);
287
- zro_fee_supplied -= r.amount;
288
- fee_paid.zro_fee += r.amount;
278
+ assert_with_error!(env, zro_fee_supplied > 0, EndpointError::ZeroZroFee);
279
+
280
+ zro_fee_recipients.iter().for_each(|r| {
281
+ // Fee amounts are modeled as non-negative values. The field type is i128 for
282
+ // compatibility with token APIs, but negative fees are always invalid and rejected
283
+ // here, while zero amounts are treated as a no-op (skipped by the check below).
284
+ assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
285
+ if r.amount > 0 {
286
+ assert_with_error!(env, zro_fee_supplied >= r.amount, EndpointError::InsufficientZroFee);
287
+ zro_client.transfer(&this_contract, &r.to, &r.amount);
288
+ zro_fee_supplied -= r.amount;
289
+ fee_paid.zro_fee += r.amount;
290
+ }
289
291
  });
290
292
  // Refund remaining ZRO fees
291
293
  if zro_fee_supplied > 0 {
@@ -320,10 +322,6 @@ mod test {
320
322
  }
321
323
  }
322
324
 
323
- // ============================================================================
324
- // Include Modules
325
- // ============================================================================
326
-
327
325
  #[path = "message_lib_manager.rs"]
328
326
  mod message_lib_manager;
329
327
  #[path = "messaging_channel.rs"]
@@ -8,7 +8,8 @@ pub enum EndpointError {
8
8
  DefaultReceiveLibUnavailable,
9
9
  DefaultSendLibUnavailable,
10
10
  InsufficientNativeFee,
11
- InsufficientZROFee,
11
+ InsufficientZroFee,
12
+ InvalidFeeAmount,
12
13
  InvalidExpiry,
13
14
  InvalidIndex,
14
15
  InvalidNonce,
@@ -24,6 +25,6 @@ pub enum EndpointError {
24
25
  SameValue,
25
26
  Unauthorized,
26
27
  UnsupportedEid,
27
- ZeroZROFee,
28
- ZROUnavailable,
28
+ ZeroZroFee,
29
+ ZroUnavailable,
29
30
  }
@@ -52,7 +52,7 @@ pub struct LzReceiveAlert {
52
52
 
53
53
  #[contractevent]
54
54
  #[derive(Clone, Debug, Eq, PartialEq)]
55
- pub struct ZROSet {
55
+ pub struct ZroSet {
56
56
  pub zro: Address,
57
57
  }
58
58
 
@@ -1,9 +1,22 @@
1
- use super::*;
1
+ use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
2
+ use crate::{
3
+ errors::EndpointError,
4
+ events::{
5
+ DefaultReceiveLibTimeoutSet, DefaultReceiveLibrarySet, DefaultSendLibrarySet, LibraryRegistered,
6
+ ReceiveLibrarySet, ReceiveLibraryTimeoutSet, SendLibrarySet,
7
+ },
8
+ interfaces::IMessageLibManager,
9
+ storage::EndpointStorage,
10
+ MessageLibClient, MessageLibType, ResolvedLibrary, SetConfigParam, Timeout,
11
+ };
12
+ use common_macros::{contract_impl, only_auth};
13
+ use soroban_sdk::{assert_with_error, vec, Address, Bytes, Env, Vec};
14
+ use utils::option_ext::OptionExt;
2
15
 
3
16
  #[contract_impl]
4
17
  impl IMessageLibManager for EndpointV2 {
5
18
  /// Registers a new message library with the endpoint.
6
- #[only_owner]
19
+ #[only_auth]
7
20
  fn register_library(env: &Env, new_lib: &Address) {
8
21
  // Call library get type to make sure it's a valid library, will panic if not
9
22
  let _ = MessageLibClient::new(env, new_lib).message_lib_type();
@@ -21,7 +34,7 @@ impl IMessageLibManager for EndpointV2 {
21
34
  }
22
35
 
23
36
  /// Sets the default send library for a destination endpoint.
24
- #[only_owner]
37
+ #[only_auth]
25
38
  fn set_default_send_library(env: &Env, dst_eid: u32, new_lib: &Address) {
26
39
  Self::require_send_lib_for_eid(env, new_lib, dst_eid);
27
40
 
@@ -36,7 +49,7 @@ impl IMessageLibManager for EndpointV2 {
36
49
  ///
37
50
  /// If a grace period is provided and there was a previous library, the old library
38
51
  /// remains valid until the grace period expires.
39
- #[only_owner]
52
+ #[only_auth]
40
53
  fn set_default_receive_library(env: &Env, src_eid: u32, new_lib: &Address, grace_period: u64) {
41
54
  Self::require_receive_lib_for_eid(env, new_lib, src_eid);
42
55
 
@@ -63,7 +76,7 @@ impl IMessageLibManager for EndpointV2 {
63
76
  ///
64
77
  /// If a timeout is provided, it must be valid and not expired. If no timeout is provided,
65
78
  /// the default receive library timeout is removed.
66
- #[only_owner]
79
+ #[only_auth]
67
80
  fn set_default_receive_lib_timeout(env: &Env, src_eid: u32, timeout: &Option<Timeout>) {
68
81
  if let Some(t) = timeout {
69
82
  Self::require_receive_lib_for_eid(env, &t.lib, src_eid);
@@ -1,4 +1,14 @@
1
- use super::*;
1
+ use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
2
+ use crate::{
3
+ constants::{EMPTY_PAYLOAD_HASH_BYTES, NIL_PAYLOAD_HASH_BYTES},
4
+ errors::EndpointError,
5
+ events::{InboundNonceSkipped, PacketBurnt, PacketNilified},
6
+ interfaces::{ILayerZeroEndpointV2, IMessagingChannel},
7
+ storage::EndpointStorage,
8
+ util::{compute_guid, keccak256},
9
+ };
10
+ use common_macros::contract_impl;
11
+ use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
2
12
 
3
13
  #[contract_impl]
4
14
  impl IMessagingChannel for EndpointV2 {
@@ -1,4 +1,14 @@
1
- use super::*;
1
+ use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
2
+ use crate::{
3
+ constants::{MAX_COMPOSE_INDEX, RECEIVED_MESSAGE_HASH_BYTES},
4
+ errors::EndpointError,
5
+ events::{ComposeDelivered, ComposeSent, LzComposeAlert},
6
+ storage::EndpointStorage,
7
+ util::keccak256,
8
+ IMessagingComposer,
9
+ };
10
+ use common_macros::contract_impl;
11
+ use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
2
12
 
3
13
  #[contract_impl]
4
14
  impl IMessagingComposer for EndpointV2 {
@@ -6,7 +6,7 @@ use soroban_sdk::{Address, BytesN};
6
6
  pub enum EndpointStorage {
7
7
  /// The ZRO token address
8
8
  #[instance(Address)]
9
- ZRO,
9
+ Zro,
10
10
 
11
11
  /// The delegate address for an OApp
12
12
  #[persistent(Address)]