Skip to content

Commit

Permalink
Merge branch 'dev' into lacchain
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier506 committed Apr 22, 2021
2 parents 6114c87 + 4494250 commit 66f4cff
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 49 deletions.
28 changes: 13 additions & 15 deletions .env.telostestnet
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ HASURA_GRAPHQL_UNAUTHORIZED_ROLE=guest
HASURA_GRAPHQL_ACTION_BASE_URL=http://hapi:9090

# hapi
HAPI_EOS_API_ENDPOINT=https://telos-testnet.eosio.cr
HAPI_EOS_API_CHAIN_ID=1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f
HAPI_EOS_BASE_ACCOUNT=eosmechatero
HAPI_EOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_EOS_MECHANICS_ACCOUNT=eosmechatero
HAPI_TELOS_API_ENDPOINT=https://telos-testnet.eosio.cr
HAPI_TELOS_API_CHAIN_ID=2a02a0053e5a8cf73a56ba0fda11e4d92e0238a4a2aa74fccf46d5a910746840
HAPI_TELOS_BASE_ACCOUNT=eosmechatero
HAPI_TELOS_BASE_ACCOUNT_PASSWORD=PW...
HAPI_TELOS_MECHANICS_ACCOUNT=eosmechatero
# TODO: add value
HAPI_EOS_MECHANICS_PASSWORD=PW...
HAPI_EOS_WALLET_URL=http://localhost:9999
HAPI_TELOS_MECHANICS_PASSWORD=PW...
HAPI_TELOS_WALLET_URL=http://localhost:9999
# TODO: let's discuss this
HAPI_EOS_EXCHANGE_RATE_API=https://api.coingecko.com/api/v3/simple/price?ids=telos&vs_currencies=usd
HAPI_EOS_BP_JSON_ON_CHAIN=false
HAPI_EOS_BP_JSON_ON_CHAIN_CONTRACT=producerjson
HAPI_EOS_BP_JSON_ON_CHAIN_TABLE=producerjson
HAPI_EOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
HAPI_TELOS_EXCHANGE_RATE_API=https://api.coingecko.com/api/v3/simple/price?ids=telos&vs_currencies=usd
HAPI_TELOS_BP_JSON_ON_CHAIN=false
HAPI_TELOS_BP_JSON_ON_CHAIN_CONTRACT=producerjson
HAPI_TELOS_BP_JSON_ON_CHAIN_TABLE=producerjson
HAPI_TELOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
HAPI_HASURA_URL=http://hasura:8080/v1/graphql
HAPI_HASURA_ADMIN_SECRET=myadminsecretkey
HAPI_SERVER_PORT=9090
Expand All @@ -41,7 +41,6 @@ HAPI_SYNC_PRODUCERS_INTERVAL=86400
HAPI_SYNC_PRODUCER_INFO_INTERVAL=1
HAPI_SYNC_PRODUCER_CPU_INTERVAL=6
HAPI_SYNC_EXCHANGE_RATE=86400
HAPI_COINGECKO_API_TOKEN_ID=telos
HAPI_SYNC_STATS_INTERVAL=60

#webapp
Expand Down Expand Up @@ -69,5 +68,4 @@ REACT_APP_EOS_CHAIN_ID=1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f319
REACT_APP_EOS_USE_BP_JSON_ON_CHAIN=false
REACT_APP_EOS_BP_JSON_ON_CHAIN_CONTRACT=producerjson
REACT_APP_EOS_BP_JSON_ON_CHAIN_TABLE=producerjson
REACT_APP_EOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
REACT_APP_TOKEN_SYMBOL=TLOS
REACT_APP_EOS_BP_JSON_ON_CHAIN_SCOPE=producerjson
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ services:
HAPI_SYNC_PRODUCERS_INTERVAL: '${HAPI_SYNC_PRODUCERS_INTERVAL}'
HAPI_SYNC_PRODUCER_INFO_INTERVAL: '${HAPI_SYNC_PRODUCER_INFO_INTERVAL}'
HAPI_SYNC_PRODUCER_CPU_INTERVAL: '${HAPI_SYNC_PRODUCER_CPU_INTERVAL}'
HAPI_COINGECKO_API_TOKEN_ID: '${HAPI_COINGECKO_API_TOKEN_ID}'
HAPI_SYNC_STATS_INTERVAL: '${HAPI_SYNC_STATS_INTERVAL}'
hasura:
container_name: '${STAGE}-${APP_NAME}-hasura'
Expand Down Expand Up @@ -103,4 +102,3 @@ services:
REACT_APP_EOS_BP_JSON_ON_CHAIN_CONTRACT: '${REACT_APP_EOS_BP_JSON_ON_CHAIN_CONTRACT}'
REACT_APP_EOS_BP_JSON_ON_CHAIN_TABLE: '${REACT_APP_EOS_BP_JSON_ON_CHAIN_TABLE}'
REACT_APP_EOS_BP_JSON_ON_CHAIN_SCOPE: '${REACT_APP_EOS_BP_JSON_ON_CHAIN_SCOPE}'
REACT_APP_TOKEN_SYMBOL: '${REACT_APP_TOKEN_SYMBOL}'
1 change: 0 additions & 1 deletion hapi/src/config/eos.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module.exports = {
},
walletUrl: process.env.HAPI_EOS_WALLET_URL,
exchangeRateApi: process.env.HAPI_EOS_EXCHANGE_RATE_API,
coingeckoApiTokenId: process.env.HAPI_COINGECKO_API_TOKEN_ID,
bpJsonOnChain: process.env.HAPI_EOS_BP_JSON_ON_CHAIN === 'true',
bpJsonOnChainContract: process.env.HAPI_EOS_BP_JSON_ON_CHAIN_CONTRACT,
bpJsonOnChainTable: process.env.HAPI_EOS_BP_JSON_ON_CHAIN_TABLE,
Expand Down
6 changes: 3 additions & 3 deletions hapi/src/services/setting.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { hasuraUtil, axiosUtil } = require('../utils')

