Skip to content

Commit

Permalink
[Release] Hotfix 2.26.4 => 2.26.5 (patch) (#11703)
Browse files Browse the repository at this point in the history
* chore: bump version to 2.26.5

* fix: fw-6308 celo icon doesn't show in collectible card, enable zora (#11704)

* fix: fw-6308 celo icon doesn't show in collectible card

* fix: enable zora for simplehash

* fix: disable celo for simplehash (#11705)

* fix: lazy load calendar data (#11706)

---------

Co-authored-by: Wukong Sun <[email protected]>
  • Loading branch information
guanbinrui and swkatmask committed Jul 24, 2024
1 parent 46d4768 commit 57c7075
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 21 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"arweave",
"astar",
"astarexchange",
"astria",
"attrace",
"avalanche",
"avax",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.26.1",
"version": "2.26.5",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/.webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export async function createConfiguration(_inputFlags: BuildFlags): Promise<webp
path: flags.outputPath,
filename: 'entry/[name].js',
chunkFilename: productionLike ? 'bundled/[id].js' : 'bundled/chunk-[name].js',
assetModuleFilename: 'assets/[hash][ext][query]',
assetModuleFilename: productionLike ? 'assets/[hash][ext][query]' : 'assets/[name]-[hash][ext][query]',
webassemblyModuleFilename: 'assets/[hash].wasm',
hotUpdateMainFilename: 'hot/[runtime].[fullhash].json',
hotUpdateChunkFilename: 'hot/[id].[fullhash].js',
Expand Down
9 changes: 6 additions & 3 deletions packages/plugins/Calendar/src/SiteAdaptor/CalendarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ export function CalendarContent({ target, disableSetting }: Props) {
const [currentTab, onChange, tabs] = useTabs('news', 'event', 'nfts')
const [selectedDate, setSelectedDate] = useState(new Date())
const [open, setOpen] = useState(false)
const { data: eventList = EMPTY_OBJECT, isPending: eventLoading } = useEventList(selectedDate)
const { data: newsList = EMPTY_OBJECT, isPending: newsLoading } = useNewsList(selectedDate)
const { data: nftList = EMPTY_OBJECT, isPending: nftLoading } = useNFTList(selectedDate)
const { data: eventList = EMPTY_OBJECT, isPending: eventLoading } = useEventList(
selectedDate,
currentTab === 'event',
)
const { data: newsList = EMPTY_OBJECT, isPending: newsLoading } = useNewsList(selectedDate, currentTab === 'news')
const { data: nftList = EMPTY_OBJECT, isPending: nftLoading } = useNFTList(selectedDate, currentTab === 'nfts')
const list = useMemo(() => {
switch (currentTab) {
case 'news':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
9 changes: 6 additions & 3 deletions packages/plugins/Calendar/src/hooks/useEventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { startOfMonth, endOfMonth, addDays } from 'date-fns'
import { EMPTY_OBJECT } from '@masknet/shared-base'
import type { UseQueryResult } from '@tanstack/react-query'

export function useNewsList(date: Date): UseQueryResult<any> {
export function useNewsList(date: Date, enabled = true): UseQueryResult<any> {
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) {
Expand All @@ -23,10 +24,11 @@ export function useNewsList(date: Date): UseQueryResult<any> {
})
}

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<any>({
enabled,
queryKey: ['eventList', startTime, endTime],
queryFn: async () => Calendar.getEventList(startTime, endTime),
select(data) {
Expand All @@ -42,10 +44,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<any>({
enabled,
queryKey: ['nftList', startTime, endTime],
queryFn: async () => Calendar.getNFTList(startTime, endTime),
select(data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -33,7 +33,8 @@ const ChainRuntimeContext = createContext<ChainRuntimeOptions>({
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, number[]> = {
[NetworkPluginID.PLUGIN_EVM]: [
ChainId.Mainnet,
Expand All @@ -45,6 +46,7 @@ const SimpleHashSupportedChains: Record<NetworkPluginID, number[]> = {
ChainId.Avalanche,
ChainId.xDai,
ChainId.Scroll,
ChainId.Zora,
],
[NetworkPluginID.PLUGIN_SOLANA]: [SolanaChainId.Mainnet],
[NetworkPluginID.PLUGIN_FLOW]: [FlowChainId.Mainnet],
Expand All @@ -64,10 +66,15 @@ export const ChainRuntimeProvider = memo<PropsWithChildren<ChainRuntimeProviderP

const networks = useMemo(() => {
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<ChainId, SchemaType, NetworkType>)
}
return sortBy(networks, (x) => supported.indexOf(x.chainId))
}, [allNetworks, pluginID])

const currentChainId = chainId ?? defaultChainId ?? (networks.length === 1 ? networks[0].chainId : chainId)
Expand Down
13 changes: 11 additions & 2 deletions packages/shared/src/UI/components/NetworkIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,11 +19,17 @@ export interface NetworkIconProps extends ImageIconProps {
network?: ReasonableNetwork<Web3Helper.ChainIdAll, Web3Helper.SchemaTypeAll, Web3Helper.NetworkTypeAll>
}

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 <ImageIcon size={20} {...rest} icon={iconUrl} />
return (
Expand Down
9 changes: 7 additions & 2 deletions packages/web3-providers/src/SimpleHash/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand All @@ -181,7 +185,8 @@ const ChainNameMap: Record<NetworkPluginID, Record<number, string>> = {
[ChainId.xDai]: 'gnosis',
[ChainId.Base]: 'base',
[ChainId.Scroll]: 'scroll',
[ChainId.Celo]: 'celo',
[ChainId.Zora]: 'zora',
[ChainId.Fantom]: 'fantom',
},
[NetworkPluginID.PLUGIN_SOLANA]: {
[SolanaChainId.Mainnet]: 'solana',
Expand Down
Binary file added packages/web3-shared/evm/src/assets/zora.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions packages/web3-shared/evm/src/constants/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
]
}
]
14 changes: 13 additions & 1 deletion packages/web3-shared/evm/src/constants/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray<NetworkDescriptor<ChainId, Netwo
iconColor: 'rgb(53, 208, 127)',
averageBlockDelay: 10,
backgroundGradient: 'linear-gradient(180deg, rgba(251, 204, 92, 0.15) 0%, rgba(251, 204, 92, 0.05) 100%)',
isMainnet: false,
isMainnet: true,
},
{
ID: `${PLUGIN_ID}_scroll`,
Expand Down Expand Up @@ -351,6 +351,18 @@ export const NETWORK_DESCRIPTORS: ReadonlyArray<NetworkDescriptor<ChainId, Netwo
isMainnet: false,
averageBlockDelay: 10,
},
{
ID: `${PLUGIN_ID}_zora`,
networkSupporterPluginID: PLUGIN_ID,
chainId: ChainId.Zora,
type: NetworkType.Zora,
icon: new URL('../assets/zora.png', import.meta.url).href,
iconColor: 'rgb(36, 150, 238)',
name: 'Zora',
// Won't list in network list
isMainnet: false,
averageBlockDelay: 10,
},
]

export const CHAIN_DESCRIPTORS: ReadonlyArray<ChainDescriptor<ChainId, SchemaType, NetworkType>> = CHAINS.map((x) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/web3-shared/evm/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export enum ChainId {
/** BitTorrent Chain Mainnet */
BitTorrent = 199,

Zora = 7777777,

// For any chains not supported yet.
Invalid = 0,
}
Expand Down Expand Up @@ -315,6 +317,7 @@ export enum NetworkType {
Scroll = 'Scroll',
Moonbeam = 'Moonbeam',
XLayer = 'XLayer',
Zora = 'Zora',
CustomNetwork = 'CustomNetwork',
}

Expand Down

0 comments on commit 57c7075

Please sign in to comment.