Skip to content

Commit

Permalink
tokens refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rastajpa committed Sep 29, 2022
1 parent 43d4e4a commit 87d99a6
Show file tree
Hide file tree
Showing 25 changed files with 338 additions and 356 deletions.
18 changes: 9 additions & 9 deletions src/constants/SupportedCurrencyOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export const CurrencyListIcons: {
doge: props => <DogeIcon {...props} />,
ltc: props => <LtcIcon {...props} />,
xrp: props => <XrpIcon {...props} />,
usdc: props => <UsdcIcon {...props} />,
gusd: props => <GusdIcon {...props} />,
busd: props => <BusdIcon {...props} />,
dai: props => <DaiIcon {...props} />,
usdp: props => <UsdpIcon {...props} />,
wbtc: props => <WbtcIcon {...props} />,
shib: props => <ShibIcon {...props} />,
ape: props => <ApeIcon {...props} />,
euroc: props => <EurocIcon {...props} />,
usdc_e: props => <UsdcIcon {...props} />,
gusd_e: props => <GusdIcon {...props} />,
busd_e: props => <BusdIcon {...props} />,
dai_e: props => <DaiIcon {...props} />,
usdp_e: props => <UsdpIcon {...props} />,
wbtc_e: props => <WbtcIcon {...props} />,
shib_e: props => <ShibIcon {...props} />,
ape_e: props => <ApeIcon {...props} />,
euroc_e: props => <EurocIcon {...props} />,
};

