NostrSignin: remove unused setSigner state
This commit is contained in:
parent
611e0e59f2
commit
b8b22fc637
|
@ -1,4 +1,3 @@
|
||||||
import { NostrSigner } from '@soapbox/nspec';
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import AccountStep from './steps/account-step';
|
import AccountStep from './steps/account-step';
|
||||||
|
@ -16,8 +15,6 @@ interface INostrSigninModal {
|
||||||
|
|
||||||
const NostrSigninModal: React.FC<INostrSigninModal> = ({ onClose }) => {
|
const NostrSigninModal: React.FC<INostrSigninModal> = ({ onClose }) => {
|
||||||
const [step, setStep] = useState<Step>(window.nostr ? 'extension' : 'identity');
|
const [step, setStep] = useState<Step>(window.nostr ? 'extension' : 'identity');
|
||||||
|
|
||||||
const [, setSigner] = useState<NostrSigner | undefined>();
|
|
||||||
const [accountId, setAccountId] = useState<string | undefined>();
|
const [accountId, setAccountId] = useState<string | undefined>();
|
||||||
|
|
||||||
const handleClose = () => onClose('NOSTR_SIGNIN');
|
const handleClose = () => onClose('NOSTR_SIGNIN');
|
||||||
|
@ -28,11 +25,11 @@ const NostrSigninModal: React.FC<INostrSigninModal> = ({ onClose }) => {
|
||||||
case 'identity':
|
case 'identity':
|
||||||
return <IdentityStep setAccountId={setAccountId} setStep={setStep} onClose={handleClose} />;
|
return <IdentityStep setAccountId={setAccountId} setStep={setStep} onClose={handleClose} />;
|
||||||
case 'key':
|
case 'key':
|
||||||
return <KeyStep setStep={setStep} onClose={handleClose} />;
|
return <KeyStep setStep={setStep} onClose={handleClose} />;
|
||||||
case 'key-add':
|
case 'key-add':
|
||||||
return <KeyAddStep setAccountId={setAccountId} setSigner={setSigner} setStep={setStep} onClose={handleClose} />;
|
return <KeyAddStep setAccountId={setAccountId} setStep={setStep} onClose={handleClose} />;
|
||||||
case 'keygen':
|
case 'keygen':
|
||||||
return <KeygenStep setAccountId={setAccountId} setSigner={setSigner} setStep={setStep} onClose={handleClose} />;
|
return <KeygenStep setAccountId={setAccountId} setStep={setStep} onClose={handleClose} />;
|
||||||
case 'account':
|
case 'account':
|
||||||
return <AccountStep accountId={accountId!} setStep={setStep} onClose={handleClose} />;
|
return <AccountStep accountId={accountId!} setStep={setStep} onClose={handleClose} />;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { NostrSigner } from '@soapbox/nspec';
|
|
||||||
import { getPublicKey, nip19 } from 'nostr-tools';
|
import { getPublicKey, nip19 } from 'nostr-tools';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
@ -12,12 +11,11 @@ import { Step } from '../nostr-signin-modal';
|
||||||
|
|
||||||
interface IKeyAddStep {
|
interface IKeyAddStep {
|
||||||
setAccountId(accountId: string): void;
|
setAccountId(accountId: string): void;
|
||||||
setSigner(signer: NostrSigner): void;
|
|
||||||
setStep(step: Step): void;
|
setStep(step: Step): void;
|
||||||
onClose(): void;
|
onClose(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const KeyAddStep: React.FC<IKeyAddStep> = ({ setAccountId, setSigner, setStep, onClose }) => {
|
const KeyAddStep: React.FC<IKeyAddStep> = ({ setAccountId, setStep, onClose }) => {
|
||||||
const [nsec, setNsec] = useState('');
|
const [nsec, setNsec] = useState('');
|
||||||
const [error, setError] = useState<string | undefined>();
|
const [error, setError] = useState<string | undefined>();
|
||||||
|
|
||||||
|
@ -32,9 +30,8 @@ const KeyAddStep: React.FC<IKeyAddStep> = ({ setAccountId, setSigner, setStep, o
|
||||||
if (result.type === 'nsec') {
|
if (result.type === 'nsec') {
|
||||||
const seckey = result.data;
|
const seckey = result.data;
|
||||||
const pubkey = getPublicKey(seckey);
|
const pubkey = getPublicKey(seckey);
|
||||||
const signer = NKeys.add(seckey);
|
NKeys.add(seckey);
|
||||||
setAccountId(pubkey);
|
setAccountId(pubkey);
|
||||||
setSigner(signer);
|
|
||||||
setStep('account');
|
setStep('account');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { NostrSigner } from '@soapbox/nspec';
|
|
||||||
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
|
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
@ -16,12 +15,11 @@ import { Step } from '../nostr-signin-modal';
|
||||||
|
|
||||||
interface IKeygenStep {
|
interface IKeygenStep {
|
||||||
setAccountId(accountId: string): void;
|
setAccountId(accountId: string): void;
|
||||||
setSigner(signer: NostrSigner): void;
|
|
||||||
setStep(step: Step): void;
|
setStep(step: Step): void;
|
||||||
onClose(): void;
|
onClose(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const KeygenStep: React.FC<IKeygenStep> = ({ setAccountId, setSigner, setStep, onClose }) => {
|
const KeygenStep: React.FC<IKeygenStep> = ({ setAccountId, setStep, onClose }) => {
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
@ -46,8 +44,7 @@ const KeygenStep: React.FC<IKeygenStep> = ({ setAccountId, setSigner, setStep, o
|
||||||
const handleCopy = () => setDownloaded(true);
|
const handleCopy = () => setDownloaded(true);
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = () => {
|
||||||
const signer = NKeys.add(secretKey);
|
NKeys.add(secretKey);
|
||||||
setSigner(signer);
|
|
||||||
setAccountId(pubkey); // HACK: Ditto uses pubkeys as account IDs.
|
setAccountId(pubkey); // HACK: Ditto uses pubkeys as account IDs.
|
||||||
setStep('account');
|
setStep('account');
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue