mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 05:21:08 +00:00
Migrate network, primitives and rpc to the 2018 edition (#1710)
This commit is contained in:
committed by
Gav Wood
parent
3a4dda7beb
commit
e60be1ad12
@@ -16,7 +16,8 @@
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Serializer, Deserialize, Deserializer};
|
||||
use H256;
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
use crate::H256;
|
||||
|
||||
/// An identifier for an authority in the consensus algorithm. The same size as ed25519::Public.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Default, Encode, Decode)]
|
||||
@@ -25,15 +26,15 @@ pub struct Ed25519AuthorityId(pub [u8; 32]);
|
||||
#[cfg(feature = "std")]
|
||||
impl ::std::fmt::Display for Ed25519AuthorityId {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
write!(f, "{}", ::ed25519::Public(self.0).to_ss58check())
|
||||
write!(f, "{}", crate::ed25519::Public(self.0).to_ss58check())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl ::std::fmt::Debug for Ed25519AuthorityId {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
let h = format!("{}", ::hexdisplay::HexDisplay::from(&self.0));
|
||||
write!(f, "{} ({}…{})", ::ed25519::Public(self.0).to_ss58check(), &h[0..8], &h[60..])
|
||||
let h = format!("{}", crate::hexdisplay::HexDisplay::from(&self.0));
|
||||
write!(f, "{} ({}…{})", crate::ed25519::Public(self.0).to_ss58check(), &h[0..8], &h[60..])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,13 +84,13 @@ impl Into<H256> for Ed25519AuthorityId {
|
||||
#[cfg(feature = "std")]
|
||||
impl Serialize for Ed25519AuthorityId {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer {
|
||||
::ed25519::serialize(&self, serializer)
|
||||
crate::ed25519::serialize(&self, serializer)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<'de> Deserialize<'de> for Ed25519AuthorityId {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de> {
|
||||
::ed25519::deserialize(deserializer)
|
||||
crate::ed25519::deserialize(deserializer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
//! Substrate changes trie configuration.
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
|
||||
/// Substrate changes trie configuration.
|
||||
#[cfg_attr(any(feature = "std", test), derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)]
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
use untrusted;
|
||||
use blake2_rfc;
|
||||
use ring::{rand, signature, signature::KeyPair};
|
||||
use {hash::H512, Ed25519AuthorityId};
|
||||
use crate::{hash::H512, Ed25519AuthorityId};
|
||||
use base58::{ToBase58, FromBase58};
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{de, Serializer, Deserializer, Deserialize};
|
||||
@@ -190,7 +191,7 @@ impl ::std::fmt::Display for Public {
|
||||
impl ::std::fmt::Debug for Public {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
let s = self.to_ss58check();
|
||||
write!(f, "{} ({}...)", ::hexdisplay::HexDisplay::from(&self.0), &s[0..8])
|
||||
write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,10 +296,11 @@ pub fn serialize<S, T: AsRef<[u8; 32]>>(data: &T, serializer: S) -> Result<S::Ok
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use hex_literal::{hex, hex_impl};
|
||||
|
||||
fn _test_primitives_signature_and_local_the_same() {
|
||||
fn takes_two<T>(_: T, _: T) { }
|
||||
takes_two(Signature::default(), ::Signature::default())
|
||||
takes_two(Signature::default(), crate::Signature::default())
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -323,7 +325,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn seeded_pair_should_work() {
|
||||
use ::hexdisplay::HexDisplay;
|
||||
use crate::hexdisplay::HexDisplay;
|
||||
|
||||
let pair = Pair::from_seed(b"12345678901234567890123456789012");
|
||||
let public = pair.public();
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
use hash_db::Hasher;
|
||||
use hash256_std_hasher::Hash256StdHasher;
|
||||
use hash::H256;
|
||||
use crate::hash::H256;
|
||||
|
||||
pub mod blake2 {
|
||||
use super::{Hasher, Hash256StdHasher, H256};
|
||||
#[cfg(feature = "std")]
|
||||
use hashing::blake2_256;
|
||||
use crate::hashing::blake2_256;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern "C" {
|
||||
|
||||
@@ -21,56 +21,6 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
extern crate primitive_types;
|
||||
#[macro_use]
|
||||
extern crate parity_codec_derive;
|
||||
|
||||
extern crate rustc_hex;
|
||||
extern crate byteorder;
|
||||
extern crate parity_codec as codec;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate serde;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate twox_hash;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate blake2_rfc;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate ring;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate base58;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate untrusted;
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate hex_literal;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate impl_serde;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate core;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate wasmi;
|
||||
extern crate hash_db;
|
||||
extern crate hash256_std_hasher;
|
||||
|
||||
extern crate sr_std as rstd;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate substrate_serializer;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate heapsize;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate pretty_assertions;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! map {
|
||||
($( $name:expr => $value:expr ),*) => (
|
||||
@@ -80,8 +30,11 @@ macro_rules! map {
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::ops::Deref;
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
#[cfg(feature = "std")]
|
||||
use std::borrow::Cow;
|
||||
#[cfg(feature = "std")]
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use impl_serde::serialize as bytes;
|
||||
@@ -168,14 +121,14 @@ pub enum NativeOrEncoded<R> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<R: codec::Encode> ::std::fmt::Debug for NativeOrEncoded<R> {
|
||||
impl<R: parity_codec::Encode> ::std::fmt::Debug for NativeOrEncoded<R> {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
self.as_encoded().as_ref().fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<R: codec::Encode> NativeOrEncoded<R> {
|
||||
impl<R: parity_codec::Encode> NativeOrEncoded<R> {
|
||||
/// Return the value as the encoded format.
|
||||
pub fn as_encoded<'a>(&'a self) -> Cow<'a, [u8]> {
|
||||
match self {
|
||||
@@ -194,13 +147,13 @@ impl<R: codec::Encode> NativeOrEncoded<R> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<R: PartialEq + codec::Decode> PartialEq for NativeOrEncoded<R> {
|
||||
impl<R: PartialEq + parity_codec::Decode> PartialEq for NativeOrEncoded<R> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(NativeOrEncoded::Native(l), NativeOrEncoded::Native(r)) => l == r,
|
||||
(NativeOrEncoded::Native(n), NativeOrEncoded::Encoded(e)) |
|
||||
(NativeOrEncoded::Encoded(e), NativeOrEncoded::Native(n)) =>
|
||||
Some(n) == codec::Decode::decode(&mut &e[..]).as_ref(),
|
||||
Some(n) == parity_codec::Decode::decode(&mut &e[..]).as_ref(),
|
||||
(NativeOrEncoded::Encoded(l), NativeOrEncoded::Encoded(r)) => l == r,
|
||||
}
|
||||
}
|
||||
@@ -213,7 +166,7 @@ impl<R: PartialEq + codec::Decode> PartialEq for NativeOrEncoded<R> {
|
||||
pub enum NeverNativeValue {}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl codec::Encode for NeverNativeValue {
|
||||
impl parity_codec::Encode for NeverNativeValue {
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
// The enum is not constructable, so this function should never be callable!
|
||||
unreachable!()
|
||||
@@ -221,8 +174,8 @@ impl codec::Encode for NeverNativeValue {
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl codec::Decode for NeverNativeValue {
|
||||
fn decode<I: codec::Input>(_: &mut I) -> Option<Self> {
|
||||
impl parity_codec::Decode for NeverNativeValue {
|
||||
fn decode<I: parity_codec::Input>(_: &mut I) -> Option<Self> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
//! Definition of a sandbox environment.
|
||||
|
||||
#[cfg(test)]
|
||||
use codec::Encode;
|
||||
use parity_codec::Encode;
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
use rstd::vec::Vec;
|
||||
|
||||
/// Error error that can be returned from host function.
|
||||
@@ -185,7 +186,7 @@ pub const ERR_EXECUTION: u32 = -3i32 as u32;
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fmt;
|
||||
use codec::Codec;
|
||||
use parity_codec::Codec;
|
||||
|
||||
fn roundtrip<S: Codec + PartialEq + fmt::Debug>(s: S) {
|
||||
let encoded = s.encode();
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
//! Contract execution data.
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use bytes;
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::bytes;
|
||||
use rstd::vec::Vec;
|
||||
|
||||
/// Contract storage key.
|
||||
|
||||
@@ -21,7 +21,7 @@ pub use primitive_types::U256;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use codec::{Encode, Decode};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use substrate_serializer as ser;
|
||||
|
||||
macro_rules! test {
|
||||
|
||||
Reference in New Issue
Block a user