keeper

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountsBalancesInvariants

func AccountsBalancesInvariants(k *Keeper) sdk.Invariant

AccountsBalancesInvariants checks that the pools, operators and services accounts have the correct balance based on the delegations that are stored in the store

func AllowedOperatorsExistInvariant

func AllowedOperatorsExistInvariant(k *Keeper) sdk.Invariant

AllowedOperatorsExistInvariant checks that all the operators that are allowed to join a service exist

func NewMsgServer

func NewMsgServer(keeper *Keeper) types.MsgServer

func OperatorDelegationToOperatorDelegationResponse

func OperatorDelegationToOperatorDelegationResponse(ctx context.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error)

OperatorDelegationToOperatorDelegationResponse converts a OperatorDelegation to a OperatorDelegationResponse

func OperatorsDelegatorsSharesInvariant

func OperatorsDelegatorsSharesInvariant(k *Keeper) sdk.Invariant

OperatorsDelegatorsSharesInvariant checks that the sum of all delegators shares for each operator is equal to the total delegators shares stored in the operator object

func OperatorsJoinedServicesExistInvariant

func OperatorsJoinedServicesExistInvariant(k *Keeper) sdk.Invariant

OperatorsJoinedServicesExistInvariant checks that all the services that are joined by operators exist

func PoolDelegationToPoolDelegationResponse

func PoolDelegationToPoolDelegationResponse(ctx context.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error)

PoolDelegationToPoolDelegationResponse converts a PoolDelegation to a PoolDelegationResponse

func PoolsDelegatorsSharesInvariant

func PoolsDelegatorsSharesInvariant(k *Keeper) sdk.Invariant

PoolsDelegatorsSharesInvariant checks that the sum of all delegators shares for each pool is equal to the total delegators shares stored in the pool object

func PositiveOperatorsDelegationsInvariant

func PositiveOperatorsDelegationsInvariant(k *Keeper) sdk.Invariant

PositiveOperatorsDelegationsInvariant checks that all stored operator delegations have > 0 shares.

func PositivePoolsDelegationsInvariant

func PositivePoolsDelegationsInvariant(k *Keeper) sdk.Invariant

PositivePoolsDelegationsInvariant checks that all stored pools delegations have > 0 shares

func PositiveServicesDelegationsInvariant

func PositiveServicesDelegationsInvariant(k *Keeper) sdk.Invariant

PositiveServicesDelegationsInvariant checks that all stored service delegations have > 0 shares.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k *Keeper)

func ServiceDelegationToServiceDelegationResponse

func ServiceDelegationToServiceDelegationResponse(ctx context.Context, k *Keeper, delegation types.Delegation) (types.DelegationResponse, error)

ServiceDelegationToServiceDelegationResponse converts a ServiceDelegation to a ServiceDelegationResponse

func ServicesDelegatorsSharesInvariant

func ServicesDelegatorsSharesInvariant(k *Keeper) sdk.Invariant

ServicesDelegatorsSharesInvariant checks that the sum of all delegators shares for each service is equal to the total delegators shares stored in the service object

Types

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeService corestoretypes.KVStoreService,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	poolsKeeper types.PoolsKeeper,
	operatorsKeeper types.OperatorsKeeper,
	servicesKeeper types.ServicesKeeper,
	authority string,
) *Keeper

func (*Keeper) AddOperatorToServiceAllowList

func (k *Keeper) AddOperatorToServiceAllowList(ctx context.Context, serviceID uint32, operatorID uint32) error

AddOperatorToServiceAllowList adds an operator to the list of operators allowed to secure a service. If the operator is already in the list, no action is taken.

func (*Keeper) AddOperatorTokensAndShares

func (k *Keeper) AddOperatorTokensAndShares(
	ctx context.Context, operator operatorstypes.Operator, tokensToAdd sdk.Coins,
) (operatorOut operatorstypes.Operator, addedShares sdk.DecCoins, err error)

AddOperatorTokensAndShares adds the given amount of tokens to the operator and returns the added shares

func (*Keeper) AddPoolToServiceSecuringPools

func (k *Keeper) AddPoolToServiceSecuringPools(ctx context.Context, serviceID uint32, poolID uint32) error

AddPoolToServiceSecuringPools adds a pool to the list of pools permitted for securing the service

func (*Keeper) AddPoolTokensAndShares

func (k *Keeper) AddPoolTokensAndShares(
	ctx context.Context, pool poolstypes.Pool, tokensToAdd sdk.Coin,
) (poolOut poolstypes.Pool, addedShares sdk.DecCoin, err error)

AddPoolTokensAndShares adds the given amount of tokens to the pool and returns the added shares

func (*Keeper) AddServiceToOperatorJoinedServices

func (k *Keeper) AddServiceToOperatorJoinedServices(ctx context.Context, operatorID uint32, serviceID uint32) error

AddServiceToOperatorJoinedServices adds the given service to the list of services joined by the operator with the given ID

func (*Keeper) AddServiceTokensAndShares

