@layerzerolabs/protocol-stellar-v2 0.2.15 → 0.2.18

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 (257) hide show
  1. package/.turbo/turbo-build.log +350 -309
  2. package/.turbo/turbo-lint.log +146 -108
  3. package/.turbo/turbo-test.log +1423 -1238
  4. package/Cargo.lock +12 -0
  5. package/Cargo.toml +3 -0
  6. package/contracts/ERROR_SPEC.md +44 -0
  7. package/contracts/common-macros/src/auth.rs +113 -0
  8. package/contracts/common-macros/src/contract_ttl.rs +84 -0
  9. package/contracts/common-macros/src/lib.rs +181 -30
  10. package/contracts/common-macros/src/lz_contract.rs +83 -0
  11. package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
  13. package/contracts/common-macros/src/tests/mod.rs +2 -2
  14. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
  15. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
  16. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
  17. package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +3 -3
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
  21. package/contracts/common-macros/src/ttl_configurable.rs +19 -34
  22. package/contracts/common-macros/src/ttl_extendable.rs +36 -0
  23. package/contracts/common-macros/src/upgradeable.rs +5 -5
  24. package/contracts/common-macros/src/utils.rs +9 -0
  25. package/contracts/endpoint-v2/src/constants.rs +4 -4
  26. package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
  27. package/contracts/endpoint-v2/src/errors.rs +4 -3
  28. package/contracts/endpoint-v2/src/events.rs +1 -1
  29. package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
  30. package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
  31. package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
  32. package/contracts/endpoint-v2/src/storage.rs +1 -1
  33. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
  34. package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
  35. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  36. package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
  37. package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
  38. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
  39. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
  40. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
  41. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
  42. package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
  43. package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
  44. package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
  45. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
  46. package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
  47. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
  48. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
  49. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
  50. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
  51. package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
  52. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
  53. package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
  54. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
  55. package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
  56. package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
  57. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
  58. package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
  59. package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
  60. package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
  61. package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
  62. package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
  63. package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
  64. package/contracts/message-libs/treasury/src/errors.rs +2 -2
  65. package/contracts/message-libs/treasury/src/events.rs +1 -1
  66. package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
  67. package/contracts/message-libs/treasury/src/storage.rs +1 -1
  68. package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
  69. package/contracts/message-libs/treasury/src/treasury.rs +14 -16
  70. package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
  71. package/contracts/message-libs/uln-302/src/send_uln.rs +23 -3
  72. package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
  73. package/contracts/oapps/counter/Cargo.toml +14 -1
  74. package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
  75. package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
  76. package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
  77. package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
  78. package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
  79. package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
  80. package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
  81. package/contracts/oapps/counter/src/counter.rs +67 -43
  82. package/contracts/oapps/counter/src/tests/mod.rs +0 -13
  83. package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
  84. package/contracts/oapps/oapp/src/errors.rs +5 -1
  85. package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
  86. package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
  87. package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
  88. package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
  89. package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
  90. package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
  91. package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
  92. package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
  93. package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
  94. package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
  95. package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
  96. package/contracts/oapps/oft/integration-tests/setup.rs +25 -7
  97. package/contracts/oapps/oft/src/errors.rs +6 -1
  98. package/contracts/oapps/oft/src/extensions/oft_fee.rs +8 -8
  99. package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
  100. package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
  101. package/contracts/oapps/oft/src/lib.rs +4 -2
  102. package/contracts/oapps/oft/src/oft.rs +24 -64
  103. package/contracts/oapps/oft/src/oft_impl.rs +201 -0
  104. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -3
  105. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -4
  106. package/contracts/oapps/oft/src/storage.rs +2 -0
  107. package/contracts/oapps/oft/src/tests/extensions/setup.rs +36 -22
  108. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +5 -3
  109. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +5 -3
  110. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +5 -3
  111. package/contracts/oapps/oft/src/tests/test_decimals.rs +2 -2
  112. package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +1 -2
  113. package/contracts/oapps/oft/src/tests/test_utils.rs +45 -23
  114. package/contracts/oapps/oft/src/types.rs +20 -0
  115. package/contracts/oapps/oft-std/integration-tests/setup.rs +4 -2
  116. package/contracts/oapps/oft-std/src/oft.rs +24 -6
  117. package/contracts/upgrader/src/lib.rs +4 -4
  118. package/contracts/utils/src/auth.rs +44 -0
  119. package/contracts/utils/src/errors.rs +27 -5
  120. package/contracts/utils/src/lib.rs +3 -0
  121. package/contracts/utils/src/multisig.rs +211 -0
  122. package/contracts/utils/src/ownable.rs +12 -10
  123. package/contracts/utils/src/tests/buffer_reader.rs +6 -6
  124. package/contracts/utils/src/tests/buffer_writer.rs +6 -6
  125. package/contracts/utils/src/tests/bytes_ext.rs +2 -4
  126. package/contracts/utils/src/tests/mod.rs +1 -0
  127. package/contracts/utils/src/tests/multisig.rs +731 -0
  128. package/contracts/utils/src/tests/option_ext.rs +2 -5
  129. package/contracts/utils/src/tests/ownable.rs +16 -5
  130. package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
  131. package/contracts/utils/src/tests/upgradeable.rs +4 -2
  132. package/contracts/utils/src/ttl_configurable.rs +23 -8
  133. package/contracts/utils/src/ttl_extendable.rs +27 -0
  134. package/contracts/utils/src/upgradeable.rs +2 -0
  135. package/contracts/workers/dvn/Cargo.toml +1 -1
  136. package/contracts/workers/dvn/src/auth.rs +7 -7
  137. package/contracts/workers/dvn/src/dvn.rs +10 -38
  138. package/contracts/workers/dvn/src/errors.rs +0 -7
  139. package/contracts/workers/dvn/src/events.rs +1 -14
  140. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  141. package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
  142. package/contracts/workers/dvn/src/storage.rs +3 -13
  143. package/contracts/workers/dvn/src/tests/auth.rs +4 -4
  144. package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
  145. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
  146. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
  147. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
  148. package/contracts/workers/dvn/src/tests/setup.rs +5 -5
  149. package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
  150. package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
  151. package/contracts/workers/executor/src/auth.rs +80 -16
  152. package/contracts/workers/executor/src/executor.rs +5 -31
  153. package/contracts/workers/executor/src/storage.rs +2 -9
  154. package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
  155. package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
  156. package/contracts/workers/executor-helper/Cargo.toml +1 -1
  157. package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
  158. package/contracts/workers/price-feed/Cargo.toml +1 -1
  159. package/contracts/workers/price-feed/src/price_feed.rs +7 -10
  160. package/contracts/workers/worker/src/errors.rs +4 -0
  161. package/contracts/workers/worker/src/tests/worker.rs +7 -6
  162. package/contracts/workers/worker/src/worker.rs +20 -16
  163. package/package.json +8 -5
  164. package/sdk/.turbo/turbo-build.log +1 -0
  165. package/sdk/.turbo/turbo-test.log +1009 -0
  166. package/sdk/dist/generated/bml.d.ts +65 -8
  167. package/sdk/dist/generated/bml.js +70 -34
  168. package/sdk/dist/generated/counter.d.ts +167 -42
  169. package/sdk/dist/generated/counter.js +86 -45
  170. package/sdk/dist/generated/dvn.d.ts +282 -229
  171. package/sdk/dist/generated/dvn.js +119 -81
  172. package/sdk/dist/generated/dvn_fee_lib.d.ts +142 -67
  173. package/sdk/dist/generated/dvn_fee_lib.js +64 -24
  174. package/sdk/dist/generated/endpoint.d.ts +97 -22
  175. package/sdk/dist/generated/endpoint.js +75 -37
  176. package/sdk/dist/generated/executor.d.ts +117 -85
  177. package/sdk/dist/generated/executor.js +102 -59
  178. package/sdk/dist/generated/executor_fee_lib.d.ts +162 -78
  179. package/sdk/dist/generated/executor_fee_lib.js +104 -57
  180. package/sdk/dist/generated/executor_helper.d.ts +133 -21
  181. package/sdk/dist/generated/executor_helper.js +99 -50
  182. package/sdk/dist/generated/oft_std.d.ts +233 -55
  183. package/sdk/dist/generated/oft_std.js +99 -54
  184. package/sdk/dist/generated/price_feed.d.ts +142 -67
  185. package/sdk/dist/generated/price_feed.js +64 -24
  186. package/sdk/dist/generated/sml.d.ts +113 -32
  187. package/sdk/dist/generated/sml.js +93 -49
  188. package/sdk/dist/generated/treasury.d.ts +896 -0
  189. package/sdk/dist/generated/treasury.js +219 -0
  190. package/sdk/dist/generated/uln302.d.ts +113 -32
  191. package/sdk/dist/generated/uln302.js +93 -49
  192. package/sdk/dist/generated/upgrader.d.ts +2 -2
  193. package/sdk/dist/generated/upgrader.js +1 -1
  194. package/sdk/dist/index.d.ts +2 -0
  195. package/sdk/dist/index.js +3 -0
  196. package/sdk/dist/wasm/blocked-message-lib.d.ts +1 -0
  197. package/sdk/dist/wasm/blocked-message-lib.js +2 -0
  198. package/sdk/dist/wasm/counter.d.ts +1 -0
  199. package/sdk/dist/wasm/counter.js +2 -0
  200. package/sdk/dist/wasm/dvn-fee-lib.d.ts +1 -0
  201. package/sdk/dist/wasm/dvn-fee-lib.js +2 -0
  202. package/sdk/dist/wasm/dvn.d.ts +1 -0
  203. package/sdk/dist/wasm/dvn.js +2 -0
  204. package/sdk/dist/wasm/endpoint-v2.d.ts +1 -0
  205. package/sdk/dist/wasm/endpoint-v2.js +2 -0
  206. package/sdk/dist/wasm/executor-fee-lib.d.ts +1 -0
  207. package/sdk/dist/wasm/executor-fee-lib.js +2 -0
  208. package/sdk/dist/wasm/executor-helper.d.ts +1 -0
  209. package/sdk/dist/wasm/executor-helper.js +2 -0
  210. package/sdk/dist/wasm/executor.d.ts +1 -0
  211. package/sdk/dist/wasm/executor.js +2 -0
  212. package/sdk/dist/wasm/layerzero-views.d.ts +1 -0
  213. package/sdk/dist/wasm/layerzero-views.js +2 -0
  214. package/sdk/dist/wasm/oft-std.d.ts +1 -0
  215. package/sdk/dist/wasm/oft-std.js +2 -0
  216. package/sdk/dist/wasm/price-feed.d.ts +1 -0
  217. package/sdk/dist/wasm/price-feed.js +2 -0
  218. package/sdk/dist/wasm/simple-message-lib.d.ts +1 -0
  219. package/sdk/dist/wasm/simple-message-lib.js +2 -0
  220. package/sdk/dist/wasm/treasury.d.ts +1 -0
  221. package/sdk/dist/wasm/treasury.js +2 -0
  222. package/sdk/dist/wasm/uln302.d.ts +1 -0
  223. package/sdk/dist/wasm/uln302.js +2 -0
  224. package/sdk/dist/wasm/upgrader.d.ts +1 -0
  225. package/sdk/dist/wasm/upgrader.js +2 -0
  226. package/sdk/dist/wasm.d.ts +15 -0
  227. package/sdk/dist/wasm.js +15 -0
  228. package/sdk/package.json +4 -2
  229. package/sdk/src/index.ts +4 -0
  230. package/sdk/test/counter-sml.test.ts +376 -0
  231. package/sdk/test/counter-uln.test.ts +493 -0
  232. package/sdk/test/{oft.test.ts → oft-sml.test.ts} +185 -310
  233. package/sdk/test/suites/constants.ts +22 -2
  234. package/sdk/test/suites/globalSetup.ts +450 -0
  235. package/sdk/test/suites/localnet.ts +23 -6
  236. package/sdk/test/upgrader.test.ts +7 -16
  237. package/sdk/test/utils.ts +558 -85
  238. package/sdk/vitest.config.ts +21 -0
  239. package/tools/ts-bindings-gen/src/main.rs +1 -0
  240. package/turbo.json +2 -0
  241. package/contracts/common-macros/src/contract_impl.rs +0 -52
  242. package/contracts/common-macros/src/ownable.rs +0 -41
  243. package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
  244. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
  245. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
  246. package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
  247. package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
  248. package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
  249. package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
  250. package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
  251. package/contracts/oapps/oapp-macros/src/util.rs +0 -107
  252. package/contracts/oapps/oft/src/constants.rs +0 -5
  253. package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
  254. package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
  255. package/contracts/workers/dvn/src/multisig.rs +0 -157
  256. package/sdk/test/index.test.ts +0 -375
  257. /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
