Documentation
¶
Index ¶
- Variables
- func BackfillLogs(ctx context.Context, db *gorm.DB, contract string) error
- func GetContractABI(address string) (abi.ABI, error)
- func GetContractEvents(address string) (map[string]abi.Event, error)
- func GetContractEventsCached(address string) (map[string]abi.Event, error)
- func GetTransactionBlock(ctx context.Context, tx string) (uint64, error)
- func Keccak256Hash(data ...[]byte) (common.Hash, error)
- func Open() (*gorm.DB, error)
- func Paginate(query *gorm.DB, page int, pageSize int) (*gorm.DB, error)
- func QueryLogs(ctx context.Context, fromBlock uint64, contract string) (uint64, []types.Log, error)
- func SanitizeHex(address string) string
- func ValidateAddress(address string) bool
- func ValidateTopic(topic string) bool
- type ContractCreation
- type ContractSource
- type Events
- type KeccakState
- type Log
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Uint256, _ = abi.NewType("uint256", "", nil)
Uint32, _ = abi.NewType("uint32", "", nil)
Uint16, _ = abi.NewType("uint16", "", nil)
String, _ = abi.NewType("string", "", nil)
Bool, _ = abi.NewType("bool", "", nil)
Bytes, _ = abi.NewType("bytes", "", nil)
Bytes32, _ = abi.NewType("bytes32", "", nil)
Address, _ = abi.NewType("address", "", nil)
Uint64Arr, _ = abi.NewType("uint64[]", "", nil)
AddressArr, _ = abi.NewType("address[]", "", nil)
Int8, _ = abi.NewType("int8", "", nil)
Approval = makeEvent("Approval",
"owner", Address, indexed,
"spender", Address, indexed,
"value", Uint256, false)
Transfer = makeEvent("Transfer",
"from", Address, indexed,
"to", Address, indexed,
"amount", Uint256, false)
)
View Source
var ( ErrInvalidContractAddress = errors.New("invalid contract address") ErrUnsetEnvironmentVar = errors.New("environment variable not set") ErrNegativePage = errors.New("page cannot be negative") ErrInvalidTopic = errors.New("invalid topic") ErrInvalidResponse = errors.New("invalid response") ErrInvalidResponseBody = errors.New("invalid response body") )
Functions ¶
func BackfillLogs ¶
TODO: Query up to head-64 (?) to retrieve only finalized logs? And then check types.Log.Removed to confirm everything was OK!
func GetContractEventsCached ¶
(address string) (map[string]abi.Event, error) {
func GetTransactionBlock ¶
Given a transaction, return the block it's included in.
func QueryLogs ¶
QueryLogs returns (toBlock, logs, err), where `logs` is all logs in the range of [fromBlock, toBlock).
func SanitizeHex ¶
func ValidateAddress ¶
func ValidateTopic ¶
Types ¶
type ContractCreation ¶
type ContractCreation struct {
ContractAddress string `json:"contractAddress"`
ContractCreator string `json:"contractCreator"`
TxHash string `json:"txHash"`
}
func GetContractCreation ¶
func GetContractCreation(contracts []string) ([]ContractCreation, error)
func GetContractCreation1 ¶
func GetContractCreation1(contract string) (ContractCreation, error)
type ContractSource ¶
type ContractSource struct {
SourceCode string `json:"SourceCode"`
ABI string `json:"ABI"`
ContractName string `json:"ContractName"`
CompilerVersion string `json:"CompilerVersion"`
OptimizationUsed string `json:"OptimizationUsed"`
Runs string `json:"Runs"`
ConstructorArguments string `json:"ConstructorArguments"`
EVMVersion string `json:"EVMVersion"`
Library string `json:"Library"`
LicenseType string `json:"LicenseType"`
Proxy string `json:"Proxy"`
Implementation string `json:"Implementation"`
SwarmSource string `json:"SwarmSource"`
}
func GetContractSource ¶
func GetContractSource(address string) ([]ContractSource, error)
func (ContractSource) String ¶
func (s ContractSource) String() string
type Events ¶
type Log ¶
type Log struct {
ID uint64 `gorm:"primaryKey"`
Address string `gorm:"uniqueIndex:idx_logs_abi;not null"`
Topic0 string ``
Topic1 string ``
Topic2 string ``
Topic3 string ``
Data string ``
BlockNumber uint64 `gorm:"uniqueIndex:idx_logs_abi;not null"`
TxHash string `gorm:"uniqueIndex:idx_logs_hi;not null"`
// Index of the transaction in the block.
TxIndex uint `gorm:"not null"`
// Index of the log in the block.
Index uint `gorm:"uniqueIndex:idx_logs_abi;uniqueIndex:idx_logs_hi;not null"`
}
Unique constraings:
- idx_logs_abi: (address,block_number,index)
- idx_logs_hi: (tx_hash,index)
func FromGethLog ¶
func SelectLogs ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.