sarafu-vise/handlers/event/custodial.go

48 lines
1.3 KiB
Go
Raw Normal View History

2025-01-13 18:26:27 +01:00
package event
import (
"context"
"fmt"
2025-01-13 18:26:27 +01:00
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
)
const (
// TODO: consolidate with loaded flags
accountCreatedFlag = 9
)
// handle custodial registration.
//
// TODO: implement account created in userstore instead, so that
// the need for persister and state use here is eliminated (it
// introduces concurrency risks)
func (eh *EventsUpdater) handleCustodialRegistration(ctx context.Context, ev any) error {
o, ok := ev.(*apievent.EventCustodialRegistration)
if !ok {
return fmt.Errorf("invalid event for custodial registration")
}
return eh.HandleCustodialRegistration(ctx, o)
}
2025-01-13 22:39:15 +01:00
func (eu *EventsUpdater) HandleCustodialRegistration(ctx context.Context, ev *apievent.EventCustodialRegistration) error {
_, userStore, err := eu.getStore(ctx)
2025-01-13 18:26:27 +01:00
if err != nil {
return err
}
2025-01-13 22:39:15 +01:00
identity, err := store.IdentityFromAddress(ctx, userStore, ev.Account)
2025-01-13 18:26:27 +01:00
if err != nil {
return err
}
// err = pe.Load(identity.SessionId)
// if err != nil {
// return err
// }
// st := pe.GetState()
// st.SetFlag(accountCreatedFlag)
// return pe.Save(identity.SessionId)
logg.DebugCtxf(ctx, "received custodial registration event", "identity", identity)
return nil
2025-01-13 18:26:27 +01:00
}