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

profile: display balance breakdown #534

Merged
merged 23 commits into from
May 27, 2020
Merged

profile: display balance breakdown #534

merged 23 commits into from
May 27, 2020

Conversation

Patrick1904
Copy link
Contributor

@Patrick1904 Patrick1904 commented Apr 22, 2020

#481

Covered in this PR:

  • - Show balance breakdown on profile
  • - Calculate actual state stake (storageUsage (bytes) * cost per byte)
  • - Prevent user from sending/signing above available balance
  • - Make total balance equal amount + locked instead of amount
  • - Explain minimum balance (icon + tooltip)
  • - Explain available balance (icon + tooltip)
  • - Show available balance on: send, sign
  • - Make Balance component return 0 when it's actually 0

Not covered in this PR:

  • Vested balance
  • Delegated balance

@render
Copy link

render bot commented Apr 22, 2020

@render
Copy link

render bot commented Apr 22, 2020

@render
Copy link

render bot commented Apr 22, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 22, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 23, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 23, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 23, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 23, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

1 similar comment
@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 24, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@Patrick1904
Copy link
Contributor Author

@kcole16 @vgrichina for state stake: I have the storage size (storageUsage) but I'm not sure how to get the price per byte. Any idea?

@vgrichina
Copy link
Contributor

I have the storage size (storageUsage) but I'm not sure how to get the price per byte. Any idea?

@Patrick1904 no idea either. @nearmax how do we get this?

@Patrick1904
Copy link
Contributor Author

I have the storage size (storageUsage) but I'm not sure how to get the price per byte. Any idea?

@Patrick1904 no idea either. @nearmax how do we get this?

@vgrichina I got info from @kcole16 that cost per byte currently is 909 * 100_000_000_000_000_000

I set this in wallet.js
const ACCOUNT_COST_PER_BYTE = process.env.REACT_APP_ACCOUNT_COST_PER_BYTE || '90900000000000000000'

const costPerByte = new BN(ACCOUNT_COST_PER_BYTE)
const stateStaked = new BN(account.storageUsage).mul(costPerByte)

Here's result for my account with 500 NEAR
Screen Shot 2020-04-24 at 5 18 32 PM

@render
Copy link

render bot commented Apr 25, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented Apr 25, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented Apr 25, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented May 18, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@marcinbodnar
Copy link
Contributor

@Patrick1904 I also changed so Available Balance info will stay while typing, I think it might be handy if someone will like to send the max amount. It will prevent content from additional jumping so double plus.

@render
Copy link

render bot commented May 19, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented May 19, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

package.json Outdated
@@ -7,6 +7,7 @@
"connected-react-router": "^6.6.0",
"fetch-send-json": "0.0.2",
"js-sha256": "^0.9.0",
"near-api-js": "^0.25.0",
"near-ledger-js": "^0.0.4",
"near-seed-phrase": "^0.0.2",
"nearlib": "^0.22.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

nearlib should be removed


