@layerzerolabs/protocol-stellar-v2 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/.turbo/turbo-build.log +275 -248
  2. package/.turbo/turbo-lint.log +52 -58
  3. package/.turbo/turbo-test.log +1224 -1358
  4. package/Cargo.lock +8 -5
  5. package/Cargo.toml +1 -1
  6. package/contracts/ERROR_SPEC.md +1 -1
  7. package/contracts/message-libs/uln-302/src/send_uln.rs +1 -1
  8. package/contracts/oapps/oapp/src/oapp_receiver.rs +1 -1
  9. package/contracts/oapps/oft/Cargo.toml +10 -7
  10. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_oft_fee.rs +3 -4
  11. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_pausable.rs +2 -3
  12. package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/test_rate_limiter.rs +1 -1
  13. package/contracts/oapps/oft/integration-tests/mod.rs +1 -1
  14. package/contracts/oapps/oft/integration-tests/setup.rs +28 -127
  15. package/contracts/oapps/oft/integration-tests/utils.rs +254 -21
  16. package/contracts/oapps/oft/src/extensions/oft_fee.rs +5 -6
  17. package/contracts/oapps/oft/src/lib.rs +10 -14
  18. package/contracts/oapps/oft/src/oft.rs +151 -189
  19. package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +9 -11
  20. package/contracts/oapps/oft/src/oft_types/mint_burn.rs +32 -12
  21. package/contracts/oapps/oft/src/oft_types/mod.rs +13 -0
  22. package/contracts/oapps/{oft-std → oft-core}/Cargo.toml +6 -4
  23. package/contracts/oapps/{oft-std → oft-core}/integration-tests/mod.rs +1 -1
  24. package/contracts/oapps/{oft-std → oft-core}/integration-tests/setup.rs +126 -29
  25. package/contracts/oapps/{oft → oft-core}/integration-tests/test_with_sml.rs +3 -3
  26. package/contracts/oapps/oft-core/integration-tests/utils.rs +201 -0
  27. package/contracts/oapps/oft-core/src/lib.rs +18 -0
  28. package/contracts/oapps/oft-core/src/oft_core.rs +439 -0
  29. package/contracts/oapps/{oft → oft-core}/src/tests/mod.rs +0 -2
  30. package/contracts/oapps/{oft → oft-core}/src/tests/test_lz_receive.rs +7 -7
  31. package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_msg_codec.rs +4 -4
  32. package/contracts/oapps/{oft → oft-core}/src/tests/test_resolve_address.rs +3 -3
  33. package/contracts/oapps/{oft → oft-core}/src/tests/test_utils.rs +44 -25
  34. package/contracts/oapps/{oft → oft-core}/src/utils.rs +1 -1
  35. package/contracts/utils/src/errors.rs +5 -1
  36. package/contracts/utils/src/ownable.rs +125 -3
  37. package/contracts/utils/src/tests/option_ext.rs +1 -1
  38. package/contracts/utils/src/tests/ownable.rs +445 -7
  39. package/contracts/utils/src/tests/ttl_configurable.rs +2 -2
  40. package/package.json +4 -5
  41. package/sdk/.turbo/turbo-test.log +216 -206
  42. package/sdk/dist/generated/bml.d.ts +30 -0
  43. package/sdk/dist/generated/bml.js +28 -5
  44. package/sdk/dist/generated/counter.d.ts +122 -2
  45. package/sdk/dist/generated/counter.js +36 -7
  46. package/sdk/dist/generated/dvn.d.ts +30 -0
  47. package/sdk/dist/generated/dvn.js +28 -5
  48. package/sdk/dist/generated/dvn_fee_lib.d.ts +122 -2
  49. package/sdk/dist/generated/dvn_fee_lib.js +36 -7
  50. package/sdk/dist/generated/endpoint.d.ts +122 -2
  51. package/sdk/dist/generated/endpoint.js +36 -7
  52. package/sdk/dist/generated/executor.d.ts +122 -2
  53. package/sdk/dist/generated/executor.js +36 -7
  54. package/sdk/dist/generated/executor_fee_lib.d.ts +122 -2
  55. package/sdk/dist/generated/executor_fee_lib.js +36 -7
  56. package/sdk/dist/generated/executor_helper.d.ts +30 -0
  57. package/sdk/dist/generated/executor_helper.js +28 -5
  58. package/sdk/dist/generated/oft.d.ts +1842 -0
  59. package/sdk/dist/generated/oft.js +345 -0
  60. package/sdk/dist/generated/price_feed.d.ts +122 -2
  61. package/sdk/dist/generated/price_feed.js +36 -7
  62. package/sdk/dist/generated/sml.d.ts +122 -2
  63. package/sdk/dist/generated/sml.js +36 -7
  64. package/sdk/dist/generated/treasury.d.ts +122 -2
  65. package/sdk/dist/generated/treasury.js +36 -7
  66. package/sdk/dist/generated/uln302.d.ts +122 -2
  67. package/sdk/dist/generated/uln302.js +36 -7
  68. package/sdk/dist/generated/upgrader.d.ts +15 -0
  69. package/sdk/dist/generated/upgrader.js +18 -0
  70. package/sdk/dist/index.d.ts +1 -2
  71. package/sdk/dist/index.js +1 -3
  72. package/sdk/package.json +3 -2
  73. package/sdk/src/index.ts +1 -4
  74. package/sdk/test/oft-sml.test.ts +16 -16
  75. package/sdk/turbo.json +8 -0
  76. package/tools/ts-bindings-gen/Cargo.toml +2 -0
  77. package/tools/ts-bindings-gen/src/main.rs +51 -4
  78. package/turbo.json +0 -2
  79. package/contracts/oapps/oft/src/interfaces/mint_burn_token.rs +0 -23
  80. package/contracts/oapps/oft/src/interfaces/mod.rs +0 -3
  81. package/contracts/oapps/oft/src/oft_impl.rs +0 -201
  82. package/contracts/oapps/oft/src/tests/extensions/mod.rs +0 -11
  83. package/contracts/oapps/oft/src/tests/extensions/setup.rs +0 -917
  84. package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +0 -751
  85. package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +0 -434
  86. package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +0 -1080
  87. package/contracts/oapps/oft-std/integration-tests/utils.rs +0 -427
  88. package/contracts/oapps/oft-std/src/lib.rs +0 -16
  89. package/contracts/oapps/oft-std/src/oft.rs +0 -174
  90. package/sdk/dist/generated/oft_std.d.ts +0 -1722
  91. package/sdk/dist/generated/oft_std.js +0 -316
  92. package/sdk/dist/wasm/blocked-message-lib.d.ts +0 -1
  93. package/sdk/dist/wasm/blocked-message-lib.js +0 -2
  94. package/sdk/dist/wasm/counter.d.ts +0 -1
  95. package/sdk/dist/wasm/counter.js +0 -2
  96. package/sdk/dist/wasm/dvn-fee-lib.d.ts +0 -1
  97. package/sdk/dist/wasm/dvn-fee-lib.js +0 -2
  98. package/sdk/dist/wasm/dvn.d.ts +0 -1
  99. package/sdk/dist/wasm/dvn.js +0 -2
  100. package/sdk/dist/wasm/endpoint-v2.d.ts +0 -1
  101. package/sdk/dist/wasm/endpoint-v2.js +0 -2
  102. package/sdk/dist/wasm/executor-fee-lib.d.ts +0 -1
  103. package/sdk/dist/wasm/executor-fee-lib.js +0 -2
  104. package/sdk/dist/wasm/executor-helper.d.ts +0 -1
  105. package/sdk/dist/wasm/executor-helper.js +0 -2
  106. package/sdk/dist/wasm/executor.d.ts +0 -1
  107. package/sdk/dist/wasm/executor.js +0 -2
  108. package/sdk/dist/wasm/layerzero-views.d.ts +0 -1
  109. package/sdk/dist/wasm/layerzero-views.js +0 -2
  110. package/sdk/dist/wasm/oft-std.d.ts +0 -1
  111. package/sdk/dist/wasm/oft-std.js +0 -2
  112. package/sdk/dist/wasm/price-feed.d.ts +0 -1
  113. package/sdk/dist/wasm/price-feed.js +0 -2
  114. package/sdk/dist/wasm/simple-message-lib.d.ts +0 -1
  115. package/sdk/dist/wasm/simple-message-lib.js +0 -2
  116. package/sdk/dist/wasm/treasury.d.ts +0 -1
  117. package/sdk/dist/wasm/treasury.js +0 -2
  118. package/sdk/dist/wasm/uln302.d.ts +0 -1
  119. package/sdk/dist/wasm/uln302.js +0 -2
  120. package/sdk/dist/wasm/upgrader.d.ts +0 -1
  121. package/sdk/dist/wasm/upgrader.js +0 -2
  122. package/sdk/dist/wasm.d.ts +0 -15
  123. package/sdk/dist/wasm.js +0 -15
  124. /package/contracts/oapps/{oft-std → oft}/integration-tests/extensions/mod.rs +0 -0
  125. /package/contracts/oapps/{oft → oft-core}/src/codec/mod.rs +0 -0
  126. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_compose_msg_codec.rs +0 -0
  127. /package/contracts/oapps/{oft → oft-core}/src/codec/oft_msg_codec.rs +0 -0
  128. /package/contracts/oapps/{oft → oft-core}/src/errors.rs +0 -0
  129. /package/contracts/oapps/{oft → oft-core}/src/events.rs +0 -0
  130. /package/contracts/oapps/{oft → oft-core}/src/storage.rs +0 -0
  131. /package/contracts/oapps/{oft → oft-core}/src/tests/test_decimals.rs +0 -0
  132. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_compose_msg_codec.rs +0 -0
  133. /package/contracts/oapps/{oft → oft-core}/src/tests/test_oft_version.rs +0 -0
  134. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_oft.rs +0 -0
  135. /package/contracts/oapps/{oft → oft-core}/src/tests/test_quote_send.rs +0 -0
  136. /package/contracts/oapps/{oft → oft-core}/src/tests/test_send.rs +0 -0
  137. /package/contracts/oapps/{oft → oft-core}/src/tests/test_token.rs +0 -0
  138. /package/contracts/oapps/{oft → oft-core}/src/types.rs +0 -0
