sarafu-vise/handlers/event/event.go

36 lines
968 B
Go
Raw Normal View History

2025-01-13 18:26:27 +01:00
package event
import (
2025-01-13 18:47:55 +01:00
"fmt"
"git.defalsify.org/vise.git/persist"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
2025-01-13 18:26:27 +01:00
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
2025-01-13 18:26:27 +01:00
)
type EventsUpdater struct {
2025-01-13 18:26:27 +01:00
api remote.AccountService
formatFunc func(string, int, any) string
store *store.UserDataStore
pe *persist.Persister
2025-01-13 18:26:27 +01:00
}
func NewEventsUpdater(api remote.AccountService, store *store.UserDataStore, pe *persist.Persister) *EventsUpdater {
return &EventsUpdater{
2025-01-13 18:26:27 +01:00
api: api,
2025-01-13 18:47:55 +01:00
formatFunc: func(tag string, i int, o any) string {
return fmt.Sprintf("%d %v", i, o)
},
store: store,
pe: pe,
2025-01-13 18:26:27 +01:00
}
}
func (eu *EventsUpdater) ToEventsHandler() *apievent.EventsHandler {
eh := apievent.NewEventsHandler()
eh = eh.WithHandler(apievent.EventTokenTransferTag, eu.handleTokenTransfer)
eh = eh.WithHandler(apievent.EventRegistrationTag, eu.handleCustodialRegistration)
return eh
}