Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix balances temp until transaction payment gets fixed #89

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/page-accounts/src/Accounts/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
locked: balancesAll.lockedBalance,
redeemable: stakingInfo?.redeemable || BN_ZERO,
total: balancesAll.freeBalance.add(balancesAll.reservedBalance),
transferable: balancesAll.transferable || balancesAll.availableBalance,
transferable: balancesAll.availableBalance,
unbonding: calcUnbonding(stakingInfo)
});

Expand Down
2 changes: 1 addition & 1 deletion packages/page-bounties/src/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function useBalanceImpl (accountId: string | null): Balance | undefined {
const { api } = useApi();
const balancesAll = useCall<DeriveBalancesAll>(api.derive.balances?.all, [accountId]);

return balancesAll?.transferable || balancesAll?.availableBalance;
return balancesAll?.availableBalance;
}

export const useBalance = createNamedHook('useBalance', useBalanceImpl);
2 changes: 1 addition & 1 deletion packages/page-staking2/src/Pools/useAmountError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useAmountErrorImpl (accountId?: string | null, amount?: BN | null, minA
return useMemo(
() => !amount || amount.isZero() || !minAmount || minAmount.gt(amount) || (
!!balances &&
amount.gt((balances.transferable || balances.availableBalance).sub(api.consts.balances.existentialDeposit))
amount.gt(balances.availableBalance.sub(api.consts.balances.existentialDeposit))
),
[api, amount, balances, minAmount]
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/AddressInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ function createBalanceItems (formatIndex: number, lookup: Record<string, string>
/>
</React.Fragment>
);
balancesAll && balanceDisplay.available && (deriveBalances.transferable || deriveBalances.availableBalance) && allItems.push(
balancesAll && balanceDisplay.available && deriveBalances.availableBalance && allItems.push(
<React.Fragment key={1}>
<Label label={t('transferable')} />
<FormatBalance
className='result'
formatIndex={formatIndex}
labelPost={<IconVoid />}
value={deriveBalances.transferable || deriveBalances.availableBalance}
value={deriveBalances.availableBalance}
/>
</React.Fragment>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/modals/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ function Transfer ({ className = '', onClose, recipientId: propRecipientId, send
if (balances && balances.accountId?.eq(fromId) && fromId && toId && api.call.transactionPaymentApi && api.tx.balances) {
nextTick(async (): Promise<void> => {
try {
const extrinsic = (api.tx.balances.transferAllowDeath || api.tx.balances.transfer)(toId, (balances.transferable || balances.availableBalance));
const extrinsic = (api.tx.balances.transferAllowDeath || api.tx.balances.transfer)(toId, balances.availableBalance);
const { partialFee } = await extrinsic.paymentInfo(fromId);
const adjFee = partialFee.muln(110).div(BN_HUNDRED);
const maxTransfer = (balances.transferable || balances.availableBalance).sub(adjFee);
const maxTransfer = balances.availableBalance.sub(adjFee);

setMaxTransfer(
api.consts.balances && maxTransfer.gt(api.consts.balances.existentialDeposit)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-query/src/Available.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function AvailableDisplay ({ children, className = '', label, params }: Props):
<FormatBalance
className={className}
label={label}
value={allBalances?.transferable || allBalances?.availableBalance}
value={allBalances?.availableBalance}
>
{children}
</FormatBalance>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-signer/src/PaymentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function PaymentInfo ({ accountId, className = '', extrinsic, isHeader }: Props)
}

const isFeeError = api.consts.balances && !(api.tx.balances?.transferAllowDeath?.is(extrinsic) || api.tx.balances?.transfer?.is(extrinsic)) && balances?.accountId.eq(accountId) && (
(balances.transferable || balances.availableBalance).lte(dispatchInfo.partialFee) ||
balances.availableBalance.lte(dispatchInfo.partialFee) ||
balances.freeBalance.sub(dispatchInfo.partialFee).lte(api.consts.balances.existentialDeposit)
);

Expand Down