package/Cargo.lock CHANGED
@@ -1199,31 +1199,32 @@ version = "0.0.1"
1199
1199
  name = "oft"
1200
1200
  version = "0.0.1"
1201
1201
  dependencies = [
1202
+ "cfg-if",
1202
1203
  "common-macros",
1203
1204
  "endpoint-v2",
1204
- "insta",
1205
1205
  "message-lib-common",
1206
1206
  "oapp",
1207
1207
  "oapp-macros",
1208
+ "oft-core",
1208
1209
  "simple-message-lib",
1209
1210
  "soroban-sdk",
1210
- "stellar-macros",
1211
- "stellar-tokens",
1212
1211
  "utils",
1213
1212
  ]
1214
1213
 
1215
1214
  [[package]]
1216
- name = "oft-std"
1215
+ name = "oft-core"
1217
1216
  version = "0.0.1"
1218
1217
  dependencies = [
1219
1218
  "common-macros",
1220
1219
  "endpoint-v2",
1220
+ "insta",
1221
1221
  "message-lib-common",
1222
1222
  "oapp",
1223
1223
  "oapp-macros",
1224
- "oft",
1225
1224
  "simple-message-lib",
1226
1225
  "soroban-sdk",
1226
+ "stellar-macros",
1227
+ "stellar-tokens",
1227
1228
  "utils",
1228
1229
  ]
