keeper

package
v0.39.2-0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

nolint:unparam

Index

Constants

This section is empty.

Variables

View Source
var (
	ApprovedValue = []byte{0x01}
)
View Source
var ChildExists = []byte{1}

Functions

This section is empty.

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)
	GetOrNewAccount(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)
	SetAccount(ctx sdk.Context, acc types.Account) error
	UpdateAccount(ctx sdk.Context, acc types.Account) error
	GetBalance(ctx sdk.Context, tokenID string, addr sdk.AccAddress) (sdk.Int, error)
}

type BankKeeper

type BankKeeper interface {
	GetCoins(ctx sdk.Context, addr sdk.AccAddress) types.Coins
	HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) bool
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt types.Coins) error
	SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) (types.Coins, error)
	AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) (types.Coins, error)
	SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) error
}

For the Token module

type BurnKeeper

type BurnKeeper interface {
	BurnFT(ctx sdk.Context, from sdk.AccAddress, amount types.Coins) error
	BurnNFT(ctx sdk.Context, from sdk.AccAddress, tokenIDs ...string) error
	BurnFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, amount types.Coins) error
	BurnNFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, tokenIDs ...string) error
}

type CollectionKeeper

type CollectionKeeper interface {
	CreateCollection(ctx sdk.Context, collection types.Collection, owner sdk.AccAddress) error
	ExistCollection(ctx sdk.Context) bool
	GetCollection(ctx sdk.Context) (collection types.Collection, err error)
	SetCollection(ctx sdk.Context, collection types.Collection) error
	UpdateCollection(ctx sdk.Context, collection types.Collection) error
}

type ComposeKeeper

type ComposeKeeper interface {
	Attach(ctx sdk.Context, from sdk.AccAddress, toTokenID string, tokenID string) error
	AttachFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, toTokenID string, tokenID string) error
	Detach(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, tokenID string) error
	DetachFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, to sdk.AccAddress, tokenID string) error
	RootOf(ctx sdk.Context, tokenID string) (types.NFT, error)
	ParentOf(ctx sdk.Context, tokenID string) (types.NFT, error)
	ChildrenOf(ctx sdk.Context, tokenID string) (types.Tokens, error)
}

type IssueKeeper

type IssueKeeper interface {
	IssueFT(ctx sdk.Context, owner sdk.AccAddress, token types.FT, amount sdk.Int) error
	IssueNFT(ctx sdk.Context, owner sdk.AccAddress, tokenType string) error
}

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc *codec.Codec,
	accountKeeper types.AccountKeeper,
	contractKeeper contract.Keeper,
	paramsSpace subspace.Subspace,
	storeKey sdk.StoreKey,
) Keeper

func TestKeeper

func TestKeeper() (sdk.Context, store.CommitMultiStore, Keeper)

func (Keeper) AddCoins

func (k Keeper) AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) (types.Coins, error)

func (Keeper) AddNFTOwner

func (k Keeper) AddNFTOwner(ctx sdk.Context, addr sdk.AccAddress, tokenID string)

func (Keeper) AddPermission

func (k Keeper) AddPermission(ctx sdk.Context, addr sdk.AccAddress, perm types.Permission)

func (Keeper) Attach

func (k Keeper) Attach(ctx sdk.Context, from sdk.AccAddress, toTokenID string, tokenID string) error

func (Keeper) AttachFrom

func (k Keeper) AttachFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, toTokenID string, tokenID string) error

func (Keeper) BurnFT

func (k Keeper) BurnFT(ctx sdk.Context, from sdk.AccAddress, amount types.Coins) error

func (Keeper) BurnFTFrom

func (k Keeper) BurnFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, amount types.Coins) error

func (Keeper) BurnNFT

func (k Keeper) BurnNFT(ctx sdk.Context, from sdk.AccAddress, tokenIDs ...string) error

func (Keeper) BurnNFTFrom

func (k Keeper) BurnNFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, tokenIDs ...string) error

func (Keeper) BurnSupply

func (k Keeper) BurnSupply(ctx sdk.Context, from sdk.AccAddress, amt types.Coins) (err error)

BurnCoins burns coins deletes coins from the balance of the module account. Panics if the name maps to a non-burner module account or if the amount is invalid.

func (Keeper) ChangeNFTOwner

