keeper

package
v0.11.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBuiltInTokenPair

func GetBuiltInTokenPair() *types.TokenPair

GetBuiltInTokenPair returns built in token pair for test

func ModuleAccountInvariant

func ModuleAccountInvariant(keeper IKeeper, supplyKeeper SupplyKeeper) sdk.Invariant

ModuleAccountInvariant checks that the module account coins reflects the sum of locks amounts held on store

func NewQuerier

func NewQuerier(keeper IKeeper) sdk.Querier

NewQuerier is the module level router for state queries

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper IKeeper, supplyKeeper SupplyKeeper)

RegisterInvariants registers all dex invariants

Types

type BankKeeper

type BankKeeper interface {
	GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
}

BankKeeper defines the expected bank Keeper

type GovKeeper

type GovKeeper interface {
	RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)
}

GovKeeper defines the expected gov Keeper

type IKeeper

type IKeeper interface {
	GetTokenPair(ctx sdk.Context, product string) *types.TokenPair
	GetTokenPairs(ctx sdk.Context) []*types.TokenPair
	GetUserTokenPairs(ctx sdk.Context, owner sdk.AccAddress) []*types.TokenPair
	GetTokenPairsOrdered(ctx sdk.Context) types.TokenPairs
	SaveTokenPair(ctx sdk.Context, tokenPair *types.TokenPair) error
	DeleteTokenPairByName(ctx sdk.Context, owner sdk.AccAddress, tokenPairName string)
	Deposit(ctx sdk.Context, product string, from sdk.AccAddress, amount sdk.SysCoin) sdk.Error
	Withdraw(ctx sdk.Context, product string, to sdk.AccAddress, amount sdk.SysCoin) sdk.Error
	GetSupplyKeeper() SupplyKeeper
	GetTokenKeeper() TokenKeeper
	GetBankKeeper() BankKeeper
	GetParamSubspace() params.Subspace
	GetParams(ctx sdk.Context) (params types.Params)
	SetParams(ctx sdk.Context, params types.Params)
	GetFeeCollector() string
	LockTokenPair(ctx sdk.Context, product string, lock *ordertypes.ProductLock)
	LoadProductLocks(ctx sdk.Context) *ordertypes.ProductLockMap
	SetWithdrawInfo(ctx sdk.Context, withdrawInfo types.WithdrawInfo)
	SetWithdrawCompleteTimeAddress(ctx sdk.Context, completeTime time.Time, addr sdk.AccAddress)
	IterateWithdrawAddress(ctx sdk.Context, currentTime time.Time, fn func(index int64, key []byte) (stop bool))
	CompleteWithdraw(ctx sdk.Context, addr sdk.AccAddress) error
	IterateWithdrawInfo(ctx sdk.Context, fn func(index int64, withdrawInfo types.WithdrawInfo) (stop bool))
	DeleteWithdrawCompleteTimeAddress(ctx sdk.Context, timestamp time.Time, delAddr sdk.AccAddress)
	SetOperator(ctx sdk.Context, operator types.DEXOperator)
	GetOperator(ctx sdk.Context, addr sdk.AccAddress) (operator types.DEXOperator, isExist bool)
	IterateOperators(ctx sdk.Context, cb func(operator types.DEXOperator) (stop bool))
	GetMaxTokenPairID(ctx sdk.Context) (tokenPairMaxID uint64)
	SetMaxTokenPairID(ctx sdk.Context, tokenPairMaxID uint64)
	GetConfirmOwnership(ctx sdk.Context, product string) (confirmOwnership *types.ConfirmOwnership, exist bool)
	SetConfirmOwnership(ctx sdk.Context, confirmOwnership *types.ConfirmOwnership)
	DeleteConfirmOwnership(ctx sdk.Context, product string)
	UpdateUserTokenPair(ctx sdk.Context, product string, owner, to sdk.AccAddress)
	UpdateTokenPair(ctx sdk.Context, product string, tokenPair *types.TokenPair)
}

IKeeper defines the expected dex Keeper

