storage

package
v0.0.0-...-391a7ad Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Models = []storage.Model{
	&State{},
	&Address{},
	&TokenMetadata{},
}

Models - list all models

View Source
var TokenUpdateID = types.NewCounter(0)

TokenUpdateID - incremental counter

Functions

func SetLastUpdateID

func SetLastUpdateID(value int64)

Types

type Address

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

	ID   uint64 `bun:"id,type:bigint,pk,notnull" comment:"Unique internal identity"`
	Hash []byte `bun:",unique:address_hash" comment:"Address hash."`
}

Address -

func (Address) TableName

func (Address) TableName() string

TableName -

type IAddress

type IAddress interface {
	storage.Table[*Address]
}

IAddress -

type IState

type IState interface {
	storage.Table[*State]

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

IState -

type ITokenMetadata

type ITokenMetadata interface {
	storage.Table[*TokenMetadata]

	GetByStatus(ctx context.Context, status Status, limit, offset, attempts, delay int) ([]TokenMetadata, error)
}

ITokenMetadata -

type State

type State struct {
	bun.BaseModel `bun:"table:state" comment:"Table contains current indexer's state"`

	ID         uint64    `bun:"id,pk,autoincrement" comment:"Unique internal identity"`
	Name       string    `bun:"name,unique:state_name" comment:"Indexer human-readable name"`
	LastHeight uint64    `comment:"Last block height"`
	LastTime   time.Time `comment:"Time of last block"`
}

State -

func (State) TableName

func (State) TableName() string

TableName -

type Status

type Status string

Status -

const (
	StatusNew     Status = "new"
	StatusFilled  Status = "filled"
	StatusFailed  Status = "failed"
	StatusSuccess Status = "success"
)

defined statuses

type TokenMetadata

type TokenMetadata struct {
	bun.BaseModel `bun:"table:token_metadata" comment:"Table contains token metadata"`

	Id         uint64          `bun:"id,notnull,type:bigint,pk" comment:"Unique internal identity"`
	CreatedAt  int64           `comment:"Time when row was created"`
	UpdatedAt  int64           `comment:"Time when row was last updated"`
	UpdateID   int64           `bun:",notnull" comment:"Update counter, increments on each and any token metadata update"`
	ContractID uint64          `comment:"Token contract id"`
	TokenId    decimal.Decimal `bun:",type:numeric" comment:"Token id"`
	Type       TokenType       `bun:",type:token_type" comment:"Token type"`
	Status     Status          `bun:",type:status" comment:"Status of resolving metadata"`
	Uri        *string         `comment:"Metadata URI"`
	Metadata   map[string]any  `bun:",type:jsonb" comment:"Token metadata as JSON"`
	Attempts   uint            `bun:",type:SMALLINT" comment:"Attempts count of receiving metadata from third-party sources"`
	Error      *string         `comment:"If metadata is failed this field contains error string"`

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

TokenMetadata -

func (*TokenMetadata) BeforeAppendModel

func (tm *TokenMetadata) BeforeAppendModel(ctx context.Context, query bun.Query) error

BeforeAppendModel -

func (TokenMetadata) TableName

func (TokenMetadata) TableName() string

TableName -

type TokenType

type TokenType string

TokenType -

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

token types

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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