func (k Keeper) ChangeNFTOwner(ctx sdk.Context, from, to sdk.AccAddress, tokenID string) error

func (Keeper) ChildrenOf

func (k Keeper) ChildrenOf(ctx sdk.Context, tokenID string) (types.Tokens, error)

func (Keeper) CreateCollection

func (k Keeper) CreateCollection(ctx sdk.Context, collection types.Collection, owner sdk.AccAddress) error

func (Keeper) DeleteApproved

func (k Keeper) DeleteApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) error

func (Keeper) DeleteNFTOwner

func (k Keeper) DeleteNFTOwner(ctx sdk.Context, addr sdk.AccAddress, tokenID string)

func (Keeper) DeleteToken

func (k Keeper) DeleteToken(ctx sdk.Context, tokenID string) error

func (Keeper) Detach

func (k Keeper) Detach(ctx sdk.Context, from sdk.AccAddress, tokenID string) error

func (Keeper) DetachFrom

func (k Keeper) DetachFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, tokenID string) error

nolint:dupl

func (Keeper) ExistCollection

func (k Keeper) ExistCollection(ctx sdk.Context) bool

func (Keeper) GetAccount

func (k Keeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)

func (Keeper) GetAllCollections

func (k Keeper) GetAllCollections(ctx sdk.Context) types.Collections

func (Keeper) GetApprovers

func (k Keeper) GetApprovers(ctx sdk.Context, proxy sdk.AccAddress) (accAds []sdk.AccAddress, err error)

func (Keeper) GetBalance

func (k Keeper) GetBalance(ctx sdk.Context, tokenID string, addr sdk.AccAddress) (sdk.Int, error)

func (Keeper) GetCoins

func (k Keeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) types.Coins

func (Keeper) GetCollection

func (k Keeper) GetCollection(ctx sdk.Context) (collection types.Collection, err error)

func (Keeper) GetDepthFromRoot

func (k Keeper) GetDepthFromRoot(ctx sdk.Context, tokenID string) int

func (Keeper) GetDepthWidthTable

func (k Keeper) GetDepthWidthTable(ctx sdk.Context, tokenID string) []int

Gets the depth-width(count) table (array)

lv0(1) lv1(2) lv2(3) lv3(2) lv4(1) token1 -+- token2 --- token4 --- token7

+- token3 -+- token5 --- token8 --- token9
           +- token6

then returns [1, 2, 3, 2, 1] and len([1, 2, 3, 2, 1]) - 1 represents the depth of token1's children

func (Keeper) GetFT

func (k Keeper) GetFT(ctx sdk.Context, tokenID string) (types.FT, error)

func (Keeper) GetFTs

func (k Keeper) GetFTs(ctx sdk.Context) (tokens types.Tokens, err error)

func (Keeper) GetNFT

func (k Keeper) GetNFT(ctx sdk.Context, tokenID string) (types.NFT, error)

func (Keeper) GetNFTCount

func (k Keeper) GetNFTCount(ctx sdk.Context, tokenType string) (sdk.Int, error)

func (Keeper) GetNFTCountInt

func (k Keeper) GetNFTCountInt(ctx sdk.Context, tokenType, target string) (sdk.Int, error)

func (Keeper) GetNFTs

func (k Keeper) GetNFTs(ctx sdk.Context, tokenType string) (tokens types.Tokens, err error)

func (Keeper) GetNFTsOwner

func (k Keeper) GetNFTsOwner(ctx sdk.Context, addr sdk.AccAddress) (tokenIDs []string)

func (Keeper) GetNextTokenIDFT

func (k Keeper) GetNextTokenIDFT(ctx sdk.Context) (string, error)

func (Keeper) GetNextTokenIDNFT

func (k Keeper) GetNextTokenIDNFT(ctx sdk.Context, tokenType string) (string, error)

func (Keeper) GetNextTokenType

func (k Keeper) GetNextTokenType(ctx sdk.Context) (tokenType string, err error)

func (Keeper) GetOrNewAccount

