Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 71d10b4

Browse files
authored
Remove indices from node-template (#5025)
* Remove indices from node-template * Use identity lookup instead * Bump impl * clean cargo.toml
1 parent 063c0c3 commit 71d10b4

File tree

5 files changed

+9
-33
lines changed

5 files changed

+9
-33
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/node/src/chain_spec.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use sp_core::{Pair, Public, sr25519};
22
use node_template_runtime::{
33
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
4-
IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature
4+
SudoConfig, SystemConfig, WASM_BINARY, Signature
55
};
66
use sp_consensus_aura::sr25519::{AuthorityId as AuraId};
77
use grandpa_primitives::{AuthorityId as GrandpaId};
@@ -127,21 +127,18 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
127127
code: WASM_BINARY.to_vec(),
128128
changes_trie_config: Default::default(),
129129
}),
130-
indices: Some(IndicesConfig {
131-
indices: vec![],
132-
}),
133130
balances: Some(BalancesConfig {
134131
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
135132
}),
136-
sudo: Some(SudoConfig {
137-
key: root_key,
138-
}),
139133
aura: Some(AuraConfig {
140134
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
141135
}),
142136
grandpa: Some(GrandpaConfig {
143137
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
144138
}),
139+
sudo: Some(SudoConfig {
140+
key: root_key,
141+
}),
145142
}
146143
}
147144

bin/node-template/runtime/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ aura = { version = "2.0.0-dev", default-features = false, package = "pallet-aura
1414
balances = { version = "2.0.0-dev", default-features = false, package = "pallet-balances", path = "../../../frame/balances" }
1515
frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../frame/support" }
1616
grandpa = { version = "2.0.0-dev", default-features = false, package = "pallet-grandpa", path = "../../../frame/grandpa" }
17-
indices = { version = "2.0.0-dev", default-features = false, package = "pallet-indices", path = "../../../frame/indices" }
1817
randomness-collective-flip = { version = "2.0.0-dev", default-features = false, package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip" }
1918
sudo = { version = "2.0.0-dev", default-features = false, package = "pallet-sudo", path = "../../../frame/sudo" }
2019
system = { version = "2.0.0-dev", default-features = false, package = "frame-system", path = "../../../frame/system" }
@@ -49,7 +48,6 @@ std = [
4948
"frame-executive/std",
5049
"frame-support/std",
5150
"grandpa/std",
52-
"indices/std",
5351
"randomness-collective-flip/std",
5452
"serde",
5553
"sp-api/std",

bin/node-template/runtime/src/lib.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use sp_runtime::{
1515
impl_opaque_keys, MultiSignature,
1616
};
1717
use sp_runtime::traits::{
18-
BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount
18+
BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount
1919
};
2020
use sp_api::impl_runtime_apis;
2121
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -132,7 +132,7 @@ impl system::Trait for Runtime {
132132
/// The aggregated dispatch type that is available for extrinsics.
133133
type Call = Call;
134134
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
135-
type Lookup = Indices;
135+
type Lookup = IdentityLookup<AccountId>;
136136
/// The index type for storing how many extrinsics an account has signed.
137137
type Index = Index;
138138
/// The index type for blocks.
@@ -177,23 +177,6 @@ impl grandpa::Trait for Runtime {
177177
type Event = Event;
178178
}
179179

180-
parameter_types! {
181-
/// How much an index costs.
182-
pub const IndexDeposit: u128 = 100;
183-
}
184-
185-
impl indices::Trait for Runtime {
186-
/// The type for recording indexing into the account enumeration. If this ever overflows, there
187-
/// will be problems!
188-
type AccountIndex = AccountIndex;
189-
/// The ubiquitous event type.
190-
type Event = Event;
191-
/// The currency type.
192-
type Currency = Balances;
193-
/// How much an index costs.
194-
type Deposit = IndexDeposit;
195-
}
196-
197180
parameter_types! {
198181
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
199182
}
@@ -250,21 +233,20 @@ construct_runtime!(
250233
UncheckedExtrinsic = UncheckedExtrinsic
251234
{
252235
System: system::{Module, Call, Config, Storage, Event<T>},
236+
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
253237
Timestamp: timestamp::{Module, Call, Storage, Inherent},
254238
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
255239
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
256-
Indices: indices::{Module, Call, Storage, Event<T>, Config<T>},
257240
Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},
258241
TransactionPayment: transaction_payment::{Module, Storage},
259242
Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
260243
// Used for the module template in `./template.rs`
261244
TemplateModule: template::{Module, Call, Storage, Event<T>},
262-
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
263245
}
264246
);
265247

266248
/// The address format for describing accounts.
267-
pub type Address = <Indices as StaticLookup>::Source;
249+
pub type Address = AccountId;
268250
/// Block header type as expected by this runtime.
269251
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
270252
/// Block type as expected by this runtime.

frame/indices/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<T: Trait> StaticLookup for Module<T> {
264264
type Source = address::Address<T::AccountId, T::AccountIndex>;
265265
type Target = T::AccountId;
266266

267-
fn lookup(a: Self::Source) -> Result<T::AccountId, LookupError> {
267+
fn lookup(a: Self::Source) -> Result<Self::Target, LookupError> {
268268
Self::lookup_address(a).ok_or(LookupError)
269269
}
270270

0 commit comments

Comments
 (0)