util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AmountToString

func AmountToString(amount uint64, decimals uint32) string

AmountToString converts amount to string with specified decimals NB! it is assumed that the decimal places value is sane and verified before calling this method.

func BytesToUint64

func BytesToUint64(b []byte) uint64

func FilterSlice added in v0.4.0

func FilterSlice[T any](src []*T, filterFn func(*T) (bool, error)) ([]*T, error)

FilterSlice generic function for filtering a slice. Keeps elements where filterFn returns true.

func InsertSeparator

func InsertSeparator(value string, reverse bool) string

InsertSeparator inserts apostrophe as thousands separator. The reverse flag defines the direction in which the insertion should happen InsertSeparator("1234", false) => 1'234 (for the integral part) InsertSeparator("1234", true) => 123'4 (for the fractional part)

func StringToAmount

func StringToAmount(amountIn string, decimals uint32) (uint64, error)

StringToAmount converts string and decimals to uint64 amount

func Uint256ToBytes

func Uint256ToBytes(i *uint256.Int) []byte

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

func Uint64ToBytes32

func Uint64ToBytes32(n uint64) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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