Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Enums: similar to Structures but also every variant of enum has a discriminator that used in Scale. By default based on 0, but can be overridden by attributes


    Code Block
    {
        "type": "enum",
        "name": "Bar",
        "codec": "SCALE", //possible values SCALE or JSON
        "variants": [
            {
                "name": "FirstVariant",
                "discriminator": 1,
                "properties": {
                    ...
                }
            },
            {
                "name": "SecondVariant",
                "discriminator": 2,
                "properties": {
                    ...
                }
            }
        ]
    }


Concerns

Currently we are not support polymorphism via TraitObjects, but it can be implemented if necessary


Additional Information

  1. Scale codec description in Substrate docs [https://substrate.dev/docs/en/knowledgebase/advanced/codec]
  2. Scale codec Github page [https://github.com/paritytech/parity-scale-codec]