storage

package
v0.0.0-...-e2aa0ca Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntityTypeClass = iota
	EntityTypeContract
)

entity types

View Source
const (
	Unknown = "UNKNOWN"
)

unknown

Variables

View Source
var Models = []storage.Model{
	&State{},
	&Address{},
	&Class{},
	&ClassReplace{},
	&StorageDiff{},
	&Block{},
	&Invoke{},
	&Declare{},
	&Deploy{},
	&DeployAccount{},
	&L1Handler{},
	&Internal{},
	&Event{},
	&Message{},
	&Transfer{},
	&Fee{},
	&Token{},
	&TokenBalance{},
	&ProxyUpgrade{},
	&Proxy{},
}

Models - list all models

View Source
var ModelsAny = []any{
	&State{},
	&Address{},
	&Class{},
	&ClassReplace{},
	&StorageDiff{},
	&Block{},
	&Invoke{},
	&Declare{},
	&Deploy{},
	&DeployAccount{},
	&L1Handler{},
	&Internal{},
	&Event{},
	&Message{},
	&Transfer{},
	&Fee{},
	&Token{},
	&TokenBalance{},
	&ProxyUpgrade{},
	&Proxy{},
}

ModelsAny - list all models with any type

Functions

This section is empty.

Types

type Address

type Address struct {
	bun.BaseModel `bun:"address" comment:"Table with starknet and ethereum addresses."`

	ID      uint64  `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	ClassID *uint64 `bun:"class_id" comment:"Class identity. It is NULL for ethereum addresses."`
	Height  uint64  `comment:"Block number of the first address occurrence."`
	Hash    []byte  `bun:",unique:address_hash" comment:"Address hash."`

	Class Class `bun:"rel:belongs-to,join:class_id=id" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
}

Address -

func (Address) GetHeight

func (address Address) GetHeight() uint64

GetHeight -

func (Address) GetId

func (address Address) GetId() uint64

GetId -

func (Address) TableName

func (Address) TableName() string

TableName -

type AddressFilter

type AddressFilter struct {
	ID           IntegerFilter
	Height       IntegerFilter
	OnlyStarknet bool
}

AddressFilter -

type BetweenFilter

type BetweenFilter struct {
	From uint64
	To   uint64
}

BetweenFilter -

type Block

type Block struct {
	bun.BaseModel `bun:"block" comment:"Block table"`

	ID      uint64    `bun:",pk,autoincrement" comment:"Unique internal identity"`
	Height  uint64    `comment:"The number (height) of this block"`
	Time    time.Time `comment:"The time the sequencer created this block before executing transactions"`
	Version *string   `comment:"The version of the Starknet protocol used when creating this block"`

	TxCount            int `comment:"Transactions count in block"`
	InvokeCount        int `comment:"Ivokes count in block"`
	DeclareCount       int `comment:"Declares count in block"`
	DeployCount        int `comment:"Deploys count in block"`
	DeployAccountCount int `comment:"Deploy accounts count in block"`
	L1HandlerCount     int `bun:"l1_handler_count" comment:"L1 handlers count in block"`
	StorageDiffCount   int `comment:"Storage diffs count in block"`

	Status           Status `comment:"Block status"`
	Hash             []byte `comment:"Block hash"`
	ParentHash       []byte `comment:"The hash of this block’s parent"`
	NewRoot          []byte `comment:"The state commitment after this block"`
	SequencerAddress []byte `comment:"The Starknet address of the sequencer who created this block"`

	Invoke        []Invoke        `bun:"rel:has-many"`
	Declare       []Declare       `bun:"rel:has-many"`
	Deploy        []Deploy        `bun:"rel:has-many"`
	DeployAccount []DeployAccount `bun:"rel:has-many"`
	L1Handler     []L1Handler     `bun:"rel:has-many"`
	Fee           []Fee           `bun:"rel:has-many"`
	StorageDiffs  []StorageDiff   `bun:"rel:has-many"`
}

Block -

func (Block) TableName

func (Block) TableName() string

TableName -

type Bytes

type Bytes stdJSON.RawMessage

Bytes -

func MustNewBytes

func MustNewBytes(str string) Bytes

MustNewBytes -

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

MarshalJSON returns b as the JSON encoding of b.

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *b to a copy of data.

func (*Bytes) UnmarshalYAML

func (b *Bytes) UnmarshalYAML(unmarshal func(interface{}) error) error

Implements the Unmarshaler interface of the yaml pkg.

type BytesFilter

type BytesFilter struct {
	Eq []byte
	In [][]byte
}

BytesFilter -

type CallType

type CallType int

CallType -

const (
	CallTypeUnknown CallType = iota + 1
	CallTypeCall
	CallTypeDelegate
)

func NewCallType

func NewCallType(value string) CallType

NewCallType -

func (CallType) String

func (s CallType) String() string

String -

type Class

type Class struct {
	bun.BaseModel `bun:"class" comment:"Classes table"`

	ID     uint64    `bun:"id,type:bigint,pk,notnull,nullzero" comment:"Unique internal identity"`
	Type   ClassType `comment:"Class type. It’s a binary mask."`
	Hash   []byte    `bun:",unique:class_hash" comment:"Class hash"`
	Abi    Bytes     `bun:",type:bytea" comment:"Class abi in a raw"`
	Height uint64    `comment:"Block height of the first class occurance"`
	Cairo  int       `bun:",default:0,type:SMALLINT" comment:"Cairo version of class"`
}

