utils

package
v0.0.0-...-018c514 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DenomFromRequestKey

func DenomFromRequestKey(query []byte, accAddr sdk.AccAddress) (string, error)

func GatherAllKeysFromStore

func GatherAllKeysFromStore(storeObj store.KVStore) []string

func GatherValuesFromStore

func GatherValuesFromStore[T any](storeObj store.KVStore, keyStart, keyEnd []byte, parseValue func([]byte) (T, error)) ([]T, error)

func GatherValuesFromStorePrefix

func GatherValuesFromStorePrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) ([]T, error)

func GetFirstValueAfterPrefixInclusive

func GetFirstValueAfterPrefixInclusive[T any](storeObj store.KVStore, keyStart []byte, parseValue func([]byte) (T, error)) (T, error)

func GetFirstValueInRange

func GetFirstValueInRange[T any](storeObj store.KVStore, keyStart, keyEnd []byte, reverseIterate bool, parseValue func([]byte) (T, error)) (T, error)

func GetIterValuesWithStop

func GetIterValuesWithStop[T any](
	storeObj store.KVStore,
	keyStart []byte,
	keyEnd []byte,
	reverse bool,
	stopFn func([]byte) bool,
	parseValue func([]byte) (T, error),
) ([]T, error)

func GetValuesUntilDerivedStop

func GetValuesUntilDerivedStop[T any](storeObj store.KVStore, keyStart []byte, stopFn func([]byte) bool, parseValue func([]byte) (T, error)) ([]T, error)

func Keys

func Keys[V interface{}](in map[string]V) []string

func MockProofOps

func MockProofOps(_ sdk.Context, _ *ibckeeper.Keeper, _, _ string, _ int64, _ string, _, _ []byte, _ *crypto.ProofOps) error

func MockSelfProofOps

func MockSelfProofOps(_ sdk.Context, _ claimsmanagerkeeper.Keeper, _, _ string, _, _ []byte, _ *crypto.ProofOps) error

func MustGet

func MustGet(storeObj store.KVStore, key []byte, result proto.Message)

MustGet gets key from store by mutating result Panics on any error.

func MustGetDec

func MustGetDec(storeObj store.KVStore, key []byte) sdk.Dec

MustGetDec gets dec value from store at key. Panics on any error.

func MustSet

func MustSet(storeObj store.KVStore, key []byte, value proto.Message)

MustSet runs store.Set(key, proto.Marshal(value)) but panics on any error.

func MustSetDec

func MustSetDec(storeObj store.KVStore, key []byte, value sdk.Dec)

MustSetDec sets dec value to store at key. Panics on any error.

func SortSlice

func SortSlice[T constraints.Ordered](s []T)

SortSlice sorts a slice of type T elements that implement constraints.Ordered. Mutates input slice s.

func Unique

func Unique[V interface{}](in []V) []V

func ValidateProofOps

func ValidateProofOps(
	ctx sdk.Context,
	ibcKeeper *ibckeeper.Keeper,
	connectionID,
	chainID string,
	height int64,
	module string,
	key,
	data []byte,
	proofOps *crypto.ProofOps,
) error

func ValidateSelfProofOps

func ValidateSelfProofOps(ctx sdk.Context, claimsKeeper claimsmanagerkeeper.Keeper, consensusStateKey, module string, key, data []byte, proofOps *crypto.ProofOps) error

func Verify

func Verify(
	trustedHeader *types.SignedHeader,
	trustedVals *types.ValidatorSet,
	untrustedHeader *types.SignedHeader,
	untrustedVals *types.ValidatorSet,
	trustingPeriod time.Duration,
	now time.Time,
	maxClockDrift time.Duration,
	trustLevel tmmath.Fraction,
) error

Verify combines both VerifyAdjacent and VerifyNonAdjacent functions.

func VerifyAdjacent

func VerifyAdjacent(
	trustedHeader *types.SignedHeader,
	untrustedHeader *types.SignedHeader,
	untrustedVals *types.ValidatorSet,
	trustingPeriod time.Duration,
	now time.Time,
	maxClockDrift time.Duration,
) error

func VerifyNonAdjacent

func VerifyNonAdjacent(
	trustedHeader *types.SignedHeader,
	trustedVals *types.ValidatorSet,
	untrustedHeader *types.SignedHeader,
	untrustedVals *types.ValidatorSet,
	trustingPeriod time.Duration,
	now time.Time,
	_ time.Duration,
	trustLevel tmmath.Fraction,
) error

VerifyNonAdjacent is identical to VerifyNonAdjacent in tendermint/tendermint/light/verifier.go, with the exception that it does not attempt to validate that the block is _newer_ than the current consensus state.

Types

type ContextKey

type ContextKey string

func (ContextKey) String

func (c ContextKey) String() string

type ProofOpsFn

type ProofOpsFn func(ctx sdk.Context, ibcKeeper *ibckeeper.Keeper, connectionID, chainID string, height int64, module string, key []byte, data []byte, proofOps *crypto.ProofOps) error

type SelfProofOpsFn

type SelfProofOpsFn func(ctx sdk.Context, claimsKeeper claimsmanagerkeeper.Keeper, consensusStateKey, module string, key []byte, data []byte, proofOps *crypto.ProofOps) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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