Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Nov 5, 2020
2 parents c6ea745 + 4268a81 commit 1f421ff
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/language/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"tableLabelCommunity": "Community Pools",
"inputLabel": "Add / Remove",
"available": "Current supply",
"balance": "Your balance",
"add": "Add",
"remove": "Remove",
"and": "and",
Expand Down
1 change: 1 addition & 0 deletions src/language/es/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"tableLabelCommunity": "Pooles comunitarios",
"inputLabel": "Aportar / Retirar",
"available": "Cantidad circulante",
"balance": "Tu Saldo",
"add": "Agregar",
"remove": "Retirar",
"and": "y",
Expand Down
1 change: 1 addition & 0 deletions src/language/ru/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"tableLabelCommunity": "Общественные пулы",
"inputLabel": "Добавить / Удалить",
"available": "Текущая поставка",
"balance": "баланс",
"add": "Добавить",
"remove": "Удалить",
"and": "и",
Expand Down
1 change: 1 addition & 0 deletions src/language/zh/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"tableLabelCommunity": "社区的流动性池",
"inputLabel": "添加 / 移除",
"available": "可用",
"balance": "平衡",
"add": "添加",
"remove": "移除",
"and": "",
Expand Down
38 changes: 26 additions & 12 deletions src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'
import React, { useState, useEffect, useCallback } from 'react'
import PropTypes from 'prop-types'
import clsx from 'clsx'
import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -118,6 +118,7 @@ const useStyles = makeStyles((theme) => {
}
},
[theme.breakpoints.up('sm')]: {
paddingTop: theme.spacing(2),
flexDirection: 'row',
'& button': {
marginRight: theme.spacing(2),
Expand All @@ -128,11 +129,9 @@ const useStyles = makeStyles((theme) => {
inputBox: {
...inputBox,
[theme.breakpoints.up('md')]: {
width: 800
},
[theme.breakpoints.up('lg')]: {
marginTop: theme.spacing(0),
paddingBottom: theme.spacing(1)
width: 800,
paddingBottom: theme.spacing(0),
marginTop: theme.spacing(0)
}
},
contentWrapper: {
Expand Down Expand Up @@ -194,6 +193,7 @@ const LiquidityBackLayer = ({
const [isTourOpen, setIsTourOpen] = useState(false)
const [youGive, setYouGive] = useState({})
const [loading, setLoading] = useState(false)
const [currentSupplyValue, setCurrentSupplyValue] = useState('0')
const [error, setError] = useState('')
const validInput = RegExp('^([0-9]+([.][0-9]*)?|[.][0-9]+)$')

Expand Down Expand Up @@ -313,9 +313,18 @@ const LiquidityBackLayer = ({
setLoading(false)
}

const getCurrentSupply = useCallback(async () => {
const currentSupply = await evolutiondex.getCurrentSupply(
youGive.selectValue
)

setCurrentSupplyValue(currentSupply)
}, [youGive.selectValue])

useEffect(() => {
getCurrentSupply()
setPair(pairs.find((pair) => pair.token === youGive.selectValue))
}, [pairs, youGive.selectValue])
}, [pairs, youGive.selectValue, getCurrentSupply])

useEffect(() => {
setError('')
Expand Down Expand Up @@ -371,11 +380,16 @@ const LiquidityBackLayer = ({
helperText={
<>
{pair && (
<Typography variant="body1" className={classes.textInfo}>
{`${t('available')} ${
pair.balance ? pair.balance.toString() : 0
}`}
</Typography>
<>
<Typography variant="body1" className={classes.textInfo}>
{`${t('balance')}: ${
pair.balance ? pair.balance.toString() : 0
}`}
</Typography>
<Typography variant="body1" className={classes.textInfo}>
{`${t('available')}: ${currentSupplyValue}`}
</Typography>
</>
)}
{error && (
<Typography variant="body1" className={classes.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
25 changes: 22 additions & 3 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,6 +620,24 @@ const voteFee = async (amount, pair, ual) => {
}
}

const getCurrentSupply = async (pool) => {
if (!pool) {
return
}

const { rows } = await eosApi.getTableRows({
json: true,
code: 'evolutiondex',
scope: pool,
table: 'stat',
limit: 1,
reverse: false,
show_payer: false
})

return rows.length ? rows[0].supply : `0 ${pool}`
}

export const evolutiondex = {
getInfo,
getTokensFor,
Expand All @@ -633,5 +651,6 @@ export const evolutiondex = {
addLiquidity,
getRemoveLiquidityAssets,
removeLiquidity,
voteFee
voteFee,
getCurrentSupply
}

0 comments on commit 1f421ff

Please sign in to comment.