func (k *Keeper) AddServiceTokensAndShares(
	ctx context.Context, service servicestypes.Service, tokensToAdd sdk.Coins,
) (serviceOut servicestypes.Service, addedShares sdk.DecCoins, err error)

AddServiceTokensAndShares adds the given amount of tokens to the service and returns the added shares

func (*Keeper) AfterOperatorDelegationModified

func (k *Keeper) AfterOperatorDelegationModified(ctx context.Context, operatorID uint32, delegator string) error

AfterOperatorDelegationModified implements types.RestakingHooks

func (*Keeper) AfterPoolDelegationModified

func (k *Keeper) AfterPoolDelegationModified(ctx context.Context, poolID uint32, delegator string) error

AfterPoolDelegationModified implements types.RestakingHooks

func (*Keeper) AfterServiceDelegationModified

func (k *Keeper) AfterServiceDelegationModified(ctx context.Context, serviceID uint32, delegator string) error

AfterServiceDelegationModified implements types.RestakingHooks

func (*Keeper) AfterUnbondingInitiated

func (k *Keeper) AfterUnbondingInitiated(ctx context.Context, unbondingDelegationID uint64) error

AfterUnbondingInitiated implements types.RestakingHooks

func (*Keeper) AfterUserPreferencesModified

func (k *Keeper) AfterUserPreferencesModified(ctx context.Context, userAddress string, oldPreferences, newPreferences types.UserPreferences) error

AfterUserPreferencesModified implements types.RestakingHooks

func (*Keeper) BeforeOperatorDelegationCreated

func (k *Keeper) BeforeOperatorDelegationCreated(ctx context.Context, operatorID uint32, delegator string) error

BeforeOperatorDelegationCreated implements types.RestakingHooks

func (*Keeper) BeforeOperatorDelegationRemoved

func (k *Keeper) BeforeOperatorDelegationRemoved(ctx context.Context, operatorID uint32, delegator string) error

BeforeOperatorDelegationRemoved implements types.RestakingHooks

func (*Keeper) BeforeOperatorDelegationSharesModified

func (k *Keeper) BeforeOperatorDelegationSharesModified(ctx context.Context, operatorID uint32, delegator string) error

BeforeOperatorDelegationSharesModified implements types.RestakingHooks

func (*Keeper) BeforePoolDelegationCreated

func (k *Keeper) BeforePoolDelegationCreated(ctx context.Context, poolID uint32, delegator string) error

BeforePoolDelegationCreated implements types.RestakingHooks

func (*Keeper) BeforePoolDelegationRemoved

func (k *Keeper) BeforePoolDelegationRemoved(ctx context.Context, poolID uint32, delegator string) error

BeforePoolDelegationRemoved implements types.RestakingHooks

func (*Keeper) BeforePoolDelegationSharesModified

func (k *Keeper) BeforePoolDelegationSharesModified(ctx context.Context, poolID uint32, delegator string) error

BeforePoolDelegationSharesModified implements types.RestakingHooks

func (*Keeper) BeforeServiceDelegationCreated

func (k *Keeper) BeforeServiceDelegationCreated(ctx context.Context, serviceID uint32, delegator string) error

BeforeServiceDelegationCreated implements types.RestakingHooks

func (*Keeper) BeforeServiceDelegationRemoved

func (k *Keeper) BeforeServiceDelegationRemoved(ctx context.Context, serviceID uint32, delegator string) error

BeforeServiceDelegationRemoved implements types.RestakingHooks

func (*Keeper) BeforeServiceDelegationSharesModified

func (k *Keeper) BeforeServiceDelegationSharesModified(ctx context.Context, serviceID uint32, delegator string) error

BeforeServiceDelegationSharesModified implements types.RestakingHooks

func (*Keeper) CanOperatorValidateService

func (k *Keeper) CanOperatorValidateService(ctx context.Context, serviceID uint32, operatorID uint32) (bool, error)

CanOperatorValidateService returns true if the given operator can secure the given service

func (*Keeper) CompleteMatureUnbondingDelegations

func (k *Keeper) CompleteMatureUnbondingDelegations(ctx sdk.Context) error

CompleteMatureUnbondingDelegations runs the endblocker logic for delegations

func (*Keeper) CompleteUnbonding

func (k *Keeper) CompleteUnbonding(ctx context.Context, data types.DTData) (sdk.Coins, error)

CompleteUnbonding completes the unbonding of all mature entries in the retrieved unbonding delegation object and returns the total unbonding balance or an error upon failure.

func (*Keeper) DelegateToOperator

func (k *Keeper) DelegateToOperator(ctx context.Context, operatorID uint32, amount sdk.Coins, delegator string) (sdk.DecCoins, error)

DelegateToOperator sends the given amount to the operator account and saves the delegation for the given user

func (*Keeper) DelegateToPool

func (k *Keeper) DelegateToPool(ctx context.Context, amount sdk.Coin, delegator string) (sdk.DecCoins, error)

DelegateToPool sends the given amount to the pool account and saves the delegation for the given user

func (*Keeper) DelegateToService

func (k *Keeper) DelegateToService(ctx context.Context, serviceID uint32, amount sdk.Coins, delegator string) (sdk.DecCoins, error)

