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

Agent: use formatTokenAmount() and add rounding tooltip #1148

Merged
merged 16 commits into from
Jun 10, 2020

Conversation

ECWireless
Copy link
Contributor

@ECWireless ECWireless commented May 18, 2020

This first commit simply re-adds the reverts @bpierre made in #1121

Fixes #1157 #756 #1065 #1128.

This PR is still a work in progress. @bpierre are there any other issues I could tack onto this PR?

To do:

  • Add rounding tooltip
  • Add formatTokenAmount() from UI
  • Align the BalanceToken.js, Balances.js, and Transfers.js components between the Finance and Agent app
  • Use BN.js values everywhere

ECWireless and others added 2 commits May 17, 2020 17:35
@bpierre
Copy link
Contributor

bpierre commented May 22, 2020

@ECWireless Thank you for this!

@bpierre are there any other issues I could tack onto this PR?

I think we might want to reproduce all the changes made in #1121, because the codebase of the two apps is really similar:

  • Use BN.js values everywhere.
  • Move to aragonUI’s formatTokenAmount().
  • Add the tooltip when an amount is rounded (what you did already).
  • Align the Balances.js and Transfers.js components between the two apps.

Let me know if you need anything!

- Adds formatTokenAmount() and BN.js values everywhere applicable except in useDownloadData.js.
@ECWireless
Copy link
Contributor Author

@bpierre @Evalir sorry for the long delay in adding more to this; just finished moving from one side of the US to the other... But I've made a few more additions to the Agent App! This primarily includes just adding formatTokenAmount() from aragon/ui, as well as BN.js, into any appropriate files.

I believe the only other file that needs updated is useDownloadData.js, although I'm having trouble testing out changes since Chrome is blocking all downloads from iFrames. Not sure if there is an easy way around this...

But let me know what you think! I'll keep messing around with useDownloadData.js in the meantime.

@sohkai
Copy link
Contributor

sohkai commented Jun 8, 2020

I believe the only other file that needs updated is useDownloadData.js, although I'm having trouble testing out changes since Chrome is blocking all downloads from iFrames. Not sure if there is an easy way around this...

Ah, this is a good catch. We may need to update our allow directive to include allow-downloads on the iframe.

@sohkai
Copy link
Contributor

sohkai commented Jun 9, 2020

On the above, this is fixed with: aragon/client#1436.

@sohkai sohkai changed the title Agent: formatTokenAmount() and Rounding Tooltip Agent: use formatTokenAmount() and add rounding tooltip Jun 9, 2020
- formatTokenAmount() from utils
- formatDecimals() from utils
- ROUNDING_AMOUNT from utils
- LOCALE_US_FORMAT from locales
- round() from math-utils
@ECWireless
Copy link
Contributor Author

@bpierre and @Evalir Finishing touches have just been added, including updates to useDownloadData.js and the removal of formatTokenAmount() (and associated functions) from utils. Let me know about any changes that need made!

@sohkai
Copy link
Contributor

sohkai commented Jun 9, 2020

@ECWireless I'm wondering if we could double check and align the BalanceToken.js, Balances.js, and Transfers.js files from #1121, as we've updated them there!

I know for BalanceToken and Balances, we should probably be able to just copy the files over!

@ECWireless
Copy link
Contributor Author

@sohkai Ah, got it! I just copied over BalanceToken.js and Balances.js and everything works fine. It looks like Finance's Transfers.js and Agent's Transactions.js can't simply be copied between each other though, so I'll go through it again and try to align it a bit more.

@ECWireless
Copy link
Contributor Author

@sohkai I believe Agent's Transactions.js and Finance's Transfers.js are pretty well aligned now. I double-checked it, and all I found was a repeated 'symbol' (because of adding formatTokenAmount() from the UI).

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Looking super good @ECWireless! We're almost there 🏁!

I noticed a few last things that I wanted to check!

@@ -257,11 +257,9 @@ const Transactions = React.memo(function Transactions({

const { symbol, decimals } = tokenDetails[toChecksumAddress(token)]
const formattedAmount = formatTokenAmount(
amount,
isIncoming,
isIncoming ? amount : -Math.abs(amount),
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, do we only have a BN object for amount at this moment? Otherwise, we should use amount.neg().

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see why now.

I've updated the frontend reducers to push BNs into these transfer objects so we can transparently consume them as BNs elsewhere :).

apps/agent/app/src/components/Transactions.js Outdated Show resolved Hide resolved
Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

🙌 👌 🙏 ✅ Thanks @ECWireless, this was a great PR! Very excited to get this out!

I've just pushed a few commits to align it again with Finance and update the state to be BN-centric :).

@sohkai sohkai merged commit 9bcd8e1 into aragon:master Jun 10, 2020
@welcome
Copy link

welcome bot commented Jun 10, 2020

Congrats on merging your first pull request! Aragon is proud of you 🦅
Eagle gif

@ECWireless ECWireless deleted the ecwireless-agent-balance-round-bnjs branch June 10, 2020 16:57
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finance, Agent: show exact token balances
3 participants