@layerzerolabs/protocol-stellar-v2 0.2.20 → 0.2.22

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 (198) hide show
  1. package/.turbo/turbo-build.log +783 -802
  2. package/.turbo/turbo-lint.log +320 -157
  3. package/.turbo/turbo-test.log +1414 -1457
  4. package/Cargo.lock +109 -108
  5. package/Cargo.toml +32 -18
  6. package/contracts/common-macros/Cargo.toml +7 -7
  7. package/contracts/common-macros/src/auth.rs +18 -37
  8. package/contracts/common-macros/src/contract_ttl.rs +2 -2
  9. package/contracts/common-macros/src/lib.rs +27 -10
  10. package/contracts/common-macros/src/lz_contract.rs +38 -7
  11. package/contracts/common-macros/src/storage.rs +251 -292
  12. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +6 -12
  13. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +12 -17
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +2 -7
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +20 -9
  16. package/contracts/common-macros/src/tests/upgradeable.rs +26 -4
  17. package/contracts/common-macros/src/ttl_configurable.rs +2 -10
  18. package/contracts/common-macros/src/ttl_extendable.rs +2 -10
  19. package/contracts/common-macros/src/upgradeable.rs +56 -15
  20. package/contracts/common-macros/src/utils.rs +0 -9
  21. package/contracts/endpoint-v2/src/lib.rs +3 -2
  22. package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +2 -2
  23. package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +3 -3
  24. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +4 -4
  25. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +17 -5
  26. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  27. package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +2 -2
  28. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +2 -2
  29. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +6 -6
  30. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +67 -37
  31. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +5 -5
  32. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +44 -54
  33. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +7 -7
  34. package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +8 -8
  35. package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +3 -3
  36. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +4 -4
  37. package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +3 -3
  38. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +2 -2
  39. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +3 -3
  40. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +2 -2
  41. package/contracts/layerzero-views/Cargo.toml +0 -1
  42. package/contracts/layerzero-views/src/layerzero_view.rs +1 -13
  43. package/contracts/macro-integration-tests/Cargo.toml +5 -15
  44. package/contracts/macro-integration-tests/tests/runtime/oapp/mod.rs +48 -0
  45. package/contracts/macro-integration-tests/tests/runtime/oapp/oapp_core.rs +170 -0
  46. package/contracts/macro-integration-tests/tests/runtime/oapp/options_type3.rs +154 -0
  47. package/contracts/macro-integration-tests/tests/runtime/oapp/receiver.rs +338 -0
  48. package/contracts/macro-integration-tests/tests/runtime/oapp/sender.rs +435 -0
  49. package/contracts/macro-integration-tests/tests/runtime.rs +1 -0
  50. package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.rs +8 -0
  51. package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.stderr +5 -0
  52. package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.rs +8 -0
  53. package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.stderr +71 -0
  54. package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.rs +10 -0
  55. package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.stderr +5 -0
  56. package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.rs +8 -0
  57. package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.stderr +5 -0
  58. package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.rs +8 -0
  59. package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.stderr +5 -0
  60. package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_all.rs +38 -0
  61. package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_single_trait.rs +96 -0
  62. package/contracts/macro-integration-tests/tests/ui/oapp/pass/minimal_contract.rs +64 -0
  63. package/contracts/macro-integration-tests/tests/ui/oapp/pass/struct_with_fields.rs +46 -0
  64. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +8 -0
  65. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +1 -1
  66. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +1 -1
  67. package/contracts/macro-integration-tests/tests/ui_oapp.rs +11 -0
  68. package/contracts/message-libs/message-lib-common/Cargo.toml +0 -1
  69. package/contracts/message-libs/message-lib-common/src/errors.rs +1 -1
  70. package/contracts/message-libs/treasury/Cargo.toml +0 -2
  71. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +2 -2
  72. package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +2 -2
  73. package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +2 -2
  74. package/contracts/message-libs/uln-302/src/tests/receive_uln302/verify.rs +2 -2
  75. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_executor_config.rs +2 -2
  76. package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +2 -2
  77. package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +7 -27
  78. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
  79. package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +2 -2
  80. package/contracts/oapps/counter/Cargo.toml +4 -6
  81. package/contracts/oapps/counter/integration_tests/utils.rs +19 -12
  82. package/contracts/oapps/oapp/src/errors.rs +1 -1
  83. package/contracts/oapps/oapp/src/interfaces/mod.rs +3 -0
  84. package/contracts/oapps/oapp/src/interfaces/oapp_msg_inspector.rs +47 -0
  85. package/contracts/oapps/oapp/src/lib.rs +1 -0
  86. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +4 -4
  87. package/contracts/oapps/oapp/src/oapp_core.rs +5 -5
  88. package/contracts/oapps/oapp/src/oapp_options_type3.rs +12 -4
  89. package/contracts/oapps/oapp/src/oapp_receiver.rs +14 -9
  90. package/contracts/oapps/oapp/src/tests/mod.rs +4 -4
  91. package/contracts/oapps/oapp/src/tests/{test_oapp_core.rs → oapp_core.rs} +4 -4
  92. package/contracts/oapps/oapp/src/tests/{test_oapp_options_type3.rs → oapp_options_type3.rs} +3 -4
  93. package/contracts/oapps/oapp-macros/Cargo.toml +8 -4
  94. package/contracts/oapps/oapp-macros/src/generators.rs +9 -34
  95. package/contracts/oapps/oapp-macros/src/lib.rs +3 -0
  96. package/contracts/oapps/oapp-macros/src/tests/mod.rs +2 -0
  97. package/contracts/oapps/oapp-macros/src/tests/oapp.rs +88 -0
  98. package/contracts/oapps/oapp-macros/src/tests/parse_custom_impls.rs +86 -0
  99. package/contracts/oapps/oapp-macros/src/tests/snapshots/oapp_macros__tests__oapp__snapshot_generate_oapp.snap +103 -0
  100. package/contracts/oapps/oft/integration-tests/utils.rs +28 -8
  101. package/contracts/oapps/oft/src/extensions/oft_fee.rs +136 -74
  102. package/contracts/oapps/oft/src/extensions/pausable.rs +44 -10
  103. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +170 -130
  104. package/contracts/oapps/oft/src/oft.rs +19 -12
  105. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
  106. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -1
  107. package/contracts/oapps/oft-core/Cargo.toml +1 -4
  108. package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -2
  109. package/contracts/oapps/oft-core/integration-tests/utils.rs +21 -3
  110. package/contracts/oapps/oft-core/src/errors.rs +3 -2
  111. package/contracts/oapps/oft-core/src/events.rs +6 -0
  112. package/contracts/oapps/oft-core/src/lib.rs +1 -1
  113. package/contracts/oapps/oft-core/src/oft_core.rs +115 -60
  114. package/contracts/oapps/oft-core/src/storage.rs +7 -3
  115. package/contracts/oapps/oft-core/src/tests/mod.rs +1 -0
  116. package/contracts/oapps/oft-core/src/tests/test_decimals.rs +37 -2
  117. package/contracts/oapps/oft-core/src/tests/test_lz_receive.rs +2 -2
  118. package/contracts/oapps/oft-core/src/tests/test_msg_inspector.rs +323 -0
  119. package/contracts/oapps/oft-core/src/tests/test_send.rs +2 -2
  120. package/contracts/oapps/oft-core/src/tests/test_utils.rs +59 -14
  121. package/contracts/utils/Cargo.toml +0 -1
  122. package/contracts/utils/src/errors.rs +1 -1
  123. package/contracts/utils/src/multisig.rs +17 -8
  124. package/contracts/utils/src/ownable.rs +6 -6
  125. package/contracts/utils/src/testing_utils.rs +124 -54
  126. package/contracts/utils/src/tests/multisig.rs +12 -12
  127. package/contracts/utils/src/tests/ownable.rs +6 -6
  128. package/contracts/utils/src/tests/testing_utils.rs +50 -167
  129. package/contracts/utils/src/tests/ttl_configurable.rs +5 -5
  130. package/contracts/utils/src/tests/upgradeable.rs +1 -1
  131. package/contracts/utils/src/ttl_configurable.rs +10 -4
  132. package/contracts/utils/src/upgradeable.rs +5 -5
  133. package/contracts/workers/dvn/Cargo.toml +5 -6
  134. package/contracts/workers/dvn/src/dvn.rs +2 -12
  135. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
  136. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +37 -19
  137. package/contracts/workers/dvn-fee-lib/src/lib.rs +12 -2
  138. package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +15 -13
  139. package/contracts/workers/executor/Cargo.toml +3 -0
  140. package/contracts/workers/executor/src/executor.rs +2 -12
  141. package/contracts/workers/executor/src/lib.rs +2 -2
  142. package/contracts/workers/executor/src/tests/auth.rs +394 -0
  143. package/contracts/workers/executor/src/tests/executor.rs +410 -0
  144. package/contracts/workers/executor/src/tests/mod.rs +3 -0
  145. package/contracts/workers/executor/src/tests/setup.rs +250 -0
  146. package/contracts/workers/executor-fee-lib/Cargo.toml +5 -0
  147. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +1 -12
  148. package/contracts/workers/executor-fee-lib/src/lib.rs +8 -2
  149. package/contracts/workers/executor-helper/Cargo.toml +0 -1
  150. package/contracts/workers/price-feed/Cargo.toml +5 -0
  151. package/contracts/workers/price-feed/src/lib.rs +9 -4
  152. package/contracts/workers/price-feed/src/price_feed.rs +1 -11
  153. package/contracts/workers/worker/src/errors.rs +1 -1
  154. package/contracts/workers/worker/src/tests/setup.rs +1 -1
  155. package/contracts/workers/worker/src/tests/worker.rs +55 -41
  156. package/contracts/workers/worker/src/worker.rs +34 -25
  157. package/docs/error-spec.md +55 -0
  158. package/docs/layerzero-v2-on-stellar.md +447 -0
  159. package/docs/oapp-guide.md +212 -0
  160. package/docs/oft-guide.md +314 -0
  161. package/package.json +3 -3
  162. package/sdk/.turbo/turbo-test.log +260 -257
  163. package/sdk/dist/generated/bml.d.ts +3 -3
  164. package/sdk/dist/generated/bml.js +4 -4
  165. package/sdk/dist/generated/counter.d.ts +295 -295
  166. package/sdk/dist/generated/counter.js +43 -43
  167. package/sdk/dist/generated/dvn.d.ts +91 -91
  168. package/sdk/dist/generated/dvn.js +24 -24
  169. package/sdk/dist/generated/dvn_fee_lib.d.ts +92 -92
  170. package/sdk/dist/generated/dvn_fee_lib.js +25 -25
  171. package/sdk/dist/generated/endpoint.d.ts +99 -99
  172. package/sdk/dist/generated/endpoint.js +16 -16
  173. package/sdk/dist/generated/executor.d.ts +91 -91
  174. package/sdk/dist/generated/executor.js +24 -24
  175. package/sdk/dist/generated/executor_fee_lib.d.ts +92 -92
  176. package/sdk/dist/generated/executor_fee_lib.js +25 -25
  177. package/sdk/dist/generated/executor_helper.d.ts +3 -3
  178. package/sdk/dist/generated/executor_helper.js +4 -4
  179. package/sdk/dist/generated/layerzero_view.d.ts +186 -186
  180. package/sdk/dist/generated/layerzero_view.js +35 -35
  181. package/sdk/dist/generated/oft.d.ts +366 -352
  182. package/sdk/dist/generated/oft.js +74 -79
  183. package/sdk/dist/generated/price_feed.d.ts +198 -198
  184. package/sdk/dist/generated/price_feed.js +39 -39
  185. package/sdk/dist/generated/sml.d.ts +99 -99
  186. package/sdk/dist/generated/sml.js +16 -16
  187. package/sdk/dist/generated/treasury.d.ts +99 -99
  188. package/sdk/dist/generated/treasury.js +16 -16
  189. package/sdk/dist/generated/uln302.d.ts +99 -99
  190. package/sdk/dist/generated/uln302.js +16 -16
  191. package/sdk/dist/generated/upgrader.d.ts +3 -3
  192. package/sdk/dist/generated/upgrader.js +3 -3
  193. package/sdk/package.json +1 -1
  194. package/sdk/test/suites/localnet.ts +84 -20
  195. package/contracts/ERROR_SPEC.md +0 -51
  196. package/contracts/endpoint-v2/ARCHITECTURE.md +0 -233
  197. /package/contracts/oapps/oapp/src/tests/{test_oapp_receiver.rs → oapp_receiver.rs} +0 -0
  198. /package/contracts/oapps/oapp/src/tests/{test_oapp_sender.rs → oapp_sender.rs} +0 -0
