fix prettier checks on nip77 related *ts files

This commit is contained in:
max-gy
2025-11-10 13:29:55 +01:00
committed by fiatjaf_
parent e19db61bec
commit f5d0c0eb0f
2 changed files with 20 additions and 7 deletions

View File

@@ -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)

View File

@@ -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)
}