dev-for-fun
dev-for-fun

Reputation: 35

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"
    ]
  },
}

Upvotes: 0

Views: 694

Answers (1)

aurexav
aurexav

Reputation: 2865

{
  "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

Upvotes: 1

Related Questions