func (k Keeper) GetOrNewAccount(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

func (Keeper) GetPermissions

func (k Keeper) GetPermissions(ctx sdk.Context, addr sdk.AccAddress) types.Permissions

func (Keeper) GetSupply

func (k Keeper) GetSupply(ctx sdk.Context) (supply types.Supply)

func (Keeper) GetToken

func (k Keeper) GetToken(ctx sdk.Context, tokenID string) (types.Token, error)

func (Keeper) GetTokenType

func (k Keeper) GetTokenType(ctx sdk.Context, tokenTypeID string) (types.TokenType, error)

func (Keeper) GetTokenTypes

func (k Keeper) GetTokenTypes(ctx sdk.Context) (tokenTypes types.TokenTypes, err error)

func (Keeper) GetTokens

func (k Keeper) GetTokens(ctx sdk.Context) (tokens types.Tokens, err error)

func (Keeper) GetTotalInt

func (k Keeper) GetTotalInt(ctx sdk.Context, tokenID, target string) (supply sdk.Int, err error)

func (Keeper) GrantPermission

func (k Keeper) GrantPermission(ctx sdk.Context, from, to sdk.AccAddress, perm types.Permission) error

func (Keeper) HasCoins

func (k Keeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) bool

func (Keeper) HasContractID

func (k Keeper) HasContractID(ctx sdk.Context) bool

func (Keeper) HasNFTOwner

func (k Keeper) HasNFTOwner(ctx sdk.Context, addr sdk.AccAddress, tokenID string) bool

func (Keeper) HasPermission

func (k Keeper) HasPermission(ctx sdk.Context, addr sdk.AccAddress, p types.Permission) bool

func (Keeper) HasToken

func (k Keeper) HasToken(ctx sdk.Context, tokenID string) bool

func (Keeper) HasTokenType

func (k Keeper) HasTokenType(ctx sdk.Context, tokenType string) bool

func (Keeper) IsApproved

func (k Keeper) IsApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) bool

func (Keeper) IssueFT

func (k Keeper) IssueFT(ctx sdk.Context, owner, to sdk.AccAddress, token types.FT, amount sdk.Int) error

func (Keeper) IssueNFT

func (k Keeper) IssueNFT(ctx sdk.Context, tokenType types.TokenType, owner sdk.AccAddress) error

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) MarshalJSON

func (k Keeper) MarshalJSON(o interface{}) ([]byte, error)

func (Keeper) MarshalJSONIndent

func (k Keeper) MarshalJSONIndent(o interface{}) ([]byte, error)

func (Keeper) MintFT

func (k Keeper) MintFT(ctx sdk.Context, from, to sdk.AccAddress, amount types.Coins) error

func (Keeper) MintNFT

func (k Keeper) MintNFT(ctx sdk.Context, from sdk.AccAddress, token types.NFT) error

func (Keeper) MintSupply

func (k Keeper) MintSupply(ctx sdk.Context, to sdk.AccAddress, amt types.Coins) (err error)

MintCoins creates new coins from thin air and adds it to the module account. Panics if the name maps to a non-minter module account or if the amount is invalid.

func (Keeper) Modify

func (k Keeper) Modify(ctx sdk.Context, owner sdk.AccAddress, tokenType, tokenIndex string,
	changes types.Changes) error

func (Keeper) NewAccountWithAddress

func (k Keeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account, err error)

func (Keeper) NewContractID

func (k Keeper) NewContractID(ctx sdk.Context) string

func (Keeper) ParentOf

func (k Keeper) ParentOf(ctx sdk.Context, tokenID string) (types.NFT, error)

func (Keeper) RevokePermission

func (k Keeper) RevokePermission(ctx sdk.Context, addr sdk.AccAddress, perm types.Permission) error

func (Keeper) RootOf

func (k Keeper) RootOf(ctx sdk.Context, tokenID string) (types.NFT, error)

func (Keeper) SendCoins

func (k Keeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt types.Coins) error

func (Keeper) SetAccount

func (k Keeper) SetAccount(ctx sdk.Context, acc types.Account) error

func (Keeper) SetApproved

func (k Keeper) SetApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) error

func (Keeper) SetCoins

func (k Keeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) error

func (Keeper) SetCollection

func (k Keeper) SetCollection(ctx sdk.Context, collection types.Collection) error

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

func (Keeper) SetSupply

func (k Keeper) SetSupply(ctx sdk.Context, supply types.Supply)

func (Keeper) SetToken

func (k Keeper) SetToken(ctx sdk.Context, token types.Token) error

func (Keeper) SetTokenType

func (k Keeper) SetTokenType(ctx sdk.Context, tokenType types.TokenType) error

func (Keeper) SubtractCoins

