Skip to content

Commit

Permalink
Fix: TaskFinalize domain balances logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rdig committed Feb 10, 2020
1 parent 406c1bc commit cce5935
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/modules/dashboard/components/TaskFinalize/TaskFinalize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
AnyTask,
Payouts,
Domain,
TokenWithBalances,
useTokenBalancesForDomainsQuery,
} from '~data/index';
import { ActionTypes } from '~redux/index';
Expand Down Expand Up @@ -76,28 +75,20 @@ const TaskFinalize = ({
try {
setIsLoading(true);
const enoughFundsAvailable = payouts.every(({ amount, tokenAddress }) => {
if (!tokenBalances) {
const domainBalances =
tokenBalances &&
tokenBalances.tokens.find(
({ address: domainTokenAddress }) =>
domainTokenAddress === tokenAddress,
);
if (!domainBalances) {
return false;
}
/*
* @NOTE About the types ignore
*
* For some reason I get a TS error about balances prop not existing, even though
* it's available on the union type. I must be missing something...
*/
const {
// @ts-ignore
balances: domainBalances,
decimals,
} = tokenBalances.tokens.find(
({ address: domainTokenAddress }) =>
domainTokenAddress === tokenAddress,
) as TokenWithBalances;
return domainBalances.every(
return domainBalances.balances.every(
({ amount: availableDomainAmount }) =>
!bnLessThan(
availableDomainAmount,
moveDecimal(amount, decimals || 18),
moveDecimal(amount, domainBalances.decimals || 18),
),
);
});
Expand Down

0 comments on commit cce5935

Please sign in to comment.