From 4081541fc7b608a9ac2b89f6fb7a1003ce675d23 Mon Sep 17 00:00:00 2001 From: Teto Gomez Date: Tue, 3 Nov 2020 08:53:05 -0600 Subject: [PATCH 1/2] fix(liquidity): hide or show current supply --- .../Evodex/BackLayer/Liquidity/LiquidityBackLayer.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js index 5193015..1c165d3 100644 --- a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js +++ b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js @@ -387,9 +387,11 @@ const LiquidityBackLayer = ({ pair.balance ? pair.balance.toString() : 0 }`} - - {`${t('available')}: ${currentSupplyValue}`} - + {ual.activeUser && ( + + {`${t('available')}: ${currentSupplyValue}`} + + )} )} {error && ( From 7251b351e9c20afe727722753f7d82f84806191d Mon Sep 17 00:00:00 2001 From: Teto Gomez Date: Tue, 3 Nov 2020 14:00:34 -0600 Subject: [PATCH 2/2] fix(current supply): use eosjs api --- .../Evodex/BackLayer/Liquidity/LiquidityBackLayer.js | 11 ++++------- src/utils/eosapi.js | 9 +++++++++ src/utils/evolutiondex.js | 12 +++++------- 3 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 src/utils/eosapi.js diff --git a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js index 1c165d3..48ec583 100644 --- a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js +++ b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js @@ -315,12 +315,11 @@ const LiquidityBackLayer = ({ const getCurrentSupply = useCallback(async () => { const currentSupply = await evolutiondex.getCurrentSupply( - ual, youGive.selectValue ) setCurrentSupplyValue(currentSupply) - }, [ual, youGive.selectValue]) + }, [youGive.selectValue]) useEffect(() => { getCurrentSupply() @@ -387,11 +386,9 @@ const LiquidityBackLayer = ({ pair.balance ? pair.balance.toString() : 0 }`} - {ual.activeUser && ( - - {`${t('available')}: ${currentSupplyValue}`} - - )} + + {`${t('available')}: ${currentSupplyValue}`} + )} {error && ( diff --git a/src/utils/eosapi.js b/src/utils/eosapi.js new file mode 100644 index 0000000..87836d3 --- /dev/null +++ b/src/utils/eosapi.js @@ -0,0 +1,9 @@ +import EosApi from 'eosjs-api' + +const eosApi = EosApi({ + httpEndpoint: `${process.env.REACT_APP_EOS_API_PROTOCOL}://${process.env.REACT_APP_EOS_API_HOST}:${process.env.REACT_APP_EOS_API_PORT}`, + verbose: false, + fetchConfiguration: {} +}) + +export default eosApi diff --git a/src/utils/evolutiondex.js b/src/utils/evolutiondex.js index 063cb3d..98d247b 100644 --- a/src/utils/evolutiondex.js +++ b/src/utils/evolutiondex.js @@ -1,11 +1,11 @@ import * as eosCommon from 'eos-common' +import { JsonRpc } from 'eosjs' import { evodexConfig } from '../config' import { getScatterError } from './getScatterError' import axiosUtil from './axios.util' - -import { JsonRpc } from 'eosjs' +import eosApi from './eosapi' const { asset, number_to_asset: numberToAsset } = eosCommon const defaultState = { pairs: [], tokens: [] } @@ -620,14 +620,12 @@ const voteFee = async (amount, pair, ual) => { } } -const getCurrentSupply = async (ual, pool) => { - if (!ual.activeUser || !pool) { +const getCurrentSupply = async (pool) => { + if (!pool) { return } - const rpc = getRpc(ual) - - const { rows } = await rpc.get_table_rows({ + const { rows } = await eosApi.getTableRows({ json: true, code: 'evolutiondex', scope: pool,