Skip to content

Commit

Permalink
fix: Fixed some known bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbe37e committed May 27, 2024
1 parent c1e53e1 commit c06930f
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### v5.0.1

- [perf] Search for private tags ignores case sensitivity
- [fix] Fix the bug where saving local labels on the Arkham website fails
- [dix] Fix the bug where importing local labels fails

### v5.0.0

- [feat] Supports Solana scans
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ For up to the minute news, follow our [Twitter](https://twitter.com/MetaDockTeam
- [x] Show evm.storage shortcut
- [x] Show transaction simulator
- [x] Show Variable Logs
- [x] Manage Local Private Labels

## Supported Websites List

Expand All @@ -66,12 +65,6 @@ For up to the minute news, follow our [Twitter](https://twitter.com/MetaDockTeam
- tronscan.org
- era.zksync.network
- blockscout.com
- debank.com
- platform.arkhamintelligence.com
- scan.merlinchain.io
- solscan.io
- solana.fm
- explorer.solana.com

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metasuites",
"version": "5.0.0",
"version": "5.0.1",
"repository": {
"type": "git",
"url": "https://github.com/blocksecteam/metasuites.git"
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/ComplianceRadarPlot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ComplianceRadarPlot: FC<Props> = ({
backgroundColor: '#6a7985'
}
},
formatter: function (params: any, v: any) {
formatter: function (params: any) {
const data = params.value
function getRisk(value: number) {
return Object.values(NFT_RISKS).find(
Expand Down
4 changes: 3 additions & 1 deletion src/common/components/ModalAddPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface Props {
onSuccess?: (label?: string, color?: string) => void
}

const LABEL_COLORS = [
export const LABEL_COLORS = [
'#EF4444',
'#FB923C',
'#EAB308',
Expand All @@ -34,6 +34,8 @@ const LABEL_COLORS = [
'#BE185D'
]

export const DEFAULT_LABEL_COLOR = '#D9D9D9'

const ModalAddPrivateLabel: FC<Props> = ({
visible,
chainType,
Expand Down
3 changes: 1 addition & 2 deletions src/content/arkham/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 2 additions & 1 deletion src/content/arkham/feat-scripts/main-address-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { createRoot } from 'react-dom/client'
import $ from 'jquery'

import { ChainType } from '@common/constants'
import { pickAddress } from '@common/utils'

import { MainPrivateLabel } from '../components'

const renderMainAddressLabel = async () => {
const container = $('div[class^="Header_displayNameAddress"]:first')

const mainAddress = container.find('input').val()
const mainAddress = pickAddress(window.location.pathname)

if (!mainAddress) return

Expand Down
3 changes: 1 addition & 2 deletions src/content/btc/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 1 addition & 2 deletions src/content/debank/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore } from '@common/hooks'
import { hexToRgba, formatAddress } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 1 addition & 2 deletions src/content/etherscan/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore, useTheme } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -13,8 +14,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const { isDarkMode } = useTheme()

Expand Down
3 changes: 1 addition & 2 deletions src/content/scans/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore, useTheme } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -13,8 +14,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const { isDarkMode } = useTheme()

Expand Down
5 changes: 2 additions & 3 deletions src/content/solanaexpl/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { type FC, useState } from 'react'

import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore, useTheme } from '@common/hooks'
import { useStore } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 1 addition & 2 deletions src/content/solanafm/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore, useTheme } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 1 addition & 2 deletions src/content/solscan/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
3 changes: 1 addition & 2 deletions src/content/tronscan/components/MainPrivateLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconAdd, IconEdit, ModalAddPrivateLabel } from '@common/components'
import { useStore, useTheme } from '@common/hooks'
import { hexToRgba } from '@common/utils'
import type { ChainType } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -12,8 +13,6 @@ interface Props {
address: string
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const MainPrivateLabel: FC<Props> = ({ address, chainType }) => {
const [privateLabels] = useStore('privateLabels')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import { parse } from 'papaparse'

import { Drawer, IconImport } from '@common/components'
import type { PrivateLabel } from '@src/store'
import { EXT_SUPPORT_WEB_LIST } from '@common/constants'
import { ChainType } from '@common/constants'
import { useStore } from '@common/hooks'
import { formatAddress } from '@common/utils'
import {
LABEL_COLORS,
DEFAULT_LABEL_COLOR
} from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

Expand All @@ -24,13 +29,24 @@ const ImportPrivateLabelsDrawer: FC<Props> = ({ visible, onClose }) => {
accept: '.csv',
multiple: false,
className: styles.upload,
beforeUpload: file => {
const isLt4M = file.size / 1024 / 1024 < 4
if (!isLt4M) {
message.error('File must smaller than 4MB')
return Upload.LIST_IGNORE
}
return true
},
customRequest: async ({ file, onSuccess, onError }) => {
parse(file as File, {
complete: parsedData => {
const [headerRow, ...dataRows] = parsedData.data as string[][]
const jsonData = dataRows.map(row => {
return headerRow.reduce((obj, header, index) => {
obj[header.toLowerCase()] = row[index]
obj[header] = row[index]
if (!LABEL_COLORS.includes(obj.color?.toUpperCase())) {
obj.color = DEFAULT_LABEL_COLOR
}
return obj
}, {} as Record<string, string>)
})
Expand All @@ -44,22 +60,19 @@ const ImportPrivateLabelsDrawer: FC<Props> = ({ visible, onClose }) => {
onChange: async info => {
const { status, response } = info.file
if (status === 'done') {
const chainList = EXT_SUPPORT_WEB_LIST.flatMap(item => [
item,
...(item.testNets || [])
])
.filter(item => item.chain)
.map(item => item.chain)
const supportedChainTypes = Object.values(ChainType).filter(
item => item !== 'unknown'
)
const labels: PrivateLabel[] = response.filter((item: PrivateLabel) => {
return (
item.label &&
item.address &&
chainList.includes(item.chain) &&
supportedChainTypes.includes(item.chainType) &&
item.label.length <= 35
)
})
const records = labels.reduce((obj, item) => {
obj[`${item.chain}-${item.address}`] = item
obj[`${item.chainType}-${formatAddress(item.address)}`] = item
return obj
}, {} as Record<string, PrivateLabel>)
setPrivateLabels({ ...privateLabels, ...records })
Expand All @@ -79,8 +92,9 @@ const ImportPrivateLabelsDrawer: FC<Props> = ({ visible, onClose }) => {
<IconImport size={40} />
</p>
<p className={styles.description}>
Support upload CSV files only, with a maximum file size of 1MB. Each
import can include up to 1,000 addresses (labels optional).
Only CSV format is supported for import, with a maximum file size of
4MB. Please refer to the exported CSV format for the correct import
format.
</p>
</Dragger>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import type { PrivateLabel } from '@src/store'
import { useStore } from '@common/hooks'
import { chromeEvent } from '@common/event'
import { REFRESH } from '@common/constants'
import { DEFAULT_LABEL_COLOR } from '@common/components/ModalAddPrivateLabel'

import styles from './index.module.less'

interface Props {
data: PrivateLabel
}

const DEFAULT_LABEL_COLOR = '#D9D9D9'

const LabelItem: FC<Props> = ({
data,
data: { chainType, address, label }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const PrivateLabelManagementDrawer: FC<Props> = ({ visible, onClose }) => {
const labelList = useMemo(() => {
return Object.values(privateLabels).filter(item => {
if (keyword.trim()) {
return item.label.indexOf(keyword) > -1
return (
item.label.toLowerCase().indexOf(keyword.toLowerCase()) > -1 ||
item.address.toLowerCase().indexOf(keyword.toLowerCase()) > -1
)
} else {
return true
}
Expand Down

0 comments on commit c06930f

Please sign in to comment.