This commit is contained in:
zmeyer44 2023-10-18 16:34:33 -04:00
parent 98f7763d69
commit a6d6384e8c
3 changed files with 7 additions and 10 deletions

View File

@ -3,7 +3,7 @@ import FormModal from "./FormModal";
import { z } from "zod";
import { useModal } from "@/app/_providers/modal/provider";
import { toast } from "sonner";
import { generateRandomStringLength } from "@/lib/nostr";
import { randomId } 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 = generateRandomStringLength(8);
const random = randomId();
const tags = [
["title", data.title],
["name", data.title],

View File

@ -7,11 +7,7 @@ import NDK, {
type NostrEvent,
NDKUser,
} from "@nostr-dev-kit/ndk";
import {
generateRandomString,
encryptMessage,
generateRandomStringLength,
} from "@/lib/nostr";
import { generateRandomString, encryptMessage, randomId } from "@/lib/nostr";
import { unixTimeNowInSeconds } from "@/lib/nostr/dates";
import { getTagsValues } from "@/lib/nostr/utils";
@ -159,7 +155,7 @@ export async function createList(
tags: [
["name", title],
["description", description ?? ""],
["d", generateRandomStringLength(8)],
["d", randomId()],
],
});
}

View File

@ -146,6 +146,7 @@ function create32ByteBuffer(inputString: string) {
export function generateRandomString() {
return crypto.randomBytes(32).toString("hex");
}
export function generateRandomStringLength(length: number) {
return crypto.randomBytes(length).toString("hex");
export function randomId(): string {
return crypto.randomBytes(32).toString("hex").slice(0, 8);
}