【发布时间】:2020-09-13 17:37:00
【问题描述】:
当我知道用于存储数据的 ID 列表时,如何通过.entries 查询storage?
来自 decl_storage 的 sn-p
/// PoE Proofs
Proofs get(fn proofs): map hasher(blake2_128_concat) GenericId=> ProofInfo<Proof, T::AccountId, T::BlockNumber>;
我试图获取仅有的几个条目的打字稿代码
type IncomingParam = [StorageKey, ProofInfo]
type SnGenericIds = GenericId[]
export async function getAll (
items: SnGenericIds = []
): Promise<IncomingParam[]> {
const api = getApi()
return await api.query.poe.proofs.entries(items)
}
// items is [ '0x6261666b313332313365616465617364' ]
当我在浏览器中使用 polkadot.js 应用程序并传递该 ID 时,我得到记录并且只有一个,上面的 TS 代码返回所有记录,我检查了https://polkadot.js.org/api/start/api.query.other.html#map-keys-entries,如果我理解正确,上面的代码应该.工作
我知道multi,但我想用这个方法来获取全部或部分,这可能吗?
【问题讨论】:
标签: substrate polkadot-js