@@ -0,0 +1,96 @@
1
+ // UI (trybuild) test: each single-trait `custom` option compiles.
2
+ //
3
+ // These are merged into one file to reduce test count while still covering:
4
+ // - `custom = [core]`
5
+ // - `custom = [sender]`
6
+ // - `custom = [receiver]`
7
+ // - `custom = [options_type3]`
8
+
9
+ use endpoint_v2::Origin;
10
+ use oapp::oapp_core::OAppCore;
11
+ use oapp::oapp_options_type3::OAppOptionsType3;
12
+ use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
13
+ use oapp::oapp_sender::OAppSenderInternal;
14
+ use oapp_macros::oapp;
15
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
16
+
17
+ #[oapp(custom = [core])]
18
+ pub struct MyOAppCustomCore;
19
+
20
+ impl LzReceiveInternal for MyOAppCustomCore {
21
+ fn __lz_receive(
22
+ _env: &Env,
23
+ _origin: &Origin,
24
+ _guid: &BytesN<32>,
25
+ _message: &Bytes,
26
+ _extra_data: &Bytes,
27
+ _executor: &Address,
28
+ _value: i128,
29
+ ) {
30
+ }
31
+ }
32
+
33
+ #[contractimpl(contracttrait)]
34
+ impl OAppCore for MyOAppCustomCore {
35
+ fn oapp_version(_env: &Env) -> (u64, u64) {
36
+ (9, 9)
37
+ }
38
+ }
39
+
40
+ #[oapp(custom = [sender])]
41
+ pub struct MyOAppCustomSender;
42
+
43
+ impl LzReceiveInternal for MyOAppCustomSender {
44
+ fn __lz_receive(
45
+ _env: &Env,
46
+ _origin: &Origin,
47
+ _guid: &BytesN<32>,
48
+ _message: &Bytes,
49
+ _extra_data: &Bytes,
50
+ _executor: &Address,
51
+ _value: i128,
52
+ ) {
53
+ }
54
+ }
55
+
56
+ impl OAppSenderInternal for MyOAppCustomSender {}
57
+
58
+ #[oapp(custom = [receiver])]
59
+ pub struct MyOAppCustomReceiver;
60
+
61
+ impl LzReceiveInternal for MyOAppCustomReceiver {
62
+ fn __lz_receive(
63
+ _env: &Env,
64
+ _origin: &Origin,
65
+ _guid: &BytesN<32>,
66
+ _message: &Bytes,
67
+ _extra_data: &Bytes,
68
+ _executor: &Address,
69
+ _value: i128,
70
+ ) {
71
+ }
72
+ }
73
+
74
+ #[contractimpl(contracttrait)]
75
+ impl OAppReceiver for MyOAppCustomReceiver {}
76
+
77
+ #[oapp(custom = [options_type3])]
78
+ pub struct MyOAppCustomOptionsType3;
79
+
80
+ impl LzReceiveInternal for MyOAppCustomOptionsType3 {
81
+ fn __lz_receive(
82
+ _env: &Env,
83
+ _origin: &Origin,
84
+ _guid: &BytesN<32>,
85
+ _message: &Bytes,
86
+ _extra_data: &Bytes,
87
+ _executor: &Address,
88
+ _value: i128,
89
+ ) {
90
+ }
91
+ }
92
+
93
+ #[contractimpl(contracttrait)]
94
+ impl OAppOptionsType3 for MyOAppCustomOptionsType3 {}
95
+
96
+ fn main() {}
@@ -0,0 +1,64 @@
1
+ // UI (trybuild) test: minimal `#[oapp]` usage compiles.
2
+ //
3
+ // Purpose:
4
+ // - Verifies `#[oapp]` applies `#[common_macros::lz_contract]` and generates default
5
+ // contract-trait implementations for `OAppCore`, `OAppReceiver`, and `OAppOptionsType3`.
6
+ // - Verifies the user must implement `LzReceiveInternal` and that the implementation is usable.
7
+
8
+ use endpoint_v2::Origin;
9
+ use oapp::oapp_receiver::LzReceiveInternal;
10
+ use oapp_macros::oapp;
11
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env};
12
+
13
+ #[oapp]
14
+ pub struct MyOApp;
15
+
16
+ impl LzReceiveInternal for MyOApp {
17
+ fn __lz_receive(
18
+ _env: &Env,
19
+ _origin: &Origin,
20
+ _guid: &BytesN<32>,
21
+ _message: &Bytes,
22
+ _extra_data: &Bytes,
23
+ _executor: &Address,
24
+ _value: i128,
25
+ ) {
26
+ // No-op.
27
+ }
28
+ }
29
+
30
+ #[contractimpl]
31
+ impl MyOApp {
32
+ pub fn init(env: Env, owner: Address, endpoint: Address) {
33
+ // `lz_contract` (applied by `#[oapp]`) provides ownable helpers.
34
+ Self::init_owner(&env, &owner);
35
+ oapp::oapp_core::OAppCoreStorage::set_endpoint(&env, &endpoint);
36
+
37
+ // Type-check: the trait impls exist.
38
+ let _ = <Self as oapp::oapp_core::OAppCore>::oapp_version(&env);
39
+ let _ = <Self as oapp::oapp_receiver::OAppReceiver>::next_nonce(
40
+ &env,
41
+ 1,
42
+ &BytesN::<32>::from_array(&env, &[0u8; 32]),
43
+ );
44
+ }
45
+ }
46
+
47
+ #[oapp(custom = [])]
48
+ pub struct MyOAppCustomEmpty;
49
+
50
+ impl LzReceiveInternal for MyOAppCustomEmpty {
51
+ fn __lz_receive(
52
+ _env: &Env,
53
+ _origin: &Origin,
54
+ _guid: &BytesN<32>,
55
+ _message: &Bytes,
56
+ _extra_data: &Bytes,
57
+ _executor: &Address,
58
+ _value: i128,
59
+ ) {
60
+ // No-op.
61
+ }
62
+ }
63
+
64
+ fn main() {}
@@ -0,0 +1,46 @@
1
+ // UI (trybuild) test: `#[oapp]` preserves struct attributes + fields.
2
+
3
+ use endpoint_v2::Origin;
4
+ use oapp::oapp_receiver::LzReceiveInternal;
5
+ use oapp_macros::oapp;
6
+ use soroban_sdk::{Address, Bytes, BytesN, Env};
7
+
8
+ #[oapp]
9
+ #[derive(Clone, Debug)]
10
+ pub struct MyOApp {
11
+ pub x: u32,
12
+ }
13
+
14
+ impl LzReceiveInternal for MyOApp {
15
+ fn __lz_receive(
16
+ _env: &Env,
17
+ _origin: &Origin,
18
+ _guid: &BytesN<32>,
19
+ _message: &Bytes,
20
+ _extra_data: &Bytes,
21
+ _executor: &Address,
22
+ _value: i128,
23
+ ) {
24
+ }
25
+ }
26
+
27
+ #[oapp]
28
+ pub struct MyOAppTuple(u32, bool);
29
+
30
+ impl LzReceiveInternal for MyOAppTuple {
31
+ fn __lz_receive(
32
+ _env: &Env,
33
+ _origin: &Origin,
34
+ _guid: &BytesN<32>,
35
+ _message: &Bytes,
36
+ _extra_data: &Bytes,
37
+ _executor: &Address,
38
+ _value: i128,
39
+ ) {
40
+ }
41
+ }
42
+
43
+ fn main() {
44
+ // Ensure tuple fields are preserved by macro expansion.
45
+ let _ = MyOAppTuple(1, true);
46
+ }
@@ -6,6 +6,14 @@ error: custom attribute panicked
6
6
  |
