mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 15:51:04 +00:00
Update to parity-scale-codec (#3232)
* WIP: update codec * WIP * compiling * WIP * rename parity-scale-codec to codec * WIP * fix * remove old comments * use published crates * fix expected error msg * bump version * fmt and fix * remove old comment * fix wrong decoding impl * implement encode like for structures * undo removal of old pending changes * trailingzeroinput * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * update codec * fmt * version is 1.0.0 * show more error * fmt
This commit is contained in:
committed by
Bastian Köcher
parent
a0d442333f
commit
4ed67e03a4
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
# Needed for various traits. In our case, `OnFinalize`.
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
# Needed for type-safe access to storage DB.
|
||||
@@ -23,7 +23,7 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
"system/std",
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0", optional = true }
|
||||
inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
@@ -27,7 +27,7 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
pub use timestamp;
|
||||
|
||||
use rstd::{result, prelude::*};
|
||||
use parity_codec::Encode;
|
||||
use codec::Encode;
|
||||
use srml_support::{decl_storage, decl_module, Parameter, storage::StorageValue, traits::Get};
|
||||
use sr_primitives::{
|
||||
traits::{SaturatedConversion, Saturating, Zero, One, Member, IsMember, TypedKey},
|
||||
@@ -65,7 +65,7 @@ use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent
|
||||
use inherents::{InherentDataProviders, ProvideInherentData};
|
||||
use substrate_consensus_aura_primitives::{AURA_ENGINE_ID, ConsensusLog};
|
||||
#[cfg(feature = "std")]
|
||||
use parity_codec::Decode;
|
||||
use codec::Decode;
|
||||
|
||||
mod mock;
|
||||
mod tests;
|
||||
@@ -138,7 +138,7 @@ impl ProvideInherentData for InherentDataProvider {
|
||||
}
|
||||
|
||||
fn error_to_string(&self, error: &[u8]) -> Option<String> {
|
||||
RuntimeString::decode(&mut &error[..]).map(Into::into)
|
||||
RuntimeString::decode(&mut &error[..]).map(Into::into).ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
@@ -17,7 +17,7 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features =
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sr-primitives/std",
|
||||
"rstd/std",
|
||||
|
||||
@@ -25,7 +25,7 @@ use rstd::collections::btree_set::BTreeSet;
|
||||
use srml_support::{decl_module, decl_storage, for_each_tuple, StorageValue};
|
||||
use srml_support::traits::{FindAuthor, VerifySeal, Get};
|
||||
use srml_support::dispatch::Result as DispatchResult;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use system::ensure_none;
|
||||
use sr_primitives::traits::{SimpleArithmetic, Header as HeaderT, One, Zero};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
@@ -382,7 +382,7 @@ mod tests {
|
||||
{
|
||||
for (id, data) in digests {
|
||||
if id == TEST_ID {
|
||||
return u64::decode(&mut &data[..]);
|
||||
return u64::decode(&mut &data[..]).ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ mod tests {
|
||||
for (id, seal) in seals {
|
||||
if id == TEST_ID {
|
||||
match u64::decode(&mut &seal[..]) {
|
||||
None => return Err("wrong seal"),
|
||||
Some(a) => {
|
||||
Err(_) => return Err("wrong seal"),
|
||||
Ok(a) => {
|
||||
if a != author {
|
||||
return Err("wrong author in seal");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
hex-literal = "0.2"
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.93", optional = true }
|
||||
inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
@@ -28,7 +28,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -28,7 +28,7 @@ use sr_primitives::{generic::DigestItem, ConsensusEngineId};
|
||||
use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert};
|
||||
#[cfg(feature = "std")]
|
||||
use timestamp::TimestampInherentData;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError};
|
||||
#[cfg(feature = "std")]
|
||||
use inherents::{InherentDataProviders, ProvideInherentData};
|
||||
@@ -103,7 +103,7 @@ impl ProvideInherentData for InherentDataProvider {
|
||||
}
|
||||
|
||||
fn error_to_string(&self, error: &[u8]) -> Option<String> {
|
||||
RuntimeString::decode(&mut &error[..]).map(Into::into)
|
||||
RuntimeString::decode(&mut &error[..]).map(Into::into).ok()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ decl_module! {
|
||||
.iter()
|
||||
.filter_map(|s| s.as_pre_runtime())
|
||||
.filter_map(|(id, mut data)| if id == BABE_ENGINE_ID {
|
||||
RawBabePreDigest::decode(&mut data)
|
||||
RawBabePreDigest::decode(&mut data).ok()
|
||||
} else {
|
||||
None
|
||||
})
|
||||
@@ -219,7 +219,7 @@ impl<T: Trait> FindAuthor<u32> for Module<T> {
|
||||
{
|
||||
for (id, mut data) in digests.into_iter() {
|
||||
if id == BABE_ENGINE_ID {
|
||||
return Some(RawBabePreDigest::decode(&mut data)?.authority_index);
|
||||
return Some(RawBabePreDigest::decode(&mut data).ok()?.authority_index);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
substrate-keyring = { path = "../../core/keyring", optional = true }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
@@ -24,7 +24,7 @@ std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"substrate-keyring",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::{cmp, result, mem};
|
||||
use parity_codec::{Codec, Encode, Decode};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use srml_support::{StorageValue, StorageMap, Parameter, decl_event, decl_storage, decl_module};
|
||||
use srml_support::traits::{
|
||||
UpdateBalanceOutcome, Currency, OnFreeBalanceZero, OnUnbalanced,
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
@@ -23,7 +23,7 @@ balances = { package = "srml-balances", path = "../balances" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"safe-mix/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"rstd/std",
|
||||
"serde",
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
pwasm-utils = { version = "0.6.1", default-features = false }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
parity-wasm = { version = "0.31", default-features = false }
|
||||
wasmi-validation = { version = "0.1", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
@@ -33,7 +33,7 @@ core = [
|
||||
]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sr-primitives/std",
|
||||
"runtime-io/std",
|
||||
|
||||
@@ -98,7 +98,7 @@ use crate::wasm::{WasmLoader, WasmVm};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use primitives::crypto::UncheckedFrom;
|
||||
use rstd::{prelude::*, marker::PhantomData};
|
||||
use parity_codec::{Codec, Encode, Decode};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use runtime_io::blake2_256;
|
||||
use sr_primitives::traits::{
|
||||
Hash, StaticLookup, Zero, MaybeSerializeDebug, Member
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use hex_literal::*;
|
||||
use parity_codec::{Decode, Encode, KeyedVec};
|
||||
use codec::{Decode, Encode, KeyedVec};
|
||||
use runtime_io;
|
||||
use runtime_io::with_externalities;
|
||||
use sr_primitives::testing::{Digest, DigestItem, Header, UintAuthorityId, H256};
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::exec::{Ext, EmptyOutputBuf, VmExecResult};
|
||||
use crate::gas::GasMeter;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use sandbox;
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@@ -26,7 +26,7 @@ use sandbox;
|
||||
use system;
|
||||
use rstd::prelude::*;
|
||||
use rstd::mem;
|
||||
use parity_codec::{Decode, Encode};
|
||||
use codec::{Decode, Encode};
|
||||
use sr_primitives::traits::{Bounded, SaturatedConversion};
|
||||
|
||||
/// Enumerates all possible *special* trap conditions.
|
||||
@@ -325,12 +325,12 @@ define_env!(Env, <E: Ext>,
|
||||
let callee = {
|
||||
let callee_buf = read_sandbox_memory(ctx, callee_ptr, callee_len)?;
|
||||
<<E as Ext>::T as system::Trait>::AccountId::decode(&mut &callee_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let value = {
|
||||
let value_buf = read_sandbox_memory(ctx, value_ptr, value_len)?;
|
||||
BalanceOf::<<E as Ext>::T>::decode(&mut &value_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let input_data = read_sandbox_memory(ctx, input_data_ptr, input_data_len)?;
|
||||
|
||||
@@ -399,12 +399,12 @@ define_env!(Env, <E: Ext>,
|
||||
) -> u32 => {
|
||||
let code_hash = {
|
||||
let code_hash_buf = read_sandbox_memory(ctx, code_hash_ptr, code_hash_len)?;
|
||||
<CodeHash<<E as Ext>::T>>::decode(&mut &code_hash_buf[..]).ok_or_else(|| sandbox::HostError)?
|
||||
<CodeHash<<E as Ext>::T>>::decode(&mut &code_hash_buf[..]).map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let value = {
|
||||
let value_buf = read_sandbox_memory(ctx, value_ptr, value_len)?;
|
||||
BalanceOf::<<E as Ext>::T>::decode(&mut &value_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let input_data = read_sandbox_memory(ctx, input_data_ptr, input_data_len)?;
|
||||
|
||||
@@ -569,7 +569,7 @@ define_env!(Env, <E: Ext>,
|
||||
let call = {
|
||||
let call_buf = read_sandbox_memory(ctx, call_ptr, call_len)?;
|
||||
<<<E as Ext>::T as Trait>::Call>::decode(&mut &call_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
|
||||
// Charge gas for dispatching this call.
|
||||
@@ -618,12 +618,12 @@ define_env!(Env, <E: Ext>,
|
||||
let dest = {
|
||||
let dest_buf = read_sandbox_memory(ctx, dest_ptr, dest_len)?;
|
||||
<<E as Ext>::T as system::Trait>::AccountId::decode(&mut &dest_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let code_hash = {
|
||||
let code_hash_buf = read_sandbox_memory(ctx, code_hash_ptr, code_hash_len)?;
|
||||
<CodeHash<<E as Ext>::T>>::decode(&mut &code_hash_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let rent_allowance = {
|
||||
let rent_allowance_buf = read_sandbox_memory(
|
||||
@@ -632,7 +632,7 @@ define_env!(Env, <E: Ext>,
|
||||
rent_allowance_len
|
||||
)?;
|
||||
BalanceOf::<<E as Ext>::T>::decode(&mut &rent_allowance_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
let delta = {
|
||||
// We don't use `with_capacity` here to not eagerly allocate the user specified amount
|
||||
@@ -717,7 +717,7 @@ define_env!(Env, <E: Ext>,
|
||||
_ => {
|
||||
let topics_buf = read_sandbox_memory(ctx, topics_ptr, topics_len)?;
|
||||
Vec::<TopicOf<<E as Ext>::T>>::decode(&mut &topics_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
}
|
||||
};
|
||||
|
||||
@@ -757,7 +757,7 @@ define_env!(Env, <E: Ext>,
|
||||
let value = {
|
||||
let value_buf = read_sandbox_memory(ctx, value_ptr, value_len)?;
|
||||
BalanceOf::<<E as Ext>::T>::decode(&mut &value_buf[..])
|
||||
.ok_or_else(|| sandbox::HostError)?
|
||||
.map_err(|_| sandbox::HostError)?
|
||||
};
|
||||
ctx.ext.set_rent_allowance(value);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
@@ -23,7 +23,7 @@ default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"runtime_io/std",
|
||||
"srml-support/std",
|
||||
|
||||
@@ -22,7 +22,7 @@ use rstd::prelude::*;
|
||||
use rstd::{result, convert::TryFrom};
|
||||
use sr_primitives::traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use parity_codec::{Encode, Decode, Input, Output};
|
||||
use codec::{Encode, Decode, Input, Output, Error};
|
||||
use srml_support::{
|
||||
decl_module, decl_storage, decl_event, ensure,
|
||||
StorageValue, StorageMap, Parameter, Dispatchable, IsSubType, EnumerableStorageMap,
|
||||
@@ -154,12 +154,15 @@ impl Encode for Vote {
|
||||
}
|
||||
}
|
||||
|
||||
impl codec::EncodeLike for Vote {}
|
||||
|
||||
impl Decode for Vote {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
fn decode<I: Input>(input: &mut I) -> core::result::Result<Self, Error> {
|
||||
let b = input.read_byte()?;
|
||||
Some(Vote {
|
||||
Ok(Vote {
|
||||
aye: (b & 0b1000_0000) == 0b1000_0000,
|
||||
conviction: Conviction::try_from(b & 0b0111_1111).ok()?,
|
||||
conviction: Conviction::try_from(b & 0b0111_1111)
|
||||
.map_err(|_| Error::from("Invalid conviction"))?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use sr_primitives::traits::{Zero, IntegerSquareRoot};
|
||||
use rstd::ops::{Add, Mul, Div, Rem};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
@@ -23,7 +23,7 @@ balances = { package = "srml-balances", path = "../balances" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"safe-mix/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"rstd/std",
|
||||
"serde",
|
||||
|
||||
@@ -35,7 +35,7 @@ use srml_support::{
|
||||
OnUnbalanced, ReservableCurrency, WithdrawReason, WithdrawReasons, ChangeMembers
|
||||
}
|
||||
};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use system::{self, ensure_signed, ensure_root};
|
||||
|
||||
// no polynomial attacks:
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
system = { package = "srml-system", path = "../system", default-features = false }
|
||||
balances = { package = "srml-balances", path = "../balances", default-features = false }
|
||||
@@ -20,7 +20,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
"system/std",
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
@@ -25,7 +25,7 @@ std = [
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"sr-primitives/std",
|
||||
"runtime_io/std",
|
||||
"system/std",
|
||||
|
||||
@@ -82,7 +82,7 @@ use sr_primitives::{generic::Digest, traits::{
|
||||
OnInitialize, NumberFor, Block as BlockT, OffchainWorker, ValidateUnsigned
|
||||
}};
|
||||
use srml_support::Dispatchable;
|
||||
use parity_codec::{Codec, Encode};
|
||||
use codec::{Codec, Encode};
|
||||
use system::{extrinsics_root, DigestOf};
|
||||
use sr_primitives::{ApplyOutcome, ApplyError};
|
||||
use sr_primitives::transaction_validity::TransactionValidity;
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
parity-codec = { version = "4.1.1", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
@@ -21,7 +21,7 @@ sr-io = { path = "../../core/sr-io", default-features = false }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -25,13 +25,13 @@ use inherents::{
|
||||
use srml_support::StorageValue;
|
||||
use sr_primitives::traits::{One, Zero, SaturatedConversion};
|
||||
use rstd::{prelude::*, result, cmp, vec};
|
||||
use parity_codec::Decode;
|
||||
use codec::Decode;
|
||||
use srml_support::{decl_module, decl_storage, for_each_tuple};
|
||||
use srml_support::traits::Get;
|
||||
use srml_system::{ensure_none, Trait as SystemTrait};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use parity_codec::Encode;
|
||||
use codec::Encode;
|
||||
|
||||
/// The identifier for the `finalnum` inherent.
|
||||
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"finalnum";
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
support = { package = "srml-support", path = "../support", default-features = false }
|
||||
@@ -20,7 +20,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std =[
|
||||
"serde/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"sr-primitives/std",
|
||||
"support/std",
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use parity_codec::{Decode, Encode, HasCompact, Input, Output};
|
||||
use codec::{Decode, Encode, HasCompact, Input, Output, Error};
|
||||
|
||||
use sr_primitives::traits::{
|
||||
CheckedAdd, CheckedSub, MaybeSerializeDebug, Member, One, Saturating, SimpleArithmetic, Zero, Bounded
|
||||
@@ -284,10 +284,12 @@ impl<AccountId: Encode> Encode for PermissionVersions<AccountId> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<AccountId: Encode> codec::EncodeLike for PermissionVersions<AccountId> {}
|
||||
|
||||
impl<AccountId: Decode> Decode for PermissionVersions<AccountId> {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
fn decode<I: Input>(input: &mut I) -> core::result::Result<Self, Error> {
|
||||
let version = PermissionVersionNumber::decode(input)?;
|
||||
Some(
|
||||
Ok(
|
||||
match version {
|
||||
PermissionVersionNumber::V1 => PermissionVersions::V1(Decode::decode(input)?)
|
||||
}
|
||||
@@ -484,7 +486,7 @@ decl_storage! {
|
||||
config.endowed_accounts.iter().for_each(|account_id| {
|
||||
storage.insert(
|
||||
<FreeBalance<T>>::key_for(asset_id, account_id),
|
||||
<T::Balance as parity_codec::Encode>::encode(&config.initial_balance)
|
||||
<T::Balance as codec::Encode>::encode(&config.initial_balance)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
@@ -23,7 +23,7 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"substrate-finality-grandpa-primitives/std",
|
||||
"rstd/std",
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
pub use substrate_finality_grandpa_primitives as fg_primitives;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use parity_codec::{self as codec, Encode, Decode};
|
||||
use codec::{self as codec, Encode, Decode, Error};
|
||||
use srml_support::{
|
||||
decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue
|
||||
};
|
||||
@@ -78,11 +78,11 @@ pub struct StoredPendingChange<N> {
|
||||
}
|
||||
|
||||
impl<N: Decode> Decode for StoredPendingChange<N> {
|
||||
fn decode<I: codec::Input>(value: &mut I) -> Option<Self> {
|
||||
fn decode<I: codec::Input>(value: &mut I) -> core::result::Result<Self, Error> {
|
||||
let old = OldStoredPendingChange::decode(value)?;
|
||||
let forced = <Option<N>>::decode(value).unwrap_or(None);
|
||||
|
||||
Some(StoredPendingChange {
|
||||
Ok(StoredPendingChange {
|
||||
scheduled_at: old.scheduled_at,
|
||||
delay: old.delay,
|
||||
next_authorities: old.next_authorities,
|
||||
|
||||
@@ -22,7 +22,7 @@ use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Heade
|
||||
use runtime_io;
|
||||
use srml_support::{impl_outer_origin, impl_outer_event, parameter_types};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use crate::{AuthorityId, GenesisConfig, Trait, Module, ConsensusLog};
|
||||
use substrate_finality_grandpa_primitives::GRANDPA_ENGINE_ID;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
@@ -18,7 +18,7 @@ system = { package = "srml-system", path = "../system", default-features = false
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"sr-primitives/std",
|
||||
"rstd/std",
|
||||
"serde",
|
||||
|
||||
@@ -74,7 +74,7 @@ use primitives::{
|
||||
offchain::StorageKind,
|
||||
sr25519, ed25519,
|
||||
};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use sr_primitives::{
|
||||
ApplyError, traits::{Member, IsMember, Extrinsic as ExtrinsicT},
|
||||
transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction},
|
||||
@@ -216,7 +216,7 @@ decl_module! {
|
||||
// we run only when a local authority key is configured
|
||||
if let Ok(key) = sr_io::pubkey(CryptoKey::AuthorityKey) {
|
||||
let authority_id = <T as Trait>::AuthorityId::decode(&mut &key[..])
|
||||
.ok_or(OffchainErr::DecodeAuthorityId)?;
|
||||
.map_err(|_| OffchainErr::DecodeAuthorityId)?;
|
||||
let network_state =
|
||||
sr_io::network_state().map_err(|_| OffchainErr::NetworkState)?;
|
||||
let heartbeat_data = Heartbeat {
|
||||
@@ -282,7 +282,7 @@ decl_module! {
|
||||
match last_gossip {
|
||||
Some(last) => {
|
||||
let worker_status: WorkerStatus<T::BlockNumber> = Decode::decode(&mut &last[..])
|
||||
.ok_or(OffchainErr::DecodeWorkerStatus)?;
|
||||
.map_err(|_| OffchainErr::DecodeWorkerStatus)?;
|
||||
|
||||
let was_aborted = !worker_status.done && worker_status.gossipping_at < now;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
substrate-keyring = { path = "../../core/keyring", optional = true }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime-io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
@@ -25,7 +25,7 @@ std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"substrate-keyring",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"rstd/std",
|
||||
"runtime-io/std",
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#[cfg(feature = "std")]
|
||||
use std::fmt;
|
||||
use rstd::convert::TryInto;
|
||||
use crate::{Member, Decode, Encode, Input, Output};
|
||||
use crate::Member;
|
||||
use codec::{Encode, Decode, Input, Output, Error};
|
||||
|
||||
/// An indices-aware address, which can be either a direct `AccountId` or
|
||||
/// an index.
|
||||
@@ -54,16 +55,16 @@ impl<AccountId, AccountIndex> From<AccountId> for Address<AccountId, AccountInde
|
||||
}
|
||||
}
|
||||
|
||||
fn need_more_than<T: PartialOrd>(a: T, b: T) -> Option<T> {
|
||||
if a < b { Some(b) } else { None }
|
||||
fn need_more_than<T: PartialOrd>(a: T, b: T) -> Result<T, Error> {
|
||||
if a < b { Ok(b) } else { Err("Invalid range".into()) }
|
||||
}
|
||||
|
||||
impl<AccountId, AccountIndex> Decode for Address<AccountId, AccountIndex> where
|
||||
AccountId: Member + Decode,
|
||||
AccountIndex: Member + Decode + PartialOrd<AccountIndex> + Ord + From<u32> + Copy,
|
||||
{
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
Some(match input.read_byte()? {
|
||||
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
|
||||
Ok(match input.read_byte()? {
|
||||
x @ 0x00..=0xef => Address::Index(AccountIndex::from(x as u32)),
|
||||
0xfc => Address::Index(AccountIndex::from(
|
||||
need_more_than(0xef, u16::decode(input)?)? as u32
|
||||
@@ -75,7 +76,7 @@ impl<AccountId, AccountIndex> Decode for Address<AccountId, AccountIndex> where
|
||||
need_more_than(0xffffffffu32.into(), Decode::decode(input)?)?
|
||||
),
|
||||
0xff => Address::Id(Decode::decode(input)?),
|
||||
_ => return None,
|
||||
_ => return Err("Invalid address variant".into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -114,6 +115,11 @@ impl<AccountId, AccountIndex> Encode for Address<AccountId, AccountIndex> where
|
||||
}
|
||||
}
|
||||
|
||||
impl<AccountId, AccountIndex> codec::EncodeLike for Address<AccountId, AccountIndex> where
|
||||
AccountId: Member + Encode,
|
||||
AccountIndex: Member + Encode + PartialOrd<AccountIndex> + Ord + Copy + From<u32> + TryInto<u32>,
|
||||
{}
|
||||
|
||||
impl<AccountId, AccountIndex> Default for Address<AccountId, AccountIndex> where
|
||||
AccountId: Member + Default,
|
||||
AccountIndex: Member,
|
||||
@@ -125,7 +131,7 @@ impl<AccountId, AccountIndex> Default for Address<AccountId, AccountIndex> where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
type Address = super::Address<[u8; 8], u32>;
|
||||
fn index(i: u32) -> Address { super::Address::Index(i) }
|
||||
@@ -135,7 +141,7 @@ mod tests {
|
||||
if let Some(ref a) = a {
|
||||
assert_eq!(d, &a.encode()[..]);
|
||||
}
|
||||
assert_eq!(Address::decode(&mut &d[..]), a);
|
||||
assert_eq!(Address::decode(&mut &d[..]).ok(), a);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::{prelude::*, result, marker::PhantomData, convert::TryInto};
|
||||
use parity_codec::{Encode, Decode, Codec, Input, Output};
|
||||
use codec::{Encode, Codec};
|
||||
use srml_support::{StorageValue, StorageMap, Parameter, decl_module, decl_event, decl_storage};
|
||||
use sr_primitives::traits::{One, SimpleArithmetic, StaticLookup, Member};
|
||||
use system::{IsDeadAccount, OnNewAccount};
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
@@ -13,7 +13,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives",
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"primitives/std",
|
||||
"serde",
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#[cfg(feature = "std")]
|
||||
use serde::Serialize;
|
||||
#[cfg(feature = "std")]
|
||||
use parity_codec::{Decode, Input};
|
||||
use parity_codec::{Encode, Output};
|
||||
use codec::{Decode, Input, Error};
|
||||
use codec::{Encode, Output};
|
||||
use rstd::vec::Vec;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -59,11 +59,13 @@ impl<B, O> Encode for DecodeDifferent<B, O> where B: Encode + 'static, O: Encode
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, O> codec::EncodeLike for DecodeDifferent<B, O> where B: Encode + 'static, O: Encode + 'static {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<B, O> Decode for DecodeDifferent<B, O> where B: 'static, O: Decode + 'static {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
<O>::decode(input).and_then(|val| {
|
||||
Some(DecodeDifferent::Decoded(val))
|
||||
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
|
||||
<O>::decode(input).map(|val| {
|
||||
DecodeDifferent::Decoded(val)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -144,6 +146,8 @@ impl<E: Encode> Encode for FnEncode<E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Encode> codec::EncodeLike for FnEncode<E> {}
|
||||
|
||||
impl<E: Encode + PartialEq> PartialEq for FnEncode<E> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0().eq(&other.0())
|
||||
@@ -223,6 +227,8 @@ impl Encode for DefaultByteGetter {
|
||||
}
|
||||
}
|
||||
|
||||
impl codec::EncodeLike for DefaultByteGetter {}
|
||||
|
||||
impl PartialEq<DefaultByteGetter> for DefaultByteGetter {
|
||||
fn eq(&self, other: &DefaultByteGetter) -> bool {
|
||||
let left = self.0.default_byte();
|
||||
@@ -333,10 +339,12 @@ impl Encode for RuntimeMetadataDeprecated {
|
||||
fn encode_to<W: Output>(&self, _dest: &mut W) {}
|
||||
}
|
||||
|
||||
impl codec::EncodeLike for RuntimeMetadataDeprecated {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl Decode for RuntimeMetadataDeprecated {
|
||||
fn decode<I: Input>(_input: &mut I) -> Option<Self> {
|
||||
unimplemented!()
|
||||
fn decode<I: Input>(_input: &mut I) -> Result<Self, Error> {
|
||||
Err("Decoding is not supported".into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
@@ -26,7 +26,7 @@ historical = ["substrate-trie"]
|
||||
std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"srml-support/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//! Afterwards, the proofs can be fed to a consensus module when reporting misbehavior.
|
||||
|
||||
use rstd::prelude::*;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use sr_primitives::KeyTypeId;
|
||||
use sr_primitives::traits::{Convert, OpaqueKeys, Hash as HashT};
|
||||
use srml_support::{
|
||||
@@ -235,13 +235,13 @@ impl<T: Trait> ProvingTrie<T> {
|
||||
let val_idx = (key_id, key_data).using_encoded(|s| {
|
||||
trie.get_with(s, &mut recorder)
|
||||
.ok()?
|
||||
.and_then(|raw| u32::decode(&mut &*raw))
|
||||
.and_then(|raw| u32::decode(&mut &*raw).ok())
|
||||
})?;
|
||||
|
||||
val_idx.using_encoded(|s| {
|
||||
trie.get_with(s, &mut recorder)
|
||||
.ok()?
|
||||
.and_then(|raw| <IdentificationTuple<T>>::decode(&mut &*raw))
|
||||
.and_then(|raw| <IdentificationTuple<T>>::decode(&mut &*raw).ok())
|
||||
})?;
|
||||
|
||||
Some(recorder.drain().into_iter().map(|r| r.data).collect())
|
||||
@@ -258,11 +258,11 @@ impl<T: Trait> ProvingTrie<T> {
|
||||
let trie = TrieDB::new(&self.db, &self.root).ok()?;
|
||||
let val_idx = (key_id, key_data).using_encoded(|s| trie.get(s))
|
||||
.ok()?
|
||||
.and_then(|raw| u32::decode(&mut &*raw))?;
|
||||
.and_then(|raw| u32::decode(&mut &*raw).ok())?;
|
||||
|
||||
val_idx.using_encoded(|s| trie.get(s))
|
||||
.ok()?
|
||||
.and_then(|raw| <IdentificationTuple<T>>::decode(&mut &*raw))
|
||||
.and_then(|raw| <IdentificationTuple<T>>::decode(&mut &*raw).ok())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::{prelude::*, marker::PhantomData, ops::{Sub, Rem}};
|
||||
use parity_codec::Decode;
|
||||
use codec::Decode;
|
||||
use sr_primitives::KeyTypeId;
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use sr_primitives::traits::{Convert, Zero, Member, OpaqueKeys, TypedKey};
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
substrate-keyring = { path = "../../core/keyring", optional = true }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
@@ -31,7 +31,7 @@ std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"substrate-keyring",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"runtime_io/std",
|
||||
"srml-support/std",
|
||||
|
||||
@@ -284,7 +284,7 @@ mod benches;
|
||||
#[cfg(feature = "std")]
|
||||
use runtime_io::with_storage;
|
||||
use rstd::{prelude::*, result, collections::btree_map::BTreeMap};
|
||||
use parity_codec::{HasCompact, Encode, Decode};
|
||||
use codec::{HasCompact, Encode, Decode};
|
||||
use srml_support::{
|
||||
StorageValue, StorageMap, EnumerableStorageMap, decl_module, decl_event,
|
||||
decl_storage, ensure, traits::{
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
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 }
|
||||
@@ -22,7 +22,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"sr-std/std",
|
||||
"sr-io/std",
|
||||
"sr-primitives/std",
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-codec", version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
srml-metadata = { path = "../metadata", default-features = false }
|
||||
sr-std = { path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
|
||||
@@ -208,7 +208,7 @@ pub trait StorageValue<T: codec::Codec> {
|
||||
let new_val = <T as codec::EncodeAppend>::append(
|
||||
storage.get_raw(Self::key()).unwrap_or_default(),
|
||||
items,
|
||||
).ok_or_else(|| "Could not append given item")?;
|
||||
).map_err(|_| "Could not append given item")?;
|
||||
storage.put_raw(Self::key(), &new_val);
|
||||
Ok(())
|
||||
}
|
||||
@@ -286,7 +286,7 @@ pub trait AppendableStorageMap<K: codec::Codec, V: codec::Codec>: StorageMap<K,
|
||||
let new_val = <V as codec::EncodeAppend>::append(
|
||||
storage.get_raw(&k[..]).unwrap_or_default(),
|
||||
items,
|
||||
).ok_or_else(|| "Could not append given item")?;
|
||||
).map_err(|_| "Could not append given item")?;
|
||||
storage.put_raw(&k[..], &new_val);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ pub trait StorageDoubleMap<K1: codec::Encode, K2: codec::Encode, V: codec::Codec
|
||||
let new_val = <V as codec::EncodeAppend>::append(
|
||||
storage.get_raw(&key).unwrap_or_default(),
|
||||
items,
|
||||
).ok_or_else(|| "Could not append given item")?;
|
||||
).map_err(|_| "Could not append given item")?;
|
||||
storage.put_raw(&key, &new_val);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
runtime_io = { package = "sr-io", path = "../../../core/sr-io", default-features = false }
|
||||
srml-support = { version = "2", path = "../", default-features = false }
|
||||
inherents = { package = "substrate-inherents", path = "../../../core/inherents", default-features = false }
|
||||
@@ -18,7 +18,7 @@ pretty_assertions = "0.6.1"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"runtime_io/std",
|
||||
"srml-support/std",
|
||||
"inherents/std",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use runtime_io::{with_externalities, Blake2Hasher};
|
||||
use srml_support::{StorageValue, StorageMap, StorageDoubleMap};
|
||||
use srml_support::storage::unhashed;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub trait Trait {
|
||||
type BlockNumber: parity_codec::Codec + Default;
|
||||
type BlockNumber: codec::Codec + Default;
|
||||
type Origin;
|
||||
}
|
||||
|
||||
@@ -41,4 +41,4 @@ fn init_genesis_config() {
|
||||
GenesisConfig::<Test> {
|
||||
t: Default::default(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ mod module1 {
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||
type Origin: From<Origin<Self, I>>;
|
||||
type SomeParameter: Get<u32>;
|
||||
type GenericType: Default + Clone + parity_codec::Codec;
|
||||
type GenericType: Default + Clone + codec::Codec;
|
||||
}
|
||||
|
||||
srml_support::decl_module! {
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false }
|
||||
@@ -22,7 +22,7 @@ default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"safe-mix/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"rstd/std",
|
||||
"runtime_io/std",
|
||||
|
||||
@@ -95,7 +95,7 @@ use srml_support::{
|
||||
Parameter, for_each_tuple, traits::{Contains, Get}
|
||||
};
|
||||
use safe_mix::TripletMix;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use runtime_io::{twox_128, TestExternalities, Blake2Hasher};
|
||||
@@ -140,8 +140,8 @@ impl<AccountId> IsDeadAccount<AccountId> for () {
|
||||
}
|
||||
|
||||
/// Compute the trie root of a list of extrinsics.
|
||||
pub fn extrinsics_root<H: Hash, E: parity_codec::Encode>(extrinsics: &[E]) -> H::Output {
|
||||
extrinsics_data_root::<H>(extrinsics.iter().map(parity_codec::Encode::encode).collect())
|
||||
pub fn extrinsics_root<H: Hash, E: codec::Encode>(extrinsics: &[E]) -> H::Output {
|
||||
extrinsics_data_root::<H>(extrinsics.iter().map(codec::Encode::encode).collect())
|
||||
}
|
||||
|
||||
/// Compute the trie root of a list of extrinsics.
|
||||
@@ -412,7 +412,7 @@ decl_storage! {
|
||||
_: &mut sr_primitives::ChildrenStorageOverlay,
|
||||
config: &GenesisConfig|
|
||||
{
|
||||
use parity_codec::Encode;
|
||||
use codec::Encode;
|
||||
|
||||
storage.insert(well_known_keys::CODE.to_vec(), config.code.clone());
|
||||
storage.insert(well_known_keys::EXTRINSIC_INDEX.to_vec(), 0u32.encode());
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false }
|
||||
@@ -21,7 +21,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"inherents/std",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
|
||||
@@ -91,9 +91,9 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::{result, ops::{Mul, Div}, cmp};
|
||||
use parity_codec::Encode;
|
||||
use codec::Encode;
|
||||
#[cfg(feature = "std")]
|
||||
use parity_codec::Decode;
|
||||
use codec::Decode;
|
||||
#[cfg(feature = "std")]
|
||||
use inherents::ProvideInherentData;
|
||||
use srml_support::{StorageValue, Parameter, decl_storage, decl_module, for_each_tuple};
|
||||
@@ -133,7 +133,7 @@ impl InherentError {
|
||||
#[cfg(feature = "std")]
|
||||
pub fn try_from(id: &InherentIdentifier, data: &[u8]) -> Option<Self> {
|
||||
if id == &INHERENT_IDENTIFIER {
|
||||
<InherentError as parity_codec::Decode>::decode(&mut &data[..])
|
||||
<InherentError as codec::Decode>::decode(&mut &data[..]).ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
|
||||
sr-primitives = { path = "../../core/sr-primitives", default-features = false }
|
||||
srml-support = { path = "../support", default-features = false }
|
||||
@@ -21,7 +21,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"parity-codec/std",
|
||||
"codec/std",
|
||||
"rstd/std",
|
||||
"sr-primitives/std",
|
||||
"srml-support/std",
|
||||
|
||||
@@ -80,7 +80,7 @@ use sr_primitives::traits::{
|
||||
Zero, EnsureOrigin, StaticLookup, CheckedSub, CheckedMul, AccountIdConversion
|
||||
};
|
||||
use sr_primitives::weights::SimpleDispatchInfo;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use system::ensure_signed;
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
|
||||
Reference in New Issue
Block a user