checkers

package
v6.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package checkers provides functions and structures to verify common types and aggregate errors.

Index

Constants

This section is empty.

Variables

View Source
var GovModuleAddr string

GovModuleAddr is set during the first call of ValidateProposal

Functions

func AssertGovAuthority

func AssertGovAuthority(authority string) error

AssertGovAuthority errors is the authority is not the gov module address. Panics if the gov module address is not set during the package initialization.

func BigNumPositive added in v6.6.0

func BigNumPositive[T interface{ IsPositive() bool }](a T, note string) error

func DecInZeroOne

func DecInZeroOne(a sdk.Dec, name string, oneInclusive bool) error

DecInZeroOne asserts that 0 <= a <= 1 when oneInclusive=True, otherwise asserts 0 <= a < 1

func DecMaxDiff

func DecMaxDiff(a, b, maxDiff sdk.Dec, note string) error

func DecNotNegative added in v6.3.0

func DecNotNegative(a sdk.Dec, paramName string) error

DecNotNegative checks if a is defined and a >= 0

func DecPositive added in v6.3.0

func DecPositive(a sdk.Dec, paramName string) error

DecPositive checks if a is defined and a > 0

func Description

func Description(d string) error

func EmergencyGroupAuthority

func EmergencyGroupAuthority(authority string, eg WithEmergencyGroup) (bool, error)

EmergencyGroupAuthority returns true if the authority is EmergencyGroup. Returns false if authority is the x/gov address. Returns error otherwise. Note: we use WithEmergencyGroup rather than emergency group AccAddress to avoid storage read if it's not necessary.

func IntegerMaxDiff

func IntegerMaxDiff[T constraints.Integer](a, b, maxDiff T, note string) error

func IsGovAuthority

func IsGovAuthority(authority string) bool

IsGovAuthority returns true if the authority is the gov module address. Panics if the gov module address is not set during the package initialization.

func Merge added in v6.1.0

func Merge(errs1, errs2 []error) []error

func NumberMin added in v6.6.0

func NumberMin[T constraints.Integer](a, minVal T, note string) error

func NumberPositive added in v6.6.0

func NumberPositive[T constraints.Integer](a T, note string) error

func PositiveCoins added in v6.6.0

func PositiveCoins(note string, coins ...sdk.Coin) []error

PositiveCoins checks if all coins are valida and amount is positive.

func Proposal

func Proposal(authority, description string) error

Proposal checks the format of the description in relation to the authority (x/gov account or other valid account). Authority must be a correct bech32 address.

func RequireDecMaxDiff

func RequireDecMaxDiff(t *testing.T, a, b, maxDiff sdk.Dec, note string)

func Signers

func Signers(signers ...string) []sdk.AccAddress

Signers converts signer bech32 addresses to sdk.AccAddress list. The function ignores errors. It is supposed to be used within Msg.GetSigners implementation.

func ValidateAddr

func ValidateAddr(addr, name string) error

Types

type WithEmergencyGroup

type WithEmergencyGroup interface {
	EmergencyGroup() sdk.AccAddress
}

WithEmergencyGroup is a copy of ugov.WithEmergencyGroup to avoid import cycle

Jump to

Keyboard shortcuts

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