mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 07:41:08 +00:00
Split Indices module from Balances (#1404)
* Indices module * Remove indices stuff from balances * Rejob node, move Lookup into system. * Fix up some modules. * Fix democracy tests * Fix staking tests * Fix more tests * Final test fixes * Bump runtime versions * Assets uses compact dispatchers * Contracts module uses indexed addressing * Democracy has more compact encoding * Example now demonstrates compact eencoding * Sudo uses indexed address * Upgrade key also uses indexed lookups * Assets more compact types. * Fix test * Rebuild runtime, whitespace * Remove TOODs * Remove TODOs * Add a couple of tests back to balances. * Update lib.rs * Update lib.rs
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
//! Primitives for the runtime modules.
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::{self, result};
|
||||
use rstd::{self, result, marker::PhantomData};
|
||||
use runtime_io;
|
||||
#[cfg(feature = "std")] use std::fmt::{Debug, Display};
|
||||
#[cfg(feature = "std")] use serde::{Serialize, de::DeserializeOwned};
|
||||
@@ -54,7 +54,7 @@ pub trait Verify {
|
||||
/// Some sort of check on the origin is performed by this object.
|
||||
pub trait EnsureOrigin<OuterOrigin> {
|
||||
type Success;
|
||||
fn ensure_origin(o: OuterOrigin) -> Result<Self::Success, &'static str>;
|
||||
fn ensure_origin(o: OuterOrigin) -> result::Result<Self::Success, &'static str>;
|
||||
}
|
||||
|
||||
/// Means of changing one type into another in a manner dependent on the source type.
|
||||
@@ -67,6 +67,31 @@ pub trait Lookup {
|
||||
fn lookup(&self, s: Self::Source) -> result::Result<Self::Target, &'static str>;
|
||||
}
|
||||
|
||||
/// Means of changing one type into another in a manner dependent on the source type.
|
||||
/// This variant is different to `Lookup` in that it doesn't (can cannot) require any
|
||||
/// context.
|
||||
pub trait StaticLookup {
|
||||
/// Type to lookup from.
|
||||
type Source: Codec + Clone + PartialEq + MaybeDebug;
|
||||
/// Type to lookup into.
|
||||
type Target;
|
||||
/// Attempt a lookup.
|
||||
fn lookup(s: Self::Source) -> result::Result<Self::Target, &'static str>;
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct IdentityLookup<T>(PhantomData<T>);
|
||||
impl<T: Codec + Clone + PartialEq + MaybeDebug> StaticLookup for IdentityLookup<T> {
|
||||
type Source = T;
|
||||
type Target = T;
|
||||
fn lookup(x: T) -> result::Result<T, &'static str> { Ok(x) }
|
||||
}
|
||||
impl<T> Lookup for IdentityLookup<T> {
|
||||
type Source = T;
|
||||
type Target = T;
|
||||
fn lookup(&self, x: T) -> result::Result<T, &'static str> { Ok(x) }
|
||||
}
|
||||
|
||||
/// Get the "current" block number.
|
||||
pub trait CurrentHeight {
|
||||
/// The type of the block number.
|
||||
|
||||
Reference in New Issue
Block a user