Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tx value for atomic name swap finalize #296

Merged
merged 1 commit into from
Apr 18, 2021

Conversation

rithvikvibhu
Copy link
Collaborator

Fixes #292.

The value for atomic name swaps show up as 0. This PR shows the +ve/-ve amount for seller/buyer.

Note: I could only test with 2 name swaps, probably needs more testing. Also not sure if this is the best way to get the values, it's the shortest I could think of.

For the example below, 2 names transferred, c/ for 50 HNS, d/ without payment.

Sender:
image

Receiver:
image

@pinheadmz
Copy link
Contributor

I think it'd be awesome if you could actually expand this list to include something like Received Payment for Finalize and Finalized With Payment

} else if (tx.type === 'FINALIZE') {
description = 'Finalized Domain';
content = this.formatDomain(tx.meta.domain);

// Renewals and Updates have a value, but it doesn't
// affect the spendable balance of the wallet.
if (covenant.action === 'RENEW' ||
covenant.action === 'UPDATE' ||
covenant.action === 'TRANSFER' ||
covenant.action === 'FINALIZE') {
covenant.action === 'TRANSFER') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I could be wrong but I think if the wallet is receiving payment for a FINALIZE, then the payment value might just be equal to totalValue calculated above. I'm not sure if that'll work for the buyer though (who is sending money) but might save you some of the logic in the blob L371-390

Copy link
Collaborator Author

@rithvikvibhu rithvikvibhu Jan 27, 2021

Choose a reason for hiding this comment

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

Yup, this works for the seller and I initially tried this (but outside the for loop because totalValue won't be complete inside the loop).

if (covAction) {
    return {
      ...covData,
      fee: tx.fee,
      value: covenant.action === 'FINALIZE' ? totalValue : covValue, // <- instead of just covValue
    };
  }

Like you said, this only works for the seller, not buyer. There's also a problem of identifying if the value is +ve or -ve.

@rithvikvibhu rithvikvibhu marked this pull request as draft January 27, 2021 05:28
@rithvikvibhu
Copy link
Collaborator Author

Rebased on master (well actually started from scratch). Now it works properly, tested with names with actual value. Finalize with/without work. Also updated transaction labels.

Seller's side (no payment, with payment):
image

Buyer's side (no payment, with payment):
image

@rithvikvibhu rithvikvibhu marked this pull request as ready for review March 30, 2021 03:58
@chikeichan chikeichan merged commit 8723c0b into kyokan:master Apr 18, 2021
@rithvikvibhu rithvikvibhu deleted the atomic-swap-tx-values branch April 18, 2021 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Atomic swap feature not showing received funds as a transaction
3 participants