From ce9a263b40a3f7f5932bbbd65ae56b26020e7f7c Mon Sep 17 00:00:00 2001 From: lash Date: Tue, 14 Jan 2025 07:02:42 +0000 Subject: [PATCH] Add event support for token mint --- handlers/event/event.go | 2 +- handlers/event/token.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/handlers/event/event.go b/handlers/event/event.go index d75b5a2..bacda01 100644 --- a/handlers/event/event.go +++ b/handlers/event/event.go @@ -34,9 +34,9 @@ func NewEventsUpdater(api remote.AccountService, store storage.StorageService) * func (eu *EventsUpdater) ToEventsHandler() *apievent.EventsHandler { eh := apievent.NewEventsHandler() + eh = eh.WithHandler(apievent.EventTokenMintTag, eu.handleTokenMint) eh = eh.WithHandler(apievent.EventTokenTransferTag, eu.handleTokenTransfer) eh = eh.WithHandler(apievent.EventRegistrationTag, eu.handleCustodialRegistration) - eh = eh.WithHandler(apievent.EventTokenMintTag, eu.handleNoop) return eh } diff --git a/handlers/event/token.go b/handlers/event/token.go index 8758108..ef85800 100644 --- a/handlers/event/token.go +++ b/handlers/event/token.go @@ -66,7 +66,7 @@ func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identi func (eh *EventsUpdater) handleTokenTransfer(ctx context.Context, ev any) error { o, ok := ev.(*apievent.EventTokenTransfer) if !ok { - fmt.Errorf("invalid event for custodial registration") + fmt.Errorf("invalid event for token transfer") } return eh.HandleTokenTransfer(ctx, o) } @@ -105,6 +105,13 @@ func (eu *EventsUpdater) HandleTokenTransfer(ctx context.Context, ev *apievent.E } // handle token mint. +func (eh *EventsUpdater) handleTokenMint(ctx context.Context, ev any) error { + o, ok := ev.(*apievent.EventTokenMint) + if !ok { + fmt.Errorf("invalid event for token mint") + } + return eh.HandleTokenMint(ctx, o) +} func (eu *EventsUpdater) HandleTokenMint(ctx context.Context, ev *apievent.EventTokenMint) error { _, userStore, err := eu.getStore(ctx) if err != nil {