Skip to content

Commit 41cdc37

Browse files
committed
fix: enforce string nip metadata
1 parent 8857498 commit 41cdc37

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

nostr-java-api/src/test/java/nostr/api/unit/JsonParseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public void testClassifiedListingTagSerializer() throws JsonProcessingException
304304

305305
GenericEvent event = new GenericEventDecoder<>().decode(classifiedListingEventJson);
306306
EventMessage message = NIP01.createEventMessage(event, "1");
307-
assertEquals(1, message.getNip());
307+
assertEquals("1", message.getNip());
308308
String encoded = new BaseEventEncoder<>((BaseEvent) message.getEvent()).encode();
309309
assertEquals(
310310
"{\"id\":\"28f2fc030e335d061f0b9d03ce0e2c7d1253e6fadb15d89bd47379a96b2c861a\",\"kind\":30402,\"content\":\"content"

nostr-java-base/src/main/java/nostr/base/IElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public interface IElement {
77

8-
default Integer getNip() {
9-
return 1;
8+
default String getNip() {
9+
return "1";
1010
}
1111
}

nostr-java-event/src/main/java/nostr/event/impl/GenericEvent.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public class GenericEvent extends BaseEvent implements ISignable, Deleteable {
135135

136136
@JsonIgnore @EqualsAndHashCode.Exclude private byte[] _serializedEvent;
137137

138-
@JsonIgnore @EqualsAndHashCode.Exclude private Integer nip;
138+
@JsonIgnore @EqualsAndHashCode.Exclude private String nip;
139139

140140
public GenericEvent() {
141141
this.tags = new ArrayList<>();
@@ -322,7 +322,7 @@ public static class GenericEventBuilder {
322322
private String content = "";
323323
private Long createdAt;
324324
private Signature signature;
325-
private Integer nip;
325+
private String nip;
326326

327327
public GenericEventBuilder id(String id) { this.id = id; return this; }
328328
public GenericEventBuilder pubKey(PublicKey pubKey) { this.pubKey = pubKey; return this; }
@@ -332,7 +332,7 @@ public static class GenericEventBuilder {
332332
public GenericEventBuilder content(String content) { this.content = content; return this; }
333333
public GenericEventBuilder createdAt(Long createdAt) { this.createdAt = createdAt; return this; }
334334
public GenericEventBuilder signature(Signature signature) { this.signature = signature; return this; }
335-
public GenericEventBuilder nip(Integer nip) { this.nip = nip; return this; }
335+
public GenericEventBuilder nip(String nip) { this.nip = nip; return this; }
336336

337337
public GenericEvent build() {
338338
GenericEvent event = new GenericEvent();
@@ -498,11 +498,11 @@ protected void addStandardTag(BaseTag tag) {
498498
Optional.ofNullable(tag).ifPresent(this::addTag);
499499
}
500500

501-
protected void addGenericTag(String key, Integer nip, Object value) {
501+
protected void addGenericTag(String key, String nip, Object value) {
502502
Optional.ofNullable(value).ifPresent(s -> addTag(BaseTag.create(key, s.toString())));
503503
}
504504

505-
protected void addStringListTag(String label, Integer nip, List<String> tag) {
505+
protected void addStringListTag(String label, String nip, List<String> tag) {
506506
Optional.ofNullable(tag).ifPresent(tagList -> BaseTag.create(label, tagList));
507507
}
508508

nostr-java-event/src/main/java/nostr/event/message/BaseAuthMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public BaseAuthMessage(String command) {
1212
}
1313

1414
@Override
15-
public Integer getNip() {
16-
return 42;
15+
public String getNip() {
16+
return "42";
1717
}
1818
}

0 commit comments

Comments
 (0)