Class -

func (Class) TableName

func (Class) TableName() string

TableName -

type ClassReplace

type ClassReplace struct {
	bun.BaseModel `bun:"class_replace" comment:"Table with class replace history"`

	ID          uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
	ContractId  uint64 `bun:"contract_id"                 comment:"Contract id"`
	PrevClassId uint64 `bun:"prev_class_id"               comment:"Previous class id"`
	NextClassId uint64 `bun:"next_class_id"               comment:"Next class id"`
	Height      uint64 `bun:"height"                      comment:"Block height"`

	Contract  Address `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	PrevClass Class   `bun:"rel:belongs-to,join:prev_class_id=id" hasura:"table:class,field:prev_class_id,remote_field:id,type:oto,name:prev_class"`
	NextClass Class   `bun:"rel:belongs-to,join:next_class_id=id" hasura:"table:class,field:next_class_id,remote_field:id,type:oto,name:next_class"`
}

ClassReplace -

func (ClassReplace) TableName

func (ClassReplace) TableName() string

TableName -

type ClassType

type ClassType uint64

ClassType -

const (
	ClassTypeERC20 ClassType = 1 << iota
	ClassTypeERC721
	ClassTypeERC721Metadata
	ClassTypeERC721Receiver
	ClassTypeERC1155
	ClassTypeERC1155Metadata
	ClassTypeERC1155Receiver
	ClassTypeProxy
	ClassTypeArgentX0
	ClassTypeArgentX
	ClassTypeBraavos
	ClassTypeAccount
)

class types

func NewClassType

func NewClassType(interfaces ...string) ClassType

NewClassType -

func (ClassType) Is

func (ct ClassType) Is(typ ClassType) bool

Is -

func (ClassType) OneOf

func (ct ClassType) OneOf(typ ...ClassType) bool

OneOf -

func (*ClassType) Set

func (ct *ClassType) Set(types ...ClassType)

Set -

type CopiableModel

type CopiableModel interface {
	storage.Model
	storage.Copiable
}

CopiableModel -

type Declare

type Declare struct {
	bun.BaseModel `bun:"declare" comment:"Table with declare transactions" partition:"RANGE(time)"`

	ID         uint64          `bun:"id,type:bigint,pk,notnull,nullzero" comment:"Unique internal identity"`
	Height     uint64          `comment:"Block height"`
	ClassID    uint64          `comment:"Declared class id"`
	Version    uint64          `comment:"Declare transaction version"`
	Position   int             `comment:"Order in block"`
	SenderID   *uint64         `comment:"Sender address id"`
	ContractID *uint64         `comment:"Contract address id"`
	Time       time.Time       `bun:",pk" comment:"Time of block"`
	Status     Status          `comment:"Status of block"`
	Hash       []byte          `comment:"Transaction hash"`
	MaxFee     decimal.Decimal `bun:",type:numeric" comment:"The maximum fee that the sender is willing to pay for the transaction"`
	Nonce      decimal.Decimal `bun:",type:numeric" comment:"The transaction nonce"`
	Error      *string         `bun:"error" comment:"Reverted error"`

	Class     Class      `bun:"rel:belongs-to" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
	Sender    Address    `bun:"rel:belongs-to" hasura:"table:address,field:sender_id,remote_field:id,type:oto,name:sender"`
	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
	Fee       *Fee       `bun:"rel:belongs-to"`
}

Declare -

func (Declare) Columns

func (Declare) Columns() []string

Columns -

func (Declare) Flat

func (d Declare) Flat() []any

Flat -

func (Declare) GetHeight

func (d Declare) GetHeight() uint64

GetHeight -

func (Declare) GetId

func (d Declare) GetId() uint64

GetId -

func (Declare) TableName

func (Declare) TableName() string

TableName -

type DeclareFilter

type DeclareFilter struct {
	ID      IntegerFilter
	Height  IntegerFilter
	Time    TimeFilter
	Status  EnumFilter
	Version EnumFilter
}

DeclareFilter -

type Deploy

type Deploy struct {
	bun.BaseModel `bun:"deploy" comment:"Table with deploy transactions" partition:"RANGE(time)"`

	ID                  uint64         `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height              uint64         `comment:"Block height"`
	ClassID             uint64         `comment:"Class id"`
	ContractID          uint64         `comment:"Contract address id"`
	Position            int            `comment:"Order in block"`
	Time                time.Time      `bun:",pk" comment:"Time of block"`
	Status              Status         ``
	Hash                []byte         `comment:"Transaction hash"`
	ContractAddressSalt []byte         `comment:"A random salt that determines the account address"`
	ConstructorCalldata []string       `bun:",array" comment:"Raw constructor calldata"`
	ParsedCalldata      map[string]any `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`
	Error               *string        `bun:"error" comment:"Reverted error"`

	Class     Class      `bun:"rel:belongs-to" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
	Fee       *Fee       `bun:"rel:belongs-to"`
	Token     *Token     `bun:"-"`
}

Deploy -

func (Deploy) Columns

func (Deploy) Columns() []string

Columns -

func (Deploy) Flat

func (d Deploy) Flat() []any

Flat -

func (Deploy) GetHeight

func (d Deploy) GetHeight() uint64

GetHeight -

func (Deploy) GetId

func (d Deploy) GetId() uint64

GetId -

func (Deploy) TableName

func (Deploy) TableName() string

