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

@@ -5,14 +5,12 @@ import { useNDK } from '@libs/ndk/provider';
import { useStronghold } from '@stores/stronghold';
import { useAccount } from '@utils/hooks/useAccount';
import { useSecureStorage } from '@utils/hooks/useSecureStorage';
export function usePublish() {
const { ndk } = useNDK();
const { account } = useAccount();
const { load } = useSecureStorage();
const cachePrivkey = useStronghold((state) => state.privkey);
const privkey = useStronghold((state) => state.privkey);
const publish = async ({
content,
@@ -23,12 +21,7 @@ export function usePublish() {
kind: NDKKind | number;
tags: string[][];
}): Promise<NDKEvent> => {
let privkey: string;
if (cachePrivkey) {
privkey = cachePrivkey;
} else {
privkey = await load(account.pubkey);
}
if (!privkey) throw new Error('Private key not found');
const event = new NDKEvent(ndk);
const signer = new NDKPrivateKeySigner(privkey);