DelegateToService sends the given amount to the service account and saves the delegation for the given user

func (*Keeper) DeleteUnbondingIndex

func (k *Keeper) DeleteUnbondingIndex(ctx context.Context, id uint64) error

DeleteUnbondingIndex removes a mapping from UnbondingId to unbonding operation

func (*Keeper) DequeueAllMatureUBDQueue

func (k *Keeper) DequeueAllMatureUBDQueue(ctx context.Context, currTime time.Time) (matureUnbonds []types.DTData, err error)

DequeueAllMatureUBDQueue returns a concatenated list of all the timeslices inclusively previous to currTime, and deletes the timeslices from the queue.

func (*Keeper) ExportGenesis

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

ExportGenesis returns a new GenesisState instance containing the information currently present inside the store

func (*Keeper) GetAllDelegations

func (k *Keeper) GetAllDelegations(ctx context.Context) ([]types.Delegation, error)

GetAllDelegations returns all the delegations

func (*Keeper) GetAllOperatorDelegations

func (k *Keeper) GetAllOperatorDelegations(ctx context.Context) ([]types.Delegation, error)

GetAllOperatorDelegations returns all the operator delegations

func (*Keeper) GetAllOperatorUnbondingDelegations

func (k *Keeper) GetAllOperatorUnbondingDelegations(ctx context.Context) ([]types.UnbondingDelegation, error)

GetAllOperatorUnbondingDelegations returns all the operator unbonding delegations

func (*Keeper) GetAllOperatorsJoinedServices

func (k *Keeper) GetAllOperatorsJoinedServices(ctx context.Context) ([]types.OperatorJoinedServices, error)

GetAllOperatorsJoinedServices returns all services that each operator has joined

func (*Keeper) GetAllPoolDelegations

func (k *Keeper) GetAllPoolDelegations(ctx context.Context) ([]types.Delegation, error)

GetAllPoolDelegations returns all the pool delegations

func (*Keeper) GetAllPoolUnbondingDelegations

func (k *Keeper) GetAllPoolUnbondingDelegations(ctx context.Context) ([]types.UnbondingDelegation, error)

GetAllPoolUnbondingDelegations returns all the pool unbonding delegations

func (*Keeper) GetAllServiceAllowedOperators

func (k *Keeper) GetAllServiceAllowedOperators(ctx context.Context, serviceID uint32) ([]uint32, error)

GetAllServiceAllowedOperators returns all operators that have been whitelisted by a service

func (*Keeper) GetAllServiceDelegations

func (k *Keeper) GetAllServiceDelegations(ctx context.Context) ([]types.Delegation, error)

GetAllServiceDelegations returns all the service delegations

func (*Keeper) GetAllServiceSecuringPools

func (k *Keeper) GetAllServiceSecuringPools(ctx context.Context, serviceID uint32) ([]uint32, error)

GetAllServiceSecuringPools returns all pools that have been allowed to secure the give service

func (*Keeper) GetAllServiceUnbondingDelegations

func (k *Keeper) GetAllServiceUnbondingDelegations(ctx context.Context) ([]types.UnbondingDelegation, error)

GetAllServiceUnbondingDelegations returns all the service unbonding delegations

func (*Keeper) GetAllServicesAllowedOperators

func (k *Keeper) GetAllServicesAllowedOperators(ctx context.Context) ([]types.ServiceAllowedOperators, error)

GetAllServicesAllowedOperators returns all the operators that are allowed to secure a service for all the services

func (*Keeper) GetAllServicesSecuringPools

func (k *Keeper) GetAllServicesSecuringPools(ctx context.Context) ([]types.ServiceSecuringPools, error)

GetAllServicesSecuringPools returns all the pools from which the services are allowed to borrow security

func (*Keeper) GetAllUnbondingDelegations

func (k *Keeper) GetAllUnbondingDelegations(ctx context.Context) ([]types.UnbondingDelegation, error)

GetAllUnbondingDelegations returns all the unbonding delegations

func (*Keeper) GetAllUserOperatorUnbondingDelegations

func (k *Keeper) GetAllUserOperatorUnbondingDelegations(ctx context.Context, userAddress string) []types.UnbondingDelegation

GetAllUserOperatorUnbondingDelegations returns all the user's unbonding delegations from an operator

func (*Keeper) GetAllUserPoolUnbondingDelegations

func (k *Keeper) GetAllUserPoolUnbondingDelegations(ctx context.Context, userAddress string) []types.UnbondingDelegation

GetAllUserPoolUnbondingDelegations returns all the user's unbonding delegations from a pool

func (*Keeper) GetAllUserRestakedCoins

func (k *Keeper) GetAllUserRestakedCoins(ctx context.Context, userAddress string) (sdk.DecCoins, error)

GetAllUserRestakedCoins returns all the user's restaked coins

func (*Keeper) GetAllUserServiceUnbondingDelegations

func (k *Keeper) GetAllUserServiceUnbondingDelegations(ctx context.Context, userAddress string) []types.UnbondingDelegation

