Add event support for token mint

This commit is contained in:
lash 2025-01-14 07:02:42 +00:00
parent f67edfb541
commit ce9a263b40
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 9 additions and 2 deletions

View File

@ -34,9 +34,9 @@ func NewEventsUpdater(api remote.AccountService, store storage.StorageService) *
func (eu *EventsUpdater) ToEventsHandler() *apievent.EventsHandler { func (eu *EventsUpdater) ToEventsHandler() *apievent.EventsHandler {
eh := apievent.NewEventsHandler() eh := apievent.NewEventsHandler()
eh = eh.WithHandler(apievent.EventTokenMintTag, eu.handleTokenMint)
eh = eh.WithHandler(apievent.EventTokenTransferTag, eu.handleTokenTransfer) eh = eh.WithHandler(apievent.EventTokenTransferTag, eu.handleTokenTransfer)
eh = eh.WithHandler(apievent.EventRegistrationTag, eu.handleCustodialRegistration) eh = eh.WithHandler(apievent.EventRegistrationTag, eu.handleCustodialRegistration)
eh = eh.WithHandler(apievent.EventTokenMintTag, eu.handleNoop)
return eh return eh
} }

View File

@ -66,7 +66,7 @@ func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identi
func (eh *EventsUpdater) handleTokenTransfer(ctx context.Context, ev any) error { func (eh *EventsUpdater) handleTokenTransfer(ctx context.Context, ev any) error {
o, ok := ev.(*apievent.EventTokenTransfer) o, ok := ev.(*apievent.EventTokenTransfer)
if !ok { if !ok {
fmt.Errorf("invalid event for custodial registration") fmt.Errorf("invalid event for token transfer")
} }
return eh.HandleTokenTransfer(ctx, o) return eh.HandleTokenTransfer(ctx, o)
} }
@ -105,6 +105,13 @@ func (eu *EventsUpdater) HandleTokenTransfer(ctx context.Context, ev *apievent.E
} }
// handle token mint. // 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 { func (eu *EventsUpdater) HandleTokenMint(ctx context.Context, ev *apievent.EventTokenMint) error {
_, userStore, err := eu.getStore(ctx) _, userStore, err := eu.getStore(ctx)
if err != nil { if err != nil {