Skip to content

Commit 9d31809

Browse files
committed
Removed Bittrex and Coinsbit.
Fixed Kuna by updating API version. Migrate Coinbase Pro to Coinbase. Migrate OkCoin to OKX.
1 parent 34e7bd4 commit 9d31809

File tree

9 files changed

+29
-60
lines changed

9 files changed

+29
-60
lines changed

bitcoin/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId = "com.brentpanther.bitcoinwidget"
1616
minSdk = 23
1717
targetSdk = 35
18-
versionCode = 336
19-
versionName = "8.6.1"
18+
versionCode = 337
19+
versionName = "8.6.2"
2020
}
2121

2222
buildFeatures {

bitcoin/src/main/java/com/brentpanther/bitcoinwidget/db/DataMigration.kt

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ object DataMigration {
1414
migrateBithumbProToBitGlobal(db)
1515
migrateKaspaToKas(db)
1616
migrateBitcludeToEgera(db)
17+
migrateCoinbaseProToCoinbase(db)
18+
migrateOkCoinToOkx(db)
1719
fixRemovedExchanges(db)
1820
}
1921

@@ -54,4 +56,12 @@ object DataMigration {
5456
db.execSQL("UPDATE Widget SET exchange = 'COINGECKO' WHERE id = $id")
5557
}
5658
}
59+
60+
private fun migrateCoinbaseProToCoinbase(db: SupportSQLiteDatabase) {
61+
db.execSQL("UPDATE Widget SET exchange = 'COINBASE' WHERE exchange = 'COINBASEPRO'")
62+
}
63+
64+
private fun migrateOkCoinToOkx(db: SupportSQLiteDatabase) {
65+
db.execSQL("UPDATE Widget SET exchange = 'OKX' WHERE exchange = 'OKCOIN'")
66+
}
5767
}

bitcoin/src/main/java/com/brentpanther/bitcoinwidget/exchange/Exchange.kt

