From c2b4bb909ce54246baff3fd24ca99f4f3362137e Mon Sep 17 00:00:00 2001 From: Sander Looijenga Date: Thu, 25 Jan 2024 11:53:00 +0100 Subject: [PATCH] Strip k: account prefix from public key field --- packages/apps/tools/src/pages/faucet/new/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/apps/tools/src/pages/faucet/new/index.tsx b/packages/apps/tools/src/pages/faucet/new/index.tsx index fa327756ab..9f303b6606 100644 --- a/packages/apps/tools/src/pages/faucet/new/index.tsx +++ b/packages/apps/tools/src/pages/faucet/new/index.tsx @@ -53,6 +53,7 @@ import { usePersistentChainID } from '@/hooks'; import { createPrincipal } from '@/services/faucet/create-principal'; import { fundCreateNewAccount } from '@/services/faucet/fund-create-new'; import { validatePublicKey } from '@/services/utils/utils'; +import { stripAccountPrefix } from '@/utils/string'; import { zodResolver } from '@hookform/resolvers/zod'; import { useQuery } from '@tanstack/react-query'; import Trans from 'next-translate/Trans'; @@ -256,17 +257,17 @@ const NewAccountFaucetPage: FC = () => { requestStatus.status === 'processing' || mainnetSelected; const addPublicKey = () => { - const value = getValues('pubKey'); + const value = stripAccountPrefix(getValues('pubKey') || ''); const copyPubKeys = [...pubKeys]; - const isDuplicate = copyPubKeys.includes(value!); + const isDuplicate = copyPubKeys.includes(value); if (isDuplicate) { setError('pubKey', { message: t('Duplicate public key') }); return; } - copyPubKeys.push(value!); + copyPubKeys.push(value); setPubKeys(copyPubKeys); resetField('pubKey'); }; @@ -398,7 +399,9 @@ const NewAccountFaucetPage: FC = () => { variant="text" onPress={() => { const value = getValues('pubKey'); - const valid = validatePublicKey(value || ''); + const valid = validatePublicKey( + stripAccountPrefix(value || ''), + ); if (valid) { addPublicKey(); } else {