common

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Start time.Time

Functions

func AlertColor

func AlertColor(str string) string

func BigToFloat added in v0.0.25

func BigToFloat(b *big.Int, decimal uint64) float64

BigToFloat converts a big int to float according to its number of decimal digits Example: - BigToFloat(1100, 3) = 1.1 - BigToFloat(1100, 2) = 11 - BigToFloat(1100, 5) = 0.11

func BigToFloatString added in v0.0.25

func BigToFloatString(value *big.Int, decimal uint64) string

func BuildContractCreationTx added in v0.0.25

func BuildContractCreationTx(
	txType uint8,
	nonce uint64,
	ethAmount *big.Int,
	gasLimit uint64,
	priceGwei float64,
	tipCapGwei float64,
	data []byte,
	chainID uint64,
) (tx *types.Transaction)

func BuildExactSendETHTx added in v0.0.25

func BuildExactSendETHTx(
	txType uint8,
	nonce uint64,
	to string,
	ethAmount *big.Int,
	gasLimit uint64,
	priceGwei float64,
	tipCapGwei float64,
	chainID uint64,
) (tx *types.Transaction)

func BuildExactTx added in v0.0.25

func BuildExactTx(
	txType uint8,
	nonce uint64,
	to string,
	ethAmount *big.Int,
	gasLimit uint64,
	priceGwei float64,
	tipCapGwei float64,
	data []byte,
	chainID uint64,
) (tx *types.Transaction)

func BuildTx added in v0.0.25

func BuildTx(
	txType uint8,
	nonce uint64,
	to string,
	ethAmount float64,
	gasLimit uint64,
	priceGwei float64,
	tipCapGwei float64,
	data []byte,
	chainID uint64,
) (tx *types.Transaction)

func DebugObjPrint added in v0.0.30

func DebugObjPrint(obj interface{})

func DebugPrintf added in v0.0.30

func DebugPrintf(format string, a ...any) (n int, err error)

func EthToWei added in v0.0.25

func EthToWei(n float64) *big.Int

EthToWei converts Gwei as a float to Wei as a big int

func FloatStringToBig added in v0.0.25

func FloatStringToBig(value string, decimal uint64) (*big.Int, error)

func FloatToBigInt added in v0.0.25

func FloatToBigInt(amount float64, decimal uint64) *big.Int

FloatToBigInt converts a float to a big int with specific decimal Example: - FloatToBigInt(1, 4) = 10000 - FloatToBigInt(1.234, 4) = 12340

func FloatToInt added in v0.0.25

func FloatToInt(amount float64) int64

func GetEIP1967BeaconABI added in v0.0.30

func GetEIP1967BeaconABI() *abi.ABI

func GetERC20ABI added in v0.0.25

func GetERC20ABI() *abi.ABI

func GetMultiCallABI added in v0.0.25

func GetMultiCallABI() *abi.ABI

func GetSignerAddressFromTx added in v0.0.30

func GetSignerAddressFromTx(tx *types.Transaction, chainID *big.Int) (common.Address, error)

func GweiToWei added in v0.0.25

func GweiToWei(n float64) *big.Int

GweiToWei converts Gwei as a float to Wei as a big int

func HexToAddress added in v0.0.25

func HexToAddress(hex string) common.Address

func HexToAddresses added in v0.0.25

func HexToAddresses(hexes []string) []common.Address

func HexToBig added in v0.0.25

func HexToBig(hex string) *big.Int

func HexToHash added in v0.0.25

func HexToHash(hex string) common.Hash

func InfoColor

func InfoColor(str string) string

func NameWithColor

func NameWithColor(name string) string

func PackERC20Data added in v0.0.25

func PackERC20Data(function string, params ...interface{}) ([]byte, error)

func PrintElapseTime added in v0.0.30

func PrintElapseTime(start time.Time, str string)

func PrintFunctionCall added in v0.0.20

func PrintFunctionCall(fc *FunctionCall)

func PrintTxDetails

func PrintTxDetails(result *TxResult, network Network, writer io.Writer)

func PrintTxSuccessSummary added in v0.0.27

func PrintTxSuccessSummary(result *TxResult, network Network, writer io.Writer)

func PrintVerboseValueToWriter added in v0.0.20

func PrintVerboseValueToWriter(writer io.Writer, values []Value)

func RawTxToHash added in v0.0.25

func RawTxToHash(data string) string

RawTxToHash returns valid hex data of a transaction to transaction hash

func ReadableNumber

func ReadableNumber(value string) string

func StringToBig added in v0.0.25

func StringToBig(input string) *big.Int

func StringToBigInt added in v0.0.25

func StringToBigInt(str string) (*big.Int, error)

func StringToFloat added in v0.0.25

func StringToFloat(input string, decimal uint64) float64

func VerboseAddress

func VerboseAddress(addr Address) string

func VerboseValues

func VerboseValues(values []Value) []string

Types

type ABIDatabase added in v0.0.20

type ABIDatabase func(address string, network Network) (*abi.ABI, error)

type Address

type Address struct {
	Address string
	Desc    string
	Decimal int64
}

type FunctionCall added in v0.0.20

type FunctionCall struct {
	Destination          Address
	Value                *big.Int
	Method               string
	Params               []ParamResult
	DecodedFunctionCalls []*FunctionCall
	Error                string
}

type InternalTx added in v0.0.25

type InternalTx struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Value string `json:"value"`
}

type LogResult

type LogResult struct {
	Name   string
	Topics []TopicResult
	Data   []ParamResult
}

type ParamResult

type ParamResult struct {
	Name  string
	Type  string
	Value []Value
	Tuple []ParamResult
}

type TopicResult

type TopicResult struct {
	Name  string
	Value []Value
}

type Transaction added in v0.0.25

type Transaction struct {
	*types.Transaction
	Extra TxExtraInfo `json:"extra"`
}

func (*Transaction) MarshalJSON added in v0.0.25

func (tx *Transaction) MarshalJSON() ([]byte, error)

func (*Transaction) UnmarshalJSON added in v0.0.25

func (tx *Transaction) UnmarshalJSON(msg []byte) error

type TxExtraInfo added in v0.0.25

type TxExtraInfo struct {
	BlockNumber *string         `json:"blockNumber,omitempty"`
	BlockHash   *common.Hash    `json:"blockHash,omitempty"`
	From        *common.Address `json:"from,omitempty"`
}

type TxInfo added in v0.0.25

type TxInfo struct {
	Status      string
	Tx          *Transaction
	InternalTxs []InternalTx
	Receipt     *types.Receipt
}

func (*TxInfo) GasCost added in v0.0.25

func (self *TxInfo) GasCost() *big.Int

type TxResult

type TxResult struct {
	Hash      string
	Network   string
	Status    string
	From      Address
	Value     string
	To        Address
	Nonce     string
	GasPrice  string
	GasLimit  string
	GasUsed   string
	GasCost   string
	Timestamp string
	TxType    string

	FunctionCall *FunctionCall
	Logs         []LogResult

	Completed bool
	Error     string
}

func NewTxResult

func NewTxResult() *TxResult

type TxResults

type TxResults map[string]*TxResult

func (*TxResults) Write

func (tr *TxResults) Write(filepath string)

type Value

type Value struct {
	Value   string
	Type    string
	Address *Address
}

Jump to

Keyboard shortcuts

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