Get rid of domain module, allow app to override default event type
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import {hexToBytes} from '@noble/hashes/utils'
|
||||
import {getPublicKey, finalizeEvent} from 'nostr-tools'
|
||||
import {now} from '@welshman/lib'
|
||||
import type {ExtensibleTrustedEvent, EventTemplate, Filter} from '@welshman/util'
|
||||
import type {CustomEvent, EventTemplate, Filter} from '@welshman/util'
|
||||
import {subscribe, publish} from '@welshman/net'
|
||||
|
||||
export type DVMHandler = {
|
||||
stop?: () => void
|
||||
handleEvent: (e: ExtensibleTrustedEvent) => AsyncGenerator<EventTemplate>
|
||||
handleEvent: (e: CustomEvent) => AsyncGenerator<EventTemplate>
|
||||
}
|
||||
|
||||
export type CreateDVMHandler = (dvm: DVM) => DVMHandler
|
||||
@@ -49,7 +49,7 @@ export class DVM {
|
||||
const filters = [filter]
|
||||
const sub = subscribe({relays, filters})
|
||||
|
||||
sub.emitter.on('event', (url: string, e: ExtensibleTrustedEvent) => this.onEvent(e))
|
||||
sub.emitter.on('event', (url: string, e: CustomEvent) => this.onEvent(e))
|
||||
sub.emitter.on('complete', () => resolve())
|
||||
})
|
||||
}
|
||||
@@ -63,8 +63,7 @@ export class DVM {
|
||||
this.active = false
|
||||
}
|
||||
|
||||
async onEvent(request: ExtensibleTrustedEvent) {
|
||||
console.log(request)
|
||||
async onEvent(request: CustomEvent) {
|
||||
const {expireAfter = 60 * 60} = this.opts
|
||||
|
||||
if (this.seen.has(request.id)) {
|
||||
|
||||
Reference in New Issue
Block a user