1

types.json

{
  "WorkerId": {
    "_enum": {
      "Single": "Single",
      "Double": "Double"
    }
  },
  "Single": "u8",
  "Double": "(u8, u8)",
}

基板代码:

#[pallet::storage]
#[pallet::getter(fn worker_infos)]
pub type WorkerInfos<T: Config> = StorageMap<_, Twox64Concat, WorkerId, WorkerInfo, ValueQuery>;


pub enum WorkerId {
    Single(u8),
    Double(u8, u8),
}

我想在 polkadot.js中查询worker_infosWorkerId

    workerIds = [1,2]
    api.query[wrpc][wcallable]
      .multi(workerIds, (results) => {
        ...
      })
      .then((unsub) => {
        ...
      })
      .catch(console.error);

错误信息:

REGISTRY: Error: Unable to create Enum via index 2, in Single, Double

对此有什么想法吗?如何在 polkadot.js 中传递 workerIds(枚举类型)?

4

1 回答 1

1

{ 单: 1 } 或 { 双: [2, 3] }

于 2021-04-13T14:11:34.837 回答