keeper

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUpdatedCallback = "status-updated"
	StakeChangedCallback  = "stake-changed"
)
View Source
const (
	StatusGuruMinXCriteria = 3
	StatusGuruMinXParameter
	StatusLeaderMinXCriteria
)

Variables

This section is empty.

Functions

func ChangeTeamActive added in v1.0.2

func ChangeTeamActive(aag *types.ActiveAggregations, teamSize uint64, delta int64)

func NewMsgServer

func NewMsgServer(keeper Keeper) types.MsgServer

Types

type Hooks

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

Wrapper struct

func (Hooks) CheckDelegationAvailable

func (h Hooks) CheckDelegationAvailable(ctx context.Context, delAddr, valAddr string) error

func (Hooks) DelegationCoinsModified

func (h Hooks) DelegationCoinsModified(ctx context.Context, delAddr, valAddr string, oldCoins, newCoins math.Int) error

Staked coins amount modified

func (Hooks) SpendCoinsForRef

func (h Hooks) SpendCoinsForRef(ctx context.Context, addr string, totalAmount math.Int) (math.Int, error)

type Keeper

type Keeper struct {
	Params collections.Item[types.Params]
	// contains filtered or unexported fields
}

Keeper of the referral store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService storetypes.KVStoreService,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	stakingKeeper types.StakingKeeper,
	authority sdk.AccAddress, referralAccountName string,
) *Keeper

NewKeeper creates a referral keeper

func (*Keeper) AddHook

func (k *Keeper) AddHook(eventName string, callback func(ctx sdk.Context, acc sdk.AccAddress) error)

func (Keeper) AddTopLevelAccount

func (k Keeper) AddTopLevelAccount(ctx sdk.Context, acc string, status types.Status) (err error)

AddTopLevelAccount adds accounts without parent and is supposed to be used during genesis

func (Keeper) AppendChild

func (k Keeper) AppendChild(ctx sdk.Context, parentAcc string, childAcc string) error

AppendChild adds a new account to the referral structure. The parent account should already exist and the child one should not.

func (Keeper) AreStatusRequirementsFulfilled

func (k Keeper) AreStatusRequirementsFulfilled(ctx sdk.Context, acc string, s types.Status) (types.StatusCheckResult, error)

AreStatusRequirementsFulfilled validates if the account suffices the status requirement. The actual account status doesn't matter and won't be updated.

func (Keeper) BurnCoins added in v1.0.1

func (k Keeper) BurnCoins(ctx sdk.Context, acc sdk.AccAddress, amt sdk.Coins) error

func (Keeper) ExportToGenesis

func (k Keeper) ExportToGenesis(ctx sdk.Context) (*types.GenesisState, error)

func (Keeper) Get

func (k Keeper) Get(ctx sdk.Context, acc string) (types.Info, error)

Get returns all the data for an account (status, parent, children)

func (Keeper) GetChildren

func (k Keeper) GetChildren(ctx sdk.Context, acc string) (children []string, err error)

func (Keeper) GetDelegatedInNetwork

func (k Keeper) GetDelegatedInNetwork(ctx sdk.Context, acc string) (math.Int, error)

GetDelegatedInNetwork returns total amount of delegated coins in a person's network Own coins inclusive.

func (Keeper) GetParams

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

GetParams returns the total set of referral parameters.

func (Keeper) GetParent

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

GetParent returns a parent for an account

func (Keeper) GetReferralFeesForDelegating

func (k Keeper) GetReferralFeesForDelegating(ctx sdk.Context, acc string) ([]types.ReferralFee, util.Fraction, error)

GetReferralFeesForDelegating returns a set of account-ratio pairs, describing what part of being delegated funds should go to what wallet. 0.15 total. The rest should be burned.

func (Keeper) GetStatus

func (k Keeper) GetStatus(ctx sdk.Context, acc string) (types.Status, error)

