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

Commit

Permalink
vCOW on profile (#2062)
Browse files Browse the repository at this point in the history
# Summary

Adding vCOW balance to Profile page

Simply loading the balance (if any) to replace the placeholder data
<img width="930" alt="Screen Shot 2022-01-07 at 15 14 51" src="https://user-images.githubusercontent.com/43217/148619074-28e83425-678e-46bb-9bc4-c2481d625213.png">



  # To Test

1. Load the test PK on rinkeby `0x044a6c3636d0e4a7d3c3ead9f9a470efff0390f8531545c6d58018fe89f8a7a5`
2. Go to Profile page
* It should show how many vCOWs it has.
* Accounts with no vCOW will show 0
* Networks where vCOW is not deployed (anything but Rinkeby) will not show the badge at all
  • Loading branch information
alfetopito authored Jan 11, 2022
1 parent ab29d42 commit be65cac
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/custom/pages/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { HelpCircle, RefreshCcw } from 'react-feather'
import Web3Status from 'components/Web3Status'
import useReferralLink from 'hooks/useReferralLink'
import useFetchProfile from 'hooks/useFetchProfile'
import { numberFormatter } from 'utils/format'
import { formatMax, formatSmart, numberFormatter } from 'utils/format'
import { getExplorerAddressLink } from 'utils/explorer'
import useTimeAgo from 'hooks/useTimeAgo'
import { MouseoverTooltipContent } from 'components/Tooltip'
Expand All @@ -33,6 +33,9 @@ import AffiliateStatusCheck from 'components/AffiliateStatusCheck'
import { useHasOrders } from 'api/gnosisProtocol/hooks'
import CowProtocolLogo from 'components/CowProtocolLogo'
import { Title } from 'components/Page'
import { useTokenBalance } from 'state/wallet/hooks'
import { V_COW } from 'constants/tokens'
import { AMOUNT_PRECISION } from 'constants/index'

export default function Profile() {
const referralLink = useReferralLink()
Expand All @@ -42,6 +45,8 @@ export default function Profile() {
const isTradesTooltipVisible = account && chainId == 1 && !!profileData?.totalTrades
const hasOrders = useHasOrders(account)

const vCowBalance = useTokenBalance(account || undefined, chainId ? V_COW[chainId] : undefined)

const renderNotificationMessages = (
<>
{error && (
Expand All @@ -64,15 +69,21 @@ export default function Profile() {
<CardHead>
<Title>Profile</Title>
</CardHead>
<VCOWBalance>
<CowProtocolLogo size={46} />
<ProfileFlexCol>
<Txt fs={14}>Balance</Txt>
<Txt fs={18}>
<strong>102,02 vCOW</strong>
</Txt>
</ProfileFlexCol>
</VCOWBalance>
{vCowBalance && (
<VCOWBalance>
<CowProtocolLogo size={46} />
<ProfileFlexCol>
<Txt fs={14}>Balance</Txt>
<Txt fs={18} title={`${formatMax(vCowBalance)} vCOW`}>
<strong>
{formatSmart(vCowBalance, AMOUNT_PRECISION, { thousandSeparator: true, isLocaleAware: true }) ||
'0'}{' '}
vCOW
</strong>
</Txt>
</ProfileFlexCol>
</VCOWBalance>
)}
</ProfileGridWrap>
</ProfileWrapper>
{chainId && chainId === ChainId.MAINNET && <AffiliateStatusCheck />}
Expand Down

0 comments on commit be65cac

Please sign in to comment.