NostrEvent.fromPartialData constructor

NostrEvent.fromPartialData({
  1. required int kind,
  2. required String content,
  3. required NostrKeyPairs keyPairs,
  4. List<List<String>>? tags,
  5. DateTime? createdAt,
  6. String? ots,
})

Creates a new NostrEvent with less fields and lower complexity. it requires only to set the fields which can be used

Implementation

factory NostrEvent.fromPartialData({
  required int kind,
  required String content,
  required NostrKeyPairs keyPairs,
  List<List<String>>? tags,
  DateTime? createdAt,
  String? ots,
}) {
  final pubkey = keyPairs.public;
  final tagsToUse = tags ?? [];
  final createdAtToUse = createdAt ?? DateTime.now();

  final id = getEventId(
    kind: kind,
    content: content,
    createdAt: createdAtToUse,
    tags: tagsToUse,
    pubkey: pubkey,
  );

  final sig = keyPairs.sign(id);

  return NostrEvent(
    id: id,
    kind: kind,
    content: content,
    sig: sig,
    pubkey: pubkey,
    createdAt: createdAtToUse,
    tags: tagsToUse,
    ots: ots,
  );
}