From 380e2cea18d05dc7de165a1c60257fb447f8eb03 Mon Sep 17 00:00:00 2001 From: guanbinrui <52657989+guanbinrui@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:03:19 +0800 Subject: [PATCH] [Release] Hotfix 2.26.0 => 2.26.1 (patch) (#11653) * chore: bump version to 2.26.1 * fix: try to fix runtime bug * Revert "fix: try to fix runtime bug" This reverts commit 0c727f320112e23e5ea15eb1bc0b90822d0ee669. * chore: clean ci cache * feat: mf-6113 add sei chain (#11505) * feat: mf-6113 add sei chain * fixup! feat: mf-6113 add sei chain * fix: token balance in token picker * fix: redpacket chain list * fix: mf-6288 approve token * fix: specific network --------- Co-authored-by: Jack Works <5390719+Jack-Works@users.noreply.github.com> Co-authored-by: Wukong Sun --- .github/workflows/compile.yml | 6 ++--- package.json | 2 +- .../components/TokenPicker/TokenItem.tsx | 16 +++++++------ .../Wallet/components/AssetsList/index.tsx | 9 +++---- .../src/SiteAdaptor/RedPacketDialog.tsx | 19 ++++++++------- .../src/SiteAdaptor/RedPacketHistoryList.tsx | 2 +- packages/plugins/RedPacket/src/base.ts | 5 ++-- packages/plugins/Tips/src/base.ts | 1 + packages/web3-constants/evm/ethereum.json | 2 ++ .../web3-constants/evm/nft-red-packet.json | 2 ++ packages/web3-constants/evm/red-packet.json | 2 ++ packages/web3-constants/evm/rpc.json | 3 +++ .../evm/token-asset-base-url.json | 6 +++-- packages/web3-constants/evm/token-list.json | 1 + packages/web3-constants/evm/token.json | 4 ++++ .../base/src/useNetworkDescriptor.ts | 11 +++++---- .../src/DeBank/apis/HistoryAPI.ts | 4 ++-- .../web3-providers/src/DeBank/constants.ts | 2 +- packages/web3-providers/src/DeBank/index.ts | 1 + packages/web3-providers/src/Rabby/index.ts | 6 ++--- .../TransactionFormatter/descriptors/ERC20.ts | 6 +++-- packages/web3-providers/src/entry.ts | 2 +- packages/web3-shared/evm/src/assets/sei.svg | 19 +++++++++++++++ .../web3-shared/evm/src/constants/chains.json | 24 +++++++++++++++++++ .../evm/src/constants/descriptors.ts | 12 ++++++++++ packages/web3-shared/evm/src/types/index.ts | 4 ++++ 26 files changed, 126 insertions(+), 45 deletions(-) create mode 100644 packages/web3-shared/evm/src/assets/sei.svg diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 54fc01afd1dc..dff5870fa171 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -49,10 +49,10 @@ jobs: uses: actions/cache@v4 with: path: packages/mask/node_modules/.cache/ - key: extension-${{ hashFiles('pnpm-lock.yaml') }}-${{ steps.get-date.outputs.date }} + key: extension-v2-${{ hashFiles('pnpm-lock.yaml') }}-${{ steps.get-date.outputs.date }} restore-keys: | - extension-${{ hashFiles('pnpm-lock.yaml') }} - extension- + extension-v2-${{ hashFiles('pnpm-lock.yaml') }} + extension-v2- - run: git config --global url."https://github.com/".insteadOf git@github.com - run: pnpm install - run: npx gulp build-ci diff --git a/package.json b/package.json index 257eb0067510..bc3e2e7c113a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.26.0", + "version": "2.26.1", "private": true, "license": "AGPL-3.0-or-later", "scripts": { diff --git a/packages/mask/popups/components/TokenPicker/TokenItem.tsx b/packages/mask/popups/components/TokenPicker/TokenItem.tsx index 6f9ae6343c27..4ce5d2c12281 100644 --- a/packages/mask/popups/components/TokenPicker/TokenItem.tsx +++ b/packages/mask/popups/components/TokenPicker/TokenItem.tsx @@ -1,9 +1,13 @@ import { Icons } from '@masknet/icons' import { NetworkIcon, ProgressiveText, TokenIcon } from '@masknet/shared' +import { NetworkPluginID } from '@masknet/shared-base' +import { useEverSeen } from '@masknet/shared-base-ui' import { makeStyles } from '@masknet/theme' import type { Web3Helper } from '@masknet/web3-helpers' import { useFungibleTokenBalance, useWeb3Utils } from '@masknet/web3-hooks-base' -import { isZero, type ReasonableNetwork } from '@masknet/web3-shared-base' +import { CHAIN_ID_TO_DEBANK_CHAIN_MAP } from '@masknet/web3-providers' +import { type ReasonableNetwork } from '@masknet/web3-shared-base' +import type { ChainId } from '@masknet/web3-shared-evm' import { Box, Link, @@ -11,15 +15,12 @@ import { ListItemIcon, ListItemText, Typography, - type ListItemProps, useForkRef, + type ListItemProps, } from '@mui/material' import { memo, useEffect, useMemo, useRef } from 'react' -import { formatTokenBalance } from '../../../shared/index.js' import { useMaskSharedTrans } from '../../../shared-ui/index.js' -import { NetworkPluginID } from '@masknet/shared-base' -import { useEverSeen } from '@masknet/shared-base-ui' -import type { ChainId } from '@masknet/web3-shared-evm' +import { formatTokenBalance } from '../../../shared/index.js' const useStyles = makeStyles()((theme) => { return { @@ -108,7 +109,8 @@ export const TokenItem = memo(function TokenItem({ const providerURL = network?.isCustomized ? network.rpcUrl : undefined const [seen, ref] = useEverSeen() // Debank might not provide asset from current custom network - const tryRpc = (!asset.balance || isZero(asset.balance)) && network?.isCustomized && seen + const supportedByDebank = CHAIN_ID_TO_DEBANK_CHAIN_MAP[asset.chainId] + const tryRpc = !supportedByDebank && seen const { data: rpcBalance, isPending } = useFungibleTokenBalance( NetworkPluginID.PLUGIN_EVM, asset.address, diff --git a/packages/mask/popups/pages/Wallet/components/AssetsList/index.tsx b/packages/mask/popups/pages/Wallet/components/AssetsList/index.tsx index 25c1f2150633..4eb3fc250f3f 100644 --- a/packages/mask/popups/pages/Wallet/components/AssetsList/index.tsx +++ b/packages/mask/popups/pages/Wallet/components/AssetsList/index.tsx @@ -3,7 +3,7 @@ import { NetworkPluginID, PopupRoutes } from '@masknet/shared-base' import { useEverSeen } from '@masknet/shared-base-ui' import { TextOverflowTooltip, makeStyles } from '@masknet/theme' import { useFungibleTokenBalance, useNetworks, useWallet } from '@masknet/web3-hooks-base' -import { formatCurrency, isGte, isLessThan, isZero, type FungibleAsset } from '@masknet/web3-shared-base' +import { formatCurrency, isGte, isLessThan, type FungibleAsset } from '@masknet/web3-shared-base' import { isNativeTokenAddress, ChainId, type SchemaType } from '@masknet/web3-shared-evm' import { Box, List, ListItem, ListItemText, Skeleton, Typography, type ListItemProps } from '@mui/material' import { range } from 'lodash-es' @@ -14,6 +14,7 @@ import { formatTokenBalance } from '../../../../../shared/index.js' import { useMaskSharedTrans } from '../../../../../shared-ui/index.js' import { useAssetExpand, useWalletAssets } from '../../hooks/index.js' import { MoreBar } from './MoreBar.js' +import { CHAIN_ID_TO_DEBANK_CHAIN_MAP } from '@masknet/web3-providers' const useStyles = makeStyles<{ hasNav?: boolean }>()((theme, { hasNav }) => ({ container: { @@ -99,11 +100,7 @@ const AssetItem = memo(function AssetItem({ asset, onItemClick, ...rest }: Asset const providerURL = network?.isCustomized ? network.rpcUrl : undefined const [seen, ref] = useEverSeen() // Debank might not provide asset from current custom network - // TODO Temporarily get XLayer balance via rpc - const tryRpc = - (!asset.balance || isZero(asset.balance)) && - (network?.isCustomized || network?.chainId === ChainId.XLayer) && - seen + const tryRpc = !CHAIN_ID_TO_DEBANK_CHAIN_MAP[network?.chainId!] && seen const { data: rpcBalance, isPending } = useFungibleTokenBalance( NetworkPluginID.PLUGIN_EVM, asset.address, diff --git a/packages/plugins/RedPacket/src/SiteAdaptor/RedPacketDialog.tsx b/packages/plugins/RedPacket/src/SiteAdaptor/RedPacketDialog.tsx index f651a6e56d88..224401668df3 100644 --- a/packages/plugins/RedPacket/src/SiteAdaptor/RedPacketDialog.tsx +++ b/packages/plugins/RedPacket/src/SiteAdaptor/RedPacketDialog.tsx @@ -2,7 +2,7 @@ import { useCallback, useContext, useMemo, useState, Suspense } from 'react' import * as web3_utils from /* webpackDefer: true */ 'web3-utils' import { DialogContent, Tab, useTheme } from '@mui/material' import { TabContext, TabPanel } from '@mui/lab' -import { CrossIsolationMessages, EMPTY_LIST, NetworkPluginID, PluginID } from '@masknet/shared-base' +import { CrossIsolationMessages, NetworkPluginID, PluginID } from '@masknet/shared-base' import { useChainContext, useGasPrice } from '@masknet/web3-hooks-base' import { ApplicationBoardModal, @@ -15,7 +15,6 @@ import { ChainId, type GasConfig, GasEditor } from '@masknet/web3-shared-evm' import { type FireflyRedPacketAPI, type RedPacketJSONPayload } from '@masknet/web3-providers/types' import { makeStyles, MaskTabList, useTabs } from '@masknet/theme' import { - useActivatedPluginSiteAdaptor, useCurrentVisitingIdentity, useLastRecognizedIdentity, useSiteThemeMode, @@ -40,6 +39,7 @@ import type { FireflyContext, FireflyRedpacketSettings } from '../types.js' import { FireflyRedpacketConfirmDialog } from './FireflyRedpacketConfirmDialog.js' import { RedPacketPast } from './RedPacketPast.js' import { CompositionTypeContext } from './RedPacketInjection.js' +import { base } from '../base.js' const useStyles = makeStyles<{ scrollY: boolean; isDim: boolean }>()((theme, { isDim, scrollY }) => { // it's hard to set dynamic color, since the background color of the button is blended transparent @@ -100,7 +100,6 @@ export default function RedPacketDialog(props: RedPacketDialogProps) { const [isNFTRedPacketLoaded, setIsNFTRedPacketLoaded] = useState(false) const { account, chainId: contextChainId, setChainId } = useChainContext() - const definition = useActivatedPluginSiteAdaptor.visibility.useAnyMode(PluginID.RedPacket) const [currentTab, onChange, tabs] = useTabs('tokens', 'collectibles') const [currentHistoryTab, onChangeHistoryTab, historyTabs] = useTabs('claimed', 'sent') const theme = useTheme() @@ -108,12 +107,14 @@ export default function RedPacketDialog(props: RedPacketDialogProps) { const { classes } = useStyles({ isDim: mode === 'dim', scrollY: !showHistory && currentTab === 'tokens' }) - const chainIdList: ChainId[] = useMemo(() => { - if (currentTab === tabs.tokens) - return definition?.enableRequirement.web3?.[NetworkPluginID.PLUGIN_EVM]?.supportedChainIds ?? EMPTY_LIST + const chainIds: ChainId[] = useMemo(() => { + if (currentTab === tabs.tokens) return base.enableRequirement.web3[NetworkPluginID.PLUGIN_EVM].supportedChainIds return [ChainId.Mainnet, ChainId.BSC, ChainId.Matic] - }, [currentTab === tabs.tokens, definition?.enableRequirement.web3]) - const chainId = chainIdList.includes(contextChainId) ? contextChainId : ChainId.Mainnet + }, [currentTab === tabs.tokens]) + const chainId = chainIds.includes(contextChainId) ? contextChainId : ChainId.Mainnet + if (process.env.NODE_ENV === 'development' && !chainIds.includes(contextChainId)) { + console.error(`${contextChainId} is not in supportedChainIds list, will fallback to mainnet`) + } // #region token lucky drop const [settings, setSettings] = useState() @@ -326,7 +327,7 @@ export default function RedPacketDialog(props: RedPacketDialogProps) { ) ?
- if (!histories?.length) return {t.search_no_result()} + if (!histories.length) return {t.search_no_result()} return (
diff --git a/packages/plugins/RedPacket/src/base.ts b/packages/plugins/RedPacket/src/base.ts index 4e05dfed3ed3..89c55103f6a4 100644 --- a/packages/plugins/RedPacket/src/base.ts +++ b/packages/plugins/RedPacket/src/base.ts @@ -4,7 +4,7 @@ import { ChainId } from '@masknet/web3-shared-evm' import { RedPacketMetaKey, RedPacketNftMetaKey, RedPacketPluginID } from './constants.js' import { languages } from './locales/languages.js' -export const base: Plugin.Shared.Definition = { +export const base = { ID: RedPacketPluginID, name: { fallback: 'Lucky Drop' }, description: { @@ -39,6 +39,7 @@ export const base: Plugin.Shared.Definition = { ChainId.Scroll, ChainId.Metis, ChainId.XLayer, + ChainId.Sei, ], }, [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, @@ -49,4 +50,4 @@ export const base: Plugin.Shared.Definition = { metadataKeys: new Set([RedPacketMetaKey, RedPacketNftMetaKey]), }, i18n: languages, -} +} satisfies Plugin.Shared.Definition diff --git a/packages/plugins/Tips/src/base.ts b/packages/plugins/Tips/src/base.ts index 2976ff411258..d9f42d7af6b5 100644 --- a/packages/plugins/Tips/src/base.ts +++ b/packages/plugins/Tips/src/base.ts @@ -37,6 +37,7 @@ export const base: Plugin.Shared.Definition = { ChainId.Optimism, ChainId.Metis, ChainId.XLayer, + ChainId.Sei, ], }, [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, diff --git a/packages/web3-constants/evm/ethereum.json b/packages/web3-constants/evm/ethereum.json index b5ce96db5ca7..48849932df3c 100644 --- a/packages/web3-constants/evm/ethereum.json +++ b/packages/web3-constants/evm/ethereum.json @@ -22,6 +22,7 @@ "Astar": "0xf5056B96ab242C566002852d0b98ce0BcDf1af51", "Scroll": "0xbC7d98985966f56A66B0cB5F23d865676dc2ac84", "Metis": "0xC119574D5Fb333F5AC018658D4d8b5035E16bf39", + "Sei": "0xd81c16d71432d7dF04575fFE9fEd76F837FEa0CC", "XLayer": "0x87EDa3a18e8C005e120B235AC52F3305186d5d25", "XLayer_Testnet": "0x8A42F70047a99298822dD1dbA34b454fc49913F2" }, @@ -50,6 +51,7 @@ "Astar": "0x1410304B91a280ad083196B0B50e9d8df749d860", "Scroll": "0x20Ee232E34B87061fE3ba0DB738A3531A3e915BF", "Metis": "0x6cc1b1058F9153358278C35E0b2D382f1585854B", + "Sei": "0x0Cc83D728CB8dDC5e0C9Aeec375cF08a68Ef9bDF", "XLayer": "0x8A42F70047a99298822dD1dbA34b454fc49913F2", "XLayer_Testnet": "0xF8935Df67cAB7BfcA9532D1Ac2088C5c39b995b5" }, diff --git a/packages/web3-constants/evm/nft-red-packet.json b/packages/web3-constants/evm/nft-red-packet.json index 544ba78a0642..846c1e0b67b4 100644 --- a/packages/web3-constants/evm/nft-red-packet.json +++ b/packages/web3-constants/evm/nft-red-packet.json @@ -15,6 +15,7 @@ "Astar": "0xc3e62b2CC70439C32a381Bfc056aCEd1d7162cef", "Scroll": "0x727F8030964CCEC6B0E344399c8d8E2B4C837351", "Metis": "0x812463356F58fc8194645A1838ee6C52D8ca2D26", + "Sei": "0x8A42F70047a99298822dD1dbA34b454fc49913F2", "XLayer": "0x977baB5f7e2cEd0C91fDA890Ed1DBDfD3Ee9AE81", "XLayer_Testnet": "0xd81c16d71432d7df04575ffe9fed76f837fea0cc" }, @@ -46,6 +47,7 @@ "Astar": 0, "Scroll": 96705, "Metis": 1702933, + "Sei": 81152001, "XLayer": 0, "XLayer_Testnet": 7319723 } diff --git a/packages/web3-constants/evm/red-packet.json b/packages/web3-constants/evm/red-packet.json index d985b4caa549..292b9407d252 100644 --- a/packages/web3-constants/evm/red-packet.json +++ b/packages/web3-constants/evm/red-packet.json @@ -38,6 +38,7 @@ "Astar": "0x2cF46Db820e279c5fBF778367D49d9C931D54524", "Scroll": "0x16f61cb37169523635B6761f3C946892fb3c18fB", "Metis": "0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77", + "Sei": "0xB349AC5E5C037C2ecb2AE9fCDc8F122b5f384620", "XLayer": "0xDb847f1D8099C5b15519ECfd0b0C981d719bccE6", "XLayer_Testnet": "0x977baB5f7e2cEd0C91fDA890Ed1DBDfD3Ee9AE81" }, @@ -69,6 +70,7 @@ "Astar": 910985, "Scroll": 96705, "Metis": 1702860, + "Sei": 81152032, "XLayer": 0, "XLayer_Testnet": 7320220 } diff --git a/packages/web3-constants/evm/rpc.json b/packages/web3-constants/evm/rpc.json index f2dacfd17560..0f70b533d100 100644 --- a/packages/web3-constants/evm/rpc.json +++ b/packages/web3-constants/evm/rpc.json @@ -72,6 +72,7 @@ "Astar": ["https://astar.api.onfinality.io/public"], "Scroll": ["https://rpc.scroll.io"], "Metis": ["https://andromeda.metis.io/?owner=1088"], + "Sei": ["https://evm-rpc.sei-apis.com"], "XLayer": ["https://rpc.xlayer.tech"], "XLayer_Testnet": ["https://testrpc.xlayer.tech"] }, @@ -103,6 +104,7 @@ "Astar": ["https://rpc.astar.network:8545"], "Scroll": ["https://rpc.scroll.io"], "Metis": ["https://andromeda.metis.io/?owner=1088"], + "Sei": ["https://evm-rpc.sei-apis.com"], "XLayer": ["https://rpc.xlayer.tech"], "XLayer_Testnet": ["https://testrpc.xlayer.tech"] }, @@ -134,6 +136,7 @@ "Astar": [0, 0, 0, 0, 0], "Scroll": [0, 0, 0, 0, 0], "Metis": [0, 0, 0, 0, 0], + "Sei": [0, 0, 0, 0, 0], "XLayer": [0, 0, 0, 0, 0], "XLayer_Testnet": [0, 0, 0, 0, 0] } diff --git a/packages/web3-constants/evm/token-asset-base-url.json b/packages/web3-constants/evm/token-asset-base-url.json index c4feadee3c14..2a7cff0618c6 100644 --- a/packages/web3-constants/evm/token-asset-base-url.json +++ b/packages/web3-constants/evm/token-asset-base-url.json @@ -26,7 +26,8 @@ "Conflux": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/conflux"], "Astar": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/astar"], "Scroll": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/scroll"], - "Metis": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/metis"] + "Metis": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/metis"], + "Sei": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/sei"] }, "ERC20_TOKEN_ASSET_BASE_URI": { "Mainnet": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/ethereum/assets"], @@ -55,6 +56,7 @@ "Conflux": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/conflux/assets"], "Astar": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/astar/assets"], "Scroll": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/scroll/assets"], - "Metis": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/metis/assets"] + "Metis": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/metis/assets"], + "Sei": ["https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/sei/assets"] } } diff --git a/packages/web3-constants/evm/token-list.json b/packages/web3-constants/evm/token-list.json index ceb4aa61b96f..82d5b074b0a9 100644 --- a/packages/web3-constants/evm/token-list.json +++ b/packages/web3-constants/evm/token-list.json @@ -27,6 +27,7 @@ "Astar": ["https://tokens.r2d2.to/latest/592/tokens.json"], "Scroll": ["https://tokens.r2d2.to/latest/534352/tokens.json"], "Metis": ["https://tokens.r2d2.to/latest/1088/tokens.json"], + "Sei": ["https://tokens.r2d2.to/latest/1329/tokens.json"], "XLayer": ["https://tokens.r2d2.to/latest/196/tokens.json"], "XLayer_Testnet": ["https://tokens.r2d2.to/latest/195/tokens.json"] } diff --git a/packages/web3-constants/evm/token.json b/packages/web3-constants/evm/token.json index 7d15d85552a5..f391a6da0670 100644 --- a/packages/web3-constants/evm/token.json +++ b/packages/web3-constants/evm/token.json @@ -25,6 +25,7 @@ "Astar": "0xaeaaf0e2c81af264101b9129c00f4440ccf0f720", "Scroll": "0x5300000000000000000000000000000000000004", "Metis": "0x420000000000000000000000000000000000000A", + "Sei": "0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7", "XLayer": "0x5a77f1443d16ee5761d310e38b62f77f726bc71c", "XLayer_Testnet": "0x049a970485cf54904a6da1e1cea2ac18c9b8fb9f" }, @@ -57,6 +58,7 @@ "Aurora": "0xb12bfca5a55806aaf64e99521918a4bf0fc40802", "Astar": "0x6a2d262D56735DbA19Dd70682B39F6bE9a931D98", "Scroll": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4", + "Sei": "0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1", "XLayer": "0x74b7f16337b8972027f6196a17a631ac6de26d22", "XLayer_Testnet": "0x2e1cba4a9f6e69d27e65046fc93b873b05f79a39" }, @@ -74,6 +76,7 @@ "Aurora": "0x4988a896b1227218e4a686fde5eabdcabd91571f", "Astar": "0x3795C36e7D12A8c252A20C5a7B455f7c57b60283", "Scroll": "0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df", + "Sei": "0xB75D0B03c06A926e488e2659DF1A861F860bD3d1", "XLayer": "0x1e4a5963abfd975d8c9021ce480b42188849d41d", "XLayer_Testnet": "0xb81fe42de28e7452088b77f3eb9685487734e088" }, @@ -318,6 +321,7 @@ "Astar": "0x0000000000000000000000000000000000000000", "Scroll": "0x0000000000000000000000000000000000000000", "Metis": "0x0000000000000000000000000000000000000000", + "Sei": "0x0000000000000000000000000000000000000000", "XLayer": "0x0000000000000000000000000000000000000000", "XLayer_Testnet": "0x0000000000000000000000000000000000000000" }, diff --git a/packages/web3-hooks/base/src/useNetworkDescriptor.ts b/packages/web3-hooks/base/src/useNetworkDescriptor.ts index 51baa09aa20b..d77501aee6e2 100644 --- a/packages/web3-hooks/base/src/useNetworkDescriptor.ts +++ b/packages/web3-hooks/base/src/useNetworkDescriptor.ts @@ -2,6 +2,7 @@ import type { NetworkPluginID } from '@masknet/shared-base' import { getRegisteredWeb3Networks } from '@masknet/web3-providers' import type { Web3Helper } from '@masknet/web3-helpers' import { useChainContext, useNetworkContext } from './useContext.js' +import { useMemo } from 'react' /** * Get built in declared network descriptor @@ -14,9 +15,9 @@ export function useNetworkDescriptor | undefined { const { pluginID } = useNetworkContext(expectedPluginID) - const { networkType } = useChainContext() - - return getRegisteredWeb3Networks(pluginID).find((x) => - [x.chainId, x.type, x.ID].includes(expectedChainIdOrNetworkTypeOrID ?? networkType ?? ''), - ) + const { networkType, chainId } = useChainContext() + const identity = expectedChainIdOrNetworkTypeOrID || networkType || chainId || '' + return useMemo(() => { + return getRegisteredWeb3Networks(pluginID).find((x) => [x.chainId, x.type, x.ID].includes(identity)) + }, [pluginID, identity]) } diff --git a/packages/web3-providers/src/DeBank/apis/HistoryAPI.ts b/packages/web3-providers/src/DeBank/apis/HistoryAPI.ts index 84e03695cbcb..271f287b0f3c 100644 --- a/packages/web3-providers/src/DeBank/apis/HistoryAPI.ts +++ b/packages/web3-providers/src/DeBank/apis/HistoryAPI.ts @@ -5,7 +5,7 @@ import { type Transaction } from '@masknet/web3-shared-base' import { ChainId, getDeBankConstants, type SchemaType } from '@masknet/web3-shared-evm' import { formatTransactions, resolveDeBankAssetIdReversed } from '../helpers.js' import type { HistoryRecord } from '../types.js' -import { CHIAN_ID_TO_DEBANK_CHAIN_MAP, DEBANK_OPEN_API } from '../constants.js' +import { CHAIN_ID_TO_DEBANK_CHAIN_MAP, DEBANK_OPEN_API } from '../constants.js' import { fetchSquashedJSON } from '../../helpers/fetchJSON.js' import type { HistoryAPI, BaseHubOptions } from '../../entry-types.js' import { evm } from '../../Manager/registry.js' @@ -17,7 +17,7 @@ class DeBankHistoryAPI implements HistoryAPI.Provider { const networks = evm.state?.Network?.networks?.getCurrentValue() // Fallback to commonly used chains if (!networks) return PRESET_CHAIN_IDS - const RUNTIME_CHAIN_IDS = networks.map((x) => CHIAN_ID_TO_DEBANK_CHAIN_MAP[x.chainId]) + const RUNTIME_CHAIN_IDS = networks.map((x) => CHAIN_ID_TO_DEBANK_CHAIN_MAP[x.chainId]) return compact(uniq([...RUNTIME_CHAIN_IDS, PRESET_CHAIN_IDS])).join(',') } async getTransactions( diff --git a/packages/web3-providers/src/DeBank/constants.ts b/packages/web3-providers/src/DeBank/constants.ts index 1c9fab545c1e..329c1a9fd02d 100644 --- a/packages/web3-providers/src/DeBank/constants.ts +++ b/packages/web3-providers/src/DeBank/constants.ts @@ -61,7 +61,7 @@ export const DEBANK_CHAIN_TO_CHAIN_ID_MAP: Record = { +export const CHAIN_ID_TO_DEBANK_CHAIN_MAP: Record = { 1: 'eth', 10: 'op', 19: 'sgb', diff --git a/packages/web3-providers/src/DeBank/index.ts b/packages/web3-providers/src/DeBank/index.ts index 0539548b8827..438ad069a281 100644 --- a/packages/web3-providers/src/DeBank/index.ts +++ b/packages/web3-providers/src/DeBank/index.ts @@ -1,3 +1,4 @@ export * from './apis/FungibleTokenAPI.js' export * from './apis/GasOptionAPI.js' export * from './apis/HistoryAPI.js' +export * from './constants.js' diff --git a/packages/web3-providers/src/Rabby/index.ts b/packages/web3-providers/src/Rabby/index.ts index f4d32b4e0842..a12e16861960 100644 --- a/packages/web3-providers/src/Rabby/index.ts +++ b/packages/web3-providers/src/Rabby/index.ts @@ -7,12 +7,12 @@ import { NON_FUNGIBLE_TOKEN_API_URL, FUNGIBLE_TOKEN_API_URL } from './constants. import type { NFTInfo, RawTokenInfo, TokenSpender } from './types.js' import { fetchJSON } from '../helpers/fetchJSON.js' import type { AuthorizationAPI } from '../entry-types.js' -import { CHIAN_ID_TO_DEBANK_CHAIN_MAP } from '../DeBank/constants.js' +import { CHAIN_ID_TO_DEBANK_CHAIN_MAP } from '../DeBank/constants.js' class RabbyAPI implements AuthorizationAPI.Provider { async getNonFungibleTokenSpenders(chainId: ChainId, account: string) { const maskDappContractInfoList = getAllMaskDappContractInfo(chainId, 'nft') - const debankChainId = CHIAN_ID_TO_DEBANK_CHAIN_MAP[chainId] + const debankChainId = CHAIN_ID_TO_DEBANK_CHAIN_MAP[chainId] if (!debankChainId || !account || !isValidChainId(chainId)) return [] const rawData = await fetchJSON<{ contracts: NFTInfo[] }>( @@ -60,7 +60,7 @@ class RabbyAPI implements AuthorizationAPI.Provider { async getFungibleTokenSpenders(chainId: ChainId, account: string) { const maskDappContractInfoList = getAllMaskDappContractInfo(chainId, 'token') - const debankChainId = CHIAN_ID_TO_DEBANK_CHAIN_MAP[chainId] + const debankChainId = CHAIN_ID_TO_DEBANK_CHAIN_MAP[chainId] if (!debankChainId || !account || !isValidChainId(chainId)) return [] diff --git a/packages/web3-providers/src/Web3/EVM/state/TransactionFormatter/descriptors/ERC20.ts b/packages/web3-providers/src/Web3/EVM/state/TransactionFormatter/descriptors/ERC20.ts index 56ca089bf0b9..b07b690c817c 100644 --- a/packages/web3-providers/src/Web3/EVM/state/TransactionFormatter/descriptors/ERC20.ts +++ b/packages/web3-providers/src/Web3/EVM/state/TransactionFormatter/descriptors/ERC20.ts @@ -53,7 +53,9 @@ export class ERC20Descriptor extends BaseDescriptor implements TransactionDescri isSameAddress(x.tokenInfo.address, context.to), ) - const spendingCap = new BigNumber(spender?.amount ?? spender?.rawAmount ?? 0).toString() + const spendingCap = new BigNumber( + spender?.amount ?? spender?.rawAmount ?? parameters.value, + ).toString() const successfulDescription = isZero(parameters.value) ? @@ -61,7 +63,7 @@ export class ERC20Descriptor extends BaseDescriptor implements TransactionDescri : i18NextInstance.t('plugin_infra_descriptor_token_revoke_but_set_positive_cap', { tokenAmountDescription: getTokenAmountDescription(spendingCap, token), spender: - spender?.address ? formatEthereumAddress(spender?.address, 4) : 'spender', + spender?.address ? formatEthereumAddress(spender.address, 4) : 'spender', }) : isZero(spendingCap) ? i18NextInstance.t('plugin_infra_descriptor_token_approve_but_set_zero_cap', { diff --git a/packages/web3-providers/src/entry.ts b/packages/web3-providers/src/entry.ts index 7d32de69813d..1e5900cba418 100644 --- a/packages/web3-providers/src/entry.ts +++ b/packages/web3-providers/src/entry.ts @@ -74,7 +74,7 @@ export { R2D2TokenList } from './R2D2/index.js' export { ENS } from './ENS/index.js' // Debank -export { DeBankHistory } from './DeBank/index.js' +export { DeBankHistory, CHAIN_ID_TO_DEBANK_CHAIN_MAP } from './DeBank/index.js' // NFTScan export { diff --git a/packages/web3-shared/evm/src/assets/sei.svg b/packages/web3-shared/evm/src/assets/sei.svg new file mode 100644 index 000000000000..7d646f0a28c2 --- /dev/null +++ b/packages/web3-shared/evm/src/assets/sei.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/packages/web3-shared/evm/src/constants/chains.json b/packages/web3-shared/evm/src/constants/chains.json index 874b180c8a10..8e4718038d7d 100644 --- a/packages/web3-shared/evm/src/constants/chains.json +++ b/packages/web3-shared/evm/src/constants/chains.json @@ -1161,6 +1161,30 @@ } ] }, + { + "chainId": 1329, + "name": "Sei", + "type": "Sei", + "network": "mainnet", + "features": [], + "nativeCurrency": { + "chainId": 1329, + "name": "Sei", + "symbol": "SEI", + "decimals": 18, + "logoURL": "https://dzyb4dm7r8k8w.cloudfront.net/prod/logos/0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE/logo.png" + }, + "defaultGasLimit": "90000", + "minGasLimit": "21000", + "infoURL": "https://www.sei.io/", + "shortName": "Sei", + "explorers": [ + { + "name": "SeiTrace", + "url": "https://seitrace.com/" + } + ] + }, { "chainId": 1284, "name": "Moonbeam", diff --git a/packages/web3-shared/evm/src/constants/descriptors.ts b/packages/web3-shared/evm/src/constants/descriptors.ts index e0d998678872..6fe3dc1361a9 100644 --- a/packages/web3-shared/evm/src/constants/descriptors.ts +++ b/packages/web3-shared/evm/src/constants/descriptors.ts @@ -328,6 +328,18 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray