Skip to content

Commit

Permalink
NFT - Fix sell assets
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Nov 10, 2023
1 parent 91127d0 commit 5c8163c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions app/components/modules/nft/NFTTokenSell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tt from 'counterpart'
import { connect, } from 'react-redux'
import CloseButton from 'react-foundation-components/lib/global/close-button'
import { Formik, Form, Field, ErrorMessage, } from 'formik'
import { api } from 'golos-lib-js'
import { Asset, AssetEditor } from 'golos-lib-js/lib/utils'

import AmountField from 'app/components/elements/forms/AmountField'
Expand All @@ -19,6 +20,20 @@ class NFTTokenSell extends Component {
}
}

async componentDidMount() {
try {
const assets = await api.getAssetsAsync('', [], '', 5000, 'by_symbol_name')
for (const asset of assets) {
asset.supply = Asset(asset.supply)
}
this.setState({
assets
})
} catch (err) {
console.error(err)
}
}

validate = (values) => {
const errors = {}
const { price } = values
Expand Down Expand Up @@ -99,7 +114,7 @@ class NFTTokenSell extends Component {
}

render() {
if (this.doNotRender) {
if (this.doNotRender || !this.state.assets) {
return <LoadingIndicator type='circle' />
}

Expand All @@ -120,9 +135,10 @@ class NFTTokenSell extends Component {
const assets = {}
assets['GOLOS'] = { supply: Asset(0, 3, 'GOLOS') }
assets['GBG'] = { supply: Asset(0, 3, 'GBG') }
for (const asset of this.props.assets) {
asset.supply = asset.supply.symbol ? asset.supply : Asset(asset.supply)
assets[asset.supply.symbol] = asset
for (const asset of this.state.assets) {
const sym = asset.supply.symbol
if ($STM_Config.hidden_assets && $STM_Config.hidden_assets[sym]) continue
assets[sym] = asset
}

return <div className='NFTTokenSell'>
Expand Down Expand Up @@ -186,7 +202,6 @@ export default connect(
(state, ownProps) => {
return { ...ownProps,
nft_tokens: state.global.get('nft_tokens'),
assets: state.global.get('assets')
}
},

Expand Down

0 comments on commit 5c8163c

Please sign in to comment.