abiutils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PanicCodeCompilerInserted              = 0x00
	PanicCodeAssertFailed                  = 0x01
	PanicCodeArithmeticUnderOverflow       = 0x11
	PanicCodeDivideByZero                  = 0x12
	PanicCodeEnumTypeConversionOutOfBounds = 0x21
	PanicCodeIncorrectStorageAccess        = 0x22
	PanicCodePopEmptyArray                 = 0x31
	PanicCodeOutOfBoundsArrayAccess        = 0x32
	PanicCodeAllocateTooMuchMemory         = 0x41
	PanicCodeCallUninitializedVariable     = 0x51
)

An enum is defined below providing all `Panic(uint)` error codes returned in return data when the VM encounters an error in some cases. Reference: https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require

Variables

This section is empty.

Functions

func GetPanicReason added in v0.1.1

func GetPanicReason(panicCode uint64) string

GetPanicReason will take in a panic code as an uint64 and will return the string reason behind that panic code. For example, if panic code is PanicCodeAssertFailed, then "assertion failure" is returned.

func GetSolidityCustomRevertError

func GetSolidityCustomRevertError(contractAbi *abi.ABI, returnError error, returnData []byte) (*abi.Error, []any)

GetSolidityCustomRevertError obtains a custom Solidity error returned, if one was and could be resolved. Returns the ABI error definition as well as its unpacked values. Or returns nil outputs if a custom error was not emitted, or could not be resolved.

func GetSolidityPanicCode

func GetSolidityPanicCode(returnError error, returnData []byte, backwardsCompatible bool) *big.Int

GetSolidityPanicCode obtains a panic code from a VM error and return data, if possible. A flag is provided indicating whether assertion failures in older Solidity compilations will be also mapped onto newer Solidity panic code. If the error and return data are not representative of a Panic, then nil is returned.

func GetSolidityRevertErrorString

func GetSolidityRevertErrorString(returnError error, returnData []byte) *string

GetSolidityRevertErrorString obtains an error message from a VM error and return data, if possible. If the error and return data are not representative of an Error, then nil is returned.

func UnpackEventAndValues

func UnpackEventAndValues(contractAbi *abi.ABI, eventLog *coreTypes.Log) (*abi.Event, []any)

UnpackEventAndValues takes a given contract ABI, and an emitted event log from VM, and attempts to find an event definition for the log, and unpack its input values. Returns the event definition and unpacked event input values, or nil for both if an event definition could not be resolved, or values could not be unpacked.

Types

This section is empty.

Jump to

Keyboard shortcuts

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