@@ -1,9 +1,12 @@
1
- use crate::tests::setup::{TestSetup, DEFAULT_MULTIPLIER_BPS, VID};
2
- use crate::{dvn::LzDVN, errors::DvnError, storage::DvnStorage};
1
+ use crate::{
2
+ dvn::LzDVN,
3
+ tests::setup::{TestSetup, DEFAULT_MULTIPLIER_BPS, VID},
4
+ };
3
5
  use soroban_sdk::{
4
6
  testutils::{Address as _, AuthorizedFunction, BytesN as _},
5
7
  vec, Address, BytesN, Env, IntoVal, Symbol, Vec,
6
8
  };
9
+ use utils::errors::MultisigError;
7
10
 
8
11
  fn random_signer(env: &Env) -> BytesN<20> {
9
12
  BytesN::random(env)
@@ -66,7 +69,7 @@ fn test_set_threshold_zero_fails() {
66
69
  let setup = TestSetup::new(1);
67
70
 
68
71
  let res = setup.multisig_client.try_set_threshold(&0);
69
- assert_eq!(res.err().unwrap().ok().unwrap(), DvnError::ZeroThreshold.into());
72
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::ZeroThreshold.into());
70
73
  }
71
74
 
72
75
  #[test]
@@ -74,7 +77,7 @@ fn test_set_threshold_above_signers_fails() {
74
77
  let setup = TestSetup::new(2);
75
78
 
76
79
  let res = setup.multisig_client.try_set_threshold(&3);
77
- assert_eq!(res.err().unwrap().ok().unwrap(), DvnError::TotalSignersLessThanThreshold.into());
80
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
78
81
  }
