Skip to content

Commit

Permalink
Revert "Support send of arbitrary ERC-20 tokens (#223)" (#224)
Browse files Browse the repository at this point in the history
This reverts commit 3a6154b.
  • Loading branch information
qrtp authored Nov 2, 2024
1 parent 3a6154b commit be327f4
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 317 deletions.
47 changes: 21 additions & 26 deletions packages/config/src/env/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default function getDefaultConfig(): Config {
CHAIN_ID: 5,
NETWORK_NAME: 'goerli', // testnet
JSON_RPC_API_URL: `https://goerli.infura.io/v3/a58ebb0c76a64c149e35145f85f82382`,
BLOCK_EXPLORER_NAME: 'oklink',
BLOCK_EXPLORER_BASE_URL: 'https://www.oklink.com/sepolia-test',
BLOCK_EXPLORER_NAME: 'etherscan',
BLOCK_EXPLORER_BASE_URL: 'https://goerli.etherscan.io',
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/sepolia-test/tx/',
DISABLE_CONTRACTS_CACHE: true,
PROXY_READER_ADDRESS: '0xFc5f608149f4D9e2Ed0733efFe9DD57ee24BCF68',
Expand All @@ -33,40 +33,21 @@ export default function getDefaultConfig(): Config {
NETWORK_NAME: 'amoy', // testnet
JSON_RPC_API_URL:
'https://polygon-amoy.infura.io/v3/a58ebb0c76a64c149e35145f85f82382',
BLOCK_EXPLORER_NAME: 'oklink',
BLOCK_EXPLORER_BASE_URL: 'https://www.oklink.com/amoy',
BLOCK_EXPLORER_NAME: 'polygonscan',
BLOCK_EXPLORER_BASE_URL: 'https://amoy.polygonscan.com',
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/amoy/tx/',
DISABLE_CONTRACTS_CACHE: true,
PROXY_READER_ADDRESS: '0x332A8191905fA8E6eeA7350B5799F225B8ed30a9',
OPEN_SEA_BASE_URL: 'https://testnets.opensea.io/assets/amoy/',
},
BASE: {
CHAIN_ID: 8453,
NETWORK_NAME: 'base',
JSON_RPC_API_URL:
'https://base-mainnet.infura.io/v3/a58ebb0c76a64c149e35145f85f82382',
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/base/tx/',
BLOCK_EXPLORER_NAME: 'oklink',
BLOCK_EXPLORER_BASE_URL: 'https://www.oklink.com/base',
DISABLE_CONTRACTS_CACHE: true,
},
BTC: {
CHAIN_ID: 0,
NETWORK_NAME: 'bitcoin',
JSON_RPC_API_URL: '',
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/btc/tx/',
BLOCK_EXPLORER_NAME: 'oklink',
BLOCK_EXPLORER_BASE_URL: 'https://www.oklink.com/btc',
DISABLE_CONTRACTS_CACHE: true,
},
SOL: {
CHAIN_ID: 0,
NETWORK_NAME: 'solana',
JSON_RPC_API_URL: '',
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/sol/tx/',
BLOCK_EXPLORER_NAME: 'oklink',
BLOCK_EXPLORER_BASE_URL: 'https://www.oklink.com/sol',
DISABLE_CONTRACTS_CACHE: true,
},
},
UD_LOGO_URL:
Expand Down Expand Up @@ -118,9 +99,23 @@ export default function getDefaultConfig(): Config {
LANDING_PAGE_URL: 'https://unstoppabledomains.com/products/wallet',
CHAINS: {
BUY: ['BTC/BTC', 'MATIC/MATIC', 'SOL/SOL', 'ETH/ETH'],
RECEIVE: ['BTC/BTC', 'MATIC/MATIC', 'SOL/SOL', 'BASE/ETH', 'ETH/ETH'],
SEND: ['BTC/BTC', 'MATIC/MATIC', 'SOL/SOL', 'BASE/ETH', 'ETH/ETH'],
DOMAINS: ['ETH', 'MATIC', 'BASE'],
RECEIVE: [
'BTC/BTC',
'MATIC/MATIC',
'MATIC/USDC',
'SOL/SOL',
'BASE/ETH',
'ETH/ETH',
],
SEND: [
'BTC/BTC',
'MATIC/MATIC',
'MATIC/USDC',
'SOL/SOL',
'BASE/ETH',
'ETH/ETH',
],
DOMAINS: ['ETH', 'MATIC'],
},
MOBILE: {
ANDROID_URL:
Expand Down
11 changes: 3 additions & 8 deletions packages/config/src/env/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ export type MaticBlockchainConfig = BaseBlockchainConfig & {
| 'https://www.oklink.com/polygon/tx/';
};

export type BitcoinBlockchainConfig = BaseBlockchainConfig & {
CHAIN_ID: 0;
export type BitcoinBlockchainConfig = {
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/btc/tx/';
};

export type SolanaBlockchainConfig = BaseBlockchainConfig & {
CHAIN_ID: 0;
export type SolanaBlockchainConfig = {
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/sol/tx/';
};

export type BaseChainBlockchainConfig = BaseBlockchainConfig & {
CHAIN_ID: 8453;
export type BaseChainBlockchainConfig = {
BLOCK_EXPLORER_TX_URL: 'https://www.oklink.com/base/tx/';
};

Expand Down
3 changes: 1 addition & 2 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unstoppabledomains/ui-components",
"version": "0.0.51-browser-extension.7",
"version": "0.0.51-browser-extension.6",
"private": true,
"description": "An open and reusable suite of Unstoppable Domains management components",
"keywords": [
Expand Down Expand Up @@ -63,7 +63,6 @@
"@xmtp/content-type-text": "^1.0.0",
"@xmtp/proto": "^3.62.1",
"@xmtp/xmtp-js": "12.1.0",
"abitype": "^1.0.6",
"bip322-js": "^1.1.0",
"bitcoin-address-validation": "^2.2.3",
"bluebird": "^3.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/src/components/Wallet/Buy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Buy: React.FC<Props> = ({isSellEnabled, onCancelClick, wallets}) => {
? 'wallet.selectAssetToBuySell'
: 'wallet.selectAssetToBuy',
)}
supportedAssetList={config.WALLETS.CHAINS.BUY}
supportedTokenList={config.WALLETS.CHAINS.BUY}
/>
</Box>
);
Expand Down
76 changes: 35 additions & 41 deletions packages/ui-components/src/components/Wallet/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const useStyles = makeStyles()((theme: Theme) => ({
marginRight: theme.spacing(-1),
},
height: '100%',
justifyContent: 'space-between',
},
selectAssetContainer: {
display: 'flex',
Expand All @@ -60,41 +59,37 @@ const useStyles = makeStyles()((theme: Theme) => ({
width: '60px',
borderRadius: '50%',
overflow: 'hidden',
marginTop: theme.spacing(1),
},
contentWrapper: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
minHeight: '250px',
width: '100%',
},
receiveAssetContainer: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginTop: theme.spacing(3),
},
receiveContentContainer: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
width: '100%',
},
copyButton: {},
addressWrapper: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
width: '100%',
},
captionContainer: {
display: 'flex',
backgroundColor: '#EEF0F3',
padding: 10,
borderRadius: 9,
},
input: {
fontSize: '12px',
},
infoIcon: {
fontSize: 15,
},
Expand Down Expand Up @@ -142,7 +137,7 @@ const Receive: React.FC<Props> = ({onCancelClick, wallets}) => {
wallets={wallets}
onCancelClick={handleBackClick}
label={t('wallet.selectAssetToReceive')}
supportedAssetList={config.WALLETS.CHAINS.RECEIVE}
supportedTokenList={config.WALLETS.CHAINS.RECEIVE}
/>
</Box>
);
Expand Down Expand Up @@ -176,7 +171,7 @@ const Receive: React.FC<Props> = ({onCancelClick, wallets}) => {
</Box>
<QRCode
value={`${asset.walletName}:${asset.walletAddress}`}
size={125}
size={110}
logoOpacity={0.5}
logoHeight={60}
logoWidth={60}
Expand All @@ -195,7 +190,6 @@ const Receive: React.FC<Props> = ({onCancelClick, wallets}) => {
stacked={true}
disabled
multiline
classes={{input: classes.input}}
endAdornment={
<Button
onClick={handleCopyClick}
Expand All @@ -205,40 +199,40 @@ const Receive: React.FC<Props> = ({onCancelClick, wallets}) => {
</Button>
}
/>
<Box mt={3} className={classes.captionContainer}>
<Box mr={1}>
<InfoIcon className={classes.infoIcon} color="error" />
</Box>
<Typography variant="caption" color="error" component="div">
<Markdown>
{t(
config.WALLETS.CHAINS.DOMAINS.map(s =>
s.toLowerCase(),
).includes(asset.symbol.toLowerCase())
? 'wallet.receiveAddressCaptionWithDomains'
: 'wallet.receiveAddressCaption',
{
symbol: getBlockchainDisplaySymbol(asset.ticker),
blockchain: asset.walletName,
},
)}
</Markdown>{' '}
{t('wallet.sendingForOtherNetworksAndTokens', {
symbol: getBlockchainDisplaySymbol(asset.ticker),
blockchain: asset.walletName,
})}{' '}
<Link
href={config.WALLETS.LANDING_PAGE_URL}
target="_blank"
className={classes.learnMoreLink}
>
<Typography variant={'caption'}>Learn More</Typography>
</Link>
</Typography>
</Box>
</Box>
</Box>
</Box>
<Box mb={1} className={classes.captionContainer}>
<Box mr={1}>
<InfoIcon className={classes.infoIcon} color="error" />
</Box>
<Typography variant="caption" color="error" component="div">
<Markdown>
{t(
config.WALLETS.CHAINS.DOMAINS.map(s => s.toLowerCase()).includes(
asset.symbol.toLowerCase(),
)
? 'wallet.receiveAddressCaptionWithDomains'
: 'wallet.receiveAddressCaption',
{
symbol: getBlockchainDisplaySymbol(asset.ticker),
blockchain: asset.walletName,
},
)}
</Markdown>{' '}
{t('wallet.sendingForOtherNetworksAndTokens', {
symbol: getBlockchainDisplaySymbol(asset.ticker),
blockchain: asset.walletName,
})}{' '}
<Link
href={config.WALLETS.LANDING_PAGE_URL}
target="_blank"
className={classes.learnMoreLink}
>
<Typography variant={'caption'}>Learn More</Typography>
</Link>
</Typography>
</Box>
</Box>
);
};
Expand Down
24 changes: 10 additions & 14 deletions packages/ui-components/src/components/Wallet/SelectAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {ImmutableArray} from '@unstoppabledomains/config/build/src/env/type
import {makeStyles} from '@unstoppabledomains/ui-kit/styles';

import type {SerializedWalletBalance} from '../../lib';
import {TokenType, WalletPaletteOwner} from '../../lib';
import {TokenType, WalletPaletteOwner, useTranslationContext} from '../../lib';
import {filterWallets} from '../../lib/wallet/filter';
import FundWalletModal from './FundWalletModal';
import {TitleWithBackButton} from './TitleWithBackButton';
Expand Down Expand Up @@ -56,8 +56,7 @@ type Props = {
requireBalance?: boolean;
onClickReceive?: () => void;
onClickBuy?: () => void;
supportedAssetList: ImmutableArray<string>;
supportErc20?: boolean;
supportedTokenList: ImmutableArray<string>;
};

export const SelectAsset: React.FC<Props> = ({
Expand All @@ -70,11 +69,11 @@ export const SelectAsset: React.FC<Props> = ({
requireBalance,
onClickReceive,
onClickBuy,
supportedAssetList,
supportErc20,
supportedTokenList,
}) => {
const {classes} = useStyles();
const wallets = filterWallets(initialWallets, supportedAssetList);
const [t] = useTranslationContext();
const wallets = filterWallets(initialWallets, supportedTokenList);

const serializeNativeTokens = (wallet: SerializedWalletBalance) => {
if (
Expand Down Expand Up @@ -112,8 +111,7 @@ export const SelectAsset: React.FC<Props> = ({
...(wallets || []).flatMap(wallet =>
(wallet?.tokens || []).map(walletToken => {
return {
address: walletToken.address,
type: walletToken.type,
type: 'Token' as never,
name: walletToken.name,
value: walletToken.value?.walletUsdAmt || 0,
balance: walletToken.balanceAmt || 0,
Expand All @@ -136,12 +134,10 @@ export const SelectAsset: React.FC<Props> = ({
];
const filteredTokens: TokenEntry[] = allTokens
.filter(token => !requireBalance || token.balance > 0)
.filter(
token =>
(token.type === TokenType.Erc20 && supportErc20) ||
supportedAssetList.includes(
`${token.symbol.toUpperCase()}/${token.ticker.toUpperCase()}`,
),
.filter(token =>
supportedTokenList.includes(
`${token.symbol.toUpperCase()}/${token.ticker.toUpperCase()}`,
),
)
.sort((a, b) => b.value - a.value || b.balance - a.balance);

Expand Down
Loading

0 comments on commit be327f4

Please sign in to comment.