Westend Mock Runtime and Client (#874)

* Copy-Pasta Call code from mock Rococo to mock Westend runtime

* Update Westend client to include signing and call related code

* Add missing part of license header

* Move `account_info_storage_key` to `polkadot-core` crate
This commit is contained in:
Hernando Castano
2021-04-07 19:50:16 -04:00
committed by Bastian Köcher
parent c6ae74725b
commit 81d4eb9ea6
8 changed files with 143 additions and 53 deletions
@@ -7,6 +7,7 @@ edition = "2018"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["derive"] }
# Bridge Dependencies
bp-messages = { path = "../messages", default-features = false }
@@ -15,6 +16,7 @@ bp-runtime = { path = "../runtime", default-features = false }
# Substrate Based Dependencies
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -24,7 +26,9 @@ std = [
"bp-messages/std",
"bp-polkadot-core/std",
"bp-runtime/std",
"parity-scale-codec/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
"sp-version/std",
]
@@ -29,6 +29,8 @@ pub use bp_polkadot_core::*;
/// Westend Chain
pub type Westend = PolkadotLike;
pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic<Call>;
/// Runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("westend"),
@@ -40,6 +42,22 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
transaction_version: 5,
};
#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, PartialEq, Eq, Clone)]
pub enum Call {
MockModule,
}
impl sp_runtime::traits::Dispatchable for Call {
type Origin = ();
type Config = ();
type Info = ();
type PostInfo = ();
fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> {
unimplemented!("The Call is not expected to be dispatched.")
}
}
// We use this to get the account on Westend (target) which is derived from Rococo's (source)
// account.
pub fn derive_account_from_rococo_id(id: bp_runtime::SourceAccount<AccountId>) -> AccountId {