mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-08-12 20:51:37 +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
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-referenda authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@pezkuwi/api';
|
|
import type { BN } from '@pezkuwi/util';
|
|
import type { TrackDescription } from '../../types.js';
|
|
import type { TrackOption } from './types.js';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi } from '@pezkuwi/react-hooks';
|
|
import { bnToBn } from '@pezkuwi/util';
|
|
|
|
import { getTrackInfo, getTrackName } from '../../util.js';
|
|
|
|
function getTrackOptions (api: ApiPromise, specName: string, palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
|
|
const includeBn = include?.map((v) => bnToBn(v));
|
|
const excludeBn = exclude?.map((v) => bnToBn(v));
|
|
|
|
return tracks
|
|
.filter(({ id }) =>
|
|
(
|
|
!includeBn ||
|
|
includeBn.some((v) => v.eq(id))
|
|
) && (
|
|
!excludeBn ||
|
|
!excludeBn.some((v) => v.eq(id))
|
|
)
|
|
)
|
|
.map(({ id, info }): TrackOption => {
|
|
const trackInfo = getTrackInfo(api, specName, palletReferenda, tracks, id.toNumber());
|
|
const trackName = getTrackName(id, info);
|
|
|
|
return {
|
|
text: trackInfo?.text
|
|
? (
|
|
<div className='trackOption'>
|
|
<div className='normal'>{trackName}</div>
|
|
<div className='faded'>{trackInfo.text}</div>
|
|
</div>
|
|
)
|
|
: trackName,
|
|
value: id.toNumber()
|
|
};
|
|
});
|
|
}
|
|
|
|
function useTrackOptionsImpl (palletReferenda: string, tracks: TrackDescription[], include?: (BN | number)[], exclude?: (BN | number)[]): TrackOption[] {
|
|
const { api, specName } = useApi();
|
|
|
|
return useMemo(
|
|
() => getTrackOptions(api, specName, palletReferenda, tracks, include, exclude),
|
|
[api, exclude, include, palletReferenda, specName, tracks]
|
|
);
|
|
}
|
|
|
|
export default createNamedHook('useTrackOptions', useTrackOptionsImpl);
|