shared

package
v0.0.0-...-fbdb3c5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeploymentTx = iota
	RegularTx
	ContractTx
)
View Source
const (
	LegacyTxType     = 0x00
	AccessListTxType = 0x01
	DynamicFeeTxType = 0x02
	BlobTxType       = 0x03
)

Transaction types.

Variables

View Source
var AddressTypeCache map[common.Address]int
View Source
var AddressTypeCacheMutex sync.RWMutex

cached data

View Source
var AlreadyProcessed map[common.Hash]ProcessedEntity
View Source
var AreActionsInitialized bool
View Source
var BlockTrackingRequired bool

this is to auto determine whether to track blocks or events

View Source
var BlockWaitGroup sync.WaitGroup

wait groups

View Source
var Blockscanners map[string]interface{}
View Source
var CachedBlocks map[*big.Int]*types.Header

cache blocks as to not query same block number multiple times warning: this may use a lot of memory

View Source
var CachedBlocksMutex = sync.RWMutex{} // prevent race condition for map CachedBlocks
View Source
var ChainID *big.Int
View Source
var DupeDetected bool
View Source
var ERC20TokenInfos map[common.Address]ERC20Info

ERC20 data

View Source
var EventSigs map[string]interface{} // from data file, maps hex string to event abi

JSON data

View Source
var FuncSigs map[string]interface{} // from data file, maps hex string (func selector) to func abi
View Source
var RpcURL string

command args (to be set by main.go)

View Source
var SwitchingToRealtime bool
View Source
var TxTypes = map[int]string{
	DeploymentTx: "Deployment",
	RegularTx:    "EOA",
	ContractTx:   "Contract",
}
View Source
var Verbose bool
View Source
var ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000")

constants

Functions

func BytesToHex

func BytesToHex(data interface{}) (string, error)

func ConnectToRPC

func ConnectToRPC(rpcURL string) (*ethclient.Client, *big.Int)

func DecodeTransaction

func DecodeTransaction(funcSelectorHex string, txData []byte, _abi interface{}) (string, map[string]interface{}, error)

returns function signature, and map function parameter name to value (argument)

func DetermineAddressType

func DetermineAddressType(address common.Address, blockNumber *big.Int) int

returns whether an address is a contract or EOA, at a block number, costing 1 query if address uncached. result is cached, which however will not take into the block number. assumes contracts stay as contracts

func DetermineTxType

func DetermineTxType(tx *types.Transaction, blockNumber *big.Int) int

determine action type of transaction. requires 1 RPC request unless cache used. not to be confused with numerical types such as for legacy tx, access list tx etc. three types possible: regular (EOA to EOA), deployment, execution (of smart contracts)

func GetBlockHeader

func GetBlockHeader(blockNum *big.Int) *types.Header

func GetDeployedContractAddress

func GetDeployedContractAddress(tx *types.Transaction) (common.Address, error)

returns deployed contract address given a tx

func GetL2BlockByHexNumber

func GetL2BlockByHexNumber(number string) (*types.Block, error)

get a block by number hex string, or `latest` / `pending` / `earliest`

func Infof

func Infof(logger *slog.Logger, format string, args ...any)

func LoadFromJson

func LoadFromJson(filename string, v any)

func TimeLogger

func TimeLogger(whichController string) *log.Logger

func Warnf

func Warnf(logger *slog.Logger, format string, args ...any)

Types

type AccessList

type AccessList []AccessTuple

AccessList is an EIP-2930 access list.

type AccessTuple

type AccessTuple struct {
	Address     common.Address `json:"address"     gencodec:"required"`
	StorageKeys []common.Hash  `json:"storageKeys" gencodec:"required"`
}

AccessTuple is the element type of an access list.

type Action

