From 63b6e1bd2d93c2ce2b87cb4396d4025ffc87cf72 Mon Sep 17 00:00:00 2001 From: Jiahui Hu Date: Thu, 4 Apr 2024 15:56:48 -0600 Subject: [PATCH] [ANCHOR-636] Clean up deprecation for fee_details (#129) * clean up deprecation for fee_details * address comments * mark fee_details as optional for backward compatibility * mark fee_details.asset as non-null --- build.gradle.kts | 2 +- .../org/stellar/walletsdk/anchor/AnchorTransaction.kt | 10 +++++++--- .../main/kotlin/org/stellar/walletsdk/anchor/Data.kt | 10 ++++++++++ wallet-sdk/src/test/resources/anchor_transactions.json | 10 ++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 59d8f23b..8b072e7b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ val jvmVersion = JavaVersion.VERSION_11 allprojects { group = "org.stellar.wallet-sdk" - version = "1.4.0" + version = "1.5.0" } subprojects { diff --git a/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/AnchorTransaction.kt b/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/AnchorTransaction.kt index 7cf19551..950fb0e1 100644 --- a/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/AnchorTransaction.kt +++ b/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/AnchorTransaction.kt @@ -31,7 +31,8 @@ sealed interface ProcessingAnchorTransaction : AnchorTransaction { val amountOutAsset: String? val amountOut: String val amountFeeAsset: String? - val amountFee: String + val amountFee: String? + val feeDetails: FeeDetails? val completedAt: Instant? val stellarTransactionId: String? val externalTransactionId: String? @@ -52,7 +53,8 @@ data class DepositTransaction( @SerialName("amount_out_asset") override val amountOutAsset: String? = null, @SerialName("amount_out") override val amountOut: String, @SerialName("amount_fee_asset") override val amountFeeAsset: String? = null, - @SerialName("amount_fee") override val amountFee: String, + @SerialName("amount_fee") override val amountFee: String? = null, + @SerialName("fee_details") override val feeDetails: FeeDetails? = null, @SerialName("started_at") override val startedAt: Instant, @SerialName("completed_at") override val completedAt: Instant? = null, @SerialName("stellar_transaction_id") override val stellarTransactionId: String? = null, @@ -78,7 +80,8 @@ data class WithdrawalTransaction( @SerialName("amount_out_asset") override val amountOutAsset: String? = null, @SerialName("amount_out") override val amountOut: String, @SerialName("amount_fee_asset") override val amountFeeAsset: String? = null, - @SerialName("amount_fee") override val amountFee: String, + @SerialName("amount_fee") override val amountFee: String? = null, + @SerialName("fee_details") override val feeDetails: FeeDetails? = null, @SerialName("started_at") override val startedAt: Instant, @SerialName("completed_at") override val completedAt: Instant? = null, @SerialName("stellar_transaction_id") override val stellarTransactionId: String? = null, @@ -130,6 +133,7 @@ data class ErrorTransaction( @SerialName("amount_out") val amountOut: String? = null, @SerialName("amount_fee_asset") val amountFeeAsset: String? = null, @SerialName("amount_fee") val amountFee: String? = null, + @SerialName("fee_details") val feeDetails: FeeDetails? = null, @SerialName("completed_at") val completedAt: String? = null, @SerialName("stellar_transaction_id") val stellarTransactionId: String? = null, @SerialName("external_transaction_id") val externalTransactionId: String? = null, diff --git a/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/Data.kt b/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/Data.kt index 49858b8c..8cb381b9 100644 --- a/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/Data.kt +++ b/wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/Data.kt @@ -46,6 +46,16 @@ data class Payment( @SerialName("id_type") val idType: String ) +@Serializable +data class FeeDetails( + val total: String, + val asset: String, + val details: List? = null +) + +@Serializable +data class FeeDescription(val name: String, val description: String, val amount: String?) + enum class MemoType(val mapper: (String) -> Memo, val serialName: String) { @SerialName("text") TEXT({ s -> Memo.text(s) }, "text"), /** Hash memo. Supports hex or base64 string encoding */ diff --git a/wallet-sdk/src/test/resources/anchor_transactions.json b/wallet-sdk/src/test/resources/anchor_transactions.json index baedb99d..3129401e 100644 --- a/wallet-sdk/src/test/resources/anchor_transactions.json +++ b/wallet-sdk/src/test/resources/anchor_transactions.json @@ -10,6 +10,10 @@ "amount_out_asset": "stellar:SRT:GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B", "amount_fee": "1.00", "amount_fee_asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", + "fee_details": { + "total": "1.00", + "asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5" + }, "started_at": "2022-05-25T20:32:54.751725Z", "completed_at": "2022-05-25T20:33:33.954697Z", "stellar_transaction_id": "636e471ac1fc07053d54aa9904233e6e2ac55289dd9f522b49fce2bd9fc69467", @@ -31,6 +35,10 @@ "amount_in": "33.00", "amount_out": "32.00", "amount_fee": "1.00", + "fee_details": { + "total": "1.00", + "asset": "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5" + }, "started_at": "2022-06-07T20:18:59.349856Z", "completed_at": "2022-06-07T20:20:24.569693Z", "stellar_transaction_id": "2c5ed43935774db06995da719d6a1901275ec65251e4ae3a4f73dd808b1a1486", @@ -52,6 +60,7 @@ "amount_in": null, "amount_out": null, "amount_fee": null, + "fee_details": null, "started_at": "2022-12-05T21:47:41.608025Z", "completed_at": null, "stellar_transaction_id": null, @@ -73,6 +82,7 @@ "amount_in": null, "amount_out": null, "amount_fee": null, + "fee_details": null, "started_at": "2022-12-05T23:04:57.704541Z", "completed_at": null, "stellar_transaction_id": null,