utils

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbiDecodeString

func AbiDecodeString(bz []byte) (string, error)

func AbiEncodeString

func AbiEncodeString(str string) ([]byte, error)

func BeautifyJson

func BeautifyJson(bzJson []byte) ([]byte, error)

BeautifyJson beautifies the given json.

func ConvertDisplayWithExponentIntoRaw

func ConvertDisplayWithExponentIntoRaw(display string, exponent int, decimalsPoint rune) (number, highNumber, lowNumber *big.Int, err error)

func ConvertNumberIntoDisplayWithExponent

func ConvertNumberIntoDisplayWithExponent(number *big.Int, exponent int) (display string, highNumber, lowNumber *big.Int, err error)

func ExitOnErr

func ExitOnErr(err error, msg string)

ExitOnErr exit the app with code 1 if error. Or does nothing if no error.

func PanicIfErr

func PanicIfErr(err error, msg string)

PanicIfErr raises a panic. If the `err` is nil, this method does nothing

func PrintfStdErr

func PrintfStdErr(format string, a ...any)

PrintfStdErr does printf to StdErr

func PrintlnStdErr

func PrintlnStdErr(a ...any)

PrintlnStdErr does println to StdErr

func ProvidedArgsOrFromPipe

func ProvidedArgsOrFromPipe(providedArgs []string) (outputArgs []string, err error)

ProvidedArgsOrFromPipe will prioritize provided args, if not provided, it will try to read from pipe.

func RequireArgs

func RequireArgs(args []string, cmd *cobra.Command)

RequireArgs will exit program if no arg provided.

func RequireExactArgsCount

func RequireExactArgsCount(args []string, want int, cmd *cobra.Command)

RequireExactArgsCount will exit program if number of arguments is not equal to want.

func TryPrintBeautyJson

func TryPrintBeautyJson(bz []byte)

TryPrintBeautyJson tries to beautify the given json and print it. If failed to beautify, it will print the original json.

Types

This section is empty.

Jump to

Keyboard shortcuts

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