type Action struct {
	From     common.Address `json:"from"`
	To       common.Address `json:"to,omitempty"`
	CallType string         `json:"callType,omitempty"`
	Gas      hexutil.Uint64 `json:"gas"`
	Input    hexutil.Bytes  `json:"input,omitempty"`
	Init     hexutil.Bytes  `json:"init,omitempty"`
	Value    *hexutil.Big   `json:"value"`
}

type ActionOptions

type ActionOptions struct {
	Addresses     []common.Address       // addresses specific to each action
	EventSigs     []common.Hash          // event sigs specific to each action
	CustomOptions map[string]interface{} // custom options specific to each action
}

type BlockTrace

type BlockTrace struct {
	Output    hexutil.Bytes `json:"output"`
	StateDiff any           `json:"stateDiff"`
	Traces    []Trace       `json:"trace"`
}

func Trace_replayBlockTransactions

func Trace_replayBlockTransactions(blockNum uint64, traceType []string) ([]BlockTrace, error)

traceType is one or more of "trace", "stateDiff"

type CallParams

type CallParams struct {
	From     common.Address `json:"from,omitempty"`
	To       common.Address `json:"to,omitempty"`
	Gas      uint64         `json:"gas,omitempty"`
	GasPrice uint64         `json:"gasPrice,omitempty"`
	Value    *hexutil.Big   `json:"value,omitempty"`
	Data     hexutil.Bytes  `json:"data,omitempty"`
}

type CallTraceResult

type CallTraceResult struct {
	GasUsed hexutil.Uint64 `json:"gasUsed"`
	Output  string         `json:"output"`
}

type ERC20Info

type ERC20Info struct {
	Name     string
	Symbol   string
	Decimals uint8
	Address  common.Address
}

info of erc20 tokens

func RetrieveERC20Info

func RetrieveERC20Info(tokenAddress common.Address) ERC20Info

type EventField

type EventField struct {
	FieldName string
	FieldType string
	Indexed   bool
}

type EventFields

type EventFields []EventField

func DecodeTopicsAndData

func DecodeTopicsAndData(topics []common.Hash, data []byte, _abi interface{}) (EventFields, map[string]interface{}, map[string]interface{})

type EventInfo

type EventInfo struct {
	Name string
	Sig  string
	Abi  map[string]interface{}
}

info for each event from the json

type HistoricalOptions

type HistoricalOptions struct {
	FromBlock          *big.Int
	ToBlock            *big.Int
	StepBlocks         *big.Int
	ContinueToRealtime bool
	LoopBackwards      bool

	BatchFetchBlocks bool
}

type ListenerOptions

type ListenerOptions struct {
	ListenToDeployments bool
}

type ProcessedEntity

type ProcessedEntity struct {
	BlockNumber *big.Int
	TxHash      common.Hash
	EventIndex  uint
}

already processed blocks, txs or events

type Result

type Result struct {
	GasUsed string         `json:"gasUsed"`
	Output  hexutil.Bytes  `json:"output,omitempty"`
	Address common.Address `json:"address,omitempty"`
	Code    hexutil.Bytes  `json:"code,omitempty"`
}

type Signer

type Signer interface {
	// Sender returns the sender address of the transaction.
	Sender(tx *Transaction) (common.Address, error)

	// SignatureValues returns the raw R, S, V values corresponding to the
	// given signature.
	SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
	ChainID() *big.Int

	// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
	// private key. This hash does not uniquely identify the transaction.
	Hash(tx *Transaction) common.Hash

	// Equal returns true if the given signer is the same as the receiver.
	Equal(Signer) bool
}

Signer encapsulates transaction signature handling. The name of this type is slightly misleading because Signers don't actually sign, they're just for validating and processing of signatures.

Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.

type StateEntry

type StateEntry struct {
	// these can either be "=" indicating nothing changed
	// or a json struct indicating whats changed
	Balance json.RawMessage `json:"balance"`
	Code    json.RawMessage `json:"code"`
	Nonce   json.RawMessage `json:"nonce,omitempty"`
	Storage json.RawMessage `json:"storage,omitempty"`
}

