mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Migrate srml crates to the 2018 edition (#1755)
This commit is contained in:
committed by
Gav Wood
parent
b28f7328ac
commit
c860787db7
@@ -2,21 +2,24 @@
|
||||
name = "srml-grandpa"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
hex-literal = "0.1.0"
|
||||
#hex-literal = "0.1.0"
|
||||
serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "3.0", default-features = false }
|
||||
parity-codec-derive = { version = "3.0", default-features = false }
|
||||
substrate-primitives = { path = "../../core/primitives", default-features = false }
|
||||
substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
srml-system = { path = "../system", default-features = false }
|
||||
srml-session = { path = "../session", default-features = false }
|
||||
system = { package = "srml-system", path = "../system", default-features = false }
|
||||
session = { package = "srml-session", path = "../session", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -26,10 +29,9 @@ std = [
|
||||
"parity-codec/std",
|
||||
"substrate-primitives/std",
|
||||
"substrate-finality-grandpa-primitives/std",
|
||||
"sr-std/std",
|
||||
"sr-io/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
"srml-system/std",
|
||||
"srml-session/std",
|
||||
"primitives/std",
|
||||
"system/std",
|
||||
"session/std",
|
||||
]
|
||||
|
||||
@@ -27,39 +27,19 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use]
|
||||
extern crate sr_std as rstd;
|
||||
|
||||
#[macro_use]
|
||||
extern crate srml_support as runtime_support;
|
||||
// re-export since this is necessary for `impl_apis` in runtime.
|
||||
pub use substrate_finality_grandpa_primitives as fg_primitives;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate parity_codec;
|
||||
#[macro_use]
|
||||
extern crate parity_codec_derive;
|
||||
|
||||
extern crate sr_primitives as primitives;
|
||||
extern crate parity_codec as codec;
|
||||
extern crate srml_system as system;
|
||||
extern crate srml_session as session;
|
||||
extern crate substrate_primitives;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate sr_io as runtime_io;
|
||||
|
||||
// re-export since this is necessary for `impl_apis` in runtime.
|
||||
pub extern crate substrate_finality_grandpa_primitives as fg_primitives;
|
||||
|
||||
use serde_derive::Serialize;
|
||||
use rstd::prelude::*;
|
||||
use parity_codec as codec;
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
use fg_primitives::ScheduledChange;
|
||||
use runtime_support::Parameter;
|
||||
use runtime_support::dispatch::Result;
|
||||
use runtime_support::storage::StorageValue;
|
||||
use runtime_support::storage::unhashed::StorageVec;
|
||||
use srml_support::{Parameter, decl_event, decl_storage, decl_module};
|
||||
use srml_support::dispatch::Result;
|
||||
use srml_support::storage::StorageValue;
|
||||
use srml_support::storage::unhashed::StorageVec;
|
||||
use primitives::traits::{CurrentHeight, Convert};
|
||||
use substrate_primitives::Ed25519AuthorityId;
|
||||
use system::ensure_signed;
|
||||
@@ -71,7 +51,7 @@ mod tests;
|
||||
struct AuthorityStorageVec<S: codec::Codec + Default>(rstd::marker::PhantomData<S>);
|
||||
impl<S: codec::Codec + Default> StorageVec for AuthorityStorageVec<S> {
|
||||
type Item = (S, u64);
|
||||
const PREFIX: &'static [u8] = ::fg_primitives::well_known_keys::AUTHORITY_PREFIX;
|
||||
const PREFIX: &'static [u8] = crate::fg_primitives::well_known_keys::AUTHORITY_PREFIX;
|
||||
}
|
||||
|
||||
/// The log type of this crate, projected from module trait type.
|
||||
@@ -162,12 +142,12 @@ decl_storage! {
|
||||
let auth_count = config.authorities.len() as u32;
|
||||
config.authorities.iter().enumerate().for_each(|(i, v)| {
|
||||
storage.insert((i as u32).to_keyed_vec(
|
||||
::fg_primitives::well_known_keys::AUTHORITY_PREFIX),
|
||||
crate::fg_primitives::well_known_keys::AUTHORITY_PREFIX),
|
||||
v.encode()
|
||||
);
|
||||
});
|
||||
storage.insert(
|
||||
::fg_primitives::well_known_keys::AUTHORITY_COUNT.to_vec(),
|
||||
crate::fg_primitives::well_known_keys::AUTHORITY_COUNT.to_vec(),
|
||||
auth_count.encode(),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
use primitives::{BuildStorage, traits::IdentityLookup, testing::{Digest, DigestItem, Header}};
|
||||
use primitives::generic::DigestItem as GenDigestItem;
|
||||
use runtime_io;
|
||||
use srml_support::{impl_outer_origin, impl_outer_event};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use parity_codec::Encode;
|
||||
use {system, GenesisConfig, Trait, Module, RawLog};
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
use crate::{GenesisConfig, Trait, Module, RawLog};
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
@@ -58,7 +60,7 @@ impl system::Trait for Test {
|
||||
}
|
||||
|
||||
mod grandpa {
|
||||
pub use ::Event;
|
||||
pub use crate::Event;
|
||||
}
|
||||
|
||||
impl_outer_event!{
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
use primitives::{testing, traits::OnFinalise};
|
||||
use primitives::traits::Header;
|
||||
use runtime_io::with_externalities;
|
||||
use mock::{Grandpa, System, new_test_ext};
|
||||
use crate::mock::{Grandpa, System, new_test_ext};
|
||||
use system::{EventRecord, Phase};
|
||||
use {RawLog, RawEvent};
|
||||
use crate::{RawLog, RawEvent};
|
||||
|
||||
#[test]
|
||||
fn authorities_change_logged() {
|
||||
|
||||
Reference in New Issue
Block a user