mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11: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
@@ -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};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user