From c59e19c0807946ae5b9802d6d48a7cd3f128d44d Mon Sep 17 00:00:00 2001 From: KtorZ Date: Mon, 6 Jul 2020 12:07:49 +0200 Subject: [PATCH] remove rewards from the available balance The rationale is to have an easy way to show what's the spendable UTxO amount. --- .../src/Test/Integration/Scenario/API/Shelley/StakePools.hs | 6 +----- lib/core/src/Cardano/Wallet/Api/Server.hs | 2 +- specifications/api/swagger.yaml | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs index d5ef92db12f..56ce3b31cd0 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -164,11 +164,7 @@ spec = do verify r [ expectField (#balance . #getApiT . #reward) (.> (Quantity 0)) ] - let Quantity totalBalance = - getFromResponse (#balance . #getApiT . #total) r - let Quantity rewardBalance = - getFromResponse (#balance . #getApiT . #reward) r - pure $ Quantity (totalBalance - rewardBalance) + pure $ getFromResponse (#balance . #getApiT . #available) r -- Use rewards addrs <- listAddresses @n ctx w diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index 9492fecdd40..685530b59e8 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -613,7 +613,7 @@ mkShelleyWallet ctx wid cp meta pending progress = do pure ApiWallet { addressPoolGap = ApiT $ getState cp ^. #externalPool . #gap , balance = ApiT $ WalletBalance - { available = Quantity $ reward + availableBalance pending cp + { available = Quantity $ availableBalance pending cp , total = Quantity $ reward + totalBalance pending cp , reward = Quantity reward } diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 2ae7b4dcb9d..40fe06b3f93 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -341,13 +341,13 @@ x-walletBalance: &walletBalance properties: available: <<: *amount - description: Available balance (funds that can be spent) + description: Available UTxO balance (funds that can be spent without condition). reward: <<: *amount description: The balance of the reward account for this wallet. total: <<: *amount - description: Total balance (available balance plus pending change) + description: Total balance (available balance plus pending change and reward balance). x-byronWalletBalance: &byronWalletBalance description: Byron wallet's current balance(s)