From e20fbf491681842b3f8b7fb587e2916e57d12a36 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Thu, 17 Mar 2022 17:19:20 +0800 Subject: [PATCH 1/5] feat: reverse address to domian component --- .../plugin-infra/src/web3/ReverseAddress.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 packages/plugin-infra/src/web3/ReverseAddress.tsx diff --git a/packages/plugin-infra/src/web3/ReverseAddress.tsx b/packages/plugin-infra/src/web3/ReverseAddress.tsx new file mode 100644 index 000000000000..d2905f19ccbe --- /dev/null +++ b/packages/plugin-infra/src/web3/ReverseAddress.tsx @@ -0,0 +1,18 @@ +import { memo } from 'react' +import type { NetworkPluginID } from '../web3-types' +import { useReverseAddress } from '../hooks' +import { useWeb3State } from './useWeb3State' + +interface ReverseAddressProps { + address: string + pluginId?: NetworkPluginID +} + +export const ReverseAddress = memo(({ address, pluginId }) => { + const { value: domain } = useReverseAddress(address, pluginId) + const { Utils } = useWeb3State(pluginId) + + if (!domain || !Utils?.formatDomainName) return null + + return <>{Utils.formatDomainName(domain)} +}) From 63e330ecac01c14b570ebc7ad61b67a870c11954 Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Thu, 17 Mar 2022 17:36:09 +0800 Subject: [PATCH 2/5] fix: add format ethereum address --- packages/plugin-infra/src/web3/ReverseAddress.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugin-infra/src/web3/ReverseAddress.tsx b/packages/plugin-infra/src/web3/ReverseAddress.tsx index d2905f19ccbe..1fda749e8fd8 100644 --- a/packages/plugin-infra/src/web3/ReverseAddress.tsx +++ b/packages/plugin-infra/src/web3/ReverseAddress.tsx @@ -6,13 +6,15 @@ import { useWeb3State } from './useWeb3State' interface ReverseAddressProps { address: string pluginId?: NetworkPluginID + domainSize?: number + addressSize?: number } -export const ReverseAddress = memo(({ address, pluginId }) => { +export const ReverseAddress = memo(({ address, pluginId, domainSize, addressSize }) => { const { value: domain } = useReverseAddress(address, pluginId) const { Utils } = useWeb3State(pluginId) - if (!domain || !Utils?.formatDomainName) return null + if (!domain || !Utils?.formatDomainName) return <>{Utils?.formatAddress?.(address, addressSize)} - return <>{Utils.formatDomainName(domain)} + return <>{Utils.formatDomainName(domain, domainSize)} }) From 8a0a4cb6bc727c2ffa2e6985cc92e4cce670015f Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Thu, 17 Mar 2022 17:44:12 +0800 Subject: [PATCH 3/5] fix: eslint --- packages/encryption/src/encryption/Decryption.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/encryption/src/encryption/Decryption.ts b/packages/encryption/src/encryption/Decryption.ts index 14de441a4ede..c29b828d5e0f 100644 --- a/packages/encryption/src/encryption/Decryption.ts +++ b/packages/encryption/src/encryption/Decryption.ts @@ -116,7 +116,6 @@ async function* v37ECDHE( encryptedPostKey: encryption.ownersAESKeyEncrypted.val, postKeyIV: iv, } - debugger yield key } yield* io.queryPostKey_version37(iv, signal) From 45bc536faa56313d9bc3025bd024fbfaeac11f0c Mon Sep 17 00:00:00 2001 From: nuanyang233 <528944303@qq.com> Date: Fri, 18 Mar 2022 11:40:36 +0800 Subject: [PATCH 4/5] fix: support ens name on ins --- .../DashboardComponents/CollectibleList/index.tsx | 6 +++--- packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatar.tsx | 3 ++- .../mask/src/plugins/Collectible/SNSAdaptor/NFTPage.tsx | 4 ++-- packages/shared/package.json | 1 + .../src/UI/components/ReverseAddress/index.tsx} | 6 ++---- packages/shared/src/UI/components/index.ts | 1 + packages/shared/tsconfig.json | 3 ++- pnpm-lock.yaml | 2 ++ 8 files changed, 15 insertions(+), 11 deletions(-) rename packages/{plugin-infra/src/web3/ReverseAddress.tsx => shared/src/UI/components/ReverseAddress/index.tsx} (73%) diff --git a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx index 9e994e5222e2..18854f54afee 100644 --- a/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx +++ b/packages/mask/src/extension/options-page/DashboardComponents/CollectibleList/index.tsx @@ -5,7 +5,6 @@ import { ChainId, ERC721ContractDetailed, ERC721TokenDetailed, - formatEthereumAddress, isSameAddress, NonFungibleAssetProvider, SocketState, @@ -22,6 +21,7 @@ import { WalletMessages } from '@masknet/plugin-wallet' import { CollectionIcon } from './CollectionIcon' import { uniqBy } from 'lodash-unified' import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' +import { ReverseAddress } from '@masknet/shared' export const CollectibleContext = createContext<{ collectiblesRetry: () => void @@ -301,7 +301,7 @@ export function CollectionList({ className={classes.button} variant="outlined" size="small"> - {formatEthereumAddress(addressName.label, 5)} + @@ -330,7 +330,7 @@ export function CollectionList({ diff --git a/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatar.tsx b/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatar.tsx index b0082df47dfd..8ed966851826 100644 --- a/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatar.tsx +++ b/packages/mask/src/plugins/Avatar/SNSAdaptor/NFTAvatar.tsx @@ -17,6 +17,7 @@ import { EthereumChainBoundary } from '../../../web3/UI/EthereumChainBoundary' import { AddNFT } from './AddNFT' import { NFTImage } from './NFTImage' import { useAccount, useWeb3State } from '@masknet/plugin-infra' +import { ReverseAddress } from '@masknet/shared' const useStyles = makeStyles()((theme) => ({ root: {}, @@ -142,7 +143,7 @@ export function NFTAvatar(props: NFTAvatarProps) { {account ? ( - {t('nft_wallet_label')}: {Utils?.formatAddress?.(account, 4) || account} + {t('nft_wallet_label')}: {!hideWallet ? (