utils

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 21 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 DecodeRawEvmTx

func DecodeRawEvmTx(rawTx string) (*ethtypes.Transaction, 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 FromMnemonicToPrivateKey

func FromMnemonicToPrivateKey(mnemonic, password string) (*ecdsa.PrivateKey, error)

func GetEvmAddressFromAnyFormatAddress

func GetEvmAddressFromAnyFormatAddress(addrs ...string) (evmAddrs []common.Address, err error)

func MarshalPrettyJsonEvmTx

func MarshalPrettyJsonEvmTx(tx *ethtypes.Transaction, option *PrettyMarshalJsonEvmTxOption) ([]byte, error)

func MarshalPrettyJsonEvmTxReceipt

func MarshalPrettyJsonEvmTxReceipt(receipt *ethtypes.Receipt, option *PrettyMarshalJsonEvmTxReceiptOption) ([]byte, error)

func OrderNumberForDenom

func OrderNumberForDenom(denom string) int

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 ReadShortInt

func ReadShortInt(input string) (out *big.Int, err error)

func ReadShortIntOrHex

func ReadShortIntOrHex(input string) (out *big.Int, err error)

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 ResolveBase64Events

func ResolveBase64Events(events []acbitypes.Event) []acbitypes.Event

func TryInjectTranslatedFieldForEvmRpcObjects

func TryInjectTranslatedFieldForEvmRpcObjects(originalObject any, _map map[string]interface{}, key string)

func TryInjectTranslationValueByKey

func TryInjectTranslationValueByKey[K comparable, V any](_map map[K]V, key K, newKeyModifier func(K) K, valueTranslate func(V) (V, bool))

TryInjectTranslationValueByKey tries to translate the value of the given key in the map and put back.

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

type PrettyMarshalJsonEvmTxOption

type PrettyMarshalJsonEvmTxOption struct {
	InjectFrom                bool
	InjectTranslateAbleFields bool
}

type PrettyMarshalJsonEvmTxReceiptOption

type PrettyMarshalJsonEvmTxReceiptOption struct {
	InjectTranslateAbleFields bool
}

type TxHashType

type TxHashType uint8
const (
	TxHashTypeInvalid TxHashType = iota
	TxHashTypeEvm
	TxHashTypeCosmos
)

func DetectTxHashType

func DetectTxHashType(txHash string) TxHashType

Jump to

Keyboard shortcuts

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