@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
@@ -5,20 +5,21 @@ mod test_full_default {
5
5
  extern crate self as oapp;
6
6
 
7
7
  use endpoint_v2::Origin;
8
+ use oapp::oapp_receiver::LzReceiveInternal;
8
9
  use oapp_macros::oapp;
9
10
  use soroban_sdk::{Address, Bytes, BytesN, Env};
10
11
 
11
12
  #[oapp]
12
13
  struct TestFullDefault;
13
14
 
14
- impl TestFullDefault {
15
+ impl LzReceiveInternal for TestFullDefault {
15
16
  fn __lz_receive(
16
17
  _env: &Env,
17
- _executor: &Address,
18
18
  _origin: &Origin,
19
19
  _guid: &BytesN<32>,
20
20
  _message: &Bytes,
21
21
  _extra_data: &Bytes,
22
+ _executor: &Address,
22
23
  _value: i128,
23
24
  ) {
24
25
  // Default behavior
@@ -34,11 +35,11 @@ mod test_full_manual_core {
34
35
 
35
36
  use endpoint_v2::Origin;
36
37
  use oapp::oapp_core::OAppCore;
37
- use oapp_macros::{oapp, oapp_manual_impl};
38
+ use oapp::oapp_receiver::LzReceiveInternal;
39
+ use oapp_macros::oapp;
38
40
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
39
41
 
40
- #[oapp]
41
- #[oapp_manual_impl(core)]
42
+ #[oapp(custom = [core])]
42
43
  struct TestFullManualCore;
43
44
 
44
45
  #[contractimpl(contracttrait)]
@@ -48,14 +49,14 @@ mod test_full_manual_core {
48
49
  }
49
50
  }
50
51
 
51
- impl TestFullManualCore {
52
+ impl LzReceiveInternal for TestFullManualCore {
52
53
  fn __lz_receive(
53
54
  _env: &Env,
54
- _executor: &Address,
55
55
  _origin: &Origin,
56
56
  _guid: &BytesN<32>,
57
57
  _message: &Bytes,
58
58
  _extra_data: &Bytes,
59
+ _executor: &Address,
59
60
  _value: i128,
60
61
  ) {
61
62
  // Custom logic
@@ -70,26 +71,26 @@ mod test_full_manual_sender {
70
71
  extern crate self as oapp;
71
72
 
72
73
  use endpoint_v2::Origin;
73
- use oapp::oapp_sender::OAppSender;
74
- use oapp_macros::{oapp, oapp_manual_impl};
74
+ use oapp::oapp_receiver::LzReceiveInternal;
75
+ use oapp::oapp_sender::OAppSenderInternal;
76
+ use oapp_macros::oapp;
75
77
  use soroban_sdk::{Address, Bytes, BytesN, Env};
76
78
 
77
- #[oapp]
78
- #[oapp_manual_impl(sender)]
79
+ #[oapp(custom = [sender])]
79
80
  struct TestFullManualSender;
80
81
 
81
- impl OAppSender for TestFullManualSender {
82
+ impl OAppSenderInternal for TestFullManualSender {
82
83
  // Custom sender implementation
83
84
  }
84
85
 
85
- impl TestFullManualSender {
86
+ impl LzReceiveInternal for TestFullManualSender {
86
87
  fn __lz_receive(
87
88
  _env: &Env,
88
- _executor: &Address,
89
89
  _origin: &Origin,
90
90
  _guid: &BytesN<32>,
91
91
  _message: &Bytes,
92
92
  _extra_data: &Bytes,
93
+ _executor: &Address,
93
94
  _value: i128,
94
95
  ) {
95
96
  // Implementation
@@ -104,14 +105,27 @@ mod test_full_manual_receiver {
104
105
  extern crate self as oapp;
105
106
 
106
107
  use endpoint_v2::Origin;
107
- use oapp::oapp_receiver::OAppReceiver;
108
- use oapp_macros::{oapp, oapp_manual_impl};
108
+ use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
109
+ use oapp_macros::oapp;
109
110
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
110
111
 
111
- #[oapp]
112
- #[oapp_manual_impl(receiver)]
112
+ #[oapp(custom = [receiver])]
113
113
  struct TestFullManualReceiver;
114
114
 
115
+ impl LzReceiveInternal for TestFullManualReceiver {
116
+ fn __lz_receive(
117
+ _env: &Env,
118
+ _origin: &Origin,
119
+ _guid: &BytesN<32>,
120
+ _message: &Bytes,
121
+ _extra_data: &Bytes,
122
+ _executor: &Address,
123
+ _value: i128,
124
+ ) {
125
+ // Custom implementation
126
+ }
127
+ }
128
+
115
129
  #[contractimpl(contracttrait)]
116
130
  impl OAppReceiver for TestFullManualReceiver {
117
131
  fn is_compose_msg_sender(_env: &Env, _origin: &Origin, _message: &Bytes, _sender: &Address) -> bool {
@@ -125,18 +139,6 @@ mod test_full_manual_receiver {
125
139
  fn next_nonce(_env: &Env, _src_eid: u32, _sender: &BytesN<32>) -> u64 {
126
140
  1 // Ordered delivery
127
141
  }
128
-
129
- fn lz_receive(
130
- _env: &Env,
131
- _executor: &Address,
132
- _origin: &Origin,
133
- _guid: &BytesN<32>,
134
- _message: &Bytes,
135
- _extra_data: &Bytes,
136
- _value: i128,
137
- ) {
138
- // Custom implementation - verify_and_clear_payload must be called manually
139
- }
140
142
  }
141
143
  }
142
144
 
@@ -148,21 +150,21 @@ mod test_full_manual_options {
148
150
 
149
151
  use endpoint_v2::Origin;
150
152
  use oapp::oapp_options_type3::{EnforcedOptionParam, OAppOptionsType3};
151
- use oapp_macros::{oapp, oapp_manual_impl};
153
+ use oapp::oapp_receiver::LzReceiveInternal;
154
+ use oapp_macros::oapp;
152
155
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env, Vec};
153
156
 
154
- #[oapp]
155
- #[oapp_manual_impl(options_type3)]
157
+ #[oapp(custom = [options_type3])]
156
158
  struct TestFullManualOptions;
157
159
 
158
- impl TestFullManualOptions {
160
+ impl LzReceiveInternal for TestFullManualOptions {
159
161
  fn __lz_receive(
160
162
  _env: &Env,
161
- _executor: &Address,
162
163
  _origin: &Origin,
163
164
  _guid: &BytesN<32>,
164
165
  _message: &Bytes,
165
166
  _extra_data: &Bytes,
167
+ _executor: &Address,
166
168
  _value: i128,
167
169
  ) {
168
170
  // Implementation
@@ -182,12 +184,11 @@ mod test_full_manual_core_sender {
182
184
  extern crate self as oapp;
183
185
 
184
186
  use endpoint_v2::Origin;
185
- use oapp::{oapp_core::OAppCore, oapp_sender::OAppSender};
186
- use oapp_macros::{oapp, oapp_manual_impl};
187
+ use oapp::{oapp_core::OAppCore, oapp_receiver::LzReceiveInternal, oapp_sender::OAppSenderInternal};
188
+ use oapp_macros::oapp;
187
189
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
188
190
 
189
- #[oapp]
190
- #[oapp_manual_impl(core, sender)]
191
+ #[oapp(custom = [core, sender])]
191
192
  struct TestFullManualCoreSender;
192
193
 
193
194
  #[contractimpl(contracttrait)]
@@ -197,18 +198,18 @@ mod test_full_manual_core_sender {
197
198
  }
198
199
  }
199
200
 
200
- impl OAppSender for TestFullManualCoreSender {
201
+ impl OAppSenderInternal for TestFullManualCoreSender {
201
202
  // Custom sender implementation
202
203
  }
203
204
 
204
- impl TestFullManualCoreSender {
205
+ impl LzReceiveInternal for TestFullManualCoreSender {
205
206
  fn __lz_receive(
206
207
  _env: &Env,
207
- _executor: &Address,
208
208
  _origin: &Origin,
209
209
  _guid: &BytesN<32>,
210
210
  _message: &Bytes,
211
211
  _extra_data: &Bytes,
212
+ _executor: &Address,
212
213
  _value: i128,
213
214
  ) {
214
215
  // Implementation
@@ -223,12 +224,14 @@ mod test_full_manual_core_receiver {
223
224
  extern crate self as oapp;
224
225
 
225
226
  use endpoint_v2::Origin;
226
- use oapp::{oapp_core::OAppCore, oapp_receiver::OAppReceiver};
227
- use oapp_macros::{oapp, oapp_manual_impl};
227
+ use oapp::{
228
+ oapp_core::OAppCore,
229
+ oapp_receiver::{LzReceiveInternal, OAppReceiver},
230
+ };
231
+ use oapp_macros::oapp;
228
232
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
229
233
 
230
- #[oapp]
231
- #[oapp_manual_impl(core, receiver)]
234
+ #[oapp(custom = [core, receiver])]
232
235
  struct TestFullManualCoreReceiver;
233
236
 
234
237
  #[contractimpl(contracttrait)]
@@ -238,20 +241,22 @@ mod test_full_manual_core_receiver {
238
241
  }
239
242
  }
240
243
 
241
- #[contractimpl(contracttrait)]
242
- impl OAppReceiver for TestFullManualCoreReceiver {
243
- fn lz_receive(
244
+ impl LzReceiveInternal for TestFullManualCoreReceiver {
245
+ fn __lz_receive(
244
246
  _env: &Env,
245
- _executor: &Address,
246
247
  _origin: &Origin,
247
248
  _guid: &BytesN<32>,
248
249
  _message: &Bytes,
249
250
  _extra_data: &Bytes,
251
+ _executor: &Address,
250
252
  _value: i128,
251
253
  ) {
252
254
  // Custom receiver implementation
253
255
  }
254
256
  }
257
+
258
+ #[contractimpl(contracttrait)]
259
+ impl OAppReceiver for TestFullManualCoreReceiver {}
255
260
  }
256
261
 
257
262
  // ============================================================================
@@ -261,32 +266,36 @@ mod test_full_manual_sender_receiver {
261
266
  extern crate self as oapp;
262
267
 
263
268
  use endpoint_v2::Origin;
264
- use oapp::{oapp_receiver::OAppReceiver, oapp_sender::OAppSender};
265
- use oapp_macros::{oapp, oapp_manual_impl};
269
+ use oapp::{
270
+ oapp_receiver::{LzReceiveInternal, OAppReceiver},
271
+ oapp_sender::OAppSenderInternal,
272
+ };
273
+ use oapp_macros::oapp;
266
274
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
267
275
 
268
- #[oapp]
269
- #[oapp_manual_impl(sender, receiver)]
276
+ #[oapp(custom = [sender, receiver])]
270
277
  struct TestFullManualSenderReceiver;
271
278
 
272
- impl OAppSender for TestFullManualSenderReceiver {
279
+ impl OAppSenderInternal for TestFullManualSenderReceiver {
273
280
  // Custom sender implementation
274
281
  }
275
282
 
276
- #[contractimpl(contracttrait)]
277
- impl OAppReceiver for TestFullManualSenderReceiver {
278
- fn lz_receive(
283
+ impl LzReceiveInternal for TestFullManualSenderReceiver {
284
+ fn __lz_receive(
279
285
  _env: &Env,
280
- _executor: &Address,
281
286
  _origin: &Origin,
282
287
  _guid: &BytesN<32>,
283
288
  _message: &Bytes,
284
289
  _extra_data: &Bytes,
290
+ _executor: &Address,
285
291
  _value: i128,
286
292
  ) {
287
293
  // Custom receiver implementation
288
294
  }
289
295
  }
296
+
297
+ #[contractimpl(contracttrait)]
298
+ impl OAppReceiver for TestFullManualSenderReceiver {}
290
299
  }
291
300
 
292
301
  // ============================================================================
@@ -296,12 +305,15 @@ mod test_full_manual_all_except_options {
296
305
  extern crate self as oapp;
297
306
 
298
307
  use endpoint_v2::Origin;
299
- use oapp::{oapp_core::OAppCore, oapp_receiver::OAppReceiver, oapp_sender::OAppSender};
300
- use oapp_macros::{oapp, oapp_manual_impl};
308
+ use oapp::{
309
+ oapp_core::OAppCore,
310
+ oapp_receiver::{LzReceiveInternal, OAppReceiver},
311
+ oapp_sender::OAppSenderInternal,
312
+ };
313
+ use oapp_macros::oapp;
301
314
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
302
315
 
303
- #[oapp]
304
- #[oapp_manual_impl(core, sender, receiver)]
316
+ #[oapp(custom = [core, sender, receiver])]
305
317
  struct TestFullManualAllExceptOptions;
306
318
 
307
319
  #[contractimpl(contracttrait)]
@@ -311,24 +323,26 @@ mod test_full_manual_all_except_options {
311
323
  }
312
324
  }
313
325
 
314
- impl OAppSender for TestFullManualAllExceptOptions {
326
+ impl OAppSenderInternal for TestFullManualAllExceptOptions {
315
327
  // Custom sender implementation
316
328
  }
317
329
 
318
- #[contractimpl(contracttrait)]
319
- impl OAppReceiver for TestFullManualAllExceptOptions {
320
- fn lz_receive(
330
+ impl LzReceiveInternal for TestFullManualAllExceptOptions {
331
+ fn __lz_receive(
321
332
  _env: &Env,
322
- _executor: &Address,
323
333
  _origin: &Origin,
324
334
  _guid: &BytesN<32>,
325
335
  _message: &Bytes,
326
336
  _extra_data: &Bytes,
337
+ _executor: &Address,
327
338
  _value: i128,
328
339
  ) {
329
340
  // Custom receiver implementation
330
341
  }
331
342
  }
343
+
344
+ #[contractimpl(contracttrait)]
345
+ impl OAppReceiver for TestFullManualAllExceptOptions {}
332
346
  }
333
347
 
334
348
  // ============================================================================
@@ -341,14 +355,13 @@ mod test_full_manual_all {
341
355
  use oapp::{
342
356
  oapp_core::OAppCore,
343
357
  oapp_options_type3::{EnforcedOptionParam, OAppOptionsType3},
344
- oapp_receiver::OAppReceiver,
345
- oapp_sender::OAppSender,
358
+ oapp_receiver::{LzReceiveInternal, OAppReceiver},
359
+ oapp_sender::OAppSenderInternal,
346
360
  };
347
- use oapp_macros::{oapp, oapp_manual_impl};
361
+ use oapp_macros::oapp;
348
362
  use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env, Vec};
349
363
 
350
- #[oapp]
351
- #[oapp_manual_impl(core, sender, receiver, options_type3)]
364
+ #[oapp(custom = [core, sender, receiver, options_type3])]
352
365
  struct TestFullManualAll;
353
366
 
354
367
  #[contractimpl(contracttrait)]
@@ -358,25 +371,27 @@ mod test_full_manual_all {
358
371
  }
359
372
  }
360
373
 
361
- impl OAppSender for TestFullManualAll {
374
+ impl OAppSenderInternal for TestFullManualAll {
362
375
  // Custom sender implementation
363
376
  }
364
377
 
365
- #[contractimpl(contracttrait)]
366
- impl OAppReceiver for TestFullManualAll {
367
- fn lz_receive(
378
+ impl LzReceiveInternal for TestFullManualAll {
379
+ fn __lz_receive(
368
380
  _env: &Env,
369
- _executor: &Address,
370
381
  _origin: &Origin,
371
382
  _guid: &BytesN<32>,
372
383
  _message: &Bytes,
373
384
  _extra_data: &Bytes,
385
+ _executor: &Address,
374
386
  _value: i128,
375
387
  ) {
376
388
  // Custom receiver implementation
377
389
  }
378
390
  }
379
391
 
392
+ #[contractimpl(contracttrait)]
393
+ impl OAppReceiver for TestFullManualAll {}
394
+
380
395
  #[contractimpl(contracttrait)]
381
396
  impl OAppOptionsType3 for TestFullManualAll {
382
397
  // Custom options implementation
@@ -1,10 +1,19 @@
1
- use common_macros::{only_owner, storage};
1
+ use common_macros::{contract_trait, only_auth, storage};
2
2
  use endpoint_v2::LayerZeroEndpointV2Client;
3
- use soroban_sdk::{contractevent, contracttrait, Address, BytesN, Env};
4
- use utils::ownable::Ownable;
5
- use utils::ownable::OwnableInitializer;
3
+ use soroban_sdk::{contractevent, Address, BytesN, Env};
4
+ use utils::ownable::{Ownable, OwnableInitializer};
6
5
 
7
- pub fn oapp_initialize<T: OAppCore + OwnableInitializer>(
6
+ /// Initializes the OApp with the specified configuration.
7
+ ///
8
+ /// This function sets up the OApp by initializing ownership, storing the LayerZero endpoint,
9
+ /// and optionally setting a delegate address for the endpoint.
10
+ ///
11
+ /// # Arguments
12
+ /// * `env` - The Soroban environment
13
+ /// * `owner` - The address that will own this OApp
14
+ /// * `endpoint` - The LayerZero endpoint address to associate with this OApp
15
+ /// * `delegate` - Optional delegate address to set on the endpoint for this OApp
16
+ pub fn initialize_oapp<T: OAppCore + OwnableInitializer>(
8
17
  env: &Env,
9
18
  owner: &Address,
10
19
  endpoint: &Address,
@@ -12,17 +21,16 @@ pub fn oapp_initialize<T: OAppCore + OwnableInitializer>(
12
21
  ) {
13
22
  T::init_owner(env, owner);
14
23
  OAppCoreStorage::set_endpoint(env, endpoint);
15
-
16
- let endpoint_client = endpoint_v2::LayerZeroEndpointV2Client::new(env, endpoint);
17
- endpoint_client.set_delegate(&env.current_contract_address(), delegate);
24
+ LayerZeroEndpointV2Client::new(env, endpoint).set_delegate(&env.current_contract_address(), delegate);
18
25
  }
19
26
 
20
27
  // =====================================================
21
- // OAppCore Storage, Events, and Interface
28
+ // OAppCore Storage and Events
22
29
  // =====================================================
23
30
 
24
31
  #[storage]
25
32
  pub enum OAppCoreStorage {
33
+ // Immutable endpoint address
26
34
  #[instance(Address)]
27
35
  Endpoint,
28
36
 
@@ -37,22 +45,26 @@ pub struct PeerSet {
37
45
  pub peer: Option<BytesN<32>>,
38
46
  }
39
47
 
40
- #[contracttrait(client_name = "OAppCoreClient")]
41
- pub trait OAppCore: Ownable + Sized {
48
+ // =====================================================
49
+ // OAppCore Interface and Default Implementation
50
+ // =====================================================
51
+
52
+ #[contract_trait]
53
+ pub trait OAppCore: Ownable {
42
54
  /// Retrieves the OApp version information.
43
55
  ///
44
56
  /// # Returns
45
57
  /// A tuple containing:
46
- /// - `sender_version`: The version of the OAppSender implementation
47
- /// - `receiver_version`: The version of the OAppReceiver implementation
58
+ /// - `sender_version`: The version of the OAppSender
59
+ /// - `receiver_version`: The version of the OAppReceiver
48
60
  fn oapp_version(_env: &Env) -> (u64, u64) {
49
- (0, 0)
61
+ (1, 1)
50
62
  }
51
63
 
52
- /// Retrieves the LayerZero endpoint associated with the OApp.
64
+ /// Retrieves the LayerZero endpoint address associated with the OApp.
53
65
  ///
54
66
  /// # Returns
55
- /// The LayerZero endpoint client
67
+ /// The LayerZero endpoint address
56
68
  fn endpoint(env: &Env) -> Address {
57
69
  OAppCoreStorage::endpoint(env).unwrap()
58
70
  }
@@ -73,7 +85,7 @@ pub trait OAppCore: Ownable + Sized {
73
85
  /// # Arguments
74
86
  /// * `eid` - The endpoint ID
75
87
  /// * `peer` - The address of the peer to be associated with the corresponding endpoint, or None to remove the peer
76
- #[only_owner]
88
+ #[only_auth]
77
89
  fn set_peer(env: &Env, eid: u32, peer: &Option<BytesN<32>>) {
78
90
  OAppCoreStorage::set_or_remove_peer(env, eid, peer);
79
91
  PeerSet { eid, peer: peer.clone() }.publish(env);
@@ -83,10 +95,13 @@ pub trait OAppCore: Ownable + Sized {
83
95
  ///
84
96
  /// # Arguments
85
97
  /// * `delegate` - The address of the delegate to be set, or None to remove the delegate
86
- #[only_owner]
98
+ #[only_auth]
87
99
  fn set_delegate(env: &Env, delegate: &Option<Address>) {
88
- let endpoint = Self::endpoint(env);
89
- let endpoint_client = LayerZeroEndpointV2Client::new(env, &endpoint);
90
- endpoint_client.set_delegate(&env.current_contract_address(), delegate);
100
+ endpoint_client::<Self>(env).set_delegate(&env.current_contract_address(), delegate);
91
101
  }
92
102
  }
103
+
104
+ /// Returns a client for the LayerZero endpoint.
105
+ pub fn endpoint_client<'a, T: OAppCore>(env: &'a Env) -> LayerZeroEndpointV2Client<'a> {
106
+ LayerZeroEndpointV2Client::new(env, &T::endpoint(env))
107
+ }
@@ -1,9 +1,9 @@
1
1
  use crate::errors::OAppError;
2
- use common_macros::{only_owner, storage};
3
- use soroban_sdk::{assert_with_error, contractevent, contracttrait, contracttype, panic_with_error, Bytes, Env, Vec};
4
- use utils::ownable::Ownable;
2
+ use common_macros::{contract_trait, only_auth, storage};
3
+ use soroban_sdk::{assert_with_error, contractevent, contracttype, panic_with_error, Bytes, Env, Vec};
4
+ use utils::{buffer_reader::BufferReader, ownable::Ownable};
5
5
 
6
- pub const OPTION_TYPE3: u32 = 3;
6
+ pub const OPTION_TYPE3: u16 = 3;
7
7
 
8
8
  #[contracttype]
9
9
  #[derive(Clone, Debug, Eq, PartialEq)]
@@ -30,13 +30,31 @@ pub struct EnforcedOptionSet {
30
30
  // OAppOptionsType3 Trait and Default Implementation
31
31
  // =========================================================================
32
32
 
33
- #[contracttrait(client_name = "OAppOptionsType3Client")]
34
- pub trait OAppOptionsType3: Ownable + Sized {
33
+ #[contract_trait]
34
+ pub trait OAppOptionsType3: Ownable {
35
+ /// Retrieves the enforced options for a given endpoint and message type.
36
+ ///
37
+ /// # Arguments
38
+ /// * `eid` - The endpoint ID
39
+ /// * `msg_type` - The OApp message type
40
+ ///
41
+ /// # Returns
42
+ /// The enforced options for the given endpoint and message type
35
43
  fn enforced_options(env: &Env, eid: u32, msg_type: u32) -> Bytes {
36
44
  OAppOptionsType3Storage::enforced_options(env, eid, msg_type)
37
45
  }
38
46
 
39
- #[only_owner]
47
+ /// Sets the enforced options for specific endpoint and message type combinations.
48
+ ///
49
+ /// Only the `authorizer` of the OApp can call this function.
50
+ /// Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc.
51
+ /// These enforced options can vary as the potential options/execution on the remote may differ as per the msg_type.
52
+ /// e.g. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you don't want to pay
53
+ /// if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose().
54
+ ///
55
+ /// # Arguments
56
+ /// * `options` - A vector of EnforcedOptionParam structures specifying enforced options
57
+ #[only_auth]
40
58
  fn set_enforced_options(env: &Env, options: Vec<EnforcedOptionParam>) {
41
59
  for option in &options {
42
60
  assert_option_type3(env, &option.options);
@@ -45,6 +63,20 @@ pub trait OAppOptionsType3: Ownable + Sized {
45
63
  EnforcedOptionSet { enforced_option_params: options }.publish(env);
46
64
  }
47
65
 
66
+ /// Combines options for a given endpoint and message type.
67
+ ///
68
+ /// If there is an enforced lzReceive option:
69
+ /// - {gas_limit: 200k, value: 1 XLM} AND a caller supplies a lzReceive option: {gas_limit: 100k, value: 0.5 XLM}
70
+ /// - The resulting options will be {gas_limit: 300k, value: 1.5 XLM} when the message is executed on the remote lz_receive() function.
71
+ /// The presence of duplicated options is handled off-chain in the verifier/executor.
72
+ ///
73
+ /// # Arguments
74
+ /// * `eid` - The endpoint ID
75
+ /// * `msg_type` - The OApp message type
76
+ /// * `extra_options` - Additional options passed by the caller
77
+ ///
78
+ /// # Returns
79
+ /// The combination of caller specified options AND enforced options
48
80
  fn combine_options(env: &Env, eid: u32, msg_type: u32, extra_options: &Bytes) -> Bytes {
49
81
  let mut enforced_options = Self::enforced_options(env, eid, msg_type);
50
82
 
@@ -71,10 +103,14 @@ pub trait OAppOptionsType3: Ownable + Sized {
71
103
  // Helpers Functions
72
104
  // =========================================================================
73
105
 
106
+ /// Asserts that the provided options are of type 3.
107
+ ///
108
+ /// # Arguments
109
+ /// * `options` - The options to be checked
110
+ ///
111
+ /// # Panics
112
+ /// If the options are not of type 3
74
113
  pub fn assert_option_type3(env: &Env, options: &Bytes) {
75
- let mut options_version_bytes = [0u8; 2];
76
- options.slice(0..2).copy_into_slice(&mut options_version_bytes);
77
- let options_version = u16::from_be_bytes(options_version_bytes);
78
-
79
- assert_with_error!(env, options_version as u32 == OPTION_TYPE3, OAppError::InvalidOptions);
114
+ let options_type = BufferReader::new(options).read_u16();
115
+ assert_with_error!(env, options_type == OPTION_TYPE3, OAppError::InvalidOptions);
80
116
  }