Skip to content

Commit

Permalink
feat(interest): eligibility by coin
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Jul 22, 2020
1 parent 59f602c commit 8af56af
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
Expand Up @@ -79,6 +79,10 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
coin,
interestBalanceBase
)
const interestEligibleCoin =
interestEligible[coin] && interestEligible[coin]?.eligible
const ineliglityReason =
interestEligible[coin] && interestEligible[coin]?.ineligibilityReason
return (
<DepositBox>
<Row>
Expand Down Expand Up @@ -192,7 +196,7 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
</AmountRow>
{accountBalanceBase > 0 ? (
<Button
disabled={!isGoldTier || !interestEligible.eligible}
disabled={!isGoldTier || !interestEligibleCoin}
style={{ marginTop: '16px' }}
nature='primary'
data-e2e='viewInterestDetails'
Expand All @@ -205,7 +209,7 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
</Button>
) : (
<Button
disabled={!isGoldTier || !interestEligible.eligible}
disabled={!isGoldTier || !interestEligibleCoin}
style={{ marginTop: '16px' }}
nature='primary'
fullwidth
Expand All @@ -220,7 +224,7 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
/>
</Button>
)}
{interestEligible.ineligibilityReason === 'REGION' && (
{ineliglityReason === 'REGION' && (
<AbsoluteWarningRegion size='12px' weight={500} color='grey600'>
<Icon name='info' color='grey600' />
<div style={{ marginLeft: '8px' }}>
Expand All @@ -242,7 +246,7 @@ function SummaryCard (props: OwnProps & SuccessStateType): ReactElement {
</div>
</AbsoluteWarningRegion>
)}
{interestEligible.ineligibilityReason === 'BLOCKED' && (
{interestEligibleCoin && ineliglityReason === 'BLOCKED' && (
<AbsoluteWarning size='12px' weight={500} color='grey600'>
<Icon name='info' color='grey600' />
<div style={{ marginLeft: '8px' }}>
Expand Down
28 changes: 23 additions & 5 deletions packages/blockchain-wallet-v4/src/network/api/interest/index.ts
Expand Up @@ -24,12 +24,30 @@ export default ({ nabuUrl, authorizedGet, authorizedPost }) => {
din
}
})
const getInterestEligible = (): InterestEligibleType => ({
BTC: {
eligible: true,
ineligibilityReason: null
},
ETH: {
eligible: true,
ineligibilityReason: null
},
PAX: {
eligible: false,
ineligibilityReason: 'REGION'
},
USDT: {
eligible: false,
ineligibilityReason: 'REGION'
}
})

const getInterestEligible = (): InterestEligibleType =>
authorizedGet({
url: nabuUrl,
endPoint: '/savings/eligible'
})
// const getInterestEligible = (): InterestEligibleType =>
// authorizedGet({
// url: nabuUrl,
// endPoint: '/savings/eligible'
// })

const getInterestInstruments = (): InterestInstrumentsType =>
authorizedGet({
Expand Down
Expand Up @@ -13,8 +13,10 @@ export type InterestAccountBalanceType = {
}

export type InterestEligibleType = {
eligible: boolean
ineligibilityReason: 'KYC_TIER' | 'BLOCKED' | 'REGION'
[key in CoinType]?: {
eligible: boolean
ineligibilityReason: 'KYC_TIER' | 'BLOCKED' | 'REGION' | null
}
}

export type InterestInstrumentsType = Array<CoinType>
Expand Down

0 comments on commit 8af56af

Please sign in to comment.