-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multi currency support (#1873)
* chore: update packages * chore: add new headers * feat: add new translations * feat: add fiat market data * feat: fetch fiat market data in app context * chore: blacklist large things from redux store * fix: more correct type defs and balance chart fixes * chore: fix headers comment * chore: consolidate to priceAtDate * chore: only upgrade market service package * chore: use same source of truth for mock test data as real data structure * fix: optimizations and bug fixes * fix: market data refetch * chore: rename booleans for readability * chore: tighter type def for setFiatMarketData * chore: freeze initial price history for safety * chore: uppercase const * chore: consistent market data selector naming * feat: view layer changes to support multi currency display * feat: add currency selection to settings modal * chore: add multi currency feature flag * feat: balance chart changes * chore: delete duplicate test with wrong file extension * chore: cache fee asset selector * Revert "chore: cache fee asset selector" This reverts commit dfcd3d0. * fix: revert chart loading behaviour * fix: default fiatType to USD * test: fix useLocaleFormatter test * chore: delete unnecessary locale renderers * chore: revert unnecessary changes to locale formatter * fix: improved number formatting * feat: currency format settings * fix: test case fixed * fix: improved input parsing * chore: fix typo * feat: walletconnect wallet (#1733) * feat: init walletconnect integration * chore: lint * fix: wallet init * fix: wallet init * fix: add imagedelivery to headers * chore: use package version * chore: show/hide WalletConnect based on flag * fix: headers for macos/ios safari * fix: show feature flag nav item for alt host * perf: add env var for better local development * chore: remove unecessary code * chore: remove package dep * chore: add hdwallet-walletconnect alpha dependency * fix: add walletconnect csp entries * fix: utilize feature flag * fix: add mobileEnabled field to WalletConnect config * chore: run linter * fix: remove usage of process.env * chore: run linter * fix: apply code review suggestions * fix: use structured logging * fix: apply code review suggestions * fix: update csp for wallet logos * chore: add flag to sample.env * chore: yarn.lock * docs: fleek info * fix: img source csp * chore: revert readme to develop * fix: image fetched by walletconnect * feat: WalletConnect rejection * chore: lint * chore: lint * chore: update hdwallet-walletconnect dependency * chore: upgrade hdwallet-walletconnect * fix: set wc connect modal error to null on init * chore: run linter * fix: walletconnect refresh bug * chore: upgrade hdwallet dependency * chore: bump hdwallet dependencies * fix: csp for walletconnect desktop logos * chore: bump hdwallet package versions * fix: disable trade max with walletconnect * fix: disable sendmax with walletconnect * chore: run linter * chore: update hdwallet dependencies * chore: run linter * fix: hide fiat sendMax with WalletConnect * fix: stylistic changes * fix: typo * feat: add copy to walletconnect option in selectmodal * fix: constrain icon width for selectmodal options * fix: update return value Co-authored-by: pastaghost <[email protected]> Co-authored-by: 0xdef1cafe <[email protected]> * chore(deps): bump terser from 4.8.0 to 4.8.1 (#2197) Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: dogecoin (#2185) * feat: dogecoin initial * add dogecoin * use p2pkh accountType for dgubs add dogecoin else if to handleSend :( add dogecoin case to handleSendMax :( :( * wrap doge plugin in a feature flag * pass chainId to utxoAccountParams * remove reference to dogecoin testnet * web clean up * fix: update old utility to new caip method * chore: add REACT_APP_FEATURE_DOGECOIN=true to sample.env * fix: update swapper logic to pass correct param * chore: version bump doge libs * fix: add dogecoin label to accounts page * fix: don't show tokens under dogecoin account Co-authored-by: 0xdef1cafe <[email protected]> Co-authored-by: Apotheosis <[email protected]> * fix: typo and lodash import * fix: conflict resolved * feat: keeping order of fiat currencies and currency formats * fix: applying suggested changes Co-authored-by: stackedQ <[email protected]> Co-authored-by: Grant Steuart <[email protected]> Co-authored-by: pastaghost <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Adam Samere <[email protected]> Co-authored-by: Apotheosis <[email protected]> Co-authored-by: reallybeard <[email protected]>
- Loading branch information
1 parent
1352c89
commit 56ba3b5
Showing
33 changed files
with
439 additions
and
166 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { ArrowBackIcon } from '@chakra-ui/icons' | ||
import { Button, Flex, Icon, IconButton, ModalBody, ModalHeader } from '@chakra-ui/react' | ||
import identity from 'lodash/identity' | ||
import sortBy from 'lodash/sortBy' | ||
import { FaCheck } from 'react-icons/fa' | ||
import { useTranslate } from 'react-polyglot' | ||
import { useHistory } from 'react-router-dom' | ||
import { SlideTransition } from 'components/SlideTransition' | ||
import { RawText } from 'components/Text' | ||
import { CurrencyFormats, preferences } from 'state/slices/preferencesSlice/preferencesSlice' | ||
import { selectCurrencyFormat } from 'state/slices/selectors' | ||
import { useAppDispatch, useAppSelector } from 'state/store' | ||
|
||
import { currencyFormatsRepresenter } from './SettingsCommon' | ||
|
||
export const CurrencyFormat = () => { | ||
const dispatch = useAppDispatch() | ||
const currentCurrencyFormat = useAppSelector(selectCurrencyFormat) | ||
const translate = useTranslate() | ||
const history = useHistory() | ||
const { goBack } = history | ||
const formats = sortBy(CurrencyFormats, identity) | ||
const { setCurrencyFormat } = preferences.actions | ||
|
||
return ( | ||
<SlideTransition> | ||
<IconButton | ||
variant='ghost' | ||
icon={<ArrowBackIcon />} | ||
aria-label={translate('common.back')} | ||
position='absolute' | ||
top={2} | ||
left={3} | ||
fontSize='xl' | ||
size='sm' | ||
isRound | ||
onClick={goBack} | ||
/> | ||
<ModalHeader textAlign='center'>{translate('modals.settings.currencyFormat')}</ModalHeader> | ||
<> | ||
<ModalBody | ||
alignItems='center' | ||
justifyContent='center' | ||
textAlign='center' | ||
maxHeight='400' | ||
overflowY='auto' | ||
overflowX='hidden' | ||
> | ||
{formats.map(currencyFormat => { | ||
const active = currencyFormat === currentCurrencyFormat | ||
const buttonProps = active | ||
? { | ||
disabled: true, | ||
_disabled: { opacity: 1 }, | ||
} | ||
: { | ||
pl: 8, | ||
variant: 'ghost', | ||
onClick: () => dispatch(setCurrencyFormat({ currencyFormat })), | ||
} | ||
return ( | ||
<Button | ||
mb={2} | ||
width='full' | ||
justifyContent='flexStart' | ||
key={currencyFormat} | ||
{...buttonProps} | ||
> | ||
<Flex alignItems='center' textAlign='left'> | ||
{active && <Icon as={FaCheck} color='blue.500' />} | ||
<Flex ml={4}> | ||
<RawText>{currencyFormatsRepresenter[currencyFormat]}</RawText> | ||
</Flex> | ||
</Flex> | ||
</Button> | ||
) | ||
})} | ||
</ModalBody> | ||
</> | ||
</SlideTransition> | ||
) | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { ArrowBackIcon } from '@chakra-ui/icons' | ||
import { Button, Flex, Icon, IconButton, ModalBody, ModalHeader } from '@chakra-ui/react' | ||
import { SupportedFiatCurrencies, SupportedFiatCurrenciesList } from '@shapeshiftoss/market-service' | ||
import identity from 'lodash/identity' | ||
import sortBy from 'lodash/sortBy' | ||
import { FaCheck } from 'react-icons/fa' | ||
import { useTranslate } from 'react-polyglot' | ||
import { useHistory } from 'react-router-dom' | ||
import { SlideTransition } from 'components/SlideTransition' | ||
import { RawText, Text } from 'components/Text' | ||
import { preferences } from 'state/slices/preferencesSlice/preferencesSlice' | ||
import { selectSelectedCurrency } from 'state/slices/selectors' | ||
import { useAppDispatch, useAppSelector } from 'state/store' | ||
|
||
export const FiatCurrencies = () => { | ||
const dispatch = useAppDispatch() | ||
const selectedCurrency = useAppSelector(selectSelectedCurrency) | ||
const translate = useTranslate() | ||
const history = useHistory() | ||
const { goBack } = history | ||
const defaultCurrency: SupportedFiatCurrencies = 'USD' | ||
const allFiatCurrencies = sortBy(SupportedFiatCurrenciesList, item => | ||
// keep default currency at the top of the list | ||
item === defaultCurrency ? defaultCurrency : identity, | ||
) | ||
const { setSelectedCurrency } = preferences.actions | ||
|
||
return ( | ||
<SlideTransition> | ||
<IconButton | ||
variant='ghost' | ||
icon={<ArrowBackIcon />} | ||
aria-label={translate('common.back')} | ||
position='absolute' | ||
top={2} | ||
left={3} | ||
fontSize='xl' | ||
size='sm' | ||
isRound | ||
onClick={goBack} | ||
/> | ||
<ModalHeader textAlign='center'>{translate('modals.settings.currency')}</ModalHeader> | ||
<> | ||
<ModalBody | ||
alignItems='center' | ||
justifyContent='center' | ||
textAlign='center' | ||
maxHeight='400' | ||
overflowY='auto' | ||
overflowX='hidden' | ||
> | ||
{allFiatCurrencies.map(currency => { | ||
const active = currency === selectedCurrency | ||
const buttonProps = active | ||
? { | ||
disabled: true, | ||
_disabled: { opacity: 1 }, | ||
} | ||
: { | ||
pl: 8, | ||
variant: 'ghost', | ||
onClick: () => dispatch(setSelectedCurrency({ currency })), | ||
} | ||
return ( | ||
<Button | ||
width='full' | ||
justifyContent='flexStart' | ||
key={currency} | ||
mb={2} | ||
{...buttonProps} | ||
> | ||
<Flex alignItems='center' textAlign='left'> | ||
{active && <Icon as={FaCheck} color='blue.500' />} | ||
<Flex ml={4}> | ||
<RawText>{currency}</RawText> | ||
<RawText mx={2}>-</RawText> | ||
<Text translation={`modals.settings.currencies.${currency}`} /> | ||
</Flex> | ||
</Flex> | ||
</Button> | ||
) | ||
})} | ||
</ModalBody> | ||
</> | ||
</SlideTransition> | ||
) | ||
} |
Oops, something went wrong.