Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import { TrendingViewDeck } from './TrendingViewDeck'
import { currentDataProviderSettings } from '../../settings'
import { useAvailableCoins } from '../../trending/useAvailableCoins'
import { usePreferredCoinId } from '../../trending/useCurrentCoinId'
import { EthereumTokenType, useFungibleTokenDetailed, useChainIdValid, useNetworkType } from '@masknet/web3-shared-evm'
import {
EthereumTokenType,
useFungibleTokenDetailed,
useChainIdValid,
useNetworkType,
isNativeTokenSymbol,
} from '@masknet/web3-shared-evm'

const useStyles = makeStyles<{ isPopper: boolean }>()((theme, props) => {
return {
Expand Down Expand Up @@ -192,8 +198,7 @@ export function TraderView(props: TraderViewProps) {
// #endregion

// #region if the coin is a native token or contract address exists
const isNativeToken = ['eth', 'matic', 'bnb', 'avax'].includes(coinSymbol)
const isSwappable = (!!trending?.coin.contract_address || isNativeToken) && chainIdValid
const isSwappable = (!!trending?.coin.contract_address || isNativeTokenSymbol(coinSymbol)) && chainIdValid
// #endregion

// #region display loading skeleton
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/plugins/Wallet/services/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getChainShortName,
getChainIdFromNetworkType,
ERC721TokenCollectionInfo,
isNativeTokenSymbol as isNativeToken,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need alias.

} from '@masknet/web3-shared-evm'
import BigNumber from 'bignumber.js'
import { values } from 'lodash-unified'
Expand Down Expand Up @@ -180,7 +181,6 @@ function formatAssetsFromZerion(
return data.map(({ asset, quantity }) => {
const balance = leftShift(quantity, asset.decimals).toNumber()
const value = (asset as ZerionAsset).price?.value ?? (asset as ZerionCovalentAsset).value ?? 0
const isNativeToken = (symbol: string) => ['ETH', 'BNB', 'MATIC', 'ARETH', 'AETH'].includes(symbol)

return {
token: {
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-shared/evm/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getEnvConstants(key: string) {
}
}

export { ZERO_ADDRESS, FAKE_SIGN_PASSWORD, EthereumNameType } from './specific'
export * from './specific'

export const getAirdropConstants = transform(Airdrop)
export const useAirdropConstants = hookTransform(getAirdropConstants)
Expand Down
8 changes: 8 additions & 0 deletions packages/web3-shared/evm/utils/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { getChainDetailed, getChainIdFromName } from './chainDetailed'
import { formatBalance } from './formatter'
import { isSameAddress } from './address'
import CHAINS from '../assets/chains.json'

export function createNativeToken(chainId: ChainId): NativeTokenDetailed {
const chainDetailed = getChainDetailed(chainId)
Expand All @@ -34,6 +35,13 @@ export function createNativeToken(chainId: ChainId): NativeTokenDetailed {
}
}

const NATIVE_TOKEN_SYMBOLS = CHAINS.filter((x) => x.network === 'mainnet' && x.nativeCurrency).map((x) =>
x.nativeCurrency.symbol.toLowerCase(),
)
export function isNativeTokenSymbol(symbol: string) {
return NATIVE_TOKEN_SYMBOLS.includes(symbol.toLowerCase())
}

export function createERC20Token(
chainId: ChainId,
address: string,
Expand Down