Skip to content

Commit

Permalink
[ANCHOR-636] Clean up deprecation for fee_details (#129)
Browse files Browse the repository at this point in the history
* clean up deprecation for fee_details

* address comments

* mark fee_details as optional for backward compatibility

* mark fee_details.asset as non-null
  • Loading branch information
JiahuiWho authored Apr 4, 2024
1 parent 592f5e6 commit 63b6e1b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val jvmVersion = JavaVersion.VERSION_11

allprojects {
group = "org.stellar.wallet-sdk"
version = "1.4.0"
version = "1.5.0"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions wallet-sdk/src/main/kotlin/org/stellar/walletsdk/anchor/Data.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<FeeDescription>? = 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 */
Expand Down
10 changes: 10 additions & 0 deletions wallet-sdk/src/test/resources/anchor_transactions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 63b6e1b

Please sign in to comment.