aboutsummaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-07-30 16:40:23 -0300
committerTorsten Grote <t@grobox.de>2020-07-30 16:40:23 -0300
commit8815105bf2462787885214a12af927d484226f21 (patch)
tree597076d6970e336b881d68ca6b48577b007c9730 /wallet
parente19ba096d57353db6b1f141da4bf170ef2d2d534 (diff)
downloadtaler-android-8815105bf2462787885214a12af927d484226f21.tar.gz
taler-android-8815105bf2462787885214a12af927d484226f21.tar.bz2
taler-android-8815105bf2462787885214a12af927d484226f21.zip
Split out common code into multiplatform Kotlin library
Diffstat (limited to 'wallet')
-rw-r--r--wallet/.gitlab-ci.yml1
-rw-r--r--wallet/build.gradle10
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt5
-rw-r--r--wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt53
-rw-r--r--wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt13
5 files changed, 15 insertions, 67 deletions
diff --git a/wallet/.gitlab-ci.yml b/wallet/.gitlab-ci.yml
index 56768f7..c417aa9 100644
--- a/wallet/.gitlab-ci.yml
+++ b/wallet/.gitlab-ci.yml
@@ -4,6 +4,7 @@ wallet_test:
changes:
- wallet/**/*
- taler-kotlin-common/**/*
+ - taler-kotlin-android/**/*
- build.gradle
script: ./gradlew :wallet:check :wallet:assembleRelease
artifacts:
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 8cca8dc..1761018 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -23,7 +23,7 @@ plugins {
id "de.undercouch.download"
}
-def walletCoreVersion = "v0.7.1-dev.14"
+def walletCoreVersion = "v0.7.1-dev.16"
static def versionCodeEpoch() {
return (new Date().getTime() / 1000).toInteger()
@@ -47,7 +47,7 @@ android {
minSdkVersion 24
targetSdkVersion 29
versionCode 6
- versionName "0.7.1.dev.14"
+ versionName "0.7.1.dev.16"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "WALLET_CORE_VERSION", "\"$walletCoreVersion\""
}
@@ -83,6 +83,10 @@ android {
jvmTarget = "1.8"
}
+ packagingOptions {
+ exclude("META-INF/*.kotlin_module")
+ }
+
lintOptions {
abortOnError true
ignoreWarnings false
@@ -93,7 +97,7 @@ android {
}
dependencies {
- implementation project(":taler-kotlin-common")
+ implementation project(":taler-kotlin-android")
implementation project(":anastasis-ui")
implementation 'net.taler:akono:0.1'
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 3d725d0..ffa2dea 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -24,10 +24,13 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.distinctUntilChanged
import androidx.lifecycle.viewModelScope
+import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
+import net.taler.common.Amount
+import net.taler.common.AmountMixin
import net.taler.common.Event
import net.taler.common.assertUiThread
import net.taler.common.toEvent
@@ -91,6 +94,8 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
private val mapper = ObjectMapper()
.registerModule(KotlinModule())
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .addMixIn(Amount::class.java, AmountMixin::class.java)
+ .enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
val withdrawManager = WithdrawManager(walletBackendApi, mapper)
val paymentManager = PaymentManager(walletBackendApi, mapper)
diff --git a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt
index ae90b98..a026283 100644
--- a/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt
+++ b/wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt
@@ -18,7 +18,6 @@ package net.taler.wallet.exchanges
import net.taler.common.Amount
import net.taler.common.Timestamp
-import org.json.JSONObject
data class CoinFee(
val coin: Amount,
@@ -42,54 +41,4 @@ data class ExchangeFees(
val earliestDepositExpiration: Timestamp,
val coinFees: List<CoinFee>,
val wireFees: List<WireFee>
-) {
- companion object {
- fun fromExchangeWithdrawDetailsJson(json: JSONObject): ExchangeFees {
- val earliestDepositExpiration =
- json.getJSONObject("earliestDepositExpiration").getLong("t_ms")
- val selectedDenoms = json.getJSONObject("selectedDenoms")
- val denoms = selectedDenoms.getJSONArray("selectedDenoms")
- val coinFees = ArrayList<CoinFee>(denoms.length())
- for (i in 0 until denoms.length()) {
- val denom = denoms.getJSONObject(i)
- val d = denom.getJSONObject("denom")
- val coinFee = CoinFee(
- coin = Amount.fromJsonObject(d.getJSONObject("value")),
- quantity = denom.getInt("count"),
- feeDeposit = Amount.fromJsonObject(d.getJSONObject("feeDeposit")),
- feeRefresh = Amount.fromJsonObject(d.getJSONObject("feeRefresh")),
- feeRefund = Amount.fromJsonObject(d.getJSONObject("feeRefund")),
- feeWithdraw = Amount.fromJsonObject(d.getJSONObject("feeWithdraw"))
- )
- coinFees.add(coinFee)
- }
-
- val wireFeesJson = json.getJSONObject("wireFees")
- val feesForType = wireFeesJson.getJSONObject("feesForType")
- val bankFees = feesForType.getJSONArray("x-taler-bank")
- val wireFees = ArrayList<WireFee>(bankFees.length())
- for (i in 0 until bankFees.length()) {
- val fee = bankFees.getJSONObject(i)
- val startStamp =
- fee.getJSONObject("startStamp").getLong("t_ms")
- val endStamp =
- fee.getJSONObject("endStamp").getLong("t_ms")
- val wireFee = WireFee(
- start = Timestamp(startStamp),
- end = Timestamp(endStamp),
- wireFee = Amount.fromJsonObject(fee.getJSONObject("wireFee")),
- closingFee = Amount.fromJsonObject(fee.getJSONObject("closingFee"))
- )
- wireFees.add(wireFee)
- }
-
- return ExchangeFees(
- withdrawFee = Amount.fromJsonObject(json.getJSONObject("withdrawFee")),
- overhead = Amount.fromJsonObject(json.getJSONObject("overhead")),
- earliestDepositExpiration = Timestamp(earliestDepositExpiration),
- coinFees = coinFees,
- wireFees = wireFees
- )
- }
- }
-}
+)
diff --git a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
index 4c5b010..d2f8e6c 100644
--- a/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
+++ b/wallet/src/main/java/net/taler/wallet/payment/PaymentResponses.kt
@@ -16,23 +16,12 @@
package net.taler.wallet.payment
-import com.fasterxml.jackson.annotation.JsonSubTypes
-import com.fasterxml.jackson.annotation.JsonSubTypes.Type
import com.fasterxml.jackson.annotation.JsonTypeInfo
-import com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME
import com.fasterxml.jackson.annotation.JsonTypeName
import net.taler.common.ContractTerms
-import net.taler.wallet.payment.PreparePayResponse.AlreadyConfirmedResponse
-import net.taler.wallet.payment.PreparePayResponse.InsufficientBalanceResponse
-import net.taler.wallet.payment.PreparePayResponse.PaymentPossibleResponse
-@JsonTypeInfo(use = NAME, include = PROPERTY, property = "status")
-@JsonSubTypes(
- Type(value = PaymentPossibleResponse::class, name = "payment-possible"),
- Type(value = AlreadyConfirmedResponse::class, name = "already-confirmed"),
- Type(value = InsufficientBalanceResponse::class, name = "insufficient-balance")
-)
+@JsonTypeInfo(use = NAME, property = "status")
sealed class PreparePayResponse(open val proposalId: String) {
@JsonTypeName("payment-possible")
data class PaymentPossibleResponse(