7
7
  = help: message: function must have an Env argument
8
8
 
9
+ warning: unused import: `Address`
10
+ --> tests/ui/ownable/fail/only_auth_missing_env.rs:7:43
11
+ |
12
+ 7 | use soroban_sdk::{contract, contractimpl, Address};
13
+ | ^^^^^^^
14
+ |
15
+ = note: `#[warn(unused_imports)]` on by default
16
+
9
17
  error[E0599]: no function or associated item named `bad` found for struct `MyContract` in the current scope
10
18
  --> tests/ui/ownable/fail/only_auth_missing_env.rs:17:12
11
19
  |
@@ -4,7 +4,7 @@
4
4
  // - Ensures a downstream crate can use the generated `Ownable` trait impl via a fully-qualified path
5
5
  // without importing `utils::ownable::Ownable` into scope.
6
6
 
7
- use soroban_sdk::{contract, contractimpl, Address, Env};
7
+ use soroban_sdk::{contract, contractimpl, Env};
8
8
 
9
9
  #[contract]
10
10
  #[common_macros::ownable]
@@ -5,7 +5,7 @@
5
5
  // even when `Env` is not the first parameter.
6
6
  // - Uses `&Env` forms to match the most common `require_auth` signature shape.
7
7
 
8
- use soroban_sdk::{contract, Address, Env};
8
+ use soroban_sdk::{contract, Env};
9
9
 
