Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialized Any does not have type field #43

Open
iboss-ptk opened this issue Sep 28, 2022 · 0 comments
Open

Serialized Any does not have type field #43

iboss-ptk opened this issue Sep 28, 2022 · 0 comments

Comments

@iboss-ptk
Copy link
Collaborator

iboss-ptk commented Sep 28, 2022

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!().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant