utils

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 65

Documentation

Index

Constants

View Source
const (
	AnvilNetwork Network = "anvil"
	Ethereum     Network = "ethereum"
	Bsc          Network = "bsc"
	Polygon      Network = "polygon"
	Avalanche    Network = "avalanche"
	Fantom       Network = "fantom"
	Arbitrum     Network = "arbitrum"
	Optimism     Network = "optimism"

	// Mainnets
	EthereumNetworkID  NetworkID = 1
	BscNetworkID       NetworkID = 56
	PolygonNetworkID   NetworkID = 137
	AvalancheNetworkID NetworkID = 43114
	FantomNetworkID    NetworkID = 250
	ArbitrumNetworkID  NetworkID = 42161
	OptimismNetworkID  NetworkID = 10

	// Testnets
	RopstenNetworkID    NetworkID = 3
	RinkebyNetworkID    NetworkID = 4
	GoerliNetworkID     NetworkID = 5
	KovanNetworkID      NetworkID = 42
	BscTestnetNetworkID NetworkID = 97
	MumbaiNetworkID     NetworkID = 80001
	FujiNetworkID       NetworkID = 43113
	FantomTestNetworkID NetworkID = 4002
	ArbitrumRinkebyID   NetworkID = 421611
	OptimismKovanID     NetworkID = 69
)
View Source
const (
	HeadStrategy    Strategy = "head"
	ArchiveStrategy Strategy = "archive"

	ZeroAddressRecipient AddressType = "zero_address"
	AddressRecipient     AddressType = "address"
	ContractRecipient    AddressType = "contract"

	UnknownTransactionMethodType TransactionMethodType = "unknown"
	ContractCreationType         TransactionMethodType = "contract_creation"
	TransferMethodType           TransactionMethodType = "transfer"

	UnknownLogEventType LogEventType = "unknown"

	AnvilSimulator SimulatorType = "anvil"

	SimulatorAccountType AccountType = "simulator"
	SimpleAccountType    AccountType = "simple"
	KeystoreAccountType  AccountType = "keystore"
)

Variables

This section is empty.

Functions

func DumpNodeNoExit

func DumpNodeNoExit(whatever any)

DumpNodeNoExit prints a formatted JSON representation of the provided interface without exiting the program. This function is primarily used for debugging purposes.

func DumpNodeWithExit

func DumpNodeWithExit(whatever any)

DumpNodeWithExit prints a formatted JSON representation of the provided interface and exits the program. This function is primarily used for debugging purposes.

func EventToABI added in v0.3.2

func EventToABI(method *abi.Event) (string, error)

EventToABI converts a Event object to its JSON ABI representation.

func GetCurrentPath added in v0.3.2

func GetCurrentPath() (string, error)

GetCurrentPath returns the current working directory.

func GetLocalSourcesPath

func GetLocalSourcesPath() string

GetLocalSourcesPath returns the absolute path to the local sources directory.

func IsSemanticVersionGreaterOrEqualTo added in v0.3.1

func IsSemanticVersionGreaterOrEqualTo(versionStr string, version SemanticVersion) bool

IsSemanticVersionGreaterOrEqualTo checks if the version represented by the string is greater than or equal to the provided SemanticVersion.

func IsSemanticVersionLowerOrEqualTo added in v0.3.1

func IsSemanticVersionLowerOrEqualTo(versionStr string, version SemanticVersion) bool

IsSemanticVersionLowerOrEqualTo checks if the version represented by the string is lower than or equal to the provided SemanticVersion.

func Keccak256 added in v0.3.1

func Keccak256(data []byte) []byte

Keccak256 returns the Keccak256 hash of the input data.

func MethodToABI added in v0.3.2

func MethodToABI(method *abi.Method) (string, error)

MethodToABI converts a Method object to its JSON ABI representation.

func PathExists added in v0.3.2

func PathExists(path string) bool

PathExists returns true if the given path exists.

func SimplifyImportPaths

func SimplifyImportPaths(content string) string

SimplifyImportPaths simplifies the paths in import statements as file will already be present in the directory for future consumption and is rather corrupted for import paths to stay the same.

func StripExtraSPDXLines

func StripExtraSPDXLines(content string) string

