diff --git a/README.md b/README.md
index 57159cb82..dbf467095 100644
--- a/README.md
+++ b/README.md
@@ -98,9 +98,9 @@ valid relay(s) must **_first_** be defined in [relays.properties](nostr-java-api
## Examples
I recommend having a look at these repositories/module for examples:
- - [nostr-example](https://github.com/tcheeric/nostr-java/tree/main/nostr-java-examples) module
- - [nostr-client](https://github.com/tcheeric/nostr-client) github repository
- - [SuperConductor](https://github.com/avlo/superconductor) nostr relay
+- [nostr-example](https://github.com/tcheeric/nostr-java/tree/main/nostr-java-examples) module
+- [nostr-client](https://github.com/tcheeric/nostr-client) github repository
+- [SuperConductor](https://github.com/avlo/superconductor) nostr relay
## Supported NIPs
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 1ee59078a..24807fb22 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -11,7 +11,7 @@ plugins {
}
group = 'xyz.tcheeric'
-version = '0.6.5-SNAPSHOT'
+version = '0.6.6-SNAPSHOT'
repositories {
mavenCentral()
diff --git a/buildSrc/src/main/groovy/nostr-java.conventions.gradle b/buildSrc/src/main/groovy/nostr-java.conventions.gradle
index b6e19f20b..dcc473528 100644
--- a/buildSrc/src/main/groovy/nostr-java.conventions.gradle
+++ b/buildSrc/src/main/groovy/nostr-java.conventions.gradle
@@ -15,7 +15,7 @@ plugins {
id 'org.gradle.test-retry'
}
-group = version = rootProject.property("nostr-java.group")
+group = rootProject.property("nostr-java.group")
version = rootProject.property("nostr-java.version")
description = rootProject.property("nostr-java.description")
@@ -38,7 +38,6 @@ publishing {
}
}
-
dependencies {
def springBootVersion = rootProject.property("nostr-java.springBootVersion")
def apacheCommonsLang3 = rootProject.property("nostr-java.apacheCommonsLang3")
@@ -61,7 +60,6 @@ dependencies {
implementation 'org.bouncycastle:bcprov-jdk18on:' + bouncyCastle
implementation 'org.apache.commons:commons-lang3:' + apacheCommonsLang3
- implementation 'com.google.guava:guava:' + googleGuava
implementation 'org.awaitility:awaitility:' + awaitility
implementation 'org.projectlombok:lombok:' + lombok
annotationProcessor 'org.awaitility:awaitility:' + awaitility
@@ -71,25 +69,20 @@ dependencies {
testImplementation 'org.projectlombok:lombok:' + lombok
testImplementation 'org.awaitility:awaitility:' + awaitility
testImplementation 'com.adarshr:gradle-test-logger-plugin:' + logger
+ testImplementation 'com.google.guava:guava:' + googleGuava
testAnnotationProcessor 'org.projectlombok:lombok:' + lombok
}
-configurations {
- compileOnly {
- extendsFrom annotationProcessor
- }
-}
-
tasks.test {
systemProperty("spring.profiles.active", "test")
useJUnitPlatform()
-// retry {
-// maxRetries.set(1)
-//// maxFailures.set(20)
-//// failOnPassedAfterRetry.set(false)
-//// failOnSkippedAfterRetry.set(true)
-// }
+}
+
+test {
+ filter {
+ excludeTestsMatching("nostr.api.integration.*");
+ }
}
test {
diff --git a/gradle.properties b/gradle.properties
index 40e91dec1..2bd5042ba 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,7 +6,7 @@ org.gradle.parallel=true
org.gradle.warning.mode=none
nostr-java.group=xyz.tcheeric
-nostr-java.version=0.6.5-SNAPSHOT
+nostr-java.version=0.6.6-SNAPSHOT
nostr-java.description=nostr-java
nostr-java.java-version=21
diff --git a/metrics.md b/metrics.md
deleted file mode 100644
index 49ccce034..000000000
--- a/metrics.md
+++ /dev/null
@@ -1,232 +0,0 @@
-### nostr-java & superconductor: gradle -vs- maven metrics
-
-
-[useful gradle commands (w/ maven equivalents) @ bottom of page](https://github.com/avlo/nostr-java-avlo-fork/blob/79d3f521e177ebd5e741490e1cdc0f1001e07c49/metrics.md#useful-gradle-commands-w-maven-equivalents)
-
-
-----
-##### nostr-java clean build
-
-###### maven: ~19 seconds
-
-```java
-$ time mvn clean install -Dmaven.test.skip=true
-
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 17.592 s
- [INFO] Finished at: 2025-03-14T22:31:52-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 0m19.156s <----------------------------------------------------------- ~19 sec
- user 0m58.042s
- sys 0m1.616s
-```
-
-###### gradle: ~9 seconds
-``` java
-$ time gradle clean build -x test
-
-BUILD SUCCESSFUL in 9s
-38 actionable tasks: 38 executed
-Configuration cache entry reused.
-
- real 0m9.618s <------------------------------------------------------------- ~9 sec
- user 0m2.383s
- sys 0m0.116s
-```
-----
-
-#### nostr-java, subsequent build
-
-###### maven: ~21 seconds
-
-```java
-$ time mvn install -Dmaven.test.skip=true
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 19.680 s
- [INFO] Finished at: 2025-03-14T22:39:35-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 0m21.324s <------------------------------------------------------------- ~21sec
- user 1m3.300s
- sys 0m1.771s
-```
-
-###### gradle: ~1 second
-
-```java
-$ time gradle build -x test
- Reusing configuration cache.
-
- BUILD SUCCESSFUL in 1s
- 27 actionable tasks: 27 up-to-date
- Configuration cache entry reused.
-
- real 0m1.178s <------------------------------------------------------------- ~1sec
- user 0m2.082s
- sys 0m0.176s
-```
-
-----
-#### superconductor clean build:
-
-###### maven: ~11 seconds
-
-```java
-$ time mvn clean install -Dmaven.test.skip=true
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 10.437 s
- [INFO] Finished at: 2025-03-14T22:46:58-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 0m11.989s <------------------------------------------------------------- ~11sec
- user 0m36.291s
- sys 0m1.351s
-```
-
-###### gradle: ~7 seconds
-
-```java
-$ time gradle clean build -x test
-
- BUILD SUCCESSFUL in 7s
- 7 actionable tasks: 4 executed, 2 from cache, 1 up-to-date
-
- real 0m7.655s <------------------------------------------------------------ ~7sec
- user 0m2.800s
- sys 0m0.164s
-```
-
-----
-#### superconductor clean build integration- test:
-
-###### maven: ~1 minute, 15 seconds
-``` java
-$ mvn clean install
-
- [INFO] Results:
- [INFO]
- [INFO] Tests run: 52, Failures: 0, Errors: 0, Skipped: 0
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 01:15 min <--------------------------------------------------- ~1min 15sec*
- [INFO] Finished at: 2025-03-14T23:26:59-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 1m16.800s <----------------------------------------------------------------- ~1min 16sec*
- user 2m58.945s
- sys 0m4.427s
-```
-_*one-second time diff re: maven publish to local repo (`~/.m2/xyz/tcheeric/...`)_
-
-###### gradle: ~49 seconds
-``` java
-$ time gradle build
-
- SUCCESS: Executed 61 tests in 41.1s
-
- BUILD SUCCESSFUL in 49s
- 10 actionable tasks: 6 executed, 4 from cache
-
- real 0m49.269s <------------------------------------------------------------- ~49sec
- user 0m2.854s
- sys 0m0.201s
-```
-
-----
-
-#### superconductor subsequent build test
-_historical note: significant down/wait-time using maven occurs here, thus motivating gradle build/test option for superconductor, initially, with nostr-java subsequently profiting from same feature/option. **from** **~1 minute** **down to** **~4 seconds** significantly improves workflow continuity. furthermore, multiple iterative test builds occurring as per typical development results in significant cumulative time saved._
-
-###### maven: ~1 minute, 3 seconds
-
-```java
-$ time mvn install
-
- [INFO] Results:
- [INFO]
- [INFO] Tests run: 52, Failures: 0, Errors: 0, Skipped: 0
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 01:03 min <--------------------------------------------------------- ~1min 3sec**
- [INFO] Finished at: 2025-03-14T23:35:18-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 1m6.132s <------------------------------------------------------------------------ ~1min 6sec**
- user 2m32.305s
- sys 0m3.797s
-```
-_** three-second time diff re: maven publish to local repo (`~/.m2/xyz/tcheeric/...`)_
-
-###### gradle: ~4 seconds
-```java
-$ time gradle build
-
-BUILD SUCCESSFUL in 3s
-10 actionable tasks: 10 up-to-date
-
-real 0m4.020s <------------------------------------------------------------------------ ~4sec
-user 0m2.913s
-```
-
-----
-
-#### nostr-java integration tests against running SC
-
-###### maven: ~29 seconds
-
-```java
-$ time mvn test
-
- [INFO] Results:
- [INFO]
- [INFO] Tests run: 159, Failures: 0, Errors: 0, Skipped: 0
- [INFO]
- [INFO] ------------------------------------------------------------------------
- [INFO] Reactor Summary for nostr-java 0.6.5-SNAPSHOT:
- [INFO]
- [INFO] nostr-java ......................................... SUCCESS [ 0.012 s]
- [INFO] nostr-java-util .................................... SUCCESS [ 0.900 s]
- [INFO] nostr-java-crypto .................................. SUCCESS [ 0.353 s]
- [INFO] nostr-java-base .................................... SUCCESS [ 0.246 s]
- [INFO] nostr-java-event ................................... SUCCESS [ 0.142 s]
- [INFO] nostr-java-id ...................................... SUCCESS [ 0.164 s]
- [INFO] nostr-java-client .................................. SUCCESS [ 0.438 s]
- [INFO] nostr-java-encryption .............................. SUCCESS [ 0.050 s]
- [INFO] nostr-java-encryption-nip04 ........................ SUCCESS [ 0.107 s]
- [INFO] nostr-java-encryption-nip44 ........................ SUCCESS [ 0.114 s]
- [INFO] nostr-java-api ..................................... SUCCESS [ 0.190 s]
- [INFO] nostr-java-examples ................................ SUCCESS [ 0.212 s]
- [INFO] nostr-java-test .................................... SUCCESS [ 25.933 s]
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 29.084 s <------------------------------------------------------------------------ ~29sec***
- [INFO] Finished at: 2025-03-15T12:41:13-07:00
- [INFO] ------------------------------------------------------------------------
-
- real 0m30.669s <-------------------------------------------------------------------------------------- ~30sec***
- user 1m2.185s
- sys 0m1.698s
-```
-_*** one-second time diff re: maven publish to local repo (`~/.m2/xyz/tcheeric/...`)_
-
-----
-
-##### useful gradle commands (w/ maven equivalents)
-
-```java
-alias gc='gradle clean' // 'maven clean'
-alias gb='gradle build' // 'maven build'
-alias gcb='gradle clean build' // 'maven clean build'
-
-alias gbnotest='gradle build -x test' // 'maven build -Dmaven.test.skip=true'
-alias gcbnotest='gradle clean build -x test' // 'maven clean build -Dmaven.test.skip=true'
-
-alias gpub='gradle publishToMavenLocal' // 'maven install'
-```
diff --git a/nostr-java-api/build.gradle b/nostr-java-api/build.gradle
index 6d8ec99ad..639865ef7 100644
--- a/nostr-java-api/build.gradle
+++ b/nostr-java-api/build.gradle
@@ -9,7 +9,7 @@ dependencies {
api project(':nostr-java-encryption')
}
-tasks.register('integrationTest', Test) {
+tasks.register('apiIntegrationTest', Test) {
description = 'api integration tests.'
group = 'verification'
systemProperty("spring.profiles.active", "test")
@@ -20,11 +20,11 @@ tasks.register('integrationTest', Test) {
}
}
-integrationTest {
+apiIntegrationTest {
retry {
failOnPassedAfterRetry = false
maxRetries = 1
}
}
-check.dependsOn integrationTest
+check.dependsOn apiIntegrationTest
diff --git a/nostr-java-api/pom.xml b/nostr-java-api/pom.xml
index b60f18204..c96a05475 100644
--- a/nostr-java-api/pom.xml
+++ b/nostr-java-api/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP09.java b/nostr-java-api/src/main/java/nostr/api/NIP09.java
index 3836077cb..b839f6bf9 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP09.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP09.java
@@ -8,7 +8,7 @@
import nostr.event.Deleteable;
import nostr.event.NIP09Event;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.AddressTag;
import nostr.event.tag.EventTag;
import nostr.event.tag.IdentifierTag;
@@ -75,7 +75,7 @@ public NIP09 createDeletionEvent(@NonNull List deleteables) {
private AddressTag toAddressTag(@NonNull GenericTag genericTag) {
IdentifierTag identifierTag = new IdentifierTag();
- identifierTag.setId(genericTag.getAttributes().get(1).getValue().toString());
+ identifierTag.setUuid(genericTag.getAttributes().get(1).getValue().toString());
AddressTag addressTag = new AddressTag();
addressTag.setIdentifierTag(identifierTag);
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP23.java b/nostr-java-api/src/main/java/nostr/api/NIP23.java
index b945b7be7..f791e673b 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP23.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP23.java
@@ -11,7 +11,7 @@
import nostr.api.factory.impl.NIP23Impl.SummaryTagFactory;
import nostr.api.factory.impl.NIP23Impl.TitleTagFactory;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.AddressTag;
import nostr.event.tag.EventTag;
import nostr.id.Identity;
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP25.java b/nostr-java-api/src/main/java/nostr/api/NIP25.java
index c687d5c01..9d6e32789 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP25.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP25.java
@@ -11,8 +11,7 @@
import nostr.event.NIP25Event;
import nostr.event.Reaction;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.EmojiTag;
import nostr.id.Identity;
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP31.java b/nostr-java-api/src/main/java/nostr/api/NIP31.java
index 1f7108bc5..d969b0714 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP31.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP31.java
@@ -2,7 +2,7 @@
import lombok.NonNull;
import nostr.api.factory.TagFactory;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
public class NIP31 {
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP32.java b/nostr-java-api/src/main/java/nostr/api/NIP32.java
index 777f51284..aad2c03de 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP32.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP32.java
@@ -9,7 +9,7 @@
import nostr.api.factory.impl.NIP32Impl.LabelTagFactory;
import nostr.api.factory.impl.NIP32Impl.NameSpace;
import nostr.api.factory.impl.NIP32Impl.NamespaceTagFactory;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import java.util.Map;
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP42.java b/nostr-java-api/src/main/java/nostr/api/NIP42.java
index 65decc882..8aa62c23d 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP42.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP42.java
@@ -14,7 +14,7 @@
import nostr.event.impl.CanonicalAuthenticationEvent;
import nostr.event.impl.GenericEvent;
import nostr.event.impl.GenericMessage;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.message.CanonicalAuthenticationMessage;
/**
@@ -83,4 +83,4 @@ public static CanonicalAuthenticationMessage createClientAuthenticationMessage(@
public static GenericMessage createRelayAuthenticationMessage(@NonNull String challenge) {
return new RelayAuthenticationMessageFactory(challenge).create();
}
-}
\ No newline at end of file
+}
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP57.java b/nostr-java-api/src/main/java/nostr/api/NIP57.java
index c3c0cb1e4..a7ae15cff 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP57.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP57.java
@@ -9,7 +9,7 @@
import nostr.base.Relay;
import nostr.event.BaseTag;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.impl.ZapRequest;
import nostr.event.tag.AddressTag;
import nostr.event.tag.EventTag;
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP60.java b/nostr-java-api/src/main/java/nostr/api/NIP60.java
index bc5b0d367..123bee06d 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP60.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP60.java
@@ -24,7 +24,7 @@
import nostr.base.Wallet;
import nostr.event.BaseTag;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.json.codec.BaseTagEncoder;
import nostr.event.tag.EventTag;
import nostr.id.Identity;
diff --git a/nostr-java-api/src/main/java/nostr/api/NIP61.java b/nostr-java-api/src/main/java/nostr/api/NIP61.java
index 08487f58c..9d27cf3b3 100644
--- a/nostr-java-api/src/main/java/nostr/api/NIP61.java
+++ b/nostr-java-api/src/main/java/nostr/api/NIP61.java
@@ -13,7 +13,7 @@
import nostr.base.Relay;
import nostr.event.BaseTag;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.EventTag;
import nostr.id.Identity;
diff --git a/nostr-java-api/src/main/java/nostr/api/factory/TagFactory.java b/nostr-java-api/src/main/java/nostr/api/factory/TagFactory.java
index 1b6f2a581..7c5197f40 100644
--- a/nostr-java-api/src/main/java/nostr/api/factory/TagFactory.java
+++ b/nostr-java-api/src/main/java/nostr/api/factory/TagFactory.java
@@ -7,7 +7,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
/**
*
diff --git a/nostr-java-api/src/main/java/nostr/config/RelayProperties.java b/nostr-java-api/src/main/java/nostr/config/RelayConfig.java
similarity index 95%
rename from nostr-java-api/src/main/java/nostr/config/RelayProperties.java
rename to nostr-java-api/src/main/java/nostr/config/RelayConfig.java
index ae8d4f066..41c2d5972 100644
--- a/nostr-java-api/src/main/java/nostr/config/RelayProperties.java
+++ b/nostr-java-api/src/main/java/nostr/config/RelayConfig.java
@@ -10,7 +10,7 @@
@Configuration
@PropertySource("classpath:relays.properties")
-public class RelayProperties {
+public class RelayConfig {
@Bean
public Map relays() {
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ApiEventIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ApiEventIT.java
index 7cc37d63b..867ddd30f 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ApiEventIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ApiEventIT.java
@@ -12,7 +12,7 @@
import nostr.base.ElementAttribute;
import nostr.base.GenericTagQuery;
import nostr.base.PrivateKey;
-import nostr.config.RelayProperties;
+import nostr.config.RelayConfig;
import nostr.crypto.bech32.Bech32;
import nostr.crypto.bech32.Bech32Prefix;
import nostr.event.BaseTag;
@@ -21,12 +21,13 @@
import nostr.event.filter.GenericTagQueryFilter;
import nostr.event.filter.GeohashTagFilter;
import nostr.event.filter.HashtagTagFilter;
+import nostr.event.filter.VoteTagFilter;
import nostr.event.impl.CalendarContent;
import nostr.event.impl.CreateOrUpdateStallEvent;
import nostr.event.impl.CreateOrUpdateStallEvent.Stall;
import nostr.event.impl.DirectMessageEvent;
import nostr.event.impl.EncryptedPayloadEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.impl.NostrMarketplaceEvent;
import nostr.event.impl.NostrMarketplaceEvent.Product.Spec;
import nostr.event.impl.TextNoteEvent;
@@ -37,13 +38,12 @@
import nostr.event.tag.HashtagTag;
import nostr.event.tag.IdentifierTag;
import nostr.event.tag.PubKeyTag;
+import nostr.event.tag.VoteTag;
import nostr.id.Identity;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
@@ -55,8 +55,7 @@
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.*;
-@SpringJUnitConfig(RelayProperties.class)
-@ActiveProfiles("test")
+@SpringJUnitConfig(RelayConfig.class)
public class ApiEventIT {
@Autowired
private Map relays;
@@ -84,7 +83,7 @@ public void testNIP01CreateTextNoteEvent() throws Exception {
}
@Test
- public void testNIP01SendTextNoteEvent() throws IOException {
+ public void testNIP01SendTextNoteEvent() {
System.out.println("testNIP01SendTextNoteEvent");
var nip01 = new NIP01(Identity.generateRandomIdentity());
@@ -98,7 +97,7 @@ public void testNIP01SendTextNoteEvent() throws IOException {
}
@Test
- public void testNIP04SendDirectMessage() throws IOException {
+ public void testNIP04SendDirectMessage() {
System.out.println("testNIP04SendDirectMessage");
var nip04 = new NIP04(
@@ -118,7 +117,7 @@ public void testNIP04SendDirectMessage() throws IOException {
}
@Test
- public void testNIP44SendDirectMessage() throws IOException {
+ public void testNIP44SendDirectMessage() {
System.out.println("testNIP44SendDirectMessage");
var nip44 = new NIP44(
@@ -135,7 +134,7 @@ public void testNIP44SendDirectMessage() throws IOException {
}
@Test
- public void testNIP01SendTextNoteEventGeoHashTag() throws IOException {
+ public void testNIP01SendTextNoteEventGeoHashTag() {
System.out.println("testNIP01SendTextNoteEventGeoHashTag");
String targetString = "geohash_tag-location-testNIP01SendTextNoteEventGeoHashTag";
@@ -157,7 +156,7 @@ public void testNIP01SendTextNoteEventGeoHashTag() throws IOException {
}
@Test
- public void testNIP01SendTextNoteEventHashtagTag() throws IOException {
+ public void testNIP01SendTextNoteEventHashtagTag() {
System.out.println("testNIP01SendTextNoteEventHashtagTag");
String targetString = "hashtag-tag-value-testNIP01SendTextNoteEventHashtagTag";
@@ -179,7 +178,7 @@ public void testNIP01SendTextNoteEventHashtagTag() throws IOException {
}
@Test
- public void testNIP01SendTextNoteEventCustomGenericTag() throws IOException {
+ public void testNIP01SendTextNoteEventCustomGenericTag() {
System.out.println("testNIP01SendTextNoteEventCustomGenericTag");
String targetString = "custom-generic-tag-testNIP01SendTextNoteEventCustomGenericTag";
@@ -205,7 +204,7 @@ public void testNIP01SendTextNoteEventCustomGenericTag() throws IOException {
}
@Test
- public void testFiltersListReturnSameSingularEvent() throws IOException {
+ public void testFiltersListReturnSameSingularEvent() {
System.out.println("testFiltersListReturnSameSingularEvent");
String geoHashTagTarget = "geohash_tag-location_SameSingularEvent";
@@ -233,7 +232,7 @@ public void testFiltersListReturnSameSingularEvent() throws IOException {
}
@Test
- public void testFiltersListReturnTwoDifferentEvents() throws IOException {
+ public void testFiltersListReturnTwoDifferentEvents() {
System.out.println("testFiltersListReturnTwoDifferentEvents");
// first event
@@ -270,7 +269,7 @@ public void testFiltersListReturnTwoDifferentEvents() throws IOException {
}
@Test
- public void testMultipleFiltersDifferentTypesReturnSameEvent() throws IOException {
+ public void testMultipleFiltersDifferentTypesReturnSameEvent() {
System.out.println("testMultipleFilters");
String geoHashTagTarget = "geohash_tag-location-DifferentTypesReturnSameEvent";
@@ -295,6 +294,35 @@ public void testMultipleFiltersDifferentTypesReturnSameEvent() throws IOExceptio
// nip01.close();
}
+ @Test
+ public void testCreateUnsupportedGenericTagAttribute() {
+ System.out.println("testCreateUnsupportedGenericTagAttribute");
+
+ String aCustomTagKey = "a-custom-tag";
+ String aCustomTagValue = "a custom tag value";
+ GenericTag genericTag1 = GenericTag.create(aCustomTagKey, aCustomTagValue);
+
+ String anotherCustomTagKey = "another-custom-tag";
+ String anotherCustomTagValue = "another custom tag value";
+ GenericTag genericTag2 = GenericTag.create(anotherCustomTagKey, anotherCustomTagValue);
+
+ NIP01 nip01 = new NIP01<>(Identity.generateRandomIdentity());
+
+ nip01.createTextNoteEvent(List.of(genericTag1, genericTag2), "Multiple Generic Tags").signAndSend(relays);
+
+ Filters filters1 = new Filters(
+ new GenericTagQueryFilter<>(new GenericTagQuery(aCustomTagKey, aCustomTagValue)));
+ Filters filters2 = new Filters(
+ new GenericTagQueryFilter<>(new GenericTagQuery(anotherCustomTagKey, anotherCustomTagValue)));
+
+ List result = nip01.sendRequest(List.of(filters1, filters2), UUID.randomUUID().toString());
+
+ assertFalse(result.isEmpty());
+ assertEquals(2, result.size());
+ assertTrue(result.stream().anyMatch(s -> s.contains(aCustomTagValue)));
+ assertTrue(result.stream().anyMatch(s -> s.contains(anotherCustomTagValue)));
+ }
+
@Test
public void testNIP04EncryptDecrypt() {
System.out.println("testNIP04EncryptDecrypt");
@@ -344,7 +372,7 @@ public void testNIP15CreateStallEvent() throws JsonProcessingException {
}
@Test
- public void testNIP15UpdateStallEvent() throws IOException {
+ public void testNIP15UpdateStallEvent() {
System.out.println("testNIP15UpdateStallEvent");
var stall = createStall();
@@ -372,7 +400,7 @@ public void testNIP15UpdateStallEvent() throws IOException {
}
@Test
- public void testNIP15CreateProductEvent() throws IOException {
+ public void testNIP15CreateProductEvent() {
System.out.println("testNIP15CreateProductEvent");
@@ -396,7 +424,7 @@ public void testNIP15CreateProductEvent() throws IOException {
}
@Test
- public void testNIP15UpdateProductEvent() throws IOException {
+ public void testNIP15UpdateProductEvent() {
System.out.println("testNIP15UpdateProductEvent");
@@ -470,7 +498,7 @@ public void testNIP32CreateLabel2() {
}
@Test
- public void testNIP52CalendarTimeBasedEventEvent() throws IOException {
+ public void testNIP52CalendarTimeBasedEventEvent() {
System.out.println("testNIP52CalendarTimeBasedEventEvent");
CalendarContent calendarContent = CalendarContent.builder(
@@ -617,4 +645,26 @@ public static NostrMarketplaceEvent.Product createProduct(Stall stall) {
return product;
}
+
+ @Test
+ public void testNIP01SendTextNoteEventVoteTag() {
+ System.out.println("testNIP01SendTextNoteEventVoteTag");
+
+ Integer targetVote = 1;
+ VoteTag voteTag = new VoteTag(targetVote);
+
+ NIP01 nip01 = new NIP01<>(Identity.generateRandomIdentity());
+ nip01.createTextNoteEvent(List.of(voteTag), "Vote Tag Test value testNIP01SendTextNoteEventVoteTag").signAndSend(relays);
+
+ Filters filters = new Filters(
+ new VoteTagFilter<>(new VoteTag(targetVote)));
+
+ List result = nip01.sendRequest(filters, UUID.randomUUID().toString());
+
+ assertFalse(result.isEmpty());
+ assertEquals(2, result.size());
+ assertTrue(result.stream().anyMatch(s -> s.contains(targetVote.toString())));
+
+// nip01.close();
+ }
}
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ApiEventTestUsingSpringWebSocketClientIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ApiEventTestUsingSpringWebSocketClientIT.java
index b6b38c8da..93d6d7bbb 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ApiEventTestUsingSpringWebSocketClientIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ApiEventTestUsingSpringWebSocketClientIT.java
@@ -4,7 +4,7 @@
import nostr.api.NIP15;
import nostr.base.PrivateKey;
import nostr.client.springwebsocket.SpringWebSocketClient;
-import nostr.config.RelayProperties;
+import nostr.config.RelayConfig;
import nostr.event.impl.GenericEvent;
import nostr.event.message.EventMessage;
import nostr.id.Identity;
@@ -22,7 +22,7 @@
import static nostr.base.IEvent.MAPPER_AFTERBURNER;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@SpringJUnitConfig(RelayProperties.class)
+@SpringJUnitConfig(RelayConfig.class)
@ActiveProfiles("test")
class ApiEventTestUsingSpringWebSocketClientIT {
private final List springWebSocketClients;
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP52RequestIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP52RequestIT.java
index c12167a27..430159dd0 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP52RequestIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP52RequestIT.java
@@ -1,15 +1,22 @@
package nostr.api.integration;
+import java.io.IOException;
+import java.net.URI;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
import nostr.api.NIP52;
+import nostr.api.util.CommonTestObjectsFactory;
import nostr.api.util.JsonComparator;
import nostr.base.PublicKey;
import nostr.client.springwebsocket.SpringWebSocketClient;
import nostr.event.BaseTag;
import nostr.event.impl.CalendarContent;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
import nostr.event.message.EventMessage;
import nostr.event.tag.EventTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.GeohashTag;
import nostr.event.tag.HashtagTag;
import nostr.event.tag.IdentifierTag;
@@ -18,170 +25,165 @@
import nostr.id.Identity;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.ActiveProfiles;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
import static nostr.base.IEvent.MAPPER_AFTERBURNER;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ActiveProfiles("test")
class ApiNIP52RequestIT {
- private static final String PRV_KEY_VALUE = "23c011c4c02de9aa98d48c3646c70bb0e7ae30bdae1dfed4d251cbceadaeeb7b";
- private static final String RELAY_URI = "ws://localhost:5555";
- private static final String UUID_CALENDAR_TIME_BASED_EVENT_TEST = "UUID-CalendarTimeBasedEventTest";
-
- public static final String ID = "299ab85049a7923e9cd82329c0fa489ca6fd6d21feeeac33543b1237e14a9e07";
- public static final String KIND = "31923";
- public static final String CALENDAR_CONTENT = "calendar content";
- public static final String PUB_KEY = "cccd79f81439ff794cf5ac5f7bff9121e257f399829e472c7a14d3e86fe76984";
- public static final String CREATED_AT = "1726114798510";
- public static final String START = "1726114798610";
- public static final String END = "1726114798710";
-
- public static final String START_TZID = "America/Costa_Rica";
- public static final String END_TZID = "America/Costa_Rica";
-
- public static final String E_TAG_HEX = "494001ac0c8af2a10f60f23538e5b35d3cdacb8e1cc956fe7a16dfa5cbfc4346";
- public static final String G_TAG_VALUE = "calendar geo-tag-1";
- public static final String T_TAG_VALUE = "calendar hash-tag-1111";
- public static final String P1_TAG_HEX = "444d79f81439ff794cf5ac5f7bff9121e257f399829e472c7a14d3e86fe76984";
- public static final String P1_ROLE = "PAYER";
- public static final String P2_ROLE = "PAYEE";
-
- public static final String P2_TAG_HEX = "555d79f81439ff794cf5ac5f7bff9121e257f399829e472c7a14d3e86fe76984";
- public static final String TITLE = "calendar title";
- public static final String SUMMARY = "calendar summary";
- public static final String LOCATION = "calendar location";
-
- public static final EventTag E_TAG = new EventTag(E_TAG_HEX);
- public static final PubKeyTag P1_TAG = new PubKeyTag(new PublicKey(P1_TAG_HEX), RELAY_URI, P1_ROLE);
- public static final PubKeyTag P2_TAG = new PubKeyTag(new PublicKey(P2_TAG_HEX), RELAY_URI, P2_ROLE);
- public static final GeohashTag G_TAG = new GeohashTag(G_TAG_VALUE);
- public static final HashtagTag T_TAG = new HashtagTag(T_TAG_VALUE);
- public static final ReferenceTag R_TAG = new ReferenceTag(URI.create(RELAY_URI));
-
- public static final String LABEL_1 = "calendar label 1 of 2";
- public static final String LABEL_2 = "calendar label 2 of 2";
-
- public static final String START_TZID_CODE = "start_tzid";
- public static final String END_TZID_CODE = "end_tzid";
- public static final String SUMMARY_CODE = "summary";
- public static final String LABEL_CODE = "l";
- public static final String LOCATION_CODE = "location";
- public static final String END_CODE = "end";
-
- public String eventId;
- public String eventPubKey;
- public String signature;
-
- @Test
- void testNIP99CalendarContentPreRequest() throws IOException {
- System.out.println("testNIP52CalendarContentEvent");
-
- List tags = new ArrayList<>();
- tags.add(E_TAG);
- tags.add(P1_TAG);
- tags.add(P2_TAG);
- tags.add(GenericTag.create(START_TZID_CODE, START_TZID));
- tags.add(GenericTag.create(END_TZID_CODE, END_TZID));
- tags.add(GenericTag.create(SUMMARY_CODE, SUMMARY));
- tags.add(GenericTag.create(LABEL_CODE, LABEL_1));
- tags.add(GenericTag.create(LABEL_CODE, LABEL_2));
- tags.add(GenericTag.create(LOCATION_CODE, LOCATION));
- tags.add(GenericTag.create(END_CODE, END));
- tags.add(G_TAG);
- tags.add(T_TAG);
- tags.add(R_TAG);
-
- CalendarContent calendarContent = CalendarContent.builder(
- new IdentifierTag(UUID_CALENDAR_TIME_BASED_EVENT_TEST),
- TITLE,
- Long.valueOf(START))
- .build();
-
- var nip52 = new NIP52<>(Identity.create(PRV_KEY_VALUE));
-
- GenericEvent event = nip52.createCalendarTimeBasedEvent(tags, CALENDAR_CONTENT, calendarContent).sign().getEvent();
- event.setCreatedAt(Long.valueOf(CREATED_AT));
- eventId = event.getId();
- signature = event.getSignature().toString();
- eventPubKey = event.getPubKey().toString();
- EventMessage eventMessage = new EventMessage(event);
-
- SpringWebSocketClient springWebSocketEventClient = new SpringWebSocketClient(RELAY_URI);
- String eventResponse = springWebSocketEventClient.send(eventMessage).stream().findFirst().orElseThrow();
-
- // Extract and compare only first 3 elements of the JSON array
- var expectedArray = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(0).asText();
- var expectedSubscriptionId = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(1).asText();
- var expectedSuccess = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(2).asBoolean();
-
- var actualArray = MAPPER_AFTERBURNER.readTree(eventResponse).get(0).asText();
- var actualSubscriptionId = MAPPER_AFTERBURNER.readTree(eventResponse).get(1).asText();
- var actualSuccess = MAPPER_AFTERBURNER.readTree(eventResponse).get(2).asBoolean();
-
- assertTrue(expectedArray.equals(actualArray), "First element should match");
- assertTrue(expectedSubscriptionId.equals(actualSubscriptionId), "Subscription ID should match");
- //assertTrue(expectedSuccess == actualSuccess, "Success flag should match"); -- This test is not required. The relay will always return false because we resending the same event, causing duplicates.
+ private static final String RELAY_URI = "ws://localhost:5555";
+ private static final String UUID_CALENDAR_TIME_BASED_EVENT_TEST = CommonTestObjectsFactory.generateRandomHex64String();
+
+ public static final String KIND = "31923";
+ public static final String CALENDAR_CONTENT = CommonTestObjectsFactory.lorumIpsum(ApiNIP52RequestIT.class);
+
+ public static final String CREATED_AT = String.valueOf(Instant.now().getEpochSecond());
+ public static final String START = String.valueOf(Instant.now().plus(Duration.ofSeconds(10)).getEpochSecond());
+ public static final String END = String.valueOf(Instant.now().plus(Duration.ofSeconds(100)).getEpochSecond());
+
+ public static final String START_TZID = "America/Costa_Rica";
+ public static final String END_TZID = "America/Costa_Rica";
+
+ public static final String E_TAG_HEX = CommonTestObjectsFactory.generateRandomHex64String();
+ public static final String G_TAG_VALUE = CommonTestObjectsFactory.generateRandomHex64String();
+ public static final String T_TAG_VALUE = CommonTestObjectsFactory.generateRandomHex64String();
+ public static final PublicKey P1_TAG_HEX = CommonTestObjectsFactory.createNewIdentity().getPublicKey();
+ public static final String P1_ROLE = "PAYER";
+ public static final String P2_ROLE = "PAYEE";
+
+ public static final PublicKey P2_TAG_HEX = CommonTestObjectsFactory.createNewIdentity().getPublicKey();
+ public static final String TITLE = CommonTestObjectsFactory.lorumIpsum();
+ public static final String SUMMARY = CommonTestObjectsFactory.lorumIpsum();
+ public static final String LOCATION = CommonTestObjectsFactory.lorumIpsum();
+
+ public static final EventTag E_TAG = new EventTag(E_TAG_HEX);
+ public static final PubKeyTag P1_TAG = new PubKeyTag(P1_TAG_HEX, RELAY_URI, P1_ROLE);
+ public static final PubKeyTag P2_TAG = new PubKeyTag(P2_TAG_HEX, RELAY_URI, P2_ROLE);
+ public static final GeohashTag G_TAG = new GeohashTag(G_TAG_VALUE);
+ public static final HashtagTag T_TAG = new HashtagTag(T_TAG_VALUE);
+ public static final ReferenceTag R_TAG = new ReferenceTag(URI.create(RELAY_URI));
+
+ public static final String LABEL_1 = CommonTestObjectsFactory.lorumIpsum();
+ public static final String LABEL_2 = CommonTestObjectsFactory.lorumIpsum();
+
+ public static final String START_TZID_CODE = "start_tzid";
+ public static final String END_TZID_CODE = "end_tzid";
+ public static final String SUMMARY_CODE = "summary";
+ public static final String LABEL_CODE = "l";
+ public static final String LOCATION_CODE = "location";
+ public static final String END_CODE = "end";
+
+ public String eventId;
+ public String eventPubKey;
+ public String signature;
+
+ @Test
+ void testNIP99CalendarContentPreRequest() throws IOException {
+ System.out.println("testNIP52CalendarContentEvent");
+
+ List tags = new ArrayList<>();
+ tags.add(E_TAG);
+ tags.add(P1_TAG);
+ tags.add(P2_TAG);
+ tags.add(GenericTag.create(START_TZID_CODE, START_TZID));
+ tags.add(GenericTag.create(END_TZID_CODE, END_TZID));
+ tags.add(GenericTag.create(SUMMARY_CODE, SUMMARY));
+ tags.add(GenericTag.create(LABEL_CODE, LABEL_1));
+ tags.add(GenericTag.create(LABEL_CODE, LABEL_2));
+ tags.add(GenericTag.create(LOCATION_CODE, LOCATION));
+ tags.add(GenericTag.create(END_CODE, END));
+ tags.add(G_TAG);
+ tags.add(T_TAG);
+ tags.add(R_TAG);
+
+ CalendarContent calendarContent = CalendarContent.builder(
+ new IdentifierTag(UUID_CALENDAR_TIME_BASED_EVENT_TEST),
+ TITLE,
+ Long.valueOf(START))
+ .build();
+
+ var nip52 = new NIP52<>(Identity.generateRandomIdentity());
+
+ GenericEvent event = nip52.createCalendarTimeBasedEvent(tags, CALENDAR_CONTENT, calendarContent).sign().getEvent();
+ event.setCreatedAt(Long.valueOf(CREATED_AT));
+ eventId = event.getId();
+ signature = event.getSignature().toString();
+ eventPubKey = event.getPubKey().toString();
+ EventMessage eventMessage = new EventMessage(event);
+
+ SpringWebSocketClient springWebSocketEventClient = new SpringWebSocketClient(RELAY_URI);
+ String eventResponse = springWebSocketEventClient.send(eventMessage).stream().findFirst().orElseThrow();
+
+ // Extract and compare only first 3 elements of the JSON array
+ var expectedArray = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(0).asText();
+ var expectedSubscriptionId = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(1).asText();
+ var expectedSuccess = MAPPER_AFTERBURNER.readTree(expectedEventResponseJson(event.getId())).get(2).asBoolean();
+
+ var actualArray = MAPPER_AFTERBURNER.readTree(eventResponse).get(0).asText();
+ var actualSubscriptionId = MAPPER_AFTERBURNER.readTree(eventResponse).get(1).asText();
+ var actualSuccess = MAPPER_AFTERBURNER.readTree(eventResponse).get(2).asBoolean();
+
+ assertEquals(expectedArray, actualArray, "First element should match");
+ assertEquals(expectedSubscriptionId, actualSubscriptionId, "Subscription ID should match");
+ //assertTrue(expectedSuccess == actualSuccess, "Success flag should match"); -- This test is not required. The relay will always return false because we resending the same event, causing duplicates.
// springWebSocketEventClient.closeSocket();
- // TODO - This assertion fails with superdonductor and nostr-rs-relay
-///*
- SpringWebSocketClient springWebSocketRequestClient = new SpringWebSocketClient(RELAY_URI);
- String subscriberId = UUID.randomUUID().toString();
- String reqJson = createReqJson(subscriberId, eventId);
- String reqResponse = springWebSocketRequestClient.send(reqJson).stream().findFirst().orElseThrow();
+ /* TODO - This assertion fails with superdonductor and nostr-rs-relay
+ above, supplemental: SpringWebSocketClient api updated to properly handle this use/use-case
+ integration testing successful against superconductor.
+ integration testing against nostr-rs-relay still pending
+ */
+
+ SpringWebSocketClient springWebSocketRequestClient = new SpringWebSocketClient(RELAY_URI);
+ String subscriberId = CommonTestObjectsFactory.generateRandomHex64String();
+ String reqJson = createReqJson(subscriberId, eventId);
+ String reqResponse = springWebSocketRequestClient.send(reqJson).stream().findFirst().orElseThrow();
- String expected = expectedRequestResponseJson(subscriberId);
- assertTrue(
- JsonComparator.isEquivalentJson(
- MAPPER_AFTERBURNER.readTree(expected),
- MAPPER_AFTERBURNER.readTree(reqResponse)));
+ String expected = expectedRequestResponseJson(subscriberId);
+ assertTrue(
+ JsonComparator.isEquivalentJson(
+ MAPPER_AFTERBURNER.readTree(expected),
+ MAPPER_AFTERBURNER.readTree(reqResponse)));
// springWebSocketRequestClient.closeSocket();
-//*/
- }
-
- private String expectedEventResponseJson(String subscriptionId) {
- return "[\"OK\",\"" + subscriptionId + "\",true,\"success: request processed\"]";
- }
-
- private String createReqJson(String subscriberId, String id) {
- return "[\"REQ\",\"" + subscriberId + "\",{\"ids\":[\"" + id + "\"]}]";
- }
-
- private String expectedRequestResponseJson(String subscriberId) {
- return " [\"EVENT\",\"" + subscriberId + "\",\n" +
- " {\"id\": \"" + eventId + "\",\n" +
- " \"kind\": " + KIND + ",\n" +
- " \"content\": \"" + CALENDAR_CONTENT + "\",\n" +
- " \"pubkey\": \"" + eventPubKey + "\",\n" +
- " \"created_at\": " + CREATED_AT + ",\n" +
- " \"tags\": [\n" +
- " [ \"e\", \"" + E_TAG.getIdEvent() + "\" ],\n" +
- " [ \"g\", \"" + G_TAG.getLocation() + "\" ],\n" +
- " [ \"t\", \"" + T_TAG.getHashTag() + "\" ],\n" +
- " [ \"d\", \"" + UUID_CALENDAR_TIME_BASED_EVENT_TEST + "\" ],\n" +
- " [ \"p\", \"" + P1_TAG.getPublicKey() + "\", \"" + RELAY_URI + "\", \"" + P1_ROLE + "\" ],\n" +
- " [ \"p\", \"" + P2_TAG.getPublicKey() + "\", \"" + RELAY_URI + "\", \"" + P2_ROLE + "\" ],\n" +
- " [ \"start_tzid\", \"" + START_TZID + "\" ],\n" +
- " [ \"end_tzid\", \"" + END_TZID + "\" ],\n" +
- " [ \"summary\", \"" + SUMMARY + "\" ],\n" +
- " [ \"l\", \"" + LABEL_1 + "\" ],\n" +
- " [ \"l\", \"" + LABEL_2 + "\" ],\n" +
- " [ \"location\", \"" + LOCATION + "\" ],\n" +
- " [ \"r\", \"" + URI.create(RELAY_URI) + "\" ],\n" +
- " [ \"title\", \"" + TITLE + "\" ],\n" +
- " [ \"start\", \"" + START + "\" ],\n" +
- " [ \"end\", \"" + END + "\" ]\n" +
- " ],\n" +
- " \"sig\": \"" + signature + "\"\n" +
- " }]";
- }
+ }
+
+ private String expectedEventResponseJson(String subscriptionId) {
+ return "[\"OK\",\"" + subscriptionId + "\",true,\"success: request processed\"]";
+ }
+
+ private String createReqJson(String subscriberId, String id) {
+ return "[\"REQ\",\"" + subscriberId + "\",{\"ids\":[\"" + id + "\"]}]";
+ }
+
+ private String expectedRequestResponseJson(String subscriberId) {
+ return " [\"EVENT\",\"" + subscriberId + "\",\n" +
+ " {\"id\": \"" + eventId + "\",\n" +
+ " \"kind\": " + KIND + ",\n" +
+ " \"content\": \"" + CALENDAR_CONTENT + "\",\n" +
+ " \"pubkey\": \"" + eventPubKey + "\",\n" +
+ " \"created_at\": " + CREATED_AT + ",\n" +
+ " \"tags\": [\n" +
+ " [ \"e\", \"" + E_TAG.getIdEvent() + "\" ],\n" +
+ " [ \"g\", \"" + G_TAG.getLocation() + "\" ],\n" +
+ " [ \"t\", \"" + T_TAG.getHashTag() + "\" ],\n" +
+ " [ \"d\", \"" + UUID_CALENDAR_TIME_BASED_EVENT_TEST + "\" ],\n" +
+ " [ \"p\", \"" + P1_TAG.getPublicKey() + "\", \"" + RELAY_URI + "\", \"" + P1_ROLE + "\" ],\n" +
+ " [ \"p\", \"" + P2_TAG.getPublicKey() + "\", \"" + RELAY_URI + "\", \"" + P2_ROLE + "\" ],\n" +
+ " [ \"start_tzid\", \"" + START_TZID + "\" ],\n" +
+ " [ \"end_tzid\", \"" + END_TZID + "\" ],\n" +
+ " [ \"summary\", \"" + SUMMARY + "\" ],\n" +
+ " [ \"l\", \"" + LABEL_1 + "\" ],\n" +
+ " [ \"l\", \"" + LABEL_2 + "\" ],\n" +
+ " [ \"location\", \"" + LOCATION + "\" ],\n" +
+ " [ \"r\", \"" + URI.create(RELAY_URI) + "\" ],\n" +
+ " [ \"title\", \"" + TITLE + "\" ],\n" +
+ " [ \"start\", \"" + START + "\" ],\n" +
+ " [ \"end\", \"" + END + "\" ]\n" +
+ " ],\n" +
+ " \"sig\": \"" + signature + "\"\n" +
+ " }]";
+ }
}
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99EventIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99EventIT.java
index 04197533b..b9133d1f4 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99EventIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99EventIT.java
@@ -7,7 +7,7 @@
import nostr.event.BaseTag;
import nostr.event.impl.ClassifiedListing;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.message.EventMessage;
import nostr.event.tag.EventTag;
import nostr.event.tag.GeohashTag;
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99RequestIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99RequestIT.java
index 70c5255f1..21d7dea93 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99RequestIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ApiNIP99RequestIT.java
@@ -7,7 +7,7 @@
import nostr.event.BaseTag;
import nostr.event.impl.ClassifiedListing;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.message.EventMessage;
import nostr.event.tag.EventTag;
import nostr.event.tag.GeohashTag;
diff --git a/nostr-java-api/src/test/java/nostr/api/integration/ZDoLastApiNIP09EventIT.java b/nostr-java-api/src/test/java/nostr/api/integration/ZDoLastApiNIP09EventIT.java
index 95857593d..76cb12953 100644
--- a/nostr-java-api/src/test/java/nostr/api/integration/ZDoLastApiNIP09EventIT.java
+++ b/nostr-java-api/src/test/java/nostr/api/integration/ZDoLastApiNIP09EventIT.java
@@ -3,7 +3,7 @@
import nostr.api.NIP01;
import nostr.api.NIP09;
import nostr.base.Relay;
-import nostr.config.RelayProperties;
+import nostr.config.RelayConfig;
import nostr.event.BaseMessage;
import nostr.event.BaseTag;
import nostr.event.Kind;
@@ -31,7 +31,7 @@
import static org.junit.jupiter.api.Assertions.*;
-@SpringJUnitConfig(RelayProperties.class)
+@SpringJUnitConfig(RelayConfig.class)
@ActiveProfiles("test")
public class ZDoLastApiNIP09EventIT {
@Autowired
@@ -118,7 +118,7 @@ public void deleteEventWithRef() throws IOException {
AddressTag addressTag = (AddressTag) addressTags.get(0);
assertEquals(10_001, addressTag.getKind());
- assertEquals(replaceableEvent.getId(), addressTag.getIdentifierTag().getId());
+ assertEquals(replaceableEvent.getId(), addressTag.getIdentifierTag().getUuid());
assertEquals(identity.getPublicKey(), addressTag.getPublicKey());
List kindTags = deletedEvent.getTags()
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/CalendarTimeBasedEventTest.java b/nostr-java-api/src/test/java/nostr/api/unit/CalendarTimeBasedEventTest.java
index 9a2266c30..f65a5503e 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/CalendarTimeBasedEventTest.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/CalendarTimeBasedEventTest.java
@@ -9,7 +9,7 @@
import nostr.event.NIP52Event;
import nostr.event.impl.CalendarContent;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.json.codec.BaseEventEncoder;
import nostr.event.tag.GeohashTag;
import nostr.event.tag.HashtagTag;
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java b/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java
index ccfff117e..7257e4f45 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java
@@ -14,7 +14,7 @@
import nostr.event.BaseTag;
import nostr.event.Kind;
import nostr.event.Marker;
-import nostr.event.filter.AddressableTagFilter;
+import nostr.event.filter.AddressTagFilter;
import nostr.event.filter.AuthorFilter;
import nostr.event.filter.EventFilter;
import nostr.event.filter.Filterable;
@@ -26,8 +26,9 @@
import nostr.event.filter.KindFilter;
import nostr.event.filter.ReferencedEventFilter;
import nostr.event.filter.ReferencedPublicKeyFilter;
+import nostr.event.filter.VoteTagFilter;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.json.codec.BaseEventEncoder;
import nostr.event.json.codec.BaseMessageDecoder;
import nostr.event.json.codec.BaseTagDecoder;
@@ -42,6 +43,7 @@
import nostr.event.tag.IdentifierTag;
import nostr.event.tag.PriceTag;
import nostr.event.tag.PubKeyTag;
+import nostr.event.tag.VoteTag;
import nostr.id.Identity;
import org.junit.jupiter.api.Test;
@@ -566,7 +568,7 @@ public void testReqMessagePopulatedListOfFiltersListDecoder() throws JsonProcess
new AuthorFilter<>(new PublicKey(author)),
new ReferencedEventFilter<>(new EventTag(referencedEventId)),
new ReferencedPublicKeyFilter<>(new PubKeyTag(new PublicKey(author))),
- new AddressableTagFilter<>(addressTag1)));
+ new AddressTagFilter<>(addressTag1)));
assertEquals(expectedReqMessage.encode(), decodedReqMessage.encode());
assertEquals(expectedReqMessage, decodedReqMessage);
@@ -674,7 +676,7 @@ public void testReqMessageAddressableTagDeserializer() throws JsonProcessingExce
addressTag1.setPublicKey(new PublicKey(author));
addressTag1.setIdentifierTag(new IdentifierTag(uuidValue1));
- ReqMessage expectedReqMessage = new ReqMessage(subscriptionId, new Filters(new AddressableTagFilter<>(addressTag1)));
+ ReqMessage expectedReqMessage = new ReqMessage(subscriptionId, new Filters(new AddressTagFilter<>(addressTag1)));
assertEquals(expectedReqMessage.encode(), decodedReqMessage.encode());
assertEquals(expectedReqMessage, decodedReqMessage);
@@ -749,4 +751,25 @@ public void testBaseEventMessageDecoderMultipleFiltersJson() throws JsonProcessi
assertEquals(subscriptionId, ((ReqMessage) message).getSubscriptionId());
assertEquals(2, ((ReqMessage) message).getFiltersList().size());
}
+
+ @Test
+ public void testReqMessageVoteTagFilterDecoder() {
+ log.info("testReqMessageVoteTagFilterDecoder");
+
+ String subscriptionId = "npub333k6vc9xhjp8q5cws262wuf2eh4zuvwupft03hy4ttqqnm7e0jrq3upup9";
+ String voteTagKey = "#v";
+ Integer voteTagValue = 1;
+ String reqJsonWithVoteTagFilterToDecode = "[\"REQ\",\"" + subscriptionId + "\",{\"" + voteTagKey + "\":[\"" + voteTagValue + "\"]}]";
+
+ assertDoesNotThrow(() -> {
+ ReqMessage decodedReqMessage = new BaseMessageDecoder().decode(reqJsonWithVoteTagFilterToDecode);
+
+ ReqMessage expectedReqMessage = new ReqMessage(subscriptionId,
+ new Filters(
+ new VoteTagFilter<>(new VoteTag(voteTagValue))));
+
+ assertEquals(reqJsonWithVoteTagFilterToDecode, decodedReqMessage.encode());
+ assertEquals(expectedReqMessage, decodedReqMessage);
+ });
+ }
}
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/NIP52ImplTest.java b/nostr-java-api/src/test/java/nostr/api/unit/NIP52ImplTest.java
index 034148118..5512abce8 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/NIP52ImplTest.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/NIP52ImplTest.java
@@ -5,7 +5,7 @@
import nostr.event.BaseTag;
import nostr.event.impl.CalendarContent;
import nostr.event.impl.CalendarTimeBasedEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.GeohashTag;
import nostr.event.tag.HashtagTag;
import nostr.event.tag.IdentifierTag;
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/NIP60Test.java b/nostr-java-api/src/test/java/nostr/api/unit/NIP60Test.java
index d24fc641c..fdef8e9b2 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/NIP60Test.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/NIP60Test.java
@@ -13,7 +13,7 @@
import nostr.event.BaseTag;
import nostr.event.Marker;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.AddressTag;
import nostr.event.tag.EventTag;
import nostr.id.Identity;
@@ -138,7 +138,7 @@ public void createTokenEvent() throws JsonProcessingException {
AddressTag aTag = (AddressTag) tags.get(0);
Assertions.assertEquals("a", aTag.getCode());
// Assertions.assertEquals("", aTag.getPublicKey());
- Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getId());
+ Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getUuid());
Assertions.assertEquals(37375, aTag.getKind().intValue());
// Decrypt and verify content
@@ -190,7 +190,7 @@ public void createSpendingHistoryEvent() throws JsonProcessingException {
// Assert a-tag
AddressTag aTag = (AddressTag) tags.get(0);
- Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getId());
+ Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getUuid());
Assertions.assertEquals(37375, aTag.getKind().intValue());
// Decrypt and verify content
@@ -258,7 +258,7 @@ public void createRedemptionQuoteEvent() {
// Assert a-tag
AddressTag aTag = (AddressTag) tags.get(2);
- Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getId());
+ Assertions.assertEquals("my-wallet", aTag.getIdentifierTag().getUuid());
Assertions.assertEquals(37375, aTag.getKind().intValue());
}
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/NIP61Test.java b/nostr-java-api/src/test/java/nostr/api/unit/NIP61Test.java
index c30e826f8..d5cb50905 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/NIP61Test.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/NIP61Test.java
@@ -13,7 +13,7 @@
import nostr.base.Relay;
import nostr.event.BaseTag;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.EventTag;
import nostr.event.tag.PubKeyTag;
import nostr.id.Identity;
diff --git a/nostr-java-api/src/test/java/nostr/api/unit/NIP99ImplTest.java b/nostr-java-api/src/test/java/nostr/api/unit/NIP99ImplTest.java
index 284e06766..33414c482 100644
--- a/nostr-java-api/src/test/java/nostr/api/unit/NIP99ImplTest.java
+++ b/nostr-java-api/src/test/java/nostr/api/unit/NIP99ImplTest.java
@@ -4,7 +4,7 @@
import nostr.event.BaseTag;
import nostr.event.impl.ClassifiedListing;
import nostr.event.impl.ClassifiedListingEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.PriceTag;
import nostr.id.Identity;
import org.junit.jupiter.api.BeforeAll;
diff --git a/nostr-java-api/src/test/java/nostr/api/util/CommonTestObjectsFactory.java b/nostr-java-api/src/test/java/nostr/api/util/CommonTestObjectsFactory.java
new file mode 100644
index 000000000..3c07ce2d4
--- /dev/null
+++ b/nostr-java-api/src/test/java/nostr/api/util/CommonTestObjectsFactory.java
@@ -0,0 +1,152 @@
+package nostr.api.util;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import lombok.Getter;
+import nostr.api.factory.impl.NIP01Impl;
+import nostr.api.factory.impl.NIP99Impl;
+import nostr.event.BaseTag;
+import nostr.event.impl.ClassifiedListing;
+import nostr.event.impl.GenericEvent;
+import nostr.event.impl.TextNoteEvent;
+import nostr.event.tag.EventTag;
+import nostr.event.tag.GeohashTag;
+import nostr.event.tag.HashtagTag;
+import nostr.event.tag.PriceTag;
+import nostr.event.tag.PubKeyTag;
+import nostr.event.tag.SubjectTag;
+import nostr.id.Identity;
+import org.apache.commons.lang3.RandomStringUtils;
+
+public class CommonTestObjectsFactory {
+
+ public static Identity createNewIdentity() {
+ return Identity.generateRandomIdentity();
+ }
+
+ public static T createTextNoteEvent(Identity identity, List tags, String content) {
+ TextNoteEvent textNoteEvent = new NIP01Impl.TextNoteEventFactory(identity, tags, content).create();
+// NIP01 nip01_1 = new NIP01<>(identity);
+// EventNostr sign = nip01_1.createTextNoteEvent(tags, content).sign();
+// return sign;
+ return (T) textNoteEvent;
+ }
+
+ public static T createClassifiedListingEvent(
+ Identity identity,
+ List tags,
+ String content,
+ ClassifiedListing cl) {
+
+ return (T) new NIP99Impl.ClassifiedListingEventFactory(identity, tags, content, cl).create();
+ }
+
+ public static GenericEvent createGenericEvent() {
+ String concat = generateRandomHex64String();
+ return new GenericEvent(concat.substring(0, 64));
+ }
+
+ public static SubjectTag createSubjectTag(Class clazz) {
+ return new SubjectTag(clazz.getName() + " Subject Tag");
+ }
+
+ public static PubKeyTag createPubKeyTag(Identity identity) {
+ return new PubKeyTag(identity.getPublicKey());
+ }
+
+ public static GeohashTag createGeohashTag(Class clazz) {
+ return new GeohashTag(clazz.getName() + " Geohash Tag");
+ }
+
+ public static HashtagTag createHashtagTag(Class clazz) {
+ return new HashtagTag(clazz.getName() + " Hashtag Tag");
+ }
+
+ public static EventTag createEventTag(Class clazz) {
+ return new EventTag(createGenericEvent().getId());
+ }
+
+ public static PriceTag createPriceTag() {
+ PriceComposite pc = new PriceComposite();
+ BigDecimal NUMBER = pc.getPrice();
+ String CURRENCY = pc.getCurrency();
+ String FREQUENCY = pc.getFrequency();
+ return new PriceTag(NUMBER, CURRENCY, FREQUENCY);
+ }
+
+ public static ClassifiedListing createClassifiedListing(String title, String summary) {
+ return new ClassifiedListingComposite(title, summary, createPriceTag()).getClassifiedListing();
+ }
+
+ public static String lorumIpsum() {
+ return lorumIpsum(CommonTestObjectsFactory.class);
+ }
+
+ public static String lorumIpsum(Class clazz) {
+ return lorumIpsum(clazz, 64);
+ }
+
+ public static String lorumIpsum(Class clazz, int length) {
+ return lorumIpsum(clazz.getSimpleName(), length);
+ }
+
+ public static String lorumIpsum(String s, int length) {
+ boolean useLetters = false;
+ boolean useNumbers = true;
+ return cullStringLength(
+ String.join("-", s, generateRandomAlphaNumericString(length, useLetters, useNumbers))
+ , 64);
+ }
+
+ public static String lnUrl() {
+// lnurl1dp68gurn8ghj7um5v93kketj9ehx2amn9uh8wetvdskkkmn0wahz7mrww4excup0dajx2mrv92x9xp
+// match lnUrl string length of 84
+ return cullStringLength("lnurl" + generateRandomHex64String(), 84);
+ }
+
+ private static String cullStringLength(String s, int x) {
+ return s.length() > x ? s.substring(0, x) : s;
+ }
+
+ private static String generateRandomAlphaNumericString(int length, boolean useLetters, boolean useNumbers) {
+ return RandomStringUtils.random(length, useLetters, useNumbers);
+ }
+
+ public static String generateRandomHex64String() {
+ return UUID.randomUUID().toString().concat(UUID.randomUUID().toString()).replaceAll("[^A-Za-z0-9]", "");
+ }
+
+ public static BigDecimal createRandomBigDecimal() {
+ Random rand = new Random();
+ int max = 100, min = 50;
+ int i = rand.nextInt(max - min + 1) + min;
+ int j = (rand.nextInt(max - min + 1) + min);
+ return new BigDecimal(String.valueOf(i) + '.' + j);
+ }
+
+ @Getter
+ public static class PriceComposite {
+ private final String currency = "BTC";
+ private final String frequency = "nanosecond";
+ private final BigDecimal price;
+
+ private PriceComposite() {
+ price = createRandomBigDecimal();
+ }
+ }
+
+ @Getter
+ public static class ClassifiedListingComposite {
+ private final ClassifiedListing classifiedListing;
+
+ private ClassifiedListingComposite(String title, String summary, PriceTag priceTag) {
+ this.classifiedListing = ClassifiedListing.builder(
+ title,
+ summary,
+ priceTag)
+ .build();
+ }
+ }
+}
diff --git a/nostr-java-base/pom.xml b/nostr-java-base/pom.xml
index 103219fe7..5e31c3a23 100644
--- a/nostr-java-base/pom.xml
+++ b/nostr-java-base/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-client/pom.xml b/nostr-java-client/pom.xml
index 405a337fe..f31ee23c9 100644
--- a/nostr-java-client/pom.xml
+++ b/nostr-java-client/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-crypto/pom.xml b/nostr-java-crypto/pom.xml
index b60d82e4e..9113f4be4 100644
--- a/nostr-java-crypto/pom.xml
+++ b/nostr-java-crypto/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-encryption/pom.xml b/nostr-java-encryption/pom.xml
index 5a7734cf5..7520a3d2e 100644
--- a/nostr-java-encryption/pom.xml
+++ b/nostr-java-encryption/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-event/pom.xml b/nostr-java-event/pom.xml
index 00c84a67c..afde0d680 100644
--- a/nostr-java-event/pom.xml
+++ b/nostr-java-event/pom.xml
@@ -4,7 +4,7 @@
xyz.tcheeric
nostr-java
- 0.6.5-SNAPSHOT
+ 0.6.6-SNAPSHOT
../pom.xml
diff --git a/nostr-java-event/src/main/java/nostr/event/BaseTag.java b/nostr-java-event/src/main/java/nostr/event/BaseTag.java
index 5c0aaff75..a88852475 100644
--- a/nostr-java-event/src/main/java/nostr/event/BaseTag.java
+++ b/nostr-java-event/src/main/java/nostr/event/BaseTag.java
@@ -13,10 +13,8 @@
import nostr.base.annotation.Key;
import nostr.base.annotation.Tag;
import nostr.event.json.deserializer.TagDeserializer;
-import nostr.event.json.serializer.TagSerializer;
-import nostr.util.NostrException;
+import nostr.event.json.serializer.BaseTagSerializer;
import org.apache.commons.lang3.stream.Streams;
-
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
@@ -28,14 +26,11 @@
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
-/**
- * @author squirrel
- */
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
@JsonDeserialize(using = TagDeserializer.class)
-@JsonSerialize(using = TagSerializer.class)
+@JsonSerialize(using = BaseTagSerializer.class)
public abstract class BaseTag implements ITag {
@JsonIgnore
@@ -51,21 +46,23 @@ public String getCode() {
return this.getClass().getAnnotation(Tag.class).code();
}
- public String getFieldValue(Field field) throws NostrException {
+ public Optional getFieldValue(Field field) {
try {
- Object f = new PropertyDescriptor(field.getName(), this.getClass()).getReadMethod().invoke(this);
- return f != null ? f.toString() : null;
+ return Optional.ofNullable(
+ new PropertyDescriptor(field.getName(), this.getClass())
+ .getReadMethod().invoke(this))
+ .map(Object::toString);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException ex) {
- throw new NostrException(ex);
+ return Optional.empty();
}
}
- public List getSupportedFields() throws NostrException {
- return new Streams.FailableStream<>(Arrays.stream(this.getClass().getDeclaredFields()))
+ public List getSupportedFields() {
+ return Streams.failableStream(Arrays.stream(this.getClass().getDeclaredFields()))
.filter(f ->
Objects.nonNull(f.getAnnotation(Key.class)))
.filter(f ->
- Objects.nonNull(getFieldValue(f)))
+ getFieldValue(f).isPresent())
.collect(Collectors.toList());
}
diff --git a/nostr-java-event/src/main/java/nostr/event/Kind.java b/nostr-java-event/src/main/java/nostr/event/Kind.java
index 0f34b990b..686f87bd6 100644
--- a/nostr-java-event/src/main/java/nostr/event/Kind.java
+++ b/nostr-java-event/src/main/java/nostr/event/Kind.java
@@ -29,6 +29,7 @@ public enum Kind {
MUTE_USER(44, "mute_user"),
ENCRYPTED_PAYLOADS(44, "encrypted_payloads"),
OTS_EVENT(1040, "ots_event"),
+ VOTE(2112, "vote"),
RESERVED_CASHU_WALLET_TOKENS(7_374, "reserved_cashu_wallet_tokens"),
WALLET_UNSPENT_PROOF(7_375, "wallet_unspent_proof"),
WALLET_TX_HISTORY(7_376, "wallet_tx_history"),
diff --git a/nostr-java-event/src/main/java/nostr/event/filter/AddressTagFilter.java b/nostr-java-event/src/main/java/nostr/event/filter/AddressTagFilter.java
new file mode 100644
index 000000000..bfbe969ba
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/filter/AddressTagFilter.java
@@ -0,0 +1,76 @@
+package nostr.event.filter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import nostr.base.PublicKey;
+import nostr.base.Relay;
+import nostr.event.BaseTag;
+import nostr.event.impl.GenericEvent;
+import nostr.event.tag.AddressTag;
+import nostr.event.tag.IdentifierTag;
+
+@EqualsAndHashCode(callSuper = true)
+public class AddressTagFilter extends AbstractFilterable {
+ public final static String FILTER_KEY = "#a";
+
+ public AddressTagFilter(T addressableTag) {
+ super(addressableTag, FILTER_KEY);
+ }
+
+ @Override
+ public Predicate getPredicate() {
+ return (genericEvent) ->
+ Filterable.getTypeSpecificTags(AddressTag.class, genericEvent).stream()
+ .anyMatch(addressTag ->
+ addressTag.equals(getAddressableTag()));
+ }
+
+ @Override
+ public Object getFilterableValue() {
+ String requiredAttributes = Stream.of(
+ getAddressableTag().getKind(),
+ getAddressableTag().getPublicKey().toHexString(),
+ getAddressableTag().getIdentifierTag().getUuid())
+ .map(Object::toString).collect(Collectors.joining(":"));
+ return Optional.ofNullable(getAddressableTag().getRelay()).map(relay ->
+ String.join("\",\"", requiredAttributes, relay.getUri())).orElse(requiredAttributes);
+ }
+
+ private T getAddressableTag() {
+ return super.getFilterable();
+ }
+
+ public static Function fxn = node ->
+ new AddressTagFilter<>(createAddressTag(node));
+
+ protected static T createAddressTag(@NonNull JsonNode node) {
+ String[] nodes = node.asText().split(",");
+ List list = Arrays.stream(nodes[0].split(":")).toList();
+
+ final AddressTag addressTag = new AddressTag();
+ addressTag.setKind(Integer.valueOf(list.get(0)));
+ addressTag.setPublicKey(new PublicKey(list.get(1)));
+ addressTag.setIdentifierTag(new IdentifierTag(list.get(2)));
+
+ if (!Objects.equals(2, nodes.length))
+ return (T) addressTag;
+
+ addressTag.setIdentifierTag(
+ new IdentifierTag(
+ list.get(2).replaceAll("\"$", "")));
+ addressTag.setRelay(
+ new Relay(
+ nodes[1].replaceAll("^\"", "")));
+
+ return (T) addressTag;
+ }
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/filter/AddressableTagFilter.java b/nostr-java-event/src/main/java/nostr/event/filter/AddressableTagFilter.java
deleted file mode 100644
index ae86a6ca3..000000000
--- a/nostr-java-event/src/main/java/nostr/event/filter/AddressableTagFilter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package nostr.event.filter;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import lombok.EqualsAndHashCode;
-import lombok.NonNull;
-import nostr.base.PublicKey;
-import nostr.event.impl.GenericEvent;
-import nostr.event.tag.AddressTag;
-import nostr.event.tag.IdentifierTag;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-@EqualsAndHashCode(callSuper = true)
-public class AddressableTagFilter extends AbstractFilterable {
- public final static String FILTER_KEY = "#a";
-
- public AddressableTagFilter(T addressableTag) {
- super(addressableTag, FILTER_KEY);
- }
-
- @Override
- public Predicate getPredicate() {
- return this::compare;
- }
-
- public static AddressTag createAddressTag(@NonNull JsonNode addressableTag) throws IllegalArgumentException {
- try {
- List list = Arrays.stream(addressableTag.asText().split(":")).toList();
-
- AddressTag addressTag = new AddressTag();
- addressTag.setKind(Integer.valueOf(list.getFirst()));
- addressTag.setPublicKey(new PublicKey(list.get(1)));
- addressTag.setIdentifierTag(new IdentifierTag(list.get(2)));
-
- return addressTag;
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(
- String.format("Malformed JsonNode addressable tag: [%s]", addressableTag.asText()), e);
- }
- }
-
- @Override
- public String getFilterableValue() {
- T addressableTag = getAddressableTag();
- Integer kind = addressableTag.getKind();
- String hexString = addressableTag.getPublicKey().toHexString();
- String id = addressableTag.getIdentifierTag().getId();
-
- return Stream.of(kind, hexString, id)
- .map(Object::toString)
- .collect(Collectors.joining(":"));
- }
-
- private boolean compare(@NonNull GenericEvent genericEvent) {
- T addressableTag = getAddressableTag();
- return
- !genericEvent.getPubKey().toHexString().equals(
- addressableTag.getPublicKey().toHexString()) ||
- !genericEvent.getKind().equals(
- addressableTag.getKind()) ||
- Filterable.getTypeSpecificTags(IdentifierTag.class, genericEvent).stream()
- .anyMatch(identifierTag ->
- identifierTag.getId().equals(
- addressableTag.getIdentifierTag().getId()));
- }
-
- private T getAddressableTag() {
- return super.getFilterable();
- }
-
- public static Function fxn = node -> new AddressableTagFilter<>(AddressableTagFilter.createAddressTag(node));
-}
diff --git a/nostr-java-event/src/main/java/nostr/event/filter/GenericTagQueryFilter.java b/nostr-java-event/src/main/java/nostr/event/filter/GenericTagQueryFilter.java
index c92ffeb98..a9f8290fc 100644
--- a/nostr-java-event/src/main/java/nostr/event/filter/GenericTagQueryFilter.java
+++ b/nostr-java-event/src/main/java/nostr/event/filter/GenericTagQueryFilter.java
@@ -5,7 +5,7 @@
import nostr.base.ElementAttribute;
import nostr.base.GenericTagQuery;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import java.util.function.Function;
import java.util.function.Predicate;
diff --git a/nostr-java-event/src/main/java/nostr/event/filter/IdentifierTagFilter.java b/nostr-java-event/src/main/java/nostr/event/filter/IdentifierTagFilter.java
index 8eb7b55b9..0b5bec5fa 100644
--- a/nostr-java-event/src/main/java/nostr/event/filter/IdentifierTagFilter.java
+++ b/nostr-java-event/src/main/java/nostr/event/filter/IdentifierTagFilter.java
@@ -21,12 +21,12 @@ public Predicate getPredicate() {
return (genericEvent) ->
Filterable.getTypeSpecificTags(IdentifierTag.class, genericEvent).stream()
.anyMatch(genericEventIdentifierTag ->
- genericEventIdentifierTag.getId().equals(getFilterableValue()));
+ genericEventIdentifierTag.getUuid().equals(getFilterableValue()));
}
@Override
public String getFilterableValue() {
- return getIdentifierTag().getId();
+ return getIdentifierTag().getUuid();
}
private T getIdentifierTag() {
diff --git a/nostr-java-event/src/main/java/nostr/event/filter/VoteTagFilter.java b/nostr-java-event/src/main/java/nostr/event/filter/VoteTagFilter.java
new file mode 100644
index 000000000..3d0f180db
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/filter/VoteTagFilter.java
@@ -0,0 +1,36 @@
+package nostr.event.filter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import lombok.EqualsAndHashCode;
+import nostr.event.impl.GenericEvent;
+import nostr.event.tag.VoteTag;
+
+@EqualsAndHashCode(callSuper = true)
+public class VoteTagFilter extends AbstractFilterable {
+ public final static String FILTER_KEY = "#v";
+
+ public VoteTagFilter(T voteTag) {
+ super(voteTag, FILTER_KEY);
+ }
+
+ @Override
+ public Predicate getPredicate() {
+ return (genericEvent) ->
+ Filterable.getTypeSpecificTags(VoteTag.class, genericEvent).stream()
+ .anyMatch(voteTag ->
+ voteTag.getVote().equals(getFilterableValue()));
+ }
+
+ @Override
+ public Integer getFilterableValue() {
+ return getVoteTag().getVote();
+ }
+
+ private T getVoteTag() {
+ return super.getFilterable();
+ }
+
+ public static Function fxn = node -> new VoteTagFilter<>(new VoteTag(node.asInt()));
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/CalendarRsvpEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/CalendarRsvpEvent.java
index 722323c84..a10a0c4b8 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/CalendarRsvpEvent.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/CalendarRsvpEvent.java
@@ -18,6 +18,7 @@
import nostr.event.NIP52Event;
import nostr.event.impl.CalendarRsvpEvent.CalendarRsvpEventDeserializer;
import nostr.event.tag.AddressTag;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.IdentifierTag;
import nostr.event.tag.PubKeyTag;
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/CalendarTimeBasedEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/CalendarTimeBasedEvent.java
index 11b5647a7..9f5e15cc8 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/CalendarTimeBasedEvent.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/CalendarTimeBasedEvent.java
@@ -17,6 +17,7 @@
import nostr.event.Kind;
import nostr.event.NIP52Event;
import nostr.event.impl.CalendarTimeBasedEvent.CalendarTimeBasedEventDeserializer;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.IdentifierTag;
import nostr.event.tag.PubKeyTag;
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/CanonicalAuthenticationEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/CanonicalAuthenticationEvent.java
index d11b6db12..132d6f2f1 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/CanonicalAuthenticationEvent.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/CanonicalAuthenticationEvent.java
@@ -7,6 +7,7 @@
import nostr.base.annotation.Event;
import nostr.event.BaseTag;
import nostr.event.Kind;
+import nostr.event.tag.GenericTag;
import java.util.ArrayList;
import java.util.List;
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/ClassifiedListingEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/ClassifiedListingEvent.java
index c0520514e..f2ad150c8 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/ClassifiedListingEvent.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/ClassifiedListingEvent.java
@@ -18,6 +18,7 @@
import nostr.event.Kind;
import nostr.event.NIP99Event;
import nostr.event.impl.ClassifiedListingEvent.ClassifiedListingEventDeserializer;
+import nostr.event.tag.GenericTag;
import nostr.event.tag.PriceTag;
import java.io.IOException;
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java b/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java
index 59098896d..abe33f000 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java
@@ -24,6 +24,7 @@
import nostr.event.Kind;
import nostr.event.json.deserializer.PublicKeyDeserializer;
import nostr.event.json.deserializer.SignatureDeserializer;
+import nostr.event.tag.GenericTag;
import nostr.util.NostrException;
import nostr.util.NostrUtil;
import nostr.util.thread.HexStringValidator;
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/GenericMessage.java b/nostr-java-event/src/main/java/nostr/event/impl/GenericMessage.java
index c96d40e63..6e7fe8920 100644
--- a/nostr-java-event/src/main/java/nostr/event/impl/GenericMessage.java
+++ b/nostr-java-event/src/main/java/nostr/event/impl/GenericMessage.java
@@ -9,44 +9,54 @@
import nostr.base.IElement;
import nostr.base.IGenericElement;
import nostr.event.BaseMessage;
-
import java.util.ArrayList;
import java.util.List;
-
+import java.util.stream.IntStream;
import static nostr.base.Encoder.ENCODER_MAPPED_AFTERBURNER;
-
-/**
- *
- * @author squirrel
- */
+import static nostr.base.IDecoder.I_DECODER_MAPPER_AFTERBURNER;
@Setter
@Getter
public class GenericMessage extends BaseMessage implements IGenericElement, IElement {
-
@JsonIgnore
private final List attributes;
- public GenericMessage(String command) {
- this(command, new ArrayList<>(), 1);
+ public GenericMessage(@NonNull String command) {
+ this(command, new ArrayList<>());
}
- public GenericMessage(String command, Integer nip) {
- this(command, new ArrayList<>(), nip);
+ /**
+ * nip ctor parameter to be removed
+ *
+ * @deprecated use any available proper constructor variant instead
+ */
+ @Deprecated(forRemoval = true)
+ public GenericMessage(@NonNull String command, @NonNull Integer nip) {
+ this(command, new ArrayList<>());
}
- public GenericMessage(String command, List attributes, Integer nip) {
+ public GenericMessage(@NonNull String command, @NonNull List attributes) {
super(command);
this.attributes = attributes;
}
+ /**
+ * nip ctor parameter to be removed
+ *
+ * @deprecated use any available proper constructor variant instead
+ */
+ @Deprecated(forRemoval = true)
+ public GenericMessage(@NonNull String command, @NonNull List attributes, @NonNull Integer nip) {
+ this(command, attributes);
+ }
+
@Override
- public void addAttribute(ElementAttribute... attribute) {
+ public void addAttribute(@NonNull ElementAttribute... attribute) {
addAttributes(List.of(attribute));
}
@Override
- public void addAttributes(List attributes) {
+ public void addAttributes(@NonNull List attributes) {
this.attributes.addAll(attributes);
}
@@ -57,13 +67,34 @@ public String encode() throws JsonProcessingException {
return ENCODER_MAPPED_AFTERBURNER.writeValueAsString(getArrayNode());
}
- public static T decode(@NonNull Object[] msgArr) {
- GenericMessage gm = new GenericMessage(msgArr[0].toString());
- for (int i = 1; i < msgArr.length; i++) {
- if (msgArr[i] instanceof String) {
- gm.addAttribute(ElementAttribute.builder().value(msgArr[i]).build());
- }
+// public static T decode(@NonNull String jsonString) {
+// try {
+// Object[] msgArr = I_DECODER_MAPPER_AFTERBURNER.readValue(jsonString, Object[].class);
+// GenericMessage gm = new GenericMessage(msgArr[0].toString());
+// for (int i = 1; i < msgArr.length; i++) {
+//// TODO: does below ever resolve to String? because RxR stream says it'll always be false. check eric's tests and see what's happening there
+// if (msgArr[i] instanceof String) {
+// gm.addAttribute(ElementAttribute.builder().value(msgArr[i]).build());
+// }
+// }
+// return (T) gm;
+// } catch (Exception e) {
+// throw new AssertionError(e);
+// }
+// }
+
+ public static T decode(@NonNull String json) {
+ try {
+ Object[] msgArr = I_DECODER_MAPPER_AFTERBURNER.readValue(json, Object[].class);
+ GenericMessage gm = new GenericMessage(
+ msgArr[0].toString(),
+ IntStream.of(1, msgArr.length-1)
+ .mapToObj(i -> ElementAttribute.builder().value(msgArr[i]).build())
+ .distinct()
+ .toList());
+ return (T) gm;
+ } catch (Exception ex) {
+ throw new AssertionError(ex);
}
- return (T) gm;
}
}
diff --git a/nostr-java-event/src/main/java/nostr/event/impl/GenericTag.java b/nostr-java-event/src/main/java/nostr/event/impl/GenericTag.java
deleted file mode 100644
index 3148f8a59..000000000
--- a/nostr-java-event/src/main/java/nostr/event/impl/GenericTag.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package nostr.event.impl;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NonNull;
-import nostr.base.ElementAttribute;
-import nostr.base.IGenericElement;
-import nostr.event.BaseTag;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.IntStream;
-
-/**
- * @author squirrel
- */
-@Data
-@EqualsAndHashCode(callSuper = false)
-public class GenericTag extends BaseTag implements IGenericElement {
-
- private final String code;
-
- private final List attributes;
-
- public GenericTag(String code) {
- this(code, new ArrayList<>());
- }
-
- /**
- * nip parameter to be removed
- *
- * @deprecated use any available proper constructor variant instead
- */
- @Deprecated(forRemoval = true)
- public GenericTag(String code, Integer nip) {
- this(code, new ArrayList<>());
- }
-
- public GenericTag(@NonNull String code, @NonNull ElementAttribute... attribute) {
- this(code, List.of(attribute));
- }
-
- public GenericTag(@NonNull String code, @NonNull List attributes) {
- this.code = code;
- this.attributes = attributes;
- }
-
- @Override
- public void addAttribute(@NonNull ElementAttribute... attribute) {
- this.addAttributes(List.of(attribute));
- }
-
- @Override
- public void addAttributes(@NonNull List attributes) {
- this.attributes.addAll(attributes);
- }
-
- /**
- * nip parameter to be removed
- *
- * @deprecated use {@link #create(String, String...)} instead.
- */
- @Deprecated(forRemoval = true)
- public static GenericTag create(String code, Integer nip, String... params) {
- return create(code, List.of(params));
- }
-
- /**
- * nip parameter to be removed
- *
- * @deprecated use {@link #create(String, List)} instead.
- */
-
- @Deprecated(forRemoval = true)
- public static GenericTag create(String code, Integer nip, List params) {
- return create(code, params);
- }
-
- public static GenericTag create(@NonNull String code, @NonNull String... params) {
- return create(code, List.of(params));
- }
-
- public static GenericTag create(@NonNull String code, @NonNull List params) {
- return new GenericTag(code,
- IntStream.range(0, params.size())
- .mapToObj(i ->
- new ElementAttribute("param".concat(String.valueOf(i)), params.get(i)))
- .toList());
- }
-}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/BaseMessageDecoder.java b/nostr-java-event/src/main/java/nostr/event/json/codec/BaseMessageDecoder.java
index b688e1193..ad5c5fe27 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/codec/BaseMessageDecoder.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/codec/BaseMessageDecoder.java
@@ -3,7 +3,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import lombok.SneakyThrows;
import nostr.base.IDecoder;
import nostr.event.BaseMessage;
import nostr.event.impl.GenericMessage;
@@ -16,9 +15,7 @@
import nostr.event.message.RelayAuthenticationMessage;
import nostr.event.message.ReqMessage;
-import java.util.List;
import java.util.Map;
-import java.util.stream.IntStream;
/**
* @author eric
@@ -27,47 +24,44 @@
public class BaseMessageDecoder implements IDecoder {
public static final int COMMAND_INDEX = 0;
public static final int ARG_INDEX = 1;
- public static final int FILTERS_START_INDEX = 2;
@Override
public T decode(@NonNull String jsonString) throws JsonProcessingException {
- ValidJsonNodeFirstPair validJsonNodeFirstPair = json_strCmd_arg(jsonString);
- String command = validJsonNodeFirstPair.formerly_strCmd();
- Object subscriptionId = validJsonNodeFirstPair.formerly_arg();
-
- Object[] msgArr = I_DECODER_MAPPER_AFTERBURNER.readValue(jsonString, Object[].class); // TODO: replace with jsonNode after ReqMessage.decode() is finished
+ ValidNostrJsonStructure validNostrJsonStructure = validateProperlyFormedJson(jsonString);
+ String command = validNostrJsonStructure.getCommand();
+ Object subscriptionId = validNostrJsonStructure.getSubscriptionId();
return switch (command) {
+// client <-> relay messages
case "AUTH" -> subscriptionId instanceof Map map ?
CanonicalAuthenticationMessage.decode(map) :
RelayAuthenticationMessage.decode(subscriptionId);
+ case "EVENT" -> EventMessage.decode(jsonString);
+// missing client <-> relay handlers
+// case "COUNT" -> CountMessage.decode(subscriptionId);
+
+// client -> relay messages
case "CLOSE" -> CloseMessage.decode(subscriptionId);
+ case "REQ" -> ReqMessage.decode(subscriptionId, jsonString);
+
+// relay -> client handlers
case "EOSE" -> EoseMessage.decode(subscriptionId);
- case "EVENT" -> EventMessage.decode(msgArr, I_DECODER_MAPPER_AFTERBURNER);
case "NOTICE" -> NoticeMessage.decode(subscriptionId);
- case "OK" -> OkMessage.decode(msgArr);
- case "REQ" -> ReqMessage.decode(subscriptionId, json_msgArr(jsonString));
- default -> GenericMessage.decode(msgArr);
+ case "OK" -> OkMessage.decode(jsonString);
+// missing relay -> client handlers
+// case "CLOSED" -> Closed.message.decode(subscriptionId);
+
+ default -> throw new IllegalArgumentException(String.format("Invalid JSON command [%s] in JSON string [%s] ", command, jsonString));
};
}
- private ValidJsonNodeFirstPair json_strCmd_arg(@NonNull String jsonString) throws JsonProcessingException {
- return new ValidJsonNodeFirstPair(
+ private ValidNostrJsonStructure validateProperlyFormedJson(@NonNull String jsonString) throws JsonProcessingException {
+ return new ValidNostrJsonStructure(
I_DECODER_MAPPER_AFTERBURNER.readTree(jsonString).get(COMMAND_INDEX).asText(),
I_DECODER_MAPPER_AFTERBURNER.readTree(jsonString).get(ARG_INDEX).asText());
}
- private List json_msgArr(@NonNull String jsonString) throws JsonProcessingException {
- return IntStream.range(FILTERS_START_INDEX, I_DECODER_MAPPER_AFTERBURNER.readTree(jsonString).size())
- .mapToObj(idx -> readTree(jsonString, idx)).toList();
- }
-
- @SneakyThrows
- private String readTree(String jsonString, int idx) {
- return I_DECODER_MAPPER_AFTERBURNER.readTree(jsonString).get(idx).toString();
- }
-
- private record ValidJsonNodeFirstPair(
- @NonNull String formerly_strCmd,
- @NonNull Object formerly_arg) {}
+ private record ValidNostrJsonStructure(
+ @NonNull String getCommand,
+ @NonNull Object getSubscriptionId) {}
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/BaseTagEncoder.java b/nostr-java-event/src/main/java/nostr/event/json/codec/BaseTagEncoder.java
index 71eeefce2..3066652a2 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/codec/BaseTagEncoder.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/codec/BaseTagEncoder.java
@@ -3,31 +3,21 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
-import lombok.Data;
-import lombok.NonNull;
import nostr.base.Encoder;
import nostr.event.BaseTag;
-import nostr.event.json.serializer.TagSerializer;
+import nostr.event.json.serializer.BaseTagSerializer;
-@Data
-public class BaseTagEncoder implements Encoder {
- public static final ObjectMapper BASETAGENCODER_MAPPED_AFTERBURNER =
+public record BaseTagEncoder(BaseTag tag) implements Encoder {
+ public static final ObjectMapper BASETAG_ENCODER_MAPPED_AFTERBURNER =
ENCODER_MAPPED_AFTERBURNER.copy()
.registerModule(
new SimpleModule().addSerializer(
- new TagSerializer()));
-
- private final BaseTag tag;
-
- public BaseTagEncoder(@NonNull BaseTag tag) {
- this.tag = tag;
- }
+ new BaseTagSerializer<>()));
@Override
public String encode() {
try {
- String s = BASETAGENCODER_MAPPED_AFTERBURNER.writeValueAsString(tag);
- return s;
+ return BASETAG_ENCODER_MAPPED_AFTERBURNER.writeValueAsString(tag);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/FilterableProvider.java b/nostr-java-event/src/main/java/nostr/event/json/codec/FilterableProvider.java
index c614f8d02..80d257d1f 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/codec/FilterableProvider.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/codec/FilterableProvider.java
@@ -1,8 +1,11 @@
package nostr.event.json.codec;
import com.fasterxml.jackson.databind.JsonNode;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.StreamSupport;
import lombok.NonNull;
-import nostr.event.filter.AddressableTagFilter;
+import nostr.event.filter.AddressTagFilter;
import nostr.event.filter.AuthorFilter;
import nostr.event.filter.EventFilter;
import nostr.event.filter.Filterable;
@@ -15,30 +18,28 @@
import nostr.event.filter.ReferencedPublicKeyFilter;
import nostr.event.filter.SinceFilter;
import nostr.event.filter.UntilFilter;
-
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.StreamSupport;
+import nostr.event.filter.VoteTagFilter;
public class FilterableProvider {
- protected static List getFilterFunction(@NonNull JsonNode node, @NonNull String type) {
- return switch (type) {
- case ReferencedPublicKeyFilter.FILTER_KEY -> getFilterable(node, ReferencedPublicKeyFilter.fxn);
- case ReferencedEventFilter.FILTER_KEY -> getFilterable(node, ReferencedEventFilter.fxn);
- case AddressableTagFilter.FILTER_KEY -> getFilterable(node, AddressableTagFilter.fxn);
- case IdentifierTagFilter.FILTER_KEY -> getFilterable(node, IdentifierTagFilter.fxn);
- case GeohashTagFilter.FILTER_KEY -> getFilterable(node, GeohashTagFilter.fxn);
- case HashtagTagFilter.FILTER_KEY -> getFilterable(node, HashtagTagFilter.fxn);
- case AuthorFilter.FILTER_KEY -> getFilterable(node, AuthorFilter.fxn);
- case EventFilter.FILTER_KEY -> getFilterable(node, EventFilter.fxn);
- case KindFilter.FILTER_KEY -> getFilterable(node, KindFilter.fxn);
- case SinceFilter.FILTER_KEY -> SinceFilter.fxn.apply(node);
- case UntilFilter.FILTER_KEY -> UntilFilter.fxn.apply(node);
- default -> getFilterable(node, GenericTagQueryFilter.fxn(type));
- };
- }
+ protected static List getFilterFunction(@NonNull JsonNode node, @NonNull String type) {
+ return switch (type) {
+ case ReferencedPublicKeyFilter.FILTER_KEY -> getFilterable(node, ReferencedPublicKeyFilter.fxn);
+ case ReferencedEventFilter.FILTER_KEY -> getFilterable(node, ReferencedEventFilter.fxn);
+ case IdentifierTagFilter.FILTER_KEY -> getFilterable(node, IdentifierTagFilter.fxn);
+ case AddressTagFilter.FILTER_KEY -> getFilterable(node, AddressTagFilter.fxn);
+ case GeohashTagFilter.FILTER_KEY -> getFilterable(node, GeohashTagFilter.fxn);
+ case HashtagTagFilter.FILTER_KEY -> getFilterable(node, HashtagTagFilter.fxn);
+ case VoteTagFilter.FILTER_KEY -> getFilterable(node, VoteTagFilter.fxn);
+ case AuthorFilter.FILTER_KEY -> getFilterable(node, AuthorFilter.fxn);
+ case EventFilter.FILTER_KEY -> getFilterable(node, EventFilter.fxn);
+ case KindFilter.FILTER_KEY -> getFilterable(node, KindFilter.fxn);
+ case SinceFilter.FILTER_KEY -> SinceFilter.fxn.apply(node);
+ case UntilFilter.FILTER_KEY -> UntilFilter.fxn.apply(node);
+ default -> getFilterable(node, GenericTagQueryFilter.fxn(type));
+ };
+ }
- private static List getFilterable(JsonNode jsonNode, Function filterFunction) {
- return StreamSupport.stream(jsonNode.spliterator(), false).map(filterFunction).toList();
- }
+ private static List getFilterable(JsonNode jsonNode, Function filterFunction) {
+ return StreamSupport.stream(jsonNode.spliterator(), false).map(filterFunction).toList();
+ }
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/FiltersEncoder.java b/nostr-java-event/src/main/java/nostr/event/json/codec/FiltersEncoder.java
index 2325bd924..3f35fadc8 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/codec/FiltersEncoder.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/codec/FiltersEncoder.java
@@ -1,35 +1,24 @@
package nostr.event.json.codec;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
import nostr.base.Encoder;
import nostr.event.filter.Filters;
-@Data
-@EqualsAndHashCode(callSuper = false)
-public class FiltersEncoder implements Encoder {
- private final Filters filters;
+public record FiltersEncoder(Filters filters) implements Encoder {
- public FiltersEncoder(Filters filters) {
- this.filters = filters;
- }
+ @Override
+ public String encode() {
+ ObjectNode root = ENCODER_MAPPED_AFTERBURNER.createObjectNode();
- @Override
- public String encode() {
- ObjectNode root = ENCODER_MAPPED_AFTERBURNER.createObjectNode();
+ filters.getFiltersMap().forEach((key, filterableList) ->
+ root.setAll(
+ filterableList
+ .stream()
+ .map(filterable ->
+ filterable.toObjectNode(root))
+ .toList()
+ .getFirst()));
- filters.getFiltersMap().forEach((key, filterableList) -> {
- final ObjectNode objectNode = ENCODER_MAPPED_AFTERBURNER.createObjectNode();
- root.setAll(
- filterableList
- .stream()
- .map(filterable ->
- filterable.toObjectNode(objectNode))
- .toList()
- .getFirst());
- });
-
- return root.toString();
- }
+ return root.toString();
+ }
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java b/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java
index d65ba7c22..3ffe238fa 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/codec/GenericTagDecoder.java
@@ -5,7 +5,7 @@
import lombok.NonNull;
import nostr.base.ElementAttribute;
import nostr.base.IDecoder;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import java.util.stream.IntStream;
diff --git a/nostr-java-event/src/main/java/nostr/event/json/deserializer/PublicKeyDeserializer.java b/nostr-java-event/src/main/java/nostr/event/json/deserializer/PublicKeyDeserializer.java
index cf12c1a7b..5fb78dc6b 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/deserializer/PublicKeyDeserializer.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/deserializer/PublicKeyDeserializer.java
@@ -1,20 +1,15 @@
-
package nostr.event.json.deserializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
-import java.io.IOException;
import nostr.base.PublicKey;
+import java.io.IOException;
public class PublicKeyDeserializer extends JsonDeserializer {
-
@Override
public PublicKey deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
- JsonNode node = jsonParser.readValueAsTree();
- String hexPubKey = node.asText();
-
- return new PublicKey(hexPubKey);
+ return new PublicKey(jsonParser.readValueAsTree().asText());
}
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/deserializer/SignatureDeserializer.java b/nostr-java-event/src/main/java/nostr/event/json/deserializer/SignatureDeserializer.java
index 3d7e8c08c..25ef2ee57 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/deserializer/SignatureDeserializer.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/deserializer/SignatureDeserializer.java
@@ -4,25 +4,16 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
import nostr.base.Signature;
import nostr.util.NostrUtil;
+import java.io.IOException;
public class SignatureDeserializer extends JsonDeserializer {
@Override
public Signature deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
- ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();
- JsonNode node = objectMapper.readTree(jsonParser);
-
- String sigValue = node.asText();
- byte[] rawData = NostrUtil.hex128ToBytes(sigValue);
-
Signature signature = new Signature();
- signature.setRawData(rawData);
-
+ signature.setRawData(NostrUtil.hex128ToBytes(jsonParser.getCodec().readTree(jsonParser).asText()));
return signature;
}
}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/deserializer/TagDeserializer.java b/nostr-java-event/src/main/java/nostr/event/json/deserializer/TagDeserializer.java
index 3eb44c106..4953baf83 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/deserializer/TagDeserializer.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/deserializer/TagDeserializer.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import nostr.event.BaseTag;
import nostr.event.json.codec.GenericTagDecoder;
+import nostr.event.tag.AddressTag;
import nostr.event.tag.EventTag;
import nostr.event.tag.GeohashTag;
import nostr.event.tag.HashtagTag;
@@ -17,6 +18,7 @@
import nostr.event.tag.SubjectTag;
import java.io.IOException;
+import nostr.event.tag.VoteTag;
public class TagDeserializer extends JsonDeserializer {
@@ -32,11 +34,13 @@ public T deserialize(JsonParser jsonParser, DeserializationContext deserializati
} else // Perform custom deserialization logic based on the concrete class
{
return switch (code) {
+ case "a" -> AddressTag.deserialize(node);
case "d" -> IdentifierTag.deserialize(node);
case "e" -> EventTag.deserialize(node);
case "g" -> GeohashTag.deserialize(node);
case "p" -> PubKeyTag.deserialize(node);
case "t" -> HashtagTag.deserialize(node);
+ case "v" -> VoteTag.deserialize(node);
case "nonce" -> NonceTag.deserialize(node);
case "price" -> PriceTag.deserialize(node);
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/AbstractTagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/AbstractTagSerializer.java
new file mode 100644
index 000000000..5ac64c450
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/json/serializer/AbstractTagSerializer.java
@@ -0,0 +1,37 @@
+package nostr.event.json.serializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import nostr.event.BaseTag;
+import java.io.IOException;
+import static nostr.event.json.codec.BaseTagEncoder.BASETAG_ENCODER_MAPPED_AFTERBURNER;
+
+abstract class AbstractTagSerializer extends StdSerializer {
+ protected AbstractTagSerializer(Class t) {
+ super(t);
+ }
+
+ public void serialize(T value, JsonGenerator gen, SerializerProvider serializers) {
+ try {
+ final ObjectNode node = BASETAG_ENCODER_MAPPED_AFTERBURNER.getNodeFactory().objectNode();
+ value.getSupportedFields().forEach(f ->
+ value.getFieldValue(f)
+ .ifPresent(s ->
+ node.put(f.getName(), s)));
+
+ applyCustomAttributes(node, value);
+
+ ArrayNode arrayNode = node.objectNode().putArray("values").add(value.getCode());
+ node.fields().forEachRemaining(entry -> arrayNode.add(entry.getValue().asText()));
+ gen.writePOJO(arrayNode);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void applyCustomAttributes(ObjectNode node, T value) {
+ }
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/AddressTagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/AddressTagSerializer.java
index f927c47c8..f8d26b857 100644
--- a/nostr-java-event/src/main/java/nostr/event/json/serializer/AddressTagSerializer.java
+++ b/nostr-java-event/src/main/java/nostr/event/json/serializer/AddressTagSerializer.java
@@ -17,11 +17,10 @@ public class AddressTagSerializer extends JsonSerializer {
public void serialize(AddressTag value, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
jsonGenerator.writeStartArray();
jsonGenerator.writeString("a");
- jsonGenerator.writeString(value.getKind() + ":" + value.getPublicKey().toString() + ":");
-
- if(value.getIdentifierTag() != null) {
- jsonGenerator.writeString(value.getIdentifierTag().getId());
- }
+ jsonGenerator.writeString(
+ value.getKind() + ":" +
+ value.getPublicKey().toString() + ":" +
+ value.getIdentifierTag().getUuid());
if (value.getRelay() != null) {
jsonGenerator.writeString("," + value.getRelay().getUri());
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/BaseTagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/BaseTagSerializer.java
new file mode 100644
index 000000000..f21a86fe1
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/json/serializer/BaseTagSerializer.java
@@ -0,0 +1,14 @@
+package nostr.event.json.serializer;
+
+import nostr.event.BaseTag;
+import java.io.Serial;
+
+public class BaseTagSerializer extends AbstractTagSerializer {
+
+ @Serial
+ private static final long serialVersionUID = -3877972991082754068L;
+
+ public BaseTagSerializer() {
+ super((Class) BaseTag.class);
+ }
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/GenericTagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/GenericTagSerializer.java
new file mode 100644
index 000000000..7a14fb7b9
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/json/serializer/GenericTagSerializer.java
@@ -0,0 +1,20 @@
+package nostr.event.json.serializer;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import nostr.event.tag.GenericTag;
+import java.io.Serial;
+
+public class GenericTagSerializer extends AbstractTagSerializer {
+
+ @Serial
+ private static final long serialVersionUID = -5318614324350049034L;
+
+ public GenericTagSerializer() {
+ super((Class) GenericTag.class);
+ }
+
+ @Override
+ protected void applyCustomAttributes(ObjectNode node, T value) {
+ value.getAttributes().forEach(a -> node.put(a.getName(), a.getValue().toString()));
+ }
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/IdentifierTagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/IdentifierTagSerializer.java
new file mode 100644
index 000000000..b44019d1f
--- /dev/null
+++ b/nostr-java-event/src/main/java/nostr/event/json/serializer/IdentifierTagSerializer.java
@@ -0,0 +1,20 @@
+package nostr.event.json.serializer;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import nostr.event.tag.IdentifierTag;
+
+import java.io.IOException;
+
+public class IdentifierTagSerializer extends JsonSerializer {
+
+ @Override
+ public void serialize(IdentifierTag value, JsonGenerator jsonGenerator, SerializerProvider serializers) throws IOException {
+ jsonGenerator.writeStartArray();
+ jsonGenerator.writeString("d");
+ jsonGenerator.writeString(value.getUuid());
+ jsonGenerator.writeEndArray();
+ }
+
+}
diff --git a/nostr-java-event/src/main/java/nostr/event/json/serializer/TagSerializer.java b/nostr-java-event/src/main/java/nostr/event/json/serializer/TagSerializer.java
deleted file mode 100644
index f3619a65f..000000000
--- a/nostr-java-event/src/main/java/nostr/event/json/serializer/TagSerializer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package nostr.event.json.serializer;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-import nostr.base.ElementAttribute;
-import nostr.event.BaseTag;
-import nostr.event.impl.GenericTag;
-import nostr.util.NostrException;
-
-import java.io.IOException;
-import java.io.Serial;
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static nostr.event.json.codec.BaseTagEncoder.BASETAGENCODER_MAPPED_AFTERBURNER;
-
-/**
- * @author guilhermegps
- *
- */
-public class TagSerializer extends StdSerializer {
-
- @Serial
- private static final long serialVersionUID = -3877972991082754068L;
-
- public TagSerializer() {
- super(BaseTag.class);
- }
-
- @Override
- public void serialize(BaseTag value, JsonGenerator gen, SerializerProvider serializers) {
- try {
- // -- Create the node
- final ObjectNode node = BASETAGENCODER_MAPPED_AFTERBURNER.getNodeFactory().objectNode();
- List fields = value.getSupportedFields();
-
- // Populate the node with the fields data
- fields.forEach((Field f) -> {
- try {
- node.put(f.getName(), value.getFieldValue(f));
- } catch (NostrException ex) {
- throw new RuntimeException(ex);
- }
- });
-
- // Populate the node with the attributes data
- if (value instanceof GenericTag genericTag) {
- List attrs = genericTag.getAttributes();
- attrs.forEach(a -> node.put(a.getName(), a.getValue().toString()));
- }
-
- // Extract the property values from the node and serialize them as an array
- if (node.isObject()) {
- ArrayNode arrayNode = node.objectNode().putArray("values");
-
- // Add the tag code as the first element
- arrayNode.add(value.getCode());
- node.fields().forEachRemaining(entry -> arrayNode.add(entry.getValue().asText()));
-
- gen.writePOJO(arrayNode);
- } else {
- throw new AssertionError("node.isObject()", new RuntimeException());
- }
-
- } catch (IOException | NostrException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
diff --git a/nostr-java-event/src/main/java/nostr/event/message/CanonicalAuthenticationMessage.java b/nostr-java-event/src/main/java/nostr/event/message/CanonicalAuthenticationMessage.java
index c7ea876b5..35ab07166 100644
--- a/nostr-java-event/src/main/java/nostr/event/message/CanonicalAuthenticationMessage.java
+++ b/nostr-java-event/src/main/java/nostr/event/message/CanonicalAuthenticationMessage.java
@@ -12,7 +12,7 @@
import nostr.event.BaseMessage;
import nostr.event.impl.CanonicalAuthenticationEvent;
import nostr.event.impl.GenericEvent;
-import nostr.event.impl.GenericTag;
+import nostr.event.tag.GenericTag;
import nostr.event.json.codec.BaseEventEncoder;
import java.util.List;
diff --git a/nostr-java-event/src/main/java/nostr/event/message/EoseMessage.java b/nostr-java-event/src/main/java/nostr/event/message/EoseMessage.java
index 204f09623..4b78c5275 100644
--- a/nostr-java-event/src/main/java/nostr/event/message/EoseMessage.java
+++ b/nostr-java-event/src/main/java/nostr/event/message/EoseMessage.java
@@ -1,4 +1,3 @@
-
package nostr.event.message;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/nostr-java-event/src/main/java/nostr/event/message/EventMessage.java b/nostr-java-event/src/main/java/nostr/event/message/EventMessage.java
index 0897e9684..3aee54acf 100644
--- a/nostr-java-event/src/main/java/nostr/event/message/EventMessage.java
+++ b/nostr-java-event/src/main/java/nostr/event/message/EventMessage.java
@@ -3,7 +3,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
@@ -13,15 +12,19 @@
import nostr.event.BaseMessage;
import nostr.event.impl.GenericEvent;
import nostr.event.json.codec.BaseEventEncoder;
-
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
-
+import java.util.function.Function;
import static nostr.base.Encoder.ENCODER_MAPPED_AFTERBURNER;
+import static nostr.base.IDecoder.I_DECODER_MAPPER_AFTERBURNER;
@Setter
@Getter
public class EventMessage extends BaseMessage {
+ private static final int SIZE_JSON_EVENT_wo_SIG_ID = 2;
+ private static final Function