1229
1230
 
@@ -2094,6 +2095,8 @@ name = "ts-bindings-gen"
2094
2095
  version = "0.0.1"
2095
2096
  dependencies = [
2096
2097
  "anyhow",
2098
+ "base64 0.22.1",
2099
+ "sha2 0.10.9",
2097
2100
  "soroban-spec-typescript",
2098
2101
  ]
2099
2102
 
package/Cargo.toml CHANGED
@@ -33,7 +33,7 @@ executor-fee-lib = { path = "contracts/workers/executor-fee-lib" }
33
33
  dvn = { path = "contracts/workers/dvn" }
34
34
  dvn-fee-lib = { path = "contracts/workers/dvn-fee-lib" }
35
35
  price-feed = { path = "contracts/workers/price-feed" }
36
- oft = { path = "contracts/oapps/oft" }
36
+ oft-core = { path = "contracts/oapps/oft-core" }
37
37
  stellar-macros = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
38
38
  stellar-tokens = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
39
39
  stellar-contract-utils = { git = "https://github.com/OpenZeppelin/stellar-contracts.git", tag = "v0.5.1" }
@@ -38,7 +38,7 @@ Each library has a unique error code range to:
38
38
  | 1300 - 1999 | Protocol Lib | (reserved) | Future protocol libs |