type Keeper

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

Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(feeCollectorName string, supplyKeeper SupplyKeeper, dexParamsSubspace params.Subspace, tokenKeeper TokenKeeper,
	stakingKeeper StakingKeeper, bankKeeper BankKeeper, storeKey, tokenPairStoreKey sdk.StoreKey, cdc *codec.Codec) Keeper

NewKeeper creates new instances of the token Keeper

func (Keeper) AfterDepositPeriodPassed

func (k Keeper) AfterDepositPeriodPassed(ctx sdk.Context, proposal govTypes.Proposal)

AfterDepositPeriodPassed handles delist proposal when passed

func (Keeper) AfterSubmitProposalHandler

func (k Keeper) AfterSubmitProposalHandler(ctx sdk.Context, proposal govTypes.Proposal)

nolint

func (Keeper) CheckMsgSubmitProposal

func (k Keeper) CheckMsgSubmitProposal(ctx sdk.Context, msg govTypes.MsgSubmitProposal) (sdkErr sdk.Error)

CheckMsgSubmitProposal validates MsgSubmitProposal

func (Keeper) CheckTokenPairUnderDexDelist

func (k Keeper) CheckTokenPairUnderDexDelist(ctx sdk.Context, product string) (isDelisting bool, err error)

CheckTokenPairUnderDexDelist checks if token pair is under delist. for x/order: It's not allowed to place an order about the tokenpair under dex delist

func (Keeper) CompleteWithdraw

func (k Keeper) CompleteWithdraw(ctx sdk.Context, addr sdk.AccAddress) error

CompleteWithdraw completes withdrawing of addr

func (Keeper) DeleteConfirmOwnership

func (k Keeper) DeleteConfirmOwnership(ctx sdk.Context, product string)

DeleteConfirmOwnership deletes ownership confirming information from db

func (Keeper) DeleteTokenPairByName

func (k Keeper) DeleteTokenPairByName(ctx sdk.Context, owner sdk.AccAddress, product string)

DeleteTokenPairByName deletes the token pair by name

func (Keeper) DeleteWithdrawCompleteTimeAddress

func (k Keeper) DeleteWithdrawCompleteTimeAddress(ctx sdk.Context, timestamp time.Time, delAddr sdk.AccAddress)

DeleteWithdrawCompleteTimeAddress deletes withdraw time key

func (Keeper) Deposit

func (k Keeper) Deposit(ctx sdk.Context, product string, from sdk.AccAddress, amount sdk.SysCoin) sdk.Error

Deposit deposits amount of tokens for a product

func (Keeper) GetBankKeeper

func (k Keeper) GetBankKeeper() BankKeeper

GetBankKeeper returns bank Keeper

func (Keeper) GetConfirmOwnership

func (k Keeper) GetConfirmOwnership(ctx sdk.Context, product string) (confirmOwnership *types.ConfirmOwnership, exist bool)

GetConfirmOwnership returns ownership confirming information

func (Keeper) GetFeeCollector

func (k Keeper) GetFeeCollector() string

GetFeeCollector returns feeCollectorName

func (Keeper) GetLockedProductsCopy

func (k Keeper) GetLockedProductsCopy(ctx sdk.Context) *ordertypes.ProductLockMap

GetLockedProductsCopy returns deep copy of product locked

func (Keeper) GetMaxDepositPeriod

func (k Keeper) GetMaxDepositPeriod(ctx sdk.Context, content gov.Content) (maxDepositPeriod time.Duration)

GetMaxDepositPeriod returns max deposit period

func (Keeper) GetMaxTokenPairID

func (k Keeper) GetMaxTokenPairID(ctx sdk.Context) (tokenPairMaxID uint64)

GetMaxTokenPairID returns the max ID of token pair

func (Keeper) GetMinDeposit

func (k Keeper) GetMinDeposit(ctx sdk.Context, content gov.Content) (minDeposit sdk.SysCoins)

GetMinDeposit returns min deposit

func (Keeper) GetOperator

