models

package
v0.0.0-...-77d485b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AstKeyPrefix = "contract:ast:entry"

AstKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

View Source
const CfgKeyPrefix = "contract:cfg:entry"

CfgKeyPrefix is a constant defining the prefix for the database keys of contract cfg entries.

View Source
const ConstructorKeyPrefix = "contract:constructor:entry"

ConstructorKeyPrefix is a constant defining the prefix for the database keys of contract constructor entries.

View Source
const ContractKeyPrefix = "contract:entry"

ContractKeyPrefix is a constant defining the prefix for the database keys of contract entries.

View Source
const EventKeyPrefix = "contract:event:entry"

EventKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

View Source
const FunctionKeyPrefix = "contract:function:entry"

FunctionKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

View Source
const MetadataKeyPrefix = "contract:metadata:entry"

MetadataKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

View Source
const StandardKeyPrefix = "contract:standard:entry"

StandardKeyPrefix is a constant defining the prefix for the database keys of contract standard entries.

View Source
const TokenKeyPrefix = "contract:token:entry"

TokenKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

View Source
const VariableKeyPrefix = "contract:variable:entry"

VariableKeyPrefix is a constant defining the prefix for the database keys of contract metadata entries.

Variables

This section is empty.

Functions

func DecodeCursor

func DecodeCursor(encodedCursor string) (*big.Int, error)

func SaveAst

func SaveAst(db *sql.DB, ast *Ast) error

SaveAst saves Ast instance to the SQLite database.

func SaveCfg

func SaveCfg(db *sql.DB, cfg *Cfg) error

SaveCfg saves Cfg instance to the SQLite database.

func SaveConstructor

func SaveConstructor(db *sql.DB, constructor *Constructor) error

SaveConstructor saves Constructor instance to the SQLite database.

func SaveContract

func SaveContract(db *sql.DB, contract *Contract) error

SaveContract saves a Contract instance to the SQLite database.

func SaveEvents

func SaveEvents(db *sql.DB, fns []*Event) error

SaveEvents performs a bulk insert of multiple Event instances into the SQLite database.

func SaveFunction

func SaveFunction(db *sql.DB, fn *Function) error

SaveFunction saves Function instance to the SQLite database.

func SaveFunctions

func SaveFunctions(db *sql.DB, fns []*Function) error

SaveFunctions performs a bulk insert of multiple Function instances into the SQLite database.

func SaveMetadata

func SaveMetadata(db *sql.DB, metadata *Metadata) error

SaveMetadata saves a Contract instance to the SQLite database.

func SaveStandard

func SaveStandard(db *sql.DB, standard *Standard) error

SaveStandard saves Standard instance to the SQLite database.

func SaveStandards

func SaveStandards(db *sql.DB, standards []*Standard) error

SaveStandards performs a bulk insert of multiple Standard instances into the SQLite database.

func SaveToken

func SaveToken(db *sql.DB, token *Token) error

SaveToken saves Token instance to the SQLite database.

func SaveVariable

func SaveVariable(db *sql.DB, variable *Variable) error

SaveVariable saves Variable instance to the SQLite database.

func SaveVariables

func SaveVariables(db *sql.DB, variables []*Variable) error

SaveVariables performs a bulk insert of multiple Variable instances into the SQLite database.

func UpdateContract

func UpdateContract(db *sql.DB, contract *Contract) error

UpdateContract updates an existing Contract instance in the database.

Types

type Ast

type Ast struct {
	Id                  int64
	NetworkId           *types.BigInt
	ContractId          *types.BigInt
	UnitsCount          int64
	ContractsCount      int64
	InterfacesCount     int64
	LibrariesCount      int64
	StateVariablesCount int64
	FunctionsCount      int64
	EventsCount         int64
	Processed           bool
	Partial             bool
	CreatedAt           time.Time
	UpdatedAt           time.Time
}

func GetContractAstByUniqueIndex

func GetContractAstByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64) (*Ast, error)

GetContractAstByUniqueIndex retrieves a single contract ast from the database based on a unique combination of network_id and contract id.

func (*Ast) EncodeCursor

func (c *Ast) EncodeCursor() string

func (*Ast) GetKey

func (c *Ast) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Ast) IsCompleted

func (c *Ast) IsCompleted() bool

type Cfg

type Cfg struct {
	Id         int64
	NetworkId  *types.BigInt
	ContractId *types.BigInt
	Mermaid    string
	Processed  bool
	Partial    bool
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func GetContractCfgByUniqueIndex

func GetContractCfgByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64) (*Cfg, error)

GetContractCfgByUniqueIndex retrieves a single contract cfg from the database based on a unique combination of network_id and contract id.

func (*Cfg) EncodeCursor

func (c *Cfg) EncodeCursor() string

func (*Cfg) GetKey

func (c *Cfg) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Cfg) IsCompleted

func (c *Cfg) IsCompleted() bool

type Constructor

