test
This commit is contained in:
parent
eecc3875fe
commit
98f7763d69
@ -3,7 +3,7 @@ import FormModal from "./FormModal";
|
||||
import { z } from "zod";
|
||||
import { useModal } from "@/app/_providers/modal/provider";
|
||||
import { toast } from "sonner";
|
||||
import { generateRandomString, randomId } from "@/lib/nostr";
|
||||
import { generateRandomStringLength } from "@/lib/nostr";
|
||||
import { satsToBtc } from "@/lib/utils";
|
||||
import useCurrentUser from "@/lib/hooks/useCurrentUser";
|
||||
import { useNDK } from "@/app/_providers/ndk";
|
||||
@ -34,7 +34,7 @@ export default function CreateList() {
|
||||
const { getSigner } = useSigner()!;
|
||||
async function handleSubmit(data: CreateListType) {
|
||||
setIsLoading(true);
|
||||
const random = randomId();
|
||||
const random = generateRandomStringLength(8);
|
||||
const tags = [
|
||||
["title", data.title],
|
||||
["name", data.title],
|
||||
|
@ -7,7 +7,11 @@ import NDK, {
|
||||
type NostrEvent,
|
||||
NDKUser,
|
||||
} from "@nostr-dev-kit/ndk";
|
||||
import { generateRandomString, encryptMessage, randomId } from "@/lib/nostr";
|
||||
import {
|
||||
generateRandomString,
|
||||
encryptMessage,
|
||||
generateRandomStringLength,
|
||||
} from "@/lib/nostr";
|
||||
import { unixTimeNowInSeconds } from "@/lib/nostr/dates";
|
||||
import { getTagsValues } from "@/lib/nostr/utils";
|
||||
|
||||
@ -155,7 +159,7 @@ export async function createList(
|
||||
tags: [
|
||||
["name", title],
|
||||
["description", description ?? ""],
|
||||
["d", randomId()],
|
||||
["d", generateRandomStringLength(8)],
|
||||
],
|
||||
});
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ export async function sendZap(
|
||||
) {
|
||||
console.log("sendzap called", amount);
|
||||
const event = await new NDKEvent(ndk, _event);
|
||||
console.log("Event", event);
|
||||
const pr = await event.zap(amount * 1000, comment);
|
||||
if (!pr) {
|
||||
console.log("No PR");
|
||||
|
@ -142,17 +142,10 @@ function create32ByteBuffer(inputString: string) {
|
||||
const buffer = Buffer.from(hash, "hex");
|
||||
return buffer;
|
||||
}
|
||||
export function randomId() {
|
||||
// @ts-ignore
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11)
|
||||
.replace(/[018]/g, (c: any) =>
|
||||
(
|
||||
c ^
|
||||
(crypto.getRandomValues(new Uint8Array(1))[0]! & (15 >> (c / 4)))
|
||||
).toString(16),
|
||||
)
|
||||
.slice(0, 8) as string;
|
||||
}
|
||||
|
||||
export function generateRandomString() {
|
||||
return crypto.randomBytes(32).toString("hex");
|
||||
}
|
||||
export function generateRandomStringLength(length: number) {
|
||||
return crypto.randomBytes(length).toString("hex");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user