TableName -

type DeployAccount

type DeployAccount struct {
	bun.BaseModel `bun:"deploy_account" comment:"table with deploy account transactions" partition:"RANGE(time)"`

	ID                  uint64          `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height              uint64          `comment:"Block height"`
	ClassID             uint64          `comment:"Class id"`
	ContractID          uint64          `comment:"Contract address id"`
	Position            int             `comment:"Order in block"`
	Time                time.Time       `bun:",pk" comment:"Time of block"`
	Status              Status          ``
	Hash                []byte          `comment:"Transaction hash"`
	ContractAddressSalt []byte          `comment:"A random salt that determines the account address"`
	MaxFee              decimal.Decimal `bun:",type:numeric" comment:"The maximum fee that the sender is willing to pay for the transaction"`
	Nonce               decimal.Decimal `bun:",type:numeric" comment:"The transaction nonce"`
	ConstructorCalldata []string        `bun:",array" comment:"Raw constructor calldata"`
	ParsedCalldata      map[string]any  `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`
	Error               *string         `bun:"error" comment:"Reverted error"`

	Class     Class      `bun:"rel:belongs-to" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
	Fee       *Fee       `bun:"rel:belongs-to"`
}

DeployAccount -

func (DeployAccount) Columns

func (DeployAccount) Columns() []string

Columns -

func (DeployAccount) Flat

func (d DeployAccount) Flat() []any

Flat -

func (DeployAccount) GetHeight

func (d DeployAccount) GetHeight() uint64

GetHeight -

func (DeployAccount) GetId

func (d DeployAccount) GetId() uint64

GetId -

func (DeployAccount) TableName

func (DeployAccount) TableName() string

TableName -

type DeployAccountFilter

type DeployAccountFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Class          BytesFilter
	ParsedCalldata map[string]string
}

DeployAccountFilter -

type DeployFilter

type DeployFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Class          BytesFilter
	ParsedCalldata map[string]string
}

DeployFilter -

type EntityType

type EntityType int8

EntityType -

type EntrypointType

type EntrypointType int

EntrypointType -

const (
	EntrypointTypeUnknown EntrypointType = iota + 1
	EntrypointTypeExternal
	EntrypointTypeConstructor
	EntrypointTypeL1Handler
)

func NewEntrypointType

func NewEntrypointType(value string) EntrypointType

NewEntrypointType -

func (EntrypointType) String

func (s EntrypointType) String() string

String -

type EnumFilter

type EnumFilter struct {
	Eq    uint64
	Neq   uint64
	In    []uint64
	Notin []uint64
}

EnumFilter -

type EnumStringFilter

type EnumStringFilter struct {
	Eq    string
	Neq   string
	In    []string
	Notin []string
}

EnumStringFilter -

type EqualityFilter

type EqualityFilter struct {
	Eq  string
	Neq string
}

EqualityFilter -

type Event

type Event struct {
	bun.BaseModel `bun:"event" comment:"Table with events" partition:"RANGE(time)"`

	ID     uint64    `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height uint64    `comment:"Block height"`
	Time   time.Time `bun:",pk" comment:"Time of block"`

	InvokeID        *uint64 `comment:"Parent invoke id"`
	DeclareID       *uint64 `comment:"Parent declare id"`
	DeployID        *uint64 `comment:"Parent deploy id"`
	DeployAccountID *uint64 `comment:"Parent deploy account id"`
	L1HandlerID     *uint64 `comment:"Parent l1 handler id"`
	FeeID           *uint64 `comment:"Parent fee invocation id"`
	InternalID      *uint64 `comment:"Parent internal transaction id"`

	Order      uint64         `comment:"Order in block"`
	ContractID uint64         `comment:"Contract address id"`
	FromID     uint64         `comment:"From address id"`
	Keys       []string       `bun:",array" comment:"Raw event keys"`
	Data       []string       `bun:",array" comment:"Raw event data"`
	Name       string         `comment:"Event name"`
	ParsedData map[string]any `bun:",nullzero" comment:"Event data parsed according to contract ABI"`

	From     Address `bun:"rel:belongs-to" hasura:"table:address,field:from_id,remote_field:id,type:oto,name:from"`
	Contract Address `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
}

Event -

func (Event) Columns

func (Event) Columns() []string

Columns -

func (Event) Flat

func (e Event) Flat() []any

Flat -

func (Event) GetHeight

func (e Event) GetHeight() uint64

GetHeight -

func (Event) GetId

func (e Event) GetId() uint64

GetId -

func (Event) TableName

func (Event) TableName() string

TableName -

type EventFilter

type EventFilter struct {
	ID         IntegerFilter
	Height     IntegerFilter
	Time       TimeFilter
	Contract   IdFilter
	From       IdFilter
	Name       StringFilter
	ParsedData map[string]string
}

EventFilter -

type Fee

