mirror of
https://github.com/Cameri/nostream.git
synced 2025-04-02 08:58:20 +02:00
fix: treat kind 0 and 3 as replaceable events
This commit is contained in:
parent
55e47a22b1
commit
7a615a99be
@ -6,6 +6,10 @@ export enum EventKinds {
|
||||
ENCRYPTED_DIRECT_MESSAGE = 4,
|
||||
DELETE = 5,
|
||||
REACTION = 7,
|
||||
REPLACEABLE_FIRST = 10000,
|
||||
REPLACEABLE_LAST = 19999,
|
||||
EPHEMERAL_FIRST = 20000,
|
||||
EPHEMERAL_LAST = 29999,
|
||||
}
|
||||
|
||||
export enum EventTags {
|
||||
|
@ -167,7 +167,7 @@ export const isEventSignatureValid = async (event: Event): Promise<boolean> => {
|
||||
}
|
||||
|
||||
export const isReplaceableEvent = (event: Event): boolean => {
|
||||
return event.kind >= 10000 && event.kind < 20000
|
||||
return event.kind === 0 || event.kind === 3 || (event.kind >= 10000 && event.kind < 20000)
|
||||
}
|
||||
|
||||
export const isEphemeralEvent = (event: Event): boolean => {
|
||||
|
@ -318,11 +318,19 @@ describe('NIP-12', () => {
|
||||
describe('NIP-16', () => {
|
||||
describe('isReplaceableEvent', () => {
|
||||
it('returns true if event is replaceable', () => {
|
||||
expect(isReplaceableEvent({ kind: 10000 } as any)).to.be.true
|
||||
expect(isReplaceableEvent({ kind: EventKinds.REPLACEABLE_FIRST } as any)).to.be.true
|
||||
})
|
||||
|
||||
it('returns true if event is set_metadata', () => {
|
||||
expect(isReplaceableEvent({ kind: EventKinds.SET_METADATA } as any)).to.be.true
|
||||
})
|
||||
|
||||
it('returns true if event is contact_list', () => {
|
||||
expect(isReplaceableEvent({ kind: EventKinds.CONTACT_LIST } as any)).to.be.true
|
||||
})
|
||||
|
||||
it('returns false if event is not replaceable', () => {
|
||||
expect(isReplaceableEvent({ kind: 20000 } as any)).to.be.false
|
||||
expect(isReplaceableEvent({ kind: EventKinds.REPLACEABLE_LAST + 1 } as any)).to.be.false
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user