mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
fix prettier checks on nip77 related *ts files
This commit is contained in:
@@ -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)
|
||||
|
||||
22
nip77.ts
22
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user