Skip to content

Commit

Permalink
feat(eth-interest): add interest wallet to eth balance dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Jun 24, 2020
1 parent 6a12114 commit 6de14d6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ADDRESS_TYPES } from 'blockchain-wallet-v4/src/redux/payment/btc/utils'
// @ts-ignore
import { concat, curry, filter, has, map, prop, reduce, sequence } from 'ramda'
import { Erc20CoinType } from 'core/types'
import { Erc20CoinType , InterestAccountBalanceType } from 'core/types'
import { Exchange, Remote } from 'blockchain-wallet-v4/src'

import { selectors } from 'data'

export const getEthData = (
Expand All @@ -12,13 +13,15 @@ export const getEthData = (
excludeLockbox?: boolean
includeCustodial?: boolean
includeExchangeAddress?: boolean
includeInterest?: boolean
}
) => {
const {
exclude = [],
excludeLockbox,
includeExchangeAddress,
includeCustodial
includeCustodial,
includeInterest
} = ownProps
const displayEthFixed = data => {
const etherAmount = Exchange.convertEtherToEther(data)
Expand Down Expand Up @@ -49,6 +52,16 @@ export const getEthData = (
})})`
)
}
const buildInterestDisplay = (x: InterestAccountBalanceType['ETH']) => {
return (
`ETH Interest Wallet` +
` (${Exchange.displayEtherToEther({
value: x ? x.balance : 0,
fromUnit: 'WEI',
toUnit: 'ETH'
})})`
)
}
// @ts-ignore
const excluded = filter(x => !exclude.includes(x.label))
const toDropdown = map(x => ({ label: buildDisplay(x), value: x }))
Expand All @@ -65,6 +78,17 @@ export const getEthData = (
}
]

const toInterestDropdown = x => [
{
label: buildInterestDisplay(x),
value: {
...x,
type: ADDRESS_TYPES.INTEREST,
label: 'ETH Interest Wallet'
}
}
]

const exchangeAddress = selectors.components.send.getPaymentsAccountExchange(
'ETH',
state
Expand All @@ -88,6 +112,13 @@ export const getEthData = (
.map(toCustodialDropdown)
.map(toGroup('Custodial Wallet'))
: Remote.of([]),
includeInterest
? selectors.components.interest
.getInterestAccountBalance(state)
.map<any, any>(prop('ETH'))
.map(toInterestDropdown)
.map(toGroup('Interest Wallet'))
: Remote.of([]),
excludeLockbox
? Remote.of([])
: selectors.core.common.eth
Expand Down Expand Up @@ -141,6 +172,7 @@ export const getErc20Data = (
})})`
)
}

// @ts-ignore
const excluded = filter(x => !exclude.includes(x.label))
const buildDisplay = wallet => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const getData = (
case 'ETH':
addressDataR = getEthAddressData(state, {
excludeLockbox: true,
includeCustodial: true
includeCustodial: true,
includeInterest: true
})
balanceDataR = balanceSelectors.getEthBalance(state)
coinRatesR = selectors.core.data.eth.getRates(state)
Expand Down

0 comments on commit 6de14d6

Please sign in to comment.