GetAllUserServiceUnbondingDelegations returns all the user's unbonding delegations from a service

func (*Keeper) GetAllUserUnbondingDelegations

func (k *Keeper) GetAllUserUnbondingDelegations(ctx context.Context, userAddress string) []types.UnbondingDelegation

GetAllUserUnbondingDelegations returns all the user's unbonding delegations

func (*Keeper) GetDelegationForTarget

func (k *Keeper) GetDelegationForTarget(
	ctx context.Context, target types.DelegationTarget, delegator string,
) (types.Delegation, bool, error)

GetDelegationForTarget returns the delegation for the given delegator and target.

func (*Keeper) GetDelegationTargetFromDelegation

func (k *Keeper) GetDelegationTargetFromDelegation(
	ctx context.Context, delegation types.Delegation,
) (types.DelegationTarget, bool, error)

GetDelegationTargetFromDelegation returns the target of the given delegation.

func (*Keeper) GetOperatorDelegation

func (k *Keeper) GetOperatorDelegation(ctx context.Context, operatorID uint32, userAddress string) (types.Delegation, bool, error)

GetOperatorDelegation retrieves the delegation for the given user and operator If the delegation does not exist, false is returned instead

func (*Keeper) GetOperatorUnbondingDelegation

func (k *Keeper) GetOperatorUnbondingDelegation(ctx context.Context, operatorID uint32, delegatorAddress string) (types.UnbondingDelegation, bool, error)

GetOperatorUnbondingDelegation returns the unbonding delegation for the given delegator address and operator id. If no unbonding delegation is found, false is returned instead.

func (*Keeper) GetParams

func (k *Keeper) GetParams(ctx context.Context) (p types.Params, err error)

GetParams returns the module parameters

func (*Keeper) GetPoolDelegation

func (k *Keeper) GetPoolDelegation(ctx context.Context, poolID uint32, userAddress string) (types.Delegation, bool, error)

GetPoolDelegation retrieves the delegation for the given user and pool If the delegation does not exist, false is returned instead

func (*Keeper) GetPoolUnbondingDelegation

func (k *Keeper) GetPoolUnbondingDelegation(ctx context.Context, poolID uint32, delegator string) (types.UnbondingDelegation, bool, error)

GetPoolUnbondingDelegation returns the unbonding delegation for the given delegator address and pool id. If no unbonding delegation is found, false is returned instead.

func (*Keeper) GetRestakableDenoms

func (k *Keeper) GetRestakableDenoms(ctx context.Context) ([]string, error)

GetRestakableDenoms gets the list of denoms that are allowed to be restaked. If the list is empty, all denoms are allowed.

func (*Keeper) GetServiceDelegation

func (k *Keeper) GetServiceDelegation(ctx context.Context, serviceID uint32, userAddress string) (types.Delegation, bool, error)

GetServiceDelegation retrieves the delegation for the given user and service If the delegation does not exist, false is returned instead

func (*Keeper) GetServiceUnbondingDelegation

func (k *Keeper) GetServiceUnbondingDelegation(ctx context.Context, serviceID uint32, delegator string) (types.UnbondingDelegation, bool, error)

GetServiceUnbondingDelegation returns the unbonding delegation for the given delegator address and service id. If no unbonding delegation is found, false is returned instead.

func (*Keeper) GetUBDQueueTimeSlice

func (k *Keeper) GetUBDQueueTimeSlice(ctx context.Context, timestamp time.Time) (dvPairs []types.DTData, err error)

GetUBDQueueTimeSlice gets a specific unbonding queue timeslice. A timeslice is a slice of DVPairs corresponding to unbonding delegations that expire at a certain time.

func (*Keeper) GetUnbondingDelegation

func (k *Keeper) GetUnbondingDelegation(
	ctx context.Context, delegatorAddress string, ubdType types.DelegationType, targetID uint32,
) (types.UnbondingDelegation, bool, error)

GetUnbondingDelegation returns the unbonding delegation for the given delegator and target.

func (*Keeper) GetUserPreferences

func (k *Keeper) GetUserPreferences(ctx context.Context, userAddress string) (types.UserPreferences, error)

GetUserPreferences returns the preferences of the user having the given address. If no custom preferences have been previously set by a user, the default ones will be returned instead.

func (*Keeper) GetUserPreferencesEntries

func (k *Keeper) GetUserPreferencesEntries(ctx context.Context) ([]types.UserPreferencesEntry, error)

GetUserPreferencesEntries returns all the user preferences entries

func (*Keeper) GetUserTrustedServicesIDs

func (k *Keeper) GetUserTrustedServicesIDs(ctx context.Context, userAddress string) ([]uint32, error)

GetUserTrustedServicesIDs returns the IDs of the services that the user trusts based on the user preferences and the services' status.

func (*Keeper) HasOperatorJoinedService

func (k *Keeper) HasOperatorJoinedService(ctx context.Context, operatorID uint32, serviceID uint32) (bool, error)

HasOperatorJoinedService returns whether the operator with the given ID has joined the provided service

func (*Keeper) IncrementUnbondingID

