From f462622e0254f41afe7837720aa50e11ba1b30f1 Mon Sep 17 00:00:00 2001 From: Robin Bryce Date: Sun, 9 Jun 2024 17:31:25 +0100 Subject: [PATCH] fix: support leaf hash direct from V3Event type AB#9587 --- simplehash/schemav3.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/simplehash/schemav3.go b/simplehash/schemav3.go index 5f568be..5fe2543 100644 --- a/simplehash/schemav3.go +++ b/simplehash/schemav3.go @@ -167,3 +167,20 @@ func (h *HasherV3) HashEventFromJSON(eventJson []byte, opts ...HashOption) error return V3HashEvent(h.hasher, v3Event) } + +// HashEventFromV3 hashes a single event according to the canonical simple hash event +// format available to api consumers. The source event a pre decoded V3Event type +// Options: same as HashEventFromJSON +func (h *HasherV3) HashEventFromV3(v3Event V3Event, opts ...HashOption) error { + + o := HashOptions{} + for _, opt := range opts { + opt(&o) + } + + h.applyEventOptions(o, &v3Event) + + h.applyHashingOptions(o) + + return V3HashEvent(h.hasher, v3Event) +}