10
10
  #[contract]
11
11
  #[common_macros::ownable]
@@ -0,0 +1,11 @@
1
+ #[test]
2
+ fn ui_oapp() {
3
+ // Important: set this before trybuild::TestCases::new() so each shard has
4
+ // its own trybuild project directory + lock + artifacts.
5
+ let target_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("target/trybuild-shards/ui_oapp");
6
+ std::env::set_var("CARGO_TARGET_DIR", target_dir.as_os_str());
7
+
8
+ let t = trybuild::TestCases::new();
9
+ t.pass("tests/ui/oapp/**/pass/*.rs");
10
+ t.compile_fail("tests/ui/oapp/**/fail/*.rs");
11
+ }
@@ -12,7 +12,6 @@ doctest = false
12
12
  testutils = []
13
13
 
14
14
  [dependencies]
15
- cfg-if = "1.0"
16
15
  soroban-sdk = { workspace = true }
17
16
  # workspace dependencies
18
17
  utils = { workspace = true }
@@ -1,7 +1,7 @@
1
1
  use common_macros::contract_error;
2
2
 
3
3
  // Message Lib Common error codes: 1100-1199
4
- // See ERROR_SPEC.md for allocation rules
4
+ // See docs/error-spec.md for allocation rules
5
5
 
6
6
  /// PacketCodecV1Error: 1100-1109
