Use querystorageAt for map entries (optional) (#2119)

This commit is contained in:
Jaco Greeff
2020-03-31 09:17:36 +02:00
committed by GitHub
parent ef9cd6fc4b
commit 0bdbf4b7a7
2 changed files with 13 additions and 8 deletions
+4 -1
View File
@@ -1,13 +1,16 @@
# 1.9.0-beta.x
**Breaking change** (TypeScript with derives only) The type names for `api.derive.*` returns has been adjusted to be consistent with `Derive*` (previously a mixture of `Derived*` and `Derive*`)
**Breaking change** (derives only) Additional cleanups of democracy proposeal & referenda derives, including support for new Polkadot/Substrate vote retrievals
**Breaking change** (derives only) Additional cleanups of democracy proposal & referenda derives, including support for new Polkadot/Substrate vote retrievals
- Tx signing via `signAndSend` & `signAsync` now tries to use the last finalized block (depending on finalized drift)
- Add support for `api.rpc.childstate.*` Substrate RPCs, older nodes with still populate `api.rpc.state.*` with the child methods
- Adjust `Error.message` on RPC failures to not include the (already known) method signature
- Internal adjustment of interface types to align with modules (no external impact via `@polkadot/types/interfaces`)
- Extended `api.derive.democracy` to cater for dispatchQueue and externals
- Extended `api.derive.council` to cater for new phragmen elections
- Use new `queryStorageAt` for query `.entries`, removing unneeded subscriptions (as available)
- Fix `BTreeSet` initialization when part of query interfaces
- Fix encoding for `Vec<u8>`-related types as part of constants
# 1.8.1 Mar 22, 2020
+9 -7
View File
@@ -41,7 +41,7 @@ interface MetaDecoration {
type LinkageData = ITuple<[Codec, Linkage<Codec>]>;
const PAGE_SIZE_KEYS = 256;
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS / 2;
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS;
const l = logger('api/init');
@@ -248,6 +248,7 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.forEach(([_, { method, section }]): void => {
delete (this._rpc as any)[section][method];
delete (this._rpcCore as any)[section][method];
delete (this._rx.rpc as any)[section][method];
});
}
@@ -502,12 +503,13 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
combineLatest([
of(keys),
from(Array(Math.ceil(keys.length / PAGE_SIZE_VALS)).fill(0)).pipe(
// FIXME New RPC to take care of this in the works...
concatMap((_, index): Observable<Option<Raw>[]> =>
this._rpcCore.state.subscribeStorage<Option<Raw>[]>(
keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS)
).pipe(take(1))
),
concatMap((_, index): Observable<Option<Raw>[]> => {
const keyset = keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS);
return this._rpcCore.state.queryStorageAt
? this._rpcCore.state.queryStorageAt<Option<Raw>[]>(keyset)
: this._rpcCore.state.subscribeStorage<Option<Raw>[]>(keyset).pipe(take(1));
}),
toArray(),
map((valsArr: Option<Raw>[][]): Option<Raw>[] =>
valsArr.reduce((result: Option<Raw>[], vals): Option<Raw>[] =>