func (k *Keeper) IncrementUnbondingID(ctx context.Context) (unbondingID uint64, err error)

IncrementUnbondingID increments and returns a unique ID for an unbonding operation

func (*Keeper) InitGenesis

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

InitGenesis initializes the genesis store using the provided data

func (*Keeper) InsertUBDQueue

func (k *Keeper) InsertUBDQueue(ctx context.Context, ubd types.UnbondingDelegation, completionTime time.Time) error

InsertUBDQueue inserts an unbonding delegation to the appropriate timeslice in the unbonding queue.

func (*Keeper) IsDenomRestakable

func (k *Keeper) IsDenomRestakable(ctx context.Context, denom string) (bool, error)

IsDenomRestakable checks if the asset with the provided denom is allowed to be restaked.

func (*Keeper) IsOperatorInServiceAllowList

func (k *Keeper) IsOperatorInServiceAllowList(ctx context.Context, serviceID uint32, operatorID uint32) (bool, error)

IsOperatorInServiceAllowList returns true if the given operator is in the service operators allow list

func (*Keeper) IsPoolInServiceSecuringPools

func (k *Keeper) IsPoolInServiceSecuringPools(ctx context.Context, serviceID uint32, poolID uint32) (bool, error)

IsPoolInServiceSecuringPools returns true if the pool is in the list of pools from which the service can borrow security

func (*Keeper) IsServiceOperatorsAllowListConfigured

func (k *Keeper) IsServiceOperatorsAllowListConfigured(ctx context.Context, serviceID uint32) (bool, error)

IsServiceOperatorsAllowListConfigured returns true if the operators allow list

func (*Keeper) IsServiceSecuredByPool

func (k *Keeper) IsServiceSecuredByPool(ctx context.Context, serviceID uint32, poolID uint32) (bool, error)

IsServiceSecuredByPool returns true if the service is being secured by the given pool

func (*Keeper) IsServiceSecuringPoolsConfigured

func (k *Keeper) IsServiceSecuringPoolsConfigured(ctx context.Context, serviceID uint32) (bool, error)

IsServiceSecuringPoolsConfigured returns true if the list of securing pools has been configured for the given service

func (*Keeper) IterateAllOperatorDelegations

func (k *Keeper) IterateAllOperatorDelegations(ctx context.Context, cb func(del types.Delegation) (stop bool, err error)) error

IterateAllOperatorDelegations iterates all the operator delegations and performs the given callback function

func (*Keeper) IterateAllOperatorsJoinedServices

func (k *Keeper) IterateAllOperatorsJoinedServices(ctx context.Context, action func(operatorID uint32, serviceID uint32) (stop bool, err error)) error

IterateAllOperatorsJoinedServices iterates over all the operators and their joined services, performing the given action. If the action returns true, the iteration will stop.

func (*Keeper) IterateAllPoolDelegations

func (k *Keeper) IterateAllPoolDelegations(ctx context.Context, cb func(del types.Delegation) (stop bool, err error)) error

IterateAllPoolDelegations iterates all the pool delegations and performs the given callback function

func (*Keeper) IterateAllServiceDelegations

func (k *Keeper) IterateAllServiceDelegations(ctx context.Context, cb func(del types.Delegation) (stop bool, err error)) error

IterateAllServiceDelegations iterates all the service delegations and performs the given callback function

func (*Keeper) IterateAllServicesAllowedOperators

func (k *Keeper) IterateAllServicesAllowedOperators(ctx context.Context, action func(serviceID uint32, operatorID uint32) (stop bool, err error)) error

IterateAllServicesAllowedOperators iterates over all the services and their allowed operators, performing the given action. If the action returns true, the iteration will stop.

func (*Keeper) IterateServiceDelegations

func (k *Keeper) IterateServiceDelegations(ctx context.Context, serviceID uint32, cb func(del types.Delegation) (stop bool, err error)) error

IterateServiceDelegations iterates all the delegations of a service and performs the given callback function

func (*Keeper) IterateUserDelegations

func (k *Keeper) IterateUserDelegations(
	ctx context.Context, userAddress string, cb func(del types.Delegation) (stop bool, err error),
) error

IterateUserDelegations iterates over the user's delegations. The delegations will be iterated in the following order: 1. Pool delegations 2. Service delegations 3. Operator delegations

func (*Keeper) IterateUserOperatorDelegations

func (k *Keeper) IterateUserOperatorDelegations(ctx context.Context, userAddress string, cb func(del types.Delegation) (stop bool, err error)) error

IterateUserOperatorDelegations iterates all the operator delegations of a user and performs the given callback function

func (*Keeper) IterateUserPoolDelegations

func (k *Keeper) IterateUserPoolDelegations(ctx context.Context, userAddress string, cb func(del types.Delegation) (stop bool, err error)) error

IterateUserPoolDelegations iterates all the pool delegations of a user and performs the given callback function

func (*Keeper) IterateUserServiceDelegations

func (k *Keeper) IterateUserServiceDelegations(ctx context.Context, userAddress string, cb func(del types.Delegation) (stop bool, err error)) error

