@layerzerolabs/protocol-stellar-v2 0.2.8 → 0.2.10

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 (239) hide show
  1. package/.turbo/turbo-build.log +443 -302
  2. package/.turbo/turbo-lint.log +118 -96
  3. package/.turbo/turbo-test.log +853 -731
  4. package/Cargo.lock +120 -37
  5. package/Cargo.toml +8 -5
  6. package/contracts/common-macros/src/contract_impl.rs +44 -0
  7. package/contracts/common-macros/src/lib.rs +86 -40
  8. package/contracts/common-macros/src/ownable.rs +24 -32
  9. package/contracts/common-macros/src/storage.rs +95 -120
  10. package/contracts/common-macros/src/tests/contract_impl.rs +289 -0
  11. package/contracts/common-macros/src/tests/mod.rs +9 -0
  12. package/contracts/common-macros/src/tests/ownable.rs +151 -0
  13. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap +85 -0
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +30 -0
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap +9 -0
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +1072 -0
  17. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +45 -0
  18. package/contracts/common-macros/src/tests/storage.rs +485 -0
  19. package/contracts/common-macros/src/tests/test_helpers.rs +93 -0
  20. package/contracts/common-macros/src/tests/ttl_configurable.rs +34 -0
  21. package/contracts/common-macros/src/ttl_configurable.rs +31 -14
  22. package/contracts/common-macros/src/utils.rs +27 -0
  23. package/contracts/endpoint-v2/ARCHITECTURE.md +4 -4
  24. package/contracts/endpoint-v2/src/endpoint_v2.rs +18 -15
  25. package/contracts/endpoint-v2/src/interfaces/message_lib.rs +2 -3
  26. package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +5 -3
  27. package/contracts/endpoint-v2/src/interfaces/messaging_channel.rs +2 -2
  28. package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
  29. package/contracts/endpoint-v2/src/interfaces/send_lib.rs +4 -4
  30. package/contracts/endpoint-v2/src/lib.rs +6 -5
  31. package/contracts/endpoint-v2/src/message_lib_manager.rs +14 -6
  32. package/contracts/endpoint-v2/src/messaging_channel.rs +6 -2
  33. package/contracts/endpoint-v2/src/messaging_composer.rs +6 -2
  34. package/contracts/endpoint-v2/src/storage.rs +10 -7
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +16 -16
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +46 -46
  37. package/contracts/endpoint-v2/src/tests/mock.rs +2 -2
  38. package/contracts/endpoint-v2/src/util.rs +8 -2
  39. package/contracts/message-libs/block-message-lib/Cargo.toml +1 -0
  40. package/contracts/message-libs/block-message-lib/src/lib.rs +5 -5
  41. package/contracts/message-libs/message-lib-common/src/errors.rs +8 -8
  42. package/contracts/message-libs/message-lib-common/src/interfaces/dvn.rs +0 -1
  43. package/contracts/message-libs/message-lib-common/src/interfaces/mod.rs +3 -3
  44. package/contracts/message-libs/message-lib-common/src/lib.rs +0 -2
  45. package/contracts/message-libs/message-lib-common/src/packet_codec_v1.rs +4 -6
  46. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +2 -2
  47. package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +11 -11
  48. package/contracts/message-libs/message-lib-common/src/worker_options.rs +10 -16
  49. package/contracts/message-libs/simple-message-lib/src/errors.rs +0 -4
  50. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +49 -34
  51. package/contracts/message-libs/simple-message-lib/src/storage.rs +3 -7
  52. package/contracts/message-libs/simple-message-lib/src/test.rs +3 -3
  53. package/contracts/message-libs/treasury/src/storage.rs +1 -2
  54. package/contracts/message-libs/treasury/src/tests/setup.rs +3 -2
  55. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +0 -13
  56. package/contracts/message-libs/treasury/src/treasury.rs +18 -21
  57. package/contracts/message-libs/uln-302/Cargo.toml +1 -0
  58. package/contracts/message-libs/uln-302/src/interfaces/mod.rs +4 -4
  59. package/contracts/message-libs/uln-302/src/interfaces/{receive.rs → receive_uln.rs} +3 -3
  60. package/contracts/message-libs/uln-302/src/interfaces/{send.rs → send_uln.rs} +8 -80
  61. package/contracts/message-libs/uln-302/src/lib.rs +5 -4
  62. package/contracts/message-libs/uln-302/src/{receive.rs → receive_uln.rs} +20 -12
  63. package/contracts/message-libs/uln-302/src/{send.rs → send_uln.rs} +19 -13
  64. package/contracts/message-libs/uln-302/src/storage.rs +1 -2
  65. package/contracts/message-libs/uln-302/src/tests/config/uln_config.rs +3 -2
  66. package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +30 -30
  67. package/contracts/message-libs/uln-302/src/tests/setup.rs +12 -11
  68. package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +1 -1
  69. package/contracts/message-libs/uln-302/src/{config_validation.rs → types.rs} +79 -11
  70. package/contracts/message-libs/uln-302/src/uln302.rs +15 -10
  71. package/contracts/oapp-macros/Cargo.toml +2 -8
  72. package/contracts/oapp-macros/src/lib.rs +57 -311
  73. package/contracts/oapp-macros/src/oapp_core.rs +23 -32
  74. package/contracts/oapp-macros/src/oapp_full.rs +8 -2
  75. package/contracts/oapp-macros/src/oapp_options_type3.rs +21 -36
  76. package/contracts/oapp-macros/src/oapp_receiver.rs +38 -57
  77. package/contracts/oapp-macros/src/oapp_sender.rs +12 -14
  78. package/contracts/oapp-macros/src/util.rs +14 -10
  79. package/contracts/oapps/counter/Cargo.toml +2 -1
  80. package/contracts/oapps/counter/integration_tests/utils.rs +4 -4
  81. package/contracts/oapps/counter/src/codec.rs +8 -9
  82. package/contracts/oapps/counter/src/counter.rs +156 -147
  83. package/contracts/oapps/counter/src/storage.rs +1 -2
  84. package/contracts/oapps/counter/src/tests/test_codec.rs +5 -5
  85. package/contracts/oapps/counter/src/tests/test_counter.rs +11 -13
  86. package/contracts/oapps/oapp/Cargo.toml +1 -0
  87. package/contracts/oapps/oapp/src/errors.rs +1 -1
  88. package/contracts/oapps/oapp/src/lib.rs +3 -0
  89. package/contracts/oapps/oapp/src/macro_tests/mod.rs +1 -0
  90. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +312 -0
  91. package/contracts/oapps/oapp/src/oapp_core.rs +52 -53
  92. package/contracts/oapps/oapp/src/oapp_options_type3.rs +18 -28
  93. package/contracts/oapps/oapp/src/oapp_receiver.rs +82 -31
  94. package/contracts/oapps/oapp/src/oapp_sender.rs +55 -13
  95. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +16 -3
  96. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +33 -8
  97. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +6 -9
  98. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +28 -15
  99. package/contracts/oapps/oft/Cargo.toml +27 -0
  100. package/contracts/oapps/oft/integration-tests/mod.rs +3 -0
  101. package/contracts/oapps/oft/integration-tests/setup.rs +320 -0
  102. package/contracts/oapps/oft/integration-tests/test_with_sml.rs +155 -0
  103. package/contracts/oapps/oft/integration-tests/utils.rs +201 -0
  104. package/contracts/oapps/oft/src/codec/mod.rs +2 -0
  105. package/contracts/oapps/oft/src/codec/oft_compose_msg_codec.rs +55 -0
  106. package/contracts/oapps/oft/src/codec/oft_msg_codec.rs +62 -0
  107. package/contracts/oapps/oft/src/constants.rs +5 -0
  108. package/contracts/oapps/oft/src/errors.rs +8 -0
  109. package/contracts/oapps/oft/src/events.rs +19 -0
  110. package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +23 -0
  111. package/contracts/oapps/oft/src/interfaces/mod.rs +3 -0
  112. package/contracts/oapps/oft/src/lib.rs +22 -0
  113. package/contracts/oapps/oft/src/macro_tests/mod.rs +2 -0
  114. package/contracts/oapps/oft/src/macro_tests/test_all_default.rs +41 -0
  115. package/contracts/oapps/oft/src/macro_tests/test_override.rs +83 -0
  116. package/contracts/oapps/oft/src/oft.rs +320 -0
  117. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +50 -0
  118. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +50 -0
  119. package/contracts/oapps/oft/src/oft_types/mod.rs +10 -0
  120. package/contracts/oapps/oft/src/storage.rs +11 -0
  121. package/contracts/oapps/oft/src/tests/mod.rs +13 -0
  122. package/contracts/oapps/oft/src/tests/test_decimals.rs +89 -0
  123. package/contracts/oapps/oft/src/tests/test_lz_receive.rs +282 -0
  124. package/contracts/oapps/oft/src/tests/test_oft_compose_msg_codec.rs +68 -0
  125. package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +136 -0
  126. package/contracts/oapps/oft/src/tests/test_oft_version.rs +13 -0
  127. package/contracts/oapps/oft/src/tests/test_quote_oft.rs +159 -0
  128. package/contracts/oapps/oft/src/tests/test_quote_send.rs +195 -0
  129. package/contracts/oapps/oft/src/tests/test_resolve_address.rs +37 -0
  130. package/contracts/oapps/oft/src/tests/test_send.rs +915 -0
  131. package/contracts/oapps/oft/src/tests/test_token.rs +47 -0
  132. package/contracts/oapps/oft/src/tests/test_utils.rs +789 -0
  133. package/contracts/oapps/oft/src/types.rs +38 -0
  134. package/contracts/oapps/oft/src/utils.rs +67 -0
  135. package/contracts/oapps/oft-mint-burn/Cargo.toml +26 -0
  136. package/contracts/oapps/oft-mint-burn/src/lib.rs +3 -0
  137. package/contracts/oapps/oft-mint-burn/src/oft.rs +28 -0
  138. package/contracts/oapps/oft-mint-burn/src/tests/mod.rs +1 -0
  139. package/contracts/utils/src/buffer_reader.rs +8 -9
  140. package/contracts/utils/src/buffer_writer.rs +11 -5
  141. package/contracts/utils/src/errors.rs +5 -5
  142. package/contracts/utils/src/ownable.rs +14 -6
  143. package/contracts/utils/src/testing_utils.rs +11 -1
  144. package/contracts/utils/src/tests/buffer_reader.rs +491 -730
  145. package/contracts/utils/src/tests/buffer_writer.rs +336 -148
  146. package/contracts/utils/src/tests/bytes_ext.rs +125 -40
  147. package/contracts/utils/src/tests/mod.rs +3 -0
  148. package/contracts/utils/src/tests/ownable.rs +379 -27
  149. package/contracts/utils/src/tests/test_helper.rs +47 -0
  150. package/contracts/utils/src/tests/testing_utils.rs +555 -0
  151. package/contracts/utils/src/tests/ttl.rs +421 -0
  152. package/contracts/utils/src/ttl.rs +29 -89
  153. package/contracts/workers/dvn/Cargo.toml +31 -0
  154. package/contracts/workers/dvn/src/auth.rs +66 -0
  155. package/contracts/workers/dvn/src/dvn.rs +143 -0
  156. package/contracts/workers/dvn/src/errors.rs +21 -0
  157. package/contracts/workers/dvn/src/events.rs +19 -0
  158. package/contracts/workers/dvn/src/interfaces/dvn.rs +12 -0
  159. package/contracts/workers/dvn/src/interfaces/mod.rs +5 -0
  160. package/contracts/workers/dvn/src/interfaces/multisig.rs +15 -0
  161. package/contracts/workers/dvn/src/lib.rs +24 -0
  162. package/contracts/workers/dvn/src/multisig.rs +127 -0
  163. package/contracts/workers/dvn/src/storage.rs +35 -0
  164. package/contracts/workers/dvn/src/tests/auth.rs +237 -0
  165. package/contracts/workers/dvn/src/tests/dvn.rs +349 -0
  166. package/contracts/workers/dvn/src/tests/key_pair.rs +66 -0
  167. package/contracts/workers/dvn/src/tests/mod.rs +5 -0
  168. package/contracts/workers/dvn/src/tests/multisig/mod.rs +3 -0
  169. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +133 -0
  170. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +108 -0
  171. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +109 -0
  172. package/contracts/workers/dvn/src/tests/setup.rs +109 -0
  173. package/contracts/workers/dvn/src/types.rs +26 -0
  174. package/contracts/workers/dvn-fee-lib/Cargo.toml +24 -0
  175. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +113 -0
  176. package/contracts/workers/dvn-fee-lib/src/errors.rs +8 -0
  177. package/contracts/workers/dvn-fee-lib/src/lib.rs +17 -0
  178. package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +282 -0
  179. package/contracts/workers/dvn-fee-lib/src/tests/mod.rs +1 -0
  180. package/contracts/workers/executor/Cargo.toml +10 -7
  181. package/contracts/workers/executor/src/errors.rs +8 -0
  182. package/contracts/workers/executor/src/events.rs +4 -7
  183. package/contracts/workers/executor/src/interfaces/executor.rs +72 -22
  184. package/contracts/workers/executor/src/interfaces/mod.rs +0 -2
  185. package/contracts/workers/executor/src/lib.rs +16 -7
  186. package/contracts/workers/executor/src/lz_executor.rs +308 -0
  187. package/contracts/workers/executor/src/storage.rs +24 -16
  188. package/contracts/workers/executor-fee-lib/Cargo.toml +22 -0
  189. package/contracts/workers/executor-fee-lib/src/errors.rs +15 -0
  190. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +215 -0
  191. package/contracts/workers/executor-fee-lib/src/executor_option.rs +203 -0
  192. package/contracts/workers/executor-fee-lib/src/lib.rs +7 -0
  193. package/contracts/workers/executor-helper/Cargo.toml +29 -0
  194. package/contracts/workers/executor-helper/src/executor_helper.rs +161 -0
  195. package/contracts/workers/executor-helper/src/lib.rs +11 -0
  196. package/contracts/workers/{worker-common → worker}/Cargo.toml +1 -4
  197. package/contracts/workers/worker/src/errors.rs +24 -0
  198. package/contracts/workers/worker/src/events.rs +62 -0
  199. package/contracts/workers/worker/src/interfaces/dvn_fee_lib.rs +75 -0
  200. package/contracts/workers/worker/src/interfaces/executor_fee_lib.rs +84 -0
  201. package/contracts/workers/{worker-common → worker}/src/interfaces/mod.rs +2 -2
  202. package/contracts/workers/worker/src/interfaces/price_feed.rs +85 -0
  203. package/contracts/workers/worker/src/lib.rs +14 -0
  204. package/contracts/workers/worker/src/storage.rs +63 -0
  205. package/contracts/workers/worker/src/worker.rs +459 -0
  206. package/package.json +3 -3
  207. package/sdk/dist/generated/bml.d.ts +88 -17
  208. package/sdk/dist/generated/bml.js +62 -16
  209. package/sdk/dist/generated/counter.d.ts +281 -102
  210. package/sdk/dist/generated/counter.js +93 -41
  211. package/sdk/dist/generated/endpoint.d.ts +128 -105
  212. package/sdk/dist/generated/endpoint.js +47 -45
  213. package/sdk/dist/generated/sml.d.ts +212 -69
  214. package/sdk/dist/generated/sml.js +103 -53
  215. package/sdk/dist/generated/uln302.d.ts +270 -173
  216. package/sdk/dist/generated/uln302.js +112 -64
  217. package/sdk/package.json +11 -11
  218. package/sdk/test/index.test.ts +147 -42
  219. package/sdk/test/suites/constants.ts +7 -3
  220. package/sdk/test/suites/deploy.ts +65 -42
  221. package/sdk/test/suites/localnet.ts +2 -2
  222. package/sdk/test/suites/scan.ts +28 -25
  223. package/sdk/test/utils.ts +199 -0
  224. package/sdk/tsconfig.json +93 -95
  225. package/tools/ts-bindings-gen/src/main.rs +2 -0
  226. package/contracts/common-macros/src/snapshots/common_macros__tests__tests__snapshot_generated_storage_code.snap +0 -310
  227. package/contracts/common-macros/src/tests.rs +0 -287
  228. package/contracts/oapp-macros/tests/test_macros.rs +0 -522
  229. package/contracts/workers/executor/src/executor.rs +0 -347
  230. package/contracts/workers/executor/src/interfaces/types.rs +0 -51
  231. package/contracts/workers/worker-common/src/constants.rs +0 -17
  232. package/contracts/workers/worker-common/src/errors.rs +0 -6
  233. package/contracts/workers/worker-common/src/events.rs +0 -34
  234. package/contracts/workers/worker-common/src/interfaces/executor_fee_lib.rs +0 -35
  235. package/contracts/workers/worker-common/src/interfaces/price_feed.rs +0 -40
  236. package/contracts/workers/worker-common/src/interfaces/worker.rs +0 -60
  237. package/contracts/workers/worker-common/src/lib.rs +0 -19
  238. package/contracts/workers/worker-common/src/storage.rs +0 -32
  239. package/contracts/workers/worker-common/src/worker_common.rs +0 -166
