mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-11-26 23:49:55 +00:00
- dev ^0.86.4 at the root and in packages/apps; directives renamed by pezkuwi-dev-migrate-eslint10. - eslint --fix with the 0.86.4 config; one fix broke syntax (typescript-eslint prefer-optional-chain turned `(isStarted && onStart) && onStart()` into `(isStarted && onStart?.();` in TxButton) and is corrected by hand. - The remaining findings fixed rather than disabled: optional chains (each suggestion reviewed), `cause` on rethrown errors, `if` instead of `a && promise` in effects, parallel instead of sequential awaits in Promise.all, Error rejections, no `delete` on arrays (the storage query cache is a Map; an upload's file list no longer keeps a hole), no `[object Object]` stringification (TFunction's second argument is text or options), dead code removed (referenda's never-shown expand button, react-query's unused CoreDescriptor).
38 lines
983 B
TypeScript
38 lines
983 B
TypeScript
// Copyright 2017-2026 @pezkuwi/apps-routing authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@pezkuwi/api';
|
|
import type { Route, TFunction } from './types.js';
|
|
|
|
import Component, { useCounter } from '@pezkuwi/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 } } } as any);
|
|
|
|
return true;
|
|
} catch {
|
|
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
|
|
};
|
|
}
|