util

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(array []string, match string) bool

func ContainsUint64

func ContainsUint64(array []uint64, match uint64) bool

func GetByteKey

func GetByteKey(keys ...interface{}) []byte

func MaxUInt64

func MaxUInt64(a uint64, b uint64) uint64

func MinInt

func MinInt(a int, b int) int

func MinUInt64

func MinUInt64(a uint64, b uint64) uint64

func PanicHalt

func PanicHalt(upgradeKeeper UpgradeKeeper, ctx sdk.Context, message string)

PanicHalt performs an emergency upgrade which immediately halts the chain The Team has to come up with a solution and develop a patch to handle the update. In a fully bug-free code this function will never be called. This function is there to do assertions and in case of a violation it will shut down the chain gracefully, to make it easier to recover from a fatal error

func RemoveFromStringArrayStable

func RemoveFromStringArrayStable(array []string, match string) ([]string, bool)

func RemoveFromUint64ArrayStable

func RemoveFromUint64ArrayStable(array []uint64, match uint64) ([]uint64, bool)

RemoveFromUint64ArrayStable removes the first occurrence of `match` in the given `array`. It returns True if one element was removed. False otherwise. The order of the remaining elements is not changed.

func TransferFromAddressToAddress

func TransferFromAddressToAddress(
	bankKeeper BankKeeper,
	ctx sdk.Context,
	fromAddress string,
	toAddress string,
	amount uint64,
) error

TransferFromAddressToAddress sends tokens from the given address to a specified address.

func TransferFromAddressToModule

func TransferFromAddressToModule(
	bankKeeper BankKeeper,
	ctx sdk.Context,
	address string,
	module string,
	amount uint64,
) error

TransferFromAddressToModule sends tokens from a specified address to the given module.

func TransferFromAddressToTreasury

func TransferFromAddressToTreasury(distrKeeper DistrKeeper, ctx sdk.Context, address string, amount uint64) error

TransferFromAddressToTreasury sends tokens from a given address to the treasury (community spend pool).

func TransferFromModuleToAddress

func TransferFromModuleToAddress(
	bankKeeper BankKeeper,
	ctx sdk.Context,
	module string,
	address string,
	amount uint64,
) error

TransferFromModuleToAddress sends tokens from the given module to a specified address.

func TransferFromModuleToModule

func TransferFromModuleToModule(
	bankKeeper BankKeeper,
	ctx sdk.Context,
	fromModule string,
	toModule string,
	amount uint64,
) error

TransferFromModuleToModule sends tokens from a specified module to the given module.

func TransferFromModuleToTreasury

func TransferFromModuleToTreasury(
	accountKeeper AccountKeeper,
	distrKeeper DistrKeeper,
	ctx sdk.Context,
	module string,
	amount uint64,
) error

TransferFromModuleToTreasury sends tokens from a module to the treasury (community spend pool).

func ValidateDecimal added in v1.1.0

func ValidateDecimal(i interface{}) error

func ValidateNumber added in v1.1.0

func ValidateNumber(i interface{}) error

func ValidatePercentage

func ValidatePercentage(i interface{}) error

func ValidatePositiveNumber added in v1.1.0

func ValidatePositiveNumber(i interface{}) error

Types

type AccountKeeper

type AccountKeeper interface {
	GetModuleAddress(moduleName string) sdk.AccAddress
}

type BankKeeper

type BankKeeper interface {
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromModuleToAccount(
		ctx sdk.Context,
		senderModule string,
		recipientAddr sdk.AccAddress,
		amt sdk.Coins,
	) error
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	SendCoinsFromAccountToModule(
		ctx sdk.Context,
		senderAddr sdk.AccAddress,
		recipientModule string,
		amt sdk.Coins,
	) error
}

type DistrKeeper

type DistrKeeper interface {
	FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}

type KeyPrefixBuilder

type KeyPrefixBuilder struct {
	Key []byte
}

func (*KeyPrefixBuilder) AInt

func (k *KeyPrefixBuilder) AInt(n uint64)

func (*KeyPrefixBuilder) AString

func (k *KeyPrefixBuilder) AString(s string)

type UpgradeKeeper

type UpgradeKeeper interface {
	ScheduleUpgrade(ctx sdk.Context, plan upgradeTypes.Plan) error
}

Jump to

Keyboard shortcuts

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