feat: pow
This commit is contained in:
@@ -95,7 +95,14 @@ export default function AudioPlayer({ src, className }: AudioPlayerProps) {
|
||||
|
||||
{/* Progress Section */}
|
||||
<div className="flex-1 relative">
|
||||
<Slider value={[currentTime]} max={duration || 100} step={1} onValueChange={handleSeek} />
|
||||
<Slider
|
||||
value={[currentTime]}
|
||||
max={duration || 100}
|
||||
step={1}
|
||||
onValueChange={handleSeek}
|
||||
hideThumb
|
||||
enableHoverAnimation
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="text-sm font-mono text-muted-foreground">
|
||||
|
||||
@@ -4,7 +4,8 @@ import { ScrollArea } from '@/components/ui/scroll-area'
|
||||
import {
|
||||
createCommentDraftEvent,
|
||||
createPollDraftEvent,
|
||||
createShortTextNoteDraftEvent
|
||||
createShortTextNoteDraftEvent,
|
||||
deleteDraftEventCache
|
||||
} from '@/lib/draft-event'
|
||||
import { isTouchDevice } from '@/lib/utils'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
@@ -56,6 +57,7 @@ export default function PostContent({
|
||||
endsAt: undefined,
|
||||
relays: []
|
||||
})
|
||||
const [minPow, setMinPow] = useState(0)
|
||||
const isFirstRender = useRef(true)
|
||||
const canPost =
|
||||
!!pubkey &&
|
||||
@@ -133,10 +135,12 @@ export default function PostContent({
|
||||
|
||||
const newEvent = await publish(draftEvent, {
|
||||
specifiedRelayUrls,
|
||||
additionalRelayUrls: isPoll ? pollCreateData.relays : []
|
||||
additionalRelayUrls: isPoll ? pollCreateData.relays : [],
|
||||
minPow
|
||||
})
|
||||
addReplies([newEvent])
|
||||
postEditorCache.clearPostCache({ defaultContent, parentEvent })
|
||||
deleteDraftEventCache(draftEvent)
|
||||
addReplies([newEvent])
|
||||
close()
|
||||
} catch (error) {
|
||||
if (error instanceof AggregateError) {
|
||||
@@ -311,11 +315,14 @@ export default function PostContent({
|
||||
</div>
|
||||
</div>
|
||||
<PostOptions
|
||||
posting={posting}
|
||||
show={showMoreOptions}
|
||||
addClientTag={addClientTag}
|
||||
setAddClientTag={setAddClientTag}
|
||||
isNsfw={isNsfw}
|
||||
setIsNsfw={setIsNsfw}
|
||||
minPow={minPow}
|
||||
setMinPow={setMinPow}
|
||||
/>
|
||||
<div className="flex gap-2 items-center justify-around sm:hidden">
|
||||
<Button
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Slider } from '@/components/ui/slider'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { StorageKey } from '@/constants'
|
||||
import { Dispatch, SetStateAction, useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export default function PostOptions({
|
||||
posting,
|
||||
show,
|
||||
addClientTag,
|
||||
setAddClientTag,
|
||||
isNsfw,
|
||||
setIsNsfw
|
||||
setIsNsfw,
|
||||
minPow,
|
||||
setMinPow
|
||||
}: {
|
||||
posting: boolean
|
||||
show: boolean
|
||||
addClientTag: boolean
|
||||
setAddClientTag: Dispatch<SetStateAction<boolean>>
|
||||
isNsfw: boolean
|
||||
setIsNsfw: Dispatch<SetStateAction<boolean>>
|
||||
minPow: number
|
||||
setMinPow: Dispatch<SetStateAction<number>>
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -43,6 +50,7 @@ export default function PostOptions({
|
||||
id="add-client-tag"
|
||||
checked={addClientTag}
|
||||
onCheckedChange={onAddClientTagChange}
|
||||
disabled={posting}
|
||||
/>
|
||||
</div>
|
||||
<div className="text-muted-foreground text-xs">
|
||||
@@ -52,7 +60,24 @@ export default function PostOptions({
|
||||
|
||||
<div className="flex items-center space-x-2">
|
||||
<Label htmlFor="add-nsfw-tag">{t('NSFW')}</Label>
|
||||
<Switch id="add-nsfw-tag" checked={isNsfw} onCheckedChange={onNsfwChange} />
|
||||
<Switch
|
||||
id="add-nsfw-tag"
|
||||
checked={isNsfw}
|
||||
onCheckedChange={onNsfwChange}
|
||||
disabled={posting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 pb-4">
|
||||
<Label>{t('Proof of Work (difficulty {{minPow}})', { minPow })}</Label>
|
||||
<Slider
|
||||
defaultValue={[0]}
|
||||
value={[minPow]}
|
||||
onValueChange={([pow]) => setMinPow(pow)}
|
||||
max={28}
|
||||
step={1}
|
||||
disabled={posting}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -5,8 +5,11 @@ import { cn } from '@/lib/utils'
|
||||
|
||||
const Slider = React.forwardRef<
|
||||
React.ElementRef<typeof SliderPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & { hideThumb?: boolean }
|
||||
>(({ className, ...props }, ref) => {
|
||||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & {
|
||||
hideThumb?: boolean
|
||||
enableHoverAnimation?: boolean
|
||||
}
|
||||
>(({ className, hideThumb, enableHoverAnimation, ...props }, ref) => {
|
||||
const [isHovered, setIsHovered] = React.useState(false)
|
||||
|
||||
return (
|
||||
@@ -22,17 +25,18 @@ const Slider = React.forwardRef<
|
||||
<SliderPrimitive.Track
|
||||
className={cn(
|
||||
'relative w-full grow overflow-hidden rounded-full bg-primary/20 cursor-pointer transition-all',
|
||||
isHovered ? 'h-3' : 'h-1.5'
|
||||
isHovered && enableHoverAnimation ? 'h-3' : 'h-1.5'
|
||||
)}
|
||||
>
|
||||
<SliderPrimitive.Range className="absolute h-full bg-primary rounded-full" />
|
||||
<SliderPrimitive.Range className="absolute h-full bg-primary disabled:bg-primary/30 rounded-full" />
|
||||
</SliderPrimitive.Track>
|
||||
{/* <SliderPrimitive.Thumb
|
||||
className={cn(
|
||||
'block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-all duration-300 cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
|
||||
isHovered ? 'opacity-100' : 'opacity-0'
|
||||
)}
|
||||
/> */}
|
||||
{!hideThumb && (
|
||||
<SliderPrimitive.Thumb
|
||||
className={cn(
|
||||
'block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-all duration-300 cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50'
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</SliderPrimitive.Root>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -399,6 +399,7 @@ export default {
|
||||
Detailed: 'تفصيلي',
|
||||
Compact: 'مضغوط',
|
||||
'Submit Relay': 'إرسال ريلاي',
|
||||
Homepage: 'الصفحة الرئيسية'
|
||||
Homepage: 'الصفحة الرئيسية',
|
||||
'Proof of Work (difficulty {{minPow}})': 'إثبات العمل (الصعوبة {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +409,7 @@ export default {
|
||||
Detailed: 'Detailliert',
|
||||
Compact: 'Kompakt',
|
||||
'Submit Relay': 'Relay einreichen',
|
||||
Homepage: 'Homepage'
|
||||
Homepage: 'Homepage',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Arbeitsnachweis (Schwierigkeit {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,6 +398,7 @@ export default {
|
||||
Detailed: 'Detailed',
|
||||
Compact: 'Compact',
|
||||
'Submit Relay': 'Submit Relay',
|
||||
Homepage: 'Homepage'
|
||||
Homepage: 'Homepage',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Proof of Work (difficulty {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,7 @@ export default {
|
||||
Detailed: 'Detallado',
|
||||
Compact: 'Compacto',
|
||||
'Submit Relay': 'Enviar relé',
|
||||
Homepage: 'Página principal'
|
||||
Homepage: 'Página principal',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Prueba de Trabajo (dificultad {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +400,7 @@ export default {
|
||||
Detailed: 'تفصیلی',
|
||||
Compact: 'فشرده',
|
||||
'Submit Relay': 'ارسال رله',
|
||||
Homepage: 'صفحه اصلی'
|
||||
Homepage: 'صفحه اصلی',
|
||||
'Proof of Work (difficulty {{minPow}})': 'اثبات کار (دشواری {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,6 +409,7 @@ export default {
|
||||
Detailed: 'Détaillé',
|
||||
Compact: 'Compact',
|
||||
'Submit Relay': 'Soumettre un relais',
|
||||
Homepage: 'Page d’accueil'
|
||||
Homepage: 'Page d’accueil',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Preuve de travail (difficulté {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,6 +403,7 @@ export default {
|
||||
Detailed: 'विस्तृत',
|
||||
Compact: 'संक्षिप्त',
|
||||
'Submit Relay': 'रिले सबमिट करें',
|
||||
Homepage: 'होमपेज'
|
||||
Homepage: 'होमपेज',
|
||||
'Proof of Work (difficulty {{minPow}})': 'कार्य प्रमाण (कठिनाई {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,7 @@ export default {
|
||||
Detailed: 'Dettagliato',
|
||||
Compact: 'Compatto',
|
||||
'Submit Relay': 'Invia Relay',
|
||||
Homepage: 'Homepage'
|
||||
Homepage: 'Homepage',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Proof of Work (difficoltà {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +401,7 @@ export default {
|
||||
Detailed: '詳細',
|
||||
Compact: 'コンパクト',
|
||||
'Submit Relay': 'リレーを提出',
|
||||
Homepage: 'ホームページ'
|
||||
Homepage: 'ホームページ',
|
||||
'Proof of Work (difficulty {{minPow}})': 'プルーフオブワーク (難易度 {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +401,7 @@ export default {
|
||||
Detailed: '상세',
|
||||
Compact: '간단',
|
||||
'Submit Relay': '릴레이 제출',
|
||||
Homepage: '홈페이지'
|
||||
Homepage: '홈페이지',
|
||||
'Proof of Work (difficulty {{minPow}})': '작업 증명 (난이도 {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,6 +405,7 @@ export default {
|
||||
Detailed: 'Szczegółowy',
|
||||
Compact: 'Zwięzły',
|
||||
'Submit Relay': 'Prześlij przekaźnik',
|
||||
Homepage: 'Strona główna'
|
||||
Homepage: 'Strona główna',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Dowód pracy (trudność {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +401,7 @@ export default {
|
||||
Detailed: 'Detalhado',
|
||||
Compact: 'Compacto',
|
||||
'Submit Relay': 'Enviar Relay',
|
||||
Homepage: 'Página inicial'
|
||||
Homepage: 'Página inicial',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Prova de Trabalho (dificuldade {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,7 @@ export default {
|
||||
Detailed: 'Detalhado',
|
||||
Compact: 'Compacto',
|
||||
'Submit Relay': 'Enviar Relay',
|
||||
Homepage: 'Página inicial'
|
||||
Homepage: 'Página inicial',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Prova de Trabalho (dificuldade {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +406,7 @@ export default {
|
||||
Detailed: 'Подробный',
|
||||
Compact: 'Компактный',
|
||||
'Submit Relay': 'Отправить релей',
|
||||
Homepage: 'Домашняя страница'
|
||||
Homepage: 'Домашняя страница',
|
||||
'Proof of Work (difficulty {{minPow}})': 'Доказательство работы (сложность {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,6 +396,7 @@ export default {
|
||||
Detailed: 'รายละเอียด',
|
||||
Compact: 'กะทัดรัด',
|
||||
'Submit Relay': 'ส่งรีเลย์',
|
||||
Homepage: 'หน้าแรก'
|
||||
Homepage: 'หน้าแรก',
|
||||
'Proof of Work (difficulty {{minPow}})': 'หลักฐานการทำงาน (ความยาก {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,6 +394,7 @@ export default {
|
||||
Detailed: '详细',
|
||||
Compact: '紧凑',
|
||||
'Submit Relay': '提交服务器',
|
||||
Homepage: '主页'
|
||||
Homepage: '主页',
|
||||
'Proof of Work (difficulty {{minPow}})': '工作量证明 (难度 {{minPow}})'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
TPollCreateData,
|
||||
TRelaySet
|
||||
} from '@/types'
|
||||
import { sha256 } from '@noble/hashes/sha2'
|
||||
import dayjs from 'dayjs'
|
||||
import { Event, kinds, nip19 } from 'nostr-tools'
|
||||
import {
|
||||
@@ -22,6 +23,39 @@ import {
|
||||
import { randomString } from './random'
|
||||
import { generateBech32IdFromETag, tagNameEquals } from './tag'
|
||||
|
||||
const draftEventCache: Map<string, string> = new Map()
|
||||
|
||||
export function deleteDraftEventCache(draftEvent: TDraftEvent) {
|
||||
const key = generateDraftEventCacheKey(draftEvent)
|
||||
draftEventCache.delete(key)
|
||||
}
|
||||
|
||||
function setDraftEventCache(baseDraft: Omit<TDraftEvent, 'created_at'>): TDraftEvent {
|
||||
const cacheKey = generateDraftEventCacheKey(baseDraft)
|
||||
const cache = draftEventCache.get(cacheKey)
|
||||
if (cache) {
|
||||
return JSON.parse(cache)
|
||||
}
|
||||
const draftEvent = { ...baseDraft, created_at: dayjs().unix() }
|
||||
draftEventCache.set(cacheKey, JSON.stringify(draftEvent))
|
||||
|
||||
return draftEvent
|
||||
}
|
||||
|
||||
function generateDraftEventCacheKey(draft: Omit<TDraftEvent, 'created_at'>) {
|
||||
const str = JSON.stringify({
|
||||
content: draft.content,
|
||||
kind: draft.kind,
|
||||
tags: draft.tags
|
||||
})
|
||||
|
||||
const encoder = new TextEncoder()
|
||||
const data = encoder.encode(str)
|
||||
const hashBuffer = sha256(data)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
|
||||
// https://github.com/nostr-protocol/nips/blob/master/25.md
|
||||
export function createReactionDraftEvent(event: Event, emoji: TEmoji | string = '+'): TDraftEvent {
|
||||
const tags: string[][] = []
|
||||
@@ -68,7 +102,6 @@ export function createRepostDraftEvent(event: Event): TDraftEvent {
|
||||
}
|
||||
}
|
||||
|
||||
const shortTextNoteDraftEventCache: Map<string, TDraftEvent> = new Map()
|
||||
export async function createShortTextNoteDraftEvent(
|
||||
content: string,
|
||||
mentions: string[],
|
||||
@@ -125,15 +158,7 @@ export async function createShortTextNoteDraftEvent(
|
||||
content: transformedEmojisContent,
|
||||
tags
|
||||
}
|
||||
const cacheKey = JSON.stringify(baseDraft)
|
||||
const cache = shortTextNoteDraftEventCache.get(cacheKey)
|
||||
if (cache) {
|
||||
return cache
|
||||
}
|
||||
const draftEvent = { ...baseDraft, created_at: dayjs().unix() }
|
||||
shortTextNoteDraftEventCache.set(cacheKey, draftEvent)
|
||||
|
||||
return draftEvent
|
||||
return setDraftEventCache(baseDraft)
|
||||
}
|
||||
|
||||
// https://github.com/nostr-protocol/nips/blob/master/51.md
|
||||
@@ -150,7 +175,6 @@ export function createRelaySetDraftEvent(relaySet: Omit<TRelaySet, 'aTag'>): TDr
|
||||
}
|
||||
}
|
||||
|
||||
const commentDraftEventCache: Map<string, TDraftEvent> = new Map()
|
||||
export async function createCommentDraftEvent(
|
||||
content: string,
|
||||
parentEvent: Event,
|
||||
@@ -228,15 +252,7 @@ export async function createCommentDraftEvent(
|
||||
content: transformedEmojisContent,
|
||||
tags
|
||||
}
|
||||
const cacheKey = JSON.stringify(baseDraft)
|
||||
const cache = commentDraftEventCache.get(cacheKey)
|
||||
if (cache) {
|
||||
return cache
|
||||
}
|
||||
const draftEvent = { ...baseDraft, created_at: dayjs().unix() }
|
||||
commentDraftEventCache.set(cacheKey, draftEvent)
|
||||
|
||||
return draftEvent
|
||||
return setDraftEventCache(baseDraft)
|
||||
}
|
||||
|
||||
export function createRelayListDraftEvent(mailboxRelays: TMailboxRelay[]): TDraftEvent {
|
||||
@@ -325,7 +341,6 @@ export function createBlossomServerListDraftEvent(servers: string[]): TDraftEven
|
||||
}
|
||||
}
|
||||
|
||||
const pollDraftEventCache: Map<string, TDraftEvent> = new Map()
|
||||
export async function createPollDraftEvent(
|
||||
author: string,
|
||||
question: string,
|
||||
@@ -389,15 +404,7 @@ export async function createPollDraftEvent(
|
||||
kind: ExtendedKind.POLL,
|
||||
tags
|
||||
}
|
||||
const cacheKey = JSON.stringify(baseDraft)
|
||||
const cache = pollDraftEventCache.get(cacheKey)
|
||||
if (cache) {
|
||||
return cache
|
||||
}
|
||||
const draftEvent = { ...baseDraft, created_at: dayjs().unix() }
|
||||
pollDraftEventCache.set(cacheKey, draftEvent)
|
||||
|
||||
return draftEvent
|
||||
return setDraftEventCache(baseDraft)
|
||||
}
|
||||
|
||||
export function createPollResponseDraftEvent(
|
||||
|
||||
@@ -2,11 +2,12 @@ import { EMBEDDED_MENTION_REGEX, ExtendedKind } from '@/constants'
|
||||
import client from '@/services/client.service'
|
||||
import { TImetaInfo } from '@/types'
|
||||
import { LRUCache } from 'lru-cache'
|
||||
import { Event, kinds, nip19 } from 'nostr-tools'
|
||||
import { Event, kinds, nip19, UnsignedEvent } from 'nostr-tools'
|
||||
import { fastEventHash, getPow } from 'nostr-tools/nip13'
|
||||
import {
|
||||
getImetaInfoFromImetaTag,
|
||||
generateBech32IdFromATag,
|
||||
generateBech32IdFromETag,
|
||||
getImetaInfoFromImetaTag,
|
||||
tagNameEquals
|
||||
} from './tag'
|
||||
|
||||
@@ -256,6 +257,47 @@ export function createFakeEvent(event: Partial<Event>): Event {
|
||||
}
|
||||
}
|
||||
|
||||
export async function minePow(
|
||||
unsigned: UnsignedEvent,
|
||||
difficulty: number
|
||||
): Promise<Omit<Event, 'sig'>> {
|
||||
let count = 0
|
||||
|
||||
const event = unsigned as Omit<Event, 'sig'>
|
||||
const tag = ['nonce', count.toString(), difficulty.toString()]
|
||||
|
||||
event.tags.push(tag)
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const mine = () => {
|
||||
let iterations = 0
|
||||
|
||||
while (iterations < 1000) {
|
||||
const now = Math.floor(new Date().getTime() / 1000)
|
||||
|
||||
if (now !== event.created_at) {
|
||||
count = 0
|
||||
event.created_at = now
|
||||
}
|
||||
|
||||
tag[1] = (++count).toString()
|
||||
event.id = fastEventHash(event)
|
||||
|
||||
if (getPow(event.id) >= difficulty) {
|
||||
resolve(event)
|
||||
return
|
||||
}
|
||||
|
||||
iterations++
|
||||
}
|
||||
|
||||
setTimeout(mine, 0)
|
||||
}
|
||||
|
||||
mine()
|
||||
})
|
||||
}
|
||||
|
||||
// Legacy compare function for sorting compatibility
|
||||
// If return 0, it means the two events are equal.
|
||||
// If return a negative number, it means `b` should be retained, and `a` should be discarded.
|
||||
|
||||
@@ -7,7 +7,12 @@ import {
|
||||
createRelayListDraftEvent,
|
||||
createSeenNotificationsAtDraftEvent
|
||||
} from '@/lib/draft-event'
|
||||
import { getLatestEvent, getReplaceableEventIdentifier, isProtectedEvent } from '@/lib/event'
|
||||
import {
|
||||
getLatestEvent,
|
||||
getReplaceableEventIdentifier,
|
||||
isProtectedEvent,
|
||||
minePow
|
||||
} from '@/lib/event'
|
||||
import { getProfileFromEvent, getRelayListFromEvent } from '@/lib/event-metadata'
|
||||
import { formatPubkey, pubkeyToNpub } from '@/lib/pubkey'
|
||||
import client from '@/services/client.service'
|
||||
@@ -594,12 +599,22 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||
return event as VerifiedEvent
|
||||
}
|
||||
|
||||
const publish = async (draftEvent: TDraftEvent, options: TPublishOptions = {}) => {
|
||||
const publish = async (
|
||||
draftEvent: TDraftEvent,
|
||||
{ minPow = 0, ...options }: TPublishOptions = {}
|
||||
) => {
|
||||
if (!account || !signer || account.signerType === 'npub') {
|
||||
throw new Error('You need to login first')
|
||||
}
|
||||
|
||||
const event = await signEvent(draftEvent)
|
||||
const draft = JSON.parse(JSON.stringify(draftEvent)) as TDraftEvent
|
||||
let event: VerifiedEvent
|
||||
if (minPow > 0) {
|
||||
const unsignedEvent = await minePow({ ...draft, pubkey: account.pubkey }, minPow)
|
||||
event = await signEvent(unsignedEvent)
|
||||
} else {
|
||||
event = await signEvent(draft)
|
||||
}
|
||||
|
||||
if (event.kind !== kinds.Application && event.pubkey !== account.pubkey) {
|
||||
const eventAuthor = await client.fetchProfile(event.pubkey)
|
||||
|
||||
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
@@ -121,6 +121,7 @@ export type TImetaInfo = {
|
||||
export type TPublishOptions = {
|
||||
specifiedRelayUrls?: string[]
|
||||
additionalRelayUrls?: string[]
|
||||
minPow?: number
|
||||
}
|
||||
|
||||
export type TNoteListMode = 'posts' | 'postsAndReplies' | 'you'
|
||||
|
||||
Reference in New Issue
Block a user