IterateUserServiceDelegations iterates all the service delegations of a user and performs the given callback function

func (*Keeper) Logger

func (k *Keeper) Logger(ctx context.Context) log.Logger

Logger returns a module-specific logger.

func (*Keeper) OperatorsHooks

func (k *Keeper) OperatorsHooks() operatorstypes.OperatorsHooks

func (*Keeper) PerformDelegation

func (k *Keeper) PerformDelegation(ctx context.Context, data types.DelegationData) (sdk.DecCoins, error)

PerformDelegation performs a delegation of the given amount from the delegator to the receiver. It sends the coins to the receiver address and updates the delegation object and returns the new shares of the delegation. NOTE: This is done so that if we implement other delegation types in the future we can have a single function that performs common operations for all of them.

func (*Keeper) PerformUndelegation

func (k *Keeper) PerformUndelegation(ctx context.Context, data types.UndelegationData) (time.Time, error)

PerformUndelegation unbonds an amount of delegator shares from a given validator. It will verify that the unbonding entries between the delegator and validator are not exceeded and unbond the staked tokens (based on shares) by creating an unbonding object and inserting it into the unbonding queue which will be processed during the staking EndBlocker.

func (*Keeper) RemoveDelegation

func (k *Keeper) RemoveDelegation(ctx context.Context, delegation types.Delegation) error

RemoveDelegation removes the given delegation from the store

func (*Keeper) RemoveOperatorDelegation

func (k *Keeper) RemoveOperatorDelegation(ctx context.Context, delegation types.Delegation) error

RemoveOperatorDelegation removes the given operator delegation from the store

func (*Keeper) RemoveOperatorFromServiceAllowList

func (k *Keeper) RemoveOperatorFromServiceAllowList(ctx context.Context, serviceID uint32, operatorID uint32) error

RemoveOperatorFromServiceAllowList removes an operator from the list of operators allowed to secure a service. If the operator is not in the list, no action is taken.

func (*Keeper) RemovePoolDelegation

func (k *Keeper) RemovePoolDelegation(ctx context.Context, delegation types.Delegation) error

RemovePoolDelegation removes the given pool delegation from the store

func (*Keeper) RemovePoolFromServiceSecuringPools

func (k *Keeper) RemovePoolFromServiceSecuringPools(ctx context.Context, serviceID uint32, poolID uint32) error

RemovePoolFromServiceSecuringPools removes a pool from the list of pools from which the service is borrowing the security from

func (*Keeper) RemoveServiceDelegation

func (k *Keeper) RemoveServiceDelegation(ctx context.Context, delegation types.Delegation) error

RemoveServiceDelegation removes the given service delegation from the store

func (*Keeper) RemoveServiceFromOperatorJoinedServices

func (k *Keeper) RemoveServiceFromOperatorJoinedServices(ctx context.Context, operatorID uint32, serviceID uint32) error

RemoveServiceFromOperatorJoinedServices removes the given service from the list of services joined by the operator with the given ID

func (*Keeper) RemoveTargetTokensAndShares

func (k *Keeper) RemoveTargetTokensAndShares(ctx context.Context, data types.UndelegationData) (sdk.Coins, error)

RemoveTargetTokensAndShares removes the given amount of tokens and shares from the target.

func (*Keeper) RemoveUnbondingDelegation

func (k *Keeper) RemoveUnbondingDelegation(ctx context.Context, ubd types.UnbondingDelegation) error

RemoveUnbondingDelegation removes the unbonding delegation object and associated index.

func (*Keeper) ServiceAllowedOperatorsIterator

func (k *Keeper) ServiceAllowedOperatorsIterator(ctx context.Context, serviceID uint32) (collections.KeySetIterator[collections.Pair[uint32, uint32]], error)

ServiceAllowedOperatorsIterator returns an iterator that iterates over all operators allowed to secure a service

func (*Keeper) ServiceSecuringPoolsIterator

func (k *Keeper) ServiceSecuringPoolsIterator(ctx context.Context, serviceID uint32) (collections.KeySetIterator[collections.Pair[uint32, uint32]], error)

ServiceSecuringPoolsIterator returns an iterator that iterates over all pools allowed to secure the given service.

func (*Keeper) ServicesHooks

func (k *Keeper) ServicesHooks() servicestypes.ServicesHooks

func (*Keeper) SetDelegation

func (k *Keeper) SetDelegation(ctx context.Context, delegation types.Delegation) error

SetDelegation stores the given delegation in the store

func (*Keeper) SetHooks

func (k *Keeper) SetHooks(rs types.RestakingHooks) *Keeper

SetHooks allows to set the reactions hooks

func (*Keeper) SetParams

func (k *Keeper) SetParams(ctx context.Context, params types.Params) error

SetParams sets module parameters

func (*Keeper) SetRestakableDenoms

func (k *Keeper) SetRestakableDenoms(ctx context.Context, denoms []string) error

SetRestakableDenoms sets the denoms that are allowed to be restaked.

func (*Keeper) SetRestakeRestriction