79
82
 
80
83
  #[test]
@@ -82,15 +85,15 @@ fn test_set_threshold_with_no_signers_fails() {
82
85
  let setup = TestSetup::new(1);
83
86
 
84
87
  setup.env.as_contract(&setup.contract_id, || {
85
- DvnStorage::remove_signers(&setup.env);
88
+ utils::multisig::MultisigStorage::remove_signers(&setup.env);
86
89
  });
87
90
 
88
91
  let res = setup.multisig_client.try_set_threshold(&1);
89
- assert_eq!(res.err().unwrap().ok().unwrap(), DvnError::TotalSignersLessThanThreshold.into());
92
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
90
93
  }
91
94
 
92
95
  #[test]
93
- #[should_panic(expected = "Error(Contract, #14)")] // DvnError::ZeroThreshold
96
+ #[should_panic(expected = "Error(Contract, #1067)")] // ZeroThreshold
94
97
  fn test_constructor_threshold_zero_panics() {
95
98
  let env = Env::default();
96
99
  env.mock_all_auths();
@@ -99,7 +102,7 @@ fn test_constructor_threshold_zero_panics() {
99
102
  }
100
103
 
101
104
  #[test]
102
- #[should_panic(expected = "Error(Contract, #12)")] // DvnError::TotalSignersLessThanThreshold
105
+ #[should_panic(expected = "Error(Contract, #1065)")] // TotalSignersLessThanThreshold
103
106
  fn test_constructor_signers_less_than_threshold_panics() {
104
107
  let env = Env::default();
105
108
  env.mock_all_auths();
@@ -1,9 +1,8 @@
1
1
  extern crate std;
2
2
 
3
- use crate::storage::DvnStorage;
4
- use crate::tests::key_pair::KeyPair;
5
- use crate::tests::setup::TestSetup;
3
+ use crate::tests::{key_pair::KeyPair, setup::TestSetup};
6
4
  use soroban_sdk::{vec, Bytes, BytesN, Vec};
5
+ use utils::errors::MultisigError;
7
6
 
8
7
  fn hash(env: &soroban_sdk::Env, label: &[u8]) -> BytesN<32> {
9
8
  env.crypto().keccak256(&Bytes::from_slice(env, label)).to_bytes()
@@ -59,7 +58,6 @@ fn test_verify_signatures_raw_v_path() {
59
58
  }
60
59
 
61
60
  #[test]
62
- #[should_panic(expected = "Error(Contract, #11)")] // DvnError::SignerNotFound
63
61
  fn test_verify_signatures_with_wrong_signer() {
64
62
  let setup = TestSetup::new(1);
65
63
  let digest = hash(&setup.env, b"test");
@@ -67,22 +65,22 @@ fn test_verify_signatures_with_wrong_signer() {
67
65
  let signature = wrong_key_pair.sign(&digest.to_array());
68
66
  let signatures: Vec<BytesN<65>> = vec![&setup.env, BytesN::from_array(&setup.env, &signature)];
69
67
 
70
- setup.multisig_client.verify_signatures(&digest, &signatures);
68
+ let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
69
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
71
70
  }
72
71
 
73
72
  #[test]
74
- #[should_panic(expected = "Error(Contract, #9)")] // DvnError::SignatureError
75
73
  fn test_verify_signatures_insufficient_signatures() {
76
74
  let setup = TestSetup::new(2);
77
75
  let digest = hash(&setup.env, b"insufficient");
78
76
 
79
77
  let signatures: Vec<BytesN<65>> = vec![&setup.env, sign(&setup, 0, &digest)];
80
78
 
81
- setup.multisig_client.verify_signatures(&digest, &signatures);
79
+ let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
80
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignatureError.into());
82
81
  }
83
82
 
84
83
  #[test]
85
- #[should_panic(expected = "Error(Contract, #13)")] // DvnError::UnsortedSigners
86
84
  fn test_verify_signatures_duplicate_signer() {
87
85
  let setup = TestSetup::new(2);
88
86
  let digest = hash(&setup.env, b"duplicate");
@@ -90,20 +88,21 @@ fn test_verify_signatures_duplicate_signer() {
90
88
  let sig1 = sign(&setup, 0, &digest);
91
89
  let signatures: Vec<BytesN<65>> = vec![&setup.env, sig1.clone(), sig1];
92
90
 
93
- setup.multisig_client.verify_signatures(&digest, &signatures);
91
+ let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
92
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::UnsortedSigners.into());
94
93
  }
95
94
 
96
95
  #[test]
97
- #[should_panic(expected = "Error(Contract, #14)")] // DvnError::ZeroThreshold
98
96
  fn test_verify_signatures_threshold_zero() {
99
97
  let setup = TestSetup::new(1);
100
98
  // Force threshold to 0 via storage to hit ZeroThreshold branch
101
99
  setup.env.as_contract(&setup.contract_id, || {
102
- DvnStorage::set_threshold(&setup.env, &0);
100
+ utils::multisig::MultisigStorage::set_threshold(&setup.env, &0);
103
101
  });
104
102
  let digest = hash(&setup.env, b"threshold_zero");
105
103
 
106
104
  let signatures: Vec<BytesN<65>> = vec![&setup.env, sign(&setup, 0, &digest)];
107
105
 
108
- setup.multisig_client.verify_signatures(&digest, &signatures);
106
+ let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
107
+ assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::ZeroThreshold.into());
109
108
  }
@@ -2,9 +2,9 @@
2
2
 
3
3
  extern crate std;
4
4
 
5
- use crate::tests::key_pair::KeyPair;
6
- use crate::{dvn::LzDVN, interfaces::MultiSigClient};
5
+ use crate::{dvn::LzDVN, tests::key_pair::KeyPair};
7
6
  use soroban_sdk::{address_payload::AddressPayload, testutils::Address as _, vec, Address, BytesN, Env, Vec};
7
+ use utils::multisig::MultisigClient;
8
8
  use std::vec::Vec as StdVec;
9
9
 
10
10
  pub const VID: u32 = 1;
@@ -13,7 +13,7 @@ pub const DEFAULT_MULTIPLIER_BPS: u32 = 10000;
13
13
  pub struct TestSetup<'a> {
14
14
  pub env: Env,
15
15
  pub contract_id: Address,
16
- pub multisig_client: MultiSigClient<'a>,
16
+ pub multisig_client: MultisigClient<'a>,
17
17
  pub key_pairs: StdVec<KeyPair>,
18
18
  pub admins: Vec<Address>,
19
19
  }
@@ -58,7 +58,7 @@ impl<'a> TestSetup<'a> {
58
58
  ),
59
59
  );