7
7
  #[contract_error]
@@ -18,10 +18,8 @@ cfg-if = { workspace = true }
18
18
  soroban-sdk = { workspace = true }
19
19
  common-macros = { workspace = true }
20
20
  utils = { workspace = true }
21
- endpoint-v2 = { workspace = true, features = ["library"] }
22
21
  message-lib-common = { workspace = true }
23
22
 
24
23
  [dev-dependencies]
25
24
  soroban-sdk = { workspace = true, features = ["testutils"] }
26
25
  utils = { workspace = true, features = ["testutils"] }
27
- insta = { workspace = true }
@@ -455,14 +455,14 @@ fn test_withdraw_token_events_emitted() {
455
455
  setup.mint_tokens(&token, &setup.treasury.address, amount);
456
456
 
457
457
  // Count events before withdrawal
458
- let events_before = setup.env.events().all().len();
458
+ let events_before = setup.env.events().all().events().len();
459
459
 
460
460
  // Withdraw tokens and check that events are emitted
461
461
  setup.mock_owner_auth("withdraw_token", (&token, &recipient, &amount));
462
462
  setup.treasury.withdraw_token(&token, &recipient, &amount);
463
463
 
464
464
  // Verify that new events were published
465
- let events_after = setup.env.events().all().len();
465
+ let events_after = setup.env.events().all().events().len();
466
466
  assert!(events_after > events_before, "TokenWithdrawn event should be emitted");
467
467
  }
468
468
 
@@ -8,7 +8,7 @@ use crate::{
8
8
  };
9
9
  use endpoint_v2::SetConfigParam;
10
10
  use soroban_sdk::{log, testutils::Address as _, vec, xdr::ToXdr, Address, Env};
11
- use utils::testing_utils::assert_event;
11
+ use utils::testing_utils::assert_eq_event;
12
12
 
13
13
  #[test]