func (k *Keeper) SetRestakeRestriction(restriction types.RestakeRestrictionFn)

SetRestakeRestriction sets a function that checks if a restake operation is allowed.

func (*Keeper) SetUBDQueueTimeSlice

func (k *Keeper) SetUBDQueueTimeSlice(ctx context.Context, timestamp time.Time, keys []types.DTData) error

SetUBDQueueTimeSlice sets a specific unbonding queue timeslice.

func (*Keeper) SetUnbondingDelegation

func (k *Keeper) SetUnbondingDelegation(ctx context.Context, ud types.UnbondingDelegation) ([]byte, error)

SetUnbondingDelegation stores the given unbonding delegation in the store

func (*Keeper) SetUnbondingDelegationByUnbondingID

func (k *Keeper) SetUnbondingDelegationByUnbondingID(ctx context.Context, ubd types.UnbondingDelegation, ubdKey []byte, id uint64) error

SetUnbondingDelegationByUnbondingID sets an index to look up an UnbondingDelegation by the unbondingID of an UnbondingDelegationEntry that it contains Note, it does not set the unbonding delegation itself, use SetUnbondingDelegation(ctx, ubd) for that

func (*Keeper) SetUnbondingDelegationEntry

func (k *Keeper) SetUnbondingDelegationEntry(
	ctx context.Context, data types.UndelegationData, creationHeight int64, minTime time.Time, balance sdk.Coins,
) (types.UnbondingDelegation, error)

SetUnbondingDelegationEntry adds an entry to the unbonding delegation at the given addresses. It creates the unbonding delegation if it does not exist.

func (*Keeper) SetUserPreferences

func (k *Keeper) SetUserPreferences(ctx context.Context, userAddress string, preferences types.UserPreferences) error

SetUserPreferences sets the given preferences for the user having the given address

func (*Keeper) UBDQueueIterator

func (k *Keeper) UBDQueueIterator(ctx context.Context, endTime time.Time) (storetypes.Iterator, error)

UBDQueueIterator returns all the unbonding queue timeslices from time 0 until endTime.

func (*Keeper) Unbond

func (k *Keeper) Unbond(ctx context.Context, data types.UndelegationData) (amount sdk.Coins, err error)

Unbond unbonds a particular delegation and perform associated store operations.

func (*Keeper) UnbondRestakedAssets

func (k *Keeper) UnbondRestakedAssets(ctx context.Context, user sdk.AccAddress, amount sdk.Coins) (time.Time, error)

UnbondRestakedAssets unbonds the provided amount from the user's delegations. The algorithm will go over the user's delegation in the following order: pools, services and operators until the token undelegated matches the provided amount.

func (*Keeper) UnbondingTime

func (k *Keeper) UnbondingTime(ctx context.Context) (time.Duration, error)

UnbondingTime returns the unbonding time.

func (*Keeper) UndelegateFromOperator

func (k *Keeper) UndelegateFromOperator(ctx context.Context, operatorID uint32, amount sdk.Coins, delegator string) (time.Time, error)

UndelegateFromOperator removes the given amount from the operator account and saves the unbonding delegation for the given user

func (*Keeper) UndelegateFromPool

func (k *Keeper) UndelegateFromPool(ctx context.Context, amount sdk.Coin, delegator string) (time.Time, error)

UndelegateFromPool removes the given amount from the pool account and saves the unbonding delegation for the given user

func (*Keeper) UndelegateFromService

func (k *Keeper) UndelegateFromService(ctx context.Context, serviceID uint32, amount sdk.Coins, delegator string) (time.Time, error)

UndelegateFromService removes the given amount from the service account and saves the unbonding delegation for the given user

func (*Keeper) ValidateRestake

func (k *Keeper) ValidateRestake(ctx context.Context, restakerAddress string, restakedAmount sdk.Coins, target types.DelegationTarget) error

ValidateRestake returns nil if the restake operation is allowed, otherwise returns an error.

func (*Keeper) ValidateUnbondAmount

func (k *Keeper) ValidateUnbondAmount(
	ctx context.Context, delAddr string, target types.DelegationTarget, amt sdk.Coins,
) (shares sdk.DecCoins, err error)

ValidateUnbondAmount validates that a given unbond or redelegation amount is valid based on upon the converted shares. If the amount is valid, the total amount of respective shares is returned, otherwise an error is returned.

type OperatorsHooks

type OperatorsHooks struct {
	*Keeper
}

func (*OperatorsHooks) AfterOperatorInactivatingCompleted

func (o *OperatorsHooks) AfterOperatorInactivatingCompleted(ctx context.Context, operatorID uint32) error

AfterOperatorInactivatingCompleted implements types.OperatorsHooks.

func (*OperatorsHooks) AfterOperatorInactivatingStarted

func (o *OperatorsHooks) AfterOperatorInactivatingStarted(ctx context.Context, operatorID uint32) error

AfterOperatorInactivatingStarted implements types.OperatorsHooks.

func (*OperatorsHooks) AfterOperatorReactivated

func (o *OperatorsHooks) AfterOperatorReactivated(ctx context.Context, operatorID uint32) error

