mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-26 17:45:42 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/apps authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@pezkuwi/api';
|
|
|
|
import { isFunction, isObject } from '@pezkuwi/util';
|
|
|
|
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][resolvedSection][method])
|
|
: isFunction((api as unknown as ApiMapper)[area][resolvedSection][method]);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function findMissingApis (api: ApiPromise, needsApi?: (string | string[])[], needsApiInstances = false, needsApiCheck?: (api: ApiPromise) => boolean): (string | string[])[] {
|
|
if (!needsApi) {
|
|
return [];
|
|
}
|
|
|
|
const missing = needsApi.filter((endpoint: string | string[]): boolean => {
|
|
const hasApi = Array.isArray(endpoint)
|
|
? endpoint.reduce((hasApi, endpoint) => hasApi || hasEndpoint(api, endpoint, needsApiInstances), false)
|
|
: hasEndpoint(api, endpoint, needsApiInstances);
|
|
|
|
return !hasApi;
|
|
});
|
|
|
|
if (!missing.length && needsApiCheck && !needsApiCheck(api)) {
|
|
return ['needsApiCheck'];
|
|
}
|
|
|
|
return missing;
|
|
}
|