mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 00:41:03 +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
@@ -17,7 +17,7 @@ substrate-bip39 = "0.2.2"
|
||||
schnorrkel = "0.1.1"
|
||||
hex = "0.3"
|
||||
hex-literal = "0.2"
|
||||
parity-codec = "4.1.1"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
system = { package = "srml-system", path = "../srml/system" }
|
||||
balances = { package = "srml-balances", path = "../srml/balances" }
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use primitives::{
|
||||
ed25519, sr25519, hexdisplay::HexDisplay, Pair, Public, blake2_256,
|
||||
crypto::{Ss58Codec, set_default_ss58_version, Ss58AddressFormat}
|
||||
};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode};
|
||||
use sr_primitives::generic::Era;
|
||||
use node_primitives::{Balance, Index, Hash};
|
||||
use node_runtime::{Call, UncheckedExtrinsic, BalancesCall, Runtime};
|
||||
@@ -165,7 +165,7 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
let genesis_hash: Hash = match matches.value_of("genesis").unwrap_or("alex") {
|
||||
"elm" => hex!["10c08714a10c7da78f40a60f6f732cf0dba97acfb5e2035445b032386157d5c3"].into(),
|
||||
"alex" => hex!["dcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b"].into(),
|
||||
h => hex::decode(h).ok().and_then(|x| Decode::decode(&mut &x[..]))
|
||||
h => hex::decode(h).ok().and_then(|x| Decode::decode(&mut &x[..]).ok())
|
||||
.expect("Invalid genesis hash or unrecognised chain identifier"),
|
||||
};
|
||||
|
||||
@@ -203,12 +203,12 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
let call = matches.value_of("call")
|
||||
.expect("call is required; thus it can't be None; qed");
|
||||
let function: Call = hex::decode(&call).ok()
|
||||
.and_then(|x| Decode::decode(&mut &x[..])).unwrap();
|
||||
.and_then(|x| Decode::decode(&mut &x[..]).ok()).unwrap();
|
||||
|
||||
let genesis_hash: Hash = match matches.value_of("genesis").unwrap_or("alex") {
|
||||
"elm" => hex!["10c08714a10c7da78f40a60f6f732cf0dba97acfb5e2035445b032386157d5c3"].into(),
|
||||
"alex" => hex!["dcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b"].into(),
|
||||
h => hex::decode(h).ok().and_then(|x| Decode::decode(&mut &x[..]))
|
||||
h => hex::decode(h).ok().and_then(|x| Decode::decode(&mut &x[..]).ok())
|
||||
.expect("Invalid genesis hash or unrecognised chain identifier"),
|
||||
};
|
||||
|
||||
@@ -289,7 +289,7 @@ mod tests {
|
||||
fn should_work() {
|
||||
let s = "0123456789012345678901234567890123456789012345678901234567890123";
|
||||
|
||||
let d1: Hash = hex::decode(s).ok().and_then(|x| Decode::decode(&mut &x[..])).unwrap();
|
||||
let d1: Hash = hex::decode(s).ok().and_then(|x| Decode::decode(&mut &x[..]).ok()).unwrap();
|
||||
|
||||
let d2: Hash = {
|
||||
let mut gh: [u8; 32] = Default::default();
|
||||
|
||||
Reference in New Issue
Block a user