mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Initial version of Call::decode dispatch. (#300)
* Initial version of call dispatch. * cargo fmt --all * Remove unused stuff. * cargo fmt --all * weight is part of msg + events * should_fail_on_weight_mismatch * plug into runtime * cargo fmt --all * fix benchmarks compilation? * expected/actual values in events * return actual weight from MessageDispatch::dispatch() * MessageOrigin -> InstanceId + move bridge_account_id to bp-runtime * fix benchmarks again * cargo fmt --all * clippy Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
c7437c7d91
commit
858940050a
@@ -6,6 +6,20 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
|
||||
[dependencies.sp-io]
|
||||
version = "2.0.0-rc6"
|
||||
tag = 'v2.0.0-rc6'
|
||||
default-features = false
|
||||
git = "https://github.com/paritytech/substrate/"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
std = [
|
||||
"codec/std",
|
||||
"sp-io/std",
|
||||
]
|
||||
|
||||
@@ -18,8 +18,29 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use sp_io::hashing::blake2_256;
|
||||
|
||||
/// Call-dispatch module prefix.
|
||||
pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/call-dispatch";
|
||||
|
||||
/// Id of deployed module instance. We have a bunch of pallets that may be used in
|
||||
/// different bridges. E.g. message-lane pallet may be deployed twice in the same
|
||||
/// runtime to bridge ThisChain with Chain1 and Chain2. Sometimes we need to be able
|
||||
/// to identify deployed instance dynamically. This type is used for that.
|
||||
pub type InstanceId = [u8; 4];
|
||||
|
||||
/// Returns id of account that acts as "system" account of given bridge instance.
|
||||
/// The `module_prefix` (arbitrary slice) may be used to generate module-level
|
||||
/// "system" account, so you could have separate "system" accounts for currency
|
||||
/// exchange, message dispatch and other modules.
|
||||
///
|
||||
/// The account is not supposed to actually exists on the chain, or to have any funds.
|
||||
/// It is only used to
|
||||
pub fn bridge_account_id<AccountId>(bridge: InstanceId, module_prefix: &[u8]) -> AccountId
|
||||
where
|
||||
AccountId: Decode + Default,
|
||||
{
|
||||
let entropy = (module_prefix, bridge).using_encoded(blake2_256);
|
||||
AccountId::decode(&mut &entropy[..]).unwrap_or_default()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user