feat: shorten long addresses in funding page
This commit is contained in:
parent
4092025b72
commit
b3427fec74
2 changed files with 10 additions and 8 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import { useQuery, gql } from '@apollo/client'
|
import { useQuery, gql } from '@apollo/client'
|
||||||
import { formatCryptoAddress } from '@lamassu/coins/lightUtils'
|
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import { format } from 'date-fns/fp'
|
import { format } from 'date-fns/fp'
|
||||||
|
|
@ -25,6 +24,7 @@ import {
|
||||||
Label3,
|
Label3,
|
||||||
} from '../../components/typography/index.jsx'
|
} from '../../components/typography/index.jsx'
|
||||||
import CopyToClipboard from '../../components/CopyToClipboard.jsx'
|
import CopyToClipboard from '../../components/CopyToClipboard.jsx'
|
||||||
|
import { formatAddress } from '../../utils/string'
|
||||||
|
|
||||||
import { primaryColor } from '../../styling/variables.js'
|
import { primaryColor } from '../../styling/variables.js'
|
||||||
|
|
||||||
|
|
@ -57,8 +57,6 @@ const GET_FUNDING = gql`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
@ -149,6 +147,10 @@ const Funding = () => {
|
||||||
const pendingTotal = getPendingTotal(funding)
|
const pendingTotal = getPendingTotal(funding)
|
||||||
const signIfPositive = num => (num >= 0 ? '+' : '')
|
const signIfPositive = num => (num >= 0 ? '+' : '')
|
||||||
|
|
||||||
|
const { address, addressDisplay } = formatAddress(
|
||||||
|
selected?.cryptoCode,
|
||||||
|
selected?.fundingAddress,
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -223,11 +225,9 @@ const Funding = () => {
|
||||||
<strong>
|
<strong>
|
||||||
<CopyToClipboard
|
<CopyToClipboard
|
||||||
buttonClassname={classes.copyToClipboard}
|
buttonClassname={classes.copyToClipboard}
|
||||||
key={selected.cryptoCode}>
|
key={selected.cryptoCode}
|
||||||
{formatAddress(
|
value={address}>
|
||||||
selected.cryptoCode,
|
{addressDisplay}
|
||||||
selected.fundingAddress,
|
|
||||||
)}
|
|
||||||
</CopyToClipboard>
|
</CopyToClipboard>
|
||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ const shortenByEllipses = (str, contextLength, ellipsesLength) =>
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const formatAddress = (cryptoCode, address) => {
|
const formatAddress = (cryptoCode, address) => {
|
||||||
|
if (!cryptoCode || !address) return { address: null, addressDisplay: null }
|
||||||
|
|
||||||
address = formatCryptoAddress(cryptoCode, address)
|
address = formatCryptoAddress(cryptoCode, address)
|
||||||
let addressDisplay =
|
let addressDisplay =
|
||||||
address.length > 84 /* 2*BTC */
|
address.length > 84 /* 2*BTC */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue