Skip to content

Commit 65c189d

Browse files
committed
feat(queries): add watchEntries
1 parent 9167cb6 commit 65c189d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/pages/typed/queries.md

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ type StorageEntryWithKeys<Args, Payload, ArgsOut> = {
4848
value: NonNullable<Payload>
4949
}>
5050
>
51+
watchEntries: (
52+
...args: [PossibleParents<Args>, options?: { at: "best" }]
53+
) => Observable<{
54+
block: BlockInfo
55+
deltas: null | {
56+
deleted: Array<{ args: ArgsOut; value: NonNullable<Payload> }>
57+
upserted: Array<{ args: ArgsOut; value: NonNullable<Payload> }>
58+
}
59+
entries: Array<{ args: ArgsOut; value: NonNullable<Payload> }>
60+
}>
5161
}
5262
```
5363
@@ -70,3 +80,9 @@ typedApi.query.Pallet.Query.getEntries(arg1, arg2, { at: "0x12345678" }) // 2/3
7080
:::note
7181
`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`.
7282
:::
83+
84+
`watchEntries` allows you to watch changes to all entries of a storage map. As in `getEntries`, you can optionally provide a subset of the keys and/or `{at: "best"}` to watch changes to the best block, instead of the default `"finalized"` block. An event will be emitted for every new block, containing:
85+
86+
- `block`: Block hash, block number, and parent block hash; to identify how updated the information is.
87+
- `deltas`: In case there were any changes since previous event, `upserted` (meaning added or changed) and `deleted` entries. If `deltas` is `null`, then no changes happened during that block.
88+
- `entries`: Immutable data-structure with the whole bunch of entries, updated to that block.

0 commit comments

Comments
 (0)