@layerzerolabs/protocol-stellar-v2 0.2.64 → 0.2.66

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 (48) hide show
  1. package/.turbo/turbo-build.log +230 -307
  2. package/.turbo/turbo-lint.log +175 -175
  3. package/.turbo/turbo-test.log +2047 -1975
  4. package/Cargo.lock +0 -16
  5. package/Cargo.toml +0 -1
  6. package/contracts/oapps/oft/integration-tests/extensions/test_oft_fee.rs +22 -0
  7. package/contracts/oapps/oft/integration-tests/extensions/test_pausable.rs +9 -2
  8. package/contracts/oapps/oft/integration-tests/extensions/test_rate_limiter.rs +27 -2
  9. package/contracts/oapps/oft/integration-tests/setup.rs +22 -18
  10. package/contracts/oapps/oft/integration-tests/utils.rs +81 -34
  11. package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -0
  12. package/contracts/oapps/oft/src/oft.rs +10 -2
  13. package/package.json +5 -5
  14. package/sdk/.turbo/turbo-test.log +284 -291
  15. package/sdk/dist/generated/oft.d.ts +3 -3
  16. package/sdk/dist/generated/oft.js +3 -3
  17. package/sdk/node_modules/.bin/vitest +2 -2
  18. package/sdk/package.json +2 -2
  19. package/contracts/oapps/console-oft/Cargo.toml +0 -30
  20. package/contracts/oapps/console-oft/integration-tests/extensions/mod.rs +0 -5
  21. package/contracts/oapps/console-oft/integration-tests/extensions/test_combined.rs +0 -90
  22. package/contracts/oapps/console-oft/integration-tests/extensions/test_oft_fee.rs +0 -186
  23. package/contracts/oapps/console-oft/integration-tests/extensions/test_ownership.rs +0 -161
  24. package/contracts/oapps/console-oft/integration-tests/extensions/test_pausable.rs +0 -154
  25. package/contracts/oapps/console-oft/integration-tests/extensions/test_rate_limiter.rs +0 -479
  26. package/contracts/oapps/console-oft/integration-tests/mod.rs +0 -3
  27. package/contracts/oapps/console-oft/integration-tests/setup.rs +0 -303
  28. package/contracts/oapps/console-oft/integration-tests/utils.rs +0 -685
  29. package/contracts/oapps/console-oft/src/errors.rs +0 -7
  30. package/contracts/oapps/console-oft/src/extensions/mod.rs +0 -3
  31. package/contracts/oapps/console-oft/src/extensions/oft_fee.rs +0 -239
  32. package/contracts/oapps/console-oft/src/extensions/pausable.rs +0 -185
  33. package/contracts/oapps/console-oft/src/extensions/rate_limiter.rs +0 -478
  34. package/contracts/oapps/console-oft/src/interfaces/mintable.rs +0 -14
  35. package/contracts/oapps/console-oft/src/interfaces/mod.rs +0 -3
  36. package/contracts/oapps/console-oft/src/lib.rs +0 -26
  37. package/contracts/oapps/console-oft/src/oft.rs +0 -208
  38. package/contracts/oapps/console-oft/src/oft_access_control.rs +0 -93
  39. package/contracts/oapps/console-oft/src/oft_types/lock_unlock.rs +0 -50
  40. package/contracts/oapps/console-oft/src/oft_types/mint_burn.rs +0 -50
  41. package/contracts/oapps/console-oft/src/oft_types/mod.rs +0 -24
  42. package/contracts/oapps/console-oft/src/tests/extensions/mod.rs +0 -3
  43. package/contracts/oapps/console-oft/src/tests/extensions/oft_fee.rs +0 -255
  44. package/contracts/oapps/console-oft/src/tests/extensions/pausable.rs +0 -212
  45. package/contracts/oapps/console-oft/src/tests/extensions/rate_limiter.rs +0 -992
  46. package/contracts/oapps/console-oft/src/tests/mod.rs +0 -2
  47. package/contracts/oapps/console-oft/src/tests/oft_types/lock_unlock.rs +0 -185
  48. package/contracts/oapps/console-oft/src/tests/oft_types/mod.rs +0 -1
