keeper

package
v0.0.0-...-b6b58f0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the farming module.

func FarmingPoolsEscrowAmountInvariant

func FarmingPoolsEscrowAmountInvariant(k Keeper) sdk.Invariant

FarmingPoolsEscrowAmountInvariant checks that outstanding unwithdrawn fees are never negative.

func HandlePublicPlanProposal

func HandlePublicPlanProposal(ctx sdk.Context, k Keeper, plansAny []*codectypes.Any) error

HandlePublicPlanProposal is a handler for executing a fixed amount plan creation proposal.

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the farming MsgServer interface for the provided Keeper.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all farming invariants.

Types

type Keeper

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

Keeper of the farming store

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
	accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, distrKeeper types.DistributionKeeper,
	blockedAddrs map[string]bool,
) Keeper

NewKeeper returns a farming keeper. It handles: - creating new ModuleAccounts for each pool ReserveAccount - sending to and from ModuleAccounts - minting, burning PoolCoins

func (Keeper) Claim

func (k Keeper) Claim(ctx sdk.Context, msg *types.MsgClaim) (types.Reward, error)

Claim claims farming rewards from the reward pool account.

func (Keeper) CreateFixedAmountPlan

func (k Keeper) CreateFixedAmountPlan(ctx sdk.Context, msg *types.MsgCreateFixedAmountPlan, typ types.PlanType) *types.FixedAmountPlan

CreateFixedAmountPlan sets fixed amount plan.

func (Keeper) CreateRatioPlan

func (k Keeper) CreateRatioPlan(ctx sdk.Context, msg *types.MsgCreateRatioPlan, typ types.PlanType) *types.RatioPlan

CreateRatioPlan sets ratio plan.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis returns the farming module's genesis state.

func (Keeper) GetAllPlans

func (k Keeper) GetAllPlans(ctx sdk.Context) (plans []types.PlanI)

GetAllPlans returns all plans in the Keeper.

func (Keeper) GetAllRewards

func (k Keeper) GetAllRewards(ctx sdk.Context) (rewards []types.Reward)

GetAllRewards returns all rewards in the Keeper.

func (Keeper) GetAllStakings

func (k Keeper) GetAllStakings(ctx sdk.Context) (stakings []types.Staking)

GetAllStakings returns all stakings in the Keeper.

func (Keeper) GetCodec

func (k Keeper) GetCodec() codec.BinaryCodec

GetCodec return codec.Codec object used by the keeper

func (Keeper) GetNextPlanIDWithUpdate

func (k Keeper) GetNextPlanIDWithUpdate(ctx sdk.Context) uint64

GetNextPlanIDWithUpdate returns and increments the global Plan ID counter. If the global plan number is not set, it initializes it with value 1.

func (Keeper) GetParams

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

GetParams gets the parameters for the farming module.

func (Keeper) GetPlan

func (k Keeper) GetPlan(ctx sdk.Context, id uint64) (plan types.PlanI, found bool)

GetPlan implements PlanI.

func (Keeper) GetPlansByFarmerAddrIndex

func (k Keeper) GetPlansByFarmerAddrIndex(ctx sdk.Context, farmerAcc sdk.AccAddress) (plans []types.PlanI)

GetPlansByFarmerAddrIndex reads from kvstore and return a specific Plan indexed by given farmer address

func (Keeper) GetReward

func (k Keeper) GetReward(ctx sdk.Context, planID uint64, farmerAcc sdk.AccAddress) (reward types.Reward, found bool)

GetReward return a specific reward

func (Keeper) GetRewardsByPlanID

func (k Keeper) GetRewardsByPlanID(ctx sdk.Context, planID uint64) (rewards []types.Reward)

GetRewardsByPlanID reads from kvstore and return a specific Reward indexed by given plan id

func (Keeper) GetStaking

func (k Keeper) GetStaking(ctx sdk.Context, planID uint64, farmerAcc sdk.AccAddress) (staking types.Staking, found bool)

GetStaking return a specific staking

func (Keeper) GetStakingsByPlanID

func (k Keeper) GetStakingsByPlanID(ctx sdk.Context, planID uint64) (stakings []types.Staking)

GetStakingsByPlanID reads from kvstore and return a specific Staking indexed by given plan id

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState)

InitGenesis initializes the farming module's state from a given genesis state.

func (Keeper) IterateAllPlans

func (k Keeper) IterateAllPlans(ctx sdk.Context, cb func(plan types.PlanI) (stop bool))

IterateAllPlans iterates over all the stored plans and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateAllRewards

func (k Keeper) IterateAllRewards(ctx sdk.Context, cb func(reward types.Reward) (stop bool))

IterateAllRewards iterates over all the stored rewards and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateAllStakings

