Adjust fee calc for signer (#5103)

This commit is contained in:
Jaco 2021-04-20 16:23:27 +03:00 committed by GitHub
parent cc3738c881
commit 7476bbbd4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -16,7 +16,7 @@ import { formatBalance, isFunction } from '@polkadot/util';
import { useTranslation } from './translate';
interface Props {
accountId?: string | null;
accountId: string | null;
className?: string;
extrinsic?: SubmittableExtrinsic | null;
isSendable: boolean;
@ -49,6 +49,11 @@ function PaymentInfo ({ accountId, className = '', extrinsic }: Props): React.Re
return null;
}
const isFeeError = api.consts.balances && !api.tx.balances?.transfer.is(extrinsic) && balances?.accountId.eq(accountId) && (
balances.availableBalance.lte(dispatchInfo.partialFee) ||
balances.freeBalance.sub(dispatchInfo.partialFee).lte(api.consts.balances.existentialDeposit)
);
return (
<>
<Expander
@ -59,7 +64,7 @@ function PaymentInfo ({ accountId, className = '', extrinsic }: Props): React.Re
</Trans>
}
/>
{api.consts.balances && !api.tx.balances?.transfer.is(extrinsic) && balances?.accountId.eq(accountId) && balances.availableBalance.sub(dispatchInfo.partialFee).lte(api.consts.balances.existentialDeposit) && (
{isFeeError && (
<MarkWarning content={t<string>('The account does not have enough free funds (excluding locked/bonded/reserved) available to cover the transaction fees without dropping the balance below the account existential amount.')} />
)}
</>

View File

@ -13,6 +13,7 @@ import PaymentInfo from './PaymentInfo';
import { useTranslation } from './translate';
interface Props {
accountId: string | null;
className?: string;
currentItem: QueueTx;
isSendable: boolean;
@ -20,7 +21,7 @@ interface Props {
tip?: BN;
}
function Transaction ({ className, currentItem: { accountId, extrinsic, isUnsigned, payload }, isSendable, onError, tip }: Props): React.ReactElement<Props> | null {
function Transaction ({ accountId, className, currentItem: { extrinsic, isUnsigned, payload }, isSendable, onError, tip }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
if (!extrinsic) {

View File

@ -361,6 +361,7 @@ function TxSigned ({ className, currentItem, requestAddress }: Props): React.Rea
: (
<>
<Transaction
accountId={senderInfo.signAddress}
currentItem={currentItem}
onError={toggleRenderError}
/>