keeper

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 76 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureSetPoEContractAddressFn

func CaptureSetPoEContractAddressFn() (func(ctx sdk.Context, ctype types.PoEContractType, contractAddr sdk.AccAddress), *[]CapturedPoEContractAddress)

CaptureSetPoEContractAddressFn helper for mocks to capture data when called

func DeliverGenTxs

func DeliverGenTxs(genTxs []json.RawMessage, deliverTx DeliverTxFn, txEncodingConfig client.TxEncodingConfig) error

DeliverGenTxs iterates over all genesis txs, decodes each into a Tx and invokes the provided DeliverTxFn with the decoded Tx.

func ExportGenesis

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

ExportGenesis returns a GenesisState for a given context and keeper.

func InitGenesis

func InitGenesis(
	ctx sdk.Context,
	keeper initer,
	deliverTx DeliverTxFn,
	genesisState types.GenesisState,
	txEncodingConfig client.TxEncodingConfig,
) error

InitGenesis - initialize accounts and deliver genesis transactions

func ModuleLogger

func ModuleLogger(ctx sdk.Context) log.Logger

func NewMsgServerImpl

func NewMsgServerImpl(poeKeeper PoEKeeper, contractKeeper wasmtypes.ContractOpsKeeper, twasmKeeper types.TWasmKeeper) types.MsgServer

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

func NewWasmVMMock

func NewWasmVMMock(mutators ...func(*wasmtesting.MockWasmer)) *wasmtesting.MockWasmer

NewWasmVMMock creates a new WasmerEngine mock with basic ops for create/instantiation set to noops.

func RandomAddress

func RandomAddress(_ *testing.T) sdk.AccAddress

func SwitchPoEContractAddressFn

func SwitchPoEContractAddressFn(t *testing.T, myValsetContract sdk.AccAddress, myStakingContract sdk.AccAddress) func(ctx sdk.Context, ctype types.PoEContractType) (sdk.AccAddress, error)

Types

type CapturedPoEContractAddress

type CapturedPoEContractAddress struct {
	Ctype        types.PoEContractType
	ContractAddr sdk.AccAddress
}

CapturedPoEContractAddress data type

type ContractSource

type ContractSource interface {
	GetPoEContractAddress(sdk.Context, types.PoEContractType) (sdk.AccAddress, error)
}

ContractSource subset of poe keeper

type DistributionContract

type DistributionContract interface {
	// ValidatorOutstandingReward returns amount or 0 for an unknown address
	ValidatorOutstandingReward(ctx sdk.Context, addr sdk.AccAddress) (sdk.Coin, error)
	Address() (sdk.AccAddress, error)
}

type EngagementContract

type EngagementContract interface {
	UpdateAdmin(ctx sdk.Context, newAdmin, sender sdk.AccAddress) error
	// QueryDelegated returns withdrawal address when set
	QueryDelegated(ctx sdk.Context, ownerAddr sdk.AccAddress) (*contract.DelegatedResponse, error)
	Address() (sdk.AccAddress, error)
}

type Keeper

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

func NewKeeper

func NewKeeper(
	marshaler codec.Codec,
	key sdk.StoreKey,
	paramSpace paramtypes.Subspace,
	twasmK types.TWasmKeeper,
	ak types.AuthKeeper,
) Keeper

NewKeeper constructor

func (*Keeper) DeleteHistoricalInfo

func (k *Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64)

DeleteHistoricalInfo deletes the historical info at a given height

func (*Keeper) DistributionContract

func (k *Keeper) DistributionContract(ctx sdk.Context) DistributionContract

func (*Keeper) EngagementContract

func (k *Keeper) EngagementContract(ctx sdk.Context) EngagementContract

func (*Keeper) GetBondDenom

func (k *Keeper) GetBondDenom(ctx sdk.Context) string

func (*Keeper) GetEngagementPoints

func (k *Keeper) GetEngagementPoints(ctx sdk.Context, opAddr sdk.AccAddress) (uint64, error)

GetEngagementPoints read engagement points from contract

func (*Keeper) GetHistoricalInfo

func (k *Keeper) GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)

GetHistoricalInfo gets the historical info at a given height

func (*Keeper) GetInitialValidatorEngagementPoints

func (k *Keeper) GetInitialValidatorEngagementPoints(ctx sdk.Context) (res uint64)

GetInitialValidatorEngagementPoints get number of engagement for any new validator joining post genesis

func (*Keeper) GetParams

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

GetParams returns all parameters as types.Params

func (*Keeper) GetPoEContractAddress

