add proper display per token
This commit is contained in:
parent
21fc220e4d
commit
d2117638b8
|
@ -42,10 +42,11 @@ function CurrencySelect({
|
||||||
const latestAllowances = {}
|
const latestAllowances = {}
|
||||||
currencies.forEach(async c => {
|
currencies.forEach(async c => {
|
||||||
if (c.contract) {
|
if (c.contract) {
|
||||||
|
const { humanReadibleFn } = c
|
||||||
const amount = await c.contract.methods.balanceOf(account).call()
|
const amount = await c.contract.methods.balanceOf(account).call()
|
||||||
const allowance = await getLpAllowance(c.contract)
|
const allowance = await getLpAllowance(c.contract)
|
||||||
latestBalances[c.value] = toEther(amount)
|
latestBalances[c.value] = humanReadibleFn(amount)
|
||||||
latestAllowances[c.value] = toEther(allowance)
|
latestAllowances[c.value] = humanReadibleFn(allowance)
|
||||||
} else {
|
} else {
|
||||||
latestBalances[c.value] = '0'
|
latestBalances[c.value] = '0'
|
||||||
latestAllowances[c.value] = '0'
|
latestAllowances[c.value] = '0'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*global web3*/
|
/*global web3*/
|
||||||
|
|
||||||
export const toEther = amount => web3.utils.fromWei(amount, 'ether')
|
export const toEther = (amount, scale = 'ether') => web3.utils.fromWei(amount, scale)
|
||||||
export const toWei = (amount, scale = 'ether') => web3.utils.toWei(amount, scale)
|
export const toWei = (amount, scale = 'ether') => web3.utils.toWei(amount, scale)
|
||||||
|
export const compoundWhole = amount => (Number(amount) / (10**8)).toString()
|
||||||
|
|
|
@ -3,6 +3,7 @@ import DAI from '../embarkArtifacts/contracts/DAI'
|
||||||
import cDAI from '../embarkArtifacts/contracts/cDAI'
|
import cDAI from '../embarkArtifacts/contracts/cDAI'
|
||||||
import cETH from '../embarkArtifacts/contracts/cETH'
|
import cETH from '../embarkArtifacts/contracts/cETH'
|
||||||
import sntIco from 'cryptocurrency-icons/svg/color/snt.svg'
|
import sntIco from 'cryptocurrency-icons/svg/color/snt.svg'
|
||||||
|
import { toEther, compoundWhole } from './conversions'
|
||||||
|
|
||||||
export const TOKEN_ICON_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/images'
|
export const TOKEN_ICON_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/images'
|
||||||
export const TOKEN_COIN_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/coins'
|
export const TOKEN_COIN_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/coins'
|
||||||
|
@ -13,33 +14,38 @@ export const currencies = [
|
||||||
label: 'cETH',
|
label: 'cETH',
|
||||||
img: `${TOKEN_API}/0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5.png`,
|
img: `${TOKEN_API}/0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5.png`,
|
||||||
width: '5%',
|
width: '5%',
|
||||||
contract: cETH
|
contract: cETH,
|
||||||
|
humanReadibleFn: compoundWhole,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
value: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||||
label: 'Wrapped Ether',
|
label: 'Wrapped Ether',
|
||||||
img: `${TOKEN_COIN_API}/60.png`,
|
img: `${TOKEN_COIN_API}/60.png`,
|
||||||
width: '5%',
|
width: '5%',
|
||||||
|
humanReadibleFn: toEther,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: SNT._address,
|
value: SNT._address,
|
||||||
label: 'SNT',
|
label: 'SNT',
|
||||||
img: sntIco,
|
img: sntIco,
|
||||||
contract: SNT
|
contract: SNT,
|
||||||
|
humanReadibleFn: toEther,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
value: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',
|
||||||
label: 'DAI',
|
label: 'DAI',
|
||||||
img: `${TOKEN_API}/0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359.png`,
|
img: `${TOKEN_API}/0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359.png`,
|
||||||
width: '5%',
|
width: '5%',
|
||||||
contract: DAI
|
contract: DAI,
|
||||||
|
humanReadibleFn: toEther,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: '0xf5dce57282a584d2746faf1593d3121fcac444dc',
|
value: '0xf5dce57282a584d2746faf1593d3121fcac444dc',
|
||||||
label: 'cDAI',
|
label: 'cDAI',
|
||||||
img: `${TOKEN_API}/0xf5dce57282a584d2746faf1593d3121fcac444dc.png`,
|
img: `${TOKEN_API}/0xf5dce57282a584d2746faf1593d3121fcac444dc.png`,
|
||||||
width: '5%',
|
width: '5%',
|
||||||
contract: cDAI
|
contract: cDAI,
|
||||||
|
humanReadibleFn: compoundWhole,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue