mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-15 11:15: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
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/app-referenda authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { Changes } from '@pezkuwi/react-hooks/useEventChanges';
|
|
import type { StorageKey } from '@pezkuwi/types';
|
|
import type { AccountId32, EventRecord } from '@pezkuwi/types/interfaces';
|
|
import type { PalletColl } from './types.js';
|
|
|
|
import { createNamedHook, useApi, useEventChanges, useMapKeys } from '@pezkuwi/react-hooks';
|
|
|
|
const OPT_ID = {
|
|
transform: (keys: StorageKey<[AccountId32]>[]): AccountId32[] =>
|
|
keys.map(({ args: [id] }) => id)
|
|
};
|
|
|
|
function filter (records: EventRecord[]): Changes<AccountId32> {
|
|
const added: AccountId32[] = [];
|
|
const removed: AccountId32[] = [];
|
|
|
|
records.forEach(({ event: { data: [id], method } }): void => {
|
|
if (method === 'MemberAdded') {
|
|
added.push(id as AccountId32);
|
|
} else {
|
|
removed.push(id as AccountId32);
|
|
}
|
|
});
|
|
|
|
return { added, removed };
|
|
}
|
|
|
|
function useMemberIdsImpl (collective: PalletColl): AccountId32[] | undefined {
|
|
const { api } = useApi();
|
|
const startValue = useMapKeys(api.query[collective].members, [], OPT_ID);
|
|
|
|
return useEventChanges([
|
|
api.events[collective].MemberAdded,
|
|
api.events[collective].MemberRemoved
|
|
], filter, startValue);
|
|
}
|
|
|
|
export default createNamedHook('useMemberIds', useMemberIdsImpl);
|