2025-01-13 18:26:27 +01:00
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
2025-01-13 18:47:55 +01:00
|
|
|
"fmt"
|
|
|
|
|
2025-01-13 21:19:34 +01:00
|
|
|
"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"
|
2025-01-13 21:19:34 +01:00
|
|
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
2025-01-13 18:26:27 +01:00
|
|
|
)
|
|
|
|
|
2025-01-13 21:19:34 +01:00
|
|
|
type EventsUpdater struct {
|
2025-01-13 18:26:27 +01:00
|
|
|
api remote.AccountService
|
|
|
|
formatFunc func(string, int, any) string
|
2025-01-13 21:19:34 +01:00
|
|
|
store *store.UserDataStore
|
|
|
|
pe *persist.Persister
|
2025-01-13 18:26:27 +01:00
|
|
|
}
|
|
|
|
|
2025-01-13 21:19:34 +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)
|
|
|
|
},
|
2025-01-13 21:19:34 +01:00
|
|
|
store: store,
|
|
|
|
pe: pe,
|
2025-01-13 18:26:27 +01:00
|
|
|
}
|
|
|
|
}
|
2025-01-13 21:19:34 +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
|
|
|
|
}
|