@layerzerolabs/protocol-stellar-v2 0.2.8

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 (265) hide show
  1. package/.turbo/turbo-build.log +727 -0
  2. package/.turbo/turbo-lint.log +158 -0
  3. package/.turbo/turbo-test.log +796 -0
  4. package/Cargo.lock +2237 -0
  5. package/Cargo.toml +63 -0
  6. package/clippy.toml +7 -0
  7. package/contracts/common-macros/Cargo.toml +20 -0
  8. package/contracts/common-macros/src/error.rs +53 -0
  9. package/contracts/common-macros/src/event.rs +16 -0
  10. package/contracts/common-macros/src/lib.rs +255 -0
  11. package/contracts/common-macros/src/ownable.rs +63 -0
  12. package/contracts/common-macros/src/snapshots/common_macros__tests__tests__snapshot_generated_storage_code.snap +310 -0
  13. package/contracts/common-macros/src/storage.rs +439 -0
  14. package/contracts/common-macros/src/tests.rs +287 -0
  15. package/contracts/common-macros/src/ttl_configurable.rs +60 -0
  16. package/contracts/endpoint-v2/ARCHITECTURE.md +233 -0
  17. package/contracts/endpoint-v2/Cargo.toml +30 -0
  18. package/contracts/endpoint-v2/src/constants.rs +52 -0
  19. package/contracts/endpoint-v2/src/endpoint_v2.rs +305 -0
  20. package/contracts/endpoint-v2/src/errors.rs +29 -0
  21. package/contracts/endpoint-v2/src/events.rs +207 -0
  22. package/contracts/endpoint-v2/src/interfaces/layerzero_composer.rs +26 -0
  23. package/contracts/endpoint-v2/src/interfaces/layerzero_endpoint_v2.rs +170 -0
  24. package/contracts/endpoint-v2/src/interfaces/layerzero_receiver.rs +43 -0
  25. package/contracts/endpoint-v2/src/interfaces/message_lib.rs +62 -0
  26. package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +220 -0
  27. package/contracts/endpoint-v2/src/interfaces/messaging_channel.rs +121 -0
  28. package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +63 -0
  29. package/contracts/endpoint-v2/src/interfaces/mod.rs +17 -0
  30. package/contracts/endpoint-v2/src/interfaces/send_lib.rs +70 -0
  31. package/contracts/endpoint-v2/src/lib.rs +22 -0
  32. package/contracts/endpoint-v2/src/message_lib_manager.rs +315 -0
  33. package/contracts/endpoint-v2/src/messaging_channel.rs +218 -0
  34. package/contracts/endpoint-v2/src/messaging_composer.rs +76 -0
  35. package/contracts/endpoint-v2/src/storage.rs +78 -0
  36. package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +131 -0
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +237 -0
  38. package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +42 -0
  39. package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +76 -0
  40. package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +211 -0
  41. package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +18 -0
  42. package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +10 -0
  43. package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +10 -0
  44. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +424 -0
  45. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +144 -0
  46. package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +72 -0
  47. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +29 -0
  48. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +513 -0
  49. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +43 -0
  50. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +27 -0
  51. package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +30 -0
  52. package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +202 -0
  53. package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +59 -0
  54. package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +172 -0
  55. package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +23 -0
  56. package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +10 -0
  57. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +131 -0
  58. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +35 -0
  59. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +28 -0
  60. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +79 -0
  61. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +246 -0
  62. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +285 -0
  63. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +180 -0
  64. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +405 -0
  65. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +80 -0
  66. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +131 -0
  67. package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +358 -0
  68. package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +316 -0
  69. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +288 -0
  70. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +316 -0
  71. package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +388 -0
  72. package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +307 -0
  73. package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +10 -0
  74. package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +239 -0
  75. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +324 -0
  76. package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +242 -0
  77. package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +232 -0
  78. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +212 -0
  79. package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +213 -0
  80. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +269 -0
  81. package/contracts/endpoint-v2/src/tests/messaging_composer/mod.rs +4 -0
  82. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +173 -0
  83. package/contracts/endpoint-v2/src/tests/mock.rs +132 -0
  84. package/contracts/endpoint-v2/src/tests/mod.rs +12 -0
  85. package/contracts/endpoint-v2/src/tests/util/build_payload.rs +126 -0
  86. package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +82 -0
  87. package/contracts/endpoint-v2/src/tests/util/keccak256.rs +115 -0
  88. package/contracts/endpoint-v2/src/tests/util/mod.rs +3 -0
  89. package/contracts/endpoint-v2/src/util.rs +52 -0
  90. package/contracts/message-libs/Cargo.toml +12 -0
  91. package/contracts/message-libs/block-message-lib/Cargo.toml +19 -0
  92. package/contracts/message-libs/block-message-lib/src/lib.rs +70 -0
  93. package/contracts/message-libs/lib.rs +2 -0
  94. package/contracts/message-libs/message-lib-common/Cargo.toml +24 -0
  95. package/contracts/message-libs/message-lib-common/src/errors.rs +20 -0
  96. package/contracts/message-libs/message-lib-common/src/interfaces/dvn.rs +55 -0
  97. package/contracts/message-libs/message-lib-common/src/interfaces/executor.rs +46 -0
  98. package/contracts/message-libs/message-lib-common/src/interfaces/mod.rs +7 -0
  99. package/contracts/message-libs/message-lib-common/src/interfaces/treasury.rs +17 -0
  100. package/contracts/message-libs/message-lib-common/src/lib.rs +14 -0
  101. package/contracts/message-libs/message-lib-common/src/packet_codec_v1.rs +99 -0
  102. package/contracts/message-libs/message-lib-common/src/testing_utils.rs +27 -0
  103. package/contracts/message-libs/message-lib-common/src/tests/mod.rs +2 -0
  104. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +162 -0
  105. package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +319 -0
  106. package/contracts/message-libs/message-lib-common/src/worker_options.rs +190 -0
  107. package/contracts/message-libs/simple-message-lib/Cargo.toml +26 -0
  108. package/contracts/message-libs/simple-message-lib/src/errors.rs +11 -0
  109. package/contracts/message-libs/simple-message-lib/src/lib.rs +14 -0
  110. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +136 -0
  111. package/contracts/message-libs/simple-message-lib/src/storage.rs +27 -0
  112. package/contracts/message-libs/simple-message-lib/src/test.rs +280 -0
  113. package/contracts/message-libs/treasury/Cargo.toml +27 -0
  114. package/contracts/message-libs/treasury/src/errors.rs +10 -0
  115. package/contracts/message-libs/treasury/src/events.rs +28 -0
  116. package/contracts/message-libs/treasury/src/interfaces/mod.rs +3 -0
  117. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +20 -0
  118. package/contracts/message-libs/treasury/src/lib.rs +20 -0
  119. package/contracts/message-libs/treasury/src/storage.rs +18 -0
  120. package/contracts/message-libs/treasury/src/tests/mod.rs +2 -0
  121. package/contracts/message-libs/treasury/src/tests/setup.rs +112 -0
  122. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +562 -0
  123. package/contracts/message-libs/treasury/src/treasury.rs +140 -0
  124. package/contracts/message-libs/uln-302/Cargo.toml +28 -0
  125. package/contracts/message-libs/uln-302/src/config_validation.rs +173 -0
  126. package/contracts/message-libs/uln-302/src/errors.rs +29 -0
  127. package/contracts/message-libs/uln-302/src/events.rs +72 -0
  128. package/contracts/message-libs/uln-302/src/interfaces/mod.rs +5 -0
  129. package/contracts/message-libs/uln-302/src/interfaces/receive.rs +82 -0
  130. package/contracts/message-libs/uln-302/src/interfaces/send.rs +159 -0
  131. package/contracts/message-libs/uln-302/src/lib.rs +20 -0
  132. package/contracts/message-libs/uln-302/src/receive.rs +199 -0
  133. package/contracts/message-libs/uln-302/src/send.rs +349 -0
  134. package/contracts/message-libs/uln-302/src/storage.rs +47 -0
  135. package/contracts/message-libs/uln-302/src/tests/config/mod.rs +2 -0
  136. package/contracts/message-libs/uln-302/src/tests/config/oapp_uln_config.rs +291 -0
  137. package/contracts/message-libs/uln-302/src/tests/config/uln_config.rs +163 -0
  138. package/contracts/message-libs/uln-302/src/tests/mod.rs +7 -0
  139. package/contracts/message-libs/uln-302/src/tests/receive_uln302/commit_verification.rs +183 -0
  140. package/contracts/message-libs/uln-302/src/tests/receive_uln302/confirmations.rs +128 -0
  141. package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +104 -0
  142. package/contracts/message-libs/uln-302/src/tests/receive_uln302/mod.rs +66 -0
  143. package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +79 -0
  144. package/contracts/message-libs/uln-302/src/tests/receive_uln302/verifiable.rs +463 -0
  145. package/contracts/message-libs/uln-302/src/tests/receive_uln302/verify.rs +173 -0
  146. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_executor_config.rs +132 -0
  147. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +117 -0
  148. package/contracts/message-libs/uln-302/src/tests/send_uln302/mod.rs +6 -0
  149. package/contracts/message-libs/uln-302/src/tests/send_uln302/quote.rs +586 -0
  150. package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +834 -0
  151. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +95 -0
  152. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +80 -0
  153. package/contracts/message-libs/uln-302/src/tests/setup.rs +268 -0
  154. package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +47 -0
  155. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +51 -0
  156. package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +51 -0
  157. package/contracts/message-libs/uln-302/src/tests/uln302/get_oapp_executor_config.rs +48 -0
  158. package/contracts/message-libs/uln-302/src/tests/uln302/mod.rs +4 -0
  159. package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +998 -0
  160. package/contracts/message-libs/uln-302/src/uln302.rs +117 -0
  161. package/contracts/oapp-macros/Cargo.toml +21 -0
  162. package/contracts/oapp-macros/src/lib.rs +408 -0
  163. package/contracts/oapp-macros/src/oapp_core.rs +49 -0
  164. package/contracts/oapp-macros/src/oapp_full.rs +15 -0
  165. package/contracts/oapp-macros/src/oapp_options_type3.rs +46 -0
  166. package/contracts/oapp-macros/src/oapp_receiver.rs +67 -0
  167. package/contracts/oapp-macros/src/oapp_sender.rs +23 -0
  168. package/contracts/oapp-macros/src/util.rs +103 -0
  169. package/contracts/oapp-macros/tests/test_macros.rs +522 -0
  170. package/contracts/oapps/Cargo.toml +12 -0
  171. package/contracts/oapps/counter/Cargo.toml +24 -0
  172. package/contracts/oapps/counter/integration_tests/mod.rs +3 -0
  173. package/contracts/oapps/counter/integration_tests/setup.rs +201 -0
  174. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +166 -0
  175. package/contracts/oapps/counter/integration_tests/utils.rs +144 -0
  176. package/contracts/oapps/counter/src/codec.rs +63 -0
  177. package/contracts/oapps/counter/src/counter.rs +235 -0
  178. package/contracts/oapps/counter/src/errors.rs +9 -0
  179. package/contracts/oapps/counter/src/lib.rs +16 -0
  180. package/contracts/oapps/counter/src/options.rs +30 -0
  181. package/contracts/oapps/counter/src/storage.rs +33 -0
  182. package/contracts/oapps/counter/src/tests/mod.rs +37 -0
  183. package/contracts/oapps/counter/src/tests/test_codec.rs +64 -0
  184. package/contracts/oapps/counter/src/tests/test_counter.rs +390 -0
  185. package/contracts/oapps/counter/src/u256_ext.rs +21 -0
  186. package/contracts/oapps/lib.rs +2 -0
  187. package/contracts/oapps/oapp/Cargo.toml +21 -0
  188. package/contracts/oapps/oapp/src/errors.rs +9 -0
  189. package/contracts/oapps/oapp/src/lib.rs +10 -0
  190. package/contracts/oapps/oapp/src/oapp_core.rs +92 -0
  191. package/contracts/oapps/oapp/src/oapp_options_type3.rs +89 -0
  192. package/contracts/oapps/oapp/src/oapp_receiver.rs +72 -0
  193. package/contracts/oapps/oapp/src/oapp_sender.rs +66 -0
  194. package/contracts/oapps/oapp/src/tests/mod.rs +4 -0
  195. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +162 -0
  196. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +180 -0
  197. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +157 -0
  198. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +283 -0
  199. package/contracts/utils/Cargo.toml +21 -0
  200. package/contracts/utils/src/buffer_reader.rs +143 -0
  201. package/contracts/utils/src/buffer_writer.rs +117 -0
  202. package/contracts/utils/src/bytes_ext.rs +19 -0
  203. package/contracts/utils/src/errors.rs +30 -0
  204. package/contracts/utils/src/lib.rs +15 -0
  205. package/contracts/utils/src/option_ext.rs +38 -0
  206. package/contracts/utils/src/ownable.rs +88 -0
  207. package/contracts/utils/src/testing_utils.rs +100 -0
  208. package/contracts/utils/src/tests/buffer_reader.rs +1006 -0
  209. package/contracts/utils/src/tests/buffer_writer.rs +330 -0
  210. package/contracts/utils/src/tests/bytes_ext.rs +77 -0
  211. package/contracts/utils/src/tests/mod.rs +4 -0
  212. package/contracts/utils/src/tests/ownable.rs +149 -0
  213. package/contracts/utils/src/ttl.rs +164 -0
  214. package/contracts/workers/Cargo.toml +13 -0
  215. package/contracts/workers/executor/Cargo.toml +26 -0
  216. package/contracts/workers/executor/src/events.rs +22 -0
  217. package/contracts/workers/executor/src/executor.rs +347 -0
  218. package/contracts/workers/executor/src/interfaces/executor.rs +40 -0
  219. package/contracts/workers/executor/src/interfaces/mod.rs +5 -0
  220. package/contracts/workers/executor/src/interfaces/types.rs +51 -0
  221. package/contracts/workers/executor/src/lib.rs +10 -0
  222. package/contracts/workers/executor/src/storage.rs +23 -0
  223. package/contracts/workers/lib.rs +2 -0
  224. package/contracts/workers/worker-common/Cargo.toml +18 -0
  225. package/contracts/workers/worker-common/src/constants.rs +17 -0
  226. package/contracts/workers/worker-common/src/errors.rs +6 -0
  227. package/contracts/workers/worker-common/src/events.rs +34 -0
  228. package/contracts/workers/worker-common/src/interfaces/executor_fee_lib.rs +35 -0
  229. package/contracts/workers/worker-common/src/interfaces/mod.rs +7 -0
  230. package/contracts/workers/worker-common/src/interfaces/price_feed.rs +40 -0
  231. package/contracts/workers/worker-common/src/interfaces/worker.rs +60 -0
  232. package/contracts/workers/worker-common/src/lib.rs +19 -0
  233. package/contracts/workers/worker-common/src/storage.rs +32 -0
  234. package/contracts/workers/worker-common/src/worker_common.rs +166 -0
  235. package/package.json +25 -0
  236. package/rust-toolchain.toml +4 -0
  237. package/rustfmt.toml +17 -0
  238. package/sdk/.turbo/turbo-build.log +4 -0
  239. package/sdk/dist/generated/bml.d.ts +452 -0
  240. package/sdk/dist/generated/bml.js +72 -0
  241. package/sdk/dist/generated/counter.d.ts +824 -0
  242. package/sdk/dist/generated/counter.js +125 -0
  243. package/sdk/dist/generated/endpoint.d.ts +1676 -0
  244. package/sdk/dist/generated/endpoint.js +216 -0
  245. package/sdk/dist/generated/sml.d.ts +810 -0
  246. package/sdk/dist/generated/sml.js +132 -0
  247. package/sdk/dist/generated/uln302.d.ts +1227 -0
  248. package/sdk/dist/generated/uln302.js +185 -0
  249. package/sdk/dist/index.d.ts +5 -0
  250. package/sdk/dist/index.js +5 -0
  251. package/sdk/node_modules/.bin/tsc +21 -0
  252. package/sdk/node_modules/.bin/tsserver +21 -0
  253. package/sdk/node_modules/.bin/vitest +21 -0
  254. package/sdk/node_modules/.bin/zx +21 -0
  255. package/sdk/package.json +40 -0
  256. package/sdk/src/index.ts +5 -0
  257. package/sdk/test/index.test.ts +271 -0
  258. package/sdk/test/suites/constants.ts +13 -0
  259. package/sdk/test/suites/deploy.ts +277 -0
  260. package/sdk/test/suites/localnet.ts +42 -0
  261. package/sdk/test/suites/scan.ts +189 -0
  262. package/sdk/tsconfig.json +106 -0
  263. package/tools/ts-bindings-gen/Cargo.toml +14 -0
  264. package/tools/ts-bindings-gen/src/main.rs +147 -0
  265. package/turbo.json +12 -0
