Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2075 from gnosis/claim-pending-update
Browse files Browse the repository at this point in the history
Claim pending update
  • Loading branch information
W3stside authored Jan 13, 2022
2 parents e9debfe + 8fbe659 commit 883daa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/custom/pages/Claim/ClaimSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function ClaimSummary({ hasClaims, unclaimedAmount }: ClaimSummar
<div>
<ClaimTotal>
<b>Total available to claim</b>
<p>{formatSmart(unclaimedAmount)} vCOW</p>
<p>{formatSmart(unclaimedAmount) ?? 0} vCOW</p>
</ClaimTotal>
</div>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/custom/state/claim/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SupportedChainId } from 'constants/chains'
import { registerOnWindow } from 'utils/misc'
import mockData, { MOCK_INDICES } from './mocks/claimData'
import { getIndexes } from './utils'
import { useAllClaimingTransactionIndices } from 'state/enhancedTransactions/hooks'

export { useUserClaimData } from '@src/state/claim/hooks'

Expand Down Expand Up @@ -194,13 +195,18 @@ export function useUserHasAvailableClaim(account: Account): boolean {
export function useUserUnclaimedAmount(account: string | null | undefined): CurrencyAmount<Token> | undefined {
const { chainId } = useActiveWeb3React()
const claims = useUserAvailableClaims(account)
const pendingIndices = useAllClaimingTransactionIndices()

const vCow = chainId ? V_COW[chainId] : undefined
if (!vCow) return undefined
if (!claims || claims.length === 0) {
return CurrencyAmount.fromRawAmount(vCow, JSBI.BigInt(0))
}

const totalAmount = claims.reduce((acc, claim) => {
// don't add pending
if (pendingIndices.has(claim.index)) return acc

return JSBI.add(acc, JSBI.BigInt(claim.amount))
}, JSBI.BigInt('0'))

Expand Down

0 comments on commit 883daa4

Please sign in to comment.