const UPSERT = `
mutation ($setting: setting_insert_input!) {
insert_setting(objects: [$setting], on_conflict: {constraint: setting_pkey, update_columns: [token_price]}) {
insert_setting(objects: [$setting], on_conflict: {constraint: setting_pkey, update_columns: [eos_price]}) {
affected_rows
}
}
Expand All @@ -18,12 +18,12 @@ const syncEOSPrice = async () => {

const { data } = await axiosUtil.instance.get(eosConfig.exchangeRateApi)

if (!data) {
if (!data || !data.success) {
return
}

await hasuraUtil.request(UPSERT, {
setting: { id: 1, token_price: data[eosConfig.coingeckoApiTokenId].usd }
setting: { id: 1, eos_price: data.rates.EOS }
})
} catch (error) {
console.error(error)
Expand Down
9 changes: 1 addition & 8 deletions hasura/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,4 @@
name: setting
- table:
schema: public
name: setting
select_permissions:
- role: guest
permission:
columns:
- id
- token_price
filter: {}
name: stat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE TABLE "public"."setting"("id" serial NOT NULL, "token_price" numeric NOT NULL, PRIMARY KEY ("id") );
CREATE TABLE "public"."setting"("id" serial NOT NULL, "eos_price" numeric NOT NULL, PRIMARY KEY ("id") );

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion webapp/src/config/eos.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const bpJsonOnChainScope =
export const networkName = process.env.REACT_APP_EOS_API_NETWORK_NAME
export const networkLabel = process.env.REACT_APP_EOS_API_NETWORK_LABEL
export const networkLogo = process.env.REACT_APP_EOS_API_NETWORK_LOGO
export const tokenSymbol = process.env.REACT_APP_TOKEN_SYMBOL

let _nodeTypes = null

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/gql/setting.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const SETTING_QUERY = gql`
query setting {
setting: setting_by_pk(id: 1) {
id
token_price
eos_price
}
}
`
25 changes: 10 additions & 15 deletions webapp/src/routes/RewardsDistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { countries } from '../utils/countries'
import { PRODUCERS_QUERY, SETTING_QUERY } from '../gql'
import CountryFlag from '../components/CountryFlag'
import Tooltip from '../components/Tooltip'
import { eosConfig } from '../config'

const lowestRewardsColor = '#B6EBF3'
const highestRewardsColor = '#265F63'
Expand Down Expand Up @@ -237,8 +236,7 @@ const RewardsDistribution = () => {
<Typography>
<span className={classes.popoverItem}>{t('rewards')}: </span>
<span>
{formatWithThousandSeparator(currentNode?.rewards, 2)}{' '}
{eosConfig.tokenSymbol}
{formatWithThousandSeparator(currentNode?.rewards, 2)} EOS
</span>
</Typography>
<Typography className={classes.popoverItem}>
Expand All @@ -257,8 +255,7 @@ const RewardsDistribution = () => {
{producer?.bp_json?.org?.candidate_name || producer.owner}
</Link>
<br />
{formatWithThousandSeparator(producer.total_rewards, 2)}{' '}
{eosConfig.tokenSymbol}
{formatWithThousandSeparator(producer.total_rewards, 2)} EOS
</li>
))}
</ul>
Expand All @@ -276,20 +273,19 @@ const RewardsDistribution = () => {
)}
{nodes.length > 0 && (
<span>
{formatWithThousandSeparator(summary.daylyRewars, 2)}{' '}
{eosConfig.tokenSymbol}
{formatWithThousandSeparator(summary.daylyRewars, 2)} EOS
</span>
)}
</Typography>
<Typography variant="subtitle1">
{!nodes.length > 0 && (
<Skeleton variant="text" width="100%" animation="wave" />
)}
{nodes.length > 0 && setting?.token_price && (
{nodes.length > 0 && setting?.eos_price && (
<span>
$
{formatWithThousandSeparator(
summary.daylyRewars * setting?.token_price,
summary.daylyRewars * setting?.eos_price,
0
)}{' '}
USD
Expand Down Expand Up @@ -321,16 +317,15 @@ const RewardsDistribution = () => {
{!nodes.length > 0 && (
<Skeleton variant="text" width="100%" animation="wave" />
)}
{nodes.length > 0 && setting?.token_price && (
{nodes.length > 0 && setting?.eos_price && (
<>
{formatWithThousandSeparator(
summary.topCountryByRewards.rewards,
0
)}{' '}
{eosConfig.tokenSymbol} / $
EOS / $
{formatWithThousandSeparator(
summary.topCountryByRewards.rewards *
setting?.token_price,
summary.topCountryByRewards.rewards * setting?.eos_price,
0
)}{' '}
USD
Expand Down Expand Up @@ -384,12 +379,12 @@ const RewardsDistribution = () => {
</span>
<span className={classes.highestRewards} />
</Typography>
{setting?.token_price && (
{setting?.eos_price && (
<Typography variant="h6" className={classes.rewardsColorSchema}>
<span className={classes.itemLabel}>
{t('exchangeRate')}:{' '}
</span>{' '}
${formatWithThousandSeparator(setting.token_price, 2)}
${formatWithThousandSeparator(setting.eos_price, 2)}
</Typography>
)}
</CardContent>
Expand Down

0 comments on commit 66f4cff

Please sign in to comment.