Versions Compared

Key

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

...

  • Option / Result / Vec / typle : basically we are interested in only inner values of the container


    Code Block
    [
    {
        "typedefinition": "Option",
        "item_type": {
            "typedefinition" : "bool"
        }
    
    },
    {
        "typedefinition": "Result",
        "item_type": {
            "typedefinition": "int",
            "mode": "CompactFourByte"
        }
    },
    {
        "typedefinition": "Vec",
        "item_type": {
            "typedefinition": "bool"
        }
    },
    {
        "typedefinition": "tuple",
        "items": [
            {
                "typedefinition": "int",
                "mode": "CompactFourByte"
            },
            {
                "typedefinition": "Option",
                "item_type": {
                    "typedefinition" : "bool"
                }
            
            }
        ]
    }
    ]


3. Custom containers 

  • Structures: in structures definitions declared inline for built-in types and declared a reference for custom types 


    Code Block
    languagebash
    {
        "typedefinition": "struct",
        "name": "Foo",
        "codec": "SCALE", //possible values SCALE or JSON
        "properties": [
            {
                "name": "enabled", //optional name
                "definitiontype": {
                    "typedefinition": "bool"
                }
            },
            {
                "name": "id", //optional name
                "definitiontype": {
                    "typedefinition": "struct", //reference to other struct
                    "struct_name": "Id"
                }
            },
            {
                "name": "counter", //optional name
                "definitiontype": {
                    "typedefinition": "int",
                    "mode": "FixedWidth"
                }
            }
        ]
    }


  • 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
    {
        "typedefinition": "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

...