Skip to content

Commit

Permalink
Merge pull request #7 from bob2402/sha256
Browse files Browse the repository at this point in the history
problem: d-tag on problems is too short
  • Loading branch information
gsovereignty authored Sep 19, 2024
2 parents 1065ee0 + 9e91de9 commit 72be025
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"cmdk-sv": "^0.0.18",
"embla-carousel-svelte": "^8.2.1",
"formsnap": "^1.0.1",
"js-sha256": "^0.11.0",
"mode-watcher": "^0.4.1",
"paneforge": "^0.0.5",
"svelte-radix": "^1.1.1",
Expand Down
9 changes: 0 additions & 9 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,3 @@ export const flyAndScale = (
easing: cubicOut
};
};

export function generateRandomHex(length: number): string {
const hexChars = '0123456789abcdef';
let result = '';
for (let i = 0; i < length; i++) {
result += hexChars[Math.floor(Math.random() * 16)];
}
return result;
}
5 changes: 4 additions & 1 deletion src/routes/problems/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import TextareaField from '../../components/TextareaField.svelte';
import { onDestroy } from 'svelte';
import type { NDKEventStore } from '@nostr-dev-kit/ndk-svelte';
import { sha256 } from 'js-sha256';
import { generateRandomHex } from '@/utils';
import { derived } from 'svelte/store';
import { Problem } from '@/event_helpers/problems';
Expand Down Expand Up @@ -67,9 +68,11 @@
}
let e = new NDKEvent(ndk);
const identify = sha256(author.pubkey + tldr);
console.log('identify', identify);
e.author = author;
e.kind = 31971;
e.tags.push(['d', generateRandomHex(32)]);
e.tags.push(['d', identify]);
e.tags.push(['tldr', tldr]);
e.tags.push(['para', para]);
e.tags.push(['child_status', child_status]);
Expand Down

0 comments on commit 72be025

Please sign in to comment.