Skip to content

Commit

Permalink
Added CoinPaprika exchange.
Browse files Browse the repository at this point in the history
Added Verus token.
  • Loading branch information
hwki committed Aug 11, 2024
1 parent d73f972 commit 0d5897c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'kotlin-android'
id 'com.google.devtools.ksp'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.24'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.25'
}

android {
Expand All @@ -13,8 +13,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 34
versionCode 331
versionName "8.5.6"
versionCode 332
versionName "8.5.7"

}

Expand Down Expand Up @@ -68,13 +68,13 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'androidx.activity:activity-ktx:1.9.0'
implementation 'androidx.activity:activity-compose:1.9.0'
implementation 'androidx.work:work-runtime:2.9.1'
implementation 'androidx.activity:activity-ktx:1.9.1'
implementation 'androidx.activity:activity-compose:1.9.1'
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material:material'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4'
implementation 'androidx.navigation:navigation-compose:2.7.7'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'io.coil-kt:coil-compose:2.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ enum class Coin(val coinName: String, val coinGeckoId: String, private vararg va
UMA("UMA", "uma", IconTheme(SOLID, ic_uma)),
UNI("Uniswap", "uniswap", IconTheme(SOLID, ic_uni)),
VET("VeChain", "vechain", IconTheme(SOLID, ic_vet)),
VRSC("Verus Coin", "verus-coin", IconTheme(SOLID, ic_vrsc)),
VTC("Vertcoin", "vertcoin", IconTheme(SOLID, ic_vtc)),
WAVES("Waves", "waves", IconTheme(SOLID, ic_waves)),
WBTC("Wrapped Bitcoin", "wrapped-bitcoin", IconTheme(SOLID, ic_wbtc)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
return getJsonObject(url)["tickers"]?.jsonArray?.get(0)?.jsonObject?.get("last").asString
}
},
COINPAPRIKA("Coinpaprika") {
override fun getValue(coin: String, currency: String): String? {
// since we can't look up by symbol, first search for id
val searchUrl = "https://api.coinpaprika.com/v1/search/?q=$coin&c=currencies&modifier=symbol_search"
val id = getJsonObject(searchUrl)["currencies"]?.jsonArray?.firstOrNull {
it.jsonObject["symbol"].asString == coin
}?.jsonObject?.get("id").asString ?: return null
val url = "https://api.coinpaprika.com/v1/tickers/$id"
return getJsonObject(url)["quotes"]?.jsonObject?.get(currency)?.jsonObject?.get("price").asString
}

},
COINSBIT("Coinsbit") {
override fun getValue(coin: String, currency: String): String? {
val coinName = if (coin == "WBTC") "wBTC" else coin
Expand Down
Binary file added bitcoin/src/main/res/drawable-nodpi/ic_vrsc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -96,7 +96,7 @@
<item>ISO</item>
<item>NONE</item>
</string-array>
<string name="json_last_modified" translatable="false">Mon, 22 Jul 2024 22:48:01 GMT</string>
<string name="json_last_modified" translatable="false">Sun, 11 Aug 2024 19:22:27 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 @@ -41,7 +41,7 @@ class GenerateSupportedCoinsJson {
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, 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::coinsbit, this::coinsph, this::cointree,
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsbit, 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,
Expand Down Expand Up @@ -433,6 +433,13 @@ class GenerateSupportedCoinsJson {
}
}

private fun coinpaprika(): List<String> {
val currencies = listOf("BTC", "ETH", "USD", "EUR", "PLN", "KRW", "GBP", "CAD", "JPY", "RUB", "TRY", "NZD", "AUD", "CHF", "UAH", "HKD", "SGD", "NGN", "PHP", "MXN", "BRL", "THB", "CLP", "CNY", "CZK", "DKK", "HUF", "IDR", "ILS", "INR", "MYR", "NOK", "PKR", "SEK", "TWD", "ZAR", "VND", "BOB", "COP", "PEN", "ARS", "ISK")
val coins = parse("https://api.coinpaprika.com/v1/coins", "$[*][?(@.is_active==true)].symbol")
.filterNot { it == "XBT" }
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")
}
Expand Down Expand Up @@ -572,8 +579,8 @@ class GenerateSupportedCoinsJson {
}

private fun phemex(): List<String> {
val list = JsonPath.read(get("https://api.phemex.com/public/products"),
"$.data.products.[?(@.status == 'Listed' && @.type == 'Spot')]") as List<Map<String, *>>
val path = "$.data.products.[?(@.status == 'Listed' && @.type == 'Spot')]"
val list = JsonPath.read(get("https://api.phemex.com/public/products"), path) as List<Map<String, *>>
return list.map { "${it["baseCurrency"]}-${it["quoteCurrency"]}" }
}

Expand All @@ -586,7 +593,8 @@ class GenerateSupportedCoinsJson {
}

private fun tradeogre(): List<String> {
val list = JsonPath.read(get("https://tradeogre.com/api/v1/markets"), "$[*]") as List<Map<String, *>>
val path = "$[*]"
val list = JsonPath.read(get("https://tradeogre.com/api/v1/markets"), path) as List<Map<String, *>>
return list.map { it.keys.first().split("-").reversed().joinToString("_") }
}

Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.compose_compiler_version = '1.5.14'
ext.compose_compiler_version = '1.5.15'

ext.kotlin_version = '1.9.24'
ext.kotlin_version = '1.9.25'
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
classpath 'com.android.tools.build:gradle:8.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id 'com.google.devtools.ksp' version '1.9.24-1.0.20' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.24'
id 'com.google.devtools.ksp' version '1.9.25-1.0.20' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.25'
}

allprojects {
Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/332.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added CoinPaprika exchange.
Added Verus token.

0 comments on commit 0d5897c

Please sign in to comment.