func (k Keeper) GetOperator(ctx sdk.Context, addr sdk.AccAddress) (operator types.DEXOperator, isExist bool)

GetOperator gets the DEXOperator and checks whether the operator with address exist or not

func (Keeper) GetParamSubspace

func (k Keeper) GetParamSubspace() params.Subspace

GetParamSubspace returns paramSubspace

func (Keeper) GetParams

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

GetParams gets inflation params from the global param store

func (Keeper) GetSupplyKeeper

func (k Keeper) GetSupplyKeeper() SupplyKeeper

GetSupplyKeeper returns supply Keeper

func (Keeper) GetTokenKeeper

func (k Keeper) GetTokenKeeper() TokenKeeper

GetTokenKeeper returns token Keeper

func (Keeper) GetTokenPair

func (k Keeper) GetTokenPair(ctx sdk.Context, product string) *types.TokenPair

GetTokenPair gets the token pair by product

func (Keeper) GetTokenPairFromStore

func (k Keeper) GetTokenPairFromStore(ctx sdk.Context, product string) *types.TokenPair

GetTokenPairFromStore returns token pair from store without cache

func (Keeper) GetTokenPairs

func (k Keeper) GetTokenPairs(ctx sdk.Context) (tokenPairs []*types.TokenPair)

GetTokenPairs returns all token pairs from store without cache

func (Keeper) GetTokenPairsOrdered

func (k Keeper) GetTokenPairsOrdered(ctx sdk.Context) types.TokenPairs

GetTokenPairsOrdered returns token pairs ordered by product

func (Keeper) GetUserTokenPairs

func (k Keeper) GetUserTokenPairs(ctx sdk.Context, owner sdk.AccAddress) (tokenPairs []*types.TokenPair)

GetUserTokenPairs returns all token pairs belong to an account from store

func (Keeper) GetVotingPeriod

func (k Keeper) GetVotingPeriod(ctx sdk.Context, content gov.Content) (votingPeriod time.Duration)

GetVotingPeriod returns voting period

func (Keeper) GetWithdrawInfo

func (k Keeper) GetWithdrawInfo(ctx sdk.Context, addr sdk.AccAddress) (withdrawInfo types.WithdrawInfo, ok bool)

GetWithdrawInfo returns withdraw info binding the addr

func (Keeper) IsAnyProductLocked

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

IsAnyProductLocked checks if any product is locked

func (Keeper) IsTokenPairLocked

func (k Keeper) IsTokenPairLocked(ctx sdk.Context, product string) bool

IsTokenPairLocked return true if token pair locked

func (Keeper) IterateOperators

func (k Keeper) IterateOperators(ctx sdk.Context, cb func(operator types.DEXOperator) (stop bool))

IterateOperators iterates over the all the operators and performs a callback function

func (Keeper) IterateWithdrawAddress

func (k Keeper) IterateWithdrawAddress(ctx sdk.Context, currentTime time.Time,
	fn func(index int64, key []byte) (stop bool))

IterateWithdrawAddress itreates withdraw time keys, and returns address

func (Keeper) IterateWithdrawInfo

func (k Keeper) IterateWithdrawInfo(ctx sdk.Context, fn func(index int64, withdrawInfo types.WithdrawInfo) (stop bool))

IterateWithdrawInfo iterates withdraw address key, and returns withdraw info

func (Keeper) LoadProductLocks

func (k Keeper) LoadProductLocks(ctx sdk.Context) *ordertypes.ProductLockMap

LoadProductLocks loads product locked

func (Keeper) LockTokenPair

func (k Keeper) LockTokenPair(ctx sdk.Context, product string, lock *ordertypes.ProductLock)

LockTokenPair locks token pair

func (Keeper) RejectedHandler

func (k Keeper) RejectedHandler(ctx sdk.Context, content govTypes.Content)

RejectedHandler handles delist proposal when rejected

func (Keeper) RemoveFromActiveProposalQueue

