@layerzerolabs/protocol-stellar-v2 0.2.20 → 0.2.21
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.
- package/.turbo/turbo-build.log +783 -802
- package/.turbo/turbo-lint.log +320 -157
- package/.turbo/turbo-test.log +1414 -1457
- package/Cargo.lock +109 -108
- package/Cargo.toml +32 -18
- package/contracts/common-macros/Cargo.toml +7 -7
- package/contracts/common-macros/src/auth.rs +18 -37
- package/contracts/common-macros/src/contract_ttl.rs +2 -2
- package/contracts/common-macros/src/lib.rs +27 -10
- package/contracts/common-macros/src/lz_contract.rs +38 -7
- package/contracts/common-macros/src/storage.rs +251 -292
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +6 -12
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +12 -17
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +2 -7
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +20 -9
- package/contracts/common-macros/src/tests/upgradeable.rs +26 -4
- package/contracts/common-macros/src/ttl_configurable.rs +2 -10
- package/contracts/common-macros/src/ttl_extendable.rs +2 -10
- package/contracts/common-macros/src/upgradeable.rs +56 -15
- package/contracts/common-macros/src/utils.rs +0 -9
- package/contracts/endpoint-v2/src/lib.rs +3 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +4 -4
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +17 -5
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +6 -6
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +67 -37
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +5 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +44 -54
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +7 -7
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +8 -8
- package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +3 -3
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +4 -4
- package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +3 -3
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +2 -2
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +3 -3
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +2 -2
- package/contracts/layerzero-views/Cargo.toml +0 -1
- package/contracts/layerzero-views/src/layerzero_view.rs +1 -13
- package/contracts/macro-integration-tests/Cargo.toml +5 -15
- package/contracts/macro-integration-tests/tests/runtime/oapp/mod.rs +48 -0
- package/contracts/macro-integration-tests/tests/runtime/oapp/oapp_core.rs +170 -0
- package/contracts/macro-integration-tests/tests/runtime/oapp/options_type3.rs +154 -0
- package/contracts/macro-integration-tests/tests/runtime/oapp/receiver.rs +338 -0
- package/contracts/macro-integration-tests/tests/runtime/oapp/sender.rs +435 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +1 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/custom_wrong_value.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/missing_lz_receive_internal.stderr +71 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/non_struct_input.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/unknown_custom_option.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/fail/wrong_key.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_all.rs +38 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/pass/custom_single_trait.rs +96 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/pass/minimal_contract.rs +64 -0
- package/contracts/macro-integration-tests/tests/ui/oapp/pass/struct_with_fields.rs +46 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +8 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +1 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +1 -1
- package/contracts/macro-integration-tests/tests/ui_oapp.rs +11 -0
- package/contracts/message-libs/message-lib-common/Cargo.toml +0 -1
- package/contracts/message-libs/message-lib-common/src/errors.rs +1 -1
- package/contracts/message-libs/treasury/Cargo.toml +0 -2
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/verify.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_executor_config.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/send.rs +7 -27
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +2 -2
- package/contracts/oapps/counter/Cargo.toml +4 -6
- package/contracts/oapps/counter/integration_tests/utils.rs +19 -12
- package/contracts/oapps/oapp/src/errors.rs +1 -1
- package/contracts/oapps/oapp/src/interfaces/mod.rs +3 -0
- package/contracts/oapps/oapp/src/interfaces/oapp_msg_inspector.rs +47 -0
- package/contracts/oapps/oapp/src/lib.rs +1 -0
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +4 -4
- package/contracts/oapps/oapp/src/oapp_core.rs +5 -5
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +12 -4
- package/contracts/oapps/oapp/src/oapp_receiver.rs +14 -9
- package/contracts/oapps/oapp/src/tests/mod.rs +4 -4
- package/contracts/oapps/oapp/src/tests/{test_oapp_core.rs → oapp_core.rs} +4 -4
- package/contracts/oapps/oapp/src/tests/{test_oapp_options_type3.rs → oapp_options_type3.rs} +3 -4
- package/contracts/oapps/oapp-macros/Cargo.toml +8 -4
- package/contracts/oapps/oapp-macros/src/generators.rs +9 -34
- package/contracts/oapps/oapp-macros/src/lib.rs +3 -0
- package/contracts/oapps/oapp-macros/src/tests/mod.rs +2 -0
- package/contracts/oapps/oapp-macros/src/tests/oapp.rs +88 -0
- package/contracts/oapps/oapp-macros/src/tests/parse_custom_impls.rs +86 -0
- package/contracts/oapps/oapp-macros/src/tests/snapshots/oapp_macros__tests__oapp__snapshot_generate_oapp.snap +103 -0
- package/contracts/oapps/oft/integration-tests/utils.rs +28 -8
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +136 -74
- package/contracts/oapps/oft/src/extensions/pausable.rs +44 -10
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +170 -130
- package/contracts/oapps/oft/src/oft.rs +19 -12
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -1
- package/contracts/oapps/oft-core/Cargo.toml +1 -4
- package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -2
- package/contracts/oapps/oft-core/integration-tests/utils.rs +21 -3
- package/contracts/oapps/oft-core/src/errors.rs +3 -2
- package/contracts/oapps/oft-core/src/events.rs +6 -0
- package/contracts/oapps/oft-core/src/lib.rs +1 -1
- package/contracts/oapps/oft-core/src/oft_core.rs +115 -60
- package/contracts/oapps/oft-core/src/storage.rs +7 -3
- package/contracts/oapps/oft-core/src/tests/mod.rs +1 -0
- package/contracts/oapps/oft-core/src/tests/test_decimals.rs +37 -2
- package/contracts/oapps/oft-core/src/tests/test_lz_receive.rs +2 -2
- package/contracts/oapps/oft-core/src/tests/test_msg_inspector.rs +323 -0
- package/contracts/oapps/oft-core/src/tests/test_send.rs +2 -2
- package/contracts/oapps/oft-core/src/tests/test_utils.rs +59 -14
- package/contracts/utils/Cargo.toml +0 -1
- package/contracts/utils/src/errors.rs +1 -1
- package/contracts/utils/src/multisig.rs +17 -8
- package/contracts/utils/src/ownable.rs +6 -6
- package/contracts/utils/src/testing_utils.rs +124 -54
- package/contracts/utils/src/tests/multisig.rs +12 -12
- package/contracts/utils/src/tests/ownable.rs +6 -6
- package/contracts/utils/src/tests/testing_utils.rs +50 -167
- package/contracts/utils/src/tests/ttl_configurable.rs +5 -5
- package/contracts/utils/src/tests/upgradeable.rs +1 -1
- package/contracts/utils/src/ttl_configurable.rs +10 -4
- package/contracts/utils/src/upgradeable.rs +5 -5
- package/contracts/workers/dvn/Cargo.toml +5 -6
- package/contracts/workers/dvn/src/dvn.rs +2 -12
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +37 -19
- package/contracts/workers/dvn-fee-lib/src/lib.rs +12 -2
- package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +15 -13
- package/contracts/workers/executor/Cargo.toml +3 -0
- package/contracts/workers/executor/src/executor.rs +2 -12
- package/contracts/workers/executor/src/lib.rs +2 -2
- package/contracts/workers/executor/src/tests/auth.rs +394 -0
- package/contracts/workers/executor/src/tests/executor.rs +410 -0
- package/contracts/workers/executor/src/tests/mod.rs +3 -0
- package/contracts/workers/executor/src/tests/setup.rs +250 -0
- package/contracts/workers/executor-fee-lib/Cargo.toml +5 -0
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +1 -12
- package/contracts/workers/executor-fee-lib/src/lib.rs +8 -2
- package/contracts/workers/executor-helper/Cargo.toml +0 -1
- package/contracts/workers/price-feed/Cargo.toml +5 -0
- package/contracts/workers/price-feed/src/lib.rs +9 -4
- package/contracts/workers/price-feed/src/price_feed.rs +1 -11
- package/contracts/workers/worker/src/errors.rs +1 -1
- package/contracts/workers/worker/src/tests/setup.rs +1 -1
- package/contracts/workers/worker/src/tests/worker.rs +55 -41
- package/contracts/workers/worker/src/worker.rs +34 -25
- package/docs/error-spec.md +55 -0
- package/docs/layerzero-v2-on-stellar.md +447 -0
- package/docs/oapp-guide.md +212 -0
- package/docs/oft-guide.md +314 -0
- package/package.json +3 -3
- package/sdk/.turbo/turbo-test.log +260 -257
- package/sdk/dist/generated/bml.d.ts +3 -3
- package/sdk/dist/generated/bml.js +4 -4
- package/sdk/dist/generated/counter.d.ts +295 -295
- package/sdk/dist/generated/counter.js +43 -43
- package/sdk/dist/generated/dvn.d.ts +91 -91
- package/sdk/dist/generated/dvn.js +24 -24
- package/sdk/dist/generated/dvn_fee_lib.d.ts +92 -92
- package/sdk/dist/generated/dvn_fee_lib.js +25 -25
- package/sdk/dist/generated/endpoint.d.ts +99 -99
- package/sdk/dist/generated/endpoint.js +16 -16
- package/sdk/dist/generated/executor.d.ts +91 -91
- package/sdk/dist/generated/executor.js +24 -24
- package/sdk/dist/generated/executor_fee_lib.d.ts +92 -92
- package/sdk/dist/generated/executor_fee_lib.js +25 -25
- package/sdk/dist/generated/executor_helper.d.ts +3 -3
- package/sdk/dist/generated/executor_helper.js +4 -4
- package/sdk/dist/generated/layerzero_view.d.ts +186 -186
- package/sdk/dist/generated/layerzero_view.js +35 -35
- package/sdk/dist/generated/oft.d.ts +366 -352
- package/sdk/dist/generated/oft.js +74 -79
- package/sdk/dist/generated/price_feed.d.ts +198 -198
- package/sdk/dist/generated/price_feed.js +39 -39
- package/sdk/dist/generated/sml.d.ts +99 -99
- package/sdk/dist/generated/sml.js +16 -16
- package/sdk/dist/generated/treasury.d.ts +99 -99
- package/sdk/dist/generated/treasury.js +16 -16
- package/sdk/dist/generated/uln302.d.ts +99 -99
- package/sdk/dist/generated/uln302.js +16 -16
- package/sdk/dist/generated/upgrader.d.ts +3 -3
- package/sdk/dist/generated/upgrader.js +3 -3
- package/sdk/package.json +1 -1
- package/sdk/test/suites/localnet.ts +84 -20
- package/contracts/ERROR_SPEC.md +0 -51
- package/contracts/endpoint-v2/ARCHITECTURE.md +0 -233
- /package/contracts/oapps/oapp/src/tests/{test_oapp_receiver.rs → oapp_receiver.rs} +0 -0
- /package/contracts/oapps/oapp/src/tests/{test_oapp_sender.rs → oapp_sender.rs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
use crate::testing_utils::{
|
|
2
|
-
use soroban_sdk::{contract, contractevent, contractimpl, testutils::Address as _, Address, Env
|
|
1
|
+
use crate::testing_utils::{assert_contains_event, assert_contains_events, assert_eq_event, assert_eq_events};
|
|
2
|
+
use soroban_sdk::{contract, contractevent, contractimpl, testutils::Address as _, Address, Env};
|
|
3
3
|
|
|
4
4
|
// ============================================
|
|
5
5
|
// Test Fixtures
|
|
@@ -78,7 +78,7 @@ impl TestingUtilsContract {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// ============================================
|
|
81
|
-
//
|
|
81
|
+
// assert_eq_event
|
|
82
82
|
// ============================================
|
|
83
83
|
|
|
84
84
|
// Basic functionality
|
|
@@ -91,7 +91,7 @@ fn test_assert_event_found() {
|
|
|
91
91
|
|
|
92
92
|
client.emit_event1(&42);
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
assert_eq_event(&env, &contract_id, TestEvent1 { value: 42 });
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
#[test]
|
|
@@ -102,7 +102,7 @@ fn test_assert_event_with_multiple_fields() {
|
|
|
102
102
|
|
|
103
103
|
client.emit_event2(&123, &456);
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
assert_eq_event(&env, &contract_id, TestEvent2 { name: 123, count: 456 });
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
#[test]
|
|
@@ -114,7 +114,7 @@ fn test_assert_event_with_address() {
|
|
|
114
114
|
let addr = Address::generate(&env);
|
|
115
115
|
client.emit_event3(&addr);
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
assert_eq_event(&env, &contract_id, TestEvent3 { address: addr });
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
#[test]
|
|
@@ -125,8 +125,8 @@ fn test_assert_event_among_multiple() {
|
|
|
125
125
|
|
|
126
126
|
client.emit_multiple_events(&10, &20);
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
assert_contains_event(&env, &contract_id, TestEvent1 { value: 10 });
|
|
129
|
+
assert_contains_event(&env, &contract_id, TestEvent1 { value: 20 });
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// Edge cases
|
|
@@ -139,7 +139,7 @@ fn test_assert_event_finds_first_matching_event() {
|
|
|
139
139
|
|
|
140
140
|
client.emit_multiple_events(&42, &42);
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
assert_contains_event(&env, &contract_id, TestEvent1 { value: 42 });
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
#[test]
|
|
@@ -151,23 +151,23 @@ fn test_assert_event_finds_correct_event_among_many() {
|
|
|
151
151
|
// Use single contract call that emits all events (events don't accumulate across calls)
|
|
152
152
|
client.emit_mixed_four_events(&1, &100, &200, &2, &3);
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
assert_contains_event(&env, &contract_id, TestEvent1 { value: 2 });
|
|
155
|
+
assert_contains_event(&env, &contract_id, TestEvent2 { name: 100, count: 200 });
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// Error cases
|
|
159
159
|
|
|
160
160
|
#[test]
|
|
161
|
-
#[should_panic(expected = "Expected
|
|
161
|
+
#[should_panic(expected = "Expected exactly one event")]
|
|
162
162
|
fn test_assert_event_no_events_emitted() {
|
|
163
163
|
let env = Env::default();
|
|
164
164
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
assert_eq_event(&env, &contract_id, TestEvent1 { value: 42 });
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
#[test]
|
|
170
|
-
#[should_panic(expected = "Expected
|
|
170
|
+
#[should_panic(expected = "Expected exactly one event")]
|
|
171
171
|
fn test_assert_event_not_found() {
|
|
172
172
|
let env = Env::default();
|
|
173
173
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -175,11 +175,11 @@ fn test_assert_event_not_found() {
|
|
|
175
175
|
|
|
176
176
|
client.emit_event1(&42);
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
assert_eq_event(&env, &contract_id, TestEvent1 { value: 100 });
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
#[test]
|
|
182
|
-
#[should_panic(expected = "Expected
|
|
182
|
+
#[should_panic(expected = "Expected exactly one event")]
|
|
183
183
|
fn test_assert_event_wrong_contract() {
|
|
184
184
|
let env = Env::default();
|
|
185
185
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -188,11 +188,11 @@ fn test_assert_event_wrong_contract() {
|
|
|
188
188
|
|
|
189
189
|
client.emit_event1(&42);
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
assert_eq_event(&env, &other_contract_id, TestEvent1 { value: 42 });
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
#[test]
|
|
195
|
-
#[should_panic(expected = "Expected
|
|
195
|
+
#[should_panic(expected = "Expected exactly one event")]
|
|
196
196
|
fn test_assert_event_topics_length_mismatch() {
|
|
197
197
|
let env = Env::default();
|
|
198
198
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -200,11 +200,11 @@ fn test_assert_event_topics_length_mismatch() {
|
|
|
200
200
|
|
|
201
201
|
client.emit_event1(&42);
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
assert_eq_event(&env, &contract_id, TestEvent2 { name: 42, count: 0 });
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
#[test]
|
|
207
|
-
#[should_panic(expected = "Expected
|
|
207
|
+
#[should_panic(expected = "Expected exactly one event")]
|
|
208
208
|
fn test_assert_event_data_mismatch() {
|
|
209
209
|
let env = Env::default();
|
|
210
210
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -212,11 +212,11 @@ fn test_assert_event_data_mismatch() {
|
|
|
212
212
|
|
|
213
213
|
client.emit_event2(&123, &456);
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
assert_eq_event(&env, &contract_id, TestEvent2 { name: 123, count: 789 });
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// ============================================
|
|
219
|
-
//
|
|
219
|
+
// assert_eq_events
|
|
220
220
|
// ============================================
|
|
221
221
|
|
|
222
222
|
// Basic functionality
|
|
@@ -229,7 +229,7 @@ fn test_assert_events_single() {
|
|
|
229
229
|
|
|
230
230
|
client.emit_event1(&42);
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }]);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
#[test]
|
|
@@ -240,11 +240,7 @@ fn test_assert_events_multiple_same_type() {
|
|
|
240
240
|
|
|
241
241
|
client.emit_multiple_events(&10, &20);
|
|
242
242
|
|
|
243
|
-
|
|
244
|
-
&env,
|
|
245
|
-
&contract_id,
|
|
246
|
-
&[TestEvent1 { value: 10 }.expected(&env), TestEvent1 { value: 20 }.expected(&env)],
|
|
247
|
-
);
|
|
243
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 10 }, &TestEvent1 { value: 20 }]);
|
|
248
244
|
}
|
|
249
245
|
|
|
250
246
|
#[test]
|
|
@@ -255,11 +251,7 @@ fn test_assert_events_multiple_different_types() {
|
|
|
255
251
|
|
|
256
252
|
client.emit_both_events(&42, &123, &456);
|
|
257
253
|
|
|
258
|
-
|
|
259
|
-
&env,
|
|
260
|
-
&contract_id,
|
|
261
|
-
&[TestEvent1 { value: 42 }.expected(&env), TestEvent2 { name: 123, count: 456 }.expected(&env)],
|
|
262
|
-
);
|
|
254
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent2 { name: 123, count: 456 }]);
|
|
263
255
|
}
|
|
264
256
|
|
|
265
257
|
#[test]
|
|
@@ -270,11 +262,7 @@ fn test_assert_events_order_independent() {
|
|
|
270
262
|
|
|
271
263
|
client.emit_both_events(&42, &123, &456);
|
|
272
264
|
|
|
273
|
-
|
|
274
|
-
&env,
|
|
275
|
-
&contract_id,
|
|
276
|
-
&[TestEvent2 { name: 123, count: 456 }.expected(&env), TestEvent1 { value: 42 }.expected(&env)],
|
|
277
|
-
);
|
|
265
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent2 { name: 123, count: 456 }]);
|
|
278
266
|
}
|
|
279
267
|
|
|
280
268
|
#[test]
|
|
@@ -282,7 +270,7 @@ fn test_assert_events_empty_list() {
|
|
|
282
270
|
let env = Env::default();
|
|
283
271
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
284
272
|
|
|
285
|
-
|
|
273
|
+
assert_eq_events(&env, &contract_id, &[]);
|
|
286
274
|
}
|
|
287
275
|
|
|
288
276
|
#[test]
|
|
@@ -293,11 +281,7 @@ fn test_assert_events_with_duplicates() {
|
|
|
293
281
|
|
|
294
282
|
client.emit_multiple_events(&42, &42);
|
|
295
283
|
|
|
296
|
-
|
|
297
|
-
&env,
|
|
298
|
-
&contract_id,
|
|
299
|
-
&[TestEvent1 { value: 42 }.expected(&env), TestEvent1 { value: 42 }.expected(&env)],
|
|
300
|
-
);
|
|
284
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent1 { value: 42 }]);
|
|
301
285
|
}
|
|
302
286
|
|
|
303
287
|
// Edge cases
|
|
@@ -311,7 +295,7 @@ fn test_assert_events_partial_match() {
|
|
|
311
295
|
// Use single contract call that emits all events (events don't accumulate across calls)
|
|
312
296
|
client.emit_two_plus_event2(&10, &20, &100, &200);
|
|
313
297
|
|
|
314
|
-
|
|
298
|
+
assert_contains_events(&env, &contract_id, &[&TestEvent1 { value: 10 }]);
|
|
315
299
|
}
|
|
316
300
|
|
|
317
301
|
#[test]
|
|
@@ -323,14 +307,10 @@ fn test_assert_events_three_events() {
|
|
|
323
307
|
// Use single contract call that emits all events (events don't accumulate across calls)
|
|
324
308
|
client.emit_three_events(&1, &2, &3);
|
|
325
309
|
|
|
326
|
-
|
|
310
|
+
assert_eq_events(
|
|
327
311
|
&env,
|
|
328
312
|
&contract_id,
|
|
329
|
-
&[
|
|
330
|
-
TestEvent1 { value: 1 }.expected(&env),
|
|
331
|
-
TestEvent1 { value: 2 }.expected(&env),
|
|
332
|
-
TestEvent1 { value: 3 }.expected(&env),
|
|
333
|
-
],
|
|
313
|
+
&[&TestEvent1 { value: 1 }, &TestEvent1 { value: 2 }, &TestEvent1 { value: 3 }],
|
|
334
314
|
);
|
|
335
315
|
}
|
|
336
316
|
|
|
@@ -345,14 +325,10 @@ fn test_assert_events_mixed_event_types_three() {
|
|
|
345
325
|
// Use single contract call that emits all events (events don't accumulate across calls)
|
|
346
326
|
client.emit_mixed_three_types(&42, &100, &200, &addr);
|
|
347
327
|
|
|
348
|
-
|
|
328
|
+
assert_eq_events(
|
|
349
329
|
&env,
|
|
350
330
|
&contract_id,
|
|
351
|
-
&[
|
|
352
|
-
TestEvent3 { address: addr.clone() }.expected(&env),
|
|
353
|
-
TestEvent1 { value: 42 }.expected(&env),
|
|
354
|
-
TestEvent2 { name: 100, count: 200 }.expected(&env),
|
|
355
|
-
],
|
|
331
|
+
&[&TestEvent1 { value: 42 }, &TestEvent2 { name: 100, count: 200 }, &TestEvent3 { address: addr.clone() }],
|
|
356
332
|
);
|
|
357
333
|
}
|
|
358
334
|
|
|
@@ -368,21 +344,17 @@ fn test_assert_events_from_specific_contract_ignores_others() {
|
|
|
368
344
|
client1.emit_multiple_events(&10, &30);
|
|
369
345
|
|
|
370
346
|
// Assert events from contract1 are found when using contract1's address
|
|
371
|
-
|
|
372
|
-
&env,
|
|
373
|
-
&contract_id1,
|
|
374
|
-
&[TestEvent1 { value: 10 }.expected(&env), TestEvent1 { value: 30 }.expected(&env)],
|
|
375
|
-
);
|
|
347
|
+
assert_eq_events(&env, &contract_id1, &[&TestEvent1 { value: 10 }, &TestEvent1 { value: 30 }]);
|
|
376
348
|
|
|
377
349
|
// Verify that using contract2's address doesn't match contract1's events
|
|
378
350
|
// (this tests the filtering logic - events should not be found for wrong contract)
|
|
379
|
-
|
|
351
|
+
assert_contains_events(&env, &contract_id2, &[]);
|
|
380
352
|
}
|
|
381
353
|
|
|
382
354
|
// Error cases
|
|
383
355
|
|
|
384
356
|
#[test]
|
|
385
|
-
#[should_panic(expected = "Expected
|
|
357
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
386
358
|
fn test_assert_events_first_not_found() {
|
|
387
359
|
let env = Env::default();
|
|
388
360
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -390,11 +362,11 @@ fn test_assert_events_first_not_found() {
|
|
|
390
362
|
|
|
391
363
|
client.emit_event1(&42);
|
|
392
364
|
|
|
393
|
-
|
|
365
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 100 }]);
|
|
394
366
|
}
|
|
395
367
|
|
|
396
368
|
#[test]
|
|
397
|
-
#[should_panic(expected = "Expected
|
|
369
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
398
370
|
fn test_assert_events_second_not_found() {
|
|
399
371
|
let env = Env::default();
|
|
400
372
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -402,15 +374,11 @@ fn test_assert_events_second_not_found() {
|
|
|
402
374
|
|
|
403
375
|
client.emit_event1(&42);
|
|
404
376
|
|
|
405
|
-
|
|
406
|
-
&env,
|
|
407
|
-
&contract_id,
|
|
408
|
-
&[TestEvent1 { value: 42 }.expected(&env), TestEvent1 { value: 100 }.expected(&env)],
|
|
409
|
-
);
|
|
377
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent1 { value: 100 }]);
|
|
410
378
|
}
|
|
411
379
|
|
|
412
380
|
#[test]
|
|
413
|
-
#[should_panic(expected = "Expected
|
|
381
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
414
382
|
fn test_assert_events_third_not_found() {
|
|
415
383
|
let env = Env::default();
|
|
416
384
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -418,19 +386,15 @@ fn test_assert_events_third_not_found() {
|
|
|
418
386
|
|
|
419
387
|
client.emit_multiple_events(&10, &20);
|
|
420
388
|
|
|
421
|
-
|
|
389
|
+
assert_eq_events(
|
|
422
390
|
&env,
|
|
423
391
|
&contract_id,
|
|
424
|
-
&[
|
|
425
|
-
TestEvent1 { value: 10 }.expected(&env),
|
|
426
|
-
TestEvent1 { value: 20 }.expected(&env),
|
|
427
|
-
TestEvent1 { value: 30 }.expected(&env),
|
|
428
|
-
],
|
|
392
|
+
&[&TestEvent1 { value: 10 }, &TestEvent1 { value: 20 }, &TestEvent1 { value: 30 }],
|
|
429
393
|
);
|
|
430
394
|
}
|
|
431
395
|
|
|
432
396
|
#[test]
|
|
433
|
-
#[should_panic(expected = "Expected
|
|
397
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
434
398
|
fn test_assert_events_duplicate_expected_but_not_emitted() {
|
|
435
399
|
let env = Env::default();
|
|
436
400
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -438,24 +402,20 @@ fn test_assert_events_duplicate_expected_but_not_emitted() {
|
|
|
438
402
|
|
|
439
403
|
client.emit_event1(&42);
|
|
440
404
|
|
|
441
|
-
|
|
442
|
-
&env,
|
|
443
|
-
&contract_id,
|
|
444
|
-
&[TestEvent1 { value: 42 }.expected(&env), TestEvent1 { value: 42 }.expected(&env)],
|
|
445
|
-
);
|
|
405
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent1 { value: 42 }]);
|
|
446
406
|
}
|
|
447
407
|
|
|
448
408
|
#[test]
|
|
449
|
-
#[should_panic(expected = "Expected
|
|
409
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
450
410
|
fn test_assert_events_no_events_emitted() {
|
|
451
411
|
let env = Env::default();
|
|
452
412
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
453
413
|
|
|
454
|
-
|
|
414
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent1 { value: 42 }]);
|
|
455
415
|
}
|
|
456
416
|
|
|
457
417
|
#[test]
|
|
458
|
-
#[should_panic(expected = "Expected
|
|
418
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
459
419
|
fn test_assert_events_wrong_contract() {
|
|
460
420
|
let env = Env::default();
|
|
461
421
|
let contract_id1 = env.register(TestingUtilsContract, ());
|
|
@@ -464,27 +424,11 @@ fn test_assert_events_wrong_contract() {
|
|
|
464
424
|
|
|
465
425
|
client1.emit_event1(&42);
|
|
466
426
|
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
#[test]
|
|
471
|
-
#[should_panic(expected = "Expected event #0 not found")]
|
|
472
|
-
fn test_assert_events_topics_length_mismatch() {
|
|
473
|
-
let env = Env::default();
|
|
474
|
-
let contract_id = env.register(TestingUtilsContract, ());
|
|
475
|
-
let client = TestingUtilsContractClient::new(&env, &contract_id);
|
|
476
|
-
|
|
477
|
-
client.emit_event1(&42);
|
|
478
|
-
|
|
479
|
-
let empty_topics: Vec<Val> = Vec::new(&env);
|
|
480
|
-
let data: Val = 42u32.into_val(&env);
|
|
481
|
-
let expected_with_empty_topics = ExpectedEvent { topics: empty_topics, data };
|
|
482
|
-
|
|
483
|
-
assert_events(&env, &contract_id, &[expected_with_empty_topics]);
|
|
427
|
+
assert_eq_events(&env, &contract_id2, &[&TestEvent1 { value: 42 }]);
|
|
484
428
|
}
|
|
485
429
|
|
|
486
430
|
#[test]
|
|
487
|
-
#[should_panic(expected = "Expected
|
|
431
|
+
#[should_panic(expected = "Expected events to match exactly")]
|
|
488
432
|
fn test_assert_events_data_mismatch() {
|
|
489
433
|
let env = Env::default();
|
|
490
434
|
let contract_id = env.register(TestingUtilsContract, ());
|
|
@@ -492,66 +436,5 @@ fn test_assert_events_data_mismatch() {
|
|
|
492
436
|
|
|
493
437
|
client.emit_event2(&100, &200);
|
|
494
438
|
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// ============================================
|
|
499
|
-
// ExpectedEvent & IntoExpectedEvent
|
|
500
|
-
// ============================================
|
|
501
|
-
|
|
502
|
-
#[test]
|
|
503
|
-
fn test_into_expected_event() {
|
|
504
|
-
let env = Env::default();
|
|
505
|
-
|
|
506
|
-
let event = TestEvent1 { value: 42 };
|
|
507
|
-
let expected = event.expected(&env);
|
|
508
|
-
|
|
509
|
-
assert!(!expected.topics.is_empty());
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
#[test]
|
|
513
|
-
fn test_into_expected_event_with_multiple_fields() {
|
|
514
|
-
let env = Env::default();
|
|
515
|
-
|
|
516
|
-
let event = TestEvent2 { name: 123, count: 456 };
|
|
517
|
-
let expected = event.expected(&env);
|
|
518
|
-
|
|
519
|
-
assert!(!expected.topics.is_empty());
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
#[test]
|
|
523
|
-
fn test_into_expected_event_with_address() {
|
|
524
|
-
let env = Env::default();
|
|
525
|
-
|
|
526
|
-
let addr = Address::generate(&env);
|
|
527
|
-
let event = TestEvent3 { address: addr };
|
|
528
|
-
let expected = event.expected(&env);
|
|
529
|
-
|
|
530
|
-
assert!(!expected.topics.is_empty());
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
#[test]
|
|
534
|
-
fn test_expected_event_struct() {
|
|
535
|
-
let env = Env::default();
|
|
536
|
-
|
|
537
|
-
let topics: Vec<Val> = Vec::new(&env);
|
|
538
|
-
let data: Val = 42u32.into_val(&env);
|
|
539
|
-
|
|
540
|
-
let expected = ExpectedEvent { topics, data };
|
|
541
|
-
|
|
542
|
-
assert_eq!(expected.topics.len(), 0);
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
#[test]
|
|
546
|
-
fn test_expected_event_with_topics() {
|
|
547
|
-
let env = Env::default();
|
|
548
|
-
|
|
549
|
-
let mut topics: Vec<Val> = Vec::new(&env);
|
|
550
|
-
topics.push_back(42u32.into_val(&env));
|
|
551
|
-
topics.push_back(100u64.into_val(&env));
|
|
552
|
-
let data: Val = 999u32.into_val(&env);
|
|
553
|
-
|
|
554
|
-
let expected = ExpectedEvent { topics, data };
|
|
555
|
-
|
|
556
|
-
assert_eq!(expected.topics.len(), 2);
|
|
439
|
+
assert_eq_events(&env, &contract_id, &[&TestEvent2 { name: 100, count: 999 }]);
|
|
557
440
|
}
|
|
@@ -5,7 +5,7 @@ use crate::{
|
|
|
5
5
|
errors::{OwnableError, TtlConfigurableError},
|
|
6
6
|
option_ext::OptionExt,
|
|
7
7
|
ownable::{Ownable, OwnableInitializer},
|
|
8
|
-
testing_utils::
|
|
8
|
+
testing_utils::assert_eq_event,
|
|
9
9
|
ttl_configurable::{
|
|
10
10
|
TtlConfig, TtlConfigStorage, TtlConfigsFrozen, TtlConfigsSet, TtlConfigurable, LEDGERS_PER_DAY, MAX_TTL,
|
|
11
11
|
},
|
|
@@ -314,7 +314,7 @@ fn test_default_ttl_configurable_set_all() {
|
|
|
314
314
|
let persistent = Some(persistent_cfg);
|
|
315
315
|
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
316
316
|
|
|
317
|
-
|
|
317
|
+
assert_eq_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
318
318
|
|
|
319
319
|
let (instance, persistent) = client.configurable_ttl_configs();
|
|
320
320
|
assert_eq!(instance, Some(instance_cfg));
|
|
@@ -331,7 +331,7 @@ fn test_default_ttl_configurable_set_partial() {
|
|
|
331
331
|
let instance = Some(instance_cfg);
|
|
332
332
|
let persistent = None;
|
|
333
333
|
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
334
|
-
|
|
334
|
+
assert_eq_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
335
335
|
|
|
336
336
|
let (instance, persistent) = client.configurable_ttl_configs();
|
|
337
337
|
assert_eq!(instance, Some(instance_cfg));
|
|
@@ -375,7 +375,7 @@ fn test_default_ttl_configurable_freeze() {
|
|
|
375
375
|
|
|
376
376
|
assert!(!client.is_ttl_configs_frozen());
|
|
377
377
|
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
378
|
-
|
|
378
|
+
assert_eq_event(&env, &contract_id, TtlConfigsFrozen {});
|
|
379
379
|
assert!(client.is_ttl_configs_frozen());
|
|
380
380
|
}
|
|
381
381
|
|
|
@@ -398,7 +398,7 @@ fn test_default_ttl_configurable_freeze_when_already_frozen() {
|
|
|
398
398
|
let (env, contract_id, owner, client) = setup_contract();
|
|
399
399
|
|
|
400
400
|
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
401
|
-
|
|
401
|
+
assert_eq_event(&env, &contract_id, TtlConfigsFrozen {});
|
|
402
402
|
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
403
403
|
}
|
|
404
404
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::upgradeable::{Upgradeable, UpgradeableInternal, UpgradeableStorage};
|
|
2
|
-
use soroban_sdk::{contract, contractimpl, xdr::ToXdr, Address, Bytes,
|
|
2
|
+
use soroban_sdk::{contract, contractimpl, xdr::ToXdr, Address, Bytes, Env, Symbol, Val};
|
|
3
3
|
|
|
4
4
|
// #![no_std]
|
|
5
5
|
|
|
@@ -111,7 +111,11 @@ pub trait TtlConfigurable: Auth {
|
|
|
111
111
|
/// # Panics
|
|
112
112
|
/// - `TtlConfigFrozen` if configs are frozen
|
|
113
113
|
/// - `InvalidTtlConfig` if validation fails
|
|
114
|
-
fn set_ttl_configs(
|
|
114
|
+
fn set_ttl_configs(
|
|
115
|
+
env: &soroban_sdk::Env,
|
|
116
|
+
instance: &Option<utils::ttl_configurable::TtlConfig>,
|
|
117
|
+
persistent: &Option<utils::ttl_configurable::TtlConfig>,
|
|
118
|
+
) {
|
|
115
119
|
auth::require_auth::<Self>(env);
|
|
116
120
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigFrozen);
|
|
117
121
|
|
|
@@ -126,7 +130,9 @@ pub trait TtlConfigurable: Auth {
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
/// Returns the current TTL configs as (instance_config, persistent_config).
|
|
129
|
-
fn ttl_configs(
|
|
133
|
+
fn ttl_configs(
|
|
134
|
+
env: &soroban_sdk::Env,
|
|
135
|
+
) -> (Option<utils::ttl_configurable::TtlConfig>, Option<utils::ttl_configurable::TtlConfig>) {
|
|
130
136
|
(TtlConfigStorage::instance(env), TtlConfigStorage::persistent(env))
|
|
131
137
|
}
|
|
132
138
|
|
|
@@ -137,7 +143,7 @@ pub trait TtlConfigurable: Auth {
|
|
|
137
143
|
///
|
|
138
144
|
/// # Panics
|
|
139
145
|
/// - `TtlConfigAlreadyFrozen` if already frozen
|
|
140
|
-
fn freeze_ttl_configs(env: &Env) {
|
|
146
|
+
fn freeze_ttl_configs(env: &soroban_sdk::Env) {
|
|
141
147
|
auth::require_auth::<Self>(env);
|
|
142
148
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigAlreadyFrozen);
|
|
143
149
|
|
|
@@ -147,7 +153,7 @@ pub trait TtlConfigurable: Auth {
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
/// Returns whether TTL configs are frozen.
|
|
150
|
-
fn is_ttl_configs_frozen(env: &Env) -> bool {
|
|
156
|
+
fn is_ttl_configs_frozen(env: &soroban_sdk::Env) -> bool {
|
|
151
157
|
TtlConfigStorage::frozen(env)
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -5,7 +5,7 @@ use crate::{
|
|
|
5
5
|
option_ext::OptionExt,
|
|
6
6
|
};
|
|
7
7
|
use common_macros::{contract_trait, storage};
|
|
8
|
-
use soroban_sdk::{assert_with_error, xdr::FromXdr,
|
|
8
|
+
use soroban_sdk::{assert_with_error, xdr::FromXdr, Env};
|
|
9
9
|
|
|
10
10
|
// ============================================
|
|
11
11
|
// Upgradeable Interface
|
|
@@ -17,7 +17,7 @@ pub trait Upgradeable: UpgradeableInternal + Auth {
|
|
|
17
17
|
/// The type of data required for migration.
|
|
18
18
|
/// Upgrades the contract to new WASM bytecode.
|
|
19
19
|
/// Sets a migration flag that must be cleared by calling `migrate`.
|
|
20
|
-
fn upgrade(env: &Env, new_wasm_hash: &BytesN<32>) {
|
|
20
|
+
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: &soroban_sdk::BytesN<32>) {
|
|
21
21
|
auth::require_auth::<Self>(env);
|
|
22
22
|
assert_with_error!(env, !Self::is_frozen(env), UpgradeableError::UpgradesFrozen);
|
|
23
23
|
UpgradeableStorage::set_migrating(env, &true);
|
|
@@ -26,7 +26,7 @@ pub trait Upgradeable: UpgradeableInternal + Auth {
|
|
|
26
26
|
|
|
27
27
|
/// Runs migration logic after an upgrade.
|
|
28
28
|
/// Can only be called when the migration flag is set by a previous `upgrade` call.
|
|
29
|
-
fn migrate(env: &Env, migration_data: &Bytes) {
|
|
29
|
+
fn migrate(env: &soroban_sdk::Env, migration_data: &soroban_sdk::Bytes) {
|
|
30
30
|
auth::require_auth::<Self>(env);
|
|
31
31
|
assert_with_error!(env, UpgradeableStorage::migrating(env), UpgradeableError::MigrationNotAllowed);
|
|
32
32
|
|
|
@@ -42,13 +42,13 @@ pub trait Upgradeable: UpgradeableInternal + Auth {
|
|
|
42
42
|
|
|
43
43
|
/// Permanently freezes the contract, preventing any future upgrades.
|
|
44
44
|
/// This action is irreversible.
|
|
45
|
-
fn freeze(env: &Env) {
|
|
45
|
+
fn freeze(env: &soroban_sdk::Env) {
|
|
46
46
|
auth::require_auth::<Self>(env);
|
|
47
47
|
UpgradeableStorage::set_frozen(env, &true);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/// Returns whether the contract is frozen (upgrades disabled).
|
|
51
|
-
fn is_frozen(env: &Env) -> bool {
|
|
51
|
+
fn is_frozen(env: &soroban_sdk::Env) -> bool {
|
|
52
52
|
UpgradeableStorage::frozen(env)
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"]
|
|
|
14
14
|
doctest = false
|
|
15
15
|
|
|
16
16
|
[dependencies]
|
|
17
|
-
cfg-if =
|
|
17
|
+
cfg-if = { workspace = true }
|
|
18
18
|
soroban-sdk = { workspace = true, features = ["hazmat-crypto"] }
|
|
19
19
|
worker = { workspace = true }
|
|
20
20
|
fee-lib-interfaces = { workspace = true }
|
|
@@ -25,8 +25,7 @@ endpoint-v2 = { workspace = true, features = ["library"] }
|
|
|
25
25
|
|
|
26
26
|
[dev-dependencies]
|
|
27
27
|
soroban-sdk = { workspace = true, features = ["testutils"] }
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ed25519-dalek = "2"
|
|
28
|
+
k256 = { workspace = true }
|
|
29
|
+
sha3 = { workspace = true }
|
|
30
|
+
rand = { workspace = true }
|
|
31
|
+
ed25519-dalek = { workspace = true }
|
|
@@ -11,7 +11,7 @@ use endpoint_v2::FeeRecipient;
|
|
|
11
11
|
use fee_lib_interfaces::{DvnFeeLibClient, DvnFeeParams};
|
|
12
12
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
13
13
|
use soroban_sdk::{xdr::ToXdr, Address, Bytes, BytesN, Env, Vec};
|
|
14
|
-
use utils::{buffer_writer::BufferWriter, multisig, option_ext::OptionExt
|
|
14
|
+
use utils::{buffer_writer::BufferWriter, multisig, option_ext::OptionExt};
|
|
15
15
|
use worker::{
|
|
16
16
|
assert_acl, assert_not_paused, assert_supported_message_lib, errors::WorkerError, init_worker, require_admin_auth,
|
|
17
17
|
set_admin_by_admin, Worker,
|
|
@@ -21,7 +21,7 @@ use worker::{
|
|
|
21
21
|
///
|
|
22
22
|
/// Implements multisig-based verification with custom account authorization.
|
|
23
23
|
/// The contract owns itself, allowing the multisig quorum to authorize operations.
|
|
24
|
-
#[lz_contract(multisig, upgradeable)]
|
|
24
|
+
#[lz_contract(multisig, upgradeable(no_migration))]
|
|
25
25
|
pub struct LzDVN;
|
|
26
26
|
|
|
27
27
|
// ============================================================================
|
|
@@ -189,16 +189,6 @@ impl ILayerZeroDVN for LzDVN {
|
|
|
189
189
|
#[contract_impl(contracttrait)]
|
|
190
190
|
impl Worker for LzDVN {}
|
|
191
191
|
|
|
192
|
-
// ============================================================================
|
|
193
|
-
// Upgradeable Implementation
|
|
194
|
-
// ============================================================================
|
|
195
|
-
|
|
196
|
-
/// No migration logic needed for initial upgrade capability
|
|
197
|
-
impl UpgradeableInternal for LzDVN {
|
|
198
|
-
type MigrationData = ();
|
|
199
|
-
fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
192
|
// ============================================================================
|
|
203
193
|
// Include Auth Module
|
|
204
194
|
// ============================================================================
|
|
@@ -14,9 +14,9 @@ crate-type = ["cdylib", "rlib"]
|
|
|
14
14
|
doctest = false
|
|
15
15
|
|
|
16
16
|
[dependencies]
|
|
17
|
+
cfg-if = { workspace = true }
|
|
17
18
|
soroban-sdk = { workspace = true }
|
|
18
19
|
common-macros = { workspace = true }
|
|
19
|
-
message-lib-common = { workspace = true }
|
|
20
20
|
utils = { workspace = true }
|
|
21
21
|
fee-lib-interfaces = { workspace = true }
|
|
22
22
|
|