types

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateRangeIncludes

func DateRangeIncludes(startTime, endTime, targetTime time.Time) bool

DateRangeIncludes returns true if the target date included on the start, end time range. End time is exclusive and start time is inclusive.

func DateRangesOverlap

func DateRangesOverlap(startTimeA, endTimeA, startTimeB, endTimeB time.Time) bool

DateRangesOverlap returns true if two date ranges overlap each other. End time is exclusive and start time is inclusive.

func DecApproxEqual

func DecApproxEqual(a, b sdk.Dec) bool

DecApproxEqual returns true if a and b are approximately equal, which means the diff ratio is equal or less than 0.1%.

func DecApproxSqrt

func DecApproxSqrt(x sdk.Dec) (r sdk.Dec)

DecApproxSqrt returns an approximate estimation of x's square root.

func GenAndDeliverTx

GenAndDeliverTx generates a transactions and delivers it.

func GenAndDeliverTxWithFees

func GenAndDeliverTxWithFees(txCtx simulation.OperationInput, gas uint64, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error)

GenAndDeliverTxWithFees generates a transaction with given fee and delivers it.

func GetShareValue

func GetShareValue(amount sdk.Int, ratio sdk.Dec) sdk.Int

GetShareValue multiplies with truncation by receiving int amount and decimal ratio and returns int result.

func IsOverflow

func IsOverflow(r interface{}) bool

IsOverflow returns true if the panic value can be interpreted as an overflow.

func PP

func PP(data interface{})

func ParseCoin

func ParseCoin(s string) sdk.Coin

ParseCoin parses and returns sdk.Coin.

func ParseCoins

func ParseCoins(s string) sdk.Coins

ParseCoins parses and returns sdk.Coins.

func ParseDec

func ParseDec(s string) sdk.Dec

ParseDec is a shortcut for sdk.MustNewDecFromStr.

func ParseDecCoins

func ParseDecCoins(s string) sdk.DecCoins

ParseDecCoins parses and returns sdk.DecCoins.

func ParseDecP

func ParseDecP(s string) *sdk.Dec

ParseDecP is like ParseDec, but it returns a pointer to sdk.Dec.

func ParseTime

func ParseTime(s string) time.Time

ParseTime parses and returns time.Time in time.RFC3339 format.

func RandomDec

func RandomDec(r *rand.Rand, min, max sdk.Dec) sdk.Dec

RandomDec returns a random decimal in the half-open interval [min, max).

func RandomInt

func RandomInt(r *rand.Rand, min, max sdk.Int) sdk.Int

RandomInt returns a random integer in the half-open interval [min, max).

func SafeMath

func SafeMath(f, onOverflow func())

SafeMath runs f in safe mode, which means that any panics occurred inside f gets caught by recover() and if the panic was an overflow, onOverflow is run. Otherwise, if the panic was not an overflow, then SafeMath will re-throw the panic.

func ShuffleSimAccounts

func ShuffleSimAccounts(r *rand.Rand, accs []simtypes.Account) []simtypes.Account

ShuffleSimAccounts returns randomly shuffled simulation accounts.

func TestAddress

func TestAddress(addrNum int) sdk.AccAddress

TestAddress returns an address for testing purpose. TestAddress returns same address when addrNum is same.

Types

type StrIntMap

type StrIntMap map[string]sdk.Int

func (StrIntMap) AddOrSet

func (m StrIntMap) AddOrSet(key string, value sdk.Int)

AddOrSet Set when the key not existed on the map or add existed value of the key.

Jump to

Keyboard shortcuts

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