type Constructor struct {
	Id           int64
	NetworkId    *types.BigInt
	ContractId   *types.BigInt
	Signature    string          `bun:"signature"`
	Arguments    json.RawMessage `bun:"arguments"`
	ArgumentsRaw json.RawMessage `bun:"arguments_raw"`
	Abi          json.RawMessage `bun:"abi"`
	Unit         json.RawMessage `bun:"unit"`
	Processed    bool
	Partial      bool
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

func GetContractConstructorByUniqueIndex

func GetContractConstructorByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64) (*Constructor, error)

GetContractConstructorByUniqueIndex retrieves a single contract constructor from the database based on a unique combination of network_id and contract id.

func (*Constructor) EncodeCursor

func (c *Constructor) EncodeCursor() string

func (*Constructor) GetKey

func (c *Constructor) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Constructor) IsCompleted

func (c *Constructor) IsCompleted() bool

type Contract

type Contract struct {
	Id                   int64
	NetworkId            *types.BigInt
	BlockNumber          *types.BigInt
	BlockHash            types.Hash
	TransactionHash      types.Hash
	Address              types.Address
	Name                 string
	Standards            types.Standards
	Proxy                bool
	License              string
	CompilerVersion      string
	SolgoVersion         string
	Optimized            bool
	OptimizationRuns     uint64
	EVMVersion           string
	ABI                  string
	Verified             bool
	SourcesProvider      string
	VerificationProvider string
	ExecutionBytecode    types.Bytecode
	Bytecode             types.Bytecode
	SafetyState          utils.SafetyStateType
	SourceAvailable      bool
	SelfDestructed       bool
	ProxyImplementations types.Addresses
	CompletedStates      types.States
	FailedStates         types.States
	Processed            bool
	Partial              bool
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

func GetContractByAddress

func GetContractByAddress(db *sql.DB, networkId *big.Int, address common.Address) (*Contract, error)

GetContractByAddress retrieves a single contract from the database based on a unique combination of network_id, block_number, and address.

func GetContractByUniqueIndex

func GetContractByUniqueIndex(db *sql.DB, networkId *big.Int, blockNumber *big.Int, address common.Address) (*Contract, error)

GetContractByUniqueIndex retrieves a single contract from the database based on a unique combination of network_id, block_number, and address.

func (*Contract) EncodeCursor

func (c *Contract) EncodeCursor() string

func (*Contract) GetKey

func (c *Contract) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Contract) IsCompleted

func (c *Contract) IsCompleted() bool

type DbStats

type DbStats struct {
	ContractsCount     int64   `json:"contractsCount"`     // The total number of contracts in the database.
	FullContractsCount int64   `json:"fullContractsCount"` // The count of contracts that are fully processed and not partial.
	MetadataCount      int64   `json:"metadataCount"`      // The number of metadata entries related to contracts.
	AstCount           int64   `json:"astCount"`           // The count of AST (Abstract Syntax Tree) entries, typically used for source code analysis.
	CfgCount           int64   `json:"cfgCount"`           // The number of CFG (Control Flow Graph) entries, important for understanding the flow of contracts.
	StandardsCount     int64   `json:"standardsCount"`     // The count of entries related to various contract standards (e.g., ERC-20, ERC-721).
	TokensCount        int64   `json:"tokensCount"`        // The number of token entries, often used in contracts for creating cryptocurrencies or other digital assets.
	ConstructorsCount  int64   `json:"constructsCount"`    // The count of constructor functions within contracts, essential for contract initialization.
	VariablesCount     int64   `json:"variablesCount"`     // The number of variables defined across all contracts.
	FunctionsCount     int64   `json:"functionsCount"`     // The count of functions defined in contracts, crucial for contract operations.
	EventsCount        int64   `json:"eventsCount"`        // The number of events defined in contracts, used for state changes and notifications within the blockchain.
	DatabaseSizeMb     float64 `json:"databaseSizeMb"`     // Size of the database in MB
}

DbStats represents the statistical data regarding various blockchain-related entities stored in the database. This includes counts of contracts, metadata, and other elements important for smart contract analysis and management.

func GetDatabaseStats

func GetDatabaseStats(db *sql.DB) (*DbStats, error)

GetDatabaseStats get full database statistics (mostly just counts)

type Event

type Event struct {
	Id             int64
	NetworkId      *types.BigInt
	ContractId     *types.BigInt
	ReferenceId    string
	Name           string
	Signature      string
	SignatureRaw   string
	SignatureBytes []byte
	Anonymous      bool
	Abi            json.RawMessage
	Unit           json.RawMessage
	Processed      bool
	Partial        bool
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func GetContractEventBySignature

func GetContractEventBySignature(db *sql.DB, networkId *big.Int, contractId int64, signature string) (*Event, error)

GetContractEventBySignature retrieves a single contract event from the database based on a unique combination of network_id, contract id and log signature (topic 0).

func GetContractEventByUniqueIndex

func GetContractEventByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64, referenceId string) (*Event, error)

GetContractEventByUniqueIndex retrieves a single contract function from the database based on a unique combination of network_id and contract id.

