Skip to content
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] Support Arb, Base and Op Chains #1146

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions assets/img/currencies/arb.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/img/currencies/base.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/img/currencies/op.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/currencies/png/ARB.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/currencies/png/BASE.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/currencies/png/OP.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/currencies/png/USDT.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/img/currencies/usdt.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ios/BitPayApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<string>bitcoincash</string>
<string>ethereum</string>
<string>matic</string>
<string>arb</string>
<string>base</string>
<string>op</string>
<string>dogecoin</string>
<string>litecoin</string>
</array>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"babel-plugin-module-resolver": "4.1.0",
"big-integer": "1.6.51",
"bitauth": "0.4.1",
"bitcore-wallet-client": "10.0.28",
"bitcore-wallet-client": "10.0.36",
"buffer": "4.9.2",
"countries-list": "2.6.1",
"eth-sig-util": "3.0.1",
Expand Down
7 changes: 7 additions & 0 deletions scripts/allowed-url-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ const allowedUrlPrefixes = [
'https://api.bitcore.io/api',
'https://api-eth.bitcore.io/api',
'https://api-matic.bitcore.io/api',
'https://api-arb.bitcore.io/api',
'https://api-base.bitcore.io/api',
'https://api-op.bitcore.io/api',
'https://api-xrp.bitcore.io/api',
'https://portal.polygon.technology/bridge',
'https://bridge.arbitrum.io/',
'https://bridge.base.org/',
'https://app.optimism.io/bridge/',
].concat(developmentOnlyAllowedUrlPrefixes);

const allowedUrlPrefixString = allowedUrlPrefixes.join(',');
Expand Down
9 changes: 6 additions & 3 deletions src/components/chain-search/ChainSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import {EIP155_CHAINS} from '../../constants/WalletConnectV2';
import cloneDeep from 'lodash.clonedeep';
import {Wallet} from '../../store/wallet/wallet.models';
import {useTheme} from 'styled-components/native';
import {setDefaultChainFilterOption} from '../../store/app/app.actions';
import {setLocalDefaultChainFilterOption} from '../../store/app/app.actions';
import ChainSelectorModal from '../../components/modal/chain-selector/ChainSelector';
import {BitpaySupportedCoins} from '../../constants/currencies';
import {SupportedChainsOptions} from '../../constants/SupportedCurrencyOptions';

