Documentation
¶
Index ¶
- Constants
- Variables
- func AddressInSlice(addr common.Address, list []common.Address) bool
- func ContainsBlacklistType(list []BlacklistType, item BlacklistType) bool
- func ContainsTransactionMethodType(list []TransactionMethodType, item TransactionMethodType) bool
- func ContainsUUID(list []uuid.UUID, item uuid.UUID) bool
- func DumpNodeNoExit(whatever any)
- func DumpNodeWithExit(whatever any)
- func EventToABI(method *abi.Event) (string, error)
- func FromJSON[T any](data []byte, target *T) error
- func GetBuildVersionByModule(module string) string
- func GetCurrentPath() (string, error)
- func GetLocalSourcesPath() string
- func IsSemanticVersionGreaterOrEqualTo(versionStr string, version SemanticVersion) bool
- func IsSemanticVersionLowerOrEqualTo(versionStr string, version SemanticVersion) bool
- func Keccak256(data []byte) []byte
- func MethodToABI(method *abi.Method) (string, error)
- func PathExists(path string) bool
- func SimplifyImportPaths(content string) string
- func StringInSlice(str string, list []string) bool
- func StripExtraSPDXLines(content string) string
- func StripImportPaths(content string) string
- func ToABI(data []byte) (*abi.ABI, error)
- func ToJSON(data any) ([]byte, error)
- func ToJSONPretty(data any) ([]byte, error)
- func ToProtoJSON(data any) ([]byte, error)
- func WriteToFile(path string, data []byte) error
- type AccountType
- type AddressType
- type AntiWhaleType
- type ArgumentABI
- type BlacklistType
- type ExchangeType
- type LogEventType
- type MethodABI
- type NamedAddr
- type Network
- type NetworkID
- type NormalizationInfo
- type NormalizeType
- type RateLimiter
- type SafetyStateType
- type SemanticVersion
- type SimulatorType
- type Strategy
- type TokenType
- type TradeType
- type TransactionMethodType
Constants ¶
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 // Special Mainnets AnvilMainnetNetworkID NetworkID = 1 // 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 // Localnets AnvilNetworkID NetworkID = 1337 )
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" NoSignatureMethodType TransactionMethodType = "no_signature" UnknownLogEventType LogEventType = "unknown" SwapLogEventType LogEventType = "swap" TransferLogEventType LogEventType = "transfer" DepositLogEventType LogEventType = "deposit" WithdrawLogEventType LogEventType = "withdraw" MintLogEventType LogEventType = "mint" BurnLogEventType LogEventType = "burn" NoSimulator SimulatorType = "no_simulator" AnvilSimulator SimulatorType = "anvil" TraceSimulator SimulatorType = "trace" SimulatorAccountType AccountType = "simulator" SimpleAccountType AccountType = "simple" KeystoreAccountType AccountType = "keystore" NoExchange ExchangeType = "no_exchange" UniswapV2 ExchangeType = "uniswap_v2" UniswapV3 ExchangeType = "uniswap_v3" SushiSwap ExchangeType = "sushiswap" PancakeswapV2 ExchangeType = "pancakeswap_v2" Erc20TokenType TokenType = "erc20" Erc721TokenType TokenType = "erc721" AntiWhalePinksale AntiWhaleType = "pinksale" BuyTradeType TradeType = "buy" SellTradeType TradeType = "sell" UnknownSafetyState SafetyStateType = "unknown" SafeSafetyState SafetyStateType = "safe" WarnSafetyState SafetyStateType = "warning" UnsafeSafetyState SafetyStateType = "unsafe" RugpullBlacklistType BlacklistType = "rugpull" HoneypotBlacklistType BlacklistType = "honeypot" HighTaxTokenBlacklistType BlacklistType = "high_tax_token" PumpAndDumpTokenBlacklistType BlacklistType = "pump_and_dump_token" MixerUsageBlacklistType BlacklistType = "mixer_usage" )
Constants defining various strategies, address types, transaction method types, etc.
Variables ¶
var ( // ZeroAddress represents a zero Ethereum address ZeroAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") // ZeroHash represents a hash value consisting of all zeros. ZeroHash = common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") )
var ( ZeroSignatureBytes = []byte{0x00, 0x00, 0x00, 0x00} ZeroSignature = "0x00000000" )
ZeroSignatureBytes and ZeroSignature represent a null signature in Ethereum transactions.
Functions ¶
func AddressInSlice ¶
AddressInSlice checks whether an Ethereum address is present in a slice of addresses.
func ContainsBlacklistType ¶
func ContainsBlacklistType(list []BlacklistType, item BlacklistType) bool
ContainsBlacklistType checks whether a BlacklistType item is present in a slice of BlacklistType.
func ContainsTransactionMethodType ¶
func ContainsTransactionMethodType(list []TransactionMethodType, item TransactionMethodType) bool
ContainsTransactionMethodType checks whether a TransactionMethodType item is present in a slice of TransactionMethodType.
func ContainsUUID ¶
ContainsUUID checks whether a UUID is present in a slice of UUIDs by comparing their string representations.
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 ¶
EventToABI converts a Event object to its JSON ABI representation.
func FromJSON ¶
FromJSON converts JSON data into a Go data structure of type T. It takes a slice of bytes representing the JSON data and a pointer to the type T where the data will be decoded. Returns an error if the decoding fails.
func GetBuildVersionByModule ¶
GetBuildVersionByModule retrieves the build version of a specified module from the current application's build information. It parses the build information obtained from the runtime debug package to search for a specific module.
func GetCurrentPath ¶
GetCurrentPath returns the current working directory.
func GetLocalSourcesPath ¶
func GetLocalSourcesPath() string
GetLocalSourcesPath returns the absolute path to the local sources directory.
func IsSemanticVersionGreaterOrEqualTo ¶
func IsSemanticVersionGreaterOrEqualTo(versionStr string, version SemanticVersion) bool
IsSemanticVersionGreaterOrEqualTo checks if the version represented by a string is greater than or equal to the provided SemanticVersion. The comparison takes into account the Major, Minor, and Patch components of the semantic version.
func IsSemanticVersionLowerOrEqualTo ¶
func IsSemanticVersionLowerOrEqualTo(versionStr string, version SemanticVersion) bool
IsSemanticVersionLowerOrEqualTo checks if the version represented by a string is lower than or equal to the provided SemanticVersion. The comparison considers the Major, Minor, and Patch components of the semantic version.
func MethodToABI ¶
MethodToABI converts a Method object to its JSON ABI representation.
func PathExists ¶
PathExists returns true if the given path exists.
func SimplifyImportPaths ¶
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 StringInSlice ¶
StringInSlice checks whether a string is present in a slice of strings.
func StripExtraSPDXLines ¶
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 ¶
StripImportPaths removes the import paths entirely from the content.
func ToJSONPretty ¶
ToJSONPretty returns a pretty-printed JSON representation of the provided interface. This function is primarily used for debugging purposes.
func ToProtoJSON ¶
ToProtoJSON converts a Go struct to its JSON representation.
func WriteToFile ¶
WriteToFile writes the provided data byte array to a file at the provided path.
Types ¶
type AccountType ¶
type AccountType string
AccountType categorizes the types of accounts used, particularly in simulations. Types include "simulator" for simulated accounts, "simple", and "keystore" for accounts stored in encrypted format.
func (AccountType) String ¶
func (t AccountType) String() string
String returns the string representation of an AccountType.
type AddressType ¶
type AddressType string
AddressType categorizes Ethereum addresses based on their usage context. Types include "zero_address" for the null address, "address" for standard addresses, and "contract" for contract addresses.
func (AddressType) String ¶
func (r AddressType) String() string
String returns the string representation of an AddressType.
type AntiWhaleType ¶
type AntiWhaleType string
AntiWhaleType represents types of anti-whale measures, such as "pinksale" for specific project launches with anti-whale features.
func (AntiWhaleType) String ¶
func (t AntiWhaleType) String() string
String returns the string representation of an AntiWhaleType.
type ArgumentABI ¶
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 BlacklistType ¶
type BlacklistType string
BlacklistType defines types of blacklist categories for tokens or contracts, such as "rugpull", "honeypot", and others related to specific risks.
func (BlacklistType) String ¶
func (t BlacklistType) String() string
String returns the string representation of a BlacklistType.
type ExchangeType ¶
type ExchangeType string
ExchangeType represents various decentralized exchange (DEX) protocols. Types include "no_exchange", "uniswap_v2", "uniswap_v3", "sushiswap", and "pancakeswap_v2".
func (ExchangeType) String ¶
func (t ExchangeType) String() string
String returns the string representation of an ExchangeType.
type LogEventType ¶
type LogEventType string
LogEventType represents the type of event logged by Ethereum smart contracts. Types include various events such as "swap", "transfer", "deposit", "withdraw", "mint", and "burn", along with "unknown" for undetermined event types.
func (LogEventType) String ¶
func (t LogEventType) String() string
String returns the string representation of a LogEventType.
type MethodABI ¶
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 NamedAddr ¶
type NamedAddr struct { Name string `json:"name"` Ens string `json:"ens"` Tags []string `json:"tags"` Addr common.Address `json:"addr"` Type AddressType `json:"type"` }
NamedAddr encapsulates detailed information about an Ethereum address along with its metadata. It includes a human-readable name, an optional Ethereum Name Service (ENS) domain, a set of tags for categorization or annotation, the Ethereum address itself, and the type of address which provides additional context about its use or origin.
type NormalizationInfo ¶
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 ¶
type NormalizeType struct{}
NormalizeType provides methods for normalizing type names.
func NewNormalizeType ¶
func NewNormalizeType() *NormalizeType
NewNormalizeType creates and returns a new NormalizeType instance.
func (*NormalizeType) Normalize ¶
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 RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a token bucket rate limiting algorithm. It is used to control how frequently events are allowed to happen. The RateLimiter allows a certain number of events to occur within a fixed time frame and refills the tokens at a constant interval.
func NewRateLimiter ¶
func NewRateLimiter(capacity int, refillTime time.Duration) *RateLimiter
NewRateLimiter initializes and returns a new RateLimiter with the specified capacity and refill time. The capacity parameter specifies the maximum number of tokens, and refillTime specifies how often the tokens are replenished. A debug message showing the capacity is printed during initialization.
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow() bool
Allow checks if at least one token is available. If a token is available, it consumes a token by decrementing the token count and returns true, indicating that the event is allowed to proceed. If no tokens are available, it returns false, indicating that the rate limit has been exceeded. Tokens are refilled based on the elapsed time since the last refill, up to the maximum capacity.
func (*RateLimiter) WaitForToken ¶
func (rl *RateLimiter) WaitForToken()
WaitForToken blocks the caller until a token becomes available. If no tokens are available upon invoking this method, it waits for a signal from a separate goroutine indicating that tokens have been refilled. This method ensures that events respect the rate limit by waiting for permission to proceed rather than immediately returning false.
type SafetyStateType ¶
type SafetyStateType string
SafetyStateType represents the safety state of a transaction or contract, including "unknown", "safe", "warning", and "unsafe".
func (SafetyStateType) String ¶
func (t SafetyStateType) String() string
String returns the string representation of a SafetyStateType.
type SemanticVersion ¶
type SemanticVersion struct { Major int `json:"major"` // Major version, incremented for incompatible API changes. Minor int `json:"minor"` // Minor version, incremented for backwards-compatible enhancements. Patch int `json:"patch"` // Patch version, incremented for backwards-compatible bug fixes. Commit string `json:"revision"` // Optional commit revision for tracking specific builds. }
SemanticVersion represents a semantic version, following the Major.Minor.Patch format. Optionally, a version can include a commit revision as a metadata string appended after a plus sign (+).
func ParseSemanticVersion ¶
func ParseSemanticVersion(version string) SemanticVersion
ParseSemanticVersion parses a version string into a SemanticVersion struct. The function supports version strings in the "Major.Minor.Patch" format, with an optional commit revision appended after a plus sign (+). The 'v' prefix in version strings is also supported and ignored during parsing.
func (SemanticVersion) String ¶
func (v SemanticVersion) String() string
String returns the string representation of the SemanticVersion, excluding the commit revision. It adheres to the "Major.Minor.Patch" format.
type SimulatorType ¶
type SimulatorType string
SimulatorType represents the types of simulators used for transaction execution or testing. Types include "no_simulator", "anvil" for the Anvil Ethereum simulator, and "trace" for simulators that support tracing capabilities.
func (SimulatorType) String ¶
func (t SimulatorType) String() string
String returns the string representation of a SimulatorType.
type Strategy ¶
type Strategy string
Strategy represents the strategy used in transaction processing or data fetching. Available strategies include "head" for latest data and "archive" for historical data.
type TokenType ¶
type TokenType string
TokenType categorizes the types of tokens, such as "erc20" for standard fungible tokens and "erc721" for non-fungible tokens (NFTs).
type TradeType ¶
type TradeType string
TradeType defines the type of trade action, including "buy" and "sell".
type TransactionMethodType ¶
type TransactionMethodType string
TransactionMethodType defines the type of transaction method used in Ethereum transactions. Types include "unknown" for undetermined, "contract_creation" for contract deployments, "transfer" for token transfers, and "no_signature" for transactions without a signature.
func (TransactionMethodType) String ¶
func (t TransactionMethodType) String() string
String returns the string representation of a TransactionMethodType.