diff --git a/packages/apps-config/src/api/params/tracks/index.ts b/packages/apps-config/src/api/params/tracks/index.ts new file mode 100644 index 0000000000..dbc38daea8 --- /dev/null +++ b/packages/apps-config/src/api/params/tracks/index.ts @@ -0,0 +1,32 @@ +// Copyright 2017-2022 @polkadot/app-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { ApiPromise } from '@polkadot/api'; +import type { TrackInfo } from './types'; + +import { KUSAMA_GENESIS } from '../../constants'; +import { kusama } from './kusama'; + +const KNOWN_GENE_TRACKS: Record> = { + [KUSAMA_GENESIS]: kusama +}; + +const KNOWN_SPEC_TRACKS: Record> = { + kusama, + // for kitchensink, we just use the root + node: { + referenda: [ + { + id: 0, + name: 'root', + origin: { system: 'Root' } + } + ] + } +}; + +export function getGovernanceTracks (api: ApiPromise, specName: string, palletReferenda: string): TrackInfo[] | undefined { + const lookup = KNOWN_GENE_TRACKS[api.genesisHash.toHex()] || KNOWN_SPEC_TRACKS[specName]; + + return lookup && lookup[palletReferenda]; +} diff --git a/packages/apps-config/src/api/params/tracks.ts b/packages/apps-config/src/api/params/tracks/kusama.ts similarity index 82% rename from packages/apps-config/src/api/params/tracks.ts rename to packages/apps-config/src/api/params/tracks/kusama.ts index 3e9922d157..52d28f22a0 100644 --- a/packages/apps-config/src/api/params/tracks.ts +++ b/packages/apps-config/src/api/params/tracks/kusama.ts @@ -1,20 +1,9 @@ // Copyright 2017-2022 @polkadot/app-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { ApiPromise } from '@polkadot/api'; +import type { TrackInfo } from './types'; -import { KUSAMA_GENESIS } from '../constants'; - -type Origin = { system: string } | { Origins: string }; - -interface TrackInfo { - id: number; - name: string; - origin: Origin | Origin[]; - text?: string; -} - -const KUSAMA: Record = { +export const kusama: Record = { fellowshipReferenda: [ { @@ -179,27 +168,3 @@ const KUSAMA: Record = { } ] }; - -const KNOWN_GENE_TRACKS: Record> = { - [KUSAMA_GENESIS]: KUSAMA -}; - -const KNOWN_SPEC_TRACKS: Record> = { - kusama: KUSAMA, - // for kitchensink, we just use the root - node: { - referenda: [ - { - id: 0, - name: 'root', - origin: { system: 'Root' } - } - ] - } -}; - -export function getGovernanceTracks (api: ApiPromise, specName: string, palletReferenda: string): TrackInfo[] | undefined { - const lookup = KNOWN_GENE_TRACKS[api.genesisHash.toHex()] || KNOWN_SPEC_TRACKS[specName]; - - return lookup && lookup[palletReferenda]; -} diff --git a/packages/apps-config/src/api/params/tracks/types.ts b/packages/apps-config/src/api/params/tracks/types.ts new file mode 100644 index 0000000000..6d3f67aa74 --- /dev/null +++ b/packages/apps-config/src/api/params/tracks/types.ts @@ -0,0 +1,11 @@ +// Copyright 2017-2022 @polkadot/app-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +export type Origin = { system: string } | { Origins: string }; + +export interface TrackInfo { + id: number; + name: string; + origin: Origin | Origin[]; + text?: string; +}