Skip to content

Deserializing u128 errors when inside an untagged enum #46

@uint

Description

@uint

Minimal reproducible example below. Note that the second you change u128 -> u64, the test passes.

#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case", untagged)]
enum ExecuteMsg {
    Interface(Interface),
}

#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
enum Interface {
    IncreaseAllowance { amount: u128 },
}

#[test]
fn foo() {
    let foo = ExecuteMsg::Interface(Interface::IncreaseAllowance { amount: 777 });

    let foo_ser = serde_json_wasm::to_string(&foo).unwrap();

    let wrapper_de: ExecuteMsg = serde_json_wasm::from_str(&foo_ser).unwrap();
}

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