this.setState({ deletingMethod: method.kind })
deleteRecoveryMethod(method)
.then(({ error }) => {
if (error) return
loadRecoveryMethods(accountId);
Copy link
Contributor

Choose a reason for hiding this comment

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

did this get changed to load recovery methods for current account? not sure how will this play with #580

Copy link
Contributor

Choose a reason for hiding this comment

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

accountId param was unnecessary, loadRecoveryMethods was using current logged account always:
https://github.com/near/near-wallet/pull/534/files/21a8e48a3f8fac0ad033d5640c34a5e72bfe8c21#diff-b3e6d1b5726af892a08cb5d16f807a6cL17

@vgrichina
Copy link
Contributor

Looks like balance gets shortened in unfortunate ways sometimes (significant digits not displayed):

Screen Shot 2020-05-18 at 6 42 50 PM

@Patrick1904
Copy link
Contributor Author

Looks like balance gets shortened in unfortunate ways sometimes (significant digits not displayed):

Screen Shot 2020-05-18 at 6 42 50 PM

@corwinharrell do you have any ideas on how to adjust nav layout so that we can fit long account names and balances on desktop? Omitting user icon doesn't do much. Could stack the two again but think we need to adjust the design a bit then.

@marcinbodnar
Copy link
Contributor

marcinbodnar commented May 19, 2020

Looks like balance gets shortened in unfortunate ways sometimes (significant digits not displayed):

@Patrick1904 actually, the design for this part was different, it should look exactly the same as a mobile version (that's why it was the same component earlier), because we resign of image icons on every page at some point. I think that while you ware changing this part, you used old designs, it was looking like this before your changes:
1

@kcole16
Copy link
Contributor

kcole16 commented May 19, 2020

Looks like balance gets shortened in unfortunate ways sometimes (significant digits not displayed)

This is a good point, and also a bit orthogonal to this PR.

I also hope very few users with that much NEAR ever use this wallet 😅 (and then only with Ledger)

@render
Copy link

render bot commented May 19, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented May 19, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@Patrick1904
Copy link
Contributor Author

Patrick1904 commented May 19, 2020

@marcinbodnar yes the desktop stacking layout looks suboptimal IMO* (as mentioned). I believe @corwinharrell has been tinkering with a new account/profile component design for the nav that solves these issues and looks great.

*Desktop: left aligned texts + right aligned component = bad
*Mobile: left aligned texts + left aligned component = good

@heycorwin
Copy link
Contributor

One thing I want to question/challenge is the persistent display of a user's balance in the application header. I can understand that the idea behind this is to allow the user to have an idea of their balance at any given moment.

That being said, I don't think this makes sense from a security perspective. At any point that you have the application open, anyone can see your balance with a simple glance at your screen. In addition, when I want to receive funds using the QR code method, I need to show my screen to another individual and have them scan my QR code with their camera. This instance also exposes my balance when I share my screen. If I'm concerned about security, this renders the QR code function useless. In future iterations, I'd like to suggest that we keep the balance one level deeper, (user must open the navigation to see available balance) in order to account for this. Thoughts?

@Patrick1904
Copy link
Contributor Author

In future iterations, I'd like to suggest that we keep the balance one level deeper, (user must open the navigation to see available balance) in order to account for this. Thoughts?

100%

@render
Copy link

render bot commented May 20, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@render
Copy link

render bot commented May 20, 2020

Your Render PR Server at https://near-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl4f8jd5s04rr9uk0.

@render
Copy link

render bot commented May 20, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

1 similar comment
@render
Copy link

render bot commented May 20, 2020

Your Render PR Server at https://betanet-wallet-pr-534.onrender.com is now live!

View it on your dashboard at https://dashboard.render.com/static/srv-bqfpl478jd5s04rr9ufg.

@kcole16
Copy link
Contributor

kcole16 commented May 26, 2020

@vgrichina @marcinbodnar Outside of navbar balance concerns (will make separate issue), is this ready to merge?

@marcinbodnar
Copy link
Contributor

@kcole16 yes

@@ -43,8 +42,8 @@ async function getKeyMeta(publicKey) {

class Wallet {
constructor() {
this.keyStore = new nearlib.keyStores.BrowserLocalStorageKeyStore(window.localStorage, 'nearlib:keystore:')
const inMemorySigner = new nearlib.InMemorySigner(this.keyStore)
this.keyStore = new nearApiJs.keyStores.BrowserLocalStorageKeyStore(window.localStorage, 'nearlib:keystore:')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: everything here is JS, just nearApi would be enough )

@vgrichina vgrichina merged commit 8bd97cf into master May 27, 2020
@heycorwin
Copy link
Contributor

Looks like balance gets shortened in unfortunate ways sometimes (significant digits not displayed):
Screen Shot 2020-05-18 at 6 42 50 PM

@corwinharrell do you have any ideas on how to adjust nav layout so that we can fit long account names and balances on desktop? Omitting user icon doesn't do much. Could stack the two again but think we need to adjust the design a bit then.

@Patrick1904 apologies, I think I missed this when you originally posted it. Will continue to think about this while designing for in-progress issue and perhaps there's a low-lift option that offers a better solution.

@MaximusHaximus MaximusHaximus deleted the locked-balance branch July 24, 2021 02:14
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.

Recovery methods show up even when it's not profile owned by wallet
7 participants