Disable referenda app where no tracks are defined (#8821)
This commit is contained in:
parent
fbfb697410
commit
ec90bd2898
@ -13,7 +13,8 @@ export default function create (t: TFunction): Route {
|
||||
needsAccounts: true,
|
||||
needsApi: [
|
||||
'tx.fellowshipCollective.vote',
|
||||
'tx.fellowshipReferenda.submit'
|
||||
'tx.fellowshipReferenda.submit',
|
||||
'consts.fellowshipReferenda.tracks'
|
||||
]
|
||||
},
|
||||
group: 'governance',
|
||||
|
||||
@ -12,7 +12,8 @@ export default function create (t: TFunction): Route {
|
||||
display: {
|
||||
needsApi: [
|
||||
'tx.referenda.submit',
|
||||
'tx.convictionVoting.vote'
|
||||
'tx.convictionVoting.vote',
|
||||
'consts.referenda.tracks'
|
||||
]
|
||||
},
|
||||
group: 'governance',
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, isObject } from '@polkadot/util';
|
||||
|
||||
type ApiMapper = Record<string, Record<string, Record<string, unknown>>>;
|
||||
|
||||
@ -11,7 +11,9 @@ function hasEndpoint (api: ApiPromise, endpoint: string, needsApiInstances: bool
|
||||
const [section] = (needsApiInstances && api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), _section)) || [_section];
|
||||
|
||||
try {
|
||||
return isFunction((api as unknown as ApiMapper)[area][section][method]);
|
||||
return area === 'consts'
|
||||
? isObject((api as unknown as ApiMapper)[area][section][method])
|
||||
: isFunction((api as unknown as ApiMapper)[area][section][method]);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user