Skip to content

Commit

Permalink
feat(queries): add explanation for opaque keys
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed Nov 27, 2024
1 parent a30c591 commit bffed46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/pages/typed/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ On the other hand, `watchValue` function returns an Observable allows you to che
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:
```ts
type StorageEntryWithKeys<Args, Payload> = {
type StorageEntryWithKeys<Args, Payload, ArgsOut> = {
isCompatible: IsCompatible
getCompatibilityLevel: GetCompatibilityLevel
getValue: (...args: [...Args, options?: CallOptions]) => Promise<Payload>
Expand All @@ -44,7 +44,7 @@ type StorageEntryWithKeys<Args, Payload> = {
...args: [PossibleParents<Args>, options?: CallOptions]
) => Promise<
Array<{
keyArgs: Args
keyArgs: ArgsOut
value: NonNullable<Payload>
}>
>
Expand All @@ -66,3 +66,7 @@ typedApi.query.Pallet.Query.getEntries({ at: "best" }) // no keys
typedApi.query.Pallet.Query.getEntries(arg1, { at: "finalized" }) // 1/3 keys
typedApi.query.Pallet.Query.getEntries(arg1, arg2, { at: "0x12345678" }) // 2/3 keys
```
:::note
`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`.
:::

0 comments on commit bffed46

Please sign in to comment.