diff --git a/nip77.test.ts b/nip77.test.ts index 13479b5..510a309 100644 --- a/nip77.test.ts +++ b/nip77.test.ts @@ -28,10 +28,7 @@ function extractJSON(message: string) { describe('nip77 negentropy message helpers', () => { it('sendNegentropyMessage should send NEG-MSG with generated subscription id and filters flattened', () => { const relay = new MockRelay() - const filters: Filter[] = [ - { kinds: [1], authors: ['abc'] }, - { ids: ['deadbeef'] }, - ] + const filters: Filter[] = [{ kinds: [1], authors: ['abc'] }, { ids: ['deadbeef'] }] sendNegentropyMessage(relay as any, 'hello', filters) expect(relay.sent.length).toBe(1) diff --git a/nip77.ts b/nip77.ts index 9c83ec5..e210dbf 100644 --- a/nip77.ts +++ b/nip77.ts @@ -1,17 +1,33 @@ import { Filter } from './filter.ts' import { AbstractRelay } from './relay.ts' -function sendNegentropyToRelay(open: boolean, relay: AbstractRelay, msg: string, filters: Filter[], subscriptionId?: any): void { +function sendNegentropyToRelay( + open: boolean, + relay: AbstractRelay, + msg: string, + filters: Filter[], + subscriptionId?: any, +): void { const subId = subscriptionId || Math.random().toString(36).slice(2, 10) const parts: any[] = [open ? 'NEG-OPEN' : 'NEG-MSG', subId, ...filters, msg] relay.send(JSON.stringify(parts)) } -export function sendNegentropyMessage(relay: AbstractRelay, msg: string, filters: Filter[], subscriptionId?: any): void { +export function sendNegentropyMessage( + relay: AbstractRelay, + msg: string, + filters: Filter[], + subscriptionId?: any, +): void { sendNegentropyToRelay(false, relay, msg, filters, subscriptionId) } -export function openNegentropyWithMessage(relay: AbstractRelay, msg: string, filters: Filter[], subscriptionId?: any): void { +export function openNegentropyWithMessage( + relay: AbstractRelay, + msg: string, + filters: Filter[], + subscriptionId?: any, +): void { sendNegentropyToRelay(true, relay, msg, filters, subscriptionId) }