type Trace

type Trace struct {
	Action              Action `json:"action"`
	BlockHash           string `json:"blockHash"`
	BlockNumber         int    `json:"blockNumber"`
	Result              Result `json:"result"`
	Subtraces           int    `json:"subtraces"`
	TraceAddress        []int  `json:"traceAddress"`
	TransactionHash     string `json:"transactionHash"`
	TransactionPosition int    `json:"transactionPosition"`
	Type                string `json:"type"`
}

func Trace_transaction

func Trace_transaction(txHash common.Hash) []Trace

type TraceAction

type TraceAction struct {
	From     string         `json:"from"`
	CallType string         `json:"callType"`
	Gas      hexutil.Uint64 `json:"gas"`
	Input    string         `json:"input"`
	To       string         `json:"to"`
	Value    *hexutil.Big   `json:"value"`
}

type TraceCallResult

type TraceCallResult struct {
	Output    string                        `json:"output"`
	StateDiff map[common.Address]StateEntry `json:"stateDiff"`
	Trace     []TraceEntry                  `json:"trace"`
	VmTrace   interface{}                   `json:"vmTrace"` // Use interface{} for null or future extensibility
}

func Trace_call

func Trace_call(callParams CallParams, traceType []string) (TraceCallResult, error)

referencing https://docs.alchemy.com/reference/trace-call traceType - Type of trace, one or more of: "trace", "stateDiff"

type TraceEntry

type TraceEntry struct {
	Action       TraceAction      `json:"action"`
	Result       *CallTraceResult `json:"result,omitempty"`
	Subtraces    int              `json:"subtraces"`
	TraceAddress []int            `json:"traceAddress"`
	Type         string           `json:"type"`
	Error        string           `json:"error,omitempty"`
}

type TraceResult

type TraceResult struct {
	From    common.Address `json:"from"`
	To      common.Address `json:"to"`
	Gas     uint64         `json:"gas"`
	GasUsed uint64         `json:"gasUsed"`
	Input   []byte         `json:"input"`
	Output  []byte         `json:"output"`
	Value   *big.Int       `json:"value"`
	Type    string         `json:"type"`
	Calls   []TraceResult  `json:"calls"`
}

func Debug_traceTransaction

func Debug_traceTransaction(txHash common.Hash) (TraceResult, error)

func (*TraceResult) UnmarshalJSON

func (t *TraceResult) UnmarshalJSON(input []byte) error

type TrackooorOptions

type TrackooorOptions struct {
	RpcURL            string
	FilterAddresses   []common.Address // global list of addresses to filter for
	FilterEventTopics [][]common.Hash  // global list of event topics to filter for

	AddressProperties map[common.Address]map[string]interface{} // e.g. map address to "name":"USDC"

	Actions map[string]ActionOptions // map action name to its options

	AutoFetchABI         bool
	MaxRequestsPerSecond int

	ListenerOptions   ListenerOptions
	HistoricalOptions HistoricalOptions

	IsL2Chain bool // will account for invalid tx types
}

config options for trackooors

var Options TrackooorOptions

type Transaction

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

Transaction is an Ethereum transaction.

type TxData

type TxData interface {
	// contains filtered or unexported methods
}

type WebhookInstance

type WebhookInstance struct {
	WebhookURL           string
	Username             string
	Avatar_url           string
	RetrySendingMessages bool
}
var DiscordWebhook WebhookInstance

global webhook instance

func (WebhookInstance) SendEmbedMessages

func (w WebhookInstance) SendEmbedMessages(embeds []discordwebhook.Embed) error

func (WebhookInstance) SendFile

func (w WebhookInstance) SendFile(imgData []byte, imgFilename string) error

func (WebhookInstance) SendMessage

func (w WebhookInstance) SendMessage(msg string) error

Jump to

Keyboard shortcuts

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