models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddressArrReflectType reflect.Type = reflect.TypeOf([]common.Address{})
View Source
var HashArrReflectType reflect.Type = reflect.TypeOf([]common.Hash{})
View Source
var StringArrReflectType reflect.Type = reflect.TypeOf("string")

Functions

This section is empty.

Types

type Block

type Block struct {
	Number           int64          `json:"number" gorm:"primaryKey"`
	Hash             common.Hash    `json:"hash" gorm:"size:32;uniqueIndex"`
	ParentHash       common.Hash    `json:"parentHash" gorm:"size:32"`
	Nonce            string         `json:"nonce" gorm:"type:char(18)"`
	SHA3Uncles       common.Hash    `json:"sha3Uncles" gorm:"size:32"`
	LogsBloom        string         `json:"logsBloom" gorm:"size:514"`
	TransactionsRoot common.Hash    `json:"transactionsRoot" gorm:"size:32"`
	StateRoot        common.Hash    `json:"stateRoot" gorm:"size:32"`
	ReceiptsRoot     common.Hash    `json:"receiptsRoot" gorm:"size:32"`
	Miner            common.Address `json:"miner" gorm:"size:20"`
	ExtraData        []byte         `json:"extraData"`
	GasLimit         int64          `json:"gasLimit"`
	GasUsed          int64          `json:"gasUsed"`
	Timestamp        int64          `json:"timestamp"`
	Difficulty       string         `json:"difficulty"`
	// Uncles will be of type text or longtext depending on the driver type
	Uncles []common.Hash `json:"uncles" gorm:"serializer:stringer_joiner"`
	// Transactions will be of type text or longtext depending on the driver type
	Transactions  []common.Hash `json:"transactions" gorm:"serializer:stringer_joiner"`
	MixHash       common.Hash   `json:"mixHash" gorm:"size:32"`
	BaseFeePerGas *int64        `json:"baseFeePerGas"`
}

func (Block) TableName

func (Block) TableName() string

type ByteArraySerializer

type ByteArraySerializer struct{}

type Code

type Code struct {
	// CodeHash common.Hash `gorm:"primaryKey"`
	ID             common.Hash `gorm:"column:code_hash;size:32;primaryKey"`
	Code           string
	Abi            datatypes.JSON
	AbiLastChecked sql.NullTime
}

func (Code) TableName

func (Code) TableName() string

type Contract

type Contract struct {
	Address common.Address `gorm:"size:20;primaryKey"`
	// Foreign Key into "eth_code"
	CodeID       *common.Hash `gorm:"column:code;size:32"`
	Code         *Code
	Metadata     datatypes.JSON
	MetadataUri  string
	CompositeAbi datatypes.JSON
}

func (Contract) TableName

func (Contract) TableName() string

type EventSignature

type EventSignature struct {
	HexSignature  string `gorm:"primaryKey"`
	TextSignature string
}

func (EventSignature) TableName

func (EventSignature) TableName() string

type FunctionSignature

type FunctionSignature struct {
	HexSignature  string `gorm:"primaryKey"`
	TextSignature string
}

func (FunctionSignature) TableName

func (FunctionSignature) TableName() string

type Interface

type Interface struct {
	ID   string `gorm:"primaryKey;type:char(10)"`
	Name string
	Abi  datatypes.JSON
}

func (Interface) TableName

func (Interface) TableName() string

type Log

type Log struct {
	BlockNumber      int64          `json:"blockNumber" gorm:"primaryKey"`
	LogIndex         int64          `json:"logIndex" gorm:"primaryKey"`
	BlockHash        common.Hash    `json:"blockHash" gorm:"size:32"`
	TransactionHash  common.Hash    `json:"transactionHash" gorm:"size:32"`
	TransactionIndex int64          `json:"transactionIndex"`
	Address          common.Address `json:"address" gorm:"size:20"`
	Data             []byte         `json:"data"`
	Topic0           common.Hash    `json:"topic0" gorm:"size:32;index:idx_721,priority:1;index:idx_1155,priority:1"`
	Topic1           common.Hash    `json:"topic1" gorm:"size:32"`
	Topic2           common.Hash    `json:"topic2" gorm:"size:32;index:idx_721"`
	Topic3           common.Hash    `json:"topic3" gorm:"size:32;index:idx_1155"`
	Removed          bool           `json:"removed"`
}

