diff --git a/packages/admin-ui/src/pages/Funding/Funding.jsx b/packages/admin-ui/src/pages/Funding/Funding.jsx index 772c9d97..93b71810 100644 --- a/packages/admin-ui/src/pages/Funding/Funding.jsx +++ b/packages/admin-ui/src/pages/Funding/Funding.jsx @@ -1,5 +1,4 @@ import { useQuery, gql } from '@apollo/client' -import { formatCryptoAddress } from '@lamassu/coins/lightUtils' import BigNumber from 'bignumber.js' import classnames from 'classnames' import { format } from 'date-fns/fp' @@ -25,6 +24,7 @@ import { Label3, } from '../../components/typography/index.jsx' import CopyToClipboard from '../../components/CopyToClipboard.jsx' +import { formatAddress } from '../../utils/string' 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 formatNumber = it => new BigNumber(it).toFormat(2) @@ -149,6 +147,10 @@ const Funding = () => { const pendingTotal = getPendingTotal(funding) const signIfPositive = num => (num >= 0 ? '+' : '') + const { address, addressDisplay } = formatAddress( + selected?.cryptoCode, + selected?.fundingAddress, + ) return ( <>
@@ -223,11 +225,9 @@ const Funding = () => { - {formatAddress( - selected.cryptoCode, - selected.fundingAddress, - )} + key={selected.cryptoCode} + value={address}> + {addressDisplay}
diff --git a/packages/admin-ui/src/utils/string.js b/packages/admin-ui/src/utils/string.js index 6f35707c..f46b5191 100644 --- a/packages/admin-ui/src/utils/string.js +++ b/packages/admin-ui/src/utils/string.js @@ -11,6 +11,8 @@ const shortenByEllipses = (str, contextLength, ellipsesLength) => ].join('') const formatAddress = (cryptoCode, address) => { + if (!cryptoCode || !address) return { address: null, addressDisplay: null } + address = formatCryptoAddress(cryptoCode, address) let addressDisplay = address.length > 84 /* 2*BTC */