Skip to content

Commit

Permalink
Removed Bittrex and Coinsbit.
Browse files Browse the repository at this point in the history
Fixed Kuna by updating API version.
Migrate Coinbase Pro to Coinbase.
Migrate OkCoin to OKX.
  • Loading branch information
hwki committed Jan 7, 2025
1 parent 34e7bd4 commit 9d31809
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 60 deletions.
4 changes: 2 additions & 2 deletions bitcoin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.brentpanther.bitcoinwidget"
minSdk = 23
targetSdk = 35
versionCode = 336
versionName = "8.6.1"
versionCode = 337
versionName = "8.6.2"
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ object DataMigration {
migrateBithumbProToBitGlobal(db)
migrateKaspaToKas(db)
migrateBitcludeToEgera(db)
migrateCoinbaseProToCoinbase(db)
migrateOkCoinToOkx(db)
fixRemovedExchanges(db)
}

Expand Down Expand Up @@ -54,4 +56,12 @@ object DataMigration {
db.execSQL("UPDATE Widget SET exchange = 'COINGECKO' WHERE id = $id")
}
}

private fun migrateCoinbaseProToCoinbase(db: SupportSQLiteDatabase) {
db.execSQL("UPDATE Widget SET exchange = 'COINBASE' WHERE exchange = 'COINBASEPRO'")
}

