substratepolkadotpolkadot-js

how to configure enum in polkadot.js


Following is my substrate code:

pub type ItemId = u8;
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug)]
pub enum PoolId {
    TX(ItemId),
}

How to configure enum type in the json file? https://polkadot.js.org/apps

This is not working:

{
  "PoolId": {
    "_enum": [
      "TX"
    ]
  },
}

Solution

  • {
      "PoolId": {
        "_enum": [
          "TX"
        ]
      },
      "TX": "u8"
    // or
    // "TX": { "_": "u8" }
    // or
    // "TX": "ItemId",
    // "ItemId": "u8"
    // or
    // "TX": { "_": "ItemId" },
    // "ItemId": "u8"
    }
    

    Also here's a real world example:

    https://github.com/darwinia-network/darwinia-common/blob/master/bin/node/runtime/pangolin/types.json#L9-L14

    https://github.com/darwinia-network/darwinia-common/blob/master/bin/node/runtime/pangolin/types.json#L18-L21