1
+ import { isEmpty , memoize } from 'lodash-es'
2
+ import { unreachable } from '@masknet/kit'
1
3
import {
2
4
SourceType ,
3
5
TokenType ,
@@ -8,15 +10,13 @@ import {
8
10
import { ChainId , SchemaType , WNATIVE , chainResolver , isValidChainId , resolveImageURL } from '@masknet/web3-shared-evm'
9
11
import { ChainId as SolanaChainId } from '@masknet/web3-shared-solana'
10
12
import { ChainId as FlowChainId } from '@masknet/web3-shared-flow'
11
- import { isEmpty } from 'lodash-es'
12
13
import { createPermalink } from '../NFTScan/helpers/EVM.js'
13
- import { fetchJSON , getAssetFullName } from '../entry-helpers.js'
14
- import { ETH_BLUR_TOKEN_ADDRESS , SIMPLE_HASH_URL } from './constants.js'
15
- import { ActivityType as ActivityTypeSimpleHash , type Asset , type Collection } from './type.js'
16
14
import { NetworkPluginID , createLookupTableResolver , queryClient } from '@masknet/shared-base'
17
15
import type { Web3Helper } from '@masknet/web3-helpers'
18
16
import { TrendingAPI } from '../entry-types.js'
19
- import { unreachable } from '@masknet/kit'
17
+ import { fetchJSON , getAssetFullName } from '../entry-helpers.js'
18
+ import { ETH_BLUR_TOKEN_ADDRESS , SIMPLE_HASH_URL } from './constants.js'
19
+ import { ActivityType as ActivityTypeSimpleHash , type Asset , type Collection } from './type.js'
20
20
21
21
export async function fetchFromSimpleHash < T > ( path : string , init ?: RequestInit ) {
22
22
return queryClient . fetchQuery < T > ( {
@@ -132,7 +132,9 @@ export function createNonFungibleCollection(collection: Collection): NonFungible
132
132
}
133
133
}
134
134
135
- export function resolveChainId ( chain : string ) : ChainId | undefined {
135
+ export const resolveChainId : ( chainId : string ) => ChainId | undefined = memoize ( function resolveChainId (
136
+ chain : string ,
137
+ ) : ChainId | undefined {
136
138
// Some of the `chainResolver.chainId()` results do not match.
137
139
switch ( chain ) {
138
140
case 'ethereum' :
@@ -152,7 +154,7 @@ export function resolveChainId(chain: string): ChainId | undefined {
152
154
default :
153
155
return undefined
154
156
}
155
- }
157
+ } )
156
158
157
159
const ChainNameMap : Record < NetworkPluginID , Record < number , string > > = {
158
160
[ NetworkPluginID . PLUGIN_EVM ] : {
@@ -184,7 +186,8 @@ export function checkBlurToken(pluginId: NetworkPluginID, chainId: Web3Helper.Ch
184
186
return `${ resolveChain ( pluginId , chainId ) } .${ address . toLowerCase ( ) } ` === `ethereum.${ ETH_BLUR_TOKEN_ADDRESS } `
185
187
}
186
188
187
- export function checkLensFollower ( name : string ) {
189
+ export function isLensFollower ( name : string ) {
190
+ if ( ! name ) return false
188
191
return name . endsWith ( '.lens-Follower' )
189
192
}
190
193
0 commit comments