AfterOperatorReactivated implements types.OperatorsHooks.

func (*OperatorsHooks) AfterOperatorRegistered

func (o *OperatorsHooks) AfterOperatorRegistered(ctx context.Context, operatorID uint32) error

AfterOperatorRegistered implements types.OperatorsHooks.

func (*OperatorsHooks) BeforeOperatorDeleted

func (o *OperatorsHooks) BeforeOperatorDeleted(ctx context.Context, operatorID uint32) error

BeforeOperatorDeleted implements types.OperatorsHooks.

type Querier

type Querier struct {
	*Keeper
}

func NewQuerier

func NewQuerier(keeper *Keeper) Querier

func (Querier) DelegatorOperator

DelegatorOperator queries the operator for the given delegator address and operator id

func (Querier) DelegatorOperatorDelegations

DelegatorOperatorDelegations queries the operator delegations for the given delegator address

func (Querier) DelegatorOperatorUnbondingDelegations

DelegatorOperatorUnbondingDelegations queries the operator unbonding delegations for the given delegator address

func (Querier) DelegatorOperators

DelegatorOperators queries the operators for the given delegator address

func (Querier) DelegatorPool

DelegatorPool queries the pool for the given delegator address and pool id

func (Querier) DelegatorPoolDelegations

DelegatorPoolDelegations queries the pool delegations for the given delegator address

func (Querier) DelegatorPoolUnbondingDelegations

DelegatorPoolUnbondingDelegations queries the pool unbonding delegations for the given delegator address

func (Querier) DelegatorPools

DelegatorPools queries the pools for the given delegator address

func (Querier) DelegatorService

DelegatorService queries the service for the given delegator address and service id

func (Querier) DelegatorServiceDelegations

DelegatorServiceDelegations queries the service delegations for the given delegator address

func (Querier) DelegatorServiceUnbondingDelegations

DelegatorServiceUnbondingDelegations queries the service unbonding delegations for the given delegator address

func (Querier) DelegatorServices

DelegatorServices queries the services for the given delegator address

func (Querier) OperatorDelegation

OperatorDelegation queries the operator delegation for the given operator id and user address

func (Querier) OperatorDelegations

OperatorDelegations queries the operator delegations for the given operator id

func (Querier) OperatorJoinedServices

OperatorJoinedServices queries the services joined by the operator with the given ID

func (Querier) OperatorUnbondingDelegation

OperatorUnbondingDelegation queries the operator unbonding delegation for the given operator id and user address

func (Querier) OperatorUnbondingDelegations

OperatorUnbondingDelegations queries the operator unbonding delegations for the given operator id

func (Querier) Params

Params queries the restaking module parameters

func (Querier) PoolDelegation

PoolDelegation queries the pool delegation for the given pool id and user address

func (Querier) PoolDelegations

PoolDelegations queries the pool delegations for the given pool id

func (Querier) PoolUnbondingDelegation

PoolUnbondingDelegation queries the pool unbonding delegation for the given pool id and user address

func (Querier) PoolUnbondingDelegations

PoolUnbondingDelegations queries the pool unbonding delegations for the given pool id

func (Querier) ServiceAllowedOperators

ServiceAllowedOperators queries the allowed operators for a given service.

func (Querier) ServiceDelegation

ServiceDelegation queries the service delegation for the given service id and user address

func (Querier) ServiceDelegations

ServiceDelegations queries the service delegations for the given service id

func (Querier) ServiceSecuringPools

ServiceSecuringPools queries the pools that are securing a given service.

func (Querier) ServiceUnbondingDelegation

ServiceUnbondingDelegation queries the service unbonding delegation for the given service id and user address

func (Querier) ServiceUnbondingDelegations

ServiceUnbondingDelegations queries the service unbonding delegations for the given service id

func (Querier) UserPreferences

UserPreferences queries the user preferences for the given user address

type ServicesHooks

type ServicesHooks struct {
	*Keeper
}

func (*ServicesHooks) AfterServiceAccreditationModified

func (h *ServicesHooks) AfterServiceAccreditationModified(ctx context.Context, serviceID uint32) error

AfterServiceAccreditationModified implements types.ServicesHooks.

func (*ServicesHooks) AfterServiceActivated

func (h *ServicesHooks) AfterServiceActivated(ctx context.Context, serviceID uint32) error

AfterServiceActivated implements types.ServicesHooks.

func (*ServicesHooks) AfterServiceCreated

func (h *ServicesHooks) AfterServiceCreated(ctx context.Context, serviceID uint32) error

AfterServiceCreated implements types.ServicesHooks.

func (*ServicesHooks) AfterServiceDeactivated

func (h *ServicesHooks) AfterServiceDeactivated(ctx context.Context, serviceID uint32) error

AfterServiceDeactivated implements types.ServicesHooks.

func (*ServicesHooks) BeforeServiceDeleted

func (h *ServicesHooks) BeforeServiceDeleted(ctx context.Context, serviceID uint32) error

BeforeServiceDeleted implements types.ServicesHooks.

Jump to

Keyboard shortcuts

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