Repository navigation
Expand file tree
/
Copy pathutils.ts
More file actions
87 lines (77 loc) · 2.68 KB
/
Copy pathutils.ts
File metadata and controls
87 lines (77 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import type { MarketplaceAppOverview } from 'types/client/marketplace';
import type { SearchResultItem } from 'types/client/search';
import config from 'configs/app';
export type ApiCategory = 'token' | 'nft' | 'address' | 'public_tag' | 'transaction' | 'block' | 'user_operation' | 'blob' | 'domain';
export type Category = ApiCategory | 'app';
export type ItemsCategoriesMap =
Record<ApiCategory, Array<SearchResultItem>> &
Record<'app', Array<MarketplaceAppOverview>>;
export type SearchResultAppItem = {
type: 'app';
app: MarketplaceAppOverview;
};
export const searchCategories: Array<{ id: Category; title: string }> = [
{ id: 'app', title: 'DApps' },
{ id: 'token', title: `Tokens (${ config.chain.tokenStandard }-20)` },
{ id: 'nft', title: `NFTs (${ config.chain.tokenStandard }-721 & 1155)` },
{ id: 'address', title: 'Addresses' },
{ id: 'public_tag', title: 'Public tags' },
{ id: 'transaction', title: 'Transactions' },
{ id: 'block', title: 'Blocks' },
];
if (config.features.userOps.isEnabled) {
searchCategories.push({ id: 'user_operation', title: 'User operations' });
}
if (config.features.dataAvailability.isEnabled) {
searchCategories.push({ id: 'blob', title: 'Blobs' });
}
if (config.features.nameService.isEnabled) {
searchCategories.unshift({ id: 'domain', title: 'Names' });
}
export const searchItemTitles: Record<Category, { itemTitle: string; itemTitleShort: string }> = {
app: { itemTitle: 'DApp', itemTitleShort: 'App' },
domain: { itemTitle: 'Name', itemTitleShort: 'Name' },
token: { itemTitle: 'Token', itemTitleShort: 'Token' },
nft: { itemTitle: 'NFT', itemTitleShort: 'NFT' },
address: { itemTitle: 'Address', itemTitleShort: 'Address' },
public_tag: { itemTitle: 'Public tag', itemTitleShort: 'Tag' },
transaction: { itemTitle: 'Transaction', itemTitleShort: 'Txn' },
block: { itemTitle: 'Block', itemTitleShort: 'Block' },
user_operation: { itemTitle: 'User operation', itemTitleShort: 'User op' },
blob: { itemTitle: 'Blob', itemTitleShort: 'Blob' },
};
export function getItemCategory(item: SearchResultItem | SearchResultAppItem): Category | undefined {
switch (item.type) {
case 'address':
case 'contract': {
return 'address';
}
case 'token': {
if (item.token_type === 'ERC-20') {
return 'token';
}
return 'nft';
}
case 'block': {
return 'block';
}
case 'label': {
return 'public_tag';
}
case 'transaction': {
return 'transaction';
}
case 'app': {
return 'app';
}
case 'user_operation': {
return 'user_operation';
}
case 'blob': {
return 'blob';
}
case 'ens_domain': {
return 'domain';
}
}
}