From f48f95be7e64205737ee6fa59d7b0646e60c05ea Mon Sep 17 00:00:00 2001 From: Ana G <40721795+Bitcoinera@users.noreply.github.com> Date: Mon, 3 Feb 2020 18:55:13 +0100 Subject: [PATCH] Ana/emoney upgrade (mergeable) (#282) * update emoney api_url * fix denom. add default fiat currency * fix rpc endpoint --- data/networks.json | 4 ++-- lib/reducers/emoneyV0-reducers.js | 4 ++-- lib/source/emoneyV0-source.js | 13 +++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/data/networks.json b/data/networks.json index a2d5b35864..984b6b9567 100644 --- a/data/networks.json +++ b/data/networks.json @@ -135,8 +135,8 @@ "id": "emoney-testnet", "title": "e-Money Testnet", "chain_id": "lilmermaid-4", - "api_url": "https://emoney-lilmermaid-4.lunie.io", - "rpc_url": "wss://emoney-lilmermaid-4.lunie.io/websocket", + "api_url": "http://lilmermaid.validator.network/light", + "rpc_url": "wss://lilmermaid.validator.network/websocket", "bech32_prefix": "emoney", "address_prefix": "emoney", "address_creator": "cosmos", diff --git a/lib/reducers/emoneyV0-reducers.js b/lib/reducers/emoneyV0-reducers.js index 41e4f53802..2cdd0f1faa 100644 --- a/lib/reducers/emoneyV0-reducers.js +++ b/lib/reducers/emoneyV0-reducers.js @@ -8,8 +8,8 @@ const Sentry = require('@sentry/node') async function totalBackedValueReducer(totalBackedValue) { const exchangeRates = await fetchTokenExchangeRates() - const token = `e`.concat(totalBackedValue.denom.substring(2)) - const ticker = totalBackedValue.denom.substring(2).toUpperCase() + const token = `e`.concat(totalBackedValue.denom.substring(1)) + const ticker = totalBackedValue.denom.substring(1).toUpperCase() // First we calculate the fiat net value of the token's total supply in it counterpart // fiat currency // TODO Not all the tokens have yet their rate value in the e-Money API. So the calculation diff --git a/lib/source/emoneyV0-source.js b/lib/source/emoneyV0-source.js index 31ad817a26..b31e7e2981 100644 --- a/lib/source/emoneyV0-source.js +++ b/lib/source/emoneyV0-source.js @@ -2,7 +2,6 @@ const TerraV3API = require('./terraV3-source') const BigNumber = require('bignumber.js') const fetch = require('node-fetch') const apiURL = `https://api.exchangeratesapi.io/latest?` -const { UserInputError } = require('apollo-server') class EMoneyV0API extends TerraV3API { setReducers() { @@ -47,18 +46,16 @@ class EMoneyV0API extends TerraV3API { // Currently this function only works for e-Money and is very e-Money centered. // But soon will also be enabled for other similar multiple-tokens networks like Terra. - async calculateFiatValue(balance, selectedFiatCurrency) { - if (!selectedFiatCurrency) { - throw new UserInputError( - `No fiatCurrency selected. Please, enter the fiat currency you'd like the fiat value to be displayed in` - ) - } + + // We just default to EUR if there is no fiat currency included in the query + // This is because the standard price for NGM tokens given by e-Money team is 0.50€ + async calculateFiatValue(balance, selectedFiatCurrency = `EUR`) { // When e-Money goes live they will count with a trading platform where the value // for the different backed tokens will be changing slightly. // They will provide with an API for us to query these values. // For now we will assume a 1:1 ratio and treat each token like it were the real // fiat currency it represents. - const denom = balance.denom.substring(2).toUpperCase() + const denom = balance.denom.substring(1).toUpperCase() // To handle the NGM balance, first we convert to EUR value and then to the selected // fiat currency value