export const SearchIconContainer = styled.View`
margin: 14px;
Expand Down Expand Up @@ -104,6 +103,10 @@ const SearchComponent = <T extends SearchableItem>({
: APP.selectedChainFilterOption,
);

const supportedChainOption = SupportedChainsOptions.find(
({chain}) => chain === selectedChainFilterOption,
);

const normalizeText = (text: string | undefined) =>
text?.replace(/\s+/g, '')?.toLowerCase() || '';

Expand Down Expand Up @@ -222,7 +225,7 @@ const SearchComponent = <T extends SearchableItem>({
<SearchFilterLabelContainer>
<SearchFilterLabel>
{selectedChainFilterOption
? BitpaySupportedCoins[selectedChainFilterOption]?.name
? supportedChainOption?.chainName
: t('All Networks')}
</SearchFilterLabel>
</SearchFilterLabelContainer>
Expand Down
10 changes: 8 additions & 2 deletions src/components/list/CurrencySelectionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ import {BaseText, H6, H7} from '../styled/Text';

export type CurrencySelectionItem = Pick<
SupportedCurrencyOption,
'id' | 'currencyAbbreviation' | 'currencyName' | 'img' | 'isToken'
| 'id'
| 'currencyAbbreviation'
| 'currencyName'
| 'img'
| 'isToken'
| 'badgeUri'
> & {
chain: string;
tokenAddress?: string;
Expand Down Expand Up @@ -123,6 +128,7 @@ export const ChainSelectionRow: React.VFC<ChainSelectionRowProps> = memo(
currencyName,
img,
imgSrc,
badgeUri,
selected,
disabled,
} = currency;
Expand All @@ -139,7 +145,7 @@ export const ChainSelectionRow: React.VFC<ChainSelectionRowProps> = memo(
: null
}>
<CurrencyColumn>
<CurrencyImage img={img} imgSrc={imgSrc} />
<CurrencyImage img={img} imgSrc={imgSrc} badgeUri={badgeUri} />
</CurrencyColumn>

<CurrencyTitleColumn style={{flexGrow: 1}}>
Expand Down
29 changes: 18 additions & 11 deletions src/components/modal/chain-selector/ChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import styled, {css} from 'styled-components/native';
import {useDispatch, useSelector} from 'react-redux';
import {AppActions} from '../../../store/app';
import {RootState} from '../../../store';
import {Black, Action, SlateDark, White, Slate} from '../../../styles/colors';
import {
Black,
Action,
SlateDark,
White,
Slate,
LightBlack,
} from '../../../styles/colors';
import haptic from '../../haptic-feedback/haptic';
import {FlatList, Platform, SectionList, View} from 'react-native';
import {useTheme} from '@react-navigation/native';
Expand All @@ -31,10 +38,10 @@ import SearchSvg from '../../../../assets/img/search.svg';
import {
BitpaySupportedCoins,
SUPPORTED_CURRENCIES_CHAINS,
SupportedCoins,
SupportedChains,
} from '../../../constants/currencies';
import {useAppSelector} from '../../../utils/hooks';
import {SupportedCoinsOptions} from '../../../constants/SupportedCurrencyOptions';
import {SupportedChainsOptions} from '../../../constants/SupportedCurrencyOptions';
import {CurrencyImage} from '../../currency-image/CurrencyImage';
import GhostSvg from '../../../../assets/img/ghost-cheeky.svg';
import AllNetworkSvg from '../../../../assets/img/all-networks.svg';
Expand Down Expand Up @@ -138,10 +145,10 @@ const ChainSelector = () => {

const renderChainItem = useCallback(
({item, index, section}: {item: string; index: number; section: any}) => {
const supportedCoin = SupportedCoinsOptions.find(
({chain}) => chain === BitpaySupportedCoins[item]?.chain,
const supportedChain = SupportedChainsOptions.find(
({chain}) => chain === item,
);
const badgeLabel = BitpaySupportedCoins[item]?.name || item;
const badgeLabel = supportedChain?.chainName || item;
const selected = selectedChainFilterOption === item;
let isLastItem = false;
if (section?.data?.length) {
Expand All @@ -153,8 +160,8 @@ const ChainSelector = () => {
activeOpacity={ActiveOpacity}
selected={selected}
onPress={() => {
const option = BitpaySupportedCoins[item]?.chain as
| SupportedCoins
const option = supportedChain?.chain as
| SupportedChains
| undefined;

// Check if the context is one of 'sell', 'swap', 'buy'
Expand All @@ -169,14 +176,14 @@ const ChainSelector = () => {
key={index.toString()}>
<RowContainer>
<ImageContainer>
{BitpaySupportedCoins[item] && supportedCoin?.img ? (
<CurrencyImage img={supportedCoin?.img} size={32} />
{supportedChain?.img ? (
<CurrencyImage img={supportedChain?.img} size={32} />
) : (
<AllNetworkSvg style={{width: 20, height: 20}} />
)}
</ImageContainer>
<NetworkName selected={selected}>{badgeLabel}</NetworkName>
{BitpaySupportedCoins[item] ? (
{supportedChain ? (
<NetworkChainLabelContainer selected={selected}>
<NetworkChainLabel>{item.toUpperCase()}</NetworkChainLabel>
</NetworkChainLabelContainer>
Expand Down
24 changes: 24 additions & 0 deletions src/constants/BWCError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ const _getErrorMessage = (err: Error) => {
return t(
'Insufficient funds in your linked MATIC wallet to cover the transaction fee.',
);
case 'INSUFFICIENT_ARB_FEE':
return t(
'Insufficient funds in your linked ARB wallet to cover the transaction fee.',
);
case 'INSUFFICIENT_BASE_FEE':
return t(
'Insufficient funds in your linked BASE wallet to cover the transaction fee.',
);
case 'INSUFFICIENT_OP_FEE':
return t(
'Insufficient funds in your linked OP wallet to cover the transaction fee.',
);
case 'LOCKED_FUNDS':
return t('Funds are locked by pending spend proposals');
case 'LOCKED_ETH_FEE':
Expand All @@ -108,6 +120,18 @@ const _getErrorMessage = (err: Error) => {
return t(
'Your POLYGON linked wallet funds are locked by pending spend proposals',
);
case 'LOCKED_ARB_FEE':
return t(
'Your ARB linked wallet funds are locked by pending spend proposals',
);
case 'LOCKED_BASE_FEE':
return t(
'Your BASE linked wallet funds are locked by pending spend proposals',
);
case 'LOCKED_OP_FEE':
return t(
'Your OP linked wallet funds are locked by pending spend proposals',
);
case 'COPAYER_VOTED':
return t('Copayer already voted on this spend proposal');
case 'NOT_AUTHORIZED':
Expand Down