mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Fix serialization of extrinsics. (#1402)
This commit is contained in:
@@ -534,7 +534,7 @@ 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))
|
||||
::codec::Encode::using_encoded(&self.0, |bytes| ::substrate_primitives::bytes::serialize(bytes, seq))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,4 +617,10 @@ mod tests {
|
||||
// check that as-style methods are not working with regular items
|
||||
assert!(b1.as_authorities_change().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opaque_extrinsic_serialization() {
|
||||
let ex = super::OpaqueExtrinsic(vec![1, 2, 3, 4]);
|
||||
assert_eq!(serde_json::to_string(&ex).unwrap(), "\"0x1001020304\"".to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ extern crate sr_primitives as runtime_primitives;
|
||||
extern crate substrate_primitives as primitives;
|
||||
|
||||
use runtime_primitives::generic;
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::bytes;
|
||||
use runtime_primitives::{OpaqueExtrinsic, traits::BlakeTwo256};
|
||||
|
||||
pub use runtime_primitives::BasicInherentData as InherentData;
|
||||
|
||||
Reference in New Issue
Block a user