private fun migrateOkCoinToOkx(db: SupportSQLiteDatabase) {
db.execSQL("UPDATE Widget SET exchange = 'OKX' WHERE exchange = 'OKCOIN'")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
return getJsonObject(url)["last"].asString
}
},
BITTREX("Bittrex") {

override fun getValue(coin: String, currency: String): String? {
val url = "https://api.bittrex.com/v3/markets/$coin-$currency/ticker"
return getJsonObject(url)["lastTradeRate"].asString
}
},
BITRUE("Bitrue") {
override fun getValue(coin: String, currency: String): String? {
val url = "https://openapi.bitrue.com/api/v1/ticker/price?symbol=$coin$currency"
Expand Down Expand Up @@ -215,13 +208,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
return obj["data"]?.jsonObject?.get("amount").asString
}
},
COINBASEPRO("Coinbase Pro") {

override fun getValue(coin: String, currency: String): String? {
val url = "https://api.pro.coinbase.com/products/$coin-$currency/ticker"
return getJsonObject(url)["price"].asString
}
},
COINDESK("Coindesk") {

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

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

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

override fun getValue(coin: String, currency: String): String? {
val pair = "$coin$currency".lowercase()
val url = "https://api.kuna.io/v3/tickers?symbols=$pair"
return getJsonArray(url)[0].jsonArray[1].asString
val url = "https://api.kuna.io/v4/markets/public/tickers?pairs=${coin}_$currency"
return getJsonObject(url)["data"]?.jsonArray?.get(0)?.jsonObject?.get("price").asString
}
},
LBANK("LBank") {
Expand Down Expand Up @@ -480,13 +458,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
return ((ask + bid) / 2).toString()
}
},
OKCOIN("OK Coin") {

override fun getValue(coin: String, currency: String): String? {
val url = "https://www.okcoin.com/api/spot/v3/instruments/$coin-$currency/ticker"
return getJsonObject(url)["last"].asString
}
},
OKX("OKX") {

override fun getValue(coin: String, currency: String): String? {
Expand Down
2 changes: 1 addition & 1 deletion bitcoin/src/main/res/raw/cryptowidgetcoins_v2.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bitcoin/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<item>ISO</item>
<item>NONE</item>
</string-array>
<string name="json_last_modified" translatable="false">Mon, 11 Nov 2024 22:24:26 GMT</string>
<string name="json_last_modified" translatable="false">Tue, 07 Jan 2025 02:28:34 GMT</string>
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>

<string name="error_restricted_battery_saver">Unable to refresh, Battery Saver is on</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ExchangeTest {

@Test
fun testPair() {
val exchange = Exchange.COINSBIT
val exchange = Exchange.COINBASE
val coin = Coin.WBTC
val currency = "USD"
val data = ExchangeData(coin, loadJSON())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class GenerateSupportedCoinsJson {
private val allExchanges =
listOf(this::ascendex, this::bibox, this::bigone, this::binance, this::binance_us, this::bingx, this::bit2c,
this::bitbank, this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bitmart,
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue,
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bitrue,
this::bitvavo, this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
this::chilebit, this::coinbase, this::coinbasepro, this::coindesk, this::coingecko,
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsbit, this::coinsph, this::cointree,
this::chilebit, this::coinbase,this::coindesk, this::coingecko,
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsph, this::cointree,
this::cryptocom, this::deversifi, this::digifinex, this::egera, this::exmo, this::foxbit, this::gateio, this::gemini,
this::hashkey, this::hitbtc, this::huobi, this::independent_reserve, this::indodax, this::itbit,
this::korbit, this::kraken, this::kucoin, this::kuna, this::lbank, this::luno,
this::mercado, this::mexc, this::ndax, this::nexchange, this::okcoin, this::okx, this::p2pb2b,
this::mercado, this::mexc, this::ndax, this::nexchange, this::okx, this::p2pb2b,
this::paribu, this::paymium, this::phemex, this::poloniex, this::probit,
this::tradeogre, this::uphold, this::vbtc, this::whitebit, this::xt, this::yadio,
this::yobit, this::zonda
Expand Down Expand Up @@ -361,10 +361,6 @@ class GenerateSupportedCoinsJson {
return parse("https://www.bitstamp.net/api/v2/trading-pairs-info", "$[*].name")
}

private fun bittrex(): List<String> {
return parse("https://api.bittrex.com/v3/markets", "$[*].symbol")
}

private fun bitrue(): List<String> {
val pairs = parse("https://openapi.bitrue.com/api/v1/exchangeInfo", "$.symbols[*].symbol")
return pairs.filterNot { it.contains("USDC") }
Expand Down Expand Up @@ -412,10 +408,6 @@ class GenerateSupportedCoinsJson {
}
}

private fun coinbasepro(): List<String> {
return parse("https://api.pro.coinbase.com/products", "$[*].id")
}

private fun coindesk(): List<String> {
val currencies = parse("https://api.coindesk.com/v1/bpi/supported-currencies.json", "$[*].currency")
return currencies.map { "BTC_$it" }
Expand Down Expand Up @@ -449,10 +441,6 @@ class GenerateSupportedCoinsJson {
return coins.flatMap { coin -> currencies.filterNot { it == coin }.map { currency -> "$coin-$currency" } }
}

private fun coinsbit(): List<String> {
return parse("https://coinsbit.io/api/v1/public/products", "$.result[*].id")
}

private fun coinsph(): List<String> {
return parse("https://api.pro.coins.ph/openapi/v1/pairs", "$[*].symbol")
}
Expand Down Expand Up @@ -538,7 +526,7 @@ class GenerateSupportedCoinsJson {
}

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

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

private fun okcoin(): List<String> {
return parse("https://www.okcoin.com/api/spot/v3/instruments", "$[*].instrument_id")
}

private fun okx(): List<String> {
val pairs = parse("https://www.okx.com/api/v5/public/instruments?instType=SPOT", "$.data[*].instId")
return pairs.filterNot { it.contains("USDC") }
Expand Down
4 changes: 4 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/337.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Removed Bittrex and Coinsbit.
Fixed Kuna by updating API version.
Migrate Coinbase Pro to Coinbase.
Migrate OkCoin to OKX.
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[versions]
agp = "8.7.2"
agp = "8.7.3"
activityKtx = "1.9.3"
coil = "2.7.0"
compose = "2024.10.01"
compose = "2024.12.01"
coreKtx = "1.15.0"
jsonPath = "2.9.0"
junit = "4.13.2"
kotlin = "2.0.21"
ksp = "2.0.21-1.0.25"
lifecycle = "2.8.7"
navigation = "2.8.3"
navigation = "2.8.5"
okhttp = "4.12.0"
preferences = "1.2.1"
room = "2.6.1"
Expand Down

0 comments on commit 9d31809

Please sign in to comment.