From 688aa88570f41830ab56c4adefa99330782ffc64 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Wed, 26 Jul 2023 01:52:55 +1200 Subject: [PATCH] improve deps for xcm-emulator (#2925) * improve deps for xcm-emulator * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <> --- cumulus/Cargo.lock | 2 +- cumulus/xcm/xcm-emulator/Cargo.toml | 2 +- cumulus/xcm/xcm-emulator/src/lib.rs | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cumulus/Cargo.lock b/cumulus/Cargo.lock index 1b69ce7539..aa43e63916 100644 --- a/cumulus/Cargo.lock +++ b/cumulus/Cargo.lock @@ -16597,7 +16597,6 @@ dependencies = [ "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-test-relay-sproof-builder", - "cumulus-test-service", "frame-support", "frame-system", "log", @@ -16613,6 +16612,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", + "sp-runtime", "sp-std", "sp-trie", "xcm", diff --git a/cumulus/xcm/xcm-emulator/Cargo.toml b/cumulus/xcm/xcm-emulator/Cargo.toml index 55ee948877..f19b58c25a 100644 --- a/cumulus/xcm/xcm-emulator/Cargo.toml +++ b/cumulus/xcm/xcm-emulator/Cargo.toml @@ -20,6 +20,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-message-queue = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -28,7 +29,6 @@ cumulus-primitives-core = { path = "../../primitives/core"} cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue" } cumulus-pallet-dmp-queue = { path = "../../pallets/dmp-queue" } cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system" } -cumulus-test-service = { path = "../../test/service" } parachain-info = { path = "../../parachains/pallets/parachain-info" } cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" } cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" } diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 0b5a6eec4a..115a32ebf2 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -28,7 +28,7 @@ pub use frame_support::{ pub use frame_system::AccountInfo; pub use pallet_balances::AccountData; pub use sp_arithmetic::traits::Bounded; -pub use sp_core::{storage::Storage, H256}; +pub use sp_core::{storage::Storage, Pair, H256}; pub use sp_io; pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, fmt::Debug}; pub use sp_trie::StorageProof; @@ -43,7 +43,6 @@ pub use cumulus_primitives_core::{ }; pub use cumulus_primitives_parachain_inherent::ParachainInherentData; pub use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; -pub use cumulus_test_service::get_account_id_from_seed; pub use pallet_message_queue; pub use parachain_info; pub use parachains_common::{AccountId, BlockNumber}; @@ -251,6 +250,19 @@ impl fmt::Display for BridgeMessageDispatchError { } } +/// Helper function to generate an account ID from seed. +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + sp_runtime::MultiSigner: + From<<::Pair as sp_core::Pair>::Public>, +{ + use sp_runtime::traits::IdentifyAccount; + let pubkey = TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public(); + sp_runtime::MultiSigner::from(pubkey).into_account() +} + // Relay Chain Implementation #[macro_export] macro_rules! decl_test_relay_chains {