From 2f845fefbef1dee409dac78bf8d7cdf6065de062 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 6 May 2024 17:46:51 +0330 Subject: [PATCH] correct types --- .../src/popup/import/attachQR/index.tsx | 16 +++++++++------- .../popup/import/attachQrFullScreen/index.tsx | 14 ++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/extension-polkagate/src/popup/import/attachQR/index.tsx b/packages/extension-polkagate/src/popup/import/attachQR/index.tsx index f75e353ef..4648eca1e 100644 --- a/packages/extension-polkagate/src/popup/import/attachQR/index.tsx +++ b/packages/extension-polkagate/src/popup/import/attachQR/index.tsx @@ -3,6 +3,8 @@ /* eslint-disable react/jsx-max-props-per-line */ +import type { HexString } from '@polkadot/util/types'; + import { Button, Grid, Typography, useTheme } from '@mui/material'; import React, { useCallback, useContext, useEffect, useState } from 'react'; @@ -14,19 +16,19 @@ import { createAccountExternal, createAccountSuri, createSeed, updateMeta } from import HeaderBrand from '../../../partials/HeaderBrand'; import Name from '../../../partials/Name'; -interface QrAccount { - content: string; - genesisHash: string; +export interface ScanType { isAddress: boolean; - name?: string; + content: string; + genesisHash: HexString | null; + name?: string | undefined; } -export default function AttachQR(): React.ReactElement { +export default function AttachQR (): React.ReactElement { const { t } = useTranslation(); const theme = useTheme(); const { accounts } = useContext(AccountContext); const onAction = useContext(ActionContext); - const [account, setAccount] = useState(null); + const [account, setAccount] = useState(null); const [address, setAddress] = useState(null); const [name, setName] = useState(null); const [password, setPassword] = useState(null); @@ -60,7 +62,7 @@ export default function AttachQR(): React.ReactElement { }, [account, name, password, setQrLabelAndGoToHome]); const _setAccount = useCallback( - (qrAccount: QrAccount) => { + (qrAccount: ScanType) => { setAccount(qrAccount); setName(qrAccount?.name || null); setGenesisHash(qrAccount.genesisHash); diff --git a/packages/extension-polkagate/src/popup/import/attachQrFullScreen/index.tsx b/packages/extension-polkagate/src/popup/import/attachQrFullScreen/index.tsx index 39f1adafd..b06b93ec2 100644 --- a/packages/extension-polkagate/src/popup/import/attachQrFullScreen/index.tsx +++ b/packages/extension-polkagate/src/popup/import/attachQrFullScreen/index.tsx @@ -16,13 +16,7 @@ import { FullScreenHeader } from '../../../fullscreen/governance/FullScreenHeade import { useFullscreen, useTranslation } from '../../../hooks'; import { createAccountExternal, createAccountSuri, createSeed, updateMeta } from '../../../messaging'; import { Name } from '../../../partials'; - -interface QrAccount { - content: string; - genesisHash: string; - isAddress: boolean; - name?: string; -} +import { ScanType } from '../attachQR'; export default function AttachQrFullScreen (): React.ReactElement { useFullscreen(); @@ -30,7 +24,7 @@ export default function AttachQrFullScreen (): React.ReactElement { const theme = useTheme(); const { accounts } = useContext(AccountContext); const onAction = useContext(ActionContext); - const [account, setAccount] = useState(null); + const [account, setAccount] = useState(null); const [address, setAddress] = useState(null); const [name, setName] = useState(null); const [password, setPassword] = useState(null); @@ -61,7 +55,7 @@ export default function AttachQrFullScreen (): React.ReactElement { }, [account, name, password, setQrLabelAndGoToHome]); const _setAccount = useCallback( - (qrAccount: QrAccount) => { + (qrAccount: ScanType) => { setAccount(qrAccount); setName(qrAccount?.name || null); @@ -80,7 +74,7 @@ export default function AttachQrFullScreen (): React.ReactElement { onAction('/'); }, [onAction]); - const _onError = useCallback((error: string) => { + const _onError = useCallback((error: Error) => { setInvalidQR(String(error).includes('Invalid prefix')); }, []);