0

以下是我的基板代码:

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

如何在json文件中配置枚举类型?https://polkadot.js.org/apps

这不起作用:

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

1 回答 1

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

这里还有一个真实世界的例子:

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

于 2021-04-01T06:45:02.200 回答