Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(wallet): Bitcoin Balance Fetching #23117
feat(wallet): Bitcoin Balance Fetching #23117
Changes from 1 commit
04c2f87
69fcc8d
437d5d8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a thing like branded types in typescrpit but for swift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think thats
typealias
in swift. i will update. thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nuo-xu I'm not sure a
typealias
would work the same here, maybe I am misunderstanding. A typealias would essentially betypealias TokenBalanceKey = String
, but would only validate the type aString
, not validate the key is the expected value/format (bothaddress
andaccountId.uniqueKey
areString
type).I think better approach for us would be
tokenBalancesCache
from each store/view model & fetch from cache when balance is neededWalletUserAssetManager
itself so all stores/view models can share it.BlockchainToken
,AccountInfo
, etc. so the cache manager itself has control of the keys used in the cache(s).pseudocode:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specific to Bitcoin, but we need to update
balance
to be aDouble
orBDouble
on this view model and format as a String in UI code instead of view model. Right now thetotalBalance
computed property uses this string to calculate the total balance, but this value is rounded to 4 decimal places, however total balance is being displayed with 6 decimal places.So if I have a balance of 0.00001 BTC it will show as 0.000000 BTC total balance.
Since this isn't specific to Bitcoin, I opened a separate issue for this rounding bug:
brave/brave-browser#37670
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is actually an idea somehere deep in backlog to return balance in weis, satoshis, lamports, etc. So any rounding happens only when we want to display that balance on screen.
Using double in money related ares is discouraged in general