export const SupportedUtxoCurrencyOptions: Array<SupportedCurrencyOption> = [
Expand Down
7 changes: 7 additions & 0 deletions src/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ export const TWO_FACTOR_EMAIL_POLL_TIMEOUT = 1000 * 60 * 5;
export const COINGECKO_BLOCKCHAIN_NETWORK = {
eth: 'ethereum',
};

// 1Inch
export const ONEINCH_BLOCKCHAIN_ID: {[key in string]: number} = {
eth: 1,
// TODO MATIC
// matic: 137,
};
56 changes: 32 additions & 24 deletions src/constants/currencies.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export type SupportedCoins = 'btc' | 'bch' | 'ltc' | 'doge' | 'eth';
export type SupportedEthereumTokens =
| 'usdc'
| 'gusd'
| 'usdp'
| 'pax' // backward compatibility
| 'busd'
| 'dai'
| 'wbtc'
| 'shib'
| 'ape'
| 'euroc';
| 'usdc_e'
| 'gusd_e'
| 'usdp_e'
| 'pax_e' // backward compatibility
| 'busd_e'
| 'dai_e'
| 'wbtc_e'
| 'shib_e'
| 'ape_e'
| 'euroc_e';
export type SupportedCurrencies = SupportedCoins | SupportedEthereumTokens;
export type EVM_CHAINS = 'eth';
export type UTXO_CHAINS = 'btc' | 'bch' | 'doge' | 'ltc';
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface CurrencyOpts {
}

export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
busd: {
busd_e: {
name: 'Binance USD Coin',
chain: 'eth',
coin: 'busd',
Expand Down Expand Up @@ -98,7 +98,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: 'rgba(30,144,255, 0.2)',
},
},
usdp: {
usdp_e: {
name: 'Paxos Dollar',
chain: 'eth',
coin: 'usdp',
Expand Down Expand Up @@ -135,7 +135,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#00845d',
},
},
pax: {
pax_e: {
// backward compatibility
name: 'Paxos Standard',
chain: 'eth',
Expand Down Expand Up @@ -173,7 +173,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#00845d',
},
},
usdc: {
usdc_e: {
name: 'USD Coin',
chain: 'eth',
coin: 'usdc',
Expand Down Expand Up @@ -210,7 +210,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#2775c9',
},
},
gusd: {
gusd_e: {
name: 'Gemini Dollar',
chain: 'eth',
coin: 'gusd',
Expand Down Expand Up @@ -247,7 +247,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#00dcfa',
},
},
dai: {
dai_e: {
name: 'DAI',
chain: 'eth',
coin: 'dai',
Expand Down Expand Up @@ -284,7 +284,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#F5AC37',
},
},
wbtc: {
wbtc_e: {
name: 'Wrapped Bitcoin',
chain: 'eth',
coin: 'wbtc',
Expand Down Expand Up @@ -321,7 +321,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#282A47',
},
},
shib: {
shib_e: {
name: 'SHIBA INU',
chain: 'eth',
coin: 'shib',
Expand Down Expand Up @@ -359,7 +359,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#F00500',
},
},
ape: {
ape_e: {
name: 'ApeCoin',
chain: 'eth',
coin: 'ape',
Expand Down Expand Up @@ -397,7 +397,7 @@ export const BitpaySupportedEthereumTokens: {[key in string]: CurrencyOpts} = {
gradientBackgroundColor: '#0054F9',
},
},
euroc: {
euroc_e: {
name: 'Euro Coin',
chain: 'eth',
coin: 'euroc',
Expand Down Expand Up @@ -665,11 +665,21 @@ export const BitpaySupportedEvmCoins: {[key in string]: CurrencyOpts} = {
},
};

export const BitpaySupportedTokens: {[key in string]: CurrencyOpts} = {
...BitpaySupportedEthereumTokens,
// TODO MATIC
};

export const BitpaySupportedCoins: {[key in string]: CurrencyOpts} = {
...BitpaySupportedUtxoCoins,
...BitpaySupportedEvmCoins,
};

export const BitpaySupportedCurrencies: {[key in string]: CurrencyOpts} = {
...BitpaySupportedCoins,
...BitpaySupportedTokens,
};

export const POPULAR_TOKENS = [
'UNI',
'SUSHI',
Expand Down Expand Up @@ -698,8 +708,6 @@ export const SUPPORTED_EVM_COINS = Object.keys(BitpaySupportedEvmCoins);
export const SUPPORTED_ETHEREUM_TOKENS = Object.keys(
BitpaySupportedEthereumTokens,
);
// TODO MATIC
export const SUPPORTED_COINS = Object.keys(BitpaySupportedCoins);
export const SUPPORTED_CURRENCIES = [
...SUPPORTED_COINS,
...SUPPORTED_ETHEREUM_TOKENS,
];
export const SUPPORTED_CURRENCIES = Object.keys(BitpaySupportedCurrencies);
38 changes: 19 additions & 19 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,62 @@ export const TokensListAPIUrl =
'https://bitpay.api.enterprise.1inch.exchange/v3.0/1/tokens';

export const BitpaySupportedEthereumTokenOpts: TokenOptsType = {
usdc: {
usdc_e: {
name: 'USD Coin',
symbol: 'USDC',
decimals: 6,
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
},
usdp: {
usdp_e: {
name: 'Paxos Dollar',
symbol: 'USDP',
decimals: 18,
address: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
},
pax: {
pax_e: {
// backward compatibility
name: 'Paxos Standard',
symbol: 'PAX',
decimals: 18,
address: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
},
gusd: {
gusd_e: {
name: 'Gemini Dollar',
symbol: 'GUSD',
decimals: 2,
address: '0x056fd409e1d7a124bd7017459dfea2f387b6d5cd',
},
busd: {
busd_e: {
name: 'Binance USD Coin',
symbol: 'BUSD',
decimals: 18,
address: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
},
dai: {
dai_e: {
name: 'Dai',
symbol: 'DAI',
decimals: 18,
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
},
wbtc: {
wbtc_e: {
name: 'Wrapped Bitcoin',
symbol: 'WBTC',
decimals: 9,
address: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
},
shib: {
shib_e: {
name: 'SHIBA INU',
symbol: 'SHIB',
decimals: 18,
address: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
},
ape: {
ape_e: {
name: 'ApeCoin',
symbol: 'APE',
decimals: 18,
address: '0x4d224452801ACEd8B2F0aebE155379bb5D594381',
},
euroc: {
euroc_e: {
name: 'Euro Coin',
symbol: 'EUROC',
decimals: 18,
Expand All @@ -72,55 +72,55 @@ export const BitpaySupportedEthereumTokenOpts: TokenOptsType = {
};

export const BitpaySupportedEthereumTokenOptsByAddress: TokenOptsType = {
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': {
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e': {
name: 'USD Coin',
symbol: 'USDC',
decimals: 6,
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
},
'0x8e870d67f660d95d5be530380d0ec0bd388289e1': {
'0x8e870d67f660d95d5be530380d0ec0bd388289e1_e': {
name: 'Paxos Dollar',
symbol: 'USDP',
decimals: 18,
address: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
},
'0x056fd409e1d7a124bd7017459dfea2f387b6d5cd': {
'0x056fd409e1d7a124bd7017459dfea2f387b6d5cd_e': {
name: 'Gemini Dollar',
symbol: 'GUSD',
decimals: 2,
address: '0x056fd409e1d7a124bd7017459dfea2f387b6d5cd',
},
'0x4fabb145d64652a948d72533023f6e7a623c7c53': {
'0x4fabb145d64652a948d72533023f6e7a623c7c53_e': {
name: 'Binance USD Coin',
symbol: 'BUSD',
decimals: 18,
address: '0x4fabb145d64652a948d72533023f6e7a623c7c53',
},
'0x6b175474e89094c44da98b954eedeac495271d0f': {
'0x6b175474e89094c44da98b954eedeac495271d0f_e': {
name: 'Dai',
symbol: 'DAI',
decimals: 18,
address: '0x6b175474e89094c44da98b954eedeac495271d0f',
},
'0x2260fac5e5542a773aa44fbcfedf7c193bc2c599': {
'0x2260fac5e5542a773aa44fbcfedf7c193bc2c599_e': {
name: 'Wrapped Bitcoin',
symbol: 'WBTC',
decimals: 9,
address: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
},
'0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce': {
'0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce_e': {
name: 'SHIBA INU',
symbol: 'SHIB',
decimals: 18,
address: '0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce',
},
'0x4d224452801ACEd8B2F0aebE155379bb5D594381': {
'0x4d224452801ACEd8B2F0aebE155379bb5D594381_e': {
name: 'ApeCoin',
symbol: 'APE',
decimals: 18,
address: '0x4d224452801ACEd8B2F0aebE155379bb5D594381',
},
'0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c': {
'0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c_e': {
name: 'Euro Coin',
symbol: 'EUROC',
decimals: 18,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import {Black, White} from '../../../../styles/colors';
import styled from 'styled-components/native';
import SheetModal from '../../../../components/modal/base/sheet/SheetModal';
import {includes, sortBy} from 'lodash';
import {
BitpaySupportedCoins,
BitpaySupportedEthereumTokens,
} from '../../../../constants/currencies';
import {SUPPORTED_CURRENCIES} from '../../../../constants/currencies';

const GlobalSelectContainer = styled.View`
flex: 1;
Expand All @@ -29,13 +26,9 @@ const WalletSelectorModal: React.FC<WalletSelectorModalProps> = ({
onDismiss,
modalTitle,
}) => {
const BitpaySupportedCurrencies: string[] = {
...Object.keys(BitpaySupportedCoins),
...Object.keys(BitpaySupportedEthereumTokens),
};
const sortedCustomSupportedCurrencies = sortBy(
customSupportedCurrencies,
coin => (includes(BitpaySupportedCurrencies, coin) ? -1 : 1),
coin => (includes(SUPPORTED_CURRENCIES, coin) ? -1 : 1),
);
return (
<SheetModal isVisible={isVisible} onBackdropPress={onDismiss}>
Expand Down
Loading

0 comments on commit 87d99a6

Please sign in to comment.