+2-31
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
147147
return getJsonObject(url)["last"].asString
148148
}
149149
},
150-
BITTREX("Bittrex") {
151-
152-
override fun getValue(coin: String, currency: String): String? {
153-
val url = "https://api.bittrex.com/v3/markets/$coin-$currency/ticker"
154-
return getJsonObject(url)["lastTradeRate"].asString
155-
}
156-
},
157150
BITRUE("Bitrue") {
158151
override fun getValue(coin: String, currency: String): String? {
159152
val url = "https://openapi.bitrue.com/api/v1/ticker/price?symbol=$coin$currency"
@@ -215,13 +208,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
215208
return obj["data"]?.jsonObject?.get("amount").asString
216209
}
217210
},
218-
COINBASEPRO("Coinbase Pro") {
219-
220-
override fun getValue(coin: String, currency: String): String? {
221-
val url = "https://api.pro.coinbase.com/products/$coin-$currency/ticker"
222-
return getJsonObject(url)["price"].asString
223-
}
224-
},
225211
COINDESK("Coindesk") {
226212

227213
override fun getValue(coin: String, currency: String): String? {
@@ -272,13 +258,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
272258
}
273259

274260
},
275-
COINSBIT("Coinsbit") {
276-
override fun getValue(coin: String, currency: String): String? {
277-
val coinName = if (coin == "WBTC") "wBTC" else coin
278-
val url = "https://coinsbit.io/api/v1/public/ticker?market=${coinName}_$currency"
279-
return getJsonObject(url)["result"]?.jsonObject?.get("last").asString
280-
}
281-
},
282261
COINSPH("Coins.ph") {
283262

284263
override fun getValue(coin: String, currency: String): String? {
@@ -429,9 +408,8 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
429408
KUNA("KunaBTC") {
430409

431410
override fun getValue(coin: String, currency: String): String? {
432-
val pair = "$coin$currency".lowercase()
433-
val url = "https://api.kuna.io/v3/tickers?symbols=$pair"
434-
return getJsonArray(url)[0].jsonArray[1].asString
411+
val url = "https://api.kuna.io/v4/markets/public/tickers?pairs=${coin}_$currency"
412+
return getJsonObject(url)["data"]?.jsonArray?.get(0)?.jsonObject?.get("price").asString
435413
}
436414
},
437415
LBANK("LBank") {
@@ -480,13 +458,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
480458
return ((ask + bid) / 2).toString()
481459
}
482460
},
483-
OKCOIN("OK Coin") {
484-
485-
override fun getValue(coin: String, currency: String): String? {
486-
val url = "https://www.okcoin.com/api/spot/v3/instruments/$coin-$currency/ticker"
487-
return getJsonObject(url)["last"].asString
488-
}
489-
},
490461
OKX("OKX") {
491462

492463
override fun getValue(coin: String, currency: String): String? {

bitcoin/src/main/res/raw/cryptowidgetcoins_v2.json

+1-1
Large diffs are not rendered by default.

bitcoin/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<item>ISO</item>
9999
<item>NONE</item>
100100
</string-array>
101-
<string name="json_last_modified" translatable="false">Mon, 11 Nov 2024 22:24:26 GMT</string>
101+
<string name="json_last_modified" translatable="false">Tue, 07 Jan 2025 02:28:34 GMT</string>
102102
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>
103103

104104
<string name="error_restricted_battery_saver">Unable to refresh, Battery Saver is on</string>

bitcoin/src/test/java/com/brentpanther/bitcoinwidget/ExchangeTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ExchangeTest {
5858

5959
@Test
6060
fun testPair() {
61-
val exchange = Exchange.COINSBIT
61+
val exchange = Exchange.COINBASE
6262
val coin = Coin.WBTC
6363
val currency = "USD"
6464
val data = ExchangeData(coin, loadJSON())

bitcoin/src/test/java/com/brentpanther/bitcoinwidget/GenerateSupportedCoinsJson.kt

+5-21
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class GenerateSupportedCoinsJson {
3838
private val allExchanges =
3939
listOf(this::ascendex, this::bibox, this::bigone, this::binance, this::binance_us, this::bingx, this::bit2c,
4040
this::bitbank, this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bitmart,
41-
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue,
41+
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bitrue,
4242
this::bitvavo, this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
43-
this::chilebit, this::coinbase, this::coinbasepro, this::coindesk, this::coingecko,
44-
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsbit, this::coinsph, this::cointree,
43+
this::chilebit, this::coinbase,this::coindesk, this::coingecko,
44+
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsph, this::cointree,
4545
this::cryptocom, this::deversifi, this::digifinex, this::egera, this::exmo, this::foxbit, this::gateio, this::gemini,
4646
this::hashkey, this::hitbtc, this::huobi, this::independent_reserve, this::indodax, this::itbit,
4747
this::korbit, this::kraken, this::kucoin, this::kuna, this::lbank, this::luno,
48-
this::mercado, this::mexc, this::ndax, this::nexchange, this::okcoin, this::okx, this::p2pb2b,
48+
this::mercado, this::mexc, this::ndax, this::nexchange, this::okx, this::p2pb2b,
4949
this::paribu, this::paymium, this::phemex, this::poloniex, this::probit,
5050
this::tradeogre, this::uphold, this::vbtc, this::whitebit, this::xt, this::yadio,
5151
this::yobit, this::zonda
@@ -361,10 +361,6 @@ class GenerateSupportedCoinsJson {
361361
return parse("https://www.bitstamp.net/api/v2/trading-pairs-info", "$[*].name")
362362
}
363363

364-
private fun bittrex(): List<String> {
365-
return parse("https://api.bittrex.com/v3/markets", "$[*].symbol")
366-
}
367-
368364
private fun bitrue(): List<String> {
369365
val pairs = parse("https://openapi.bitrue.com/api/v1/exchangeInfo", "$.symbols[*].symbol")
370366
return pairs.filterNot { it.contains("USDC") }
@@ -412,10 +408,6 @@ class GenerateSupportedCoinsJson {
412408
}
413409
}
414410

415-
private fun coinbasepro(): List<String> {
416-
return parse("https://api.pro.coinbase.com/products", "$[*].id")
417-
}
418-
419411
private fun coindesk(): List<String> {
420412
val currencies = parse("https://api.coindesk.com/v1/bpi/supported-currencies.json", "$[*].currency")
421413
return currencies.map { "BTC_$it" }
@@ -449,10 +441,6 @@ class GenerateSupportedCoinsJson {
449441
return coins.flatMap { coin -> currencies.filterNot { it == coin }.map { currency -> "$coin-$currency" } }
450442
}
451443

452-
private fun coinsbit(): List<String> {
453-
return parse("https://coinsbit.io/api/v1/public/products", "$.result[*].id")
454-
}
455-
456444
private fun coinsph(): List<String> {
457445
return parse("https://api.pro.coins.ph/openapi/v1/pairs", "$[*].symbol")
458446
}
@@ -538,7 +526,7 @@ class GenerateSupportedCoinsJson {
538526
}
539527

540528
private fun kuna(): List<String> {
541-
return parse("https://api.kuna.io/v3/markets", "$[*].id")
529+
return parse("https://api.kuna.io/v4/markets/public/getAll", "$.data[*].pair")
542530
}
543531

544532
private fun lbank(): List<String> {
@@ -566,10 +554,6 @@ class GenerateSupportedCoinsJson {
566554
return parse("https://api.n.exchange/en/api/v1/pair/?format=json", "$[?(@.disabled==false)].name")
567555
}
568556

569-
private fun okcoin(): List<String> {
570-
return parse("https://www.okcoin.com/api/spot/v3/instruments", "$[*].instrument_id")
571-
}
572-
573557
private fun okx(): List<String> {
574558
val pairs = parse("https://www.okx.com/api/v5/public/instruments?instType=SPOT", "$.data[*].instId")
575559
return pairs.filterNot { it.contains("USDC") }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Removed Bittrex and Coinsbit.
2+
Fixed Kuna by updating API version.
3+
Migrate Coinbase Pro to Coinbase.
4+
Migrate OkCoin to OKX.

gradle/libs.versions.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[versions]
2-
agp = "8.7.2"
2+
agp = "8.7.3"
33
activityKtx = "1.9.3"
44
coil = "2.7.0"
5-
compose = "2024.10.01"
5+
compose = "2024.12.01"
66
coreKtx = "1.15.0"
77
jsonPath = "2.9.0"
88
junit = "4.13.2"
99
kotlin = "2.0.21"
1010
ksp = "2.0.21-1.0.25"
1111
lifecycle = "2.8.7"
12-
navigation = "2.8.3"
12+
navigation = "2.8.5"
1313
okhttp = "4.12.0"
1414
preferences = "1.2.1"
1515
room = "2.6.1"

0 commit comments

Comments
 (0)