mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 14:17:56 +00:00
camelcase structs returned over RPC (#1507)
This commit is contained in:
@@ -71,7 +71,8 @@ macro_rules! create_apis_vec {
|
||||
/// In particular: bug fixes should result in an increment of `spec_version` and possibly `authoring_version`,
|
||||
/// absolutely not `impl_version` since they change the semantics of the runtime.
|
||||
#[derive(Clone, PartialEq, Eq, Encode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize, Decode))]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Decode))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
pub struct RuntimeVersion {
|
||||
/// Identifies the different Substrate runtimes. There'll be at least polkadot and node.
|
||||
/// A different on-chain spec_name to that of the native runtime would normally result
|
||||
@@ -103,6 +104,7 @@ pub struct RuntimeVersion {
|
||||
pub impl_version: u32,
|
||||
|
||||
/// List of supported API "features" along with their versions.
|
||||
#[cfg_attr(feature = "std", serde(serialize_with = "apis_serialize::serialize"))]
|
||||
pub apis: ApisVec,
|
||||
}
|
||||
|
||||
@@ -154,3 +156,36 @@ impl NativeVersion {
|
||||
self.can_author_with.contains(&other.authoring_version))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod apis_serialize {
|
||||
extern crate impl_serde;
|
||||
extern crate serde;
|
||||
|
||||
use super::*;
|
||||
use self::impl_serde::serialize as bytes;
|
||||
use self::serde::{Serializer, ser::SerializeTuple};
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ApiId<'a>(
|
||||
#[serde(serialize_with="serialize_bytesref")] &'a super::ApiId,
|
||||
&'a u32,
|
||||
);
|
||||
|
||||
pub fn serialize<S>(apis: &ApisVec, ser: S) -> Result<S::Ok, S::Error> where
|
||||
S: Serializer,
|
||||
{
|
||||
let len = apis.len();
|
||||
let mut seq = ser.serialize_tuple(len)?;
|
||||
for (api, ver) in &**apis {
|
||||
seq.serialize_element(&ApiId(api, ver))?;
|
||||
}
|
||||
seq.end()
|
||||
}
|
||||
|
||||
pub fn serialize_bytesref<S>(apis: &&super::ApiId, ser: S) -> Result<S::Ok, S::Error> where
|
||||
S: Serializer,
|
||||
{
|
||||
bytes::serialize(*apis, ser)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user