mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 21:21:06 +00:00
Ensure opaque extr serialise is same as transparent (#1388)
* Ensure opaque extr serialise is same as transparent Fixes #889 * Fix wasm compile
This commit is contained in:
@@ -525,6 +525,25 @@ impl CheckInherentError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Simple blob to hold an extrinsic without commiting to its format and ensure it is serialized
|
||||||
|
/// correctly.
|
||||||
|
#[derive(PartialEq, Eq, Clone, Default, Encode, Decode)]
|
||||||
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
|
pub struct OpaqueExtrinsic(pub Vec<u8>);
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl ::serde::Serialize for OpaqueExtrinsic {
|
||||||
|
fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error> where S: ::serde::Serializer {
|
||||||
|
::codec::Encode::using_encoded(&self.0, |bytes| seq.serialize_bytes(bytes))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl traits::Extrinsic for OpaqueExtrinsic {
|
||||||
|
fn is_signed(&self) -> Option<bool> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use substrate_primitives::hash::H256;
|
use substrate_primitives::hash::H256;
|
||||||
|
|||||||
@@ -22,21 +22,18 @@
|
|||||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[macro_use]
|
extern crate serde;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[macro_use]
|
extern crate parity_codec as codec;
|
||||||
extern crate parity_codec_derive;
|
|
||||||
|
|
||||||
extern crate sr_std as rstd;
|
extern crate sr_std as rstd;
|
||||||
extern crate sr_primitives as runtime_primitives;
|
extern crate sr_primitives as runtime_primitives;
|
||||||
extern crate substrate_primitives as primitives;
|
extern crate substrate_primitives as primitives;
|
||||||
|
|
||||||
use rstd::prelude::*;
|
|
||||||
use runtime_primitives::generic;
|
use runtime_primitives::generic;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use primitives::bytes;
|
use primitives::bytes;
|
||||||
use runtime_primitives::traits::{BlakeTwo256, self};
|
use runtime_primitives::{OpaqueExtrinsic, traits::BlakeTwo256};
|
||||||
|
|
||||||
pub use runtime_primitives::BasicInherentData as InherentData;
|
pub use runtime_primitives::BasicInherentData as InherentData;
|
||||||
|
|
||||||
@@ -78,12 +75,4 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|||||||
pub type BlockId = generic::BlockId<Block>;
|
pub type BlockId = generic::BlockId<Block>;
|
||||||
|
|
||||||
/// Opaque, encoded, unchecked extrinsic.
|
/// Opaque, encoded, unchecked extrinsic.
|
||||||
#[derive(PartialEq, Eq, Clone, Default, Encode, Decode)]
|
pub type UncheckedExtrinsic = OpaqueExtrinsic;
|
||||||
#[cfg_attr(feature = "std", derive(Serialize, Debug))]
|
|
||||||
pub struct UncheckedExtrinsic(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8>);
|
|
||||||
|
|
||||||
impl traits::Extrinsic for UncheckedExtrinsic {
|
|
||||||
fn is_signed(&self) -> Option<bool> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user