nip60: fix a bunch of stupid bugs.

This commit is contained in:
fiatjaf
2025-02-04 10:25:13 -03:00
parent 3c0f4a723a
commit e7432baeba
3 changed files with 26 additions and 49 deletions

View File

@@ -80,6 +80,7 @@ func (h HistoryEntry) toEvent(ctx context.Context, kr nostr.Keyer, evt *nostr.Ev
func (h *HistoryEntry) parse(ctx context.Context, kr nostr.Keyer, evt *nostr.Event) error {
h.event = evt
h.createdAt = evt.CreatedAt
h.TokenReferences = make([]TokenRef, 0, 3)
pk, err := kr.GetPublicKey(ctx)
if err != nil {
@@ -132,10 +133,7 @@ func (h *HistoryEntry) parse(ctx context.Context, kr nostr.Keyer, evt *nostr.Eve
return fmt.Errorf("'e' tag has invalid event id %s", tag[1])
}
h.TokenReferences = append(h.TokenReferences)
tf := TokenRef{EventID: tag[1]}
switch tag[3] {
case "created":
tf.Created = true
@@ -143,9 +141,11 @@ func (h *HistoryEntry) parse(ctx context.Context, kr nostr.Keyer, evt *nostr.Eve
tf.Created = false
case "redeemed":
tf.IsNutzap = true
tf.Created = true
default:
return fmt.Errorf("unsupported 'e' token marker: %s", tag[3])
}
h.TokenReferences = append(h.TokenReferences, tf)
}
}