func (k *Keeper) GetPoEContractAddress(ctx sdk.Context, ctype types.PoEContractType) (sdk.AccAddress, error)

GetPoEContractAddress get the stored contract address for the given type or returns an error when not exists (yet)

func (*Keeper) HistoricalEntries

func (k *Keeper) HistoricalEntries(ctx sdk.Context) (res uint32)

HistoricalEntries = number of historical info entries to persist in store

func (*Keeper) InitContractAddressCache added in v1.0.1

func (k *Keeper) InitContractAddressCache(ctx sdk.Context)

InitContractAddressCache adds all poe contracts to the in memory cache

func (*Keeper) IteratePoEContracts

func (k *Keeper) IteratePoEContracts(ctx sdk.Context, cb func(types.PoEContractType, sdk.AccAddress) bool)

IteratePoEContracts for each persisted PoE contract the given callback is called. When the callback returns true, the loop is aborted early.

func (*Keeper) MinimumDelegationAmounts

func (k *Keeper) MinimumDelegationAmounts(ctx sdk.Context) (res sdk.Coins)

func (*Keeper) SetHistoricalInfo

func (k *Keeper) SetHistoricalInfo(ctx sdk.Context, height int64, hi *stakingtypes.HistoricalInfo)

SetHistoricalInfo sets the historical info at a given height

func (*Keeper) SetPoEContractAddress

func (k *Keeper) SetPoEContractAddress(ctx sdk.Context, ctype types.PoEContractType, contractAddr sdk.AccAddress)

SetPoEContractAddress stores the contract address for the given type. If one exists already then it is overwritten.

func (*Keeper) SetValidatorInitialEngagementPoints

func (k *Keeper) SetValidatorInitialEngagementPoints(ctx sdk.Context, opAddr sdk.AccAddress, selfDelegation sdk.Coin) error

SetValidatorInitialEngagementPoints set an initial amount of engagement points for a validator when it matches self delegation preconditions

func (*Keeper) StakeContract

func (k *Keeper) StakeContract(ctx sdk.Context) StakeContract

func (*Keeper) TrackHistoricalInfo

func (k *Keeper) TrackHistoricalInfo(ctx sdk.Context)

TrackHistoricalInfo saves the latest historical-info and deletes the oldest heights that are below pruning height

func (*Keeper) UnbondingTime

func (k *Keeper) UnbondingTime(ctx sdk.Context) time.Duration

UnbondingTime returns the unbonding period from the staking contract

func (*Keeper) ValsetContract

func (k *Keeper) ValsetContract(ctx sdk.Context) ValsetContract

type LegacyDistributionGRPCQuerier added in v1.0.0

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

func NewLegacyDistributionGRPCQuerier

func NewLegacyDistributionGRPCQuerier(keeper ViewKeeper) *LegacyDistributionGRPCQuerier

func (LegacyDistributionGRPCQuerier) CommunityPool added in v1.0.0

func (LegacyDistributionGRPCQuerier) Params added in v1.0.0

Params is not supported. Method returns default distribution module params.

type LegacySlashingGRPCQuerier added in v1.0.0

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

func NewLegacySlashingGRPCQuerier

func NewLegacySlashingGRPCQuerier(keeper ContractSource) *LegacySlashingGRPCQuerier

func (LegacySlashingGRPCQuerier) Params added in v1.0.0

Params is not supported. Method returns default slashing module params.

func (LegacySlashingGRPCQuerier) SigningInfo added in v1.0.0

SigningInfo legacy support for cosmos-sdk signing info. Note that not all field are available on tgrade

func (LegacySlashingGRPCQuerier) SigningInfos added in v1.0.0

SigningInfos is not supported and will return unimplemented error

type LegacyStakingGRPCQuerier added in v1.0.0

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

func NewLegacyStakingGRPCQuerier

func NewLegacyStakingGRPCQuerier(poeKeeper stakingQuerierKeeper) *LegacyStakingGRPCQuerier

func (LegacyStakingGRPCQuerier) Delegation added in v1.0.0

Delegation legacy support for querying the delegate info for a given validator delegator pair Returns response or NotFound error when none exists.

func (LegacyStakingGRPCQuerier) DelegatorDelegations added in v1.0.0

DelegatorDelegations legacy support for querying all delegations of a given delegator address. In PoE only validator operators do self delegations/ unbondings. Result set is either zero or one element.

func (LegacyStakingGRPCQuerier) DelegatorUnbondingDelegations added in v1.0.0

DelegatorUnbondingDelegations legacy support for querying all unbonding delegations of a given delegator address In PoE only validator operators do self delegations/ unbondings. Result set is either zero or one element.

