Split track defs (slightly more scalable) (#8474)
This commit is contained in:
parent
3e9acf18c7
commit
293dfe431e
32
packages/apps-config/src/api/params/tracks/index.ts
Normal file
32
packages/apps-config/src/api/params/tracks/index.ts
Normal file
@ -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<string, Record<string, TrackInfo[]>> = {
|
||||
[KUSAMA_GENESIS]: kusama
|
||||
};
|
||||
|
||||
const KNOWN_SPEC_TRACKS: Record<string, Record<string, TrackInfo[]>> = {
|
||||
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];
|
||||
}
|
||||
@ -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<string, TrackInfo[]> = {
|
||||
export const kusama: Record<string, TrackInfo[]> = {
|
||||
fellowshipReferenda: [
|
||||
{
|
||||
|
||||
@ -179,27 +168,3 @@ const KUSAMA: Record<string, TrackInfo[]> = {
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const KNOWN_GENE_TRACKS: Record<string, Record<string, TrackInfo[]>> = {
|
||||
[KUSAMA_GENESIS]: KUSAMA
|
||||
};
|
||||
|
||||
const KNOWN_SPEC_TRACKS: Record<string, Record<string, TrackInfo[]>> = {
|
||||
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];
|
||||
}
|
||||
11
packages/apps-config/src/api/params/tracks/types.ts
Normal file
11
packages/apps-config/src/api/params/tracks/types.ts
Normal file
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user