gateway

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMetadataImage is the default image for table's metadata.
	DefaultMetadataImage = "https://bafkreifhuhrjhzbj4onqgbrmhpysk2mop2jimvdvfut6taiyzt2yqzt43a.ipfs.dweb.link"

	// DefaultAnimationURL is an empty string. It means that the attribute will not appear in the JSON metadata.
	DefaultAnimationURL = ""
)

Variables

View Source
var ErrTableNotFound = errors.New("table not found")

ErrTableNotFound indicates that the table doesn't exist.

Functions

This section is empty.

Types

type Column added in v1.3.0

type Column struct {
	Name string `json:"name"`
}

Column defines a column in table data.

type ColumnSchema added in v1.3.0

type ColumnSchema struct {
	Name        string
	Type        string
	Constraints []string
}

ColumnSchema represents the schema of a column.

type ColumnValue added in v1.3.0

type ColumnValue struct {
	// contains filtered or unexported fields
}

ColumnValue wraps data from the db that may be raw json or any other value.

func JSONColValue added in v1.3.0

func JSONColValue(v json.RawMessage) *ColumnValue

JSONColValue creates a UserValue with the provided json.

func OtherColValue added in v1.3.0

func OtherColValue(v interface{}) *ColumnValue

OtherColValue creates a UserValue with the provided other value.

func (*ColumnValue) MarshalJSON added in v1.3.0

func (cv *ColumnValue) MarshalJSON() ([]byte, error)

MarshalJSON implements MarshalJSON.

func (*ColumnValue) Scan added in v1.3.0

func (cv *ColumnValue) Scan(src interface{}) error

Scan implements Scan.

func (*ColumnValue) Value added in v1.3.0

func (cv *ColumnValue) Value() interface{}

Value returns the underlying value.

type Gateway

type Gateway interface {
	RunReadQuery(ctx context.Context, stmt string) (*TableData, error)
	GetTableMetadata(context.Context, tableland.ChainID, tables.TableID) (TableMetadata, error)
	GetReceiptByTransactionHash(context.Context, tableland.ChainID, common.Hash) (Receipt, bool, error)
}

Gateway defines the gateway operations.

func NewGateway

func NewGateway(
	parser parsing.SQLValidator,
	store GatewayStore,
	extURLPrefix string,
	metadataRendererURI string,
	animationRendererURI string,
) (Gateway, error)

NewGateway creates a new gateway service.

func NewInstrumentedGateway

func NewInstrumentedGateway(gateway Gateway) (Gateway, error)

NewInstrumentedGateway creates a new InstrumentedGateway.

type GatewayService

type GatewayService struct {
	// contains filtered or unexported fields
}

GatewayService implements the Gateway interface using SQLStore.

func (*GatewayService) GetReceiptByTransactionHash

func (g *GatewayService) GetReceiptByTransactionHash(
	ctx context.Context, chainID tableland.ChainID, txnHash common.Hash,
) (Receipt, bool, error)

GetReceiptByTransactionHash returns a receipt by transaction hash.

func (*GatewayService) GetTableMetadata

func (g *GatewayService) GetTableMetadata(
	ctx context.Context, chainID tableland.ChainID, id tables.TableID,
) (TableMetadata, error)

GetTableMetadata returns table's metadata fetched from SQLStore.

func (*GatewayService) RunReadQuery

func (g *GatewayService) RunReadQuery(ctx context.Context, statement string) (*TableData, error)

RunReadQuery allows the user to run SQL.

type GatewayStore added in v1.3.0

type GatewayStore interface {
	Read(context.Context, parsing.ReadStmt) (*TableData, error)
	GetTable(context.Context, tableland.ChainID, tables.TableID) (Table, error)
	GetSchemaByTableName(context.Context, string) (TableSchema, error)
	GetReceipt(context.Context, tableland.ChainID, string) (Receipt, bool, error)
}

GatewayStore is the storage layer of the Gateway.

type InstrumentedGateway

type InstrumentedGateway struct {
	// contains filtered or unexported fields
}

InstrumentedGateway implements an instrumented Gateway.

func (*InstrumentedGateway) GetReceiptByTransactionHash

func (g *InstrumentedGateway) GetReceiptByTransactionHash(
	ctx context.Context, chainID tableland.ChainID, hash common.Hash,
) (Receipt, bool, error)

GetReceiptByTransactionHash implements gateway.Gateway.

func (*InstrumentedGateway) GetTableMetadata

func (g *InstrumentedGateway) GetTableMetadata(
	ctx context.Context,
	chainID tableland.ChainID,
	id tables.TableID,
) (TableMetadata, error)

GetTableMetadata returns table's metadata fetched from SQLStore.

func (*InstrumentedGateway) RunReadQuery

func (g *InstrumentedGateway) RunReadQuery(ctx context.Context, statement string) (*TableData, error)

RunReadQuery allows the user to run SQL.

type Receipt added in v1.3.0

type Receipt struct {
	ChainID       tableland.ChainID
	BlockNumber   int64
	IndexInBlock  int64
	TxnHash       string
	TableIDs      []tables.TableID
	Error         *string
	ErrorEventIdx *int

	// Deprecated: the Receipt must hold information of all tables that were modified by the transaction.
	// This field was replaced by TableIDs.
	TableID *tables.TableID
}

Receipt represents a Tableland receipt.

type Table added in v1.3.0

type Table struct {
	ID         tables.TableID    `json:"id"` // table id
	ChainID    tableland.ChainID `json:"chain_id"`
	Controller string            `json:"controller"` // controller address
	Prefix     string            `json:"prefix"`
	Structure  string            `json:"structure"`
	CreatedAt  time.Time         `json:"created_at"`
}

Table represents a system-wide table stored in Tableland.

func (Table) Name added in v1.3.0

func (t Table) Name() string

Name returns table's full name.

type TableData added in v1.3.0

type TableData struct {
	Columns []Column         `json:"columns"`
	Rows    [][]*ColumnValue `json:"rows"`
}

TableData defines a tabular representation of query results.

type TableMetadata added in v1.3.0

type TableMetadata struct {
	Name         string                   `json:"name,omitempty"`
	ExternalURL  string                   `json:"external_url"`
	Image        string                   `json:"image"`
	Message      string                   `json:"message,omitempty"`
	AnimationURL string                   `json:"animation_url,omitempty"`
	Attributes   []TableMetadataAttribute `json:"attributes,omitempty"`
	Schema       TableSchema              `json:"schema"`
}

TableMetadata represents table metadata (OpenSea standard).

type TableMetadataAttribute added in v1.3.0

type TableMetadataAttribute struct {
	DisplayType string      `json:"display_type"`
	TraitType   string      `json:"trait_type"`
	Value       interface{} `json:"value"`
}

TableMetadataAttribute represents the table metadata attribute.

type TableSchema added in v1.3.0

type TableSchema struct {
	Columns          []ColumnSchema
	TableConstraints []string
}

TableSchema represents the schema of a table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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