Bump @polkadot/util & use nextTick (#4882)

This commit is contained in:
Jaco
2022-06-01 08:31:13 +03:00
committed by GitHub
parent d245bc69c9
commit 05cf0cba8a
23 changed files with 155 additions and 163 deletions
+1 -1
View File
@@ -29,7 +29,7 @@
"@polkadot/types": "8.6.3-3",
"@polkadot/types-augment": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
},
"devDependencies": {
"@polkadot/types-support": "8.6.3-3"
+1 -1
View File
@@ -26,7 +26,7 @@
"@babel/runtime": "^7.18.3",
"@polkadot/rpc-core": "8.6.3-3",
"@polkadot/types": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"rxjs": "^7.5.5"
}
}
+3 -3
View File
@@ -28,12 +28,12 @@
"@polkadot/types": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/types-create": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util-crypto": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/util-crypto": "^9.3.2-1",
"rxjs": "^7.5.5"
},
"devDependencies": {
"@polkadot/api-augment": "8.6.3-3",
"@polkadot/keyring": "^9.3.1"
"@polkadot/keyring": "^9.3.2-1"
}
}
+2 -2
View File
@@ -30,8 +30,8 @@
"@polkadot/rpc-core": "8.6.3-3",
"@polkadot/types": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util-crypto": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/util-crypto": "^9.3.2-1",
"rxjs": "^7.5.5"
},
"devDependencies": {
@@ -9,6 +9,8 @@ import type { DeriveApi } from '../types';
import { BehaviorSubject, map, of, switchMap, tap, toArray } from 'rxjs';
import { nextTick } from '@polkadot/util';
import { memo } from '../util';
function traverseLinks (api: DeriveApi, head: AccountId32 | string): Observable<PalletBagsListListNode[]> {
@@ -19,11 +21,11 @@ function traverseLinks (api: DeriveApi, head: AccountId32 | string): Observable<
api.query.bagsList.listNodes(account)
),
tap((node: Option<PalletBagsListListNode>): void => {
setTimeout((): void => {
nextTick((): void => {
node.isSome && node.value.next.isSome
? subject.next(node.unwrap().next.unwrap())
: subject.complete();
}, 0);
});
}),
toArray(), // toArray since we want to startSubject to be completed
map((all: Option<PalletBagsListListNode>[]) =>
+1 -1
View File
@@ -6,8 +6,8 @@ import type { AnyFunction } from '@polkadot/types/types';
import type { ExactDerive } from './derive';
import type { DeriveApi } from './types';
import { lazyDeriveSection } from './util/lazy';
import { derive } from './derive';
import { lazyDeriveSection } from './util';
export * from './derive';
export * from './type';
@@ -8,7 +8,7 @@ import type { DeriveApi, DeriveContributions } from '../types';
import { BehaviorSubject, combineLatest, EMPTY, map, of, startWith, switchMap, tap, toArray } from 'rxjs';
import { arrayFlatten, isFunction } from '@polkadot/util';
import { arrayFlatten, isFunction, nextTick } from '@polkadot/util';
import { memo } from '../util';
import { extractContributed } from './util';
@@ -67,11 +67,11 @@ function _getKeysPaged (api: DeriveApi, childKey: string): Observable<StorageKey
api.rpc.childstate.getKeysPaged(childKey, '0x', PAGE_SIZE_K, startKey)
),
tap((keys): void => {
setTimeout((): void => {
nextTick((): void => {
keys.length === PAGE_SIZE_K
? subject.next(keys[PAGE_SIZE_K - 1].toHex())
: subject.complete();
}, 0);
});
}),
toArray(), // toArray since we want to startSubject to be completed
map((keyArr: StorageKey[][]) => arrayFlatten(keyArr))
+3 -3
View File
@@ -9,7 +9,7 @@ import type { DeriveApi } from '../types';
import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs';
import { arrayChunk, arrayFlatten } from '@polkadot/util';
import { arrayChunk, arrayFlatten, nextTick } from '@polkadot/util';
import { memo } from '../util';
@@ -28,13 +28,13 @@ function chunkEras <T> (eras: EraIndex[], fn: (eras: EraIndex[]) => Observable<T
return subject.pipe(
switchMap(fn),
tap((): void => {
setTimeout((): void => {
nextTick((): void => {
index++;
index === chunked.length
? subject.complete()
: subject.next(chunked[index]);
}, 0);
});
}),
toArray(),
map(arrayFlatten)
+1
View File
@@ -7,3 +7,4 @@ export * from './approvalFlagsToBools';
export * from './cache';
export * from './cacheImpl';
export * from './first';
export * from './lazy';
+3 -3
View File
@@ -27,7 +27,7 @@
"@polkadot/api-augment": "8.6.3-3",
"@polkadot/api-base": "8.6.3-3",
"@polkadot/api-derive": "8.6.3-3",
"@polkadot/keyring": "^9.3.1",
"@polkadot/keyring": "^9.3.2-1",
"@polkadot/rpc-augment": "8.6.3-3",
"@polkadot/rpc-core": "8.6.3-3",
"@polkadot/rpc-provider": "8.6.3-3",
@@ -36,8 +36,8 @@
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/types-create": "8.6.3-3",
"@polkadot/types-known": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util-crypto": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/util-crypto": "^9.3.2-1",
"eventemitter3": "^4.0.7",
"rxjs": "^7.5.5"
},
+8 -11
View File
@@ -19,7 +19,7 @@ import { getAvailableDerives } from '@polkadot/api-derive';
import { memo, RpcCore } from '@polkadot/rpc-core';
import { WsProvider } from '@polkadot/rpc-provider';
import { expandMetadata, Metadata, TypeRegistry, unwrapStorageType } from '@polkadot/types';
import { arrayChunk, arrayFlatten, assert, assertReturn, BN, BN_ZERO, compactStripLength, lazyMethod, lazyMethods, logger, objectSpread, u8aToHex } from '@polkadot/util';
import { arrayChunk, arrayFlatten, assert, assertReturn, BN, BN_ZERO, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, u8aToHex } from '@polkadot/util';
import { createSubmittable } from '../submittable';
import { augmentObject } from '../util/augmentObject';
@@ -661,7 +661,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
queueIdx++;
queue.push([[], from(
// slightly faster than setTimeout(..., 0)
// Defer to the next tick - this aligns with nextTick in @polkadot/util,
// however since we return a value here, we don't re-use what is there
Promise
.resolve()
.then((): [StorageEntry, ...unknown[]][] => {
@@ -787,15 +788,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
switchMap(getKeysPaged),
map((keys) => keys.map(setMeta)),
tap((keys): void => {
// slightly faster than setTimeout(..., 0)
Promise
.resolve()
.then((): void => {
keys.length === PAGE_SIZE_K
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
: startSubject.complete();
})
.catch(console.error);
nextTick((): void => {
keys.length === PAGE_SIZE_K
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
: startSubject.complete();
});
}),
toArray(), // toArray since we want to startSubject to be completed
map(arrayFlatten)
+3 -11
View File
@@ -7,7 +7,7 @@ import type { DecorateFn, DecorateMethodOptions, ObsInnerType, StorageEntryPromi
import { catchError, EMPTY, Subscription, tap } from 'rxjs';
import { assert, isFunction } from '@polkadot/util';
import { assert, isFunction, nextTick } from '@polkadot/util';
interface Tracker<T> {
reject: (value: Error) => Observable<never>;
@@ -76,11 +76,7 @@ function decorateCall<M extends DecorateFn<CodecReturnType<M>>> (method: M, args
.subscribe((result): void => {
tracker.resolve(result);
// slightly faster than setTimeout(..., 0)
Promise
.resolve()
.then(() => subscription.unsubscribe())
.catch(console.error);
nextTick(() => subscription.unsubscribe());
});
});
}
@@ -99,11 +95,7 @@ function decorateSubscribe<M extends DecorateFn<CodecReturnType<M>>> (method: M,
)
.subscribe((result): void => {
// queue result (back of queue to clear current)
// slightly faster than setTimeout(..., 0)
Promise
.resolve()
.then(() => resultCb(result))
.catch(console.error);
nextTick(() => resultCb(result));
});
});
}
+1 -1
View File
@@ -27,6 +27,6 @@
"@polkadot/rpc-core": "8.6.3-3",
"@polkadot/types": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
}
}
+2 -2
View File
@@ -27,11 +27,11 @@
"@polkadot/rpc-augment": "8.6.3-3",
"@polkadot/rpc-provider": "8.6.3-3",
"@polkadot/types": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"rxjs": "^7.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^9.3.1",
"@polkadot/keyring": "^9.3.2-1",
"@polkadot/rpc-augment": "8.6.3-3"
}
}
+6 -6
View File
@@ -24,14 +24,14 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/keyring": "^9.3.1",
"@polkadot/keyring": "^9.3.2-1",
"@polkadot/types": "8.6.3-3",
"@polkadot/types-support": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util-crypto": "^9.3.1",
"@polkadot/x-fetch": "^9.3.1",
"@polkadot/x-global": "^9.3.1",
"@polkadot/x-ws": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/util-crypto": "^9.3.2-1",
"@polkadot/x-fetch": "^9.3.2-1",
"@polkadot/x-global": "^9.3.2-1",
"@polkadot/x-ws": "^9.3.2-1",
"@substrate/connect": "0.7.5",
"eventemitter3": "^4.0.7",
"mock-socket": "^9.1.4",
+2 -2
View File
@@ -42,8 +42,8 @@
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/types-create": "8.6.3-3",
"@polkadot/types-support": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/x-ws": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/x-ws": "^9.3.2-1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
"yargs": "^17.5.1"
+1 -1
View File
@@ -26,6 +26,6 @@
"@babel/runtime": "^7.18.3",
"@polkadot/types": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
}
}
+2 -2
View File
@@ -24,12 +24,12 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
},
"devDependencies": {
"@polkadot/types": "8.6.3-3",
"@polkadot/types-augment": "8.6.3-3",
"@polkadot/types-support": "8.6.3-3",
"@polkadot/util-crypto": "^9.3.1"
"@polkadot/util-crypto": "^9.3.2-1"
}
}
+1 -1
View File
@@ -25,7 +25,7 @@
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
},
"devDependencies": {
"@polkadot/types": "8.6.3-3"
+2 -2
View File
@@ -24,10 +24,10 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/networks": "^9.3.1",
"@polkadot/networks": "^9.3.2-1",
"@polkadot/types": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/types-create": "8.6.3-3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
}
}
+1 -1
View File
@@ -24,6 +24,6 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/util": "^9.3.1"
"@polkadot/util": "^9.3.2-1"
}
}
+4 -4
View File
@@ -24,16 +24,16 @@
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.3",
"@polkadot/keyring": "^9.3.1",
"@polkadot/keyring": "^9.3.2-1",
"@polkadot/types-augment": "8.6.3-3",
"@polkadot/types-codec": "8.6.3-3",
"@polkadot/types-create": "8.6.3-3",
"@polkadot/util": "^9.3.1",
"@polkadot/util-crypto": "^9.3.1",
"@polkadot/util": "^9.3.2-1",
"@polkadot/util-crypto": "^9.3.2-1",
"rxjs": "^7.5.5"
},
"devDependencies": {
"@polkadot/keyring": "^9.3.1",
"@polkadot/keyring": "^9.3.2-1",
"@polkadot/types-support": "8.6.3-3"
}
}