diff --git a/cspell.json b/cspell.json index a344509ed9ea..77e36629540a 100644 --- a/cspell.json +++ b/cspell.json @@ -35,6 +35,7 @@ "arweave", "astar", "astarexchange", + "astria", "attrace", "avalanche", "avax", diff --git a/package.json b/package.json index a9cb9eca555e..2ac060cca035 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.26.4", + "version": "2.26.5", "private": true, "license": "AGPL-3.0-or-later", "scripts": { diff --git a/packages/mask/.webpack/config.ts b/packages/mask/.webpack/config.ts index be8a6eb21a63..242c058a6ac0 100644 --- a/packages/mask/.webpack/config.ts +++ b/packages/mask/.webpack/config.ts @@ -324,7 +324,7 @@ export async function createConfiguration(_inputFlags: BuildFlags): Promise { switch (currentTab) { case 'news': diff --git a/packages/plugins/Calendar/src/SiteAdaptor/components/DatePicker.tsx b/packages/plugins/Calendar/src/SiteAdaptor/components/DatePicker.tsx index de5ad07328af..9a84b6a491d3 100644 --- a/packages/plugins/Calendar/src/SiteAdaptor/components/DatePicker.tsx +++ b/packages/plugins/Calendar/src/SiteAdaptor/components/DatePicker.tsx @@ -90,9 +90,9 @@ export function DatePicker({ selectedDate, setSelectedDate, open, setOpen, curre const startingDayOfWeek = monthStart.getDay() const daysInMonth = endOfMonth(currentDate).getDate() const daysInPrevMonth = endOfMonth(addMonths(currentDate, -1)).getDate() - const { data: eventList } = useEventList(monthStart) - const { data: newsList } = useNewsList(monthStart) - const { data: nftList } = useNFTList(monthStart) + const { data: eventList } = useEventList(monthStart, currentTab === 'event') + const { data: newsList } = useNewsList(monthStart, currentTab === 'news') + const { data: nftList } = useNFTList(monthStart, currentTab === 'nfts') const list = useMemo(() => { switch (currentTab) { case 'news': diff --git a/packages/plugins/Calendar/src/hooks/useEventList.tsx b/packages/plugins/Calendar/src/hooks/useEventList.tsx index 1f83cf3f0bc1..5445c3c7fba6 100644 --- a/packages/plugins/Calendar/src/hooks/useEventList.tsx +++ b/packages/plugins/Calendar/src/hooks/useEventList.tsx @@ -5,10 +5,11 @@ import { EMPTY_OBJECT } from '@masknet/shared-base' import type { UseQueryResult } from '@tanstack/react-query' import { addDays } from 'date-fns/esm' -export function useNewsList(date: Date): UseQueryResult { +export function useNewsList(date: Date, enabled = true): UseQueryResult { const startTime = startOfMonth(date).getTime() / 1000 const endTime = Math.floor(addDays(date, 45).getTime() / 1000) return useQuery({ + enabled, queryKey: ['newsList', startTime, endTime], queryFn: async () => Calendar.getNewsList(startTime, endTime), select(data) { @@ -24,10 +25,11 @@ export function useNewsList(date: Date): UseQueryResult { }) } -export function useEventList(date: Date) { +export function useEventList(date: Date, enabled = true) { const startTime = startOfMonth(date).getTime() / 1000 const endTime = Math.floor(addDays(date, 45).getTime() / 1000) return useQuery({ + enabled, queryKey: ['eventList', startTime, endTime], queryFn: async () => Calendar.getEventList(startTime, endTime), select(data) { @@ -43,10 +45,11 @@ export function useEventList(date: Date) { }) } -export function useNFTList(date: Date) { +export function useNFTList(date: Date, enabled = true) { const startTime = startOfMonth(date).getTime() / 1000 const endTime = Math.floor(endOfMonth(date).getTime() / 1000) return useQuery({ + enabled, queryKey: ['nftList', startTime, endTime], queryFn: async () => Calendar.getNFTList(startTime, endTime), select(data) { diff --git a/packages/shared/src/UI/components/AssetsManagement/ChainRuntimeProvider.tsx b/packages/shared/src/UI/components/AssetsManagement/ChainRuntimeProvider.tsx index 0c90d0afac9a..ac98c24a1408 100644 --- a/packages/shared/src/UI/components/AssetsManagement/ChainRuntimeProvider.tsx +++ b/packages/shared/src/UI/components/AssetsManagement/ChainRuntimeProvider.tsx @@ -1,6 +1,6 @@ import { EMPTY_LIST, NetworkPluginID } from '@masknet/shared-base' import type { Web3Helper } from '@masknet/web3-helpers' -import { ChainId } from '@masknet/web3-shared-evm' +import { CHAIN_DESCRIPTORS, ChainId, type NetworkType, type SchemaType } from '@masknet/web3-shared-evm' import { ChainId as FlowChainId } from '@masknet/web3-shared-flow' import { noop, sortBy } from 'lodash-es' import { ChainId as SolanaChainId } from '@masknet/web3-shared-solana' @@ -33,7 +33,8 @@ const ChainRuntimeContext = createContext({ networks: EMPTY_LIST, }) -// https://docs.simplehash.com/reference/chains +// https://docs.simplehash.com/reference/chains +// sync `resolveChainId` and `ChainNameMap` in `web3-providers/src/SimpleHash/helpers.ts` const SimpleHashSupportedChains: Record = { [NetworkPluginID.PLUGIN_EVM]: [ ChainId.Mainnet, @@ -45,6 +46,7 @@ const SimpleHashSupportedChains: Record = { ChainId.Avalanche, ChainId.xDai, ChainId.Scroll, + ChainId.Zora, ], [NetworkPluginID.PLUGIN_SOLANA]: [SolanaChainId.Mainnet], [NetworkPluginID.PLUGIN_FLOW]: [FlowChainId.Mainnet], @@ -64,10 +66,15 @@ export const ChainRuntimeProvider = memo { const supported = SimpleHashSupportedChains[pluginID] - return sortBy( - allNetworks.filter((x) => (x.network === 'mainnet' || x.isCustomized) && supported.includes(x.chainId)), - (x) => supported.indexOf(x.chainId), + const networks = allNetworks.filter( + (x) => (x.network === 'mainnet' || x.isCustomized) && supported.includes(x.chainId), ) + // hard-coded for Zora + if (pluginID === NetworkPluginID.PLUGIN_EVM) { + const zora = CHAIN_DESCRIPTORS.find((x) => x.chainId === ChainId.Zora) + if (zora) networks.push(zora as ReasonableNetwork) + } + return sortBy(networks, (x) => supported.indexOf(x.chainId)) }, [allNetworks, pluginID]) const currentChainId = chainId ?? defaultChainId ?? (networks.length === 1 ? networks[0].chainId : chainId) diff --git a/packages/shared/src/UI/components/NetworkIcon/index.tsx b/packages/shared/src/UI/components/NetworkIcon/index.tsx index be17e96d322b..d4087e702a63 100644 --- a/packages/shared/src/UI/components/NetworkIcon/index.tsx +++ b/packages/shared/src/UI/components/NetworkIcon/index.tsx @@ -1,10 +1,13 @@ import type { Web3Helper } from '@masknet/web3-helpers' import { useNetwork } from '@masknet/web3-hooks-base' -import type { NetworkPluginID } from '@masknet/shared-base' +import { NetworkPluginID } from '@masknet/shared-base' import { ImageIcon, type ImageIconProps } from '../ImageIcon/index.js' import { ChainIcon } from '../index.js' import { memo } from 'react' import type { ReasonableNetwork } from '@masknet/web3-shared-base' +import { CHAIN_DESCRIPTORS as EVM_CHAIN_DESCRIPTORS } from '@masknet/web3-shared-evm' +import { CHAIN_DESCRIPTORS as SOLANA_CHAIN_DESCRIPTORS } from '@masknet/web3-shared-solana' +import { CHAIN_DESCRIPTORS as FLOW_CHAIN_DESCRIPTORS } from '@masknet/web3-shared-flow' export interface NetworkIconProps extends ImageIconProps { pluginID: NetworkPluginID @@ -16,11 +19,17 @@ export interface NetworkIconProps extends ImageIconProps { network?: ReasonableNetwork } +const descriptorsMap = { + [NetworkPluginID.PLUGIN_EVM]: EVM_CHAIN_DESCRIPTORS, + [NetworkPluginID.PLUGIN_SOLANA]: SOLANA_CHAIN_DESCRIPTORS, + [NetworkPluginID.PLUGIN_FLOW]: FLOW_CHAIN_DESCRIPTORS, +} as const + export const NetworkIcon = memo(function NetworkIcon(props: NetworkIconProps) { const { pluginID, chainId, icon, network: expectedNetwork, ...rest } = props const fallbackNetwork = useNetwork(pluginID, chainId) const network = expectedNetwork || fallbackNetwork - const iconUrl = network?.iconUrl || icon + const iconUrl = network?.iconUrl || icon || descriptorsMap[pluginID].find((x) => x.chainId === chainId)?.iconUrl if (iconUrl && !network?.isCustomized) return return ( diff --git a/packages/web3-providers/src/SimpleHash/helpers.ts b/packages/web3-providers/src/SimpleHash/helpers.ts index 7f25702c322f..d16f30fa1086 100644 --- a/packages/web3-providers/src/SimpleHash/helpers.ts +++ b/packages/web3-providers/src/SimpleHash/helpers.ts @@ -140,7 +140,7 @@ export function createNonFungibleCollection( } } -export const resolveChainId: (chainId: string) => ChainId | undefined = memoize(function resolveChainId( +export const resolveChainId: (chain: string) => ChainId | undefined = memoize(function resolveChainId( chain: string, ): ChainId | undefined { // Some of the `chainResolver.chainId()` results do not match. @@ -165,6 +165,10 @@ export const resolveChainId: (chainId: string) => ChainId | undefined = memoize( return ChainId.Scroll case 'celo': return ChainId.Celo + case 'zora': + return ChainId.Zora + case 'fantom': + return ChainId.Fantom default: return undefined } @@ -181,7 +185,8 @@ const ChainNameMap: Record> = { [ChainId.xDai]: 'gnosis', [ChainId.Base]: 'base', [ChainId.Scroll]: 'scroll', - [ChainId.Celo]: 'celo', + [ChainId.Zora]: 'zora', + [ChainId.Fantom]: 'fantom', }, [NetworkPluginID.PLUGIN_SOLANA]: { [SolanaChainId.Mainnet]: 'solana', diff --git a/packages/web3-shared/evm/src/assets/zora.png b/packages/web3-shared/evm/src/assets/zora.png new file mode 100644 index 000000000000..14b013c70ea6 Binary files /dev/null and b/packages/web3-shared/evm/src/assets/zora.png differ diff --git a/packages/web3-shared/evm/src/constants/chains.json b/packages/web3-shared/evm/src/constants/chains.json index 8e4718038d7d..4f1e7e56aca5 100644 --- a/packages/web3-shared/evm/src/constants/chains.json +++ b/packages/web3-shared/evm/src/constants/chains.json @@ -1328,5 +1328,29 @@ "url": "https://explorer.emerald.oasis.dev/" } ] + }, + { + "chainId": 7777777, + "name": "Zora", + "type": "Zora", + "network": "mainnet", + "features": [], + "nativeCurrency": { + "chainId": 42262, + "name": "Ether", + "symbol": "ETH", + "decimals": 18, + "logoURL": "https://imagedelivery.net/PCnTHRkdRhGodr0AWBAvMA/Assets/blockchains/ethereum/info/logo.png/quality=85" + }, + "defaultGasLimit": "90000", + "minGasLimit": "21000", + "infoURL": "https://zora.co/", + "shortName": "Zora", + "explorers": [ + { + "name": "Zora Superscan", + "url": "https://zora.superscan.network/" + } + ] } ] diff --git a/packages/web3-shared/evm/src/constants/descriptors.ts b/packages/web3-shared/evm/src/constants/descriptors.ts index 6fe3dc1361a9..9a2be4cdcd35 100644 --- a/packages/web3-shared/evm/src/constants/descriptors.ts +++ b/packages/web3-shared/evm/src/constants/descriptors.ts @@ -195,7 +195,7 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray> = CHAINS.map((x) => { diff --git a/packages/web3-shared/evm/src/types/index.ts b/packages/web3-shared/evm/src/types/index.ts index 333f34891f42..9da7984f0166 100644 --- a/packages/web3-shared/evm/src/types/index.ts +++ b/packages/web3-shared/evm/src/types/index.ts @@ -149,6 +149,8 @@ export enum ChainId { /** BitTorrent Chain Mainnet */ BitTorrent = 199, + Zora = 7777777, + // For any chains not supported yet. Invalid = 0, } @@ -311,6 +313,7 @@ export enum NetworkType { Scroll = 'Scroll', Moonbeam = 'Moonbeam', XLayer = 'XLayer', + Zora = 'Zora', CustomNetwork = 'CustomNetwork', }