radix-engine-toolkit icon indicating copy to clipboard operation
radix-engine-toolkit copied to clipboard

remove DisplayFromStr for discriminator in enum

Open Krulknul opened this issue 1 year ago • 0 comments

Hi :)

Proposed fix for the following issue: Discord message

Take this event as an example:

  "data": {
    "kind": "Enum",
    "type_name": "WithdrawEvent",
    "variant_id": 0,
    "variant_name": "Fungible",
    "fields": [
      {
        "kind": "Reference",
        "type_name": "ResourceAddress",
        "value": "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd"
      },
      {
        "kind": "Decimal",
        "value": "500.1243461544827"
      }
    ]
  }

You can find it here: https://dashboard.radixdlt.com/transaction/txid_rdx1lq7zd5xnl9s2v8rjns4q474jtxjadnesm0u37uyldk6ht3l9kd6sdfedjz/details

The variant_id here is 0, as a number, while the toolkit seems to expect it to be a string as per the #[serde_as(as = "serde_with::DisplayFromStr")]

I'm not sure whether this is correct and if it has further effects on other code, but this fix worked for me and I need it to work so thought I'd suggest it. Thanks in advance for taking the time.

Krulknul avatar Mar 26 '24 12:03 Krulknul