Skip to content

Commit

Permalink
Migrate Bitmax to Ascendex.
Browse files Browse the repository at this point in the history
Fix ZB Exchange.
Remove LakeBTC.
  • Loading branch information
hwki committed Jul 6, 2021
1 parent 7fd5c64 commit 365eac1
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 32 deletions.
4 changes: 2 additions & 2 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdkVersion 21
targetSdkVersion 30
versionCode 263
versionName "7.4.4"
versionCode 264
versionName "7.4.5"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal object DataMigration {
private const val BCH_TO_ABC = "bch_abc"
private const val INDODAX = "indodax"
private const val XZC_TO_FIRO = "firo"
private const val ASCENDEX = "ascendex"

fun migrate(context: Context) {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
Expand Down Expand Up @@ -61,6 +62,22 @@ internal object DataMigration {
migrationFiro()
prefs.edit().putBoolean(XZC_TO_FIRO, true).apply()
}
val hasAscendex = prefs.getBoolean(ASCENDEX, false)
if (!hasAscendex) {
migrationAscendex()
prefs.edit().putBoolean(ASCENDEX, true).apply()
}
}

private fun migrationAscendex() {
val widgetIds = WidgetApplication.instance.widgetIds
for (widgetId in widgetIds) {
val prefs = Prefs(widgetId)
val exchange = prefs.getValue("exchange")
if (exchange == "BITMAX") {
prefs.setValue("exchange", "ASCENDEX")
}
}
}

private fun migrationFiro() {
Expand Down
22 changes: 7 additions & 15 deletions bitcoin/src/main/java/com/brentpanther/bitcoinwidget/Exchange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ internal enum class Exchange(val exchangeName: String, shortName: String? = null
return getJsonObject(url).get("last").asString
}
},
ASCENDEX("AscendEX") {
override fun getValue(coin: String, currency: String): String? {
val obj = getJsonObject("https://ascendex.com/api/pro/v1/ticker?symbol=$coin/$currency")
return obj.getAsJsonObject("data").get("close").asString
}
},
BIBOX("Bibox") {

override fun getValue(coin: String, currency: String): String {
Expand Down Expand Up @@ -121,12 +127,6 @@ internal enum class Exchange(val exchangeName: String, shortName: String? = null
return getJsonObject(url).getAsJsonArray("data").get(0).asJsonObject.get("c").asString
}
},
BITMAX("BitMax") {
override fun getValue(coin: String, currency: String): String? {
val obj = getJsonObject("https://bitmax.io/api/pro/v1/ticker?symbol=$coin/$currency")
return obj.getAsJsonObject("data").get("close").asString
}
},
BITMEX("BitMEX") {

override fun getValue(coin: String, currency: String): String {
Expand Down Expand Up @@ -562,14 +562,6 @@ internal enum class Exchange(val exchangeName: String, shortName: String? = null
return obj.getAsJsonObject("ticker").get("last").asString
}
},
LAKEBTC("LakeBTC") {

override fun getValue(coin: String, currency: String): String {
val pair = "$coin$currency".lowercase(Locale.ROOT)
val obj = getJsonObject("https://api.lakebtc.com/api_v2/ticker")
return obj.getAsJsonObject(pair).get("last").asString
}
},
LBANK("LBank") {

override fun getValue(coin: String, currency: String): String {
Expand Down Expand Up @@ -751,7 +743,7 @@ internal enum class Exchange(val exchangeName: String, shortName: String? = null
ZB("ZB") {

override fun getValue(coin: String, currency: String): String {
val url = "http://api.zb.live/data/v1/ticker?market=${coin.lowercase(Locale.ROOT)}_${
val url = "http://api.zb.land/data/v1/ticker?market=${coin.lowercase(Locale.ROOT)}_${
currency.lowercase(Locale.ROOT)
}"
return getJsonObject(url).getAsJsonObject("ticker").get("last").asString
Expand Down
2 changes: 1 addition & 1 deletion bitcoin/src/main/res/raw/cryptowidgetcoins.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bitcoin/src/main/res/raw/othercoins.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 @@ -96,7 +96,7 @@
</string-array>
<string name="value_unknown" translatable="false">\u0020\u0020\u0020\?\u0020\u0020\u0020</string>
<string name="value_exchange_removed" translatable="false">\u0020!\u0020</string>
<string name="json_last_modified" translatable="false">Sun, 06 Jun 2021 18:24:00 GMT</string>
<string name="json_last_modified" translatable="false">Tue, 06 Jul 2021 19:00:00 GMT</string>
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins.json</string>

<string name="dialog_update_title">Updating</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class GenerateSupportedCoinsJson {
allCurrencies = (json.read("$..currencies.*") as List<String>).toSortedSet()

val exchanges =
listOf(this::abucoins, this::bibox, this::bigone, this::binance, this::binance_us, this::bit2c,
listOf(this::abucoins, this::ascendex, this::bibox, this::bigone, this::binance, this::binance_us, this::bit2c,
this::bitbank, this::bitbay, this::bitcambio, this::bitclude,
this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bithumbpro, this::bitmax, this::bitmex,
this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bithumbpro, this::bitmex,
this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitvavo, this::bleutrade,
this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
this::chilebit, this::coinbase, this::coinbasepro, this::coinbene, this::coindesk, this::coinegg, this::coingecko,
this::coinjar, this::coinmate, this::coinone, this::coinsbit, this::coinsph, this::cointree,
this::cryptocom, this::deversifi, this::duedex, this::exmo, this::ftx, this::foxbit, this::gateio, this::gemini, this::hitbtc,
this::huobi, this::independent_reserve, this::indodax, this::itbit, this::korbit, this::kraken, this::kucoin,
this::kuna, this::lakebtc, this::lbank, this::liquid, this::luno, this::mercado, this::ndax,
this::kuna, this::lbank, this::liquid, this::luno, this::mercado, this::ndax,
this::nexchange, this::okcoin, this::okex, this::p2pb2b, this::paribu, this::paymium, this::phemex,
this::pocketbits, this::poloniex, this::probit, this::therock, this::tradeogre, this::uphold,
this::urdubit, this::vbtc, this::whitebit, this::wyre, this::yobit, this::zb, this::zbg
Expand Down Expand Up @@ -193,6 +193,10 @@ class GenerateSupportedCoinsJson {
return parse("https://api.abucoins.com/products", "$[*].id")
}

private fun ascendex(): List<String> {
return parse("https://ascendex.com/api/pro/v1/products", "$.data[?(@.status=='Normal')].symbol")
}

private fun bibox(): List<String> {
return parse("https://api.bibox.com/v1/mdata?cmd=pairList", "$.result[*].pair")
}
Expand Down Expand Up @@ -257,10 +261,6 @@ class GenerateSupportedCoinsJson {
return parse("https://global-openapi.bithumb.pro/openapi/v1/spot/ticker?symbol=ALL", "$.data[*].s")
}

private fun bitmax(): List<String> {
return parse("https://bitmax.io/api/pro/v1/products", "$.data[?(@.status=='Normal')].symbol")
}

private fun bitmex(): List<String> {
return parse("https://www.bitmex.com/api/v1/instrument/active", "$.[*].symbol")
}
Expand Down Expand Up @@ -455,10 +455,6 @@ class GenerateSupportedCoinsJson {
return parse("https://api.kuna.io/v3/markets", "$[*].id")
}

private fun lakebtc(): List<String> {
return parseKeys("https://api.lakebtc.com/api_v2/ticker", "$")
}

private fun lbank(): List<String> {
return parse("https://api.lbkex.com/v2/currencyPairs.do", "$.data[*]")
}
Expand Down Expand Up @@ -581,7 +577,7 @@ class GenerateSupportedCoinsJson {
}

private fun zb(): List<String> {
return parseKeys("http://api.zb.live/data/v1/markets", "$")
return parseKeys("http://api.zb.land/data/v1/markets", "$")
}

private fun zbg(): List<String> {
Expand Down
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/264.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Migrate Bitmax to Ascendex.
Fix ZB Exchange.
Remove LakeBTC.

0 comments on commit 365eac1

Please sign in to comment.