Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/src/base/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,36 @@ 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> =>
mapCapabilities(
{
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)
Expand Down
19 changes: 11 additions & 8 deletions packages/types-known/src/spec/westend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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'
Expand Down