mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-12 18:51:21 +01:00
REF: wzirx to coinpaprika for INR
This commit is contained in:
parent
30575b99d7
commit
a59a5a7b1a
7 changed files with 38 additions and 32 deletions
10
Gemfile.lock
10
Gemfile.lock
|
@ -23,7 +23,7 @@ GEM
|
||||||
artifactory (3.0.17)
|
artifactory (3.0.17)
|
||||||
atomos (0.1.3)
|
atomos (0.1.3)
|
||||||
aws-eventstream (1.3.0)
|
aws-eventstream (1.3.0)
|
||||||
aws-partitions (1.961.0)
|
aws-partitions (1.962.0)
|
||||||
aws-sdk-core (3.201.3)
|
aws-sdk-core (3.201.3)
|
||||||
aws-eventstream (~> 1, >= 1.3.0)
|
aws-eventstream (~> 1, >= 1.3.0)
|
||||||
aws-partitions (~> 1, >= 1.651.0)
|
aws-partitions (~> 1, >= 1.651.0)
|
||||||
|
@ -186,7 +186,7 @@ GEM
|
||||||
google-apis-core (>= 0.11.0, < 2.a)
|
google-apis-core (>= 0.11.0, < 2.a)
|
||||||
google-apis-storage_v1 (0.31.0)
|
google-apis-storage_v1 (0.31.0)
|
||||||
google-apis-core (>= 0.11.0, < 2.a)
|
google-apis-core (>= 0.11.0, < 2.a)
|
||||||
google-cloud-core (1.7.0)
|
google-cloud-core (1.7.1)
|
||||||
google-cloud-env (>= 1.0, < 3.a)
|
google-cloud-env (>= 1.0, < 3.a)
|
||||||
google-cloud-errors (~> 1.0)
|
google-cloud-errors (~> 1.0)
|
||||||
google-cloud-env (1.6.0)
|
google-cloud-env (1.6.0)
|
||||||
|
@ -238,7 +238,7 @@ GEM
|
||||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||||
uber (< 0.2.0)
|
uber (< 0.2.0)
|
||||||
retriable (3.1.2)
|
retriable (3.1.2)
|
||||||
rexml (3.2.9)
|
rexml (3.3.4)
|
||||||
strscan
|
strscan
|
||||||
rouge (2.0.7)
|
rouge (2.0.7)
|
||||||
ruby-macho (2.5.1)
|
ruby-macho (2.5.1)
|
||||||
|
@ -269,13 +269,13 @@ GEM
|
||||||
uber (0.1.0)
|
uber (0.1.0)
|
||||||
unicode-display_width (2.5.0)
|
unicode-display_width (2.5.0)
|
||||||
word_wrap (1.0.0)
|
word_wrap (1.0.0)
|
||||||
xcodeproj (1.24.0)
|
xcodeproj (1.25.0)
|
||||||
CFPropertyList (>= 2.3.3, < 4.0)
|
CFPropertyList (>= 2.3.3, < 4.0)
|
||||||
atomos (~> 0.1.3)
|
atomos (~> 0.1.3)
|
||||||
claide (>= 1.0.2, < 2.0)
|
claide (>= 1.0.2, < 2.0)
|
||||||
colored2 (~> 3.1)
|
colored2 (~> 3.1)
|
||||||
nanaimo (~> 0.3.0)
|
nanaimo (~> 0.3.0)
|
||||||
rexml (~> 3.2.4)
|
rexml (>= 3.3.2, < 4.0)
|
||||||
xcpretty (0.3.0)
|
xcpretty (0.3.0)
|
||||||
rouge (~> 2.0.7)
|
rouge (~> 2.0.7)
|
||||||
xcpretty-travis-formatter (1.0.1)
|
xcpretty-travis-formatter (1.0.1)
|
||||||
|
|
|
@ -149,7 +149,7 @@
|
||||||
"INR": {
|
"INR": {
|
||||||
"endPointKey": "INR",
|
"endPointKey": "INR",
|
||||||
"locale": "hi-IN",
|
"locale": "hi-IN",
|
||||||
"source": "wazirx",
|
"source": "coinpaprika",
|
||||||
"symbol": "₹",
|
"symbol": "₹",
|
||||||
"country": "India (Indian Rupee)"
|
"country": "India (Indian Rupee)"
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,7 +66,7 @@ object MarketAPI {
|
||||||
"Yadio" -> "https://api.yadio.io/json/$endPointKey"
|
"Yadio" -> "https://api.yadio.io/json/$endPointKey"
|
||||||
"YadioConvert" -> "https://api.yadio.io/convert/1/BTC/$endPointKey"
|
"YadioConvert" -> "https://api.yadio.io/convert/1/BTC/$endPointKey"
|
||||||
"Exir" -> "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
"Exir" -> "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
||||||
"wazirx" -> "https://api.wazirx.com/api/v2/tickers/btcinr"
|
"coinpaprika" -> "https://api.coinpaprika.com/v1/tickers/btc-bitcoin?quotes=INR"
|
||||||
"Bitstamp" -> "https://www.bitstamp.net/api/v2/ticker/btc${endPointKey.lowercase()}"
|
"Bitstamp" -> "https://www.bitstamp.net/api/v2/ticker/btc${endPointKey.lowercase()}"
|
||||||
"Coinbase" -> "https://api.coinbase.com/v2/prices/BTC-${endPointKey.uppercase()}/buy"
|
"Coinbase" -> "https://api.coinbase.com/v2/prices/BTC-${endPointKey.uppercase()}/buy"
|
||||||
"CoinGecko" -> "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${endPointKey.lowercase()}"
|
"CoinGecko" -> "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${endPointKey.lowercase()}"
|
||||||
|
@ -86,7 +86,7 @@ object MarketAPI {
|
||||||
"CoinGecko" -> json.getJSONObject("bitcoin").getString(endPointKey.lowercase())
|
"CoinGecko" -> json.getJSONObject("bitcoin").getString(endPointKey.lowercase())
|
||||||
"Exir" -> json.getString("last")
|
"Exir" -> json.getString("last")
|
||||||
"Bitstamp" -> json.getString("last")
|
"Bitstamp" -> json.getString("last")
|
||||||
"wazirx" -> json.getJSONObject("ticker").getString("buy")
|
"coinpaprika" -> json.getJSONObject("quotes").getJSONObject("INR").getString("price")
|
||||||
"Coinbase" -> json.getJSONObject("data").getString("amount")
|
"Coinbase" -> json.getJSONObject("data").getString("amount")
|
||||||
"Kraken" -> json.getJSONObject("result").getJSONObject("XXBTZ${endPointKey.uppercase()}").getJSONArray("c").getString(0)
|
"Kraken" -> json.getJSONObject("result").getJSONObject("XXBTZ${endPointKey.uppercase()}").getJSONArray("c").getString(0)
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
@ -139,7 +139,7 @@ class WidgetUpdateWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
"Yadio" -> "https://api.yadio.io/json/$endPointKey"
|
"Yadio" -> "https://api.yadio.io/json/$endPointKey"
|
||||||
"YadioConvert" -> "https://api.yadio.io/convert/1/BTC/$endPointKey"
|
"YadioConvert" -> "https://api.yadio.io/convert/1/BTC/$endPointKey"
|
||||||
"Exir" -> "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
"Exir" -> "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
||||||
"wazirx" -> "https://api.wazirx.com/api/v2/tickers/btcinr"
|
"coinpaprika" -> "https://api.coinpaprika.com/v1/tickers/btc-bitcoin?quotes=INR"
|
||||||
"Bitstamp" -> "https://www.bitstamp.net/api/v2/ticker/btc${endPointKey.lowercase()}"
|
"Bitstamp" -> "https://www.bitstamp.net/api/v2/ticker/btc${endPointKey.lowercase()}"
|
||||||
"Coinbase" -> "https://api.coinbase.com/v2/prices/BTC-${endPointKey.uppercase()}/buy"
|
"Coinbase" -> "https://api.coinbase.com/v2/prices/BTC-${endPointKey.uppercase()}/buy"
|
||||||
"CoinGecko" -> "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${endPointKey.lowercase()}"
|
"CoinGecko" -> "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${endPointKey.lowercase()}"
|
||||||
|
@ -155,7 +155,7 @@ class WidgetUpdateWorker(context: Context, workerParams: WorkerParameters) : Wor
|
||||||
"CoinGecko" -> json.getJSONObject("bitcoin").getString(endPointKey.lowercase())
|
"CoinGecko" -> json.getJSONObject("bitcoin").getString(endPointKey.lowercase())
|
||||||
"Coinbase" -> json.getJSONObject("data").getString("amount")
|
"Coinbase" -> json.getJSONObject("data").getString("amount")
|
||||||
"Bitstamp" -> json.getString("last")
|
"Bitstamp" -> json.getString("last")
|
||||||
"wazirx" -> json.getJSONObject("ticker").getString("buy")
|
"coinpaprika" -> json.getJSONObject("quotes").getJSONObject("INR").getString("price")
|
||||||
"Exir" -> json.getString("last")
|
"Exir" -> json.getString("last")
|
||||||
"Yadio", "YadioConvert" -> json.getJSONObject(endPointKey).getString("price")
|
"Yadio", "YadioConvert" -> json.getJSONObject(endPointKey).getString("price")
|
||||||
else -> throw IllegalArgumentException("Unsupported source: $source")
|
else -> throw IllegalArgumentException("Unsupported source: $source")
|
||||||
|
|
|
@ -25,8 +25,8 @@ class MarketAPI {
|
||||||
return "https://api.yadio.io/convert/1/BTC/\(endPointKey)"
|
return "https://api.yadio.io/convert/1/BTC/\(endPointKey)"
|
||||||
case "Exir":
|
case "Exir":
|
||||||
return "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
return "https://api.exir.io/v1/ticker?symbol=btc-irt"
|
||||||
case "wazirx":
|
case "coinpaprika":
|
||||||
return "https://api.wazirx.com/api/v2/tickers/btcinr"
|
return "https://api.coinpaprika.com/v1/tickers/btc-bitcoin?quotes=INR"
|
||||||
case "Bitstamp":
|
case "Bitstamp":
|
||||||
return "https://www.bitstamp.net/api/v2/ticker/btc\(endPointKey.lowercased())"
|
return "https://www.bitstamp.net/api/v2/ticker/btc\(endPointKey.lowercased())"
|
||||||
case "Coinbase":
|
case "Coinbase":
|
||||||
|
@ -102,17 +102,19 @@ class MarketAPI {
|
||||||
completion(nil, CurrencyError(errorDescription: "Data formatting error for source: \(source)"))
|
completion(nil, CurrencyError(errorDescription: "Data formatting error for source: \(source)"))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "wazirx":
|
case "coinpaprika":
|
||||||
if let tickerDict = json["ticker"] as? [String: Any],
|
if let quotesDict = json["quotes"] as? [String: Any],
|
||||||
let rateString = tickerDict["buy"] as? String,
|
let inrDict = quotesDict["INR"] as? [String: Any],
|
||||||
let rateDouble = Double(rateString) {
|
let rateDouble = inrDict["price"] as? Double {
|
||||||
|
|
||||||
|
let rateString = String(rateDouble)
|
||||||
let lastUpdatedString = ISO8601DateFormatter().string(from: Date())
|
let lastUpdatedString = ISO8601DateFormatter().string(from: Date())
|
||||||
|
|
||||||
latestRateDataStore = WidgetDataStore(rate: rateString, lastUpdate: lastUpdatedString, rateDouble: rateDouble)
|
latestRateDataStore = WidgetDataStore(rate: rateString, lastUpdate: lastUpdatedString, rateDouble: rateDouble)
|
||||||
completion(latestRateDataStore, nil)
|
completion(latestRateDataStore, nil)
|
||||||
} else {
|
} else {
|
||||||
completion(nil, CurrencyError(errorDescription: "Data formatting error for source: \(source)"))
|
completion(nil, CurrencyError(errorDescription: "Data formatting error for source: \(source)"))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Coinbase":
|
case "Coinbase":
|
||||||
if let data = json["data"] as? [String: Any],
|
if let data = json["data"] as? [String: Any],
|
||||||
let rateString = data["amount"] as? String,
|
let rateString = data["amount"] as? String,
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const FiatUnitSource = {
|
||||||
Yadio: 'Yadio',
|
Yadio: 'Yadio',
|
||||||
YadioConvert: 'YadioConvert',
|
YadioConvert: 'YadioConvert',
|
||||||
Exir: 'Exir',
|
Exir: 'Exir',
|
||||||
wazirx: 'wazirx',
|
coinpaprika: 'coinpaprika',
|
||||||
Bitstamp: 'Bitstamp',
|
Bitstamp: 'Bitstamp',
|
||||||
BNR: 'BNR',
|
BNR: 'BNR',
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -165,20 +165,24 @@ const RateExtractors = {
|
||||||
return rate;
|
return rate;
|
||||||
},
|
},
|
||||||
|
|
||||||
wazirx: async (ticker: string): Promise<number> => {
|
coinpaprika: async (ticker: string): Promise<number> => {
|
||||||
let json;
|
let json;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`https://api.wazirx.com/api/v2/tickers/btcinr`);
|
const res = await fetch('https://api.coinpaprika.com/v1/tickers/btc-bitcoin?quotes=INR');
|
||||||
json = await res.json();
|
json = await res.json();
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw new Error(`Could not update rate for ${ticker}: ${e.message}`);
|
throw new Error(`Could not update rate for ${ticker}: ${e.message}`);
|
||||||
}
|
}
|
||||||
let rate = json?.ticker?.buy;
|
|
||||||
|
const rate = json?.quotes?.INR?.price;
|
||||||
if (!rate) throw new Error(`Could not update rate for ${ticker}: data is wrong`);
|
if (!rate) throw new Error(`Could not update rate for ${ticker}: data is wrong`);
|
||||||
|
|
||||||
rate = Number(rate);
|
const parsedRate = Number(rate);
|
||||||
if (!(rate >= 0)) throw new Error(`Could not update rate for ${ticker}: data is wrong`);
|
if (isNaN(parsedRate) || parsedRate <= 0) {
|
||||||
return rate;
|
throw new Error(`Could not update rate for ${ticker}: data is wrong`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedRate;
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -187,7 +191,7 @@ export type TFiatUnit = {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
country: string;
|
country: string;
|
||||||
source: 'CoinDesk' | 'Yadio' | 'Exir' | 'wazirx' | 'Bitstamp' | 'Kraken';
|
source: 'CoinDesk' | 'Yadio' | 'Exir' | 'coinpaprika' | 'Bitstamp' | 'Kraken';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TFiatUnits = {
|
export type TFiatUnits = {
|
||||||
|
|
|
@ -149,7 +149,7 @@
|
||||||
"INR": {
|
"INR": {
|
||||||
"endPointKey": "INR",
|
"endPointKey": "INR",
|
||||||
"locale": "hi-IN",
|
"locale": "hi-IN",
|
||||||
"source": "wazirx",
|
"source": "coinpaprika",
|
||||||
"symbol": "₹",
|
"symbol": "₹",
|
||||||
"country": "India (Indian Rupee)"
|
"country": "India (Indian Rupee)"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue