Skip to content

Commit fe07f76

Browse files
committed
feat(queries): add `getKey
1 parent 7013cbd commit fe07f76

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/pages/typed/queries.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ type StorageEntryWithoutKeys<Payload> = {
1717
getCompatibilityLevel: GetCompatibilityLevel
1818
getValue: (options?: CallOptions) => Promise<Payload>
1919
watchValue: (bestOrFinalized?: "best" | "finalized") => Observable<Payload>
20+
21+
getKey: () => Promise<HexString>
22+
getKey: (token: CompatibilityToken) => HexString
2023
}
2124
```
2225
26+
`getKey` builds the storage key for a specific query. It optionally takes a [`CompatibilityToken`](/typed), making it synchronous if passed.
27+
2328
As you might expect, `getValue` returns you the `Payload` for that particular query, allowing you to choose which block to query (`at` can be a blockHash, `"finalized"` (the default), or `"best"`).
2429
2530
On the other hand, `watchValue` function returns an Observable allows you to check the changes of a particular storage entry in `"best"` or `"finalized"` (the default) block.
@@ -58,9 +63,14 @@ type StorageEntryWithKeys<Args, Payload, ArgsOut> = {
5863
}
5964
entries: Array<{ args: ArgsOut; value: NonNullable<Payload> }>
6065
}>
66+
67+
getKey: (...args: PossibleArgs) => Promise<HexString>
68+
getKey: (...args: PossibleArgs, token: CompatibilityToken) => HexString
6169
}
6270
```
6371
72+
`getKey` builds the storage key for a specific query and set of arguments. You can pass all args just a subset of them. It optionally takes a [`CompatibilityToken`](/typed), making it synchronous if passed.
73+
6474
Both `getValue` and `watchValue` have the same behaviour as in the previous case, but they require you to pass all keys required for that storage query (in our example, an address). The same function arguments that are found in the no-keys situation can be passed at the end of the call to modify which block to query, etc. For example, a query with 3 args:
6575
6676
```ts

0 commit comments

Comments
 (0)