func (LegacyStakingGRPCQuerier) DelegatorValidator added in v1.0.0

func (LegacyStakingGRPCQuerier) DelegatorValidators added in v1.0.0

func (LegacyStakingGRPCQuerier) HistoricalInfo added in v1.0.0

HistoricalInfo queries the historical info for given height

func (LegacyStakingGRPCQuerier) Params added in v1.0.0

func (LegacyStakingGRPCQuerier) Pool added in v1.0.0

func (LegacyStakingGRPCQuerier) Redelegations added in v1.0.0

func (LegacyStakingGRPCQuerier) UnbondingDelegation added in v1.0.0

UnbondingDelegation legacy support for querying the unbonding info for given validator delegator pair Returns response or NotFound error when none exists.

func (LegacyStakingGRPCQuerier) Validator added in v1.0.0

Validator legacy support for querying the validator info for a given validator address. returns NotFound error code when none exists for the given address

func (LegacyStakingGRPCQuerier) ValidatorDelegations added in v1.0.0

ValidatorDelegations legacy support for querying the delegate infos for a given validator. In PoE only validator operators do self delegations/ unbondings. Result set is either zero or one element.

func (LegacyStakingGRPCQuerier) ValidatorUnbondingDelegations added in v1.0.0

ValidatorUnbondingDelegations legacy support for querying the unbonding delegations of a validator. In PoE only validator operators do self delegations/ unbondings. Result set is either zero or one element.

func (LegacyStakingGRPCQuerier) Validators added in v1.0.0

Validators legacy support for querying all validators that match the given status

type PoEKeeper

type PoEKeeper interface {
	ContractSource
	SetValidatorInitialEngagementPoints(ctx sdk.Context, address sdk.AccAddress, value sdk.Coin) error
	GetBondDenom(ctx sdk.Context) string
	ValsetContract(ctx sdk.Context) ValsetContract
}

PoEKeeper is a subset of the keeper

type PoEKeeperMock

type PoEKeeperMock struct {
	GetPoEContractAddressFn               func(ctx sdk.Context, ctype types.PoEContractType) (sdk.AccAddress, error)
	SetValidatorInitialEngagementPointsFn func(ctx sdk.Context, address sdk.AccAddress, value sdk.Coin) error
	SetPoEContractAddressFn               func(ctx sdk.Context, ctype types.PoEContractType, contractAddr sdk.AccAddress)

	GetBondDenomFn         func(ctx sdk.Context) string
	HistoricalEntriesFn    func(ctx sdk.Context) uint32
	UnbondingTimeFn        func(ctx sdk.Context) time.Duration
	GetHistoricalInfoFn    func(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
	DistributionContractFn func(ctx sdk.Context) DistributionContract
	ValsetContractFn       func(ctx sdk.Context) ValsetContract
	StakeContractFn        func(ctx sdk.Context) StakeContract
	EngagementContractFn   func(ctx sdk.Context) EngagementContract
	// contains filtered or unexported fields
}

PoEKeeperMock mocks Keeper methods

func (PoEKeeperMock) DistributionContract

func (m PoEKeeperMock) DistributionContract(ctx sdk.Context) DistributionContract

func (PoEKeeperMock) EngagementContract

func (m PoEKeeperMock) EngagementContract(ctx sdk.Context) EngagementContract

func (PoEKeeperMock) GetBondDenom

func (m PoEKeeperMock) GetBondDenom(ctx sdk.Context) string

func (PoEKeeperMock) GetHistoricalInfo

func (m PoEKeeperMock) GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)

func (PoEKeeperMock) GetPoEContractAddress

func (m PoEKeeperMock) GetPoEContractAddress(ctx sdk.Context, ctype types.PoEContractType) (sdk.AccAddress, error)

func (PoEKeeperMock) HistoricalEntries

func (m PoEKeeperMock) HistoricalEntries(ctx sdk.Context) uint32

func (PoEKeeperMock) SetPoEContractAddress

func (m PoEKeeperMock) SetPoEContractAddress(ctx sdk.Context, ctype types.PoEContractType, contractAddr sdk.AccAddress)

func (PoEKeeperMock) SetValidatorInitialEngagementPoints

func (m PoEKeeperMock) SetValidatorInitialEngagementPoints(ctx sdk.Context, opAddr sdk.AccAddress, points sdk.Coin) error

func (PoEKeeperMock) StakeContract

func (m PoEKeeperMock) StakeContract(ctx sdk.Context) StakeContract

func (PoEKeeperMock) ValsetContract

func (m PoEKeeperMock) ValsetContract(ctx sdk.Context) ValsetContract