@@ -1,2 +0,0 @@
1
- mod extensions;
2
- mod oft_types;
@@ -1,185 +0,0 @@
1
- extern crate std;
2
-
3
- use crate::oft_types::lock_unlock;
4
- use endpoint_v2::Origin;
5
- use oapp::oapp_receiver::{LzReceiveInternal, OAppReceiver};
6
- use oft_core::{OFTCore, OFTInternal, OFTReceipt};
7
- use soroban_sdk::{
8
- contract, contractimpl, contracttype,
9
- testutils::Address as _,
10
- token::{StellarAssetClient, TokenClient},
11
- Address, Bytes, BytesN, Env,
12
- };
13
-
14
- // ============================================================================
15
- // Mock Contracts
16
- // ============================================================================
17
-
18
- #[contract]
19
- struct DummyEndpoint;
20
-
21
- #[derive(Clone)]
22
- #[contracttype]
23
- enum DummyEndpointDataKey {
24
- Delegate(Address),
25
- }
26
-
27
- #[contractimpl]
28
- impl DummyEndpoint {
29
- pub fn set_delegate(env: Env, oapp: &Address, delegate: &Option<Address>) {
30
- let key = DummyEndpointDataKey::Delegate(oapp.clone());
31
- match delegate {
32
- Some(d) => env.storage().persistent().set(&key, d),
33
- None => env.storage().persistent().remove(&key),
34
- }
35
- }
36
- }
37
-
38
- // ============================================================================
39
- // LockUnlock OFT Harness Contract
40
- // ============================================================================
41
-
42
- #[common_macros::lz_contract]
43
- #[oapp_macros::oapp(custom = [receiver])]
44
- pub struct LockUnlockHarnessOFT;
45
-
46
- #[contractimpl]
47
- impl LockUnlockHarnessOFT {
48
- pub fn __constructor(
49
- env: &Env,
50
- token: &Address,
51
- owner: &Address,
52
- endpoint: &Address,
53
- delegate: &Address,
54
- shared_decimals: u32,
55
- ) {
56
- Self::__initialize_oft(env, token, shared_decimals, owner, endpoint, delegate);
57
- }
58
-
59
- pub fn debit(env: Env, sender: Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> OFTReceipt {
60
- let (amount_sent_ld, amount_received_ld) =
61
- <Self as OFTInternal>::__debit(&env, &sender, amount_ld, min_amount_ld, dst_eid);
62
- OFTReceipt { amount_sent_ld, amount_received_ld }
63
- }
64
-
65
- pub fn credit(env: Env, to: Address, amount_ld: i128, src_eid: u32) -> i128 {
66
- <Self as OFTInternal>::__credit(&env, &to, amount_ld, src_eid)
67
- }
68
- }
69
-
70
- #[contractimpl(contracttrait)]
71
- impl OFTCore for LockUnlockHarnessOFT {}
72
-
73
- impl LzReceiveInternal for LockUnlockHarnessOFT {
74
- fn __lz_receive(
75
- env: &Env,
76
- origin: &Origin,
77
- guid: &BytesN<32>,
78
- message: &Bytes,
79
- extra_data: &Bytes,
80
- executor: &Address,
81
- value: i128,
82
- ) {
83
- <Self as OFTInternal>::__receive(env, origin, guid, message, extra_data, executor, value)
84
- }
85
- }
86
-
87
- #[contractimpl(contracttrait)]
88
- impl OAppReceiver for LockUnlockHarnessOFT {}
89
-
90
- impl OFTInternal for LockUnlockHarnessOFT {
91
- fn __debit(env: &Env, sender: &Address, amount_ld: i128, min_amount_ld: i128, dst_eid: u32) -> (i128, i128) {
92
- let target = Self::token(env);
93
- lock_unlock::debit::<Self>(env, &target, sender, amount_ld, min_amount_ld, dst_eid)
94
- }
95
-
96
- fn __credit(env: &Env, to: &Address, amount_ld: i128, src_eid: u32) -> i128 {
97
- let target = Self::token(env);
98
- lock_unlock::credit::<Self>(env, &target, to, amount_ld, src_eid)
99
- }
100
- }
101
-
102
- // ============================================================================
103
- // Test Setup
104
- // ============================================================================
105
-
106
- struct TestSetup {
107
- env: Env,
108
- client: LockUnlockHarnessOFTClient<'static>,
109
- oft_address: Address,
110
- token: Address,
111
- }
112
-
113
- fn setup() -> TestSetup {
114
- let env = Env::default();
115
- // Enable mock_all_auths_allowing_non_root_auth for all tests to bypass authorization checks
116
- // including sub-contract invocations like token transfers
117
- env.mock_all_auths_allowing_non_root_auth();
118
-
119
- let token_admin = Address::generate(&env);
120
- let sac = env.register_stellar_asset_contract_v2(token_admin.clone());
121
- let token = sac.address();
122
- let endpoint = env.register(DummyEndpoint, ());
123
-
124
- let owner = Address::generate(&env);
125
- let delegate = owner.clone();
126
- let shared_decimals: u32 = 6;
127
-
128
- let oft_address = env.register(LockUnlockHarnessOFT, (&token, &owner, &endpoint, &delegate, &shared_decimals));
129
- let client = LockUnlockHarnessOFTClient::new(&env, &oft_address);
130
-
131
- TestSetup { env, client, oft_address, token }
132
- }
133
-
134
- // ============================================================================
135
- // Tests
136
- // ============================================================================
137
-
138
- #[test]
139
- fn test_debit_transfers_to_contract() {
140
- let TestSetup { env, client, oft_address, token, .. } = setup();
141
-
142
- let sender = Address::generate(&env);
143
-
144
- // Auth is automatically mocked by mock_all_auths_allowing_non_root_auth
145
- StellarAssetClient::new(&env, &token).mint(&sender, &1_000_000i128);
146
-
147
- let token_client = TokenClient::new(&env, &token);
148
- let sender_before = token_client.balance(&sender);
149
- let contract_before = token_client.balance(&oft_address);
150
-
151
- // With shared_decimals=6 and typical SAC decimals=7, conversion_rate=10 => 105 -> 100.
152
- // debit transfers from sender to OFT contract
153
- let amount_ld = 105i128;
154
-
155
- let receipt = client.debit(&sender, &amount_ld, &0i128, &999u32);
156
- assert_eq!(receipt.amount_sent_ld, receipt.amount_received_ld);
157
-
158
- // LockUnlock transfers `amount_received_ld` from sender -> contract.
159
- assert_eq!(token_client.balance(&sender), sender_before - receipt.amount_received_ld);
160
- assert_eq!(token_client.balance(&oft_address), contract_before + receipt.amount_received_ld);
161
- }
162
-
163
- #[test]
164
- fn test_credit_transfers_from_contract() {
165
- let TestSetup { env, client, oft_address, token, .. } = setup();
166
-
167
- let recipient = Address::generate(&env);
168
-
169
- // Auth is automatically mocked by mock_all_auths_allowing_non_root_auth
170
- StellarAssetClient::new(&env, &token).mint(&oft_address, &1_000_000i128);
171
-
172
- let token_client = TokenClient::new(&env, &token);
173
- let contract_before = token_client.balance(&oft_address);
174
- let recipient_before = token_client.balance(&recipient);
175
-
176
- // credit transfers from OFT contract to recipient
177
- let amount = 123i128;
178
-
179
- let credited = client.credit(&recipient, &amount, &1u32);
180
- assert_eq!(credited, amount);
181
-
182
- // LockUnlock transfers `amount` from contract -> recipient.
183
- assert_eq!(token_client.balance(&oft_address), contract_before - amount);
184
- assert_eq!(token_client.balance(&recipient), recipient_before + amount);
185
- }
@@ -1 +0,0 @@
1
- mod lock_unlock;