utils

package
v1.5.9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: LGPL-3.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcBlockConfirmationRisk added in v0.1.1

func CalcBlockConfirmationRisk(rawConfirmationRisk *big.Int) *big.Float

CalcBlockConfirmationRisk calculates block revert rate

func FormatJson added in v1.5.4

func FormatJson(input string) string

Format Json into string with orderd by field names

func Get1stBoolIfy added in v1.5.4

func Get1stBoolIfy(values []bool) bool

func GetMapSortedKeys added in v0.1.1

func GetMapSortedKeys(m map[string]interface{}) []string

func GetObjFileds added in v0.1.1

func GetObjFileds(obj interface{}) []string

func GetObjJsonFieldTags added in v0.1.1

func GetObjJsonFieldTags(obj interface{}) []string

func Has0xPrefix added in v0.1.1

func Has0xPrefix(input string) bool

Has0xPrefix returns true if input starts with '0x' or '0X'

func HexStringToBytes added in v0.1.1

func HexStringToBytes(hexStr string) (hexutil.Bytes, error)

HexStringToBytes converts hex string to bytes

func IsNil added in v0.1.1

func IsNil(i interface{}) bool

IsNil checks if interface object is nil

func Keccak256

func Keccak256(hexStr string) (string, error)

Keccak256 hashes hex string by keccak256 and returns it's hash value

func PanicIfErr added in v0.1.1

func PanicIfErr(err error)

PanicIfErr panic and reports error message

func PanicIfErrf added in v0.1.1

func PanicIfErrf(err error, msg string, args ...interface{})

PanicIfErrf panic and reports error message with args

func PrettyJSON added in v0.1.1

func PrettyJSON(value interface{}) string

PrettyJSON json marshal value and pretty with indent

func PrivateKeyToPublicKey

func PrivateKeyToPublicKey(privateKey string) string

PrivateKeyToPublicKey calculates public key from private key

func PublicKeyToCommonAddress added in v0.1.1

func PublicKeyToCommonAddress(publicKey string) (common.Address, error)

PublicKeyToCommonAddress generate address from public key

Account address in conflux starts with '0x1'

Types

type RpcError added in v0.1.1

type RpcError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func ToRpcError added in v0.1.1

func ToRpcError(origin error) (*RpcError, error)

ToRpcError converts a error to JsonError

func (*RpcError) Error added in v0.1.1

func (e *RpcError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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