Skip to content

Commit

Permalink
Ana/emoney upgrade (mergeable) (#282)
Browse files Browse the repository at this point in the history
* update emoney api_url

* fix denom. add default fiat currency

* fix rpc endpoint
  • Loading branch information
Bitcoinera authored Feb 3, 2020
1 parent 669216a commit f48f95b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions data/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lib/reducers/emoneyV0-reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions lib/source/emoneyV0-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f48f95b

Please sign in to comment.