Skip to content

Commit

Permalink
Strip k: account prefix from public key field
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Looijenga committed Jan 25, 2024
1 parent 423448e commit c2b4bb9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/apps/tools/src/pages/faucet/new/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c2b4bb9

Please sign in to comment.