diff --git a/cspell.json b/cspell.json index d4f0b992f296..5923f7e634e6 100644 --- a/cspell.json +++ b/cspell.json @@ -24,6 +24,7 @@ "arbitrum", "ARETH", "arweave", + "avax", "bgcolor", "bignumber", "bips", @@ -349,6 +350,7 @@ "testweb", "tinycolor", "treeshake", + "txreceipt", "txts", "uaddr", "unauthenticate", @@ -362,8 +364,7 @@ "walletlink", "WNATIVE", "xdescribe", - "xtest", - "txreceipt" + "xtest" ], "ignoreRegExpList": ["/@servie/"], "overrides": [ diff --git a/packages/dashboard/src/locales/en-US.json b/packages/dashboard/src/locales/en-US.json index e876883d170a..4ee7cbf04ddf 100644 --- a/packages/dashboard/src/locales/en-US.json +++ b/packages/dashboard/src/locales/en-US.json @@ -164,7 +164,7 @@ "wallets_collectible_been_added": "The Collectible has already been added.", "wallets_collectible_error_not_exist": "The collectible does not exist or belong to you.", "wallets_collectible_contract_is_empty": "Please select contract", - "wallets_collectible_token_id_is_empty": "Please select token", + "wallets_collectible_token_id_is_empty": "Please select collectible", "wallets_collectible_add": "Add", "wallets_add_token": "Add Token", "wallets_token_been_added": "Token has already been added.", diff --git a/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx b/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx index ab6493d531f1..f5f6be3ac606 100644 --- a/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/HistoryTableRow/index.tsx @@ -62,7 +62,7 @@ export const HistoryTableRow = memo(({ transaction, select const transactionType = useMemo(() => { if (transaction.type === TransactionType.CREATE_RED_PACKET) { - return 'Create Luck Drop' + return 'Create Lucky Drop' } return (transaction.type ?? '').replace(/_/g, ' ') }, [transaction.type]) diff --git a/packages/dashboard/src/pages/Wallets/components/Transfer/SelectNFTList.tsx b/packages/dashboard/src/pages/Wallets/components/Transfer/SelectNFTList.tsx index b5ec4fd32f85..b6f22d309e33 100644 --- a/packages/dashboard/src/pages/Wallets/components/Transfer/SelectNFTList.tsx +++ b/packages/dashboard/src/pages/Wallets/components/Transfer/SelectNFTList.tsx @@ -10,10 +10,11 @@ interface SelectNFTListProps { list: ERC721TokenDetailed[] selectedTokenId: string loading: boolean + error?: boolean onSelect(tokenId: string): void } -export const SelectNFTList = memo(({ list, onSelect, selectedTokenId, loading }) => { +export const SelectNFTList = memo(({ list, onSelect, selectedTokenId, loading, error }) => { const t = useDashboardI18N() const renderStatus = useMemo(() => { @@ -43,6 +44,12 @@ export const SelectNFTList = memo(({ list, onSelect, selecte sx={{ width: 640, borderRadius: '12px', + ...(error + ? { + boxShadow: `0 0 0 4px ${MaskColorVar.redMain.alpha(0.2)}`, + border: `1px solid ${MaskColorVar.redMain.alpha(0.8)}`, + } + : {}), background: (theme) => theme.palette.mode === 'dark' ? MaskColorVar.lightBackground : MaskColorVar.normalBackground, }}> diff --git a/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC20.tsx b/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC20.tsx index c0e7afaf202f..19490f576ed2 100644 --- a/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC20.tsx +++ b/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC20.tsx @@ -116,7 +116,7 @@ export const TransferERC20 = memo(({ token }) => { const maxAmount = useMemo(() => { let amount_ = new BigNumber(tokenBalance || '0') amount_ = selectedToken.type === EthereumTokenType.Native ? amount_.minus(gasFee) : amount_ - return amount_.toFixed() + return BigNumber.max(0, amount_).toFixed() }, [tokenBalance, gasPrice, selectedToken?.type, amount]) const [transferState, transferCallback, resetTransferCallback] = useTokenTransferCallback( diff --git a/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC721.tsx b/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC721.tsx index 2eddd864d454..cb3a2b906696 100644 --- a/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC721.tsx +++ b/packages/dashboard/src/pages/Wallets/components/Transfer/TransferERC721.tsx @@ -374,6 +374,7 @@ export const TransferERC721 = memo(() => { control={control} render={(field) => ( setValue('tokenId', value)} list={ defaultToken diff --git a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts index 2d9875d9327a..66192f74dbde 100644 --- a/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts +++ b/packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts @@ -8,7 +8,6 @@ import { getERC721TokenAssetFromChain, getEthereumConstants, getRPCConstants, - getTokenConstants, isSameAddress, Web3ProviderType, FungibleAssetProvider, @@ -36,7 +35,6 @@ export const getFungibleAssetsFn = const web3 = new Web3(provider) const { BALANCE_CHECKER_ADDRESS } = getEthereumConstants(chainId) - const { NATIVE_TOKEN_ADDRESS } = getTokenConstants() const socketId = `mask.fetchFungibleTokenAsset_${address}` let dataFromProvider = await socket.sendAsync>({ id: socketId, @@ -107,15 +105,20 @@ export const getFungibleAssetsFn = (t) => t.isMainnet && !allTokens.find( - (x) => x.token.chainId === t.chainId && isSameAddress(x.token.id, NATIVE_TOKEN_ADDRESS), + (x) => + x.token.chainId === t.chainId && + isSameAddress(x.token.id, createNativeToken(x.chainId).address), ), ) - .map((x) => ({ - id: NATIVE_TOKEN_ADDRESS!, - chainId: x.chainId, - token: { ...createNativeToken(x.chainId), id: NATIVE_TOKEN_ADDRESS!, type: TokenType.Fungible }, - balance: '0', - })) + .map((x) => { + const nativeToken = createNativeToken(x.chainId) + return { + id: nativeToken.address, + chainId: x.chainId, + token: { ...nativeToken, id: nativeToken.address!, type: TokenType.Fungible }, + balance: '0', + } + }) return uniqBy( [...nativeTokens, ...allTokens], diff --git a/packages/web3-providers/package.json b/packages/web3-providers/package.json index d104ab6f2e53..322a7df2e808 100644 --- a/packages/web3-providers/package.json +++ b/packages/web3-providers/package.json @@ -7,6 +7,7 @@ "@masknet/plugin-infra": "workspace:*", "@masknet/web3-shared-base": "workspace:*", "@masknet/web3-shared-evm": "workspace:*", + "@masknet/web3-constants": "workspace:*", "bignumber.js": "9.0.1", "date-fns": "^2.27.0", "json-stable-stringify": "^1.0.1", diff --git a/packages/web3-providers/src/debank/format.ts b/packages/web3-providers/src/debank/format.ts index aa8cda398f62..cca95cbff9f7 100644 --- a/packages/web3-providers/src/debank/format.ts +++ b/packages/web3-providers/src/debank/format.ts @@ -1,17 +1,20 @@ import BigNumber from 'bignumber.js' import type { WalletTokenRecord } from './type' -import { ChainId, getChainIdFromName } from '@masknet/web3-shared-evm' +import { ChainId, createNativeToken, getChainIdFromName } from '@masknet/web3-shared-evm' import { CurrencyType, TokenType, Web3Plugin } from '@masknet/plugin-infra' import { multipliedBy, rightShift } from '@masknet/web3-shared-base' +import DeBank from '@masknet/web3-constants/evm/debank.json' type Asset = Web3Plugin.Asset export function formatAssets(data: WalletTokenRecord[]): Asset[] { + const supportedChains = Object.values(DeBank.CHAIN_ID).filter(Boolean) + return data .filter((x) => x.is_verified) .map((y): Asset => { const chainIdFromChain = getChainIdFromName(y.chain) ?? ChainId.Mainnet - const address = y.id === 'eth' ? '' : y.id + const address = supportedChains.includes(y.id) ? createNativeToken(chainIdFromChain).address : y.id return { id: address, diff --git a/packages/web3-shared/evm/assets/chains.json b/packages/web3-shared/evm/assets/chains.json index 02d2a9cb8cb1..c0bfd90d762a 100644 --- a/packages/web3-shared/evm/assets/chains.json +++ b/packages/web3-shared/evm/assets/chains.json @@ -1204,7 +1204,12 @@ "rpc": ["https://rpcapi.fantom.network"], "faucets": [], "features": [], - "nativeCurrency": { "name": "Fantom", "symbol": "FTM", "decimals": 18 }, + "nativeCurrency": { + "name": "Fantom", + "symbol": "FTM", + "decimals": 18, + "logoURI": "https://static.debank.com/image/ftm_token/logo_url/ftm/33fdb9c5067e94f3a1b9e78f6fa86984.png" + }, "infoURL": "https://fantom.foundation", "shortName": "ftm", "chainId": 250, diff --git a/packages/web3-shared/evm/utils/token.ts b/packages/web3-shared/evm/utils/token.ts index 1d79e3cc92e2..a952c12dde09 100644 --- a/packages/web3-shared/evm/utils/token.ts +++ b/packages/web3-shared/evm/utils/token.ts @@ -24,7 +24,7 @@ import { isSameAddress } from './address' export function createNativeToken(chainId: ChainId): NativeTokenDetailed { const chainDetailed = getChainDetailed(chainId) if (!chainDetailed) throw new Error('Unknown chain id.') - const { NATIVE_TOKEN_ADDRESS } = getTokenConstants() + const { NATIVE_TOKEN_ADDRESS } = getTokenConstants(chainId) if (!NATIVE_TOKEN_ADDRESS) throw new Error('Failed to create token.') return { type: EthereumTokenType.Native, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b0e365ceff2..8ab4973aff46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1045,6 +1045,7 @@ importers: packages/web3-providers: specifiers: '@masknet/plugin-infra': workspace:* + '@masknet/web3-constants': workspace:* '@masknet/web3-shared-base': workspace:* '@masknet/web3-shared-evm': workspace:* bignumber.js: 9.0.1 @@ -1057,6 +1058,7 @@ importers: uuid: ^8.3.2 dependencies: '@masknet/plugin-infra': link:../plugin-infra + '@masknet/web3-constants': link:../web3-constants '@masknet/web3-shared-base': link:../web3-shared/base '@masknet/web3-shared-evm': link:../web3-shared/evm bignumber.js: 9.0.1