fix(slp-mutable-data): Re-enabling token icons

This commit is contained in:
Chris Troutner
2022-02-19 12:17:03 -08:00
parent 47deccbf2e
commit f0d4bea76b
3 changed files with 596 additions and 1128 deletions
+533 -1065
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -56,7 +56,7 @@
"react-redux": "7.2.4",
"semver": "7.3.5",
"sharp": "0.29.3",
"slp-mutable-data": "1.2.2",
"slp-mutable-data": "1.4.2",
"stream-browserify": "3.0.0",
"stream-http": "3.2.0"
},
+62 -62
View File
@@ -6,7 +6,7 @@ import TokenModal from './token-modal'
import Spinner from '../../../images/loader.gif'
// import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import SendTokens from './send-tokens'
// import { SlpMutableData } from 'slp-mutable-data'
import { SlpMutableData } from 'slp-mutable-data'
let _this
class Tokens extends React.Component {
constructor (props) {
@@ -31,22 +31,22 @@ class Tokens extends React.Component {
return (
<>
<Button
text='Refresh'
icon='fa-redo'
type='primary'
className='btn-md ml-1 mt-1 mb-1'
text="Refresh"
icon="fa-redo"
type="primary"
className="btn-md ml-1 mt-1 mb-1"
onClick={() => _this.handleGetTokens(true)}
/>
{_this.state.txId && (
<div className='txIdContainer'>
<div className="txIdContainer">
<button onClick={() => _this.setState({ txId: null })}>
&times;
</button>
<Col xs={12} className='text-center mt-1'>
<Box title='Transaction ID' type='primary' className='p-0'>
<Col xs={12} className="text-center mt-1">
<Box title="Transaction ID" type="primary" className="p-0">
<a
target='_blank'
rel='noopener noreferrer'
target="_blank"
rel="noopener noreferrer"
href={`${_this.state.explorerURL}/${_this.state.txId}`}
>
{_this.state.txId}
@@ -71,46 +71,46 @@ class Tokens extends React.Component {
)}
{_this.state.inFetch
? (
<div className='spinner'>
<img alt='Loading...' src={Spinner} width={100} />
</div>
<div className="spinner">
<img alt="Loading..." src={Spinner} width={100} />
</div>
)
: (
<Content>
{_this.state.errMsg && (
<Box padding='true' className='container-nofound'>
<Row>
<Col xs={12}>
<em>{_this.state.errMsg}</em>
</Col>
</Row>
</Box>
)}
<Content>
{_this.state.errMsg && (
<Box padding="true" className="container-nofound">
<Row>
<Col xs={12}>
<em>{_this.state.errMsg}</em>
</Col>
</Row>
</Box>
)}
{_this.state.tokens.length > 0 && (
<>
<Row>
{_this.state.tokens.map((val, i) => {
if (val.qty > 0) {
return (
<Col sm={4} key={`token-${i}`}>
<TokenCard
key={`token-${i}`}
id={`token-${i}`}
token={val}
showToken={_this.showToken}
selectToken={_this.selectToken}
/>
</Col>
)
} else {
return <span key={`token-${i}`} />
}
})}
</Row>
</>
)}
</Content>
{_this.state.tokens.length > 0 && (
<>
<Row>
{_this.state.tokens.map((val, i) => {
if (val.qty > 0) {
return (
<Col sm={4} key={`token-${i}`}>
<TokenCard
key={`token-${i}`}
id={`token-${i}`}
token={val}
showToken={_this.showToken}
selectToken={_this.selectToken}
/>
</Col>
)
} else {
return <span key={`token-${i}`} />
}
})}
</Row>
</>
)}
</Content>
)}
<TokenModal
bchWallet={_this.props.bchWallet}
@@ -227,9 +227,9 @@ class Tokens extends React.Component {
Rate limits exceeded, increase rate limits with a JWT token from
<a
style={{ marginLeft: '5px' }}
target='_blank'
href='https://fullstack.cash'
rel='noopener noreferrer'
target="_blank"
href="https://fullstack.cash"
rel="noopener noreferrer"
>
FullStack.cash
</a>
@@ -271,21 +271,21 @@ class Tokens extends React.Component {
async handleMutableData (tokensArr) {
try {
const tokens = []
// const slpMutableLib = new SlpMutableData()
const slpMutableLib = new SlpMutableData()
for (let i = 0; i < tokensArr.length; i++) {
const token = tokensArr[i]
// try {
// const data = await slpMutableLib.get.mutableData(token.tokenId)
// token.mutableData = data
// // console.log(`data: ${JSON.stringify(data, null, 2)}`)
// } catch (error) {
// // console.warn(error)
// // Skip error
// console.log(
// `Could not access mutable data for ${token.ticker} (${token.tokenId})`
// )
// }
try {
const data = await slpMutableLib.get.mutableData(token.tokenId)
token.mutableData = data
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
} catch (error) {
// console.warn(error)
// Skip error
console.log(
`Could not access mutable data for ${token.ticker} (${token.tokenId})`
)
}
tokens.push(token)
}