StripExtraSPDXLines removes the extra SPDX lines from the content. This is used when passing combined source to the solc compiler as it will complain about the extra SPDX lines.

func StripImportPaths

func StripImportPaths(content string) string

StripImportPaths removes the import paths entirely from the content.

func ToABI added in v0.3.2

func ToABI(data []byte) (*abi.ABI, error)

ToABI converts the ABI object into an ethereum/go-ethereum ABI object.

func ToJSON

func ToJSON(data any) ([]byte, error)

ToJSON converts a Go struct to its JSON representation.

func ToJSONPretty

func ToJSONPretty(data any) ([]byte, error)

ToJSONPretty returns a pretty-printed JSON representation of the provided interface. This function is primarily used for debugging purposes.

func ToProtoJSON

func ToProtoJSON(data any) ([]byte, error)

ToProtoJSON converts a Go struct to its JSON representation.

func WriteToFile

func WriteToFile(path string, data []byte) error

WriteToFile writes the provided data byte array to a file at the provided path.

Types

type AccountType added in v0.3.2

type AccountType string

func (AccountType) String added in v0.3.2

func (t AccountType) String() string

type AddressType added in v0.3.2

type AddressType string

func (AddressType) String added in v0.3.2

func (r AddressType) String() string

type ArgumentABI added in v0.3.2

type ArgumentABI struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Indexed bool   `json:"indexed,omitempty"`
}

ArgumentABI represents the JSON structure of a method's argument.

type LogEventType added in v0.3.2

type LogEventType string

func (LogEventType) String added in v0.3.2

func (t LogEventType) String() string

type MethodABI added in v0.3.2

type MethodABI struct {
	Name            string        `json:"name"`
	Type            string        `json:"type"` // "function", "constructor", etc.
	Inputs          []ArgumentABI `json:"inputs,omitempty"`
	Outputs         []ArgumentABI `json:"outputs,omitempty"`
	StateMutability string        `json:"stateMutability,omitempty"`
	Constant        bool          `json:"constant,omitempty"`
	Payable         bool          `json:"payable,omitempty"`
}

MethodABI represents the JSON structure of a method's ABI.

type Network added in v0.3.2

type Network string

func (Network) String added in v0.3.2

func (n Network) String() string

type NetworkID added in v0.3.2

type NetworkID uint64

func GetNetworkID added in v0.3.2

func GetNetworkID(network Network) NetworkID

func (NetworkID) ToBig added in v0.3.2

func (n NetworkID) ToBig() *big.Int

type NormalizationInfo added in v0.3.1

type NormalizationInfo struct {
	TypeName   string
	Normalized bool
}

NormalizationInfo represents the result of a type normalization. It includes the normalized type name and a flag indicating whether the type name was actually normalized.

type NormalizeType added in v0.3.1

type NormalizeType struct{}

NormalizeType provides methods for normalizing type names.

func NewNormalizeType added in v0.3.1

func NewNormalizeType() *NormalizeType

NewNormalizeType creates and returns a new NormalizeType instance.

func (*NormalizeType) Normalize added in v0.3.1

func (n *NormalizeType) Normalize(typeName string) NormalizationInfo

Normalize attempts to normalize the given type name. It returns the NormalizationInfo which contains the normalized type name and a flag indicating if the provided type name was actually normalized.

type SemanticVersion added in v0.3.1

type SemanticVersion struct {
	Major int `json:"major"`
	Minor int `json:"minor"`
	Patch int `json:"patch"`
}

SemanticVersion represents a version in the format Major.Minor.Patch.

func ParseSemanticVersion added in v0.3.1

func ParseSemanticVersion(version string) SemanticVersion

ParseSemanticVersion converts a string representation of a version into a SemanticVersion struct. It expects the version string to be in the format "Major.Minor.Patch".

type SimulatorType added in v0.3.2

type SimulatorType string

func (SimulatorType) String added in v0.3.2

func (t SimulatorType) String() string

type Strategy added in v0.3.2

type Strategy string

func (Strategy) String added in v0.3.2

func (s Strategy) String() string

type TransactionMethodType added in v0.3.2

type TransactionMethodType string

func (TransactionMethodType) String added in v0.3.2

func (t TransactionMethodType) String() string

Jump to

Keyboard shortcuts

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