diff --git a/event.go b/event.go index 156ca0d..cce165e 100644 --- a/event.go +++ b/event.go @@ -82,24 +82,3 @@ func (evt *Event) Serialize() []byte { return dst } - -// IsRegular checks if the given kind is in Regular range. -func (evt *Event) IsRegular() bool { - return evt.Kind < 10000 && evt.Kind != 0 && evt.Kind != 3 -} - -// IsReplaceable checks if the given kind is in Replaceable range. -func (evt *Event) IsReplaceable() bool { - return evt.Kind == 0 || evt.Kind == 3 || - (10000 <= evt.Kind && evt.Kind < 20000) -} - -// IsEphemeral checks if the given kind is in Ephemeral range. -func (evt *Event) IsEphemeral() bool { - return 20000 <= evt.Kind && evt.Kind < 30000 -} - -// IsAddressable checks if the given kind is in Addressable range. -func (evt *Event) IsAddressable() bool { - return 30000 <= evt.Kind && evt.Kind < 40000 -} diff --git a/event_test.go b/event_test.go index c61ff36..0cde38b 100644 --- a/event_test.go +++ b/event_test.go @@ -116,15 +116,3 @@ func BenchmarkIDCheck(b *testing.B) { } }) } - -func EventKindTest(t *testing.T) { - require.True(t, (&Event{Kind: 1}).IsRegular()) - require.True(t, (&Event{Kind: 9}).IsRegular()) - require.True(t, (&Event{Kind: 1111}).IsRegular()) - require.True(t, (&Event{Kind: 0}).IsReplaceable()) - require.True(t, (&Event{Kind: 3}).IsReplaceable()) - require.True(t, (&Event{Kind: 10002}).IsReplaceable()) - require.True(t, (&Event{Kind: 10050}).IsReplaceable()) - require.True(t, (&Event{Kind: 30023}).IsAddressable()) - require.True(t, (&Event{Kind: 39000}).IsAddressable()) -} diff --git a/kinds.go b/kinds.go index 73f614d..177b2fd 100644 --- a/kinds.go +++ b/kinds.go @@ -132,3 +132,19 @@ const ( KindSimpleGroupAdmins int = 39001 KindSimpleGroupMembers int = 39002 ) + +func IsRegularKind(kind int) bool { + return kind < 10000 && kind != 0 && kind != 3 +} + +func IsReplaceableKind(kind int) bool { + return kind == 0 || kind == 3 || (10000 <= kind && kind < 20000) +} + +func IsEphemeralKind(kind int) bool { + return 20000 <= kind && kind < 30000 +} + +func IsAddressableKind(kind int) bool { + return 30000 <= kind && kind < 40000 +} diff --git a/kinds_test.go b/kinds_test.go new file mode 100644 index 0000000..e834237 --- /dev/null +++ b/kinds_test.go @@ -0,0 +1,19 @@ +package nostr + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func KindKindTest(t *testing.T) { + require.True(t, IsRegularKind(1)) + require.True(t, IsRegularKind(9)) + require.True(t, IsRegularKind(1111)) + require.True(t, IsReplaceableKind(0)) + require.True(t, IsReplaceableKind(3)) + require.True(t, IsReplaceableKind(10002)) + require.True(t, IsReplaceableKind(10050)) + require.True(t, IsAddressableKind(30023)) + require.True(t, IsAddressableKind(39000)) +}