From 8815105bf2462787885214a12af927d484226f21 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 30 Jul 2020 16:40:23 -0300 Subject: Split out common code into multiplatform Kotlin library --- .../net/taler/wallet/exchanges/ExchangeFees.kt | 53 +--------------------- 1 file changed, 1 insertion(+), 52 deletions(-) (limited to 'wallet/src/main/java/net/taler/wallet/exchanges/ExchangeFees.kt') 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, val wireFees: List -) { - 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(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(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 - ) - } - } -} +) -- cgit v1.2.3