ghost-portal/packages/apps-routing/src/democracy.ts
Jaco 4929b1c6fd
Update headers for 2023 (#8665)
* Update headers for 2023

* Adjust env-config
2023-01-01 10:32:05 +02:00

39 lines
1015 B
TypeScript

// Copyright 2017-2023 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { TFunction } from 'i18next';
import type { ApiPromise } from '@polkadot/api';
import type { Route } from './types';
import Component, { useCounter } from '@polkadot/app-democracy';
function needsApiCheck (api: ApiPromise): boolean {
try {
// we need to be able to create an actual vote
api.tx.democracy.vote(1, { Standard: { balance: 1, vote: { aye: true, conviction: 1 } } });
return true;
} catch (error) {
console.warn('Unable to create referendum vote transaction, disabling democracy route');
return false;
}
}
export default function create (t: TFunction): Route {
return {
Component,
display: {
needsApi: [
'tx.democracy.propose'
],
needsApiCheck
},
group: 'governance',
icon: 'calendar-check',
name: 'democracy',
text: t('nav.democracy', 'Democracy', { ns: 'apps-routing' }),
useCounter
};
}