60
60
 
61
- let multisig_client = MultiSigClient::new(&env, &contract_id);
61
+ let multisig_client = MultisigClient::new(&env, &contract_id);
62
62
 
63
63
  Self { env, contract_id, multisig_client, key_pairs, admins }
64
64
  }
@@ -102,7 +102,7 @@ impl<'a> TestSetup<'a> {
102
102
  ),
103
103
  );
104
104
 
105
- let multisig_client = MultiSigClient::new(&env, &contract_id);
105
+ let multisig_client = MultisigClient::new(&env, &contract_id);
106
106
 
107
107
  Self { env, contract_id, multisig_client, key_pairs, admins }
108
108
  }
@@ -10,7 +10,7 @@ library = []
10
10
  testutils = []
11
11
 
12
12
  [lib]
13
- crate-type = ["cdylib"]
13
+ crate-type = ["cdylib", "rlib"]
14
14
  doctest = false
15
15
 
16
16
  [dependencies]
@@ -1,6 +1,6 @@
1
1
  use crate::errors::DvnFeeLibError;
2
- use common_macros::{contract_impl, ownable, ttl_configurable, upgradeable};
3
- use soroban_sdk::{assert_with_error, contract, Address, Env};
2
+ use common_macros::{contract_impl, lz_contract};
3
+ use soroban_sdk::{assert_with_error, Address, Env};
4
4
  use utils::upgradeable::UpgradeableInternal;