func (k Keeper) SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt types.Coins) (types.Coins, error)

func (Keeper) TransferFT

func (k Keeper) TransferFT(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amount ...types.Coin) error

func (Keeper) TransferFTFrom

func (k Keeper) TransferFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, to sdk.AccAddress, amount ...types.Coin) error

func (Keeper) TransferNFT

func (k Keeper) TransferNFT(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, tokenIDs ...string) error

func (Keeper) TransferNFTFrom

func (k Keeper) TransferNFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, to sdk.AccAddress, tokenIDs ...string) error

nolint:dupl

func (Keeper) UnmarshalJSON

func (k Keeper) UnmarshalJSON(bz []byte, ptr interface{}) error

func (Keeper) UpdateAccount

func (k Keeper) UpdateAccount(ctx sdk.Context, acc types.Account) error

func (Keeper) UpdateCollection

func (k Keeper) UpdateCollection(ctx sdk.Context, collection types.Collection) error

func (Keeper) UpdateToken

func (k Keeper) UpdateToken(ctx sdk.Context, token types.Token) error

func (Keeper) UpdateTokenType

func (k Keeper) UpdateTokenType(ctx sdk.Context, tokenType types.TokenType) error

type MintKeeper

type MintKeeper interface {
	MintFT(ctx sdk.Context, from, to sdk.AccAddress, amount types.Coins) error
	MintNFT(ctx sdk.Context, from sdk.AccAddress, token types.NFT) error
}

type ProxyKeeper

type ProxyKeeper interface {
	IsApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) bool
	SetApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) error
	DeleteApproved(ctx sdk.Context, proxy sdk.AccAddress, approver sdk.AccAddress) error
}

type SupplyKeeper

type SupplyKeeper interface {
	GetTotalInt(ctx sdk.Context, tokenID, target string) (supply sdk.Int, err error)
	GetSupply(ctx sdk.Context) (supply types.Supply)
	SetSupply(ctx sdk.Context, supply types.Supply)
	MintSupply(ctx sdk.Context, to sdk.AccAddress, amt types.Coins) error
	BurnSupply(ctx sdk.Context, from sdk.AccAddress, amt types.Coins) error
}

type TokenKeeper

type TokenKeeper interface {
	GetToken(ctx sdk.Context, tokenID string) (types.Token, error)
	HasToken(ctx sdk.Context, tokenID string) bool
	SetToken(ctx sdk.Context, token types.Token) error
	DeleteToken(ctx sdk.Context, tokenID string) error
	UpdateToken(ctx sdk.Context, token types.Token) error
	GetTokens(ctx sdk.Context) (tokens types.Tokens, err error)
	GetFT(ctx sdk.Context, tokenID string) (types.FT, error)
	GetFTs(ctx sdk.Context) (tokens types.Tokens, err error)
	GetNFT(ctx sdk.Context, tokenID string) (types.NFT, error)
	GetNFTCount(ctx sdk.Context, tokenType string) (sdk.Int, error)
	GetNFTCountInt(ctx sdk.Context, tokenType, target string) (sdk.Int, error)
	GetNFTs(ctx sdk.Context, tokenType string) (tokens types.Tokens, err error)
	GetNextTokenIDFT(ctx sdk.Context) (string, error)
	GetNextTokenIDNFT(ctx sdk.Context, tokenType string) (string, error)
}

type TokenTypeKeeper

type TokenTypeKeeper interface {
	GetNextTokenType(ctx sdk.Context) (tokenType string, err error)
	GetTokenTypes(ctx sdk.Context) (types.TokenTypes, error)
	GetTokenType(ctx sdk.Context, tokenType string) (types.TokenType, error)
	HasTokenType(ctx sdk.Context, tokenType string) bool
	SetTokenType(ctx sdk.Context, token types.TokenType) error
	UpdateTokenType(ctx sdk.Context, token types.TokenType) error
}

type TransferKeeper

type TransferKeeper interface {
	TransferFT(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amount ...types.Coin) error
	TransferNFT(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, tokenID ...string) error
	TransferFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, to sdk.AccAddress, amount ...types.Coin) error
	TransferNFTFrom(ctx sdk.Context, proxy sdk.AccAddress, from sdk.AccAddress, to sdk.AccAddress, tokenID ...string) error
}

Jump to

Keyboard shortcuts

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