39
39
  | 2000 - 2099 | OApp Lib | oapp | `oapps/oapp/src/errors.rs` |
40
40
  | 2100 - 2999 | OApp Lib | (reserved) | Future OApp libs |
41
- | 3000 - 3099 | OFT Lib | oft | `oapps/oft/src/errors.rs` |
41
+ | 3000 - 3099 | OFT Lib | oft-core | `oapps/oft-core/src/errors.rs` |
42
42
  | 3100 - 3999 | OFT Lib | (reserved) | Future OFT libs |
43
43
 
44
44
  ---
@@ -86,7 +86,7 @@ impl ISendLib for Uln302 {
86
86
 
87
87
  // Handle ZRO fee recipients
88
88
  let mut zro_fee_recipients = vec![env];
89
- if treasury_fee > 0 {
89
+ if treasury_fee != 0 {
90
90
  // The treasury contract address is used as the fixed fee recipient (rather than allowing
91
91
  // the treasury admin to configure a custom receiver). This is because ZRO may be issued
92
92
  // as a Stellar Classic Asset, which requires the recipient to have an established trustline.
@@ -171,7 +171,7 @@ pub fn clear_payload_and_transfer<T: OAppCore>(
171
171
 
172
172
  // Require authorization from the executor and transfer the value from the executor to the oapp if has value
173
173
  executor.require_auth();
174
- if value > 0 {
174
+ if value != 0 {
175
175
  let token_client = TokenClient::new(env, &endpoint_client.native_token());
176
176
  token_client.transfer(executor, &this_address, &value);
177
177
  }
@@ -5,15 +5,22 @@ edition.workspace = true
5
5
  license.workspace = true
6
6
 
7
7
  [lib]
8
- crate-type = ["rlib"]
8
+ crate-type = ["cdylib", "rlib"]
9
9
  doctest = false
10
10
 
11
+ [features]
12
+ library = []
13
+ testutils = []
14
+
11
15
  [dependencies]
12
16
  soroban-sdk = { workspace = true }
13
- endpoint-v2 = { workspace = true, features = ["library"] }
17
+ cfg-if = { workspace = true }
14
18
  utils = { workspace = true }
15
- oapp = { workspace = true }
16
19
  common-macros = { workspace = true }
20
+ endpoint-v2 = { workspace = true, features = ["library"] }
21
+ oapp = { workspace = true }
22
+ oapp-macros = { workspace = true }
23
+ oft-core = { workspace = true }
17
24
 
18
25
  [dev-dependencies]
19
26
  soroban-sdk = { workspace = true, features = ["testutils"] }
@@ -21,7 +28,3 @@ simple-message-lib = { workspace = true }
21
28
  message-lib-common = { workspace = true, features = ["testutils"] }
22
29
  endpoint-v2 = { workspace = true, features = ["testutils"] }
23
30
  utils = { workspace = true, features = ["testutils"] }
24
- insta = { workspace = true }
25
- oapp-macros = { workspace = true }
26
- stellar-macros = { workspace = true }
27
- stellar-tokens = { workspace = true }
@@ -8,10 +8,9 @@
8
8
  use crate::integration_tests::{
9
9
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
10
10
  utils::{
11
- address_to_peer_bytes32, create_send_param, lz_receive, mint_to,
12
- quote_oft, quote_send, scan_packet_sent_event, send, send_with_fee,
13
- set_default_fee_bps, set_fee_bps, set_fee_deposit_address, token_balance,
14
- transfer_sac_admin, validate_packet,
11
+ address_to_peer_bytes32, create_send_param, lz_receive, mint_to, quote_oft, quote_send,
12
+ scan_packet_sent_event, send, send_with_fee, set_default_fee_bps, set_fee_bps, set_fee_deposit_address,
13
+ token_balance, transfer_sac_admin, validate_packet,
15
14
  },
16
15
  };
17
16
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
@@ -6,9 +6,8 @@
6
6
  use crate::integration_tests::{
7
7
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
8
8
  utils::{
9
- address_to_peer_bytes32, create_send_param, is_paused, lz_receive, mint_to,
10
- quote_oft, quote_send, scan_packet_sent_event, send, set_paused, transfer_sac_admin,
11
- try_lz_receive, try_send, validate_packet,
9
+ address_to_peer_bytes32, create_send_param, is_paused, lz_receive, mint_to, quote_oft, quote_send,
10
+ scan_packet_sent_event, send, set_paused, transfer_sac_admin, try_lz_receive, try_send, validate_packet,
12
11
  },
13
12
  };
14
13
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
@@ -3,6 +3,7 @@
3
3
  //! Tests verify that the RateLimiter extension properly enforces rate limits
4
4
  //! on cross-chain transfers. Uses real EndpointV2 and SimpleMessageLib.
5
5
 
6
+ use crate::extensions::rate_limiter::Direction;
6
7
  use crate::integration_tests::{
7
8
  setup::{create_recipient_address, decode_packet, setup, wire_endpoint, wire_oft, TestSetup},
8
9
  utils::{
@@ -11,7 +12,6 @@ use crate::integration_tests::{
11
12
  try_send, validate_packet,
12
13
  },
13
14
  };
14
- use oft::extensions::rate_limiter::Direction;
15
15
  use soroban_sdk::{testutils::Address as _, token::TokenClient, Address};
16
16
 
17
17
  /// Test e2e send without rate limit (default - unlimited)
@@ -1,3 +1,3 @@
1
+ pub mod extensions;
1
2
  pub mod setup;
2
- pub mod test_with_sml;
3
3
  pub mod utils;
@@ -1,141 +1,39 @@
1
- //! Integration test setup for OFT.
1
+ //! Integration test setup for OFT-STD with real EndpointV2 and SimpleMessageLib.
2
2
  //!
3
- //! This file contains TestOFT contract and test setup utilities.
3
+ //! This file contains test setup utilities for OFT-STD with all extensions enabled.
4
4
 
5
- extern crate self as oft;
6
5
  extern crate std;
7
6
 
8
- use crate::integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address};
9
- use common_macros::contract_impl;
10
- use endpoint_v2::{EndpointV2, EndpointV2Client, ILayerZeroComposer, Origin};
11
- use oapp::oapp_receiver::LzReceiveInternal;
12
- use oft::{
13
- initialize_oft,
14
- oft::{OFTClient, OFTInternal, OFT},
15
- oft_impl,
16
- storage::OFTStorage,
17
- types::OFTReceipt,
7
+ use crate::{
8
+ integration_tests::utils::{address_to_peer_bytes32, peer_bytes32_to_address},
9
+ oft::{OFTClient, OFT},
10
+ oft_types::OftType,
18
11
  };
12
+ use endpoint_v2::{EndpointV2, EndpointV2Client};
19
13
  use simple_message_lib::{SimpleMessageLib, SimpleMessageLibClient};
20
14
  use soroban_sdk::{
21
- contract, contractimpl, contracttype, log, symbol_short,
15
+ contract, contractimpl, log,
22
16
  testutils::{Address as _, MockAuth, MockAuthInvoke},
23
- token::{StellarAssetClient, TokenClient},
24
- Address, Bytes, BytesN, Env, IntoVal,
17
+ token::TokenClient,
18
+ Address, BytesN, Env, IntoVal,
25
19
  };
26
20
 
27
21
  // ============================================================================
28
- // Test OFT Contract
22
+ // Dummy Recipient - used to create valid contract addresses for recipients
29
23
  // ============================================================================
30
24
 
31
- #[oapp_macros::oapp]
32
- pub struct TestOFT;
33
-
34
- impl LzReceiveInternal for TestOFT {
35
- fn __lz_receive(
36
- env: &Env,
37
- origin: &Origin,
38
- guid: &BytesN<32>,
39
- message: &Bytes,
40
- extra_data: &Bytes,
41
- executor: &Address,
42
- value: i128,
43
- ) {
44
- oft_impl::lz_receive::<Self>(env, executor, origin, guid, message, extra_data, value)
45
- }
46
- }
47
-
48
- #[contract_impl]
49
- impl TestOFT {
50
- pub fn __constructor(
51
- env: &Env,
52
- token: &Address,
53
- owner: &Address,
54
- endpoint: &Address,
55
- delegate: &Option<Address>,
56
- shared_decimals: u32,
57
- ) {
58
- initialize_oft::<Self>(env, owner, token, endpoint, delegate, shared_decimals)
59
- }
60
- }
61
-
62
- #[contractimpl(contracttrait)]
63
- impl OFT for TestOFT {}
64
-
65
- impl OFTInternal for TestOFT {
66
- fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
67
- // Get the receipt (handles decimal conversion, fees, etc.)
68
- let receipt = Self::__debit_view(env, amount_ld, min_amount_ld, dst_eid);
69
- // Actually burn tokens from sender
70
- StellarAssetClient::new(env, &OFTStorage::token(env).unwrap()).burn(sender, &receipt.amount_sent_ld);
71
- receipt
72
- }
73
-
74
- fn __credit(env: &Env, to: &Address, amount_ld: i128, _src_eid: u32) -> i128 {
75
- // Actually mint tokens to recipient
76
- StellarAssetClient::new(env, &OFTStorage::token(env).unwrap()).mint(to, &amount_ld);
77
- amount_ld
78
- }
79
- }
80
-
81
- // ============================================================================
82
- // Dummy Composer for testing compose messages
83
- // ============================================================================
84
-
85
- #[contracttype]
86
- pub struct ComposeMessage {
87
- pub executor: Address,
88
- pub from: Address,
89
- pub guid: BytesN<32>,
90
- pub index: u32,
91
- pub message: Bytes,
92
- pub extra_data: Bytes,
93
- pub value: i128,
94
- }
95
-
96
25
  #[contract]
97
- pub struct DummyComposer;
26
+ pub struct DummyRecipient;
98
27
 
99
- #[contract_impl]
100
- impl DummyComposer {
101
- pub fn __constructor(env: &Env, endpoint: &Address) {
102
- env.storage().instance().set(&symbol_short!("endpoint"), endpoint);
103
- }
104
-
105
- pub fn compose_message(env: &Env) -> Option<ComposeMessage> {
106
- env.storage().instance().get(&symbol_short!("msg"))
107
- }
28
+ #[contractimpl]
29
+ impl DummyRecipient {
30
+ pub fn __constructor(_env: &Env) {}
108
31
  }
109
32
 
110
- #[contract_impl]
111
- impl ILayerZeroComposer for DummyComposer {
112
- fn lz_compose(
113
- env: &Env,
114
- executor: &Address,
115
- from: &Address,
116
- guid: &BytesN<32>,
117
- index: u32,
118
- message: &Bytes,
119
- extra_data: &Bytes,
120
- value: i128,
121
- ) {
122
- let endpoint_address: Address = env.storage().instance().get(&symbol_short!("endpoint")).unwrap();
123
- let endpoint = endpoint_v2::MessagingComposerClient::new(env, &endpoint_address);
124
- endpoint.clear_compose(&env.current_contract_address(), from, guid, &index, message);
125
-
126
- env.storage().instance().set(
127
- &symbol_short!("msg"),
128
- &ComposeMessage {
129
- executor: executor.clone(),
130
- from: from.clone(),
131
- guid: guid.clone(),
132
- index,
133
- message: message.clone(),
134
- extra_data: extra_data.clone(),
135
- value,
136
- },
137
- );
138
- }
33
+ /// Creates a valid recipient address by deploying a dummy contract.
34
+ /// Use this in tests when the address needs to pass the `.exists()` check.
35
+ pub fn create_recipient_address(env: &Env) -> Address {
36
+ env.register(DummyRecipient, ())
139
37
  }
140
38
 
141
39
  // ============================================================================
@@ -146,16 +44,16 @@ pub struct ChainSetup<'a> {
146
44
  pub eid: u32,
147
45
  pub owner: Address,
148
46
  pub native_token: Address,
47
+ pub zro_token: Address,
149
48
  pub oft_token: Address,
150
49
  pub endpoint: EndpointV2Client<'a>,
151
50
  pub sml: SimpleMessageLibClient<'a>,
152
51
  pub oft: OFTClient<'a>,
153
- pub composer: DummyComposerClient<'a>,
52
+ pub fee_collector: Address,
154
53
  }
155
54
 
156
55
  pub struct TestSetup<'a> {
157
56
  pub env: Env,
158
-
159
57
  pub chain_a: ChainSetup<'a>,
160
58
  pub chain_b: ChainSetup<'a>,
161
59
  }
@@ -163,9 +61,13 @@ pub struct TestSetup<'a> {
163
61
  fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
164
62
  let owner = Address::generate(env);
165
63
 
64
+ // Create native token FIRST - this must match the endpoint's NATIVE_TOKEN constant
166
65
  let sac = env.register_stellar_asset_contract_v2(owner.clone());
167
66
  let native_token = sac.address();
168
67
 
68
+ // Generate fee_collector AFTER native_token to not affect the address derivation
69
+ let fee_collector = Address::generate(env);
70
+
169
71
  // Create ZRO token
170
72
  let zro_sac = env.register_stellar_asset_contract_v2(owner.clone());
171
73
  let zro_token = zro_sac.address();
@@ -179,13 +81,12 @@ fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
179
81
  let sml_address = env.register(SimpleMessageLib, (&owner, &endpoint_address, &fee_recipient));
180
82
  let delegate: Option<Address> = Some(owner.clone());
181
83
  let shared_decimals: u32 = 6; // Default shared decimals
182
- let oft_address = env.register(TestOFT, (&oft_token, &owner, &endpoint_address, &delegate, &shared_decimals));
183
- let composer_address = env.register(DummyComposer, (&endpoint_address,));
84
+ let mode = OftType::MintBurn;
85
+ let oft_address = env.register(OFT, (&oft_token, &owner, &endpoint_address, &delegate, &shared_decimals, &mode));
184
86
 
185
87
  let endpoint = EndpointV2Client::new(env, &endpoint_address);
186
88
  let sml = SimpleMessageLibClient::new(env, &sml_address);
187
89
  let oft = OFTClient::new(env, &oft_address);
188
- let composer = DummyComposerClient::new(env, &composer_address);
189
90
 
190
91
  // Set ZRO token in endpoint
191
92
  env.mock_auths(&[MockAuth {
@@ -202,7 +103,7 @@ fn setup_chain<'a>(env: &Env) -> ChainSetup<'a> {
202
103
  register_library(env, &owner, &endpoint, &sml.address);
203
104
 
204
105
  let eid = endpoint.eid();
205
- ChainSetup { eid, owner, native_token, oft_token, endpoint, sml, oft, composer }
106
+ ChainSetup { eid, owner, native_token, zro_token, oft_token, endpoint, sml, oft, fee_collector }
206
107
  }
207
108
 
208
109
  pub fn setup<'a>() -> TestSetup<'a> {