keeper

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestMembershipType = "green"
View Source
var TestSignerAddress, _ = sdk.AccAddressFromBech32("cosmos1lwmppctrr6ssnrmuyzu554dzf50apkfvd53jx0")

Test variables

View Source
var TestUserAddress, _ = sdk.AccAddressFromBech32("cosmos1lwmppctrr6ssnrmuyzu554dzf50apkfvd53jx0")

Functions

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

Types

type Keeper

type Keeper struct {
	StoreKey sdk.StoreKey

	// NFT keeper to mint tokens
	NftKeeper nft.Keeper

	// Pointer to the codec that is used by Amino to encode and decode binary structs.
	Cdc *codec.Codec
}

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, nftKeeper nft.Keeper) Keeper

NewKeeper creates new instances of the membership module Keeper

func SetupTestInput

func SetupTestInput() (cdc *codec.Codec, ctx sdk.Context, keeper Keeper)

This function create an environment to test modules

func (Keeper) AddTrustedMinter

func (keeper Keeper) AddTrustedMinter(ctx sdk.Context, minter sdk.AccAddress)

AddTrustedMinter allows to add the given minter as a trusted address that can sign the minting of new memberships tokens

func (Keeper) AssignMembership

func (keeper Keeper) AssignMembership(ctx sdk.Context, user sdk.AccAddress, membershipType string) (string, error)

AssignMembership allow to mint and assign a membership of the given membershipType to the specified user. If the user already has a membership assigned, deletes the current one and assigns to it the new one. Returns the URI of the new minted token represented the assigned membership, or an error if something goes wrong

func (Keeper) GetMembership

func (keeper Keeper) GetMembership(ctx sdk.Context, user sdk.AccAddress) (exported.NFT, bool)

GetMembership allows to retrieve any existent membership for the specified user. The second returned false (the boolean one) tells if the NFT token representing the membership was found or not

func (Keeper) GetMembershipType

func (keeper Keeper) GetMembershipType(membership exported.NFT) string

GetMembershipType returns the type of the membership represented by the given NFT token

func (Keeper) GetMembershipsSet

func (keeper Keeper) GetMembershipsSet(ctx sdk.Context) []types.Membership

Get GetMembershipsSet returns the list of all the memberships that have been minted and are currently stored inside the store

func (Keeper) GetTrustedMinters

func (keeper Keeper) GetTrustedMinters(ctx sdk.Context) types.Minters

GetTrustedMinters returns the list of the current addresses that are allowed to mint a new membership token when necessary

func (Keeper) RemoveMembership

func (keeper Keeper) RemoveMembership(ctx sdk.Context, user sdk.AccAddress) (bool, error)

RemoveMembership allows to remove any existing membership associated with the given user.

type MembershipResult

type MembershipResult struct {
	User           sdk.AccAddress `json:"user"`
	MembershipType string         `json:"membership_type"`
}

MembershipResult represents the data returned when a search is performed to know the membership of a given user

Jump to

Keyboard shortcuts

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