diff --git a/bee-api/bee-rest-api/CHANGELOG.md b/bee-api/bee-rest-api/CHANGELOG.md index 08c6b11b9a..499aaf768c 100644 --- a/bee-api/bee-rest-api/CHANGELOG.md +++ b/bee-api/bee-rest-api/CHANGELOG.md @@ -19,10 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> -## 0.2.1 - 2022-02-28 +## 0.2.1 - 2022-03-04 + +### Changed - Update `bee-gossip` dependency to 0.5.0; +### Fixed + +- Convert `None` to `0` for balance response; + ## 0.2.0 - 2022-01-28 ### Added diff --git a/bee-api/bee-rest-api/src/endpoints/routes/api/v1/balance_ed25519.rs b/bee-api/bee-rest-api/src/endpoints/routes/api/v1/balance_ed25519.rs index 7e10e75632..ef6f84a764 100644 --- a/bee-api/bee-rest-api/src/endpoints/routes/api/v1/balance_ed25519.rs +++ b/bee-api/bee-rest-api/src/endpoints/routes/api/v1/balance_ed25519.rs @@ -59,18 +59,21 @@ pub(crate) async fn balance_ed25519( "unable to fetch the balance of the address".to_string(), )) })? { - (Ok(response), ledger_index) => match response { - Some(balance) => Ok(warp::reply::json(&SuccessBody::new(BalanceAddressResponse { + (Ok(response), ledger_index) => { + let (balance, dust_allowed) = if let Some(balance) = response { + (balance.amount(), balance.dust_allowed()) + } else { + (0, false) + }; + + Ok(warp::reply::json(&SuccessBody::new(BalanceAddressResponse { address_type: Ed25519Address::KIND, address: addr.to_string(), - balance: balance.amount(), - dust_allowed: balance.dust_allowed(), + balance, + dust_allowed, ledger_index: *ledger_index, - }))), - None => Err(reject::custom(CustomRejection::NotFound( - "balance not found".to_string(), - ))), - }, + }))) + } (Err(e), _) => { error!("unable to fetch the balance of the address: {}", e); Err(reject::custom(CustomRejection::ServiceUnavailable(