From 5c8163c375a8b03a4ce2c13883a15663e1b1d8e8 Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Fri, 10 Nov 2023 07:25:36 +0000 Subject: [PATCH] NFT - Fix sell assets --- app/components/modules/nft/NFTTokenSell.jsx | 25 ++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/components/modules/nft/NFTTokenSell.jsx b/app/components/modules/nft/NFTTokenSell.jsx index 9fd9e6b..e056670 100644 --- a/app/components/modules/nft/NFTTokenSell.jsx +++ b/app/components/modules/nft/NFTTokenSell.jsx @@ -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' @@ -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 @@ -99,7 +114,7 @@ class NFTTokenSell extends Component { } render() { - if (this.doNotRender) { + if (this.doNotRender || !this.state.assets) { return } @@ -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
@@ -186,7 +202,6 @@ export default connect( (state, ownProps) => { return { ...ownProps, nft_tokens: state.global.get('nft_tokens'), - assets: state.global.get('assets') } },