func (k Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

RemoveFromActiveProposalQueue removes active proposal in queue

func (Keeper) SaveTokenPair

func (k Keeper) SaveTokenPair(ctx sdk.Context, tokenPair *types.TokenPair) error

SaveTokenPair saves the token pair to db key is base:quote

func (Keeper) SetConfirmOwnership

func (k Keeper) SetConfirmOwnership(ctx sdk.Context, confirmOwnership *types.ConfirmOwnership)

SetConfirmOwnership sets ownership confirming information to db

func (*Keeper) SetGovKeeper

func (k *Keeper) SetGovKeeper(gk GovKeeper)

SetGovKeeper sets keeper of gov

func (Keeper) SetMaxTokenPairID

func (k Keeper) SetMaxTokenPairID(ctx sdk.Context, MaxtokenPairID uint64)

SetMaxTokenPairID sets the max ID of token pair

func (*Keeper) SetObserverKeeper

func (k *Keeper) SetObserverKeeper(sk StreamKeeper)

func (Keeper) SetOperator

func (k Keeper) SetOperator(ctx sdk.Context, operator types.DEXOperator)

SetOperator save the operator information

func (Keeper) SetParams

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

SetParams sets inflation params from the global param store

func (Keeper) SetWithdrawCompleteTimeAddress

func (k Keeper) SetWithdrawCompleteTimeAddress(ctx sdk.Context, completeTime time.Time, addr sdk.AccAddress)

SetWithdrawCompleteTimeAddress sets withdraw time key with empty []byte{} value

func (Keeper) SetWithdrawInfo

func (k Keeper) SetWithdrawInfo(ctx sdk.Context, withdrawInfo types.WithdrawInfo)

SetWithdrawInfo sets withdraw address key with withdraw info

func (Keeper) SortProducts

func (k Keeper) SortProducts(ctx sdk.Context, products []string)

SortProducts sorts products

func (Keeper) UnlockTokenPair

func (k Keeper) UnlockTokenPair(ctx sdk.Context, product string)

UnlockTokenPair unlocks token pair

func (Keeper) UpdateTokenPair

func (k Keeper) UpdateTokenPair(ctx sdk.Context, product string, tokenPair *types.TokenPair)

UpdateTokenPair updates token pair in the store and the cache

func (Keeper) UpdateUserTokenPair

func (k Keeper) UpdateUserTokenPair(ctx sdk.Context, product string, owner, to sdk.AccAddress)

UpdateUserTokenPair updates token pair in the store and the cache

func (Keeper) VoteHandler

func (k Keeper) VoteHandler(ctx sdk.Context, proposal govTypes.Proposal, vote govTypes.Vote) (string, sdk.Error)

VoteHandler handles delist proposal when voted

func (Keeper) Withdraw

func (k Keeper) Withdraw(ctx sdk.Context, product string, to sdk.AccAddress, amount sdk.SysCoin) sdk.Error

Withdraw withdraws amount of tokens from a product

type StakingKeeper

type StakingKeeper interface {
	IsValidator(ctx sdk.Context, addr sdk.AccAddress) bool
}

StakingKeeper defines the expected staking Keeper (noalias)

type StreamKeeper

type StreamKeeper interface {
	OnAddNewTokenPair(ctx sdk.Context, tokenPair *types.TokenPair)
	OnTokenPairUpdated(ctx sdk.Context)
}

type SupplyKeeper

type SupplyKeeper interface {
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress,
		recipientModule string, amt sdk.Coins) sdk.Error
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string,
		recipientAddr sdk.AccAddress, amt sdk.Coins) sdk.Error
	GetModuleAccount(ctx sdk.Context, moduleName string) exported.ModuleAccountI
	GetModuleAddress(moduleName string) sdk.AccAddress
	MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) sdk.Error
}

SupplyKeeper defines the expected supply Keeper

type TokenKeeper

type TokenKeeper interface {
	TokenExist(ctx sdk.Context, symbol string) bool
}

TokenKeeper defines the expected token Keeper

Jump to

Keyboard shortcuts

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