Skip to content

Commit 96ea580

Browse files
authored
Adjust Westend known & detection (#3386)
1 parent 7d99459 commit 96ea580

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

packages/api/src/base/Init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { cryptoWaitReady } from '@polkadot/util-crypto';
1818
import { of } from '@polkadot/x-rxjs';
1919
import { map, switchMap } from '@polkadot/x-rxjs/operators';
2020

21+
import { detectedCapabilities } from './capabilities';
2122
import { Decorate } from './Decorate';
22-
import { detectedCapabilities } from './util';
2323

2424
const KEEPALIVE_INTERVAL = 15000;
2525
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };

packages/api/src/base/util.ts renamed to packages/api/src/base/capabilities.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,36 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
144144
api.query.system?.upgradedToTripleRefCount,
145145
api.query.staking?.storageVersion
146146
]);
147-
const keyed = filterEntries([
147+
const raws = filterEntries([
148148
api.query.session?.queuedKeys
149149
]);
150150

151151
return combineLatest([
152-
// FIXME consts don't have .at as of yet...
153-
of(extractResults<ExtractedC>(consts.original, consts)),
152+
consts.filtered.length
153+
? blockHash
154+
// FIXME consts don't have .at as of yet...
155+
? of([])
156+
: of(consts.filtered)
157+
: of([]),
154158
queries.filtered.length
155159
? blockHash
156160
? combineLatest(queries.filtered.map((c) => c.at(blockHash)))
157161
: api.queryMulti(queries.filtered)
158162
: of([]),
159-
keyed.filtered.length
163+
raws.filtered.length
160164
? blockHash
161-
? combineLatest(keyed.filtered.map((k) => api.rpc.state.getStorage.raw(k.key(), blockHash)))
162-
: combineLatest(keyed.filtered.map((k) => api.rpc.state.getStorage.raw(k.key())))
165+
? combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key(), blockHash)))
166+
: combineLatest(raws.filtered.map((k) => api.rpc.state.getStorage.raw(k.key())))
163167
: of([])
164168
]).pipe(
165169
map(([cResults, qResults, rResults]): Partial<DetectedTypes> =>
166170
mapCapabilities(
167171
{
168172
accountIdLength: api.registry.createType('AccountId').encodedLength
169173
},
170-
cResults,
174+
extractResults<ExtractedC>(cResults, consts),
171175
extractResults<ExtractedQ>(qResults, queries),
172-
extractResults<ExtractedR>(rResults, keyed)
176+
extractResults<ExtractedR>(rResults, raws)
173177
)
174178
),
175179
take(1)

packages/types-known/src/spec/westend.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66
import type { OverrideVersionedType } from '@polkadot/types/types';
77

88
const sharedTypes = {
9-
AccountInfo: 'AccountInfoWithDualRefCount',
10-
Address: 'MultiAddress',
119
Keys: 'SessionKeys7B',
12-
LookupSource: 'MultiAddress',
1310
ProxyType: {
14-
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy'
15-
]
16-
},
17-
ValidatorPrefs: 'ValidatorPrefsWithBlocked'
11+
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement', 'CancelProxy']
12+
}
1813
};
1914

2015
const addrAccountIdTypes = {
@@ -72,9 +67,17 @@ const versioned: OverrideVersionedType[] = [
7267
...addrAccountIdTypes
7368
}
7469
},
70+
{
71+
minmax: [48, 49],
72+
types: {
73+
...sharedTypes,
74+
AccountInfo: 'AccountInfoWithDualRefCount',
75+
Keys: 'SessionKeys6'
76+
}
77+
},
7578
{
7679
// 50 was supposed to have Beefy, didn't
77-
minmax: [48, 50],
80+
minmax: [50, 50],
7881
types: {
7982
...sharedTypes,
8083
Keys: 'SessionKeys6'

0 commit comments

Comments
 (0)