fix: removed the 'bitcoincash:' substring from bch addresses on the

admin
This commit is contained in:
Liordino Neto 2020-09-25 16:04:25 -03:00 committed by Josh Harvey
parent 14cbd127c4
commit 7da522b1da
4 changed files with 21 additions and 9 deletions

View file

@ -22,6 +22,7 @@ import {
} from 'src/components/typography' } from 'src/components/typography'
import CopyToClipboard from 'src/pages/Transactions/CopyToClipboard' import CopyToClipboard from 'src/pages/Transactions/CopyToClipboard'
import { primaryColor } from 'src/styling/variables' import { primaryColor } from 'src/styling/variables'
import { formatCryptoAddress } from 'src/utils/coin'
import styles from './Funding.styles' import styles from './Funding.styles'
@ -50,7 +51,8 @@ const GET_FUNDING = gql`
} }
` `
const formatAddress = (address = '') => address.replace(/(.{4})/g, '$1 ') const formatAddress = (cryptoCode = '', address = '') =>
formatCryptoAddress(cryptoCode, address).replace(/(.{4})/g, '$1 ')
const sumReducer = (acc, value) => acc.plus(value) const sumReducer = (acc, value) => acc.plus(value)
const formatNumber = it => new BigNumber(it).toFormat(2) const formatNumber = it => new BigNumber(it).toFormat(2)
@ -202,7 +204,10 @@ const Funding = () => {
<Mono className={classes.address}> <Mono className={classes.address}>
<strong> <strong>
<CopyToClipboard buttonClassname={classes.copyToClipboard}> <CopyToClipboard buttonClassname={classes.copyToClipboard}>
{formatAddress(selected.fundingAddress)} {formatAddress(
selected.cryptoCode,
selected.fundingAddress
)}
</CopyToClipboard> </CopyToClipboard>
</strong> </strong>
</Mono> </Mono>

View file

@ -14,7 +14,7 @@ import { ReactComponent as CamIdIcon } from 'src/styling/icons/ID/photo/zodiac.s
import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
import { URI } from 'src/utils/apollo' import { URI } from 'src/utils/apollo'
import { toUnit } from 'src/utils/coin' import { toUnit, formatCryptoAddress } from 'src/utils/coin'
import { onlyFirstToUpper } from 'src/utils/string' import { onlyFirstToUpper } from 'src/utils/string'
import CopyToClipboard from './CopyToClipboard' import CopyToClipboard from './CopyToClipboard'
@ -22,7 +22,8 @@ import styles from './DetailsCard.styles'
const useStyles = makeStyles(styles) const useStyles = makeStyles(styles)
const formatAddress = (address = '') => address.replace(/(.{5})/g, '$1 ') const formatAddress = (cryptoCode = '', address = '') =>
formatCryptoAddress(cryptoCode, address).replace(/(.{5})/g, '$1 ')
const getCashOutStatus = it => { const getCashOutStatus = it => {
if (it.hasError) return 'Error' if (it.hasError) return 'Error'
@ -181,9 +182,11 @@ const DetailsRow = ({ it: tx }) => {
</div> </div>
<div className={classes.secondRow}> <div className={classes.secondRow}>
<div className={classes.address}> <div className={classes.address}>
<Label>BTC address</Label> <Label>Address</Label>
<div> <div>
<CopyToClipboard>{formatAddress(tx.toAddress)}</CopyToClipboard> <CopyToClipboard>
{formatAddress(tx.cryptoCode, tx.toAddress)}
</CopyToClipboard>
</div> </div>
</div> </div>
<div className={classes.transactionId}> <div className={classes.transactionId}>

View file

@ -11,7 +11,7 @@ import Title from 'src/components/Title'
import DataTable from 'src/components/tables/DataTable' import DataTable from 'src/components/tables/DataTable'
import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg' import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg' import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
import { toUnit } from 'src/utils/coin' import { toUnit, formatCryptoAddress } from 'src/utils/coin'
import DetailsRow from './DetailsCard' import DetailsRow from './DetailsCard'
import { mainStyles } from './Transactions.styles' import { mainStyles } from './Transactions.styles'
@ -111,7 +111,7 @@ const Transactions = () => {
}, },
{ {
header: 'Address', header: 'Address',
view: R.path(['toAddress']), view: it => formatCryptoAddress(it.cryptoCode, it.toAddress),
className: classes.overflowTd, className: classes.overflowTd,
size: 'sm', size: 'sm',
width: 140 width: 140

View file

@ -52,4 +52,8 @@ function toUnit(cryptoAtoms, cryptoCode) {
return cryptoAtoms.shiftedBy(-unitScale) return cryptoAtoms.shiftedBy(-unitScale)
} }
export { toUnit } function formatCryptoAddress(cryptoCode = '', address = '') {
return cryptoCode === 'BCH' ? address.replace('bitcoincash:', '') : address
}
export { toUnit, formatCryptoAddress }