func (*Event) EncodeCursor

func (c *Event) EncodeCursor() string

func (*Event) GetKey

func (c *Event) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, network id, and contract id.

func (*Event) IsCompleted

func (c *Event) IsCompleted() bool

type Function

type Function struct {
	Id             int64
	NetworkId      *types.BigInt
	ContractId     *types.BigInt
	ReferenceId    string
	Name           string
	Type           string
	Signature      string
	SignatureRaw   string
	SignatureBytes []byte
	Abi            json.RawMessage
	Implemented    bool
	Visibility     string
	Mutability     string
	Virtual        bool
	Unit           json.RawMessage
	Processed      bool
	Partial        bool
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func GetContractFunctionBySignature

func GetContractFunctionBySignature(db *sql.DB, networkId *big.Int, contractId int64, signature string) (*Function, error)

GetContractFunctionBySignature retrieves a single contract function from the database based on a unique combination of network_id and contract id and signature.

func GetContractFunctionByUniqueIndex

func GetContractFunctionByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64, referenceId string) (*Function, error)

GetContractFunctionByUniqueIndex retrieves a single contract function from the database based on a unique combination of network_id and contract id.

func GetFunctionBySignature

func GetFunctionBySignature(db *sql.DB, networkId *big.Int, signature string) (*Function, error)

GetFunctionBySignature retrieves a single contract function from the database based on a unique combination of network_id and signature.

func (*Function) EncodeCursor

func (c *Function) EncodeCursor() string

func (*Function) GetKey

func (c *Function) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, network id, and contract id.

func (*Function) IsCompleted

func (c *Function) IsCompleted() bool

type Metadata

type Metadata struct {
	Id          int64
	NetworkId   *types.BigInt
	ContractId  *types.BigInt
	CborLength  int16
	AuxBytes    string
	Ipfs        string
	Bzzr0       string
	Bzzr1       string
	SolcVersion string
	Processed   bool
	Partial     bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func GetContractMetadataByUniqueIndex

func GetContractMetadataByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64) (*Metadata, error)

GetContractMetadataByUniqueIndex retrieves a single contract metadata from the database based on a unique combination of network_id and contract id.

func (*Metadata) EncodeCursor

func (c *Metadata) EncodeCursor() string

func (*Metadata) GetKey

func (c *Metadata) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Metadata) IsCompleted

func (c *Metadata) IsCompleted() bool

type Standard

type Standard struct {
	Id               int64
	NetworkId        *types.BigInt
	ContractId       *types.BigInt
	Name             string
	Type             standards.Standard
	Confidence       string
	ConfidencePoints float64
	DiscoveredTokens int64
	MaximumTokens    int64
	Threshold        float64
	Unit             json.RawMessage
	Processed        bool
	Partial          bool
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

func GetContractStandardByUniqueIndex

func GetContractStandardByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64, standardType standards.Standard) (*Standard, error)

GetContractStandardByUniqueIndex retrieves a single contract standard from the database based on a unique combination of network_id and contract id.

func (*Standard) EncodeCursor

func (c *Standard) EncodeCursor() string

func (*Standard) GetKey

func (c *Standard) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, network id, and contract id.

func (*Standard) IsCompleted

func (c *Standard) IsCompleted() bool

type Token

type Token struct {
	Id          int64
	NetworkId   *types.BigInt
	ContractId  *types.BigInt
	Name        string
	Symbol      string
	Decimals    int64
	TotalSupply string
	Valid       bool
	Processed   bool
	Partial     bool
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func GetTokenByUniqueIndex

func GetTokenByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64) (*Token, error)

GetTokenByUniqueIndex retrieves a single token from the database based on a unique combination of network_id and contract id.

func (*Token) EncodeCursor

func (c *Token) EncodeCursor() string

func (*Token) GetKey

func (c *Token) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Token) IsCompleted

func (c *Token) IsCompleted() bool

type Variable

type Variable struct {
	Id              int64
	NetworkId       *types.BigInt
	ContractId      *types.BigInt
	Name            string
	Type            string
	StateMutability string
	Visibility      string
	IsConstant      bool
	IsAddress       bool
	IsContract      bool
	IsArray         bool
	IsDynamicArray  bool
	IsMapping       bool
	IsStruct        bool
	StorageIndex    int64
	Size            int64
	Offset          int64
	Unit            json.RawMessage
	Processed       bool
	Partial         bool
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

func GetContractVariableByUniqueIndex

func GetContractVariableByUniqueIndex(db *sql.DB, networkId *big.Int, contractId int64, name string) (*Variable, error)

GetContractVariableByUniqueIndex retrieves a single contract state variable from the database based on a unique combination of network_id and contract id.

func (*Variable) EncodeCursor

func (c *Variable) EncodeCursor() string

func (*Variable) GetKey

func (c *Variable) GetKey() string

GetKey constructs and returns a unique key for the entry combining the prefix, network, networkID, and address.

func (*Variable) IsCompleted

func (c *Variable) IsCompleted() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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