ghost-portal/packages/page-council/src/useModuleElections.ts
2024-01-08 15:06:30 +02:00

24 lines
615 B
TypeScript

// Copyright 2017-2024 @polkadot/app-council authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { useMemo } from 'react';
import { createNamedHook, useApi } from '@polkadot/react-hooks';
function useModuleElectionsImpl (): string | null {
const { api } = useApi();
return useMemo(
() => api.tx.phragmenElection
? 'phragmenElection'
: api.tx.electionsPhragmen
? 'electionsPhragmen'
: api.tx.elections
? 'elections'
: null,
[api]
);
}
export const useModuleElections = createNamedHook('useModuleElections', useModuleElectionsImpl);