func (k Keeper) IterateAllStakings(ctx sdk.Context, cb func(staking types.Staking) (stop bool))

IterateAllStakings iterates over all the stored stakings and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IteratePlansByFarmerAddr

func (k Keeper) IteratePlansByFarmerAddr(ctx sdk.Context, farmerAcc sdk.AccAddress, cb func(plan types.PlanI) (stop bool))

IteratePlansByFarmerAddr iterates over all the stored plans and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateRewardsByPlanID

func (k Keeper) IterateRewardsByPlanID(ctx sdk.Context, planID uint64, cb func(reward types.Reward) (stop bool))

IterateRewardsByPlanID iterates over all the stored rewards and performs a callback function. Stops iteration when callback returns true.

func (Keeper) IterateStakingsByPlanID

func (k Keeper) IterateStakingsByPlanID(ctx sdk.Context, planID uint64, cb func(staking types.Staking) (stop bool))

IterateStakingsByPlanID iterates over all the stored stakings and performs a callback function. Stops iteration when callback returns true.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MarshalPlan

func (k Keeper) MarshalPlan(plan types.PlanI) ([]byte, error)

MarshalPlan protobuf serializes an Plan interface

func (Keeper) NewPlan

func (k Keeper) NewPlan(ctx sdk.Context, plan types.PlanI) types.PlanI

NewPlan sets the next plan number to a given plan interface

func (Keeper) ReleaseStakingCoins

func (k Keeper) ReleaseStakingCoins(ctx sdk.Context, reserveAcc, farmer sdk.AccAddress, unstakingCoins sdk.Coins) error

ReleaseStakingCoins sends staking coins back to the farmer.

func (Keeper) RemovePlan

func (k Keeper) RemovePlan(ctx sdk.Context, plan types.PlanI)

RemovePlan removes an plan for the plan mapper store. NOTE: this will cause supply invariant violation if called

func (Keeper) RemoveReward

func (k Keeper) RemoveReward(ctx sdk.Context, reward types.Reward)

RemoveReward removes an reward for the reward mapper store.

func (Keeper) RemoveStaking

func (k Keeper) RemoveStaking(ctx sdk.Context, staking types.Staking)

RemoveStaking removes an staking for the staking mapper store.

func (Keeper) ReserveStakingCoins

func (k Keeper) ReserveStakingCoins(ctx sdk.Context, farmer, reserveAcc sdk.AccAddress, stakingCoins sdk.Coins) error

ReserveStakingCoins sends staking coins to the staking reserve account.

func (Keeper) SetParams

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

SetParams sets the parameters for the farming module.

func (Keeper) SetPlan

func (k Keeper) SetPlan(ctx sdk.Context, plan types.PlanI)

SetPlan implements PlanI.

func (Keeper) SetPlanIDByFarmerAddrIndex

func (k Keeper) SetPlanIDByFarmerAddrIndex(ctx sdk.Context, planID uint64, farmerAcc sdk.AccAddress)

SetPlanIDByFarmerAddrIndex sets Index by FarmerAddr TODO: need to gas cost check for existing check or update everytime

func (Keeper) SetReward

func (k Keeper) SetReward(ctx sdk.Context, reward types.Reward)

SetReward implements Reward.

func (Keeper) SetStaking

func (k Keeper) SetStaking(ctx sdk.Context, staking types.Staking)

SetStaking implements Staking.

func (Keeper) Stake

func (k Keeper) Stake(ctx sdk.Context, msg *types.MsgStake) (types.Staking, error)

Stake stores staking coins to queued coins and it will be processed in the next epoch.

func (Keeper) UnmarshalPlan

func (k Keeper) UnmarshalPlan(bz []byte) (types.PlanI, error)

UnmarshalPlan returns an Plan interface from raw encoded plan bytes of a Proto-based Plan type

func (Keeper) UnmarshalReward

func (k Keeper) UnmarshalReward(bz []byte) (types.Reward, error)

UnmarshalReward unmarshals a Reward from bytes.

func (Keeper) UnmarshalStaking

func (k Keeper) UnmarshalStaking(bz []byte) (types.Staking, error)

UnmarshalStaking unmarshals a Staking from bytes.

func (Keeper) Unstake

func (k Keeper) Unstake(ctx sdk.Context, msg *types.MsgUnstake) (types.Staking, error)

Unstake unstakes an amount of staking coins from the staking reserve account.

func (Keeper) ValidateGenesis

func (k Keeper) ValidateGenesis(ctx sdk.Context, genState types.GenesisState) error

ValidateGenesis validates the farming module's genesis state.

type Querier

type Querier struct {
	Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper.

func (Querier) Plan

func (Querier) Plans

Jump to

Keyboard shortcuts

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