util

package
v0.0.0-...-5efa85e Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDelimiter = "_"

Variables

View Source
var (
	ErrInvalidLengthThreshold        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowThreshold          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupThreshold = fmt.Errorf("proto: unexpected end of group")
)

Functions

func HexDecode

func HexDecode(input string) ([]byte, error)

Decode a hex string. Hex string can be optionally prefixed with 0x.

func HexEncode

func HexEncode(input []byte) string

Encode a bytearray as hex string with 0x prefix.

func IndexOf

func IndexOf(strs []string, str string) int

IndexOf returns the index of str in the slice; -1 if not found

func NormalizeString

func NormalizeString(str string) string

NormalizeString normalizes a string as NFKC

func RemoveDuplicatesFromUint64Slice

func RemoveDuplicatesFromUint64Slice(sliceList []uint64) []uint64

func StrNotSet

func StrNotSet(value string) bool

StrNotSet will return true if the string value provided is empty

func ToNumeric

func ToNumeric(i *big.Int) decimal.Decimal

func ValidateString

func ValidateString(str string, forbidden ...string) error

ValidateString checks if the given string is:

1. non-empty 2. entirely composed of utf8 runes 3. normalized as NFKC 4. does not contain any forbidden Unicode code points

func ValidateStringAllowEmpty

func ValidateStringAllowEmpty(str string, forbidden string) error

ValidateStringAllowEmpty checks if the given string is:

1. entirely composed of utf8 runes 2. normalized as NFKC 3. does not contain any forbidden Unicode code points

Types

type Nonce

type Nonce [sha256.Size]byte

Nonce defines a 32 byte array representing a deterministically-generated nonce

func GetNonce

func GetNonce(hash tmbytes.HexBytes, gasMeter sdk.GasMeter) Nonce

GetNonce deterministically calculates a nonce using a hash and gas meter

type Threshold

type Threshold struct {
	// split threshold into Numerator and denominator to avoid floating point
	// errors down the line
	Numerator   int64 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"`
	Denominator int64 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"`
}
var OneThreshold Threshold = NewThreshold(1, 1)

OneThreshold is a threshold that equals to 1

var ZeroThreshold Threshold = NewThreshold(0, 1)

ZeroThreshold is a threshold that equals to 0

func NewThreshold

func NewThreshold(numerator, denominator int64) Threshold

NewThreshold is the constructor for Threshold

func (*Threshold) Descriptor

func (*Threshold) Descriptor() ([]byte, []int)

func (Threshold) GT

func (m Threshold) GT(t Threshold) bool

GT returns true if and only if threshold is greater than the given one

func (Threshold) GTE

func (m Threshold) GTE(t Threshold) bool

GTE returns true if and only if threshold is greater than or equal to the given one

func (Threshold) IsMet

func (m Threshold) IsMet(share sdk.Int, total sdk.Int) bool

IsMet returns true if share >= threshold * total

func (Threshold) LT

func (m Threshold) LT(t Threshold) bool

LT returns true if and only if threshold is less than the given one

func (Threshold) LTE

func (m Threshold) LTE(t Threshold) bool

LTE returns true if and only if threshold is less than or equal to the given one

func (*Threshold) Marshal

func (m *Threshold) Marshal() (dAtA []byte, err error)

func (*Threshold) MarshalTo

func (m *Threshold) MarshalTo(dAtA []byte) (int, error)

func (*Threshold) MarshalToSizedBuffer

func (m *Threshold) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Threshold) ProtoMessage

func (*Threshold) ProtoMessage()

func (*Threshold) Reset

func (m *Threshold) Reset()

func (*Threshold) Size

func (m *Threshold) Size() (n int)

func (Threshold) String

func (m Threshold) String() string

String returns a string representation of the threshold

func (*Threshold) Unmarshal

func (m *Threshold) Unmarshal(dAtA []byte) error

func (Threshold) Validate

func (m Threshold) Validate() error

Validate returns an error if threshold is invalid

func (*Threshold) XXX_DiscardUnknown

func (m *Threshold) XXX_DiscardUnknown()

func (*Threshold) XXX_Marshal

func (m *Threshold) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Threshold) XXX_Merge

func (m *Threshold) XXX_Merge(src proto.Message)

func (*Threshold) XXX_Size

func (m *Threshold) XXX_Size() int

func (*Threshold) XXX_Unmarshal

func (m *Threshold) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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