type Fee struct {
	bun.BaseModel `bun:"fee" comment:"Table with fee invocations" partition:"RANGE(time)"`

	ID     uint64    `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height uint64    `comment:"Block height"`
	Time   time.Time `bun:",pk" comment:"Time of block"`

	ContractID uint64 `comment:"Contract address id"`
	CallerID   uint64 `comment:"Caller address id"`
	ClassID    uint64 `comment:"Class id"`

	InvokeID        *uint64 `comment:"Parent invoke id"`
	DeclareID       *uint64 `comment:"Parent declare id"`
	DeployID        *uint64 `comment:"Parent deploy id"`
	DeployAccountID *uint64 `comment:"Parent deploy account id"`
	L1HandlerID     *uint64 `comment:"Parent l1 handler id"`

	EntrypointType EntrypointType `bun:",type:SMALLINT" comment:"Entrypoint type (unknown - 1 | external - 2 | constructor - 3 | l1 handler - 4)"`
	CallType       CallType       `bun:",type:SMALLINT" comment:"Call type (unknwown - 1 | call - 2 | delegate - 3)"`
	Status         Status         `` /* 172-byte string literal not displayed */

	Selector       []byte         `comment:"Called selector"`
	Entrypoint     string         `comment:"Entrypoint name"`
	Calldata       []string       `bun:",array" comment:"Raw calldata"`
	Result         []string       `bun:",array" comment:"Raw result"`
	ParsedCalldata map[string]any `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`

	Class     Class      `bun:"rel:belongs-to" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
	Caller    Address    `bun:"rel:belongs-to" hasura:"table:address,field:caller_id,remote_field:id,type:oto,name:caller"`
	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
}

Fee -

func (Fee) Columns

func (Fee) Columns() []string

Columns -

func (Fee) Flat

func (f Fee) Flat() []any

Flat -

func (Fee) GetHeight

func (f Fee) GetHeight() uint64

GetHeight -

func (Fee) GetId

func (f Fee) GetId() uint64

GetId -

func (Fee) TableName

func (Fee) TableName() string

TableName -

type FeeFilter

type FeeFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Contract       BytesFilter
	Caller         BytesFilter
	Class          BytesFilter
	Selector       EqualityFilter
	Entrypoint     StringFilter
	EntrypointType EnumFilter
	CallType       EnumFilter
	ParsedCalldata map[string]string
}

FeeFilter -

type FilterOption

type FilterOption func(opt *FilterOptions)

FilterOption -

func WithAscSortByIdFilter

func WithAscSortByIdFilter() FilterOption

WithAscSortByIdFilter -

func WithCursor

func WithCursor(id uint64) FilterOption

WithCursor -

func WithDescSortByIdFilter

func WithDescSortByIdFilter() FilterOption

WithDescSortByIdFilter -

func WithLimitFilter

func WithLimitFilter(limit int) FilterOption

WithLimitFilter -

func WithMaxHeight

func WithMaxHeight(height uint64, columnName string) FilterOption

WithMaxHeight -

func WithMultiSort

func WithMultiSort(fields ...string) FilterOption

WithMultiSort -

func WithOffsetFilter

func WithOffsetFilter(offset int) FilterOption

WithOffsetFilter -

func WithSortFilter

func WithSortFilter(field string, order storage.SortOrder) FilterOption

WithSortFilter -

type FilterOptions

type FilterOptions struct {
	Limit  int
	Offset int

	SortField string
	SortOrder storage.SortOrder

	SortFields []string

	MaxHeight        uint64
	HeightColumnName string
	Cursor           uint64
}

FilterOptions -

type Filterable

type Filterable[M storage.Model, F any] interface {
	Filter(ctx context.Context, flt []F, opts ...FilterOption) ([]M, error)
}

Filterable -

type HashByHeight

type HashByHeight interface {
	HashByHeight(ctx context.Context, height uint64) ([]byte, error)
}

type Heightable

type Heightable interface {
	storage.Model

	GetHeight() uint64
	GetId() uint64
}

Heightable -

type IAddress

type IAddress interface {
	storage.Table[*Address]

	Filterable[Address, AddressFilter]

	GetByHash(ctx context.Context, hash []byte) (Address, error)
	GetAddresses(ctx context.Context, ids ...uint64) ([]Address, error)
	GetByHashes(ctx context.Context, hash [][]byte) ([]Address, error)
}

type IBlock

type IBlock interface {
	storage.Table[*Block]

	ByHeight(ctx context.Context, height uint64) (Block, error)
	Last(ctx context.Context) (Block, error)
	ByStatus(ctx context.Context, status Status, limit, offset uint64, order storage.SortOrder) ([]Block, error)
}

type IClass

type IClass interface {
	storage.Table[*Class]

	GetByHash(ctx context.Context, hash []byte) (Class, error)
	GetUnresolved(ctx context.Context) ([]Class, error)
}

type IClassReplace

type IClassReplace interface {
	storage.Table[*ClassReplace]

	ByHeight(ctx context.Context, height uint64) ([]ClassReplace, error)
}

type IDeploy

type IDeploy interface {
	storage.Table[*Deploy]
	Filterable[Deploy, DeployFilter]
	HashByHeight
}

type IEvent

type IEvent interface {
	storage.Table[*Event]
	Filterable[Event, EventFilter]
}

type IFee

type IFee interface {
	storage.Table[*Fee]
	Filterable[Fee, FeeFilter]
}

type IInternal

type IInternal interface {
	storage.Table[*Internal]
	Filterable[Internal, InternalFilter]
}

type IInvoke

type IInvoke interface {
	storage.Table[*Invoke]
	Filterable[Invoke, InvokeFilter]
	HashByHeight
}

type IMessage

type IMessage interface {
	storage.Table[*Message]

	Filterable[Message, MessageFilter]
}

type IProxy

type IProxy interface {
	storage.Table[*Proxy]

	GetByHash(ctx context.Context, address, selector []byte) (Proxy, error)
}