@@ -0,0 +1,170 @@
1
+ use soroban_sdk::{contractclient, contracttype, Address, Bytes, BytesN, Env};
2
+
3
+ use super::{IMessageLibManager, IMessagingChannel, IMessagingComposer};
4
+
5
+ /// Parameters for sending a cross-chain message.
6
+ #[contracttype]
7
+ #[derive(Clone, Debug, Eq, PartialEq)]
8
+ pub struct MessagingParams {
9
+ /// Destination endpoint ID (chain identifier).
10
+ pub dst_eid: u32,
11
+ /// Receiver address on the destination chain (32 bytes).
12
+ pub receiver: BytesN<32>,
13
+ /// The message payload to send.
14
+ pub message: Bytes,
15
+ /// Encoded executor and DVN options.
16
+ pub options: Bytes,
17
+ /// Whether to pay fees in ZRO token instead of native token.
18
+ pub pay_in_zro: bool,
19
+ }
20
+
21
+ /// Source message information identifying where a cross-chain message came from.
22
+ #[contracttype]
23
+ #[derive(Clone, Debug, Eq, PartialEq)]
24
+ pub struct Origin {
25
+ /// Source endpoint ID (chain identifier).
26
+ pub src_eid: u32,
27
+ /// Sender address on the source chain (32 bytes).
28
+ pub sender: BytesN<32>,
29
+ /// Nonce for this pathway.
30
+ pub nonce: u64,
31
+ }
32
+
33
+ /// Fee structure for cross-chain messaging.
34
+ #[contracttype]
35
+ #[derive(Clone, Debug, Eq, PartialEq)]
36
+ pub struct MessagingFee {
37
+ /// Fee paid in native token (XLM).
38
+ pub native_fee: i128,
39
+ /// Fee paid in ZRO token (LayerZero token).
40
+ pub zro_fee: i128,
41
+ }
42
+
43
+ /// Receipt returned after successfully sending a cross-chain message.
44
+ #[contracttype]
45
+ #[derive(Clone, Debug, Eq, PartialEq)]
46
+ pub struct MessagingReceipt {
47
+ /// Globally unique identifier for the message.
48
+ pub guid: BytesN<32>,
49
+ /// The outbound nonce for this pathway.
50
+ pub nonce: u64,
51
+ /// The fees charged for sending the message.
52
+ pub fee: MessagingFee,
53
+ }
54
+
55
+ /// The main LayerZero Endpoint V2 interface for cross-chain messaging.
56
+ #[contractclient(name = "LayerZeroEndpointV2Client")]
57
+ pub trait ILayerZeroEndpointV2: IMessageLibManager + IMessagingChannel + IMessagingComposer {
58
+ /// Quotes the messaging fee for sending a cross-chain message.
59
+ ///
60
+ /// # Arguments
61
+ /// * `sender` - The sender OApp address
62
+ /// * `params` - The messaging parameters (destination, receiver, message, options)
63
+ ///
64
+ /// # Returns
65
+ /// `MessagingFee` containing estimated native and ZRO fees
66
+ fn quote(env: &Env, sender: &Address, params: &MessagingParams) -> MessagingFee;
67
+
68
+ /// Sends a cross-chain message to a destination endpoint.
69
+ ///
70
+ /// # Arguments
71
+ /// * `sender` - The sender OApp address, must provide authorization
72
+ /// * `params` - The messaging parameters (destination, receiver, message, options)
73
+ /// * `refund_address` - The address to receive any excess fee refunds
74
+ ///
75
+ /// # Returns
76
+ /// `MessagingReceipt` containing the message GUID, nonce, and fees paid
77
+ fn send(env: &Env, sender: &Address, params: &MessagingParams, refund_address: &Address) -> MessagingReceipt;
78
+
79
+ /// Verifies an inbound cross-chain message from a receive library.
80
+ ///
81
+ /// # Arguments
82
+ /// * `receive_lib` - The receive library address, must provide authorization
83
+ /// * `origin` - The origin information (source EID, sender, nonce)
84
+ /// * `receiver` - The OApp address receiving the message
85
+ /// * `payload_hash` - The hash of the message payload
86
+ fn verify(env: &Env, receive_lib: &Address, origin: &Origin, receiver: &Address, payload_hash: &BytesN<32>);
87
+
88
+ /// Checks if a message can be verified for the given origin and receiver.
89
+ ///
90
+ /// # Arguments
91
+ /// * `origin` - The origin of the message
92
+ /// * `receiver` - The OApp address
93
+ ///
94
+ /// # Returns
95
+ /// `true` if the message can be verified, `false` otherwise
96
+ fn verifiable(env: &Env, origin: &Origin, receiver: &Address) -> bool;
97
+
98
+ /// Checks if a messaging path is initializable for the given origin and receiver.
99
+ ///
100
+ /// # Arguments
101
+ /// * `origin` - The origin of the message
102
+ /// * `receiver` - The OApp address
103
+ ///
104
+ /// # Returns
105
+ /// `true` if the path can be initialized, `false` otherwise
106
+ fn initializable(env: &Env, origin: &Origin, receiver: &Address) -> bool;
107
+
108
+ /// Clears a verified message from the endpoint (PULL mode) by the OApp.
109
+ ///
110
+ /// # Arguments
111
+ /// * `caller` - The caller address, must be the OApp or its delegate
112
+ /// * `origin` - The origin of the message
113
+ /// * `receiver` - The OApp address receiving the message
114
+ /// * `guid` - The GUID of the message
115
+ /// * `message` - The message content
116
+ fn clear(env: &Env, caller: &Address, origin: &Origin, receiver: &Address, guid: &BytesN<32>, message: &Bytes);
117
+
118
+ /// Emits an alert event when `lz_receive` execution fails.
119
+ ///
120
+ /// # Arguments
121
+ /// * `executor` - The executor address, must provide authorization
122
+ /// * `origin` - The origin of the message
123
+ /// * `receiver` - The OApp address
124
+ /// * `guid` - The message GUID
125
+ /// * `gas` - The gas provided for execution
126
+ /// * `value` - The value provided for execution
127
+ /// * `message` - The message content
128
+ /// * `extra_data` - Additional data for execution
129
+ /// * `reason` - The failure reason
130
+ fn lz_receive_alert(
131
+ env: &Env,
132
+ executor: &Address,
133
+ origin: &Origin,
134
+ receiver: &Address,
135
+ guid: &BytesN<32>,
136
+ gas: i128,
137
+ value: i128,
138
+ message: &Bytes,
139
+ extra_data: &Bytes,
140
+ reason: &Bytes,
141
+ );
142
+
143
+ /// Returns the endpoint ID.
144
+ fn eid(env: &Env) -> u32;
145
+
146
+ /// Returns the native token address used for fee payments.
147
+ fn native_token(env: &Env) -> Address;
148
+
149
+ /// Sets the ZRO token address for fee payments.
150
+ ///
151
+ /// # Arguments
152
+ /// * `zro` - The ZRO token contract address
153
+ fn set_zro(env: &Env, zro: &Address);
154
+
155
+ /// Returns the ZRO token address if set.
156
+ fn zro(env: &Env) -> Option<Address>;
157
+
158
+ /// Sets or removes a delegate address for an OApp.
159
+ ///
160
+ /// # Arguments
161
+ /// * `oapp` - The OApp address, must provide authorization
162
+ /// * `new_delegate` - The delegate address, or `None` to remove
163
+ fn set_delegate(env: &Env, oapp: &Address, new_delegate: &Option<Address>);
164
+
165
+ /// Returns the delegate address for an OApp if set.
166
+ ///
167
+ /// # Arguments
168
+ /// * `oapp` - The OApp address
169
+ fn delegate(env: &Env, oapp: &Address) -> Option<Address>;
170
+ }
@@ -0,0 +1,43 @@
1
+ use soroban_sdk::{contractclient, Address, Bytes, BytesN, Env};
2
+
3
+ use crate::Origin;
4
+
5
+ /// Interface for OApps that can receive cross-chain messages.
6
+ #[contractclient(name = "LayerZeroReceiverClient")]
7
+ pub trait ILayerZeroReceiver {
8
+ /// Checks if a messaging path can be initialized for the given origin.
9
+ ///
10
+ /// # Arguments
11
+ /// * `origin` - The origin of the message
12
+ ///
13
+ /// # Returns
14
+ /// True if the path can be initialized, false otherwise
15
+ fn allow_initialize_path(env: &Env, origin: &Origin) -> bool;
16
+
17
+ /// Returns the next expected nonce for ordered message delivery.
18
+ /// 0 means there is NO nonce ordered enforcement.
19
+ ///
20
+ /// # Arguments
21
+ /// * `src_eid` - The source endpoint ID
22
+ /// * `sender` - The sender OApp address
23
+ fn next_nonce(env: &Env, src_eid: u32, sender: &BytesN<32>) -> u64;
24
+
25
+ /// Receives and processes a cross-chain message.
26
+ ///
27
+ /// # Arguments
28
+ /// * `executor` - The executor address delivering the message
29
+ /// * `origin` - The origin information (source EID, sender, nonce)
30
+ /// * `guid` - The message GUID
31
+ /// * `message` - The message content
32
+ /// * `extra_data` - Additional executor-provided data (untrusted)
33
+ /// * `value` - The native token value sent with the message
34
+ fn lz_receive(
35
+ env: &Env,
36
+ executor: &Address,
37
+ origin: &Origin,
38
+ guid: &BytesN<32>,
39
+ message: &Bytes,
40
+ extra_data: &Bytes,
41
+ value: i128,
42
+ );
43
+ }
@@ -0,0 +1,62 @@
1
+ use soroban_sdk::{contractclient, contracttype, Address, Bytes, Env, Vec};
2
+
3
+ use crate::SetConfigParam;
4
+
5
+ /// Type of message library indicating supported operations.
6
+ #[contracttype]
7
+ #[derive(Clone, Debug, Eq, PartialEq)]
8
+ #[repr(u8)]
9
+ pub enum MessageLibType {
10
+ /// Supports only sending messages.
11
+ Send,
12
+ /// Supports only receiving messages.
13
+ Receive,
14
+ /// Supports both sending and receiving messages.
15
+ SendAndReceive,
16
+ }
17
+
18
+ /// Version information for a message library.
19
+ ///
20
+ /// Note: `minor` and `endpoint_version` use `u32` instead of `u8` because Stellar does not
21
+ /// support `u8` types in contract interface functions.
22
+ #[contracttype]
23
+ #[derive(Clone, Debug, Eq, PartialEq)]
24
+ pub struct MessageLibVersion {
25
+ /// Major version number.
26
+ pub major: u64,
27
+ /// Minor version number (should not exceed u8::MAX = 255).
28
+ pub minor: u32,
29
+ /// Endpoint version (should not exceed u8::MAX = 255).
30
+ pub endpoint_version: u32,
31
+ }
32
+
33
+ /// Interface for message libraries that handle cross-chain message verification and delivery.
34
+ #[contractclient(name = "MessageLibClient")]
35
+ pub trait IMessageLib {
36
+ /// Sets the configuration for an OApp by the Endpoint.
37
+ ///
38
+ /// # Arguments
39
+ /// * `oapp` - The OApp address
40
+ /// * `params` - Library-specific configuration parameters (e.g., DVN configs, executor configs)
41
+ fn set_config(env: &Env, oapp: &Address, params: &Vec<SetConfigParam>);
42
+
43
+ /// Returns the configuration for a specific endpoint ID and config type.
44
+ ///
45
+ /// # Arguments
46
+ /// * `eid` - The endpoint ID
47
+ /// * `oapp` - The OApp address
48
+ /// * `config_type` - The type of configuration
49
+ fn get_config(env: &Env, eid: u32, oapp: &Address, config_type: u32) -> Bytes;
50
+
51
+ /// Checks if an endpoint ID is supported by this library.
52
+ ///
53
+ /// # Arguments
54
+ /// * `eid` - The endpoint ID
55
+ fn is_supported_eid(env: &Env, eid: u32) -> bool;
56
+
57
+ /// Returns the version information of this library.
58
+ fn version(env: &Env) -> MessageLibVersion;
59
+
60
+ /// Returns the type of this message library.
61
+ fn message_lib_type(env: &Env) -> MessageLibType;
62
+ }
@@ -0,0 +1,220 @@
1
+ use soroban_sdk::{contractclient, contracttype, Address, Bytes, Env, Vec};
2
+
3
+ /// Timeout configuration for receive library transitions.
4
+ #[contracttype]
5
+ #[derive(Clone, Debug, Eq, PartialEq)]
6
+ pub struct Timeout {
7
+ /// The new library address to transition to.
8
+ pub lib: Address,
9
+ /// Unix timestamp when the timeout expires.
10
+ pub expiry: u64,
11
+ }
12
+
13
+ impl Timeout {
14
+ /// Checks if the timeout has expired.
15
+ pub fn is_expired(&self, env: &Env) -> bool {
16
+ self.expiry <= env.ledger().timestamp()
17
+ }
18
+
19
+ /// Checks if the timeout is valid for the given library (matches and not expired).
20
+ pub fn is_valid_for(&self, env: &Env, lib: &Address) -> bool {
21
+ &self.lib == lib && !self.is_expired(env)
22
+ }
23
+ }
24
+
25
+ /// Parameters for setting message library configuration.
26
+ #[contracttype]
27
+ #[derive(Clone, Debug, Eq, PartialEq)]
28
+ pub struct SetConfigParam {
29
+ /// The endpoint ID this config applies to.
30
+ pub eid: u32,
31
+ /// The type of configuration (e.g., executor, ULN).
32
+ pub config_type: u32,
33
+ /// XDR-encoded configuration data.
34
+ pub config: Bytes,
35
+ }
36
+
37
+ /// Resolved library information with default status.
38
+ #[contracttype]
39
+ #[derive(Clone, Debug, Eq, PartialEq)]
40
+ pub struct ResolvedLibrary {
41
+ /// The resolved library address.
42
+ pub lib: Address,
43
+ /// Whether this is the default library (true) or OApp-specific (false).
44
+ pub is_default: bool,
45
+ }
46
+
47
+ /// EndpointV2's Interface for managing message libraries.
48
+ #[contractclient(name = "MessageLibManagerClient")]
49
+ pub trait IMessageLibManager {
50
+ /// Registers a new message library with the endpoint.
51
+ ///
52
+ /// # Arguments
53
+ /// * `new_lib` - The address of the message library to register
54
+ fn register_library(env: &Env, new_lib: &Address);
55
+
56
+ /// Checks if a message library is registered.
57
+ ///
58
+ /// # Arguments
59
+ /// * `lib` - The address of the message library to check
60
+ fn is_registered_library(env: &Env, lib: &Address) -> bool;
61
+
62
+ /// Returns the index of a message library.
63
+ ///
64
+ /// # Arguments
65
+ /// * `lib` - The address of the message library to check
66
+ ///
67
+ /// # Returns
68
+ /// * `Option<u32>` - The index of the message library, or `None` if the library is not registered
69
+ fn get_library_index(env: &Env, lib: &Address) -> Option<u32>;
70
+
71
+ /// Returns a list of registered message libraries within the specified range.
72
+ ///
73
+ /// # Arguments
74
+ /// * `start` - The starting index
75
+ /// * `max_count` - The maximum number of libraries to return
76
+ fn get_registered_libraries(env: &Env, start: u32, max_count: u32) -> Vec<Address>;
77
+
78
+ /// Returns the number of registered message libraries.
79
+ fn registered_libraries_count(env: &Env) -> u32;
80
+
81
+ /// Sets the default send library for a destination endpoint.
82
+ ///
83
+ /// # Arguments
84
+ /// * `dst_eid` - The destination endpoint ID
85
+ /// * `new_lib` - The library address to set as default
86
+ fn set_default_send_library(env: &Env, dst_eid: u32, new_lib: &Address);
87
+
88
+ /// Returns the default send library for a destination endpoint.
89
+ ///
90
+ /// # Arguments
91
+ /// * `dst_eid` - The destination endpoint ID
92
+ fn default_send_library(env: &Env, dst_eid: u32) -> Option<Address>;
93
+
94
+ /// Sets the default receive library for a source endpoint.
95
+ ///
96
+ /// # Arguments
97
+ /// * `src_eid` - The source endpoint ID
98
+ /// * `new_lib` - The library address to set as default
99
+ /// * `grace_period` - Time in seconds during which the old library remains valid
100
+ fn set_default_receive_library(env: &Env, src_eid: u32, new_lib: &Address, grace_period: u64);
101
+
102
+ /// Returns the default receive library for a source endpoint.
103
+ ///
104
+ /// # Arguments
105
+ /// * `src_eid` - The source endpoint ID
106
+ fn default_receive_library(env: &Env, src_eid: u32) -> Option<Address>;
107
+
108
+ /// Sets or removes the default receive library timeout for a source endpoint.
109
+ ///
110
+ /// This function provides the same functionality as `setDefaultReceiveLibraryTimeout` on EVM.
111
+ /// The function name has been shortened to `set_default_receive_lib_timeout` due to Stellar's
112
+ /// naming constraints.
113
+ ///
114
+ /// # Arguments
115
+ /// * `src_eid` - The source endpoint ID
116
+ /// * `timeout` - The timeout configuration, or `None` to remove it
117
+ fn set_default_receive_lib_timeout(env: &Env, src_eid: u32, timeout: &Option<Timeout>);
118
+
119
+ /// Returns the default receive library timeout for a source endpoint.
120
+ ///
121
+ /// # Arguments
122
+ /// * `src_eid` - The source endpoint ID
123
+ fn default_receive_library_timeout(env: &Env, src_eid: u32) -> Option<Timeout>;
124
+
125
+ /// Checks if an endpoint ID is supported (both send and receive libraries are set).
126
+ ///
127
+ /// # Arguments
128
+ /// * `eid` - The endpoint ID
129
+ fn is_supported_eid(env: &Env, eid: u32) -> bool;
130
+
131
+ /// Checks if a receive library is valid for an OApp and source endpoint.
132
+ ///
133
+ /// # Arguments
134
+ /// * `receiver` - The receiver OApp address
135
+ /// * `src_eid` - The source endpoint ID
136
+ /// * `lib` - The library address to check
137
+ fn is_valid_receive_library(env: &Env, receiver: &Address, src_eid: u32, lib: &Address) -> bool;
138
+
139
+ // === OApp Control Functions ===
140
+
141
+ /// Sets or removes a custom send library for an OApp.
142
+ ///
143
+ /// # Arguments
144
+ /// * `caller` - The caller address, must be the OApp or its delegate
145
+ /// * `sender` - The receiver OApp address
146
+ /// * `dst_eid` - The destination endpoint ID
147
+ /// * `new_lib` - The library address, or `None` to use the default
148
+ fn set_send_library(env: &Env, caller: &Address, sender: &Address, dst_eid: u32, new_lib: &Option<Address>);
149
+
150
+ /// Returns the effective send library for an OApp and destination endpoint.
151
+ ///
152
+ /// # Arguments
153
+ /// * `sender` - The receiver OApp address
154
+ /// * `dst_eid` - The destination endpoint ID
155
+ fn get_send_library(env: &Env, sender: &Address, dst_eid: u32) -> ResolvedLibrary;
156
+
157
+ /// Sets or removes a custom receive library for an OApp.
158
+ ///
159
+ /// # Arguments
160
+ /// * `caller` - The caller address, must be the OApp or its delegate
161
+ /// * `receiver` - The receiver OApp address
162
+ /// * `src_eid` - The source endpoint ID
163
+ /// * `new_lib` - The library address, or `None` to use the default
164
+ /// * `grace_period` - Time in seconds during which the old library remains valid
165
+ fn set_receive_library(
166
+ env: &Env,
167
+ caller: &Address,
168
+ receiver: &Address,
169
+ src_eid: u32,
170
+ new_lib: &Option<Address>,
171
+ grace_period: u64,
172
+ );
173
+
174
+ /// Returns the effective receive library for an OApp and source endpoint.
175
+ ///
176
+ /// # Arguments
177
+ /// * `receiver` - The receiver OApp address
178
+ /// * `src_eid` - The source endpoint ID
179
+ fn get_receive_library(env: &Env, receiver: &Address, src_eid: u32) -> ResolvedLibrary;
180
+
181
+ /// Sets or removes the receive library timeout for an OApp.
182
+ ///
183
+ /// # Arguments
184
+ /// * `caller` - The caller address, must be the OApp or its delegate
185
+ /// * `receiver` - The receiver OApp address
186
+ /// * `src_eid` - The source endpoint ID
187
+ /// * `timeout` - The timeout configuration, or `None` to remove
188
+ fn set_receive_library_timeout(
189
+ env: &Env,
190
+ caller: &Address,
191
+ receiver: &Address,
192
+ src_eid: u32,
193
+ timeout: &Option<Timeout>,
194
+ );
195
+
196
+ /// Returns the receive library timeout for an OApp and source endpoint.
197
+ ///
198
+ /// # Arguments
199
+ /// * `receiver` - The receiver OApp address
200
+ /// * `src_eid` - The source endpoint ID
201
+ fn receive_library_timeout(env: &Env, receiver: &Address, src_eid: u32) -> Option<Timeout>;
202
+
203
+ /// Sets the configuration for a message library.
204
+ ///
205
+ /// # Arguments
206
+ /// * `caller` - The caller address, must be the OApp or its delegate
207
+ /// * `oapp` - The OApp address
208
+ /// * `lib` - The message library address
209
+ /// * `params` - The configuration parameters
210
+ fn set_config(env: &Env, caller: &Address, oapp: &Address, lib: &Address, params: &Vec<SetConfigParam>);
211
+
212
+ /// Returns the configuration for a message library.
213
+ ///
214
+ /// # Arguments
215
+ /// * `oapp` - The OApp address
216
+ /// * `lib` - The message library address
217
+ /// * `eid` - The endpoint ID
218
+ /// * `config_type` - The type of configuration
219
+ fn get_config(env: &Env, oapp: &Address, lib: &Address, eid: u32, config_type: u32) -> Bytes;
220
+ }
@@ -0,0 +1,121 @@
1
+ use soroban_sdk::{contractclient, Address, BytesN, Env};
2
+
3
+ /// EndpointV2's Interface for managing messaging channels, nonces, and payload hashes.
4
+ #[contractclient(name = "MessagingChannelClient")]
5
+ pub trait IMessagingChannel {
6
+ /// Skips the next expected inbound nonce without verifying.
7
+ ///
8
+ /// Used to handle messages that should be bypassed (e.g., due to precrime alerts).
9
+ ///
10
+ /// # Arguments
11
+ /// * `caller` - The caller address, must be the OApp or its delegate
12
+ /// * `receiver` - The receiver OApp address
13
+ /// * `src_eid` - The source endpoint ID
14
+ /// * `sender` - The sender address on the source chain
15
+ /// * `nonce` - The nonce to skip (must be the next expected nonce)
16
+ fn skip(env: &Env, caller: &Address, receiver: &Address, src_eid: u32, sender: &BytesN<32>, nonce: u64);
17
+
18
+ /// Marks a verified message as nil, preventing execution until re-verified.
19
+ /// The message can be re-verified later by calling `verify` again.
20
+ /// A non-verified nonce can be nilified by passing `None` for `payload_hash`.
21
+ ///
22
+ /// # Arguments
23
+ /// * `caller` - The caller address, must be the OApp or its delegate
24
+ /// * `receiver` - The receiver OApp address
25
+ /// * `src_eid` - The source endpoint ID
26
+ /// * `sender` - The sender address on the source chain
27
+ /// * `nonce` - The nonce of the message to nilify
28
+ /// * `payload_hash` - The payload hash (must match the stored hash), or `None` for a non-verified nonce
29
+ fn nilify(
30
+ env: &Env,
31
+ caller: &Address,
32
+ receiver: &Address,
33
+ src_eid: u32,
34
+ sender: &BytesN<32>,
35
+ nonce: u64,
36
+ payload_hash: &Option<BytesN<32>>,
37
+ );
38
+
39
+ /// Marks a nonce as permanently unexecutable and un-verifiable.
40
+ /// The nonce can never be re-verified or executed after burning.
41
+ ///
42
+ /// # Arguments
43
+ /// * `caller` - The caller address, must be the OApp or its delegate
44
+ /// * `receiver` - The receiver OApp address
45
+ /// * `src_eid` - The source endpoint ID
46
+ /// * `sender` - The sender OApp address on the source chain
47
+ /// * `nonce` - The nonce to burn
48
+ /// * `payload_hash` - The payload hash (must match the stored hash)
49
+ fn burn(
50
+ env: &Env,
51
+ caller: &Address,
52
+ receiver: &Address,
53
+ src_eid: u32,
54
+ sender: &BytesN<32>,
55
+ nonce: u64,
56
+ payload_hash: &BytesN<32>,
57
+ );
58
+
59
+ /// Generates the next GUID for an outbound packet.
60
+ ///
61
+ /// # Arguments
62
+ /// * `sender` - The sender OApp address
63
+ /// * `dst_eid` - The destination endpoint ID
64
+ /// * `receiver` - The receiver OApp address on the destination chain
65
+ ///
66
+ /// # Returns
67
+ /// The next GUID computed from nonce, source EID, sender, destination EID, and receiver
68
+ fn next_guid(env: &Env, sender: &Address, dst_eid: u32, receiver: &BytesN<32>) -> BytesN<32>;
69
+
70
+ /// Returns the current outbound nonce for a specific path.
71
+ ///
72
+ /// # Arguments
73
+ /// * `sender` - The sender OApp address
74
+ /// * `dst_eid` - The destination endpoint ID
75
+ /// * `receiver` - The receiver OApp address on the destination chain
76
+ ///
77
+ /// # Returns
78
+ /// The current outbound nonce (0 if no messages sent yet)
79
+ fn outbound_nonce(env: &Env, sender: &Address, dst_eid: u32, receiver: &BytesN<32>) -> u64;
80
+
81
+ /// Returns the max index of the longest gapless sequence of verified nonces.
82
+ /// Example: `[1,2,3,4,6,7] => 4`, `[1,2,6,8,10] => 2`
83
+ ///
84
+ /// # Arguments
85
+ /// * `receiver` - The receiver OApp address
86
+ /// * `src_eid` - The source endpoint ID
87
+ /// * `sender` - The sender address on the source chain
88
+ ///
89
+ /// # Returns
90
+ /// The highest nonce in the gapless sequence starting from lazy_inbound_nonce
91
+ fn inbound_nonce(env: &Env, receiver: &Address, src_eid: u32, sender: &BytesN<32>) -> u64;
92
+
93
+ /// Returns the lazy inbound nonce (last checkpoint) for a specific path.
94
+ ///
95
+ /// # Arguments
96
+ /// * `receiver` - The receiver OApp address
97
+ /// * `src_eid` - The source endpoint ID
98
+ /// * `sender` - The sender OApp address on the source chain
99
+ ///
100
+ /// # Returns
101
+ /// The lazy inbound nonce, updated when messages are cleared/executed
102
+ fn lazy_inbound_nonce(env: &Env, receiver: &Address, src_eid: u32, sender: &BytesN<32>) -> u64;
103
+
104
+ /// Returns the payload hash for a specific inbound nonce.
105
+ ///
106
+ /// # Arguments
107
+ /// * `receiver` - The receiver OApp address
108
+ /// * `src_eid` - The source endpoint ID
109
+ /// * `sender` - The sender OApp address on the source chain
110
+ /// * `nonce` - The nonce to query
111
+ ///
112
+ /// # Returns
113
+ /// The payload hash if verified, `None` otherwise
114
+ fn inbound_payload_hash(
115
+ env: &Env,
116
+ receiver: &Address,
117
+ src_eid: u32,
118
+ sender: &BytesN<32>,
119
+ nonce: u64,
120
+ ) -> Option<BytesN<32>>;
121
+ }
@@ -0,0 +1,63 @@
1
+ use soroban_sdk::{contractclient, Address, Bytes, BytesN, Env};
2
+
3
+ /// EndpointV2's Interface for managing composed messages between OApps and composers.
4
+ #[contractclient(name = "MessagingComposerClient")]
5
+ pub trait IMessagingComposer {
6
+ /// Sends a composed message from an OApp to a composer.
7
+ /// The OApp can send compose to multiple composers with the same GUID.
8
+ ///
9
+ /// # Arguments
10
+ /// * `from` - The sender OApp address, must provide authorization
11
+ /// * `to` - The composer address that will receive the message
12
+ /// * `guid` - The message GUID
13
+ /// * `index` - The compose message index
14
+ /// * `message` - The composed message content
15
+ fn send_compose(env: &Env, from: &Address, to: &Address, guid: &BytesN<32>, index: u32, message: &Bytes);
16
+
17
+ /// Clears a composed message after execution by the composer.
18
+ /// This is PULL mode - the composer calls this after processing the message.
19
+ ///
20
+ /// # Arguments
21
+ /// * `composer` - The composer address, must provide authorization
22
+ /// * `from` - The sender OApp address
23
+ /// * `guid` - The message GUID
24
+ /// * `index` - The compose message index
25
+ /// * `message` - The composed message content (must match stored hash)
26
+ fn clear_compose(env: &Env, composer: &Address, from: &Address, guid: &BytesN<32>, index: u32, message: &Bytes);
27
+
28
+ /// Emits an alert event when `lz_compose` execution fails.
29
+ ///
30
+ /// # Arguments
31
+ /// * `executor` - The executor address, must provide authorization
32
+ /// * `from` - The sender OApp address
33
+ /// * `to` - The composer address
34
+ /// * `guid` - The message GUID
35
+ /// * `index` - The compose message index
36
+ /// * `gas` - The gas provided for execution
37
+ /// * `value` - The value provided for execution
38
+ /// * `message` - The composed message content
39
+ /// * `extra_data` - Additional data for execution
40
+ /// * `reason` - The failure reason
41
+ fn lz_compose_alert(
42
+ env: &Env,
43
+ executor: &Address,
44
+ from: &Address,
45
+ to: &Address,
46
+ guid: &BytesN<32>,
47
+ index: u32,
48
+ gas: i128, // TODO: should rename to fee cuz there's no gas in stellar
49
+ value: i128,
50
+ message: &Bytes,
51
+ extra_data: &Bytes,
52
+ reason: &Bytes,
53
+ );
54
+
55
+ /// Returns the stored hash for a composed message.
56
+ ///
57
+ /// # Arguments
58
+ /// * `from` - The sender OApp address
59
+ /// * `to` - The composer address
60
+ /// * `guid` - The message GUID
61
+ /// * `index` - The compose message index
62
+ fn compose_queue(env: &Env, from: &Address, to: &Address, guid: &BytesN<32>, index: u32) -> Option<BytesN<32>>;
63
+ }