Documentation ¶
Index ¶
- Constants
- Variables
- func ReclaimPersona(ctx context.Context, nk runtime.NakamaModule, txSigner signer.Signer, ...) error
- type StorageObj
- func ClaimPersona(ctx context.Context, nk runtime.NakamaModule, verifier *Verifier, ...) (res *StorageObj, err error)
- func LoadPersonaTagStorageObj(ctx context.Context, nk runtime.NakamaModule) (*StorageObj, error)
- func ShowPersona(ctx context.Context, nk runtime.NakamaModule, txSigner signer.Signer, ...) (res *StorageObj, err error)
- func StorageObjToPersonaTagStorageObj(obj *api.StorageObject) (*StorageObj, error)
- type TxResponse
- type Verifier
Constants ¶
const ( StatusPending personaTagStatus = "pending" StatusAccepted personaTagStatus = "accepted" StatusRejected personaTagStatus = "rejected" PersonaTagKey = "persona_tag" CardinalCollection = "cardinal_collection" )
Variables ¶
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 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 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.