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:
Gav Wood
2019-01-11 11:36:44 +01:00
committed by GitHub
parent 9acda28c16
commit 039741c977
2 changed files with 23 additions and 15 deletions
+19
View File
@@ -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)]
mod tests {
use substrate_primitives::hash::H256;