Adjust Westend known & detection (#3386)

This commit is contained in:
Jaco Greeff
2021-04-11 15:19:05 +02:00
committed by GitHub
parent 7d99459f50
commit 96ea5803d4
3 changed files with 24 additions and 17 deletions
+1 -1
View File
@@ -18,8 +18,8 @@ import { cryptoWaitReady } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { detectedCapabilities } from './capabilities';
import { Decorate } from './Decorate';
import { detectedCapabilities } from './util';
const KEEPALIVE_INTERVAL = 15000;
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
@@ -144,22 +144,26 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
api.query.system?.upgradedToTripleRefCount,
api.query.staking?.storageVersion
]);
const keyed = filterEntries([
const raws = filterEntries([
api.query.session?.queuedKeys
]);
return combineLatest([
// FIXME consts don't have .at as of yet...
of(extractResults<ExtractedC>(consts.original, consts)),
consts.filtered.length
? blockHash
// FIXME consts don't have .at as of yet...
? of([])
: of(consts.filtered)
: of([]),
queries.filtered.length
? blockHash
? combineLatest(queries.filtered.map((c) => c.at(blockHash)))
: api.queryMulti(queries.filtered)
: of([]),
keyed.filtered.length
raws.filtered.length
? blockHash
? combineLatest(keyed.filtered.map((k) => api.rpc.state.getStorage.raw(k.key(), blockHash)))
: combineLatest(keyed.filtered.map((k) => api.rpc.state.getStorage.raw(k.key())))
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key(), blockHash)))
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key())))
: of([])
]).pipe(
map(([cResults, qResults, rResults]): Partial<DetectedTypes> =>
@@ -167,9 +171,9 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
{
accountIdLength: api.registry.createType('AccountId').encodedLength
},
cResults,
extractResults<ExtractedC>(cResults, consts),
extractResults<ExtractedQ>(qResults, queries),
extractResults<ExtractedR>(rResults, keyed)
extractResults<ExtractedR>(rResults, raws)
)
),
take(1)
+11 -8
View File
@@ -6,15 +6,10 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
Keys: 'SessionKeys7B',
LookupSource: 'MultiAddress',
ProxyType: {
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy'
]
},
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy']
}
};
const addrAccountIdTypes = {
@@ -72,9 +67,17 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes
}
},
{
minmax: [48, 49],
types: {
...sharedTypes,
AccountInfo: 'AccountInfoWithDualRefCount',
Keys: 'SessionKeys6'
}
},
{
// 50 was supposed to have Beefy, didn't
minmax: [48, 50],
minmax: [50, 50],
types: {
...sharedTypes,
Keys: 'SessionKeys6'