Preimage tweaks (disable & fees) (#7943)
This commit is contained in:
parent
983e79bee9
commit
409e50d895
@ -24,6 +24,7 @@ import membership from './membership';
|
||||
import nfts from './nfts';
|
||||
import parachains from './parachains';
|
||||
import poll from './poll';
|
||||
import preimages from './preimages';
|
||||
import rpc from './rpc';
|
||||
import runtime from './runtime';
|
||||
import settings from './settings';
|
||||
@ -57,6 +58,7 @@ export default function create (t: TFunction): Routes {
|
||||
techcomm(t),
|
||||
membership(t),
|
||||
alliance(t),
|
||||
preimages(t),
|
||||
whitelist(t),
|
||||
parachains(t),
|
||||
gilt(t),
|
||||
|
||||
26
packages/apps-routing/src/preimages.ts
Normal file
26
packages/apps-routing/src/preimages.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2017-2022 @polkadot/apps-routing authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { TFunction } from 'i18next';
|
||||
import type { Route } from './types';
|
||||
|
||||
import Component from '@polkadot/app-preimages';
|
||||
|
||||
export default function create (t: TFunction): Route {
|
||||
return {
|
||||
Component,
|
||||
display: {
|
||||
needsAccounts: true,
|
||||
needsApi: [
|
||||
'tx.preimage.notePreimage',
|
||||
// only enable when we have referenda (or ranked would be applicable as
|
||||
// well, we basically want to disable on all Gov1 chains)
|
||||
'tx.referenda.submit'
|
||||
]
|
||||
},
|
||||
group: 'governance',
|
||||
icon: 'panorama',
|
||||
name: 'preimages',
|
||||
text: t('nav.preimages', 'Preimages', { ns: 'apps-routing' })
|
||||
};
|
||||
}
|
||||
@ -10,6 +10,7 @@ export default function create (t: TFunction): Route {
|
||||
return {
|
||||
Component,
|
||||
display: {
|
||||
needsAccounts: true,
|
||||
needsApi: [
|
||||
'tx.whitelist.removeWhitelistedCall'
|
||||
]
|
||||
|
||||
@ -36,13 +36,15 @@ function Add ({ className, imageHash }: Props): React.ReactElement<Props> {
|
||||
|
||||
useEffect((): void => {
|
||||
const encodedProposal = (proposal as SubmittableExtrinsic<'promise'>)?.method.toHex() || '';
|
||||
const storageFee = api.consts.democracy.preimageByteDeposit.mul(
|
||||
encodedProposal
|
||||
? new BN((encodedProposal.length - 2) / 2)
|
||||
: BN_ZERO
|
||||
);
|
||||
|
||||
setHash({ encodedHash: blake2AsHex(encodedProposal), encodedProposal, storageFee });
|
||||
// we currently don't have a constant exposed, or rather, maybe somwhere else...
|
||||
// const storageFee = api.consts.democracy.preimageByteDeposit.mul(
|
||||
// encodedProposal
|
||||
// ? new BN((encodedProposal.length - 2) / 2)
|
||||
// : BN_ZERO
|
||||
// );
|
||||
|
||||
setHash({ encodedHash: blake2AsHex(encodedProposal), encodedProposal, storageFee: BN_ZERO });
|
||||
}, [api, proposal]);
|
||||
|
||||
const isMatched = imageHash
|
||||
@ -93,14 +95,16 @@ function Add ({ className, imageHash }: Props): React.ReactElement<Props> {
|
||||
value={encodedHash}
|
||||
/>
|
||||
</Modal.Columns>
|
||||
<Modal.Columns hint={t<string>('The calculated storage costs based on the size and the per-bytes fee.')}>
|
||||
<InputBalance
|
||||
defaultValue={storageFee}
|
||||
help={t<string>('The amount reserved to store this image')}
|
||||
isDisabled
|
||||
label={t<string>('calculated storage fee')}
|
||||
/>
|
||||
</Modal.Columns>
|
||||
{!storageFee.isZero() && (
|
||||
<Modal.Columns hint={t<string>('The calculated storage costs based on the size and the per-bytes fee.')}>
|
||||
<InputBalance
|
||||
defaultValue={storageFee}
|
||||
help={t<string>('The amount reserved to store this image')}
|
||||
isDisabled
|
||||
label={t<string>('calculated storage fee')}
|
||||
/>
|
||||
</Modal.Columns>
|
||||
)}
|
||||
</Modal.Content>
|
||||
<Modal.Actions>
|
||||
<TxButton
|
||||
|
||||
Loading…
Reference in New Issue
Block a user