Skip to content

Commit

Permalink
fix(current supply): use eosjs api
Browse files Browse the repository at this point in the history
  • Loading branch information
tetogomez committed Nov 3, 2020
1 parent 4081541 commit 7251b35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
11 changes: 4 additions & 7 deletions src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -387,11 +386,9 @@ const LiquidityBackLayer = ({
pair.balance ? pair.balance.toString() : 0
}`}
</Typography>
{ual.activeUser && (
<Typography variant="body1" className={classes.textInfo}>
{`${t('available')}: ${currentSupplyValue}`}
</Typography>
)}
<Typography variant="body1" className={classes.textInfo}>
{`${t('available')}: ${currentSupplyValue}`}
</Typography>
</>
)}
{error && (
Expand Down
9 changes: 9 additions & 0 deletions src/utils/eosapi.js
Original file line number Diff line number Diff line change
@@ -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
12 changes: 5 additions & 7 deletions src/utils/evolutiondex.js
Original file line number Diff line number Diff line change
@@ -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: [] }
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7251b35

Please sign in to comment.