fourbyte

package
v1.101304.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fourbyte contains the 4byte database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is a 4byte database with the possibility of maintaining an immutable set (embedded) into the process and a mutable set (loaded and written to file).

func New

func New() (*Database, error)

New loads the standard signature database embedded in the package.

func NewFromFile

func NewFromFile(path string) (*Database, error)

NewFromFile loads signature database from file, and errors if the file is not valid JSON. The constructor does no other validation of contents. This method does not load the embedded 4byte database.

The provided path will be used to write new values into if they are submitted via the API.

func NewWithFile

func NewWithFile(path string) (*Database, error)

NewWithFile loads both the standard signature database (embedded resource file) as well as a custom database. The latter will be used to write new values into if they are submitted via the API.

func (*Database) AddSelector

func (db *Database) AddSelector(selector string, data []byte) error

AddSelector inserts a new 4byte entry into the database. If custom database saving is enabled, the new dataset is also persisted to disk.

Node, this method does _not_ validate the correctness of the data. It assumes the caller has already done so.

func (*Database) Selector

func (db *Database) Selector(id []byte) (string, error)

Selector checks the given 4byte ID against the known ABI methods.

This method does not validate the match, it's assumed the caller will do.

func (*Database) Size

func (db *Database) Size() (int, int)

Size returns the number of 4byte entries in the embedded and custom datasets.

func (*Database) ValidateCallData

func (db *Database) ValidateCallData(selector *string, data []byte, messages *apitypes.ValidationMessages)

ValidateCallData checks if the ABI call-data + method selector (if given) can be parsed and seems to match.

func (*Database) ValidateTransaction

func (db *Database) ValidateTransaction(selector *string, tx *apitypes.SendTxArgs) (*apitypes.ValidationMessages, error)

ValidateTransaction does a number of checks on the supplied transaction, and returns either a list of warnings, or an error (indicating that the transaction should be immediately rejected).

Jump to

Keyboard shortcuts

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