From 26e0ecbbd192bb33a794f34665bfe7c6159ca987 Mon Sep 17 00:00:00 2001 From: Antoine Estienne Date: Wed, 16 Jun 2021 18:49:32 +0200 Subject: [PATCH] Aadd isEthereum props to ScanAddress to import eth addresses (#484) * add isEthereum props to ScanAddress to import eth addresses * fix missing seed --- packages/react-qr/src/ScanAddress.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-qr/src/ScanAddress.tsx b/packages/react-qr/src/ScanAddress.tsx index 69aa3a7e..770ef2ee 100644 --- a/packages/react-qr/src/ScanAddress.tsx +++ b/packages/react-qr/src/ScanAddress.tsx @@ -22,15 +22,16 @@ interface Props { onScan: (scanned: ScanType) => void; size?: string | number; style?: React.CSSProperties; + isEthereum?: boolean } -function ScanAddress ({ className, onError, onScan, size, style }: Props): React.ReactElement { +function ScanAddress ({ className, isEthereum, onError, onScan, size, style }: Props): React.ReactElement { const _onScan = useCallback( (data: string | null): void => { if (data) { try { const [prefix, content, genesisHash, ...name] = data.split(':'); - const isValidPrefix = prefix === ADDRESS_PREFIX || prefix === SEED_PREFIX; + const isValidPrefix = (prefix === (isEthereum ? 'ethereum' : ADDRESS_PREFIX)) || (prefix === SEED_PREFIX); assert(isValidPrefix, `Invalid prefix received, expected '${ADDRESS_PREFIX}/${SEED_PREFIX}' , found '${prefix}'`); @@ -46,7 +47,7 @@ function ScanAddress ({ className, onError, onScan, size, style }: Props): React } } }, - [onScan] + [onScan, isEthereum] ); return (