type IProxyUpgrade

type IProxyUpgrade interface {
	storage.Table[*ProxyUpgrade]

	LastBefore(ctx context.Context, hash, selector []byte, height uint64) (ProxyUpgrade, error)
	ListWithHeight(ctx context.Context, height uint64, limit, offset int) ([]ProxyUpgrade, error)
}

type IState

type IState interface {
	storage.Table[*State]

	ByName(ctx context.Context, name string) (State, error)
}

type IStorageDiff

type IStorageDiff interface {
	storage.Table[*StorageDiff]
	Filterable[StorageDiff, StorageDiffFilter]

	GetOnBlock(ctx context.Context, height, contractId uint64, key []byte) (StorageDiff, error)
}

type IToken

type IToken interface {
	storage.Table[*Token]
	Filterable[Token, TokenFilter]

	Find(ctx context.Context, contractId uint64, tokenId string) (Token, error)
	ListByType(ctx context.Context, typ TokenType, limit uint64, offset uint64, order storage.SortOrder) ([]Token, error)
}

type ITokenBalance

type ITokenBalance interface {
	storage.Table[*TokenBalance]
	Filterable[TokenBalance, TokenBalanceFilter]

	Balances(ctx context.Context, contractId uint64, tokenId int64, limit, offset int) ([]TokenBalance, error)
}

type ITransfer

type ITransfer interface {
	storage.Table[*Transfer]
	Filterable[Transfer, TransferFilter]
}

type IdFilter

type IdFilter struct {
	Eq uint64
	In []uint64
}

IdFilter -

type IntegerFilter

type IntegerFilter struct {
	Eq      uint64
	Neq     uint64
	Gt      uint64
	Gte     uint64
	Lt      uint64
	Lte     uint64
	Between *BetweenFilter
}

IntegerFilter -

type Internal

type Internal struct {
	bun.BaseModel `bun:"internal_tx" comment:"Table with internal transactions" partition:"RANGE(time)"`

	ID     uint64    `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height uint64    `comment:"Block height"`
	Time   time.Time `bun:",pk" comment:"Time of block"`

	InvokeID        *uint64 `comment:"Parent invoke id"`
	DeclareID       *uint64 `comment:"Parent declare id"`
	DeployID        *uint64 `comment:"Parent deploy id"`
	DeployAccountID *uint64 `comment:"Parent deploy account id"`
	L1HandlerID     *uint64 `comment:"Parent l1 handler id"`
	InternalID      *uint64 `comment:"Parent internal transaction id"`
	ClassID         uint64  `comment:"Class id"`
	CallerID        uint64  `comment:"Caller address id"`
	ContractID      uint64  `comment:"Contract address id"`

	Status         Status         `` /* 172-byte string literal not displayed */
	EntrypointType EntrypointType `bun:",type:SMALLINT" comment:"Entrypoint type (unknown - 1 | external - 2 | constructor - 3 | l1 handler - 4)"`
	CallType       CallType       `bun:",type:SMALLINT" comment:"Call type (unknwown - 1 | call - 2 | delegate - 3)"`

	Hash           []byte         `comment:"Transaction hash"`
	Selector       []byte         `comment:"Called selector"`
	Entrypoint     string         `comment:"Entrypoint name"`
	Result         []string       `bun:",array" comment:"Raw result"`
	Calldata       []string       `bun:",array" comment:"Raw calldata"`
	ParsedCalldata map[string]any `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`
	ParsedResult   map[string]any `bun:",nullzero" comment:"Result parsed according to contract ABI"`

	Class     Class      `bun:"rel:belongs-to" hasura:"table:class,field:class_id,remote_field:id,type:oto,name:class"`
	Caller    Address    `bun:"rel:belongs-to" hasura:"table:address,field:caller_id,remote_field:id,type:oto,name:caller"`
	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
}

Internal -

func (Internal) Columns

func (Internal) Columns() []string

Columns -

func (Internal) Flat

func (i Internal) Flat() []any

Flat -

func (Internal) GetHeight

func (i Internal) GetHeight() uint64

GetHeight -

func (Internal) GetId

func (i Internal) GetId() uint64

GetId -

func (Internal) TableName

func (Internal) TableName() string

TableName -

type InternalFilter

type InternalFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Contract       BytesFilter
	Caller         BytesFilter
	Class          BytesFilter
	Selector       EqualityFilter
	Entrypoint     StringFilter
	EntrypointType EnumFilter
	CallType       EnumFilter
	ParsedCalldata map[string]string
}

InternalFilter -

type Invoke

type Invoke struct {
	bun.BaseModel `bun:"invoke" comment:"Table with invokes" partition:"RANGE(time)"`

	ID                 uint64          `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height             uint64          `comment:"Block height"`
	Time               time.Time       `bun:",pk" comment:"Time of block"`
	Status             Status          `` /* 151-byte string literal not displayed */
	Hash               []byte          `comment:"Transaction hash"`
	Version            uint64          `comment:"Version of invoke transaction"`
	Position           int             `comment:"Order in block"`
	ContractID         uint64          `comment:"Contract address id"`
	EntrypointSelector []byte          `comment:"Called selector"`
	Entrypoint         string          `comment:"Entrypoint name"`
	MaxFee             decimal.Decimal `bun:",type:numeric" comment:"The maximum fee that the sender is willing to pay for the transaction"`
	Nonce              decimal.Decimal `bun:",type:numeric" comment:"The transaction nonce"`
	CallData           []string        `bun:",array" comment:"Raw calldata"`
	ParsedCalldata     map[string]any  `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`
	Error              *string         `bun:"error" comment:"Reverted error"`

	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
	Fee       *Fee       `bun:"rel:belongs-to"`
}