GetStatus returns a status for an account (i.e. lvl 1 "Lucky", lvl 2 "Leader", lvl 3 "Master" or so on)

func (Keeper) GetTopLevelAccounts

func (k Keeper) GetTopLevelAccounts(ctx sdk.Context) (topLevel []string, err error)

GetTopLevelAccounts returns all accounts without parents and is supposed to be used during genesis export

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new distribution hooks

func (Keeper) ImportFromGenesis

func (k Keeper) ImportFromGenesis(
	ctx sdk.Context,
	topLevel []*types.RefInfo,
	otherAccounts []types.Refs,
	downgrades []types.Downgrade,
) error

func (Keeper) Iterate

func (k Keeper) Iterate(ctx sdk.Context, callback func(acc string, r *types.Info) (changed, checkForStatusUpdate bool))

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MustSetActive

func (k Keeper) MustSetActive(ctx sdk.Context, acc string, value bool, bu *bunchUpdater)

func (Keeper) MustSetActiveWithoutStatusUpdate

func (k Keeper) MustSetActiveWithoutStatusUpdate(ctx sdk.Context, acc string, value bool, bu *bunchUpdater)

MustSetActiveWithoutStatusUpdate updates active referrals but skips status update check after it. So this check MUST be performed from the outer code later. This is useful for massive updates like genesis init, because it allows to avoid excessive checks repeating again and again for the same account (every time any of referrals up to 14 lines down changes its activity).

func (Keeper) OnBalanceChanged

func (k Keeper) OnBalanceChanged(ctx sdk.Context, acc string, dd math.Int) error

func (Keeper) OneDay

func (k Keeper) OneDay(ctx sdk.Context) time.Duration

func (Keeper) OneMonth

func (k Keeper) OneMonth(ctx sdk.Context) time.Duration

func (Keeper) OneWeek

func (k Keeper) OneWeek(ctx sdk.Context) time.Duration

func (Keeper) PayUpFees

func (k Keeper) PayUpFees(ctx sdk.Context, acc string, totalAmount math.Int) (remain math.Int, err error)

func (Keeper) PerfomStatusDowngradeSchedule

func (k Keeper) PerfomStatusDowngradeSchedule(ctx sdk.Context) error

func (Keeper) PerformDowngrade

func (k Keeper) PerformDowngrade(ctx sdk.Context, data []byte, _ time.Time)

func (Keeper) PerformStatusBonus

func (k Keeper) PerformStatusBonus(ctx sdk.Context, _ []byte, t time.Time)

func (Keeper) RemoveStatusDowngradeSchedule

func (k Keeper) RemoveStatusDowngradeSchedule(ctx sdk.Context, acc string, downgradeAt time.Time) error

func (Keeper) ScheduleStatusDowngrade

func (k Keeper) ScheduleStatusDowngrade(ctx sdk.Context, acc string, downgradeAt time.Time) error

func (Keeper) SetActive

func (k Keeper) SetActive(ctx sdk.Context, acc string, value, checkAncestorsForStatusUpdate bool, bu *bunchUpdater) error

func (Keeper) SetParams

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

SetParams sets the referral parameters to the param space.

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) CheckStatus

func (qs Querier) CheckStatus(ctx context.Context, request *types.CheckStatusRequest) (*types.CheckStatusResponse, error)

func (Querier) Children

func (qs Querier) Children(ctx context.Context, request *types.ChildrenRequest) (*types.ChildrenResponse, error)

func (Querier) Coins

func (qs Querier) Coins(ctx context.Context, request *types.CoinsRequest) (*types.CoinsResponse, error)

func (Querier) Exists

func (qs Querier) Exists(ctx context.Context, request *types.ExistsRequest) (*types.ExistsResponse, error)

func (Querier) Get

func (qs Querier) Get(ctx context.Context, request *types.GetRequest) (*types.GetResponse, error)

func (Querier) Params

Jump to

Keyboard shortcuts

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