term/event/custodial_registration.go

43 lines
880 B
Go
Raw Normal View History

2024-10-24 17:00:46 +02:00
package event
import (
"context"
2024-10-24 17:00:46 +02:00
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
"git.grassecon.net/urdt/ussd/common"
"git.grassecon.net/term/lookup"
2024-10-24 17:00:46 +02:00
)
const (
evReg = "CUSTODIAL_REGISTRATION"
)
type eventCustodialRegistration struct {
Account string
2024-10-24 17:00:46 +02:00
}
func asCustodialRegistrationEvent(gev *geEvent.Event) (*eventCustodialRegistration, bool) {
var ok bool
var ev eventCustodialRegistration
if gev.TxType != evReg {
return nil, false
}
pl := gev.Payload
ev.Account, ok = pl["account"].(string)
2024-10-24 17:00:46 +02:00
if !ok {
return nil, false
}
2024-10-24 17:17:04 +02:00
logg.Debug("parsed ev", "pl", pl, "ev", ev)
2024-10-24 17:00:46 +02:00
return &ev, true
}
func handleCustodialRegistration(ctx context.Context, store common.UserDataStore, ev *eventCustodialRegistration) error {
identity, err := lookup.IdentityFromAddress(ctx, store, ev.Account)
if err != nil {
return err
}
_ = identity
2024-10-24 17:00:46 +02:00
return nil
}