Skip to content

Commit

Permalink
Merge pull request #12 from ethicnology/develop
Browse files Browse the repository at this point in the history
fix: Inconsitency in events is breaking tags #8
  • Loading branch information
ethicnology authored Jan 27, 2023
2 parents edc719d + d538ddf commit 792433c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
- add Close (+ unit tests)
- add Message wrapper deserializer (+ unit tests)
- Documentation

## 1.3.1

- fix: Inconsitency in events is breaking tags
8 changes: 6 additions & 2 deletions lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class Event {
pubkey = json['pubkey'];
createdAt = json['created_at'];
kind = json['kind'];
tags = json['tags'].cast<List<String>>();
tags = (json['tags'] as List<dynamic>)
.map((e) => (e as List<dynamic>).map((e) => e as String).toList())
.toList();
content = json['content'];
sig = json['sig'];
}
Expand Down Expand Up @@ -131,7 +133,9 @@ class Event {
pubkey = json['pubkey'];
createdAt = json['created_at'];
kind = json['kind'];
tags = json['tags'].cast<List<String>>();
tags = (json['tags'] as List<dynamic>)
.map((e) => (e as List<dynamic>).map((e) => e as String).toList())
.toList();
content = json['content'];
sig = json['sig'];
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nostr
description: A library for nostr protocol implemented in dart for flutter
version: 1.3.0
version: 1.3.1
homepage: https://github.com/ethicnology/dart-nostr

environment:
Expand Down
6 changes: 6 additions & 0 deletions test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,10 @@ void main() {
Event.deserialize(serializeWithoutSubscriptionId);
expect(eventWithoutSubscriptionId.subscriptionId, null);
});

test('Generated from decoded json', () {
Event event = Event.fromJson(jsonDecode(
'{"kind": 1, "pubkey":"0ba0206887bd61579bf65ec09d7806bea32c64be1cf2c978cf031a811cd238db","content": "dart-nostr","tags": [["p","052acd328f1c1d48e86fff3e34ada4bfc60578116f4f68f296602530529656a2",""]],"created_at": 1672477962,"sig":"246970954e7b74e7fe381a4c818fed739ee59444cb536dadf45fbbce33bd7455ae7cd678c347c4a0c6e0a4483d18c7e26b7abe76f4cc73234f774e0e0d65204b","id": "047663d895d56aefa3f528935c7ce7dc8939eb721a0ec76ef2e558a8257955d2"}'));
expect(event.tags[0][2], equals(""));
});
}

0 comments on commit 792433c

Please sign in to comment.