Skip to content

Commit

Permalink
Add compatibility with older wallet api
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Jan 22, 2024
1 parent 2cf1d1a commit 3271553
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.serialization.json.putJsonArray
import net.primal.android.nostr.model.NostrEvent
import net.primal.android.user.domain.Relay
import net.primal.android.user.domain.RelayPermission
import timber.log.Timber

val NostrJson = Json {
ignoreUnknownKeys = true
Expand All @@ -31,6 +32,7 @@ inline fun <reified T> Json.decodeFromStringOrNull(string: String?): T? {
return try {
decodeFromString(string)
} catch (error: IllegalArgumentException) {
Timber.e(error)
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ data class ContentWalletTransaction(
val type: TxType,
val state: TxState,
@SerialName("created_at") val createdAt: Long,
@SerialName("updated_at") val updatedAt: Long,
@SerialName("completed_at") val completedAt: Long?,
@SerialName("updated_at") val updatedAt: Long = createdAt,
@SerialName("completed_at") val completedAt: Long? = null,
@SerialName("amount_btc") val amountInBtc: Double,
@SerialName("amount_usd") val amountInUsd: Double?,
@SerialName("amount_usd") val amountInUsd: Double? = null,
@SerialName("pubkey_1") val selfPubkey: String,
@SerialName("subindex_1") val selfSubWallet: SubWallet,
@SerialName("lud16_1") val selfLud16: String?,
@SerialName("pubkey_2") val otherPubkey: String?,
@SerialName("subindex_2") val otherSubWallet: SubWallet?,
@SerialName("lud16_2") val otherLud16: String?,
val note: String?,
@SerialName("lud16_1") val selfLud16: String? = null,
@SerialName("pubkey_2") val otherPubkey: String? = null,
@SerialName("subindex_2") val otherSubWallet: SubWallet? = null,
@SerialName("lud16_2") val otherLud16: String? = null,
val note: String? = null,
@SerialName("is_zap") val isZap: Boolean,
@SerialName("zap_request") val zapRequestRawJson: String?,
@SerialName("zap_request") val zapRequestRawJson: String? = null,
@SerialName("is_in_app_purchase") val isInAppPurchase: Boolean,
val invoice: String?,
@SerialName("total_fee_btc") val totalFeeInBtc: String?,
@SerialName("exchange_rate") val exchangeRate: String?,
@SerialName("onchainAddress") val onChainAddress: String?,
val invoice: String? = null,
@SerialName("total_fee_btc") val totalFeeInBtc: String? = null,
@SerialName("exchange_rate") val exchangeRate: String? = null,
@SerialName("onchainAddress") val onChainAddress: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import net.primal.android.wallet.api.model.WalletRequestBody
import net.primal.android.wallet.api.model.WalletUserInfoResponse
import net.primal.android.wallet.api.model.WithdrawRequestBody
import net.primal.android.wallet.domain.SubWallet
import timber.log.Timber

class WalletApiImpl @Inject constructor(
@PrimalWalletApiClient private val primalApiClient: PrimalApiClient,
Expand Down Expand Up @@ -189,6 +190,7 @@ class WalletApiImpl @Inject constructor(
try {
NostrJson.decodeFromJsonElement<ContentWalletTransaction>(it)
} catch (error: IllegalArgumentException) {
Timber.e(error)
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import kotlinx.serialization.Serializable
data class BalanceResponse(
val amount: String,
val currency: String,
@SerialName("max_amount") val maxAmount: String,
@SerialName("max_amount") val maxAmount: String? = null,
)

0 comments on commit 3271553

Please sign in to comment.