Skip to content

Serialized Any does not have type field #43

@iboss-ptk

Description

@iboss-ptk

When Any type gets serialized, it removes @type field due to current limitation of https://github.com/CosmWasm/serde-json-wasm. It does not implement serialize_map (which serde-json-core does).

That means we can't implement type:

#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct AnyT<T>
where
    T: Serialize + DeserializeOwned,
{
    pub type_url: String,
    #[serde(
        flatten,
        serialize_with = "T::serialize",
        deserialize_with = "T::deserialize"
    )]
    pub value: T,
}

Which can produce serialization that looks conform proto json format.

{ "@type": "<type_url>", ...<struct_fields> }

Current implementation for serde_json_wasm will panic due to calling unreachable!().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions