util

package
v0.0.0-...-c50c231 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var IsAlphanumeric = regexp.MustCompile(`^[0-9a-zA-Z]+$`).MatchString

Functions

func All

func All[T any](set []T) (subsets [][]T)

All returns all combinations for a given string array. This is essentially a powerset of the given set except that the empty set is disregarded.

Example
combinations := All([]string{"A", "B", "C"})
fmt.Println(combinations)
Output:

[[A] [B] [A B] [C] [A C] [B C] [A B C]]

func Combinations

func Combinations[T any](set []T, n int) (subsets [][]T)

Combinations returns combinations of n elements for a given string array. For n < 1, it equals to All and returns all combinations.

func ConvertBigIntFromString

func ConvertBigIntFromString(v0, v1 string) (n0 *big.Int, n1 *big.Int, err error)

func ConvertFloat64ToTokenAmount

func ConvertFloat64ToTokenAmount(amount float64, decimals int) *big.Int

func ConvertHexToDecimalInStringFormat

func ConvertHexToDecimalInStringFormat(hexString string) string

func ConvertTokenAmountToFloat64

func ConvertTokenAmountToFloat64(amt string, tokenDecimal int32) float64

func CreateTransactionOpts

func CreateTransactionOpts(client *ethclient.Client, key *ecdsa.PrivateKey, chainId uint64, caller common.Address) (opts *bind.TransactOpts, err error)

func EncodeAddress

func EncodeAddress(addr common.Address) []byte

func EncodeBigInt

func EncodeBigInt(b *big.Int) []byte

func EncodeBytesString

func EncodeBytesString(v string) []byte

func EncodePacked

func EncodePacked(input ...[]byte) []byte

func EncodeUint256

func EncodeUint256(v string) []byte

func EncodeUint256Array

func EncodeUint256Array(arr []string) []byte

func GenerateIncreaseID

func GenerateIncreaseID() (int64, error)

func GetHTTPClient

func GetHTTPClient() *http.Client

func GetRandomNumber

func GetRandomNumber(min, max int) (int, error)

gen min<= a <= max

func HTTPReq

func HTTPReq(method string, url string, httpClient *http.Client, content []byte, headers map[string]string) (body []byte, err error)

HTTPReq ..

func InTransaction

func InTransaction(db *xorm.Engine, callback dbTransactionFunc) error

func InitLog

func InitLog(logPath, logLever string)

func IsAnAddress

func IsAnAddress(address string) bool

func IsValidTxHash

func IsValidTxHash(txHash string) bool

func Logger

func Logger() *zap.Logger

func PadLeft

func PadLeft(str, pad string, length int) string

func PrivateToAddress

func PrivateToAddress(key string) (string, error)

func RemoveIndex

func RemoveIndex[T any](s []T, index int) []T

func TxWaitToSync

func TxWaitToSync(ctx context.Context, client *ethclient.Client, tx *types.Transaction) (*types.Receipt, bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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