Invoke -

func (Invoke) Columns

func (Invoke) Columns() []string

Columns -

func (Invoke) Flat

func (i Invoke) Flat() []any

Flat -

func (Invoke) GetHeight

func (invoke Invoke) GetHeight() uint64

GetHeight -

func (Invoke) GetId

func (invoke Invoke) GetId() uint64

GetId -

func (Invoke) TableName

func (Invoke) TableName() string

TableName -

type InvokeFilter

type InvokeFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Version        EnumFilter
	Contract       BytesFilter
	Selector       EqualityFilter
	Entrypoint     StringFilter
	ParsedCalldata map[string]string
}

InvokeFilter -

type L1Handler

type L1Handler struct {
	bun.BaseModel `bun:"l1_handler" comment:"Table with l1 handler transactions" partition:"RANGE(time)"`

	ID             uint64          `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Height         uint64          `comment:"Block height"`
	Time           time.Time       `bun:",pk" comment:"Time of block"`
	Status         Status          `` /* 165-byte string literal not displayed */
	Hash           []byte          `comment:"Transaction hash"`
	ContractID     uint64          `comment:"Contract address id"`
	Position       int             `comment:"Order in block"`
	Selector       []byte          `comment:"Called selector"`
	Entrypoint     string          `comment:"Entrypoint name"`
	MaxFee         decimal.Decimal `bun:",type:numeric" comment:"The maximum fee that the sender is willing to pay for the transaction"`
	Nonce          decimal.Decimal `bun:",type:numeric" comment:"The transaction nonce"`
	CallData       []string        `bun:",array" comment:"Raw calldata"`
	ParsedCalldata map[string]any  `bun:",nullzero" comment:"Calldata parsed according to contract ABI"`
	Error          *string         `bun:"error" comment:"Reverted error"`

	Contract  Address    `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Internals []Internal `bun:"rel:has-many"`
	Messages  []Message  `bun:"rel:has-many"`
	Transfers []Transfer `bun:"rel:has-many"`
	Events    []Event    `bun:"rel:has-many"`
	Fee       *Fee       `bun:"rel:belongs-to"`
}

L1Handler -

func (L1Handler) Columns

func (L1Handler) Columns() []string

Columns -

func (L1Handler) Flat

func (l1 L1Handler) Flat() []any

Flat -

func (L1Handler) GetHeight

func (l1 L1Handler) GetHeight() uint64

GetHeight -

func (L1Handler) GetId

func (l1 L1Handler) GetId() uint64

GetId -

func (L1Handler) TableName

func (L1Handler) TableName() string

TableName -

type L1HandlerFilter

type L1HandlerFilter struct {
	ID             IntegerFilter
	Height         IntegerFilter
	Time           TimeFilter
	Status         EnumFilter
	Contract       BytesFilter
	Selector       EqualityFilter
	Entrypoint     StringFilter
	ParsedCalldata map[string]string
}

L1HandlerFilter -

type Message

type Message struct {
	bun.BaseModel `bun:"message" comment:"Table with messages" partition:"RANGE(time)"`

	ID     uint64    `bun:",pk,autoincrement,nullzero" comment:"Unique internal identity"`
	Height uint64    `comment:"Block height"`
	Time   time.Time `bun:",pk" comment:"Time of block"`

	InvokeID        *uint64 `comment:"Parent invoke id"`
	DeclareID       *uint64 `comment:"Parent declare id"`
	DeployID        *uint64 `comment:"Parent deploy id"`
	DeployAccountID *uint64 `comment:"Parent deploy account id"`
	L1HandlerID     *uint64 `comment:"Parent l1 handler id"`
	FeeID           *uint64 `comment:"Parent fee invocation id"`
	InternalID      *uint64 `comment:"Parent internal transaction id"`

	ContractID uint64          `comment:"Contract address id"`
	Order      uint64          `comment:"Order in block"`
	FromID     uint64          `comment:"From address id"`
	ToID       uint64          `comment:"To address id"`
	Selector   string          `comment:"Called selector"`
	Nonce      decimal.Decimal `bun:",type:numeric" comment:"The transaction nonce"`
	Payload    []string        `bun:",array" comment:"Message payload"`

	From     Address `bun:"rel:belongs-to" hasura:"table:address,field:from_id,remote_field:id,type:oto,name:from"`
	To       Address `bun:"rel:belongs-to" hasura:"table:address,field:to_id,remote_field:id,type:oto,name:to"`
	Contract Address `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
}

Message -

func (Message) Columns

func (msg Message) Columns() []string

Columns -

func (Message) Flat

func (msg Message) Flat() []any

Flat -

func (Message) GetHeight

func (msg Message) GetHeight() uint64

GetHeight -

func (Message) GetId

func (msg Message) GetId() uint64

GetId -

func (Message) TableName

func (Message) TableName() string

TableName -

type MessageFilter

type MessageFilter struct {
	ID       IntegerFilter
	Height   IntegerFilter
	Time     TimeFilter
	Contract BytesFilter
	From     BytesFilter
	To       BytesFilter
	Selector EqualityFilter
}

MessageFilter -

type Proxy

type Proxy struct {
	bun.BaseModel `bun:"proxy"`

	ID         uint64     `bun:",pk,autoincrement" comment:"Unique internal identity"`
	ContractID uint64     `comment:"Proxy contract id"`
	Hash       []byte     `comment:"Proxy contract hash"`
	Selector   []byte     `comment:"Proxy contract selector (for modules)"`
	EntityType EntityType `comment:"Entity type behind proxy (0 - class | 1 - contract)"`
	EntityID   uint64     `comment:"Entity id behind proxy"`
	EntityHash []byte     `comment:"Entity hash behind proxy"`

	Contract Address `bun:"rel:belongs-to,join:contract_id=id" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Entity   Address `bun:"rel:belongs-to,join:entity_id=id" hasura:"table:address,field:entity_id,remote_field:id,type:oto,name:entity"`
}

