common

package
v1.1.12-beta Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructEventABI

func ConstructEventABI(signature string) (*abi.Event, error)

func ConstructFunctionABI

func ConstructFunctionABI(signature string) (*abi.Method, error)

func ConvertBigNumbersToString

func ConvertBigNumbersToString(data interface{}) interface{}

func GetABIForContract

func GetABIForContract(chainId string, contract string) (*abi.ABI, error)

func GetABIForContractWithCache

func GetABIForContractWithCache(chainId string, contract string, abiCache *sync.Map) *abi.ABI

func SliceToChunks

func SliceToChunks[T any](values []T, chunkSize int) [][]T

func ValidateQuery

func ValidateQuery(query string) error

ValidateQuery checks the query for disallowed patterns and ensures only allowed functions are used.

Types

type Block

type Block struct {
	ChainId          *big.Int  `json:"chain_id" ch:"chain_id"`
	Number           *big.Int  `json:"block_number" ch:"block_number"`
	Hash             string    `json:"hash" ch:"hash"`
	ParentHash       string    `json:"parent_hash" ch:"parent_hash"`
	Timestamp        time.Time `json:"block_timestamp" ch:"block_timestamp"`
	Nonce            string    `json:"nonce" ch:"nonce"`
	Sha3Uncles       string    `json:"sha3_uncles" ch:"sha3_uncles"`
	MixHash          string    `json:"mix_hash" ch:"mix_hash"`
	Miner            string    `json:"miner" ch:"miner"`
	StateRoot        string    `json:"state_root" ch:"state_root"`
	TransactionsRoot string    `json:"transactions_root" ch:"transactions_root"`
	ReceiptsRoot     string    `json:"receipts_root" ch:"receipts_root"`
	LogsBloom        string    `json:"logs_bloom" ch:"logs_bloom"`
	Size             uint64    `json:"size" ch:"size"`
	ExtraData        string    `json:"extra_data" ch:"extra_data"`
	Difficulty       *big.Int  `json:"difficulty" ch:"difficulty"`
	TotalDifficulty  *big.Int  `json:"total_difficulty" ch:"total_difficulty"`
	TransactionCount uint64    `json:"transaction_count" ch:"transaction_count"`
	GasLimit         *big.Int  `json:"gas_limit" ch:"gas_limit"`
	GasUsed          *big.Int  `json:"gas_used" ch:"gas_used"`
	WithdrawalsRoot  string    `json:"withdrawals_root" ch:"withdrawals_root"`
	BaseFeePerGas    uint64    `json:"base_fee_per_gas" ch:"base_fee_per_gas"`
	Sign             int8      `json:"sign" ch:"sign"`
	InsertTimestamp  time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

func (*Block) Serialize

func (b *Block) Serialize() BlockModel

type BlockData

type BlockData struct {
	Block        Block
	Transactions []Transaction
	Logs         []Log
	Traces       []Trace
}

type BlockFailure

type BlockFailure struct {
	BlockNumber   *big.Int
	ChainId       *big.Int
	FailureTime   time.Time
	FailureReason string
	FailureCount  int
}

type BlockHeader

type BlockHeader struct {
	Number     *big.Int `json:"number"`
	Hash       string   `json:"hash"`
	ParentHash string   `json:"parent_hash"`
}

type BlockModel

type BlockModel struct {
	ChainId          string `json:"chain_id"`
	BlockNumber      uint64 `json:"block_number"`
	BlockHash        string `json:"block_hash"`
	ParentHash       string `json:"parent_hash"`
	BlockTimestamp   uint64 `json:"block_timestamp"`
	Nonce            string `json:"nonce"`
	Sha3Uncles       string `json:"sha3_uncles"`
	MixHash          string `json:"mix_hash"`
	Miner            string `json:"miner"`
	StateRoot        string `json:"state_root"`
	TransactionsRoot string `json:"transactions_root"`
	ReceiptsRoot     string `json:"receipts_root"`
	LogsBloom        string `json:"logs_bloom"`
	Size             uint64 `json:"size"`
	ExtraData        string `json:"extra_data"`
	Difficulty       string `json:"difficulty"`
	TotalDifficulty  string `json:"total_difficulty"`
	TransactionCount uint64 `json:"transaction_count"`
	GasLimit         string `json:"gas_limit"`
	GasUsed          string `json:"gas_used"`
	WithdrawalsRoot  string `json:"withdrawals_root"`
	BaseFeePerGas    uint64 `json:"base_fee_per_gas"`
}

BlockModel represents a simplified Block structure for Swagger documentation

type DecodedLog

type DecodedLog struct {
	Log
	Decoded DecodedLogData `json:"decoded"`
}

func DecodeLogs

func DecodeLogs(chainId string, logs []Log) []*DecodedLog

func (*DecodedLog) Serialize

func (l *DecodedLog) Serialize() DecodedLogModel

type DecodedLogData

type DecodedLogData struct {
	Name             string                 `json:"name"`
	Signature        string                 `json:"signature"`
	IndexedParams    map[string]interface{} `json:"indexed_params"`
	NonIndexedParams map[string]interface{} `json:"non_indexed_params"`
}

type DecodedLogDataModel

type DecodedLogDataModel struct {
	Name             string                 `json:"name"`
	Signature        string                 `json:"signature"`
	IndexedParams    map[string]interface{} `json:"indexed_params" swaggertype:"object"`
	NonIndexedParams map[string]interface{} `json:"non_indexed_params" swaggertype:"object"`
}

type DecodedLogModel

type DecodedLogModel struct {
	LogModel
	Decoded DecodedLogDataModel `json:"decoded"`
}

type DecodedTransaction

type DecodedTransaction struct {
	Transaction
	Decoded DecodedTransactionData `json:"decoded"`
}

func DecodeTransactions

func DecodeTransactions(chainId string, txs []Transaction) []*DecodedTransaction

func (*DecodedTransaction) Serialize

type DecodedTransactionData

type DecodedTransactionData struct {
	Name      string                 `json:"name"`
	Signature string                 `json:"signature"`
	Inputs    map[string]interface{} `json:"inputs"`
}

type DecodedTransactionDataModel

type DecodedTransactionDataModel struct {
	Name      string                 `json:"name"`
	Signature string                 `json:"signature"`
	Inputs    map[string]interface{} `json:"inputs"`
}

type DecodedTransactionModel

type DecodedTransactionModel struct {
	TransactionModel
	Decoded DecodedTransactionDataModel `json:"decoded"`
}

type Log

type Log struct {
	ChainId          *big.Int  `json:"chain_id" ch:"chain_id" swaggertype:"string"`
	BlockNumber      *big.Int  `json:"block_number" ch:"block_number" swaggertype:"string"`
	BlockHash        string    `json:"block_hash" ch:"block_hash"`
	BlockTimestamp   time.Time `json:"block_timestamp" ch:"block_timestamp"`
	TransactionHash  string    `json:"transaction_hash" ch:"transaction_hash"`
	TransactionIndex uint64    `json:"transaction_index" ch:"transaction_index"`
	LogIndex         uint64    `json:"log_index" ch:"log_index"`
	Address          string    `json:"address" ch:"address"`
	Data             string    `json:"data" ch:"data"`
	Topic0           string    `json:"topic_0" ch:"topic_0"`
	Topic1           string    `json:"topic_1" ch:"topic_1"`
	Topic2           string    `json:"topic_2" ch:"topic_2"`
	Topic3           string    `json:"topic_3" ch:"topic_3"`
	Sign             int8      `json:"sign" ch:"sign"`
	InsertTimestamp  time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

func (*Log) Decode

func (l *Log) Decode(eventABI *abi.Event) *DecodedLog

func (*Log) GetTopic

func (l *Log) GetTopic(index int) (string, error)

func (*Log) Serialize

func (l *Log) Serialize() LogModel

type LogModel

type LogModel struct {
	ChainId          string   `json:"chain_id"`
	BlockNumber      uint64   `json:"block_number"`
	BlockHash        string   `json:"block_hash"`
	BlockTimestamp   uint64   `json:"block_timestamp"`
	TransactionHash  string   `json:"transaction_hash"`
	TransactionIndex uint64   `json:"transaction_index"`
	LogIndex         uint64   `json:"log_index"`
	Address          string   `json:"address"`
	Data             string   `json:"data"`
	Topics           []string `json:"topics" swaggertype:"array,string"`
}

LogModel represents a simplified Log structure for Swagger documentation

type RawBlock

type RawBlock = map[string]interface{}

type RawLogs

type RawLogs = []map[string]interface{}

type RawReceipt

type RawReceipt = map[string]interface{}

type RawReceipts

type RawReceipts = []RawReceipt

type RawTraces

type RawTraces = []map[string]interface{}

type RawTransaction

type RawTransaction = map[string]interface{}

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable]() *Set[T]

NewSet creates a new set

func (*Set[T]) Add

func (s *Set[T]) Add(value T)

Add inserts an element into the set

func (*Set[T]) Contains

func (s *Set[T]) Contains(value T) bool

Contains checks if an element is in the set

func (*Set[T]) List

func (s *Set[T]) List() []T

List returns all elements in the set as a slice

func (*Set[T]) Remove

func (s *Set[T]) Remove(value T)

Remove deletes an element from the set

func (*Set[T]) Size

func (s *Set[T]) Size() int

Size returns the number of elements in the set

type TokenBalance

type TokenBalance struct {
	ChainId      *big.Int `json:"chain_id" ch:"chain_id"`
	TokenType    string   `json:"token_type" ch:"token_type"`
	TokenAddress string   `json:"token_address" ch:"address"`
	Owner        string   `json:"owner" ch:"owner"`
	TokenId      *big.Int `json:"token_id" ch:"token_id"`
	Balance      *big.Int `json:"balance" ch:"balance"`
}

type TokenTransfer

type TokenTransfer struct {
	TokenType       string    `json:"token_type" ch:"token_type"`
	ChainID         *big.Int  `json:"chain_id" ch:"chain_id"`
	TokenAddress    string    `json:"token_address" ch:"token_address"`
	FromAddress     string    `json:"from_address" ch:"from_address"`
	ToAddress       string    `json:"to_address" ch:"to_address"`
	BlockNumber     *big.Int  `json:"block_number" ch:"block_number"`
	BlockTimestamp  time.Time `json:"block_timestamp" ch:"block_timestamp"`
	TransactionHash string    `json:"transaction_hash" ch:"transaction_hash"`
	TokenID         *big.Int  `json:"token_id" ch:"token_id"`
	Amount          *big.Int  `json:"amount" ch:"amount"`
	LogIndex        uint64    `json:"log_index" ch:"log_index"`
	Sign            int8      `json:"sign" ch:"sign"`
	InsertTimestamp time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

type Trace

type Trace struct {
	ChainID          *big.Int  `json:"chain_id" ch:"chain_id"`
	BlockNumber      *big.Int  `json:"block_number" ch:"block_number"`
	BlockHash        string    `json:"block_hash" ch:"block_hash"`
	BlockTimestamp   time.Time `json:"block_timestamp" ch:"block_timestamp"`
	TransactionHash  string    `json:"transaction_hash" ch:"transaction_hash"`
	TransactionIndex uint64    `json:"transaction_index" ch:"transaction_index"`
	Subtraces        int64     `json:"subtraces" ch:"subtraces"`
	TraceAddress     []uint64  `json:"trace_address" ch:"trace_address"`
	TraceType        string    `json:"trace_type" ch:"type"`
	CallType         string    `json:"call_type" ch:"call_type"`
	Error            string    `json:"error" ch:"error"`
	FromAddress      string    `json:"from_address" ch:"from_address"`
	ToAddress        string    `json:"to_address" ch:"to_address"`
	Gas              *big.Int  `json:"gas" ch:"gas"`
	GasUsed          *big.Int  `json:"gas_used" ch:"gas_used"`
	Input            string    `json:"input" ch:"input"`
	Output           string    `json:"output" ch:"output"`
	Value            *big.Int  `json:"value" ch:"value"`
	Author           string    `json:"author" ch:"author"`
	RewardType       string    `json:"reward_type" ch:"reward_type"`
	RefundAddress    string    `json:"refund_address" ch:"refund_address"`
	Sign             int8      `json:"sign" ch:"sign"`
	InsertTimestamp  time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

func (*Trace) Serialize

func (t *Trace) Serialize() TraceModel

type TraceModel

type TraceModel struct {
	ChainId          string   `json:"chain_id"`
	BlockNumber      uint64   `json:"block_number"`
	BlockHash        string   `json:"block_hash"`
	BlockTimestamp   uint64   `json:"block_timestamp"`
	TransactionHash  string   `json:"transaction_hash"`
	TransactionIndex uint64   `json:"transaction_index"`
	Subtraces        int64    `json:"subtraces"`
	TraceAddress     []uint64 `json:"trace_address"`
	TraceType        string   `json:"trace_type"`
	CallType         string   `json:"call_type"`
	Error            string   `json:"error"`
	FromAddress      string   `json:"from_address"`
	ToAddress        string   `json:"to_address"`
	Gas              uint64   `json:"gas"`
	GasUsed          uint64   `json:"gas_used"`
	Input            string   `json:"input"`
	Output           string   `json:"output"`
	Value            uint64   `json:"value"`
	Author           string   `json:"author"`
	RewardType       string   `json:"reward_type"`
	RefundAddress    string   `json:"refund_address"`
}

type Transaction

type Transaction struct {
	ChainId               *big.Int  `json:"chain_id" ch:"chain_id" swaggertype:"string"`
	Hash                  string    `json:"hash" ch:"hash"`
	Nonce                 uint64    `json:"nonce" ch:"nonce"`
	BlockHash             string    `json:"block_hash" ch:"block_hash"`
	BlockNumber           *big.Int  `json:"block_number" ch:"block_number" swaggertype:"string"`
	BlockTimestamp        time.Time `json:"block_timestamp" ch:"block_timestamp"`
	TransactionIndex      uint64    `json:"transaction_index" ch:"transaction_index"`
	FromAddress           string    `json:"from_address" ch:"from_address"`
	ToAddress             string    `json:"to_address" ch:"to_address"`
	Value                 *big.Int  `json:"value" ch:"value" swaggertype:"string"`
	Gas                   uint64    `json:"gas" ch:"gas"`
	GasPrice              *big.Int  `json:"gas_price" ch:"gas_price" swaggertype:"string"`
	Data                  string    `json:"data" ch:"data"`
	FunctionSelector      string    `json:"function_selector" ch:"function_selector"`
	MaxFeePerGas          *big.Int  `json:"max_fee_per_gas" ch:"max_fee_per_gas" swaggertype:"string"`
	MaxPriorityFeePerGas  *big.Int  `json:"max_priority_fee_per_gas" ch:"max_priority_fee_per_gas" swaggertype:"string"`
	MaxFeePerBlobGas      *big.Int  `json:"max_fee_per_blob_gas" ch:"max_fee_per_blob_gas" swaggertype:"string"`
	BlobVersionedHashes   []string  `json:"blob_versioned_hashes" ch:"blob_versioned_hashes"`
	TransactionType       uint8     `json:"transaction_type" ch:"transaction_type"`
	R                     *big.Int  `json:"r" ch:"r" swaggertype:"string"`
	S                     *big.Int  `json:"s" ch:"s" swaggertype:"string"`
	V                     *big.Int  `json:"v" ch:"v" swaggertype:"string"`
	AccessListJson        *string   `json:"access_list_json" ch:"access_list"`
	AuthorizationListJson *string   `json:"authorization_list_json" ch:"authorization_list"`
	ContractAddress       *string   `json:"contract_address" ch:"contract_address"`
	GasUsed               *uint64   `json:"gas_used" ch:"gas_used"`
	CumulativeGasUsed     *uint64   `json:"cumulative_gas_used" ch:"cumulative_gas_used"`
	EffectiveGasPrice     *big.Int  `json:"effective_gas_price" ch:"effective_gas_price" swaggertype:"string"`
	BlobGasUsed           *uint64   `json:"blob_gas_used" ch:"blob_gas_used"`
	BlobGasPrice          *big.Int  `json:"blob_gas_price" ch:"blob_gas_price" swaggertype:"string"`
	LogsBloom             *string   `json:"logs_bloom" ch:"logs_bloom"`
	Status                *uint64   `json:"status" ch:"status"`
	Sign                  int8      `json:"sign" ch:"sign"`
	InsertTimestamp       time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

func (*Transaction) Decode

func (t *Transaction) Decode(functionABI *abi.Method) *DecodedTransaction

func (*Transaction) Serialize

func (t *Transaction) Serialize() TransactionModel

type TransactionModel

type TransactionModel struct {
	ChainId               string   `json:"chain_id"`
	Hash                  string   `json:"hash"`
	Nonce                 uint64   `json:"nonce"`
	BlockHash             string   `json:"block_hash"`
	BlockNumber           uint64   `json:"block_number"`
	BlockTimestamp        uint64   `json:"block_timestamp"`
	TransactionIndex      uint64   `json:"transaction_index"`
	FromAddress           string   `json:"from_address"`
	ToAddress             string   `json:"to_address"`
	Value                 string   `json:"value"`
	Gas                   uint64   `json:"gas"`
	GasPrice              string   `json:"gas_price"`
	Data                  string   `json:"data"`
	FunctionSelector      string   `json:"function_selector"`
	MaxFeePerGas          string   `json:"max_fee_per_gas"`
	MaxPriorityFeePerGas  string   `json:"max_priority_fee_per_gas"`
	MaxFeePerBlobGas      *string  `json:"max_fee_per_blob_gas,omitempty"`
	BlobVersionedHashes   []string `json:"blob_versioned_hashes,omitempty"`
	TransactionType       uint8    `json:"transaction_type"`
	R                     string   `json:"r"`
	S                     string   `json:"s"`
	V                     string   `json:"v"`
	AccessListJson        *string  `json:"access_list_json"`
	AuthorizationListJson *string  `json:"authorization_list_json"`
	ContractAddress       *string  `json:"contract_address"`
	GasUsed               *uint64  `json:"gas_used"`
	CumulativeGasUsed     *uint64  `json:"cumulative_gas_used"`
	EffectiveGasPrice     *string  `json:"effective_gas_price"`
	BlobGasUsed           *uint64  `json:"blob_gas_used"`
	BlobGasPrice          *string  `json:"blob_gas_price"`
	LogsBloom             *string  `json:"logs_bloom"`
	Status                *uint64  `json:"status"`
}

TransactionModel represents a simplified Transaction structure for Swagger documentation

Jump to

Keyboard shortcuts

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