feat: upgrade to rust nostr 0.28

This commit is contained in:
2024-02-17 09:29:37 +07:00
parent f28a7ae82f
commit f47eba5af7
16 changed files with 352 additions and 210 deletions

View File

@@ -1,28 +1,17 @@
import {
PropsWithChildren,
createContext,
useContext,
useEffect,
useMemo,
} from "react";
import { PropsWithChildren, createContext, useContext, useMemo } from "react";
import { Ark } from "./ark";
export const ArkContext = createContext<Ark>(undefined);
export const ArkProvider = ({ children }: PropsWithChildren<object>) => {
const ark = useMemo(() => new Ark(), []);
useEffect(() => {
if (ark) ark.load_account();
}, []);
return <ArkContext.Provider value={ark}>{children}</ArkContext.Provider>;
const ark = useMemo(() => new Ark(), []);
return <ArkContext.Provider value={ark}>{children}</ArkContext.Provider>;
};
export const useArk = () => {
const context = useContext(ArkContext);
if (context === undefined) {
throw new Error("Ark Provider is not import");
}
return context;
const context = useContext(ArkContext);
if (context === undefined) {
throw new Error("Ark Provider is not import");
}
return context;
};