Proxy -

func (Proxy) TableName

func (Proxy) TableName() string

TableName -

type ProxyAction

type ProxyAction int

ProxyAction -

const (
	ProxyActionAdd ProxyAction = iota
	ProxyActionUpdate
	ProxyActionDelete
)

default proxy actions

type ProxyUpgrade

type ProxyUpgrade struct {
	bun.BaseModel `bun:"proxy_upgrade"`

	ID         uint64      `bun:",pk,autoincrement" comment:":Unique internal identity"`
	ContractID uint64      `comment:":Proxy contract id"`
	Hash       []byte      `comment:":Proxy contract hash"`
	Selector   []byte      `comment:":Proxy contract selector (for modules)"`
	EntityType EntityType  `comment:"Entity type behind proxy (0 - class | 1 - contract)"`
	EntityID   uint64      `comment:":Entity id behind proxy"`
	EntityHash []byte      `comment:":Entity hash behind proxy"`
	Height     uint64      `comment:":Height when event occured"`
	Action     ProxyAction `comment:":Action which occured with proxy (0 - add | 1 - update | 2 - delete)"`
}

ProxyUpgrade -

func NewUpgradeFromProxy

func NewUpgradeFromProxy(p Proxy) ProxyUpgrade

NewUpgradeFromProxy -

func (ProxyUpgrade) TableName

func (ProxyUpgrade) TableName() string

TableName -

func (ProxyUpgrade) ToProxy

func (pu ProxyUpgrade) ToProxy() Proxy

ToProxy -

type Rollback

type Rollback interface {
	Rollback(ctx context.Context, indexerName string, height uint64) error
}

Rollback -

type State

type State struct {
	bun.BaseModel `bun:"state"`

	ID         uint64    `bun:",pk,autoincrement" comment:"Unique internal identity"`
	Name       string    `bun:",unique:state_name"`
	LastHeight uint64    `comment:"Last block height"`
	LastTime   time.Time `comment:"Time of last block"`

	InvokesCount        uint64 `comment:"Total invokes count"`
	DeploysCount        uint64 `comment:"Total deploys count"`
	DeployAccountsCount uint64 `comment:"Total deploy accounts count"`
	DeclaresCount       uint64 `comment:"Total declares count"`
	L1HandlersCount     uint64 `comment:"Total l1 handlers count"`
	TxCount             uint64 `comment:"Total transactions count"`

	LastClassID   uint64 `comment:"Last internal class id"`
	LastAddressID uint64 `comment:"Last internal address id"`
	LastTxID      uint64 `comment:"Last internal transaction id"`
	LastEventID   uint64 `comment:"Last internal event id"`
}

State -

func (State) TableName

func (State) TableName() string

TableName -

type Status

type Status int

Status -

const (
	StatusUnknown Status = iota + 1
	StatusNotReceived
	StatusReceived
	StatusPending
	StatusRejected
	StatusAcceptedOnL2
	StatusAcceptedOnL1
	StatusReverted
)

func NewStatus

func NewStatus(value string) Status

NewStatus -

func (Status) String

func (s Status) String() string

String -

type StorageDiff

type StorageDiff struct {
	bun.BaseModel `bun:"storage_diff"`

	ID         uint64 `bun:",pk,autoincrement" comment:"Unique internal identity"`
	Height     uint64 `comment:"Block height"`
	ContractID uint64 `comment:"Contract id which storage was changed"`
	Key        []byte `comment:"Storage key"`
	Value      []byte `comment:"Data"`

	Contract Address `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
}

StorageDiff -

func (StorageDiff) Columns

func (StorageDiff) Columns() []string

Columns -

func (StorageDiff) Flat

func (sd StorageDiff) Flat() []any

Flat -

func (StorageDiff) GetHeight

func (sd StorageDiff) GetHeight() uint64

GetHeight -

func (StorageDiff) GetId

func (sd StorageDiff) GetId() uint64

GetId -

func (StorageDiff) TableName

func (StorageDiff) TableName() string

TableName -

type StorageDiffFilter

type StorageDiffFilter struct {
	ID       IntegerFilter
	Height   IntegerFilter
	Contract BytesFilter
	Key      EqualityFilter
}

StorageDiffFilter -

type StringFilter

type StringFilter struct {
	Eq string
	In []string
}

StringFilter -

type TimeFilter

type TimeFilter struct {
	Gt      uint64
	Gte     uint64
	Lt      uint64
	Lte     uint64
	Between *BetweenFilter
}

TimeFilter -

type Token

type Token struct {
	bun.BaseModel `bun:"token"`

	ID          uint64          `bun:"id,pk,autoincrement" comment:"Unique internal identity"`
	FirstHeight uint64          `comment:"Block height when token was first time transferred or minted"`
	ContractId  uint64          `bun:",unique:token_unique_id" comment:"Token contract id"`
	TokenId     decimal.Decimal `bun:",unique:token_unique_id,type:numeric" comment:"Token id"`
	Type        TokenType       `bun:",type:token_type" comment:"Token type"`

	Contract Address `bun:"rel:belongs-to,join:contract_id=id" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
}

