Changeset View
Changeset View
Standalone View
Standalone View
cashtab/src/components/Etokens/TokenList.js
// Copyright (c) 2024 The Bitcoin developers | // Copyright (c) 2024 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
import React from 'react'; | import React from 'react'; | ||||
import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||
import TokenListItem from './TokenListItem'; | import TokenListItem from './TokenListItem'; | ||||
import { Link } from 'react-router-dom'; | import { Link } from 'react-router-dom'; | ||||
import { formatTokenBalance } from 'utils/formatting'; | import { decimalizedTokenQtyToLocaleFormat } from 'utils/formatting'; | ||||
import { BN } from 'slp-mdm'; | |||||
const TokenList = ({ tokens }) => { | const TokenList = ({ tokens, tokenCache, userLocale }) => { | ||||
return ( | return Array.from(tokens).map(keyValueArray => ( | ||||
<div> | <Link key={keyValueArray[0]} to={`/send-token/${keyValueArray[0]}`}> | ||||
{tokens.map(token => ( | |||||
<Link key={token.tokenId} to={`/send-token/${token.tokenId}`}> | |||||
<TokenListItem | <TokenListItem | ||||
ticker={token.info.tokenTicker} | tokenId={keyValueArray[0]} | ||||
tokenId={token.tokenId} | balance={decimalizedTokenQtyToLocaleFormat( | ||||
balance={formatTokenBalance( | keyValueArray[1], | ||||
new BN(token.balance), | userLocale, | ||||
token.info.decimals, | |||||
)} | )} | ||||
cachedTokenInfo={tokenCache.get(keyValueArray[0])} | |||||
/> | /> | ||||
</Link> | </Link> | ||||
))} | )); | ||||
</div> | |||||
); | |||||
}; | }; | ||||
TokenList.propTypes = { | TokenList.propTypes = { | ||||
tokens: PropTypes.array, | tokens: PropTypes.instanceOf(Map), | ||||
tokenCache: PropTypes.instanceOf(Map), | |||||
userLocale: PropTypes.string, | |||||
}; | }; | ||||
export default TokenList; | export default TokenList; |