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:
Gav Wood
2019-01-16 15:57:19 +01:00
committed by GitHub
parent 04175ddc83
commit c9f047fe84
44 changed files with 907 additions and 619 deletions
+17 -9
View File
@@ -45,6 +45,7 @@ extern crate srml_council as council;
extern crate srml_democracy as democracy;
extern crate srml_executive as executive;
extern crate srml_grandpa as grandpa;
extern crate srml_indices as indices;
extern crate srml_session as session;
extern crate srml_staking as staking;
extern crate srml_sudo as sudo;
@@ -69,7 +70,8 @@ use runtime_primitives::{ApplyResult, CheckInherentError, BasicInherentData};
use runtime_primitives::transaction_validity::TransactionValidity;
use runtime_primitives::generic;
use runtime_primitives::traits::{
Convert, BlakeTwo256, Block as BlockT, DigestFor, NumberFor, ProvideInherent
Convert, BlakeTwo256, Block as BlockT, DigestFor, NumberFor, ProvideInherent,
StaticLookup
};
use version::RuntimeVersion;
use council::{motions as council_motions, voting as council_voting};
@@ -96,8 +98,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 15,
impl_version: 15,
spec_version: 16,
impl_version: 16,
apis: RUNTIME_API_VERSIONS,
};
@@ -118,6 +120,7 @@ impl system::Trait for Runtime {
type Hashing = BlakeTwo256;
type Digest = generic::Digest<Log>;
type AccountId = AccountId;
type Lookup = Indices;
type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
type Event = Event;
type Log = Log;
@@ -127,10 +130,17 @@ impl aura::Trait for Runtime {
type HandleReport = aura::StakingSlasher<Runtime>;
}
impl indices::Trait for Runtime {
type AccountIndex = AccountIndex;
type IsDeadAccount = Balances;
type ResolveHint = indices::SimpleResolveHint<Self::AccountId, Self::AccountIndex>;
type Event = Event;
}
impl balances::Trait for Runtime {
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnFreeBalanceZero = ((Staking, Contract), Democracy);
type OnNewAccount = Indices;
type EnsureAccountLiquid = (Staking, Democracy);
type Event = Event;
}
@@ -222,6 +232,7 @@ construct_runtime!(
Aura: aura::{Module},
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
Consensus: consensus::{Module, Call, Storage, Config<T>, Log(AuthoritiesChange), Inherent},
Indices: indices,
Balances: balances,
Session: session,
Staking: staking,
@@ -238,10 +249,7 @@ construct_runtime!(
);
/// The address format for describing accounts.
pub use balances::address::Address as RawAddress;
/// The address format for describing accounts.
pub type Address = balances::Address<Runtime>;
pub type Address = <Indices as StaticLookup>::Source;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
/// Block type as expected by this runtime.
@@ -255,7 +263,7 @@ pub type UncheckedExtrinsic = generic::UncheckedMortalCompactExtrinsic<Address,
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Index, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, balances::ChainContext<Runtime>, Balances, AllModules>;
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Balances, AllModules>;
impl_runtime_apis! {
impl client_api::Core<Block> for Runtime {