Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,8 @@ impl From<TendermintFeeDetails> for TxFeeDetails {
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct KmdRewardsDetails {
amount: BigDecimal,
/// Note that we don't have a case where this boolean is set to false.
/// It persists here though for backward compatibility and potential future use cases.
claimed_by_me: bool,
Comment thread
shamardy marked this conversation as resolved.
Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just remove the field IMO. The BC is nothing like a big deal (people can simply remove it from their use-case). I am not even sure if there is a real-user depending on this field.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, we better remove it all together.

cc/ @shamardy what do u think? and we can edit method names to de-reflect that claimed_by_me field.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with removing it

}

Expand Down
51 changes: 8 additions & 43 deletions mm2src/coins/utxo/utxo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3318,7 +3318,6 @@ fn zer_mtp() {
}

#[test]
#[ignore]
fn test_tx_details_kmd_rewards() {
let electrum = electrum_client_for_test(&[
"electrum1.cipig.net:10001",
Expand All @@ -3332,10 +3331,11 @@ fn test_tx_details_kmd_rewards() {
);
let coin = utxo_coin_from_fields(fields);

let tx_details = get_tx_details_eq_for_both_versions(
let mut tx_details = get_tx_details_eq_for_both_versions(
&coin,
"535ffa3387d3fca14f4a4d373daf7edf00e463982755afce89bc8c48d8168024",
);
block_on(coin.update_kmd_rewards(&mut tx_details, &mut HashMap::new())).expect("!update_kmd_rewards");

let expected_fee = TxFeeDetails::Utxo(UtxoFeeDetails {
coin: Some("KMD".into()),
Expand All @@ -3354,7 +3354,6 @@ fn test_tx_details_kmd_rewards() {
/// then `TransactionDetails::kmd_rewards` has to be `Some(0)`, not `None`.
/// https://kmdexplorer.io/tx/f09e8894959e74c1e727ffa5a753a30bf2dc6d5d677cc1f24b7ee5bb64e32c7d
#[test]
#[ignore]
Comment thread
shamardy marked this conversation as resolved.
#[cfg(not(target_arch = "wasm32"))]
fn test_tx_details_kmd_rewards_claimed_by_other() {
const TX_HASH: &str = "f09e8894959e74c1e727ffa5a753a30bf2dc6d5d677cc1f24b7ee5bb64e32c7d";
Expand All @@ -3371,19 +3370,19 @@ fn test_tx_details_kmd_rewards_claimed_by_other() {
);
let coin = utxo_coin_from_fields(fields);

let tx_details = get_tx_details_eq_for_both_versions(&coin, TX_HASH);
let mut tx_details = get_tx_details_eq_for_both_versions(&coin, TX_HASH);
block_on(coin.update_kmd_rewards(&mut tx_details, &mut HashMap::new())).expect("!update_kmd_rewards");

let expected_fee = TxFeeDetails::Utxo(UtxoFeeDetails {
coin: Some("KMD".into()),
amount: BigDecimal::from_str("0.00001").unwrap(),
});
assert_eq!(tx_details.fee_details, Some(expected_fee));

let expected_kmd_rewards = KmdRewardsDetails {
amount: BigDecimal::from_str("0.00022428").unwrap(),
claimed_by_me: false,
};
assert_eq!(tx_details.kmd_rewards, Some(expected_kmd_rewards));
assert_eq!(
tx_details.kmd_rewards.unwrap().amount,
BigDecimal::from_str("0.00022428").unwrap()
);
}

#[test]
Expand Down Expand Up @@ -3436,40 +3435,6 @@ fn test_update_kmd_rewards() {
assert_eq!(tx_details.fee_details, Some(expected_fee_details));
}

#[test]
fn test_update_kmd_rewards_claimed_not_by_me() {
// The custom 535ffa3387d3fca14f4a4d373daf7edf00e463982755afce89bc8c48d8168024 transaction with the additional 'from' address.
const OUTDATED_TX_DETAILS: &str = r#"{"tx_hex":"0400008085202f8901afcadb73880bc1c9e7ce96b8274c2e2a4547415e649f425f98791685be009b73020000006b483045022100b8fbb77efea482b656ad16fc53c5a01d289054c2e429bf1d7bab16c3e822a83602200b87368a95c046b2ce6d0d092185138a3f234a7eb0d7f8227b196ef32358b93f012103b1e544ce2d860219bc91314b5483421a553a7b33044659eff0be9214ed58adddffffffff01dd15c293000000001976a91483762a373935ca241d557dfce89171d582b486de88ac99fe9960000000000000000000000000000000","tx_hash":"535ffa3387d3fca14f4a4d373daf7edf00e463982755afce89bc8c48d8168024","from":["RMGJ9tRST45RnwEKHPGgBLuY3moSYP7Mhk", "RMDc4fvQeekJwrXxuaw1R2b7CTPEuVguMP"],"to":["RMGJ9tRST45RnwEKHPGgBLuY3moSYP7Mhk"],"total_amount":"24.68539379","spent_by_me":"24.68539379","received_by_me":"24.78970333","my_balance_change":"0.10430954","block_height":2387532,"timestamp":1620705483,"fee_details":{"type":"Utxo","amount":"-0.10430954"},"coin":"KMD","internal_id":"535ffa3387d3fca14f4a4d373daf7edf00e463982755afce89bc8c48d8168024"}"#;

let electrum = electrum_client_for_test(&[
"electrum1.cipig.net:10001",
"electrum2.cipig.net:10001",
"electrum3.cipig.net:10001",
]);
let mut fields = utxo_coin_fields_for_test(electrum.into(), None, false);
fields.conf.ticker = "KMD".to_owned();
fields.derivation_method = DerivationMethod::SingleAddress(
Address::from_legacyaddress("RMGJ9tRST45RnwEKHPGgBLuY3moSYP7Mhk", &KMD_PREFIXES).unwrap(),
);
let coin = utxo_coin_from_fields(fields);

let mut input_transactions = HistoryUtxoTxMap::default();
let mut tx_details: TransactionDetails = json::from_str(OUTDATED_TX_DETAILS).unwrap();
block_on(coin.update_kmd_rewards(&mut tx_details, &mut input_transactions)).expect("!update_kmd_rewards");

let expected_rewards = KmdRewardsDetails {
amount: BigDecimal::from_str("0.10431954").unwrap(),
claimed_by_me: false,
};
assert_eq!(tx_details.kmd_rewards, Some(expected_rewards));

let expected_fee_details = TxFeeDetails::Utxo(UtxoFeeDetails {
coin: Some("KMD".into()),
amount: BigDecimal::from_str("0.00001").unwrap(),
});
assert_eq!(tx_details.fee_details, Some(expected_fee_details));
}

/// https://github.com/KomodoPlatform/atomicDEX-API/issues/966
#[test]
fn test_parse_tx_with_huge_locktime() {
Expand Down
Loading