update stronghold

This commit is contained in:
Ren Amamiya
2023-07-20 08:57:58 +07:00
parent a80477b40e
commit bbfdb139c6
16 changed files with 74 additions and 127 deletions

View File

@@ -3,11 +3,8 @@ import { create } from 'zustand';
interface OnboardingState {
profile: { [x: string]: string };
pubkey: string;
privkey: string;
createProfile: (data: { [x: string]: string }) => void;
setPubkey: (pubkey: string) => void;
setPrivkey: (privkey: string) => void;
clearPrivkey: (privkey: string) => void;
}
export const useOnboarding = create<OnboardingState>((set) => ({
@@ -20,10 +17,4 @@ export const useOnboarding = create<OnboardingState>((set) => ({
setPubkey: (pubkey: string) => {
set({ pubkey: pubkey });
},
setPrivkey: (privkey: string) => {
set({ privkey: privkey });
},
clearPrivkey: () => {
set({ privkey: '' });
},
}));

View File

@@ -1,19 +1,22 @@
import { create } from 'zustand';
import { createJSONStorage, persist } from 'zustand/middleware';
interface StrongholdState {
password: null | string;
privkey: null | string;
setPassword: (password: string) => void;
setPrivkey: (privkey: string) => void;
}
export const useStronghold = create<StrongholdState>((set) => ({
password: null,
privkey: null,
setPassword: (password: string) => {
set({ password: password });
},
setPrivkey: (privkey: string) => {
set({ privkey: privkey });
},
}));
export const useStronghold = create<StrongholdState>()(
persist(
(set) => ({
privkey: null,
setPrivkey: (privkey: string) => {
set({ privkey: privkey });
},
}),
{
name: 'stronghold',
storage: createJSONStorage(() => sessionStorage),
}
)
);