14
14
  fn test_effective_receive_uln_config_with_default_only() {
@@ -57,7 +57,7 @@ fn test_effective_receive_uln_config_with_custom_config() {
57
57
  endpoint.set_config(&Address::generate(&env), &oapp, &uln302.address, &params);
58
58
 
59
59
  // Assert ReceiveUlnConfigSet event was published immediately after the setter
60
- assert_event(
60
+ assert_eq_event(
61
61
  &env,
62
62
  &uln302.address,
63
63
  ReceiveUlnConfigSet { config: custom_config.clone(), receiver: oapp.clone(), src_eid: eid },
@@ -9,7 +9,7 @@ use soroban_sdk::{
9
9
  testutils::{MockAuth, MockAuthInvoke},
10
10
  vec, IntoVal,
11
11
  };
12
- use utils::testing_utils::assert_event;
12
+ use utils::testing_utils::assert_eq_event;
13
13
 
14
14
  #[test]
15
15
  fn test_set_default_receive_uln_configs() {
@@ -33,7 +33,7 @@ fn test_set_default_receive_uln_configs() {
33
33
  uln302.set_default_receive_uln_configs(&oapp_receive_uln_configs);
34
34
 
35
35
  // Assert DefaultReceiveUlnConfigSet event was published with all params
36
- assert_event(&env, &uln302.address, DefaultReceiveUlnConfigsSet { params: oapp_receive_uln_configs.clone() });
36
+ assert_eq_event(&env, &uln302.address, DefaultReceiveUlnConfigsSet { params: oapp_receive_uln_configs.clone() });
37
37
 
38
38
  let uln302_receive_client = ReceiveUln302Client::new(&env, &uln302.address);
39
39
  for config in oapp_receive_uln_configs.clone() {
@@ -2,7 +2,7 @@ use soroban_sdk::{
2
2
  testutils::{Address as _, MockAuth, MockAuthInvoke},
3
3
  Address, IntoVal,
4
4
  };
5
- use utils::testing_utils::assert_event;
5
+ use utils::testing_utils::assert_eq_event;
6
6
 
7
7
  use crate::{
8
8
  events::PayloadVerified,
@@ -165,7 +165,7 @@ fn test_verify_emits_event() {
165
165
  receive_client.verify(&dvn, &packet_header, &payload_hash, &CONFIRMATIONS);
166
166
 
167
167
  // Verify PayloadVerified event was emitted
168
- assert_event(
168
+ assert_eq_event(
169
169
  &env,
170
170
  &uln302.address,
171
171
  PayloadVerified { dvn, header: packet_header, proof_hash: payload_hash, confirmations: CONFIRMATIONS },
@@ -8,7 +8,7 @@ use crate::{
8
8
  };
9
9
  use endpoint_v2::SetConfigParam;
10
10
  use soroban_sdk::{log, testutils::Address as _, vec, xdr::ToXdr, Address, Env};
11
- use utils::testing_utils::assert_event;
11
+ use utils::testing_utils::assert_eq_event;
12
12
 
13
13
  #[test]
14
14
  fn test_effective_executor_config_with_default_only() {
@@ -57,7 +57,7 @@ fn test_effective_executor_config_with_custom_executor() {
57
57
 
58
58
  // Assert ExecutorConfigSet event was published immediately after the setter
59
59
 
60
- assert_event(
60
+ assert_eq_event(
61
61
  &setup.env,
62
62
  &setup.uln302.address,
63
63
  ExecutorConfigSet { config: custom_config.clone(), dst_eid: eid, sender: oapp.clone() },
@@ -9,7 +9,7 @@ use crate::{
9
9
  };
10
10
  use endpoint_v2::SetConfigParam;
11
11
  use soroban_sdk::{log, testutils::Address as _, vec, xdr::ToXdr, Address, Env};
12
- use utils::testing_utils::assert_event;
12
+ use utils::testing_utils::assert_eq_event;
13
13
 
14
14
  #[test]
15
15
  fn test_effective_send_uln_config_with_default_only() {
@@ -65,7 +65,7 @@ fn test_effective_send_uln_config_with_custom_config() {
65
65
  endpoint.set_config(&Address::generate(&env), &oapp, &uln302.address, &params);
66
66
 
67
67
  // Assert SendUlnConfigSet event was published immediately after the setter
68
- assert_event(
68
+ assert_eq_event(
69
69
  &env,
70
70
  &uln302.address,
71
71
  SendUlnConfigSet { config: custom_config.clone(), dst_eid: eid, sender: oapp.clone() },
@@ -14,7 +14,7 @@ use soroban_sdk::{
14
14
  vec, Bytes, BytesN, IntoVal,
15
15
  };
16
16
  use soroban_sdk::{Address, Env, Vec};
17
- use utils::testing_utils::{assert_events, IntoExpectedEvent};
17
+ use utils::testing_utils::assert_eq_events;
18
18
 
19
19
  // Note that all the hot paths and assertions are covered in the quote test so here we only test the events emittance
20
20
  #[test]
@@ -72,22 +72,12 @@ fn test_send_events_emittance() {
72
72
  let send_result = setup.uln302.send(&packet, &options, &pay_in_zro);
73
73
  let native_fee_recipients = &send_result.native_fee_recipients;
74
74
  let zro_fee_recipients = &send_result.zro_fee_recipients;
75
- assert_events(
75
+ assert_eq_events(
76
76
  &setup.env,
77
77
  &setup.uln302.address,
78
78
  &[
79
- ExecutorFeePaid {
80
- executor: executor.clone(),
81
- guid: packet.guid.clone(),
82
- fee: native_fee_recipients.get(0).unwrap().clone(),
83
- }
84
- .expected(&setup.env),
85
- DVNFeePaid {
86
- guid: packet.guid.clone(),
87
- dvns: dvns.slice(0..2).clone(),
88
- fees: native_fee_recipients.slice(1..3).clone(),
89
- }
90
- .expected(&setup.env),
79
+ &ExecutorFeePaid { guid: packet.guid.clone(),executor: executor.clone(), fee: native_fee_recipients.get(0).unwrap().clone() },
80
+ &DVNFeePaid { guid: packet.guid.clone(),dvns: dvns.slice(0..2).clone(), fees: native_fee_recipients.slice(1..3).clone() },
91
81
  ],
92
82
  );
93
83
 
@@ -170,22 +160,12 @@ fn test_send_events_emittance_with_zro() {
170
160
  let native_fee_recipients = &send_result.native_fee_recipients;
171
161
  let zro_fee_recipients = &send_result.zro_fee_recipients;
172
162
 
173
- assert_events(
163
+ assert_eq_events(
174
164
  &setup.env,
175
165
  &setup.uln302.address,
176
166
  &[
177
- ExecutorFeePaid {
178
- executor: executor.clone(),
179
- guid: packet.guid.clone(),
180
- fee: native_fee_recipients.get(0).unwrap().clone(),
181
- }
182
- .expected(&setup.env),
183
- DVNFeePaid {
184
- guid: packet.guid.clone(),
185
- dvns: dvns.slice(0..2).clone(),
186
- fees: native_fee_recipients.slice(1..3).clone(),
187
- }
188
- .expected(&setup.env),
167
+ &ExecutorFeePaid { guid: packet.guid.clone(), executor: executor.clone(), fee: native_fee_recipients.get(0).unwrap().clone() },
168
+ &DVNFeePaid { guid: packet.guid.clone(), dvns: dvns.slice(0..2).clone(), fees: native_fee_recipients.slice(1..3).clone() },
189
169
  ],
190
170
  );
191
171
 
@@ -3,7 +3,7 @@ use soroban_sdk::{
3
3
  testutils::{Address as _, MockAuth, MockAuthInvoke},
4
4
  vec, Address, IntoVal,
5
5
  };
6
- use utils::testing_utils::assert_event;
6
+ use utils::testing_utils::assert_eq_event;
7
7
 
8
8
  use crate::{
9
9
  errors::Uln302Error,
@@ -44,7 +44,7 @@ fn test_set_default_executor_configs() {
44
44
  uln302.set_default_executor_configs(&executor_configs);
45
45
 
46
46
  // Assert DefaultExecutorConfigSet event was published with all params
47
- assert_event(&env, &uln302.address, DefaultExecutorConfigsSet { params: executor_configs.clone() });
47
+ assert_eq_event(&env, &uln302.address, DefaultExecutorConfigsSet { params: executor_configs.clone() });
48
48
 
49
49
  let uln302_send_client = SendUln302Client::new(&env, &uln302.address);
50
50
  for config_param in executor_configs.clone() {
@@ -3,7 +3,7 @@ use soroban_sdk::{
3
3
  testutils::{MockAuth, MockAuthInvoke},
4
4
  vec, IntoVal,
5
5
  };
6
- use utils::testing_utils::assert_event;
6
+ use utils::testing_utils::assert_eq_event;
7
7
 
8
8
  use crate::{
9
9
  errors::Uln302Error,
@@ -34,7 +34,7 @@ fn test_set_default_send_uln_configs() {
34
34
  uln302.set_default_send_uln_configs(&oapp_send_uln_configs);
35
35
 
36
36
  // Assert DefaultSendUlnConfigSet event was published with all params
37
- assert_event(&env, &uln302.address, DefaultSendUlnConfigsSet { params: oapp_send_uln_configs.clone() });
37
+ assert_eq_event(&env, &uln302.address, DefaultSendUlnConfigsSet { params: oapp_send_uln_configs.clone() });
38
38
 
39
39
  let uln302_send_client = SendUln302Client::new(&env, &uln302.address);
40
40
  for config in oapp_send_uln_configs.clone() {
@@ -18,7 +18,6 @@ oapp-macros = { workspace = true }
18
18
 
19
19
  [dev-dependencies]
20
20
  soroban-sdk = { workspace = true, features = ["testutils"] }
21
- assert_unordered = "0.3.5"
22
21
  simple-message-lib = { workspace = true }
23
22
  message-lib-common = { workspace = true, features = ["testutils"] }
24
23
  endpoint-v2 = { workspace = true, features = ["testutils"] }
@@ -27,13 +26,12 @@ uln302 = { workspace = true, features = ["testutils"] }
27
26
  dvn = { workspace = true, features = ["testutils"] }
28
27
  dvn-fee-lib = { workspace = true }
29
28
  executor-fee-lib = { workspace = true }
30
- worker = { workspace = true }
31
29
  treasury = { workspace = true, features = ["testutils"] }
32
30
  price-feed = { workspace = true }
33
31
  fee-lib-interfaces = { workspace = true }
34
32
  executor-helper = { workspace = true }
35
33
  # For real DVN signature verification in integration tests
36
- k256 = "0.13"
37
- sha3 = "0.10"
38
- rand = "0.8"
39
- ed25519-dalek = "2"
34
+ k256 = { workspace = true }
35
+ sha3 = { workspace = true }
36
+ rand = { workspace = true }
37
+ ed25519-dalek = { workspace = true }
@@ -11,6 +11,7 @@ use soroban_sdk::{
11
11
  Address, Bytes, BytesN, Env, IntoVal, Map, Symbol, Val, Vec,
12
12
  };
13
13
  use utils::buffer_reader::BufferReader;
14
+ use utils::testing_utils::decode_event_topics_data;
14
15
 
15
16
  /// Trait for common fields in chain setup structs.
16
17
  /// Both SML and ULN302 ChainSetup implement this trait.
@@ -215,13 +216,15 @@ pub fn validate_packet<'a, C: ChainSetupCommon<'a>>(
215
216
 
216
217
  /// Scans for the latest packet_sent event and returns (encoded_payload, options, send_library).
217
218
  pub fn scan_packet_sent_event(env: &Env, endpoint: &Address) -> Option<(Bytes, Bytes, Address)> {
218
- let events = env.events().all();
219
+ let events = env.events().all().filter_by_contract(endpoint);
219
220
  let packet_sent_symbol = Symbol::new(env, "packet_sent").to_val();
220
221
 
221
222
  // Iterate in reverse to find the most recent packet sent event
222
- for i in (0..events.len()).rev() {
223
- let (emitter, topics, data) = events.get(i).unwrap();
224
- if emitter == *endpoint && topics.contains(packet_sent_symbol) {
223
+ for event in events.events().iter().rev() {
224
+ let Some((topics, data)) = decode_event_topics_data(env, event) else {
225
+ continue;
226
+ };
227
+ if topics.contains(packet_sent_symbol) {
225
228
  let map: Map<Symbol, Val> = data.into_val(env);
226
229
 
227
230
  let encoded_payload: Bytes = map.get(Symbol::new(env, "encoded_packet")).unwrap().into_val(env);
@@ -240,13 +243,15 @@ pub fn scan_packet_sent_event(env: &Env, endpoint: &Address) -> Option<(Bytes, B
240
243
  /// Use this only after all messages have been sent in a single "transaction" or collect events incrementally.
241
244
  #[allow(dead_code)]
242
245
  pub fn scan_all_packet_sent_events(env: &Env, endpoint: &Address) -> Vec<(Bytes, Bytes, Address)> {
243
- let events = env.events().all();
246
+ let events = env.events().all().filter_by_contract(endpoint);
244
247
  let packet_sent_symbol = Symbol::new(env, "packet_sent").to_val();
245
248
  let mut result = Vec::new(env);
246
249
 
247
- for i in 0..events.len() {
248
- let (emitter, topics, data) = events.get(i).unwrap();
249
- if emitter == *endpoint && topics.contains(packet_sent_symbol) {
250
+ for event in events.events().iter() {
251
+ let Some((topics, data)) = decode_event_topics_data(env, event) else {
252
+ continue;
253
+ };
254
+ if topics.contains(packet_sent_symbol) {
250
255
  let map: Map<Symbol, Val> = data.into_val(env);
251
256
 
252
257
  let encoded_payload: Bytes = map.get(Symbol::new(env, "encoded_packet")).unwrap().into_val(env);
@@ -265,13 +270,15 @@ pub type ComposeSentEvent = (Address, Address, BytesN<32>, u32, Bytes);
265
270
 
266
271
  /// Scans for the latest compose_sent event and returns (from, to, guid, index, message).
267
272
  pub fn scan_compose_sent_event(env: &Env, endpoint: &Address) -> Option<ComposeSentEvent> {
268
- let events = env.events().all();
273
+ let events = env.events().all().filter_by_contract(endpoint);
269
274
  let compose_sent_symbol = Symbol::new(env, "compose_sent").to_val();
270
275
 
271
276
  // Iterate in reverse to find the most recent compose sent event
272
- for i in (0..events.len()).rev() {
273
- let (emitter, topics, data) = events.get(i).unwrap();
274
- if emitter == *endpoint && topics.contains(compose_sent_symbol) {
277
+ for event in events.events().iter().rev() {
278
+ let Some((topics, data)) = decode_event_topics_data(env, event) else {
279
+ continue;
280
+ };
281
+ if topics.contains(compose_sent_symbol) {
275
282
  let map: Map<Symbol, Val> = data.into_val(env);
276
283
  let from: Address = topics.get(1).unwrap().into_val(env);
277
284
  let to: Address = topics.get(2).unwrap().into_val(env);
@@ -1,7 +1,7 @@
1
1
  use common_macros::contract_error;
2
2
 
3
3
  // OApp library error codes: 2000-2099
4
- // See ERROR_SPEC.md for allocation rules
4
+ // See docs/error-spec.md for allocation rules
5
5
 
6
6
  /// OAppError: 2000-2099
7
7
  #[contract_error]
@@ -0,0 +1,3 @@
1
+ mod oapp_msg_inspector;
2
+
3
+ pub use oapp_msg_inspector::*;
@@ -0,0 +1,47 @@
1
+ //! OApp Message Inspector interface.
2
+ //!
3
+ //! This module defines the `IOAppMsgInspector` trait that external inspector contracts
4
+ //! must implement to validate outgoing LayerZero messages and options.
5
+ //!
6
+ //! ## Usage
7
+ //!
8
+ //! Inspector contracts should implement this trait and panic if inspection fails:
9
+ //!
10
+ //! ```ignore
11
+ //! use oapp::interfaces::IOAppMsgInspector;
12
+ //!
13
+ //! pub struct MyInspector;
14
+ //!
15
+ //! #[contractimpl]
16
+ //! impl IOAppMsgInspector for MyInspector {
17
+ //! fn inspect(env: &Env, oapp: &Address, message: &Bytes, options: &Bytes) {
18
+ //! // Validate message and options
19
+ //! // Panic if invalid
20
+ //! if !is_valid(message, options) {
21
+ //! panic_with_error!(env, MyError::InspectionFailed);
22
+ //! }
23
+ //! }
24
+ //! }
25
+ //! ```
26
+
27
+ use soroban_sdk::{contractclient, Address, Bytes, Env};
28
+
29
+ /// Interface for OApp message inspectors.
30
+ ///
31
+ /// Contracts implementing this trait can be set as message inspectors on OFT contracts
32
+ /// to validate outgoing messages and options before they are sent cross-chain.
33
+ ///
34
+ /// If inspection fails, the implementation should panic to revert the transaction.
35
+ #[contractclient(name = "OAppMsgInspectorClient")]
36
+ pub trait IOAppMsgInspector {
37
+ /// Inspects the LayerZero message and options before sending.
38
+ ///
39
+ /// # Arguments
40
+ /// * `oapp` - The address of the OApp contract sending the message
41
+ /// * `message` - The encoded message payload to be sent
42
+ /// * `options` - The LayerZero options for the message
43
+ ///
44
+ /// # Panics
45
+ /// Should panic if the message or options are invalid, reverting the transaction.
46
+ fn inspect(env: &Env, oapp: &Address, message: &Bytes, options: &Bytes);
47
+ }
@@ -1,6 +1,7 @@
1
1
  #![no_std]
2
2
 
3
3
  pub mod errors;
4
+ pub mod interfaces;
4
5
  pub mod oapp_core;
5
6
  pub mod oapp_options_type3;
6
7
  pub mod oapp_receiver;