update stronghold
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user