This repository was archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 357
(Feature) Balances enhancements #1122
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
5602812
Fix ts error
Agupane ac742d8
Add skeleton for loading balance value
Agupane 0c7c5aa
Fix texts in uppercase
Agupane 2b8056e
Adds ETH Icon in currencyValues dropdown
Agupane e7693d2
Adds getExchangeRatesUrlFallback
Agupane 762861d
Alphabetically sort currencies
Agupane a12b62a
Add types
Agupane 672d8f4
Type formatAmount
Agupane fc866db
Adds formatAmountInUsFormat util function
Agupane 4676074
Add types
Agupane 3c5e37a
Updates max and min fraction digits on formatAmountInUsFormat
Agupane 5aac964
Updates max and min fraction digits on formatAmountInUsFormat
Agupane 4648ac0
Add types
Agupane 188f8fb
Fix currencyValues types
Agupane f4ae546
Adds safeFiatBalancesTotalSelector
Agupane 2ec2a6b
Adds total balance to safe header
Agupane b490b16
Merge branch 'development' of https://github.com/gnosis/safe-react in…
Agupane 91eb070
Fix types
Agupane 931d0ce
Adds currentCurrency on header
Agupane 31f1ce0
Adds types to getTokenPriceInCurrency
Agupane 58168eb
Fix balance currency rate conversion
Agupane 0318452
Add guards for modules
Agupane dc44932
Merge branch 'fix-add-type-guards' into balances-enhacements
Agupane f32e606
Add guards for modules
Agupane 039ae42
Merge branch 'fix-add-type-guards' into balances-enhacements
Agupane 753ff66
Uses console error for api
Agupane 302125b
Remove anys
Agupane c673bc3
Redefine CurrencyRateValue types into CurrencyRateValueRecord
Agupane a90ecd9
Redefine test texts
Agupane c7a0be0
Use absolute imports
Agupane d738355
Merge branch 'development' into balances-enhacements
Agupane c33621e
Add types to dispatch
Agupane 3aca31e
Merge branch 'development' into balances-enhacements
mmv08 8e3cd29
Merge branch 'development' into balances-enhacements
mmv08 5a23d8f
Add guard for no balance value
Agupane 9239ada
Merge remote-tracking branch 'origin/balances-enhacements' into balan…
Agupane 9dc19b3
Fix ESLINT warning
Agupane 5de5096
Add types
Agupane a2d906f
Merge branch 'development' of https://github.com/gnosis/safe-react in…
Agupane e38c379
Fix no balance case
Agupane 2b89b22
Use optional chaining
Agupane b365fb9
Absolute paths
Agupane a695029
Adds return types
Agupane 698f708
Remove number as type for formatAmountInUsFormat
Agupane 2500d73
Uses createStyles to remove any types
Agupane 60a78c4
Improve total balances display
Agupane 466dc0e
Fix balances value column
Agupane c21fac2
formatAmountInUsFormat feedback
Agupane c8e5cea
Force boolean evaluation
Agupane 4a66110
Fix totalBalance heading styles
Agupane 8c2563f
Add types
Agupane 2bfc415
Add types to fetchTokenCurrenciesBalances endpoint
Agupane ecf3ed9
Replaces coinbase dependency by backend for ETH price in USD
Agupane e3bf715
Merge branch 'development' into balances-enhacements
mmv08 b1d6ae3
Absolute paths
Agupane 00f24e3
Replaces RecordOf<TokenProps> with Token
Agupane be90cf3
Merge remote-tracking branch 'origin/balances-enhacements' into balan…
Agupane 8625248
Feedback
Agupane 5d3b2ac
Merge branch 'development' into balances-enhacements
Agupane 91cd4e4
Trigger buid
Agupane 365b5d3
Merge remote-tracking branch 'origin/balances-enhacements' into balan…
Agupane 30bd83f
Merge branch 'development' into balances-enhacements
mmv08 d9b6b6e
Types
Agupane 1ef9d4a
Merge remote-tracking branch 'origin/balances-enhacements' into balan…
Agupane 5391083
Fix tests order
Agupane 1efec3a
Renames numberFormat to usNumberFormatter
Agupane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
src/logic/currencyValues/api/fetchTokenCurrenciesBalances.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,58 @@ | ||
| import { List } from 'immutable' | ||
| import { List, Map, RecordOf } from 'immutable' | ||
| import { createSelector } from 'reselect' | ||
|
|
||
| import { CURRENCY_VALUES_KEY } from 'src/logic/currencyValues/store/reducer/currencyValues' | ||
| import { safeParamAddressFromStateSelector } from 'src/routes/safe/store/selectors' | ||
| import { AppReduxState } from 'src/store/index' | ||
| import { | ||
| AVAILABLE_CURRENCIES, | ||
| BalanceCurrencyRecord, | ||
| CurrencyRateValue, | ||
| CurrencyRateValueRecord, | ||
| } from 'src/logic/currencyValues/store/model/currencyValues' | ||
| import { BigNumber } from 'bignumber.js' | ||
|
|
||
| export const currencyValuesSelector = (state) => state[CURRENCY_VALUES_KEY] | ||
| export const currencyValuesSelector = (state: AppReduxState): Map<string, RecordOf<CurrencyRateValue>> => | ||
| state[CURRENCY_VALUES_KEY] | ||
|
|
||
| export const safeFiatBalancesSelector = createSelector( | ||
| currencyValuesSelector, | ||
| safeParamAddressFromStateSelector, | ||
| (currencyValues, safeAddress) => { | ||
| (currencyValues, safeAddress): CurrencyRateValueRecord => { | ||
| if (!currencyValues) return | ||
| return currencyValues.get(safeAddress) | ||
| }, | ||
| ) | ||
|
|
||
| export const safeFiatBalancesListSelector = createSelector(safeFiatBalancesSelector, (currencyValuesMap) => { | ||
| if (!currencyValuesMap) return | ||
| return currencyValuesMap.get('currencyBalances') ? currencyValuesMap.get('currencyBalances') : List([]) | ||
| }) | ||
| export const safeFiatBalancesListSelector = createSelector( | ||
| safeFiatBalancesSelector, | ||
| (currencyValuesMap): List<BalanceCurrencyRecord> => { | ||
| if (!currencyValuesMap) return | ||
| return currencyValuesMap.get('currencyBalances') ? currencyValuesMap.get('currencyBalances') : List([]) | ||
| }, | ||
| ) | ||
|
|
||
| export const currentCurrencySelector = createSelector(safeFiatBalancesSelector, (currencyValuesMap) => | ||
| currencyValuesMap ? currencyValuesMap.get('selectedCurrency') : null, | ||
| export const currentCurrencySelector = createSelector( | ||
| safeFiatBalancesSelector, | ||
| (currencyValuesMap): AVAILABLE_CURRENCIES | null => | ||
| currencyValuesMap ? currencyValuesMap.get('selectedCurrency') : null, | ||
| ) | ||
|
|
||
| export const currencyRateSelector = createSelector(safeFiatBalancesSelector, (currencyValuesMap) => | ||
| export const currencyRateSelector = createSelector(safeFiatBalancesSelector, (currencyValuesMap): number | null => | ||
| currencyValuesMap ? currencyValuesMap.get('currencyRate') : null, | ||
| ) | ||
|
|
||
| export const safeFiatBalancesTotalSelector = createSelector( | ||
| safeFiatBalancesListSelector, | ||
| currencyRateSelector, | ||
| (currencyBalances, currencyRate): string | null => { | ||
| if (!currencyBalances) return '0' | ||
| if (!currencyRate) return null | ||
|
|
||
| const totalInBaseCurrency = currencyBalances.reduce((total, balanceCurrencyRecord) => { | ||
| return total.plus(balanceCurrencyRecord.balanceInBaseCurrency) | ||
| }, new BigNumber(0)) | ||
|
|
||
| return totalInBaseCurrency.times(currencyRate).toFixed(2) | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.