@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.
- package/.turbo/turbo-build.log +350 -309
- package/.turbo/turbo-lint.log +146 -108
- package/.turbo/turbo-test.log +1423 -1238
- package/Cargo.lock +12 -0
- package/Cargo.toml +3 -0
- package/contracts/ERROR_SPEC.md +44 -0
- package/contracts/common-macros/src/auth.rs +113 -0
- package/contracts/common-macros/src/contract_ttl.rs +84 -0
- package/contracts/common-macros/src/lib.rs +181 -30
- package/contracts/common-macros/src/lz_contract.rs +83 -0
- package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
- package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
- package/contracts/common-macros/src/tests/mod.rs +2 -2
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
- 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
- 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
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -21
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +2 -2
- package/contracts/common-macros/src/ttl_configurable.rs +19 -34
- package/contracts/common-macros/src/ttl_extendable.rs +36 -0
- package/contracts/common-macros/src/upgradeable.rs +5 -5
- package/contracts/common-macros/src/utils.rs +9 -0
- package/contracts/endpoint-v2/src/constants.rs +4 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +38 -40
- package/contracts/endpoint-v2/src/errors.rs +4 -3
- package/contracts/endpoint-v2/src/events.rs +1 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
- package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
- package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
- package/contracts/endpoint-v2/src/storage.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +3 -3
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +4 -4
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +1 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +1 -1
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +4 -4
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +1 -1
- package/contracts/layerzero-views/src/layerzero_view.rs +3 -6
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +2 -2
- package/contracts/macro-integration-tests/tests/runtime/ownable/{only_owner_guard.rs → only_auth_guard.rs} +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +1 -1
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +0 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.rs → only_auth_missing_env.rs} +3 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/{only_owner_missing_env.stderr → only_auth_missing_env.stderr} +4 -4
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +2 -3
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/{only_owner_env_param_variants.rs → only_auth_env_param_variants.rs} +9 -9
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +6 -6
- package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +3 -3
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +1 -2
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +9 -9
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +1 -1
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +2 -2
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
- package/contracts/message-libs/treasury/src/errors.rs +2 -2
- package/contracts/message-libs/treasury/src/events.rs +1 -1
- package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/storage.rs +1 -1
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
- package/contracts/message-libs/treasury/src/treasury.rs +14 -16
- package/contracts/message-libs/uln-302/src/receive_uln.rs +13 -2
- package/contracts/message-libs/uln-302/src/send_uln.rs +23 -3
- package/contracts/message-libs/uln-302/src/uln302.rs +6 -24
- package/contracts/oapps/counter/Cargo.toml +14 -1
- package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
- package/contracts/oapps/counter/integration_tests/{setup.rs → setup_sml.rs} +48 -80
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
- package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
- package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
- package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
- package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
- package/contracts/oapps/counter/src/counter.rs +67 -43
- package/contracts/oapps/counter/src/tests/mod.rs +0 -13
- package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
- package/contracts/oapps/oapp/src/errors.rs +5 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +93 -78
- package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
- package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
- package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -8
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -17
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -7
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -15
- package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
- package/contracts/oapps/oapp-macros/src/lib.rs +113 -56
- package/contracts/oapps/oft/integration-tests/setup.rs +25 -7
- package/contracts/oapps/oft/src/errors.rs +6 -1
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +8 -8
- package/contracts/oapps/oft/src/extensions/pausable.rs +4 -4
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +5 -5
- package/contracts/oapps/oft/src/lib.rs +4 -2
- package/contracts/oapps/oft/src/oft.rs +24 -64
- package/contracts/oapps/oft/src/oft_impl.rs +201 -0
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -3
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -4
- package/contracts/oapps/oft/src/storage.rs +2 -0
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +36 -22
- package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +5 -3
- package/contracts/oapps/oft/src/tests/test_decimals.rs +2 -2
- package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +1 -2
- package/contracts/oapps/oft/src/tests/test_utils.rs +45 -23
- package/contracts/oapps/oft/src/types.rs +20 -0
- package/contracts/oapps/oft-std/integration-tests/setup.rs +4 -2
- package/contracts/oapps/oft-std/src/oft.rs +24 -6
- package/contracts/upgrader/src/lib.rs +4 -4
- package/contracts/utils/src/auth.rs +44 -0
- package/contracts/utils/src/errors.rs +27 -5
- package/contracts/utils/src/lib.rs +3 -0
- package/contracts/utils/src/multisig.rs +211 -0
- package/contracts/utils/src/ownable.rs +12 -10
- package/contracts/utils/src/tests/buffer_reader.rs +6 -6
- package/contracts/utils/src/tests/buffer_writer.rs +6 -6
- package/contracts/utils/src/tests/bytes_ext.rs +2 -4
- package/contracts/utils/src/tests/mod.rs +1 -0
- package/contracts/utils/src/tests/multisig.rs +731 -0
- package/contracts/utils/src/tests/option_ext.rs +2 -5
- package/contracts/utils/src/tests/ownable.rs +16 -5
- package/contracts/utils/src/tests/ttl_configurable.rs +27 -16
- package/contracts/utils/src/tests/upgradeable.rs +4 -2
- package/contracts/utils/src/ttl_configurable.rs +23 -8
- package/contracts/utils/src/ttl_extendable.rs +27 -0
- package/contracts/utils/src/upgradeable.rs +2 -0
- package/contracts/workers/dvn/Cargo.toml +1 -1
- package/contracts/workers/dvn/src/auth.rs +7 -7
- package/contracts/workers/dvn/src/dvn.rs +10 -38
- package/contracts/workers/dvn/src/errors.rs +0 -7
- package/contracts/workers/dvn/src/events.rs +1 -14
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
- package/contracts/workers/dvn/src/storage.rs +3 -13
- package/contracts/workers/dvn/src/tests/auth.rs +4 -4
- package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
- package/contracts/workers/dvn/src/tests/setup.rs +5 -5
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +3 -6
- package/contracts/workers/executor/src/auth.rs +80 -16
- package/contracts/workers/executor/src/executor.rs +5 -31
- package/contracts/workers/executor/src/storage.rs +2 -9
- package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +3 -6
- package/contracts/workers/executor-helper/Cargo.toml +1 -1
- package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
- package/contracts/workers/price-feed/Cargo.toml +1 -1
- package/contracts/workers/price-feed/src/price_feed.rs +7 -10
- package/contracts/workers/worker/src/errors.rs +4 -0
- package/contracts/workers/worker/src/tests/worker.rs +7 -6
- package/contracts/workers/worker/src/worker.rs +20 -16
- package/package.json +8 -5
- package/sdk/.turbo/turbo-build.log +1 -0
- package/sdk/.turbo/turbo-test.log +1009 -0
- package/sdk/dist/generated/bml.d.ts +65 -8
- package/sdk/dist/generated/bml.js +70 -34
- package/sdk/dist/generated/counter.d.ts +167 -42
- package/sdk/dist/generated/counter.js +86 -45
- package/sdk/dist/generated/dvn.d.ts +282 -229
- package/sdk/dist/generated/dvn.js +119 -81
- package/sdk/dist/generated/dvn_fee_lib.d.ts +142 -67
- package/sdk/dist/generated/dvn_fee_lib.js +64 -24
- package/sdk/dist/generated/endpoint.d.ts +97 -22
- package/sdk/dist/generated/endpoint.js +75 -37
- package/sdk/dist/generated/executor.d.ts +117 -85
- package/sdk/dist/generated/executor.js +102 -59
- package/sdk/dist/generated/executor_fee_lib.d.ts +162 -78
- package/sdk/dist/generated/executor_fee_lib.js +104 -57
- package/sdk/dist/generated/executor_helper.d.ts +133 -21
- package/sdk/dist/generated/executor_helper.js +99 -50
- package/sdk/dist/generated/oft_std.d.ts +233 -55
- package/sdk/dist/generated/oft_std.js +99 -54
- package/sdk/dist/generated/price_feed.d.ts +142 -67
- package/sdk/dist/generated/price_feed.js +64 -24
- package/sdk/dist/generated/sml.d.ts +113 -32
- package/sdk/dist/generated/sml.js +93 -49
- package/sdk/dist/generated/treasury.d.ts +896 -0
- package/sdk/dist/generated/treasury.js +219 -0
- package/sdk/dist/generated/uln302.d.ts +113 -32
- package/sdk/dist/generated/uln302.js +93 -49
- package/sdk/dist/generated/upgrader.d.ts +2 -2
- package/sdk/dist/generated/upgrader.js +1 -1
- package/sdk/dist/index.d.ts +2 -0
- package/sdk/dist/index.js +3 -0
- package/sdk/dist/wasm/blocked-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/blocked-message-lib.js +2 -0
- package/sdk/dist/wasm/counter.d.ts +1 -0
- package/sdk/dist/wasm/counter.js +2 -0
- package/sdk/dist/wasm/dvn-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/dvn-fee-lib.js +2 -0
- package/sdk/dist/wasm/dvn.d.ts +1 -0
- package/sdk/dist/wasm/dvn.js +2 -0
- package/sdk/dist/wasm/endpoint-v2.d.ts +1 -0
- package/sdk/dist/wasm/endpoint-v2.js +2 -0
- package/sdk/dist/wasm/executor-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/executor-fee-lib.js +2 -0
- package/sdk/dist/wasm/executor-helper.d.ts +1 -0
- package/sdk/dist/wasm/executor-helper.js +2 -0
- package/sdk/dist/wasm/executor.d.ts +1 -0
- package/sdk/dist/wasm/executor.js +2 -0
- package/sdk/dist/wasm/layerzero-views.d.ts +1 -0
- package/sdk/dist/wasm/layerzero-views.js +2 -0
- package/sdk/dist/wasm/oft-std.d.ts +1 -0
- package/sdk/dist/wasm/oft-std.js +2 -0
- package/sdk/dist/wasm/price-feed.d.ts +1 -0
- package/sdk/dist/wasm/price-feed.js +2 -0
- package/sdk/dist/wasm/simple-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/simple-message-lib.js +2 -0
- package/sdk/dist/wasm/treasury.d.ts +1 -0
- package/sdk/dist/wasm/treasury.js +2 -0
- package/sdk/dist/wasm/uln302.d.ts +1 -0
- package/sdk/dist/wasm/uln302.js +2 -0
- package/sdk/dist/wasm/upgrader.d.ts +1 -0
- package/sdk/dist/wasm/upgrader.js +2 -0
- package/sdk/dist/wasm.d.ts +15 -0
- package/sdk/dist/wasm.js +15 -0
- package/sdk/package.json +4 -2
- package/sdk/src/index.ts +4 -0
- package/sdk/test/counter-sml.test.ts +376 -0
- package/sdk/test/counter-uln.test.ts +493 -0
- package/sdk/test/{oft.test.ts → oft-sml.test.ts} +185 -310
- package/sdk/test/suites/constants.ts +22 -2
- package/sdk/test/suites/globalSetup.ts +450 -0
- package/sdk/test/suites/localnet.ts +23 -6
- package/sdk/test/upgrader.test.ts +7 -16
- package/sdk/test/utils.ts +558 -85
- package/sdk/vitest.config.ts +21 -0
- package/tools/ts-bindings-gen/src/main.rs +1 -0
- package/turbo.json +2 -0
- package/contracts/common-macros/src/contract_impl.rs +0 -52
- package/contracts/common-macros/src/ownable.rs +0 -41
- package/contracts/common-macros/src/tests/contract_impl.rs +0 -386
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -12
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +0 -50
- package/contracts/oapps/oapp-macros/src/oapp_core.rs +0 -41
- package/contracts/oapps/oapp-macros/src/oapp_full.rs +0 -21
- package/contracts/oapps/oapp-macros/src/oapp_options_type3.rs +0 -31
- package/contracts/oapps/oapp-macros/src/oapp_receiver.rs +0 -48
- package/contracts/oapps/oapp-macros/src/oapp_sender.rs +0 -21
- package/contracts/oapps/oapp-macros/src/util.rs +0 -107
- package/contracts/oapps/oft/src/constants.rs +0 -5
- package/contracts/oapps/oft/src/default_oft_impl.rs +0 -152
- package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
- package/contracts/workers/dvn/src/multisig.rs +0 -157
- package/sdk/test/index.test.ts +0 -375
- /package/sdk/test/suites/{testUpgradeable.ts → dummyContractClient.ts} +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
use crate::{errors::OwnableError, option_ext::OptionExt, tests::test_helper::assert_panics_contains};
|
|
1
2
|
use soroban_sdk::Env;
|
|
2
3
|
|
|
3
|
-
use crate::{errors::OwnableError, option_ext::OptionExt};
|
|
4
|
-
|
|
5
|
-
use crate::tests::test_helper::assert_panics_contains;
|
|
6
|
-
|
|
7
4
|
#[test]
|
|
8
5
|
fn unwrap_or_panic_some_returns_value() {
|
|
9
6
|
let env = Env::default();
|
|
@@ -13,7 +10,7 @@ fn unwrap_or_panic_some_returns_value() {
|
|
|
13
10
|
|
|
14
11
|
#[test]
|
|
15
12
|
fn unwrap_or_panic_none_panics_with_error() {
|
|
16
|
-
const EXPECTED: &str = "Error(Contract, #
|
|
13
|
+
const EXPECTED: &str = "Error(Contract, #1031)"; // OwnerNotSet
|
|
17
14
|
assert_panics_contains("none unwrap_or_panic", EXPECTED, || {
|
|
18
15
|
let env = Env::default();
|
|
19
16
|
let _got: u32 = None::<u32>.unwrap_or_panic(&env, OwnableError::OwnerNotSet);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
+
auth::Auth,
|
|
3
|
+
errors::OwnableError,
|
|
4
|
+
option_ext::OptionExt,
|
|
2
5
|
ownable::{self, Ownable, OwnableInitializer, OwnableStorage, OwnershipRenounced, OwnershipTransferred},
|
|
3
6
|
testing_utils::assert_event,
|
|
4
7
|
};
|
|
@@ -35,6 +38,14 @@ impl Contract {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
/// Auth implementation for the test contract - uses stored owner as authorizer.
|
|
42
|
+
#[contractimpl]
|
|
43
|
+
impl Auth for Contract {
|
|
44
|
+
fn authorizer(env: &Env) -> Address {
|
|
45
|
+
<Self as Ownable>::owner(env).unwrap_or_panic(env, OwnableError::OwnerNotSet)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
#[contractimpl(contracttrait)]
|
|
39
50
|
impl Ownable for Contract {}
|
|
40
51
|
impl OwnableInitializer for Contract {}
|
|
@@ -76,7 +87,7 @@ fn auth_non_owner_cannot_call() {
|
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
#[test]
|
|
79
|
-
#[should_panic(expected = "Error(Contract, #
|
|
90
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
80
91
|
fn auth_require_owner_when_no_owner_set() {
|
|
81
92
|
let env = Env::default();
|
|
82
93
|
let owner = Address::generate(&env);
|
|
@@ -154,7 +165,7 @@ fn transfer_ownership_to_same_owner() {
|
|
|
154
165
|
}
|
|
155
166
|
|
|
156
167
|
#[test]
|
|
157
|
-
#[should_panic(expected = "Error(Contract, #
|
|
168
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
158
169
|
fn transfer_after_renounce_fails() {
|
|
159
170
|
let env = Env::default();
|
|
160
171
|
let owner = Address::generate(&env);
|
|
@@ -218,7 +229,7 @@ fn renounce_ownership_with_event() {
|
|
|
218
229
|
}
|
|
219
230
|
|
|
220
231
|
#[test]
|
|
221
|
-
#[should_panic(expected = "Error(Contract, #
|
|
232
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
222
233
|
fn renounce_after_renounce_fails() {
|
|
223
234
|
let env = Env::default();
|
|
224
235
|
let owner = Address::generate(&env);
|
|
@@ -297,7 +308,7 @@ fn chain_new_owner_can_transfer() {
|
|
|
297
308
|
// ============================================
|
|
298
309
|
|
|
299
310
|
#[test]
|
|
300
|
-
#[should_panic(expected = "Error(Contract, #
|
|
311
|
+
#[should_panic(expected = "Error(Contract, #1030)")] // OwnerAlreadySet
|
|
301
312
|
fn reinit_owner_fails() {
|
|
302
313
|
let env = Env::default();
|
|
303
314
|
let owner = Address::generate(&env);
|
|
@@ -334,7 +345,7 @@ fn enforce_owner_auth_returns_owner() {
|
|
|
334
345
|
}
|
|
335
346
|
|
|
336
347
|
#[test]
|
|
337
|
-
#[should_panic(expected = "Error(Contract, #
|
|
348
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
338
349
|
fn enforce_owner_auth_no_owner_set_fails() {
|
|
339
350
|
let env = Env::default();
|
|
340
351
|
let owner = Address::generate(&env);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
extern crate std;
|
|
2
2
|
|
|
3
|
-
use crate::
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
use crate::{
|
|
4
|
+
auth::Auth,
|
|
5
|
+
errors::{OwnableError, TtlConfigurableError},
|
|
6
|
+
option_ext::OptionExt,
|
|
7
|
+
ownable::{Ownable, OwnableInitializer},
|
|
8
|
+
testing_utils::assert_event,
|
|
9
|
+
ttl_configurable::{
|
|
10
|
+
TtlConfig, TtlConfigStorage, TtlConfigsFrozen, TtlConfigsSet, TtlConfigurable, LEDGERS_PER_DAY, MAX_TTL,
|
|
11
|
+
},
|
|
8
12
|
};
|
|
9
13
|
use soroban_sdk::{
|
|
10
14
|
contract, contractimpl,
|
|
@@ -90,11 +94,18 @@ impl TtlTestContract {
|
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
// Enable the default `TtlConfigurable` implementation (which requires `
|
|
97
|
+
// Enable the default `TtlConfigurable` implementation (which requires `Auth`) on the test contract.
|
|
94
98
|
//
|
|
95
99
|
// Note: use plain Rust `impl` (not `#[contractimpl(contracttrait)]`) to avoid generating
|
|
96
|
-
// duplicate Soroban contract entrypoints that would collide with this test contract
|
|
97
|
-
|
|
100
|
+
// duplicate Soroban contract entrypoints that would collide with this test contract's helpers.
|
|
101
|
+
|
|
102
|
+
/// Auth implementation for test contract - uses the stored owner as authorizer.
|
|
103
|
+
impl Auth for TtlTestContract {
|
|
104
|
+
fn authorizer(env: &soroban_sdk::Env) -> Address {
|
|
105
|
+
<Self as Ownable>::owner(env).unwrap_or_panic(env, OwnableError::OwnerNotSet)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
impl Ownable for TtlTestContract {}
|
|
98
109
|
impl OwnableInitializer for TtlTestContract {}
|
|
99
110
|
impl TtlConfigurable for TtlTestContract {}
|
|
100
111
|
|
|
@@ -369,7 +380,7 @@ fn test_default_ttl_configurable_freeze() {
|
|
|
369
380
|
}
|
|
370
381
|
|
|
371
382
|
#[test]
|
|
372
|
-
#[should_panic(expected = "Error(Contract, #
|
|
383
|
+
#[should_panic(expected = "Error(Contract, #1021)")] // TtlConfigFrozen
|
|
373
384
|
fn test_default_ttl_configurable_set_when_frozen() {
|
|
374
385
|
let (env, contract_id, owner, client) = setup_contract();
|
|
375
386
|
|
|
@@ -382,7 +393,7 @@ fn test_default_ttl_configurable_set_when_frozen() {
|
|
|
382
393
|
}
|
|
383
394
|
|
|
384
395
|
#[test]
|
|
385
|
-
#[should_panic(expected = "Error(Contract, #
|
|
396
|
+
#[should_panic(expected = "Error(Contract, #1022)")] // TtlConfigAlreadyFrozen
|
|
386
397
|
fn test_default_ttl_configurable_freeze_when_already_frozen() {
|
|
387
398
|
let (env, contract_id, owner, client) = setup_contract();
|
|
388
399
|
|
|
@@ -412,7 +423,7 @@ fn test_default_ttl_configurable_freeze_wrong_signer_fails() {
|
|
|
412
423
|
}
|
|
413
424
|
|
|
414
425
|
#[test]
|
|
415
|
-
#[should_panic(expected = "Error(Contract, #
|
|
426
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
416
427
|
fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
417
428
|
let env = Env::default();
|
|
418
429
|
let contract_id = env.register(TtlTestContract, ());
|
|
@@ -430,7 +441,7 @@ fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
|
430
441
|
// ============================================
|
|
431
442
|
|
|
432
443
|
#[test]
|
|
433
|
-
#[should_panic(expected = "Error(Contract, #
|
|
444
|
+
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
434
445
|
fn test_default_ttl_configurable_invalid_instance_config() {
|
|
435
446
|
let (env, contract_id, owner, client) = setup_contract();
|
|
436
447
|
// threshold > extend_to is invalid
|
|
@@ -441,7 +452,7 @@ fn test_default_ttl_configurable_invalid_instance_config() {
|
|
|
441
452
|
}
|
|
442
453
|
|
|
443
454
|
#[test]
|
|
444
|
-
#[should_panic(expected = "Error(Contract, #
|
|
455
|
+
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
445
456
|
fn test_default_ttl_configurable_invalid_persistent_config() {
|
|
446
457
|
let (env, contract_id, owner, client) = setup_contract();
|
|
447
458
|
let invalid_cfg = TtlConfig::new(5000, 4000);
|
|
@@ -451,7 +462,7 @@ fn test_default_ttl_configurable_invalid_persistent_config() {
|
|
|
451
462
|
}
|
|
452
463
|
|
|
453
464
|
#[test]
|
|
454
|
-
#[should_panic(expected = "Error(Contract, #
|
|
465
|
+
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
455
466
|
fn test_default_ttl_configurable_exceeds_max_ttl() {
|
|
456
467
|
let (env, contract_id, owner, client) = setup_contract();
|
|
457
468
|
let invalid_cfg = TtlConfig::new(1000, MAX_TTL + 1);
|
|
@@ -518,7 +529,7 @@ fn test_default_ttl_configurable_set_wrong_signer_fails() {
|
|
|
518
529
|
}
|
|
519
530
|
|
|
520
531
|
#[test]
|
|
521
|
-
#[should_panic(expected = "Error(Contract, #
|
|
532
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // OwnerNotSet
|
|
522
533
|
fn test_default_ttl_configurable_set_when_owner_not_set() {
|
|
523
534
|
let env = Env::default();
|
|
524
535
|
let contract_id = env.register(TtlTestContract, ());
|
|
@@ -534,7 +545,7 @@ fn test_default_ttl_configurable_set_when_owner_not_set() {
|
|
|
534
545
|
}
|
|
535
546
|
|
|
536
547
|
#[test]
|
|
537
|
-
#[should_panic(expected = "Error(Contract, #
|
|
548
|
+
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
538
549
|
fn test_default_ttl_configurable_exceeds_effective_max_ttl() {
|
|
539
550
|
let (env, contract_id, owner, client) = setup_contract();
|
|
540
551
|
|
|
@@ -256,7 +256,7 @@ fn test_migrate_success() {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
#[test]
|
|
259
|
-
#[should_panic(expected = "Error(Contract, #
|
|
259
|
+
#[should_panic(expected = "Error(Contract, #1050)")] // MigrationNotAllowed
|
|
260
260
|
fn test_migrate_fail_without_upgrade() {
|
|
261
261
|
let env = Env::default();
|
|
262
262
|
let contract_id = env.register(DummyContract, ());
|
|
@@ -271,14 +271,16 @@ fn test_migrate_fail_without_upgrade() {
|
|
|
271
271
|
// Integration test: upgrade then migrate
|
|
272
272
|
// ============================================
|
|
273
273
|
|
|
274
|
+
// TODO (ken): change error code to 1050 and fix test
|
|
274
275
|
#[test]
|
|
275
|
-
#[should_panic(expected = "Error(Contract, #1500)")]
|
|
276
|
+
#[should_panic(expected = "Error(Contract, #1500)")] // MigrationNotAllowed (TEST_WASM uses old error code)
|
|
276
277
|
fn test_cannot_migrate_twice_without_upgrade() {
|
|
277
278
|
let env = Env::default();
|
|
278
279
|
let contract_id = env.register(DummyContract, ());
|
|
279
280
|
let client = DummyContractClient::new(&env, &contract_id);
|
|
280
281
|
|
|
281
282
|
// First upgrade and migrate with valid WASM
|
|
283
|
+
// Note: TEST_WASM is a pre-compiled contract with old error codes (1500 instead of 1050)
|
|
282
284
|
let wasm_hash = env.deployer().upload_contract_wasm(Bytes::from_slice(&env, TEST_WASM));
|
|
283
285
|
client.upgrade(&wasm_hash);
|
|
284
286
|
client.migrate(&());
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
+
self as utils,
|
|
3
|
+
auth::{require_auth, Auth},
|
|
2
4
|
errors::TtlConfigurableError,
|
|
3
|
-
ownable::{require_owner_auth, Ownable},
|
|
4
5
|
};
|
|
5
|
-
use
|
|
6
|
+
use common_macros::contract_trait;
|
|
7
|
+
use soroban_sdk::{assert_with_error, contractevent, contracttype, Env};
|
|
6
8
|
|
|
7
9
|
/// Ledgers per day (~5 second close time).
|
|
8
10
|
pub const LEDGERS_PER_DAY: u32 = (24 * 3600) / 5;
|
|
@@ -75,15 +77,28 @@ pub enum TtlConfigStorage {
|
|
|
75
77
|
Persistent,
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
/// Initializes TTL configs with the default values (threshold: 29 days, extend_to: 30 days).
|
|
81
|
+
///
|
|
82
|
+
/// This sets both instance and persistent TTL configs to `DEFAULT_TTL_CONFIG`.
|
|
83
|
+
pub fn init_default_ttl_configs(env: &Env) {
|
|
84
|
+
let default_ttl_config = TtlConfig::new(29 * LEDGERS_PER_DAY, 30 * LEDGERS_PER_DAY);
|
|
85
|
+
TtlConfigStorage::set_instance(env, &default_ttl_config);
|
|
86
|
+
TtlConfigStorage::set_persistent(env, &default_ttl_config);
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
/// Trait for contracts that support configurable TTL (Time-To-Live) management.
|
|
79
90
|
///
|
|
80
|
-
/// Allows the contract
|
|
91
|
+
/// Allows the contract authorizer to configure how long instance and persistent storage entries
|
|
81
92
|
/// remain alive on Stellar.
|
|
82
93
|
///
|
|
83
|
-
/// The
|
|
94
|
+
/// The authorizer can also permanently freeze the configuration to prevent future changes,
|
|
84
95
|
/// providing immutability guarantees to users.
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
///
|
|
97
|
+
/// Requires the `Auth` trait to be implemented, which can be provided by either:
|
|
98
|
+
/// - `#[ownable]` macro for single-owner contracts
|
|
99
|
+
/// - `Multisig` trait for multisig-controlled contracts
|
|
100
|
+
#[contract_trait]
|
|
101
|
+
pub trait TtlConfigurable: Auth {
|
|
87
102
|
/// Sets TTL configs for instance and persistent storage.
|
|
88
103
|
///
|
|
89
104
|
/// - `None` values remove the corresponding config (disables auto-extension for that type)
|
|
@@ -97,7 +112,7 @@ pub trait TtlConfigurable: Ownable {
|
|
|
97
112
|
/// - `TtlConfigFrozen` if configs are frozen
|
|
98
113
|
/// - `InvalidTtlConfig` if validation fails
|
|
99
114
|
fn set_ttl_configs(env: &Env, instance: &Option<TtlConfig>, persistent: &Option<TtlConfig>) {
|
|
100
|
-
|
|
115
|
+
require_auth::<Self>(env);
|
|
101
116
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigFrozen);
|
|
102
117
|
|
|
103
118
|
let max_ttl = u32::min(MAX_TTL, env.storage().max_ttl());
|
|
@@ -123,7 +138,7 @@ pub trait TtlConfigurable: Ownable {
|
|
|
123
138
|
/// # Panics
|
|
124
139
|
/// - `TtlConfigAlreadyFrozen` if already frozen
|
|
125
140
|
fn freeze_ttl_configs(env: &Env) {
|
|
126
|
-
|
|
141
|
+
require_auth::<Self>(env);
|
|
127
142
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigAlreadyFrozen);
|
|
128
143
|
|
|
129
144
|
TtlConfigStorage::set_frozen(env, &true);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//! TtlExtendable trait for manual instance TTL extension.
|
|
2
|
+
//!
|
|
3
|
+
//! This module provides the `TtlExtendable` trait which allows external callers
|
|
4
|
+
//! to extend a contract's instance storage TTL, keeping the contract alive.
|
|
5
|
+
|
|
6
|
+
use soroban_sdk::Env;
|
|
7
|
+
|
|
8
|
+
/// Trait for contracts that support manual instance TTL extension.
|
|
9
|
+
///
|
|
10
|
+
/// This trait provides a public contract function to extend the instance storage TTL,
|
|
11
|
+
/// allowing external callers to keep the contract alive by paying for TTL extension.
|
|
12
|
+
///
|
|
13
|
+
/// Uses `#[soroban_sdk::contracttrait]` directly (not `#[common_macros::contract_trait]`)
|
|
14
|
+
/// because auto TTL extension would be redundant for a trait whose purpose is manual
|
|
15
|
+
/// TTL control.
|
|
16
|
+
#[soroban_sdk::contracttrait]
|
|
17
|
+
pub trait TtlExtendable {
|
|
18
|
+
/// Extends the instance TTL.
|
|
19
|
+
///
|
|
20
|
+
/// # Arguments
|
|
21
|
+
///
|
|
22
|
+
/// * `threshold` - The threshold to extend the TTL (if current TTL is below this, extend).
|
|
23
|
+
/// * `extend_to` - The TTL to extend to.
|
|
24
|
+
fn extend_instance_ttl(env: &Env, threshold: u32, extend_to: u32) {
|
|
25
|
+
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
use super::*;
|
|
2
|
-
|
|
3
2
|
use soroban_sdk::{
|
|
4
3
|
address_payload::AddressPayload,
|
|
5
4
|
auth::{Context, CustomAccountInterface},
|
|
6
|
-
|
|
5
|
+
contracttype,
|
|
7
6
|
crypto::Hash,
|
|
8
7
|
vec, Symbol,
|
|
9
8
|
};
|
|
@@ -43,7 +42,7 @@ pub struct TransactionAuthData {
|
|
|
43
42
|
// Custom Account Interface Implementation
|
|
44
43
|
// ============================================================================
|
|
45
44
|
|
|
46
|
-
#[
|
|
45
|
+
#[contract_impl]
|
|
47
46
|
impl CustomAccountInterface for LzDVN {
|
|
48
47
|
type Signature = TransactionAuthData;
|
|
49
48
|
type Error = DvnError;
|
|
@@ -125,9 +124,10 @@ impl LzDVN {
|
|
|
125
124
|
///
|
|
126
125
|
/// Used to allow quorum-only admin changes without requiring existing admin authorization.
|
|
127
126
|
fn is_invoking_quorum_change_admin(env: &Env, auth_contexts: &Vec<Context>) -> bool {
|
|
128
|
-
auth_contexts.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
auth_contexts.len() == 1
|
|
128
|
+
&& auth_contexts.first().is_some_and(|ctx| {
|
|
129
|
+
let Context::Contract(c) = ctx else { return false };
|
|
130
|
+
c.contract == env.current_contract_address() && c.fn_name == Symbol::new(env, "quorum_change_admin")
|
|
131
|
+
})
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -5,17 +5,14 @@
|
|
|
5
5
|
//! signatures for authorization and implements Soroban's custom account
|
|
6
6
|
//! interface for transaction signing.
|
|
7
7
|
|
|
8
|
-
use crate::{
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
use common_macros::{contract_impl, ttl_configurable, upgradeable};
|
|
8
|
+
use crate::{errors::DvnError, events::SetDstConfig, storage::DvnStorage, Call, DstConfig, DstConfigParam, IDVN};
|
|
9
|
+
use common_macros::{contract_impl, lz_contract};
|
|
12
10
|
use endpoint_v2::FeeRecipient;
|
|
13
11
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
14
|
-
use soroban_sdk::
|
|
15
|
-
use
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
use utils::upgradeable::UpgradeableInternal;
|
|
12
|
+
use soroban_sdk::{xdr::ToXdr, Address, Bytes, BytesN, Env, Vec};
|
|
13
|
+
use utils::{
|
|
14
|
+
buffer_writer::BufferWriter, multisig, option_ext::OptionExt, ttl_configurable, upgradeable::UpgradeableInternal,
|
|
15
|
+
};
|
|
19
16
|
use worker::{
|
|
20
17
|
assert_acl, assert_not_paused, assert_supported_message_lib, init_worker, require_admin_auth, set_admin_by_admin,
|
|
21
18
|
set_admin_by_owner, DvnFeeLibClient, DvnFeeParams, Worker,
|
|
@@ -25,9 +22,7 @@ use worker::{
|
|
|
25
22
|
///
|
|
26
23
|
/// Implements multisig-based verification with custom account authorization.
|
|
27
24
|
/// The contract owns itself, allowing the multisig quorum to authorize operations.
|
|
28
|
-
#[
|
|
29
|
-
#[ttl_configurable]
|
|
30
|
-
#[upgradeable]
|
|
25
|
+
#[lz_contract(multisig, upgradeable)]
|
|
31
26
|
pub struct LzDVN;
|
|
32
27
|
|
|
33
28
|
// ============================================================================
|
|
@@ -60,7 +55,8 @@ impl LzDVN {
|
|
|
60
55
|
worker_fee_lib: &Address,
|
|
61
56
|
deposit_address: &Address,
|
|
62
57
|
) {
|
|
63
|
-
|
|
58
|
+
ttl_configurable::init_default_ttl_configs(env);
|
|
59
|
+
multisig::init_multisig(env, signers, threshold);
|
|
64
60
|
init_worker::<Self>(
|
|
65
61
|
env,
|
|
66
62
|
admins,
|
|
@@ -219,32 +215,8 @@ impl UpgradeableInternal for LzDVN {
|
|
|
219
215
|
}
|
|
220
216
|
|
|
221
217
|
// ============================================================================
|
|
222
|
-
//
|
|
223
|
-
// ============================================================================
|
|
224
|
-
|
|
225
|
-
/// Self-owning contract: the DVN owns itself.
|
|
226
|
-
///
|
|
227
|
-
/// This allows multisig quorum approval to serve as owner authorization.
|
|
228
|
-
/// Ownership transfer and renouncement are disabled since the contract is self-owned.
|
|
229
|
-
impl Ownable for LzDVN {
|
|
230
|
-
fn owner(env: &Env) -> Option<Address> {
|
|
231
|
-
Some(env.current_contract_address())
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
fn transfer_ownership(env: &Env, _new_owner: &Address) {
|
|
235
|
-
panic_with_error!(env, DvnError::InvalidInvocation);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
fn renounce_ownership(env: &Env) {
|
|
239
|
-
panic_with_error!(env, DvnError::InvalidInvocation);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// ============================================================================
|
|
244
|
-
// Include SubModules
|
|
218
|
+
// Include Auth Module
|
|
245
219
|
// ============================================================================
|
|
246
220
|
|
|
247
221
|
#[path = "auth.rs"]
|
|
248
222
|
pub mod auth;
|
|
249
|
-
#[path = "multisig.rs"]
|
|
250
|
-
pub mod multisig;
|
|
@@ -6,14 +6,7 @@ pub enum DvnError {
|
|
|
6
6
|
EidNotSupported,
|
|
7
7
|
HashAlreadyUsed,
|
|
8
8
|
InvalidInvocation,
|
|
9
|
-
InvalidSigner,
|
|
10
9
|
InvalidVid,
|
|
11
10
|
NonContractInvoke,
|
|
12
11
|
OnlyAdmin,
|
|
13
|
-
SignatureError,
|
|
14
|
-
SignerAlreadyExists,
|
|
15
|
-
SignerNotFound,
|
|
16
|
-
TotalSignersLessThanThreshold,
|
|
17
|
-
UnsortedSigners,
|
|
18
|
-
ZeroThreshold,
|
|
19
12
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
use crate::DstConfigParam;
|
|
2
|
-
use soroban_sdk::{contractevent,
|
|
3
|
-
|
|
4
|
-
#[contractevent]
|
|
5
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
6
|
-
pub struct SignerSet {
|
|
7
|
-
pub signer: BytesN<20>,
|
|
8
|
-
pub active: bool,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
#[contractevent]
|
|
12
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
13
|
-
pub struct ThresholdSet {
|
|
14
|
-
pub threshold: u32,
|
|
15
|
-
}
|
|
2
|
+
use soroban_sdk::{contractevent, Vec};
|
|
16
3
|
|
|
17
4
|
#[contractevent]
|
|
18
5
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
use crate::IMultisig;
|
|
2
1
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
3
2
|
use soroban_sdk::{contractclient, contracttype, Address, BytesN, Env, Symbol, Val, Vec};
|
|
3
|
+
use utils::multisig::Multisig;
|
|
4
4
|
use worker::Worker;
|
|
5
5
|
|
|
6
6
|
/// Configuration for a destination chain.
|
|
@@ -47,7 +47,7 @@ pub struct Call {
|
|
|
47
47
|
/// Extends the LayerZero DVN interface with destination configuration management
|
|
48
48
|
/// and multisig capabilities for secure cross-chain message verification.
|
|
49
49
|
#[contractclient(name = "DVNClient")]
|
|
50
|
-
pub trait IDVN: ILayerZeroDVN + Worker +
|
|
50
|
+
pub trait IDVN: ILayerZeroDVN + Worker + Multisig {
|
|
51
51
|
/// Sets the configuration for one or more destination chains.
|
|
52
52
|
///
|
|
53
53
|
/// # Arguments
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
use crate::DstConfig;
|
|
2
2
|
use common_macros::storage;
|
|
3
|
-
use soroban_sdk::
|
|
3
|
+
use soroban_sdk::BytesN;
|
|
4
4
|
|
|
5
5
|
/// DVN contract storage keys.
|
|
6
|
+
///
|
|
7
|
+
/// Note: Multisig storage (Signers, Threshold) is provided by `utils::multisig::MultisigStorage`.
|
|
6
8
|
#[storage]
|
|
7
9
|
pub enum DvnStorage {
|
|
8
|
-
// ======================== Multisig ========================
|
|
9
|
-
/// List of authorized signer addresses (20-byte Ethereum addresses).
|
|
10
|
-
#[persistent(Vec<BytesN<20>>)]
|
|
11
|
-
#[default(Vec::new(env))]
|
|
12
|
-
Signers,
|
|
13
|
-
|
|
14
|
-
/// Minimum number of signatures required for multisig operations.
|
|
15
|
-
#[instance(u32)]
|
|
16
|
-
#[default(0)]
|
|
17
|
-
Threshold,
|
|
18
|
-
|
|
19
|
-
// ======================== DVN ============================
|
|
20
10
|
/// Verifier ID - unique identifier for this DVN instance.
|
|
21
11
|
#[instance(u32)]
|
|
22
12
|
Vid,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
use crate::tests::setup::{TestSetup, VID};
|
|
2
1
|
use crate::{
|
|
3
2
|
dvn::auth::{Sender, TransactionAuthData},
|
|
4
3
|
errors::DvnError,
|
|
4
|
+
tests::setup::{TestSetup, VID},
|
|
5
5
|
};
|
|
6
6
|
use ed25519_dalek::{Signer, SigningKey};
|
|
7
7
|
use rand::thread_rng;
|
|
@@ -134,15 +134,15 @@ fn test_check_auth_wrong_signer_fails() {
|
|
|
134
134
|
sender: Sender::Admin(public_key, signature),
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
// verify_signatures panics with
|
|
138
|
-
let res = env.try_invoke_contract_check_auth::<
|
|
137
|
+
// verify_signatures panics with MultisigError::SignerNotFound when signer is not found
|
|
138
|
+
let res = env.try_invoke_contract_check_auth::<utils::errors::MultisigError>(
|
|
139
139
|
&setup.contract_id,
|
|
140
140
|
&payload,
|
|
141
141
|
tx_auth.into_val(&env),
|
|
142
142
|
&auth_contexts,
|
|
143
143
|
);
|
|
144
144
|
|
|
145
|
-
assert_eq!(res, Err(Ok(
|
|
145
|
+
assert_eq!(res, Err(Ok(utils::errors::MultisigError::SignerNotFound)));
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
#[test]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
use crate::tests::setup::TestSetup;
|
|
2
|
-
use crate::{dvn::LzDVN, DVNClient, DstConfig, DstConfigParam, IDVN};
|
|
1
|
+
use crate::{dvn::LzDVN, tests::setup::TestSetup, DVNClient, DstConfig, DstConfigParam, IDVN};
|
|
3
2
|
use endpoint_v2::FeeRecipient;
|
|
4
3
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
5
4
|
use soroban_sdk::{
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
use crate::errors::DvnError;
|
|
2
|
-
use crate::storage::DvnStorage;
|
|
3
1
|
use crate::tests::setup::TestSetup;
|
|
4
2
|
use soroban_sdk::{
|
|
5
3
|
testutils::{AuthorizedFunction, BytesN as _},
|
|
6
4
|
BytesN, Env, IntoVal, Symbol,
|
|
7
5
|
};
|
|
6
|
+
use utils::errors::MultisigError;
|
|
8
7
|
|
|
9
8
|
fn random_signer(env: &Env) -> BytesN<20> {
|
|
10
9
|
BytesN::random(env)
|
|
@@ -12,7 +11,7 @@ fn random_signer(env: &Env) -> BytesN<20> {
|
|
|
12
11
|
|
|
13
12
|
fn clear_signers(setup: &TestSetup) {
|
|
14
13
|
setup.env.as_contract(&setup.contract_id, || {
|
|
15
|
-
|
|
14
|
+
utils::multisig::MultisigStorage::remove_signers(&setup.env);
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -48,7 +47,7 @@ fn test_set_signer_duplicate_fails() {
|
|
|
48
47
|
setup.multisig_client.set_signer(&signer, &true);
|
|
49
48
|
let res = setup.multisig_client.try_set_signer(&signer, &true);
|
|
50
49
|
|
|
51
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
50
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerAlreadyExists.into());
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
#[test]
|
|
@@ -69,7 +68,7 @@ fn test_set_signer_remove_not_found() {
|
|
|
69
68
|
let signer = random_signer(&setup.env);
|
|
70
69
|
|
|
71
70
|
let res = setup.multisig_client.try_set_signer(&signer, &false);
|
|
72
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
71
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
#[test]
|
|
@@ -78,7 +77,7 @@ fn test_set_signer_invalid_signer_zero_address() {
|
|
|
78
77
|
let zero = BytesN::from_array(&setup.env, &[0u8; 20]);
|
|
79
78
|
|
|
80
79
|
let res = setup.multisig_client.try_set_signer(&zero, &true);
|
|
81
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
80
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::InvalidSigner.into());
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
#[test]
|
|
@@ -115,7 +114,7 @@ fn test_remove_signer_when_no_signers() {
|
|
|
115
114
|
|
|
116
115
|
let signer = random_signer(&setup.env);
|
|
117
116
|
let res = setup.multisig_client.try_set_signer(&signer, &false);
|
|
118
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
117
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
#[test]
|
|
@@ -129,5 +128,5 @@ fn test_remove_signer_violates_threshold() {
|
|
|
129
128
|
|
|
130
129
|
// Removing a signer should fail because it would leave only 1 signer with threshold 2
|
|
131
130
|
let res = setup.multisig_client.try_set_signer(&signer_to_remove, &false);
|
|
132
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
131
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
|
|
133
132
|
}
|