Skip to content

Commit

Permalink
Remove locked_by_swaps field from my_balance/electrum/enable #689
Browse files Browse the repository at this point in the history
  • Loading branch information
artemii235 committed Jun 29, 2020
1 parent 281d6ec commit 08d013c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
4 changes: 0 additions & 4 deletions mm2src/mm2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,6 @@ fn test_my_balance() {
assert_eq!(my_balance, "7.777");
let my_address = unwrap!(json["address"].as_str());
assert_eq!(my_address, "RRnMcSeKiLrNdbp91qNVQwwXx5azD4S4CD");

// locked by swaps should be displayed as fraction
assert_eq!(json["locked_by_swaps"]["numer"], Json::from("0"));
assert_eq!(json["locked_by_swaps"]["denom"], Json::from("1"));
}

fn check_set_price_fails(mm: &MarketMakerIt, base: &str, rel: &str) {
Expand Down
8 changes: 1 addition & 7 deletions mm2src/rpc/lp_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use serde_json::{self as json, Value as Json};
use std::borrow::Cow;

use crate::mm2::lp_ordermatch::{CancelBy, cancel_orders_by};
use crate::mm2::lp_swap::{get_locked_amount, active_swaps_using_coin};
use crate::mm2::lp_swap::{active_swaps_using_coin};

/// Attempts to disable the coin
pub fn disable_coin (ctx: MmArc, req: Json) -> HyRes {
Expand Down Expand Up @@ -73,12 +73,10 @@ pub async fn electrum (ctx: MmArc, req: Json) -> Result<Response<Vec<u8>>, Strin
let ticker = try_s! (req["coin"].as_str().ok_or ("No 'coin' field")).to_owned();
let coin: MmCoinEnum = try_s! (lp_coininit (&ctx, &ticker, &req) .await);
let balance = try_s! (coin.my_balance().compat().await);
let trade_fee = try_s!(coin.get_trade_fee().compat().await);
let res = json! ({
"result": "success",
"address": try_s!(coin.my_address()),
"balance": balance,
"locked_by_swaps": get_locked_amount (&ctx, &ticker, &trade_fee),
"coin": coin.ticker(),
"required_confirmations": coin.required_confirmations(),
"requires_notarization": coin.requires_notarization(),
Expand All @@ -92,12 +90,10 @@ pub async fn enable (ctx: MmArc, req: Json) -> Result<Response<Vec<u8>>, String>
let ticker = try_s! (req["coin"].as_str().ok_or ("No 'coin' field")).to_owned();
let coin: MmCoinEnum = try_s! (lp_coininit (&ctx, &ticker, &req) .await);
let balance = try_s! (coin.my_balance().compat().await);
let trade_fee = try_s!(coin.get_trade_fee().compat().await);
let res = json! ({
"result": "success",
"address": try_s!(coin.my_address()),
"balance": balance,
"locked_by_swaps": get_locked_amount (&ctx, &ticker, &trade_fee),
"coin": coin.ticker(),
"required_confirmations": coin.required_confirmations(),
"requires_notarization": coin.requires_notarization(),
Expand Down Expand Up @@ -141,12 +137,10 @@ pub async fn my_balance (ctx: MmArc, req: Json) -> Result<Response<Vec<u8>>, Str
Ok (None) => return ERR!("No such coin: {}", ticker),
Err (err) => return ERR!("!lp_coinfind({}): {}", ticker, err)
};
let trade_fee = try_s!(coin.get_trade_fee().compat().await);
let my_balance = try_s!(coin.my_balance().compat().await);
let res = json!({
"coin": ticker,
"balance": my_balance,
"locked_by_swaps": get_locked_amount(&ctx, &ticker, &trade_fee).to_fraction(),
"address": try_s!(coin.my_address()),
});
let res = try_s! (json::to_vec (&res));
Expand Down

0 comments on commit 08d013c

Please sign in to comment.