@@ -1,8 +1,7 @@
1
1
  use common_macros::storage;
2
2
  use soroban_sdk::BytesN;
3
- use utils::ttl::DefaultTtlConfigProvider;
4
3
 
5
- #[storage(DefaultTtlConfigProvider)]
4
+ #[storage]
6
5
  pub enum CounterStorage {
7
6
  #[instance(u32)]
8
7
  EID,
@@ -1,5 +1,5 @@
1
1
  use crate::codec::*;
2
- use soroban_sdk::{Bytes, Env, U256};
2
+ use soroban_sdk::{Bytes, Env};
3
3
 
4
4
  #[test]
5
5
  fn test_encode_and_decode() {
@@ -16,11 +16,11 @@ fn test_encode_and_decode_with_value() {
16
16
  let env = Env::default();
17
17
  let _msg_type = 1;
18
18
  let _src_eid = 1;
19
- let _value = U256::from_u32(&env, 100);
20
- let data = encode_with_value(&env, _msg_type.into(), _src_eid, _value.clone());
19
+ let _value = 100u32;
20
+ let data = encode_with_value(&env, _msg_type.into(), _src_eid, _value);
21
21
  assert_eq!(msg_type(&data), MsgType::from(_msg_type));
22
22
  assert_eq!(src_eid(&data), _src_eid);
23
- assert_eq!(_value.eq(&value(&env, &data)), true);
23
+ assert_eq!(value(&env, &data), _value as i128);
24
24
  }
25
25
 
26
26
  #[test]
@@ -35,7 +35,7 @@ fn test_msg_type() {
35
35
  fn test_zero_value_when_not_provided() {
36
36
  let env = Env::default();
37
37
  let data = encode(&env, 1.into(), 1);
38
- assert_eq!(value(&env, &data), U256::from_u32(&env, 0));
38
+ assert_eq!(value(&env, &data), 0i128);
39
39
  }
40
40
 
41
41
  #[test]
@@ -4,7 +4,7 @@ use endpoint_v2::{MessagingFee, MessagingParams, MessagingReceipt, Origin};
4
4
  use soroban_sdk::{
5
5
  contract, contractimpl, log, symbol_short,
6
6
  testutils::{Address as _, MockAuth, MockAuthInvoke},
7
- Address, Bytes, BytesN, Env, IntoVal, U256,
7
+ Address, Bytes, BytesN, Env, IntoVal,
8
8
  };
9
9
 
10
10
  use crate::{
@@ -156,19 +156,18 @@ fn test_lz_receive_vanilla() {
156
156
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 1 };
157
157
  let guid = BytesN::from_array(&env, &[2u8; 32]);
158
158
  let value = 100;
159
- let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, U256::from_u32(&env, value));
159
+ let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, value);
160
160
  let executor = Address::generate(&env);
161
161
  let extra_data = Bytes::new(&env);
162
162
 
163
163
  setup_mock_peer(&env, &owner, &counter, origin.src_eid);
164
164
 
165
165
  mint_to(&env, &owner, &native_token, &executor, value as i128);
166
- approve(&env, &executor, &native_token, value as i128);
167
166
 
168
167
  let sub_invokes_with_transfer = MockAuthInvoke {
169
168
  contract: &native_token,
170
- fn_name: "transfer_from",
171
- args: (&executor, &executor, &counter.address, &(value as i128)).into_val(&env),
169
+ fn_name: "transfer",
170
+ args: (&executor, &counter.address, &(value as i128)).into_val(&env),
172
171
  sub_invokes: &[],
173
172
  };
174
173
  env.mock_auths(&[MockAuth {
@@ -195,7 +194,7 @@ fn test_lz_receive_not_from_executor() {
195
194
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 1 };
196
195
  let guid = BytesN::from_array(&env, &[2u8; 32]);
197
196
  let value = 100;
198
- let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, U256::from_u32(&env, value));
197
+ let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, value);
199
198
  let executor = Address::generate(&env);
200
199
  let extra_data = Bytes::new(&env);
201
200
 
@@ -211,18 +210,17 @@ fn test_lz_receive_vanilla_ordered_nonce_wrong_nonce() {
211
210
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 999 };
212
211
  let guid = BytesN::from_array(&env, &[2u8; 32]);
213
212
  let value = 100;
214
- let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, U256::from_u32(&env, value));
213
+ let message = codec::encode_with_value(&env, MsgType::Vanilla, origin.src_eid, value);
215
214
  let executor = Address::generate(&env);
216
215
  let extra_data = Bytes::new(&env);
217
216
 
218
217
  setup_mock_peer(&env, &owner, &counter, origin.src_eid);
219
218
  mint_to(&env, &owner, &native_token, &executor, value as i128);
220
- approve(&env, &executor, &native_token, value as i128);
221
219
 
222
220
  let sub_invokes_with_transfer = MockAuthInvoke {
223
221
  contract: &native_token,
224
- fn_name: "transfer_from",
225
- args: (&executor, &executor, &counter.address, &(value as i128)).into_val(&env),
222
+ fn_name: "transfer",
223
+ args: (&executor, &counter.address, &(value as i128)).into_val(&env),
226
224
  sub_invokes: &[],
227
225
  };
228
226
  set_ordered_nonce(&env, &owner, &counter, true);
@@ -249,7 +247,7 @@ fn test_lz_compose() {
249
247
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 1 };
250
248
  let guid = BytesN::from_array(&env, &[2u8; 32]);
251
249
  let value = 100;
252
- let message = codec::encode_with_value(&env, MsgType::Composed, origin.src_eid, U256::from_u32(&env, value));
250
+ let message = codec::encode_with_value(&env, MsgType::Composed, origin.src_eid, value);
253
251
  let executor = Address::generate(&env);
254
252
  let extra_data = Bytes::new(&env);
255
253
 
@@ -285,7 +283,7 @@ fn test_lz_compose_not_from_executor() {
285
283
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 1 };
286
284
  let guid = BytesN::from_array(&env, &[2u8; 32]);
287
285
  let value = 100;
288
- let message = codec::encode_with_value(&env, MsgType::Composed, origin.src_eid, U256::from_u32(&env, value));
286
+ let message = codec::encode_with_value(&env, MsgType::Composed, origin.src_eid, value);
289
287
  let executor = Address::generate(&env);
290
288
  let extra_data = Bytes::new(&env);
291
289
 
@@ -300,7 +298,7 @@ fn test_lz_compose_aba() {
300
298
  let origin = Origin { src_eid: 101, sender: BytesN::from_array(&env, &[1u8; 32]), nonce: 1 };
301
299
  let guid = BytesN::from_array(&env, &[2u8; 32]);
302
300
  let value = 100;
303
- let message = codec::encode_with_value(&env, MsgType::ComposedABA, origin.src_eid, U256::from_u32(&env, value));
301
+ let message = codec::encode_with_value(&env, MsgType::ComposedABA, origin.src_eid, value);
304
302
  let executor = Address::generate(&env);
305
303
  let extra_data = Bytes::new(&env);
306
304
 
@@ -19,3 +19,4 @@ oapp-macros = { workspace = true }
19
19
  [dev-dependencies]
20
20
  soroban-sdk = { workspace = true, features = ["testutils"] }
21
21
  utils = { workspace = true, features = ["testutils"] }
22
+ endpoint-v2 = { workspace = true, features = ["testutils"] }
@@ -2,7 +2,7 @@ use common_macros::contract_error;
2
2
 
3
3
  #[contract_error]
4
4
  pub enum OAppError {
5
- InvalidOptions = 20000,
5
+ InvalidOptions = 2000,
6
6
  NoPeer,
7
7
  OnlyPeer,
8
8
  ZROTokenUnavailable,
@@ -6,5 +6,8 @@ pub mod oapp_options_type3;
6
6
  pub mod oapp_receiver;
7
7
  pub mod oapp_sender;
8
8
 
9
+ #[cfg(test)]
10
+ mod macro_tests;
11
+
9
12
  #[cfg(test)]
10
13
  mod tests;
@@ -0,0 +1 @@
1
+ pub mod test_macros;
@@ -0,0 +1,312 @@
1
+ extern crate self as oapp;
2
+
3
+ use endpoint_v2::Origin;
4
+ use oapp::{
5
+ oapp_core::OAppCore,
6
+ oapp_options_type3::{EnforcedOptionParam, OAppOptionsType3},
7
+ oapp_receiver::OAppReceiver,
8
+ oapp_sender::OAppSender,
9
+ };
10
+ use oapp_macros::{oapp, oapp_manual_impl};
11
+ use soroban_sdk::{contractimpl, Address, Bytes, BytesN, Env, Vec};
12
+
13
+ // ============================================================================
14
+ // Test 1: Full OApp with all defaults
15
+ // ============================================================================
16
+ #[oapp]
17
+ struct TestFullDefault;
18
+
19
+ impl TestFullDefault {
20
+ fn __lz_receive(
21
+ _env: &Env,
22
+ _executor: &Address,
23
+ _origin: &Origin,
24
+ _guid: &BytesN<32>,
25
+ _message: &Bytes,
26
+ _extra_data: &Bytes,
27
+ _value: i128,
28
+ ) {
29
+ // Default behavior
30
+ }
31
+ }
32
+
33
+ // ============================================================================
34
+ // Test 2: Full OApp with manual core implementation
35
+ // ============================================================================
36
+ #[oapp]
37
+ #[oapp_manual_impl(core)]
38
+ struct TestFullManualCore;
39
+
40
+ #[contractimpl(contracttrait)]
41
+ impl OAppCore for TestFullManualCore {
42
+ fn oapp_version(_env: &Env) -> (u64, u64) {
43
+ (2, 0)
44
+ }
45
+ }
46
+
47
+ impl TestFullManualCore {
48
+ fn __lz_receive(
49
+ _env: &Env,
50
+ _executor: &Address,
51
+ _origin: &Origin,
52
+ _guid: &BytesN<32>,
53
+ _message: &Bytes,
54
+ _extra_data: &Bytes,
55
+ _value: i128,
56
+ ) {
57
+ // Custom logic
58
+ }
59
+ }
60
+
61
+ // ============================================================================
62
+ // Test 3: Full OApp with manual sender implementation
63
+ // ============================================================================
64
+ #[oapp]
65
+ #[oapp_manual_impl(sender)]
66
+ struct TestFullManualSender;
67
+
68
+ impl OAppSender for TestFullManualSender {
69
+ // Custom sender implementation
70
+ }
71
+
72
+ impl TestFullManualSender {
73
+ fn __lz_receive(
74
+ _env: &Env,
75
+ _executor: &Address,
76
+ _origin: &Origin,
77
+ _guid: &BytesN<32>,
78
+ _message: &Bytes,
79
+ _extra_data: &Bytes,
80
+ _value: i128,
81
+ ) {
82
+ // Implementation
83
+ }
84
+ }
85
+
86
+ // ============================================================================
87
+ // Test 4: Full OApp with manual receiver implementation
88
+ // ============================================================================
89
+ #[oapp]
90
+ #[oapp_manual_impl(receiver)]
91
+ struct TestFullManualReceiver;
92
+
93
+ #[contractimpl(contracttrait)]
94
+ impl OAppReceiver for TestFullManualReceiver {
95
+ fn is_compose_msg_sender(_env: &Env, _origin: &Origin, _message: &Bytes, _sender: &Address) -> bool {
96
+ true
97
+ }
98
+
99
+ fn allow_initialize_path(_env: &Env, _origin: &Origin) -> bool {
100
+ true
101
+ }
102
+
103
+ fn next_nonce(_env: &Env, _src_eid: u32, _sender: &BytesN<32>) -> u64 {
104
+ 1 // Ordered delivery
105
+ }
106
+
107
+ fn lz_receive(
108
+ _env: &Env,
109
+ _executor: &Address,
110
+ _origin: &Origin,
111
+ _guid: &BytesN<32>,
112
+ _message: &Bytes,
113
+ _extra_data: &Bytes,
114
+ _value: i128,
115
+ ) {
116
+ // Custom implementation - verify_and_clear_payload must be called manually
117
+ }
118
+ }
119
+
120
+ // ============================================================================
121
+ // Test 5: Full OApp with manual options_type3 implementation
122
+ // ============================================================================
123
+ #[oapp]
124
+ #[oapp_manual_impl(options_type3)]
125
+ struct TestFullManualOptions;
126
+
127
+ impl TestFullManualOptions {
128
+ fn __lz_receive(
129
+ _env: &Env,
130
+ _executor: &Address,
131
+ _origin: &Origin,
132
+ _guid: &BytesN<32>,
133
+ _message: &Bytes,
134
+ _extra_data: &Bytes,
135
+ _value: i128,
136
+ ) {
137
+ // Implementation
138
+ }
139
+ }
140
+
141
+ #[contractimpl(contracttrait)]
142
+ impl OAppOptionsType3 for TestFullManualOptions {
143
+ // Custom options implementation
144
+ }
145
+
146
+ // ============================================================================
147
+ // Test 6: Full OApp with manual core + sender
148
+ // ============================================================================
149
+ #[oapp]
150
+ #[oapp_manual_impl(core, sender)]
151
+ struct TestFullManualCoreSender;
152
+
153
+ #[contractimpl(contracttrait)]
154
+ impl OAppCore for TestFullManualCoreSender {
155
+ fn oapp_version(_env: &Env) -> (u64, u64) {
156
+ (3, 0)
157
+ }
158
+ }
159
+
160
+ impl OAppSender for TestFullManualCoreSender {
161
+ // Custom sender implementation
162
+ }
163
+
164
+ impl TestFullManualCoreSender {
165
+ fn __lz_receive(
166
+ _env: &Env,
167
+ _executor: &Address,
168
+ _origin: &Origin,
169
+ _guid: &BytesN<32>,
170
+ _message: &Bytes,
171
+ _extra_data: &Bytes,
172
+ _value: i128,
173
+ ) {
174
+ // Implementation
175
+ }
176
+ }
177
+
178
+ // ============================================================================
179
+ // Test 7: Full OApp with manual core + receiver
180
+ // ============================================================================
181
+ #[oapp]
182
+ #[oapp_manual_impl(core, receiver)]
183
+ struct TestFullManualCoreReceiver;
184
+
185
+ #[contractimpl(contracttrait)]
186
+ impl OAppCore for TestFullManualCoreReceiver {
187
+ fn oapp_version(_env: &Env) -> (u64, u64) {
188
+ (4, 0)
189
+ }
190
+ }
191
+
192
+ #[contractimpl(contracttrait)]
193
+ impl OAppReceiver for TestFullManualCoreReceiver {
194
+ fn lz_receive(
195
+ _env: &Env,
196
+ _executor: &Address,
197
+ _origin: &Origin,
198
+ _guid: &BytesN<32>,
199
+ _message: &Bytes,
200
+ _extra_data: &Bytes,
201
+ _value: i128,
202
+ ) {
203
+ // Custom receiver implementation
204
+ }
205
+ }
206
+
207
+ // ============================================================================
208
+ // Test 8: Full OApp with manual sender + receiver
209
+ // ============================================================================
210
+ #[oapp]
211
+ #[oapp_manual_impl(sender, receiver)]
212
+ struct TestFullManualSenderReceiver;
213
+
214
+ impl OAppSender for TestFullManualSenderReceiver {
215
+ // Custom sender implementation
216
+ }
217
+
218
+ #[contractimpl(contracttrait)]
219
+ impl OAppReceiver for TestFullManualSenderReceiver {
220
+ fn lz_receive(
221
+ _env: &Env,
222
+ _executor: &Address,
223
+ _origin: &Origin,
224
+ _guid: &BytesN<32>,
225
+ _message: &Bytes,
226
+ _extra_data: &Bytes,
227
+ _value: i128,
228
+ ) {
229
+ // Custom receiver implementation
230
+ }
231
+ }
232
+
233
+ // ============================================================================
234
+ // Test 9: Full OApp with manual core + sender + receiver (all except options)
235
+ // ============================================================================
236
+ #[oapp]
237
+ #[oapp_manual_impl(core, sender, receiver)]
238
+ struct TestFullManualAllExceptOptions;
239
+
240
+ #[contractimpl(contracttrait)]
241
+ impl OAppCore for TestFullManualAllExceptOptions {
242
+ fn oapp_version(_env: &Env) -> (u64, u64) {
243
+ (5, 0)
244
+ }
245
+ }
246
+
247
+ impl OAppSender for TestFullManualAllExceptOptions {
248
+ // Custom sender implementation
249
+ }
250
+
251
+ #[contractimpl(contracttrait)]
252
+ impl OAppReceiver for TestFullManualAllExceptOptions {
253
+ fn lz_receive(
254
+ _env: &Env,
255
+ _executor: &Address,
256
+ _origin: &Origin,
257
+ _guid: &BytesN<32>,
258
+ _message: &Bytes,
259
+ _extra_data: &Bytes,
260
+ _value: i128,
261
+ ) {
262
+ // Custom receiver implementation
263
+ }
264
+ }
265
+
266
+ // ============================================================================
267
+ // Test 10: Full OApp with all manual implementations
268
+ // ============================================================================
269
+ #[oapp]
270
+ #[oapp_manual_impl(core, sender, receiver, options_type3)]
271
+ struct TestFullManualAll;
272
+
273
+ #[contractimpl(contracttrait)]
274
+ impl OAppCore for TestFullManualAll {
275
+ fn oapp_version(_env: &Env) -> (u64, u64) {
276
+ (6, 0)
277
+ }
278
+ }
279
+
280
+ impl OAppSender for TestFullManualAll {
281
+ // Custom sender implementation
282
+ }
283
+
284
+ #[contractimpl(contracttrait)]
285
+ impl OAppReceiver for TestFullManualAll {
286
+ fn lz_receive(
287
+ _env: &Env,
288
+ _executor: &Address,
289
+ _origin: &Origin,
290
+ _guid: &BytesN<32>,
291
+ _message: &Bytes,
292
+ _extra_data: &Bytes,
293
+ _value: i128,
294
+ ) {
295
+ // Custom receiver implementation
296
+ }
297
+ }
298
+
299
+ #[contractimpl(contracttrait)]
300
+ impl OAppOptionsType3 for TestFullManualAll {
301
+ // Custom options implementation
302
+ }
303
+
304
+ // ============================================================================
305
+ // Tests
306
+ // ============================================================================
307
+
308
+ #[test]
309
+ fn test_macros_compile() {
310
+ // This test verifies that all macro combinations compile successfully
311
+ assert!(true);
312
+ }
@@ -1,51 +1,27 @@
1
- use common_macros::{event, storage};
1
+ use common_macros::{event, only_owner, storage};
2
2
  use endpoint_v2::LayerZeroEndpointV2Client;
3
- use soroban_sdk::{Address, BytesN, Env};
4
- use utils::{ownable::Ownable, ttl::DefaultTtlConfigProvider};
3
+ use soroban_sdk::{contracttrait, Address, BytesN, Env};
4
+ use utils::ownable::Ownable;
5
+ use utils::ownable::OwnableInitializer;
5
6
 
6
- pub trait OAppCore: Ownable {
7
- /// Retrieves the OApp version information.
8
- ///
9
- /// # Returns
10
- /// A tuple containing:
11
- /// - `sender_version`: The version of the OAppSender implementation
12
- /// - `receiver_version`: The version of the OAppReceiver implementation
13
- fn oapp_version(env: &Env) -> (u64, u64);
7
+ pub fn oapp_initialize<T: OAppCore + OwnableInitializer>(
8
+ env: &Env,
9
+ owner: &Address,
10
+ endpoint: &Address,
11
+ delegate: &Option<Address>,
12
+ ) {
13
+ T::init_owner(env, owner);
14
+ OAppCoreStorage::set_endpoint(env, endpoint);
14
15
 
15
- /// Retrieves the LayerZero endpoint associated with the OApp.
16
- ///
17
- /// # Returns
18
- /// The LayerZero endpoint client
19
- fn endpoint(env: &Env) -> Address;
20
-
21
- /// Retrieves the peer (OApp) associated with a corresponding endpoint.
22
- ///
23
- /// # Arguments
24
- /// * `eid` - The endpoint ID
25
- ///
26
- /// # Returns
27
- /// The peer address (OApp instance) associated with the corresponding endpoint
28
- fn peer(env: &Env, eid: u32) -> Option<BytesN<32>>;
29
-
30
- /// Sets or removes the peer address (OApp instance) for a corresponding endpoint.
31
- ///
32
- /// # Arguments
33
- /// * `eid` - The endpoint ID
34
- /// * `peer` - The address of the peer to be associated with the corresponding endpoint, or None to remove the peer
35
- fn set_peer(env: &Env, eid: u32, peer: &Option<BytesN<32>>);
36
-
37
- /// Sets the delegate address for the OApp Core.
38
- ///
39
- /// # Arguments
40
- /// * `delegate` - The address of the delegate to be set, or None to remove the delegate
41
- fn set_delegate(env: &Env, delegate: &Option<Address>);
16
+ let endpoint_client = endpoint_v2::LayerZeroEndpointV2Client::new(env, endpoint);
17
+ endpoint_client.set_delegate(&env.current_contract_address(), delegate);
42
18
  }
43
19
 
44
20
  // =====================================================
45
- // Implement overrides for the OAppCore trait
21
+ // OAppCore Storage, Events, and Interface
46
22
  // =====================================================
47
23
 
48
- #[storage(DefaultTtlConfigProvider)]
24
+ #[storage]
49
25
  pub enum OAppCoreStorage {
50
26
  #[instance(Address)]
51
27
  Endpoint,
@@ -60,32 +36,55 @@ pub struct PeerSet {
60
36
  pub peer: Option<BytesN<32>>,
61
37
  }
62
38
 
63
- pub trait OAppCoreOverrides {
64
- fn __oapp_initialize(env: &Env, endpoint: &Address, delegate: &Option<Address>) {
65
- OAppCoreStorage::set_endpoint(env, endpoint);
66
- let endpoint_client = endpoint_v2::LayerZeroEndpointV2Client::new(env, endpoint);
67
- endpoint_client.set_delegate(&env.current_contract_address(), delegate);
68
- }
69
-
70
- fn __oapp_version(_env: &Env) -> (u64, u64) {
39
+ #[contracttrait(client_name = "OAppCoreClient")]
40
+ pub trait OAppCore: Ownable + Sized {
41
+ /// Retrieves the OApp version information.
42
+ ///
43
+ /// # Returns
44
+ /// A tuple containing:
45
+ /// - `sender_version`: The version of the OAppSender implementation
46
+ /// - `receiver_version`: The version of the OAppReceiver implementation
47
+ fn oapp_version(_env: &Env) -> (u64, u64) {
71
48
  (0, 0)
72
49
  }
73
50
 
74
- fn __endpoint(env: &Env) -> Address {
51
+ /// Retrieves the LayerZero endpoint associated with the OApp.
52
+ ///
53
+ /// # Returns
54
+ /// The LayerZero endpoint client
55
+ fn endpoint(env: &Env) -> Address {
75
56
  OAppCoreStorage::endpoint(env).unwrap()
76
57
  }
77
58
 
78
- fn __peer(env: &Env, eid: u32) -> Option<BytesN<32>> {
59
+ /// Retrieves the peer (OApp) associated with a corresponding endpoint.
60
+ ///
61
+ /// # Arguments
62
+ /// * `eid` - The endpoint ID
63
+ ///
64
+ /// # Returns
65
+ /// The peer address (OApp instance) associated with the corresponding endpoint
66
+ fn peer(env: &Env, eid: u32) -> Option<BytesN<32>> {
79
67
  OAppCoreStorage::peer(env, eid)
80
68
  }
81
69
 
82
- fn __set_peer(env: &Env, eid: u32, peer: &Option<BytesN<32>>) {
70
+ /// Sets or removes the peer address (OApp instance) for a corresponding endpoint.
71
+ ///
72
+ /// # Arguments
73
+ /// * `eid` - The endpoint ID
74
+ /// * `peer` - The address of the peer to be associated with the corresponding endpoint, or None to remove the peer
75
+ #[only_owner]
76
+ fn set_peer(env: &Env, eid: u32, peer: &Option<BytesN<32>>) {
83
77
  OAppCoreStorage::set_or_remove_peer(env, eid, peer);
84
78
  PeerSet { eid, peer: peer.clone() }.publish(env);
85
79
  }
86
80
 
87
- fn __set_delegate(env: &Env, delegate: &Option<Address>) {
88
- let endpoint = Self::__endpoint(env);
81
+ /// Sets the delegate address for the OApp Core.
82
+ ///
83
+ /// # Arguments
84
+ /// * `delegate` - The address of the delegate to be set, or None to remove the delegate
85
+ #[only_owner]
86
+ fn set_delegate(env: &Env, delegate: &Option<Address>) {
87
+ let endpoint = Self::endpoint(env);
89
88
  let endpoint_client = LayerZeroEndpointV2Client::new(env, &endpoint);
90
89
  endpoint_client.set_delegate(&env.current_contract_address(), delegate);
91
90
  }