Conversation
| currencyConfig: wallet.currencyConfig, | ||
| tokenId: balanceTokenId, | ||
| nativeAmount: wallet.balanceMap.get(balanceTokenId) ?? '0' | ||
| }).displayDollarValue(exchangeRates, DECIMAL_PRECISION) |
There was a problem hiding this comment.
You can't do math with a display value. Display values are only for showing to the user, because they might do weird foreign things like using commas for decimal points.
Please add two methods to CryptoAmount called just dollarValue and fiatValue, and have them return plain numbers. You can then implement displayDollarValue and displayFiatValue by calling these two new methods, and then doing the return parseFloat(convertedAmount).toFixed(precision ?? 2) at the end, to get the display formatting. In the future, we might replace this formatting logic with something from our intl tools, in which case we would get the weird foreign stuff.
| const { route, navigation } = props | ||
| const { assetId, fiatCurrencyCode, coinRankingData: initCoinRankingData } = route.params | ||
|
|
||
| const currencyConfigMap = useSelector(state => state.core.account.currencyConfig) |
There was a problem hiding this comment.
This is wrong. You already have account on the line below, so you can either do const currencyConfigMap = account.currencyConfig, which is fine because happen to know that this particular field doesn't change, or you can do const currencyConfigMap = useWatch(account, 'currencyConfig'), which is how we generally access core properties. The useSelector hook is never supposed to reach inside core objects.
| uninitializedStakingWallets.forEach(wallet => { | ||
| if (walletStakingStateMap[wallet.id] != null && Object.keys(walletStakingStateMap[wallet.id].stakePolicies).length > 0) return | ||
| dispatch(updateStakingState(currencyCode, wallet)).catch(err => showError(err)) | ||
| }) |
There was a problem hiding this comment.
Please swap forEach for for (const wallet of uninitializedStakingWallets) { ..., and of course the return becomes a continue. We hardly ever use forEach in our codebase, and it's slower anyhow.
d83b540 to
5f2c008
Compare
5f2c008 to
1da1c51
Compare
1da1c51 to
e93e569
Compare
Also fix the Earn button loading UI and disabled state
- Remove dependency on existing wallets to gather stake information - Properly distinguish stakeable assets/wallets vs looser coinrank assets/wallets. - Fix incorrect wallet picker options from currency code overlaps between mainnet and token codes - Fix staking logic, state, effects, order of operations - Fix going to the stake scene before fully initializing stake state causes a crash - Fix `isStakingLoading` condition - Add APY text to Earn button
"Trade" is defined as bringing up a modal with Buy/Sell/Swap in `TransactionListTop` that brings you to the Exchange scene. Since the button on `CoinRankingDetails` brings you directly to the Exchange scene, this button should be `Swap`
"Select Asset to Purchase/Sell" to match the Buy/Sell scenes' modals For the rest, generic "Select Wallet" since Swap can go either direction once you are on the scene, and Earn can be both the stake and/or reward asset.
e93e569 to
e4ad258
Compare
Various fixes
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneRequirements
If you have made any visual changes to the GUI. Make sure you have: