util

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: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ETH_ADDR                  string = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
	MAX_ADDR                  string = "0xffffffffffffffffffffffffffffffffffffffff"
	MIN_ADDR                  string = "0x00000000000000ffffffffffffffffffffffffff"
	ETHEREUM_MAINNET_NODE_VAR string = "ETHEREUM_MAINNET_NODE"
	ETHEREUM_ROPSTEN_NODE_VAR string = "ETHEREUM_ROPSTEN_NODE"
	TOMO_MAINNET_NODE_VAR     string = "TOMO_MAINNET_NODE"
	ETHEREUM_KOVAN_NODE_VAR   string = "ETHEREUM_KOVAN_NODE"
	ETHEREUM_RINKEBY_NODE_VAR string = "ETHEREUM_RINKEBY_NODE"
	BSC_MAINNET_NODE_VAR      string = "BSC_MAINNET_NODE"
	BSC_TESTNET_NODE_VAR      string = "BSC_TESTNET_NODE"
	ETHERSCAN_API_KEY_VAR     string = "ETHERSCAN_API_KEY"
	BSCSCAN_API_KEY_VAR       string = "BSCSCAN_API_KEY"
)

Variables

View Source
var ERC20_METHODS = [...]string{
	"name",
	"symbol",
	"decimals",
	"totalSupply",
	"balanceOf",
	"transfer",
	"transferFrom",
	"approve",
	"allowance",
}
View Source
var PROXY_METHODS = [...]string{
	"implementation",
	"upgradeTo",
	"upgradeToAndCall",
}

Functions

func AnalyzeAndPrint added in v0.0.9

func AnalyzeAndPrint(
	reader *reader.EthReader,
	analyzer TxAnalyzer,
	tx string,
	network Network,
	forceERC20ABI bool,
	customABI string,
	a *abi.ABI,
	customABIs map[string]*abi.ABI,
	degenMode bool,
) *TxResult

func AnalyzeMethodCallAndPrint added in v0.0.9

func AnalyzeMethodCallAndPrint(
	analyzer TxAnalyzer,
	value *big.Int,
	destination string,
	data []byte,
	customABIs map[string]*abi.ABI,
	network Network,
) (fc *FunctionCall)

func CalculateTimeDurationFromBlock added in v0.0.9

func CalculateTimeDurationFromBlock(network Network, from, to uint64) time.Duration

func ConfigToABI added in v0.0.18

func ConfigToABI(
	address string,
	forceERC20ABI bool,
	customABI string,
	network Network,
) (*abi.ABI, error)

func ConvertEthereumTypeToInputString added in v0.0.20

func ConvertEthereumTypeToInputString(t abi.Type, value interface{}) (string, error)

func ConvertParamStrToArray added in v0.0.30

func ConvertParamStrToArray(
	name string,
	t abi.Type,
	str string,
	network Network,
) ([]interface{}, error)

func ConvertParamStrToFixedByteType added in v0.0.15

func ConvertParamStrToFixedByteType(
	name string,
	t abi.Type,
	strs []string,
	network Network,
) (interface{}, error)

func ConvertParamStrToTupleType added in v0.0.30

func ConvertParamStrToTupleType(
	name string,
	t abi.Type,
	str string,
	network Network,
) (interface{}, error)

func ConvertParamStrToType added in v0.0.10

func ConvertParamStrToType(
	name string,
	t abi.Type,
	str string,
	network Network,
) (interface{}, error)

func ConvertToAddress added in v0.0.10

func ConvertToAddress(str string) (common.Address, error)

func ConvertToBig added in v0.0.10

func ConvertToBig(str string, network Network) (*big.Int, error)

func ConvertToBool added in v0.0.10

func ConvertToBool(str string) (bool, error)

func ConvertToBytes added in v0.0.10

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

func ConvertToFixedBytes added in v0.0.10

func ConvertToFixedBytes(str string, size int) (interface{}, error)

func ConvertToHash added in v0.0.10

func ConvertToHash(str string) (common.Hash, error)

func ConvertToInt added in v0.0.10

func ConvertToInt(str string, size int) (interface{}, error)

func ConvertToIntOrBig added in v0.0.10

func ConvertToIntOrBig(str string, size int, network Network) (interface{}, error)

func ConvertToString added in v0.0.10

func ConvertToString(str string) (string, error)

func ConvertToUint added in v0.0.10

func ConvertToUint(str string, size int) (interface{}, error)

func ConvertToUintOrBig added in v0.0.10

func ConvertToUintOrBig(str string, size int, network Network) (interface{}, error)

func DisplayBroadcastedTx added in v0.0.9

func DisplayBroadcastedTx(t *types.Transaction, broadcasted bool, err error, network Network)

func DisplayWaitAnalyze

func DisplayWaitAnalyze(
	reader *reader.EthReader,
	analyzer TxAnalyzer,
	t *types.Transaction,
	broadcasted bool,
	err error,
	network Network,
	a *abi.ABI,
	customABIs map[string]*abi.ABI,
	degenMode bool,
)

func EthBroadcaster added in v0.0.9

func EthBroadcaster(network Network) (*broadcaster.Broadcaster, error)

func EthReader

func EthReader(network Network) (*reader.EthReader, error)

func EthTxMonitor added in v0.0.9

func EthTxMonitor(network Network) (*monitor.TxMonitor, error)

func GetABI

func GetABI(addr string, network Network) (*abi.ABI, error)

func GetABIFromBytes added in v0.0.17

func GetABIFromBytes(abiBytes []byte) (*abi.ABI, error)

func GetABIFromString added in v0.0.17

func GetABIFromString(abiStr string) (*abi.ABI, error)

func GetABIString added in v0.0.18

func GetABIString(addr string, network Network) (string, error)

func GetABIStringBypassCache added in v0.0.20

func GetABIStringBypassCache(addr string, network Network) (string, error)

func GetABIStringFromFile added in v0.0.17

func GetABIStringFromFile(filepath string) (string, error)

func GetABIStringFromURL added in v0.0.17

func GetABIStringFromURL(url string) (string, error)

func GetAddressFromString added in v0.0.9

func GetAddressFromString(str string) (addr string, name string, err error)

func GetBalances added in v0.0.21

func GetBalances(
	wallets []string,
	tokens []string,
	network Network,
) (balances map[common.Address][]*big.Int, block int64, err error)

func GetCoinGeckoRateInUSD added in v0.0.18

func GetCoinGeckoRateInUSD(token string) (float64, error)

func GetERC20Decimal added in v0.0.2

func GetERC20Decimal(addr string, network Network) (uint64, error)

func GetERC20Symbol added in v0.0.27

func GetERC20Symbol(addr string, network Network) (string, error)

func GetETHPriceInUSD added in v0.0.19

func GetETHPriceInUSD() (float64, error)

func GetExactAddressFromDatabases added in v0.0.18

func GetExactAddressFromDatabases(str string) (addrs []string, names []string, scores []int)

func GetGnosisMsigABI added in v0.0.20

func GetGnosisMsigABI() *abi.ABI

func GetGnosisMsigDeployByteCode added in v0.0.20

func GetGnosisMsigDeployByteCode(ctorBytes []byte) ([]byte, error)

func GetHistoryBalances added in v0.0.21

func GetHistoryBalances(
	atBlock int64,
	wallets []string,
	tokens []string,
	network Network,
) (balances map[common.Address][]*big.Int, block int64, err error)

func GetJarvisAddress added in v0.0.18

func GetJarvisAddress(addr string, network Network) Address

func GetJarvisValue added in v0.0.18

func GetJarvisValue(value string, network Network) Value

func GetMatchingAddress added in v0.0.17

func GetMatchingAddress(str string) (addr string, name string, err error)

func GetMatchingAddresses added in v0.0.17

func GetMatchingAddresses(str string) (addrs []string, names []string, scores []int)

func GetNodes added in v0.0.9

func GetNodes(network Network) (map[string]string, error)

func InterpretInput added in v0.0.20

func InterpretInput(input string, network Network) (string, error)

func IsAddress

func IsAddress(addr string) bool

func IsContract added in v0.0.20

func IsContract(addr string, network Network) (bool, error)

func IsERC20 added in v0.0.11

func IsERC20(addr string, network Network) (bool, error)

func IsERC20ABI added in v0.0.27

func IsERC20ABI(a *abi.ABI) bool

func IsGnosisMultisig

func IsGnosisMultisig(a *abi.ABI) (bool, error)

func IsInlineScript added in v0.0.20

func IsInlineScript(input string) bool

func IsProxyABI added in v0.0.30

func IsProxyABI(a *abi.ABI) bool

func NewMultiCall added in v0.0.21

func NewMultiCall(network Network) (*reader.MultipleCall, error)

func ParamToBigInt added in v0.0.2

func ParamToBigInt(param string) (*big.Int, error)

func PathToAddress

func PathToAddress(path string) (string, error)

func ReadCustomABI added in v0.0.16

func ReadCustomABI(addr string, pathOrAddress string, network Network) (a *abi.ABI, err error)

func ReadCustomABIString added in v0.0.17

func ReadCustomABIString(
	addr string,
	pathOrAddress string,
	network Network,
) (str string, err error)

func ScanForAddresses

func ScanForAddresses(para string) []string

func ScanForTxs

func ScanForTxs(para string) []string

func SplitInputParamStr added in v0.0.30

func SplitInputParamStr(input string) (result []string, err error)

func ValueToAmountAndCurrency

func ValueToAmountAndCurrency(value string) (string, string, error)

Split value by space, if the lowercase of first element is 'all', the amount will be "ALL", indicating a balance query is needed else, return the string as the amount. Join whats left by space and trim by space, if it is empty, interpret it as ETH. Error will not be nil if it fails to proceed all of above steps.

Types

type CMD added in v0.0.20

type CMD int
const (
	BalanceOf CMD = iota
	TokenBalance
)

type GrammarTree added in v0.0.20

type GrammarTree struct {
	Cmd    CMD
	Params []GrammarTree
}

func ParseGrammarTree added in v0.0.20

func ParseGrammarTree(input string) (*GrammarTree, error)

func (*GrammarTree) Execute added in v0.0.20

func (gt *GrammarTree) Execute() (result string, t abi.Type, err error)

type TxAnalyzer added in v0.0.18

type TxAnalyzer interface {
	AnalyzeFunctionCallRecursively(lookupABI ABIDatabase, value *big.Int, destination string, data []byte, customABIs map[string]*abi.ABI) (fc *FunctionCall)
	AnalyzeMethodCall(a *abi.ABI, data []byte) (method string, params []ParamResult, err error)
	AnalyzeOffline(txinfo *TxInfo, lookupABI ABIDatabase, customABIs map[string]*abi.ABI, isContract bool, network Network) *TxResult
	ParamAsJarvisValues(t abi.Type, value interface{}) []Value
}

Directories

Path Synopsis
trezoreum/trezor
Package trezor contains the wire protocol.
Package trezor contains the wire protocol.
usb
Package usb provide interfaces for generic USB devices.
Package usb provide interfaces for generic USB devices.

Jump to

Keyboard shortcuts

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