Token -

func (Token) GetHeight

func (t Token) GetHeight() uint64

GetHeight -

func (Token) GetId

func (t Token) GetId() uint64

GetId -

func (Token) String

func (t Token) String() string

String -

func (Token) TableName

func (Token) TableName() string

TableName -

type TokenBalance

type TokenBalance struct {
	bun.BaseModel `bun:"token_balance" comment:"Table with token balances"`

	OwnerID    uint64          `bun:",pk" comment:"Identity of owner address"`
	ContractID uint64          `bun:",pk" comment:"Identity of contract address"`
	TokenID    decimal.Decimal `bun:",pk,type:numeric" comment:"Token id"`
	Balance    decimal.Decimal `bun:",type:numeric" comment:"Token balance"`

	Contract Address `bun:"rel:belongs-to,join:contract_id=id" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Owner    Address `bun:"rel:belongs-to,join:owner_id=id" hasura:"table:address,field:owner_id,remote_field:id,type:oto,name:owner"`
}

TokenBalance -

func (TokenBalance) String

func (tb TokenBalance) String() string

String -

func (TokenBalance) TableName

func (TokenBalance) TableName() string

TableName -

type TokenBalanceFilter

type TokenBalanceFilter struct {
	Owner    BytesFilter
	Contract BytesFilter
	TokenId  StringFilter
}

TokenBalanceFilter -

type TokenFilter

type TokenFilter struct {
	ID       IntegerFilter
	Contract IdFilter
	TokenId  StringFilter
	Type     EnumStringFilter
}

TokenFilter -

type TokenType

type TokenType string

TokenType -

const (
	TokenTypeERC20   TokenType = "erc20"
	TokenTypeERC721  TokenType = "erc721"
	TokenTypeERC1155 TokenType = "erc1155"
)

token types

type TransactionType

type TransactionType int

TransactionType -

const (
	TransactionTypeUnknown TransactionType = iota + 1
	TransactionTypeInvoke
	TransactionTypeDeclare
	TransactionTypeDeploy
	TransactionTypeDeployAccount
	TransactionTypeL1Handler
)

func NewTransactionType

func NewTransactionType(value string) TransactionType

NewTransactionType -

func (TransactionType) String

func (t TransactionType) String() string

String -

type Transfer

type Transfer struct {
	bun.BaseModel `bun:"transfer" comment:"Trandfer table" partition:"RANGE(time)"`

	ID         uint64          `bun:",pk,autoincrement" comment:"Unique internal identity"`
	Height     uint64          `comment:"Block height"`
	Time       time.Time       `bun:",pk" comment:"Block time"`
	ContractID uint64          `comment:"Token contract id"`
	FromID     uint64          `comment:"Id address which transfer from"`
	ToID       uint64          `comment:"Id address which transfer to"`
	Amount     decimal.Decimal `bun:",type:numeric" comment:"Amount of transfer"`
	TokenID    decimal.Decimal `bun:",type:numeric" comment:"Id token which was transferred"`

	InvokeID        *uint64 `comment:"Parent invoke id"`
	DeclareID       *uint64 `comment:"Parent declare id"`
	DeployID        *uint64 `comment:"Parent deploy id"`
	DeployAccountID *uint64 `comment:"Parent deploy account id"`
	L1HandlerID     *uint64 `comment:"Parent l1 handler id"`
	FeeID           *uint64 `comment:"Parent fee invocation id"`
	InternalID      *uint64 `comment:"Parent internal transaction id"`

	From     Address `bun:"rel:belongs-to" hasura:"table:address,field:from_id,remote_field:id,type:oto,name:from"`
	To       Address `bun:"rel:belongs-to" hasura:"table:address,field:to_id,remote_field:id,type:oto,name:to"`
	Contract Address `bun:"rel:belongs-to" hasura:"table:address,field:contract_id,remote_field:id,type:oto,name:contract"`
	Token    Token   `bun:"-" hasura:"table:token,field:contract_id,remote_field:contract_id,type:oto,name:token"`
}

Transfer -

func (Transfer) Columns

func (Transfer) Columns() []string

Columns -

func (Transfer) Flat

func (transfer Transfer) Flat() []any

Flat -

func (Transfer) GetHeight

func (transfer Transfer) GetHeight() uint64

GetHeight -

func (Transfer) GetId

func (transfer Transfer) GetId() uint64

GetId -

func (Transfer) TableName

func (Transfer) TableName() string

TableName -

func (Transfer) TokenBalanceUpdates

func (transfer Transfer) TokenBalanceUpdates() []TokenBalance

TokenBalanceUpdates -

type TransferFilter

type TransferFilter struct {
	ID       IntegerFilter
	Height   IntegerFilter
	Time     TimeFilter
	Contract BytesFilter
	From     BytesFilter
	To       BytesFilter
	TokenId  StringFilter
}

TransferFilter -

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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