Resolve module location for endpoints if it exists (#10483)
* Council fix in endpoint for modules * lint
This commit is contained in:
parent
c4044ec5f0
commit
5f6cb557b5
@ -10,11 +10,14 @@ type ApiMapper = Record<string, Record<string, Record<string, unknown>>>;
|
||||
function hasEndpoint (api: ApiPromise, endpoint: string, needsApiInstances: boolean): boolean {
|
||||
const [area, _section, method] = endpoint.split('.');
|
||||
const [section] = (needsApiInstances && api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), _section)) || [_section];
|
||||
const resolvedSection = (api as unknown as ApiMapper)[area][section]
|
||||
? section
|
||||
: _section;
|
||||
|
||||
try {
|
||||
return area === 'consts'
|
||||
? isObject((api as unknown as ApiMapper)[area][section][method])
|
||||
: isFunction((api as unknown as ApiMapper)[area][section][method]);
|
||||
? isObject((api as unknown as ApiMapper)[area][resolvedSection][method])
|
||||
: isFunction((api as unknown as ApiMapper)[area][resolvedSection][method]);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user