persona

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending      personaTagStatus = "pending"
	StatusAccepted     personaTagStatus = "accepted"
	StatusRejected     personaTagStatus = "rejected"
	PersonaTagKey                       = "persona_tag"
	CardinalCollection                  = "cardinal_collection"
)

Variables

View Source
var (
	ErrPersonaTagStorageObjNotFound = errors.New("persona tag storage object not found")
	ErrNoPersonaTagForUser          = errors.New("user does not have a verified persona tag")
	ErrPersonaSignerAvailable       = errors.New("persona signer is available")
	ErrPersonaSignerUnknown         = errors.New("persona signer is unknown")
	ErrPersonaTagEmpty              = errors.New("personaTag field was left empty")
)

Functions

func ReclaimPersona added in v1.2.3

func ReclaimPersona(
	ctx context.Context,
	nk runtime.NakamaModule,
	txSigner signer.Signer,
	cardinalAddress string,
	namespace string,
) error

ReclaimPersona attempts to claim a persona tag that has already been verified with Nakama. This is useful when Cardinal's state is reset and loses all record of previously claimed persona tags. This method is different from the initial ClaimPersona because all the bookkeeping on Nakama's side can be skipped.

Types

type StorageObj

type StorageObj struct {
	PersonaTag string           `json:"personaTag"`
	Status     personaTagStatus `json:"status"`
	Tick       uint64           `json:"tick"`
	TxHash     string           `json:"txHash"`
	// contains filtered or unexported fields
}

StorageObj contains persona tag information for a specific user, and keeps track of whether the persona tag has been successfully registered with cardinal.

func ClaimPersona

func ClaimPersona(
	ctx context.Context,
	nk runtime.NakamaModule,
	verifier *Verifier,
	notifier *events.Notifier,
	personaStorageObj *StorageObj,
	txSigner signer.Signer,
	globalCardinalAddress string,
	globalNamespace string,
	globalPersonaTagAssignment *sync.Map,
) (res *StorageObj, err error)

func LoadPersonaTagStorageObj

func LoadPersonaTagStorageObj(ctx context.Context, nk runtime.NakamaModule) (*StorageObj, error)

LoadPersonaTagStorageObj loads the current user's persona tag storage object from Nakama's storage layer. The "current user" comes from the user ID stored in the given context.

func ShowPersona

func ShowPersona(
	ctx context.Context,
	nk runtime.NakamaModule,
	txSigner signer.Signer,
	globalCardinalAddress string,
) (res *StorageObj, err error)

func StorageObjToPersonaTagStorageObj

func StorageObjToPersonaTagStorageObj(obj *api.StorageObject) (*StorageObj, error)

StorageObjToPersonaTagStorageObj converts a generic Nakama StorageObject to a locally defined StorageObj.

func (*StorageObj) AttemptToUpdatePending

func (p *StorageObj) AttemptToUpdatePending(
	ctx context.Context,
	nk runtime.NakamaModule,
	txSigner signer.Signer,
	cardinalAddr string,
) (*StorageObj, error)

AttemptToUpdatePending attempts to change the given StorageObj's Status from "pending" to either "accepted" or "rejected" by using cardinal as the source of truth. If the Status is not "pending", this call is a no-op.

func (*StorageObj) SavePersonaTagStorageObj

func (p *StorageObj) SavePersonaTagStorageObj(ctx context.Context, nk runtime.NakamaModule) error

SavePersonaTagStorageObj saves the given StorageObj to the Nakama DB for the current user.

func (*StorageObj) ToJSON

func (p *StorageObj) ToJSON() (string, error)

type TxResponse

type TxResponse struct {
	TxHash string `json:"txHash"`
	Tick   uint64 `json:"tick"`
}

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier is a helper struct that asynchronously collects both persona tag registration requests (from nakama) AND persona tag transaction receipts from cardinal. When the result of both systems has been recorded, this struct attempts to update the user's StorageObj to reflect the success/failure of the claim persona tag request.

func NewVerifier

func NewVerifier(
	logger runtime.Logger, nk runtime.NakamaModule, eh *events.EventHub,
) *Verifier

func (*Verifier) AddPendingPersonaTag

func (p *Verifier) AddPendingPersonaTag(userID, txHash string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL