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