Skip to content

Commit bffed46

Browse files
committed
feat(queries): add explanation for opaque keys
1 parent a30c591 commit bffed46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/pages/typed/queries.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ On the other hand, `watchValue` function returns an Observable allows you to che
2929
Similarly, we'll use the example of `System.Account` query (it returns the information of a particular `Account`). In this case, this storage query has a key to index it with, and therefore we find the following structure:
3030
3131
```ts
32-
type StorageEntryWithKeys<Args, Payload> = {
32+
type StorageEntryWithKeys<Args, Payload, ArgsOut> = {
3333
isCompatible: IsCompatible
3434
getCompatibilityLevel: GetCompatibilityLevel
3535
getValue: (...args: [...Args, options?: CallOptions]) => Promise<Payload>
@@ -44,7 +44,7 @@ type StorageEntryWithKeys<Args, Payload> = {
4444
...args: [PossibleParents<Args>, options?: CallOptions]
4545
) => Promise<
4646
Array<{
47-
keyArgs: Args
47+
keyArgs: ArgsOut
4848
value: NonNullable<Payload>
4949
}>
5050
>
@@ -66,3 +66,7 @@ typedApi.query.Pallet.Query.getEntries({ at: "best" }) // no keys
6666
typedApi.query.Pallet.Query.getEntries(arg1, { at: "finalized" }) // 1/3 keys
6767
typedApi.query.Pallet.Query.getEntries(arg1, arg2, { at: "0x12345678" }) // 2/3 keys
6868
```
69+
70+
:::note
71+
`getEntries` returns as well the key arguments for every entry found. There are some storage entries whose arguments cannot be inferred directly from the key, because the arguments are hashed to compute the key. Therefore, only in these cases, `keyArgs` will be the `key` instead of the arguments themselves. The type will be `OpaqueKeyHash`.
72+
:::

0 commit comments

Comments
 (0)