type Querier added in v1.0.0

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

func NewQuerier added in v1.0.0

func NewQuerier(keeper ViewKeeper) *Querier

NewQuerier constructor

func (Querier) ContractAddress added in v1.0.0

ContractAddress query PoE contract address for given type

func (Querier) UnbondingPeriod added in v1.0.0

UnbondingPeriod query the global unbonding period

func (Querier) Validator added in v1.0.0

Validator queries validator info for a given validator address. returns NotFound error code when none exists for the given address

func (Querier) ValidatorDelegation added in v1.0.0

func (Querier) Validators added in v1.0.0

Validators query all validators that match the given status.

type SmartQuerierMock

type SmartQuerierMock struct {
	QuerySmartFn func(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)
}

SmartQuerierMock Mock queries to a contract

func (SmartQuerierMock) QuerySmart

func (m SmartQuerierMock) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)

type StakeContract

type StakeContract interface {
	// QueryStakedAmount returns amount in default denom or nil value for an unknown address
	QueryStakedAmount(ctx sdk.Context, opAddr sdk.AccAddress) (*sdk.Int, error)
	QueryStakingUnbondingPeriod(ctx sdk.Context) (time.Duration, error)
	// QueryStakingUnbonding returns the unbondings or empty list for an unknown address
	QueryStakingUnbonding(ctx sdk.Context, opAddr sdk.AccAddress) ([]stakingtypes.UnbondingDelegationEntry, error)
	Address() (sdk.AccAddress, error)
}

type TestKeepers

type TestKeepers struct {
	AccountKeeper  authkeeper.AccountKeeper
	BankKeeper     bankkeeper.Keeper
	GovKeeper      govkeeper.Keeper
	TWasmKeeper    *twasmkeeper.Keeper
	IBCKeeper      *ibckeeper.Keeper
	PoEKeeper      *Keeper
	EncodingConfig simappparams.EncodingConfig
	UpgradeKeeper  upgradekeeper.Keeper
	Faucet         *wasmkeeper.TestFaucet
	BaseApp        *baseapp.BaseApp
}

func CreateDefaultTestInput

func CreateDefaultTestInput(t *testing.T, opts ...wasmkeeper.Option) (sdk.Context, TestKeepers)

CreateDefaultTestInput common settings for CreateTestInput

func CreateTestInput

func CreateTestInput(t *testing.T, isCheckTx bool, supportedFeatures string, opts ...wasmkeeper.Option) (sdk.Context, TestKeepers)

CreateTestInput encoders can be nil to accept the defaults, or set it to override some of the message handlers (like default)

type TwasmKeeperMock

type TwasmKeeperMock struct {
	QuerySmartFn        func(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)
	SudoFn              func(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error)
	GetContractKeeperFn func() wasmtypes.ContractOpsKeeper
}

TwasmKeeperMock mock smart queries and sudo calls

func (TwasmKeeperMock) GetContractKeeper

func (m TwasmKeeperMock) GetContractKeeper() wasmtypes.ContractOpsKeeper

func (TwasmKeeperMock) QuerySmart

func (m TwasmKeeperMock) QuerySmart(ctx sdk.Context, contractAddr sdk.AccAddress, req []byte) ([]byte, error)

func (TwasmKeeperMock) Sudo

func (m TwasmKeeperMock) Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error)

type ValsetContract

type ValsetContract interface {
	ListValidators(ctx sdk.Context, pagination *contract.Paginator) ([]stakingtypes.Validator, contract.PaginationCursor, error)
	QueryValidator(ctx sdk.Context, opAddr sdk.AccAddress) (*stakingtypes.Validator, error)
	ListValidatorSlashing(ctx sdk.Context, opAddr sdk.AccAddress) ([]contract.ValidatorSlashing, error)
	QueryConfig(ctx sdk.Context) (*contract.ValsetConfigResponse, error)
	UpdateAdmin(ctx sdk.Context, new sdk.AccAddress, sender sdk.AccAddress) error
	IterateActiveValidators(ctx sdk.Context, callback func(c contract.ValidatorInfo) bool, pagination *contract.Paginator) error
	Address() (sdk.AccAddress, error)
}

type ViewKeeper

type ViewKeeper interface {
	ContractSource
	GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
	GetBondDenom(ctx sdk.Context) string
	DistributionContract(ctx sdk.Context) DistributionContract
	ValsetContract(ctx sdk.Context) ValsetContract
	StakeContract(ctx sdk.Context) StakeContract
	EngagementContract(ctx sdk.Context) EngagementContract
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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