5
5
  use worker::{DvnFeeParams, IDvnFeeLib, LayerZeroPriceFeedClient};
6
6
 
@@ -28,10 +28,7 @@ pub(crate) const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
28
28
  /// Provides fee calculation logic based on quorum size, destination gas costs,
29
29
  /// and current gas prices from the price feed. Handles fee multipliers and
30
30
  /// floor margins.
31
- #[contract]
32
- #[ownable]
33
- #[ttl_configurable]
34
- #[upgradeable]
31
+ #[lz_contract(upgradeable)]
35
32
  pub struct DvnFeeLib;
36
33
 
37
34
  #[contract_impl]
@@ -1,10 +1,11 @@
1
1
  use super::*;
2
-
2
+ use endpoint_v2::LayerZeroEndpointV2Client;
3
3
  use soroban_sdk::{
4
4
  address_payload::AddressPayload,
5
5
  auth::{Context, CustomAccountInterface},
6
- contractimpl, contracttype,
6
+ contracttype,
7
7
  crypto::Hash,
8
+ Symbol, TryFromVal, Val,
8
9
  };
9
10
 
10
11
  // ============================================================================
@@ -26,7 +27,7 @@ pub struct ExecutorSignature {
26
27
  // Custom Account Interface Implementation
27
28
  // ============================================================================
28
29
 
29
- #[contractimpl]
30
+ #[contract_impl]
30
31
  impl CustomAccountInterface for LzExecutor {
31
32
  type Signature = ExecutorSignature;
32
33
  type Error = ExecutorError;
@@ -35,7 +36,6 @@ impl CustomAccountInterface for LzExecutor {
35
36
  ///
36
37
  /// The public key must correspond to a registered admin and must have signed the signature_payload.
37
38
  /// Uses Ed25519 signature verification.
38
- /// Only whitelisted function calls are authorized.
39
39
  fn __check_auth(
40
40
  env: Env,
41
41
  signature_payload: Hash<32>,
@@ -70,24 +70,88 @@ impl LzExecutor {
70
70
  Ok(())
71
71
  }
72
72
 
73
- /// Validates that the first auth context is a whitelisted (contract, function) pair.
74
- /// Sub-invocations are trusted since they're controlled by the whitelisted contract.
73
+ /// Validates auth contexts according to executor rules.
74
+ ///
75
+ /// # Design
76
+ ///
77
+ /// For `lz_receive`: OApps call `verify_and_clear_payload` (see `oapp_receiver.rs`)
78
+ /// which requires executor auth and optionally transfers native token from executor to OApp.
79
+ ///
80
+ /// For `lz_compose`: Composers follow the same pattern - require executor auth and
81
+ /// optionally transfer native token from executor to composer.
82
+ ///
83
+ /// Both create 1-2 auth contexts depending on whether value == 0:
84
+ /// - Context 1: `lz_receive`/`lz_compose` on the OApp/Composer (always present)
85
+ /// - Context 2: `transfer` on native token (only if value != 0)
86
+ ///
87
+ /// For `lz_receive_alert`/`lz_compose_alert`: These are called directly on the endpoint
88
+ /// to record failed executions. Only 1 context on the endpoint is expected.
75
89
  fn validate_auth_contexts(env: &Env, contexts: &Vec<Context>) -> Result<(), ExecutorError> {
76
- let first_context = contexts.first().ok_or(ExecutorError::UnauthorizedContext)?;
77
-
78
- match first_context {
79
- Context::Contract(contract_context) => {
80
- // Check if (contract, fn_name) pair is whitelisted
81
- if !Self::is_whitelisted_fn(env, &contract_context.contract, &contract_context.fn_name) {
82
- return Err(ExecutorError::UnauthorizedContext);
83
- }
90
+ // Early bounds check: max 2 contexts expected
91
+ if contexts.len() > 2 {
92
+ return Err(ExecutorError::UnauthorizedContext);
93
+ }
94
+
95
+ let first_ctx = contexts.first().ok_or(ExecutorError::UnauthorizedContext)?;
96
+ let Context::Contract(first_ctx) = first_ctx else {
97
+ return Err(ExecutorError::UnauthorizedContext);
98
+ };
99
+
100
+ let first_fn_name = &first_ctx.fn_name;
101
+
102
+ // Alert path: lz_receive_alert or lz_compose_alert (lazy Symbol creation)
103
+ if *first_fn_name == Symbol::new(env, "lz_receive_alert")
104
+ || *first_fn_name == Symbol::new(env, "lz_compose_alert")
105
+ {
106
+ // Require exactly 1 context and the contract must be the endpoint
107
+ if contexts.len() != 1 || first_ctx.contract != Self::endpoint(env) {
108
+ return Err(ExecutorError::UnauthorizedContext);
84
109
  }
85
- // Contract creation is not allowed
86
- Context::CreateContractHostFn(_) | Context::CreateContractWithCtorHostFn(_) => {
110
+ return Ok(());
111
+ }
112
+
113
+ // Execute path: lz_receive or lz_compose
114
+ if *first_fn_name != Symbol::new(env, "lz_receive") && *first_fn_name != Symbol::new(env, "lz_compose") {
115
+ return Err(ExecutorError::UnauthorizedContext);
116
+ }
117
+
118
+ let value = Self::extract_i128(env, first_ctx.args.last())?;
119
+ if value == 0 {
120
+ // If value is 0, there should be exactly 1 context
121
+ if contexts.len() != 1 {
87
122
  return Err(ExecutorError::UnauthorizedContext);
88
123
  }
124
+ return Ok(());
125
+ }
126
+
127
+ // value != 0: validate transfer context (only if there are 2 contexts)
128
+ if contexts.len() != 2 {
129
+ return Err(ExecutorError::UnauthorizedContext);
130
+ }
131
+
132
+ // Second context must be the transfer context
133
+ let Context::Contract(second_ctx) = contexts.get(1).unwrap() else {
134
+ return Err(ExecutorError::UnauthorizedContext);
135
+ };
136
+
137
+ let native_token = LayerZeroEndpointV2Client::new(env, &Self::endpoint(env)).native_token();
138
+ let transfer_amount = Self::extract_i128(env, second_ctx.args.get(2))?;
139
+
140
+ // Validate transfer context: must be transfer with matching value and native token contract
141
+ if second_ctx.fn_name != Symbol::new(env, "transfer")
142
+ || second_ctx.contract != native_token
143
+ || transfer_amount != value
144
+ {
145
+ return Err(ExecutorError::UnauthorizedContext);
89
146
  }
90
147
 
91
148
  Ok(())
92
149
  }
150
+
151
+ /// Extracts an i128 value from an optional Val.
152
+ #[inline]
153
+ fn extract_i128(env: &Env, val: Option<Val>) -> Result<i128, ExecutorError> {
154
+ let val = val.ok_or(ExecutorError::UnauthorizedContext)?;
155
+ i128::try_from_val(env, &val).map_err(|_| ExecutorError::UnauthorizedContext)
156
+ }
93
157
  }
@@ -5,29 +5,25 @@ use crate::{
5
5
  storage::ExecutorStorage,
6
6
  NativeDropParams,
7
7
  };
8
- use common_macros::{contract_impl, only_owner, ownable, ttl_configurable, upgradeable};
8
+ use common_macros::{contract_impl, lz_contract};
9
9
  use endpoint_v2::{FeeRecipient, LayerZeroEndpointV2Client, Origin};
10
10
  use message_lib_common::interfaces::ILayerZeroExecutor;
11
- use soroban_sdk::{contract, token::TokenClient, vec, Address, Bytes, BytesN, Env, Symbol, Vec};
12
- use utils::option_ext::OptionExt;
13
- use utils::upgradeable::UpgradeableInternal;
11
+ use soroban_sdk::{token::TokenClient, vec, Address, Bytes, BytesN, Env, Vec};
12
+ use utils::{option_ext::OptionExt, upgradeable::UpgradeableInternal};
14
13
  use worker::{
15
14
  assert_acl, assert_not_paused, assert_supported_message_lib, init_worker, require_admin_auth, set_admin_by_owner,
16
15
  ExecutorFeeLibClient, FeeParams, Worker,
17
16
  };
18
17
 
19
18
  /// LayerZero Executor contract for cross-chain message execution.
20
- #[contract]
21
- #[ttl_configurable]
22
- #[upgradeable]
23
- #[ownable]
19
+ #[lz_contract(upgradeable)]
24
20
  pub struct LzExecutor;
25
21
 
26
22
  #[contract_impl]
27
23
  impl LzExecutor {
28
24
  /// Initializes the executor contract.
29
25
  ///
30
- /// Sets up ownership, worker configuration, endpoint address, and whitelisted functions.
26
+ /// Sets up ownership, worker configuration, and endpoint address.
31
27
  ///
32
28
  /// # Arguments
33
29
  /// * `endpoint` - LayerZero Endpoint V2 contract address
@@ -36,7 +32,6 @@ impl LzExecutor {
36
32
  /// * `message_libs` - Supported message library addresses (e.g., ULN302)
37
33
  /// * `price_feed` - Price feed contract address for fee calculations
38
34
  /// * `default_multiplier_bps` - Default fee multiplier in basis points (10000 = 1x)
39
- /// * `whitelist` - Initial whitelisted (contract, function) pairs for authorization
40
35
  /// * `worker_fee_lib` - Worker fee library contract address
41
36
  /// * `deposit_address` - Address to receive fee payments
42
37
  pub fn __constructor(
@@ -47,7 +42,6 @@ impl LzExecutor {
47
42
  message_libs: &Vec<Address>,
48
43
  price_feed: &Address,
49
44
  default_multiplier_bps: u32,
50
- whitelist: &Vec<(Address, Symbol)>,
51
45
  worker_fee_lib: &Address,
52
46
  deposit_address: &Address,
53
47
  ) {
@@ -62,26 +56,6 @@ impl LzExecutor {
62
56
  deposit_address,
63
57
  );
64
58
  ExecutorStorage::set_endpoint(env, endpoint);
65
-
66
- // Set initial whitelisted functions
67
- for (contract, fn_name) in whitelist.iter() {
68
- ExecutorStorage::set_whitelisted_fn(env, &contract, &fn_name, &true);
69
- }
70
- }
71
-
72
- /// Sets whether a (contract, function) pair is whitelisted.
73
- /// When `allowed` is false, the entry is removed from storage to save space.
74
- ///
75
- /// Only the contract owner can call this function.
76
- #[only_owner]
77
- pub fn set_whitelisted_fn(env: &Env, contract: &Address, fn_name: &Symbol, allowed: bool) {
78
- let value = if allowed { Some(true) } else { None };
79
- ExecutorStorage::set_or_remove_whitelisted_fn(env, contract, fn_name, &value);
80
- }
81
-
82
- /// Returns whether a (contract, function) pair is whitelisted.
83
- pub fn is_whitelisted_fn(env: &Env, contract: &Address, fn_name: &Symbol) -> bool {
84
- ExecutorStorage::has_whitelisted_fn(env, contract, fn_name)
85
59
  }
86
60
 
87
61
  /// Withdraws a token from the contract to a specified address.
@@ -1,12 +1,12 @@
1
1
  use common_macros::storage;
2
- use soroban_sdk::{Address, Symbol};
2
+ use soroban_sdk::Address;
3
3
 
4
4
  use crate::DstConfig;
5
5
 
6
6
  /// Storage keys for the Executor contract.
7
7
  ///
8
8
  /// Manages persistent storage for destination configurations and instance storage
9
- /// for the endpoint address and whitelisted functions.
9
+ /// for the endpoint address.
10
10
  #[storage]
11
11
  pub enum ExecutorStorage {
12
12
  /// Destination chain configuration indexed by endpoint ID.
@@ -21,11 +21,4 @@ pub enum ExecutorStorage {
21
21
  /// Used for receive-flow operations to interact with the endpoint.
22
22
  #[instance(Address)]
23
23
  Endpoint,
24
-
25
- /// Whitelisted function for a specific contract.
26
- ///
27
- /// Only whitelisted (contract, function) pairs can trigger Executor authorization.
28
- /// This allows fine-grained control over which contracts can call which functions.
29
- #[instance(bool)]
30
- WhitelistedFn { contract: Address, fn_name: Symbol },
31
24
  }
@@ -6,7 +6,7 @@ license.workspace = true
6
6
  publish = false
7
7
 
8
8
  [lib]
9
- crate-type = ["cdylib"]
9
+ crate-type = ["cdylib", "rlib"]
10
10
  doctest = false
11
11
 
12
12
  [dependencies]
@@ -1,6 +1,6 @@
1
1
  use crate::{errors::ExecutorFeeLibError, executor_option};
2
- use common_macros::{contract_impl, ownable, ttl_configurable, upgradeable};
3
- use soroban_sdk::{assert_with_error, contract, Address, Bytes, Env};
2
+ use common_macros::{contract_impl, lz_contract};
3
+ use soroban_sdk::{assert_with_error, Address, Bytes, Env};
4
4
  use utils::upgradeable::UpgradeableInternal;
5
5
  use worker::{FeeParams, IExecutorFeeLib, LayerZeroPriceFeedClient};
6
6
 
@@ -25,10 +25,7 @@ const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
25
25
  /// Provides fee calculation logic based on executor options, destination configuration,
26
26
  /// and current gas prices from the price feed. Handles fee multipliers, margins, and
27
27
  /// native token value conversions.
28
- #[contract]
29
- #[ownable]
30
- #[ttl_configurable]
31
- #[upgradeable]
28
+ #[lz_contract(upgradeable)]
32
29
  pub struct ExecutorFeeLib;
33
30
 
34
31
  #[contract_impl]
@@ -6,7 +6,7 @@ license.workspace = true
6
6
  publish = false
7
7
 
8
8
  [lib]
9
- crate-type = ["cdylib"]
9
+ crate-type = ["cdylib", "rlib"]
10
10
  doctest = false
11
11
 
12
12
  [dependencies]
@@ -1,11 +1,11 @@
1
1
  //! ABA-safe entry point for cross-chain message execution on Stellar.
2
2
  //! Prevents reentry into the Executor during OApp Atomic Batch Actions.
3
3
 
4
+ use common_macros::contract_impl;
4
5
  use endpoint_v2::{
5
6
  LayerZeroComposerClient, LayerZeroEndpointV2Client, LayerZeroReceiverClient, MessagingComposerClient, Origin,
6
7
  };
7
8
  use executor::{ExecutorClient, NativeDropParams};
8
- use common_macros::contract_impl;
9
9
  use soroban_sdk::{contract, contracttype, token::TokenClient, Address, Bytes, BytesN, Env, Vec};
10
10
 
11
11
  /// Parameters for `lz_receive` execution.
@@ -40,28 +40,43 @@ pub struct ExecutorHelper;
40
40
 
41
41
  #[contract_impl]
42
42
  impl ExecutorHelper {
43
- /// Executes `lz_receive` on the target OApp; falls back to `lz_receive_alert` on failure.
43
+ /// Executes `lz_receive` on the target OApp
44
44
  pub fn execute(env: &Env, executor: &Address, params: &ExecutionParams, value_payer: &Address) {
45
- if params.value > 0 {
46
- value_payer.require_auth();
45
+ if params.value != 0 {
46
+ transfer_value(env, value_payer, executor, params.value);
47
47
  }
48
- Self::execute_internal(env, executor, params, value_payer);
48
+ LayerZeroReceiverClient::new(env, &params.receiver).lz_receive(
49
+ executor,
50
+ &params.origin,
51
+ &params.guid,
52
+ &params.message,
53
+ &params.extra_data,
54
+ &params.value,
55
+ );
49
56
  }
50
57
 
51
- /// Executes `lz_compose` on the target composer; falls back to `lz_compose_alert` on failure.
52
- pub fn compose(env: &Env, executor: &Address, params: &ComposeParams, value_payer: &Address) {
53
- executor.require_auth();
54
-
55
- let endpoint = if params.value > 0 {
56
- let ep = ExecutorClient::new(env, executor).endpoint();
57
- value_payer.require_auth();
58
- transfer_value(env, &ep, value_payer, executor, params.value);
59
- Some(ep)
60
- } else {
61
- None
62
- };
58
+ /// Records a failed `lz_receive` execution for off-chain processing.
59
+ pub fn lz_receive_alert(env: &Env, executor: &Address, params: &ExecutionParams, reason: &Bytes) {
60
+ let endpoint = ExecutorClient::new(env, executor).endpoint();
61
+ LayerZeroEndpointV2Client::new(env, &endpoint).lz_receive_alert(
62
+ executor,
63
+ &params.origin,
64
+ &params.receiver,
65
+ &params.guid,
66
+ &params.gas_limit,
67
+ &params.value,
68
+ &params.message,
69
+ &params.extra_data,
70
+ reason,
71
+ );
72
+ }
63
73
 
64
- let result = LayerZeroComposerClient::new(env, &params.to).try_lz_compose(
74
+ /// Executes `lz_compose` on the target composer
75
+ pub fn compose(env: &Env, executor: &Address, params: &ComposeParams, value_payer: &Address) {
76
+ if params.value != 0 {
77
+ transfer_value(env, value_payer, executor, params.value);
78
+ }
79
+ LayerZeroComposerClient::new(env, &params.to).lz_compose(
65
80
  executor,
66
81
  &params.from,
67
82
  &params.guid,
@@ -70,22 +85,23 @@ impl ExecutorHelper {
70
85
  &params.extra_data,
71
86
  &params.value,
72
87
  );
88
+ }
73
89
 
74
- if result.is_err() {
75
- let ep = endpoint.unwrap_or_else(|| ExecutorClient::new(env, executor).endpoint());
76
- MessagingComposerClient::new(env, &ep).lz_compose_alert(
77
- executor,
78
- &params.from,
79
- &params.to,
80
- &params.guid,
81
- &params.index,
82
- &params.gas_limit,
83
- &params.value,
84
- &params.message,
85
- &params.extra_data,
86
- &Bytes::new(env),
87
- );
88
- }
90
+ /// Records a failed `lz_compose` execution for off-chain processing.
91
+ pub fn lz_compose_alert(env: &Env, executor: &Address, params: &ComposeParams, reason: &Bytes) {
92
+ let endpoint = ExecutorClient::new(env, executor).endpoint();
93
+ MessagingComposerClient::new(env, &endpoint).lz_compose_alert(
94
+ executor,
95
+ &params.from,
96
+ &params.to,
97
+ &params.guid,
98
+ &params.index,
99
+ &params.gas_limit,
100
+ &params.value,
101
+ &params.message,
102
+ &params.extra_data,
103
+ reason,
104
+ );
89
105
  }
90
106
 
91
107
  /// Delegates `native_drop` to the executor contract.
@@ -98,7 +114,6 @@ impl ExecutorHelper {
98
114
  oapp: &Address,
99
115
  params: &Vec<NativeDropParams>,
100
116
  ) {
101
- admin.require_auth();
102
117
  ExecutorClient::new(env, executor).native_drop(admin, origin, &dst_eid, oapp, params);
103
118
  }
104
119
 
@@ -114,48 +129,13 @@ impl ExecutorHelper {
114
129
  execute_params: &ExecutionParams,
115
130
  ) {
116
131
  Self::native_drop(env, executor, admin, origin, dst_eid, oapp, native_drop_params);
117
- Self::execute_internal(env, executor, execute_params, admin); // admin already authed above
118
- }
119
-
120
- fn execute_internal(env: &Env, executor: &Address, params: &ExecutionParams, value_payer: &Address) {
121
- executor.require_auth();
122
-
123
- let endpoint = if params.value > 0 {
124
- let ep = ExecutorClient::new(env, executor).endpoint();
125
- transfer_value(env, &ep, value_payer, executor, params.value);
126
- Some(ep)
127
- } else {
128
- None
129
- };
130
-
131
- let result = LayerZeroReceiverClient::new(env, &params.receiver).try_lz_receive(
132
- executor,
133
- &params.origin,
134
- &params.guid,
135
- &params.message,
136
- &params.extra_data,
137
- &params.value,
138
- );
139
-
140
- if result.is_err() {
141
- let ep = endpoint.unwrap_or_else(|| ExecutorClient::new(env, executor).endpoint());
142
- LayerZeroEndpointV2Client::new(env, &ep).lz_receive_alert(
143
- executor,
144
- &params.origin,
145
- &params.receiver,
146
- &params.guid,
147
- &params.gas_limit,
148
- &params.value,
149
- &params.message,
150
- &params.extra_data,
151
- &Bytes::new(env),
152
- );
153
- }
132
+ Self::execute(env, executor, execute_params, admin);
154
133
  }
155
134
  }
156
135
 
157
136
  #[inline]
158
- fn transfer_value(env: &Env, endpoint: &Address, payer: &Address, executor: &Address, value: i128) {
159
- let native_token = LayerZeroEndpointV2Client::new(env, endpoint).native_token();
137
+ fn transfer_value(env: &Env, payer: &Address, executor: &Address, value: i128) {
138
+ let endpoint = ExecutorClient::new(env, executor).endpoint();
139
+ let native_token = LayerZeroEndpointV2Client::new(env, &endpoint).native_token();
160
140
  TokenClient::new(env, &native_token).transfer(payer, executor, &value);
161
141
  }
@@ -6,7 +6,7 @@ license.workspace = true
6
6
  publish = false
7
7
 
8
8
  [lib]
9
- crate-type = ["cdylib"]
9
+ crate-type = ["cdylib", "rlib"]
10
10
  doctest = false
11
11
 
12
12
  [dependencies]