Primary key: BlockNumber + LogIndex

func LogsAsArraysToLogs

func LogsAsArraysToLogs(arr LogsAsArrays) []*Log

Assume all arrays are of same length

func (Log) TableName

func (Log) TableName() string

type LogsAsArrays

type LogsAsArrays struct {
	BlockNumber      []int64          `json:"blockNumber" gorm:"primaryKey"`
	LogIndex         []int64          `json:"logIndex" gorm:"primaryKey"`
	BlockHash        []common.Hash    `json:"blockHash" gorm:"size:32"`
	TransactionHash  []common.Hash    `json:"transactionHash" gorm:"size:32"`
	TransactionIndex []int64          `json:"transactionIndex"`
	Address          []common.Address `json:"address" gorm:"size:20"`
	Data             [][]byte         `json:"data"`
	Topic0           []common.Hash    `json:"topic0" gorm:"size:32;index:idx_721,priority:1;index:idx_1155,priority:1"`
	Topic1           []common.Hash    `json:"topic1" gorm:"size:32"`
	Topic2           []common.Hash    `json:"topic2" gorm:"size:32;index:idx_721"`
	Topic3           []common.Hash    `json:"topic3" gorm:"size:32;index:idx_1155"`
	Removed          []bool           `json:"removed"`
}

func LogsToLogsAsArrays

func LogsToLogsAsArrays(logs []*Log) LogsAsArrays

type StringerJoinerSerializer

type StringerJoinerSerializer struct{}

func (StringerJoinerSerializer) Scan

func (StringerJoinerSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)

Assumes field is a slice

func (StringerJoinerSerializer) String

func (StringerJoinerSerializer) Value

func (StringerJoinerSerializer) Value(ctx context.Context, field *schema.Field, dst reflect.Value, fieldValue interface{}) (interface{}, error)

Assumes field a slice

type SupportsInterface

type SupportsInterface struct {
	Address common.Address `gorm:"size:20;primaryKey"`
	// Foreign Key into "eth_code"
	Interface string `gorm:"primaryKey;type:char(10)"`
	Supports  bool
}

func (SupportsInterface) TableName

func (SupportsInterface) TableName() string

type Token

type Token struct {
	Address     common.Address `gorm:"size:20;primaryKey"`
	Metadata    datatypes.JSON
	MetadataUrl string
	TokenID     string `gorm:"type:varchar(34);primaryKey"`
	Image       string
	Type        string
}

func (Token) TableName

func (Token) TableName() string

type Transaction

type Transaction struct {
	Hash             common.Hash     `json:"hash" gorm:"size:32;primaryKey"`
	BlockHash        common.Hash     `json:"blockHash" gorm:"size:32"`
	BlockNumber      int64           `json:"blockNumber"`
	TransactionIndex int64           `json:"transactionIndex"`
	From             common.Address  `json:"from" gorm:"size:20"`
	To               *common.Address `json:"to" gorm:"size:20"`
	ContractAddress  *common.Address `json:"contractAddress" gorm:"size:20"`
	Value            string          `json:"value"`
	GasPrice         int64           `json:"gasPrice"`
	Gas              int64           `json:"gas"`
	GasUsed          int64           `json:"gasUsed"`
	Input            []byte          `json:"input"`
	Nonce            int64           `json:"nonce"`
	Logs             []*Log          `json:"logs"`
}

NOTE: Pointers => nullable field, except for strings

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

func (Transaction) TableName

func (Transaction) TableName() string

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

type TransactionsHash

type TransactionsHash struct {
	Hash common.Hash `json:"hash" gorm:"size:32"`
}

func (TransactionsHash) TableName

func (TransactionsHash) TableName() string

Jump to

Keyboard shortcuts

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