model

package
v0.2.41 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableContract = "contracts"

	ContractTypePst   = "pst"
	ContractTypeOther = "other"
)
View Source
const (
	TableBundleItem = "bundle_items"
)
View Source
const TableContractSource = "contracts_src"
View Source
const (
	TableInteraction = "interactions"
)
View Source
const TableState = "sync_state"

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, dbConfig *config.Database, username, password, applicationName string) (self *gorm.DB, err error)

func Migrate

func Migrate(ctx context.Context, config *config.Config) (err error)

func NewConnection

func NewConnection(ctx context.Context, config *config.Config, applicationName string) (self *gorm.DB, err error)

func NewReadOnlyConnection added in v0.2.8

func NewReadOnlyConnection(ctx context.Context, config *config.Config, applicationName string) (self *gorm.DB, err error)

Types

type AppSyncContractNotification

type AppSyncContractNotification struct {
	ContractTxId   string `json:"contractTxId"`
	Creator        string `json:"creator"`
	Type           string `json:"type"`
	BlockHeight    uint64 `json:"blockHeight"`
	BlockTimestamp uint64 `json:"blockTimestamp"`
	Source         string `json:"source"`
	SyncTimestamp  int64  `json:"syncTimestamp"`
}

func (*AppSyncContractNotification) MarshalBinary

func (self *AppSyncContractNotification) MarshalBinary() (data []byte, err error)

type BundleItem

type BundleItem struct {
	// Numerical id of the interaction
	InteractionID int
	// Alternative way of bundling. GW creates data items and stores them in this column
	DataItem pgtype.Bytea
	// Can be preloaded by gorm, but isn't by default.
	Interaction Interaction
	// Oryginal transaction needed to create the bundle
	Transaction pgtype.JSONB
	// Tags created by the sequencer
	Tags pgtype.JSONB
	// State of bundle
	State BundleState
	// Block height upon which interaction was bundled. Used to trigger verification later
	BlockHeight sql.NullInt64
	// Response from bundlr.network
	BundlrResponse pgtype.JSONB
	// Time of the last update to this row
	UpdatedAt time.Time
}

CREATE TABLE "bundle_items" ("interaction_id" bigserial NOT NULL,"state" bundle_state NOT NULL,"block_height" bigint,"updated_at" timestamptz,PRIMARY KEY ("interaction_id"),CONSTRAINT "fk_bundle_items_interaction" FOREIGN KEY ("interaction_id") REFERENCES "interactions"("id")) CREATE INDEX IF NOT EXISTS "idx_bundle_items_block_height" ON "bundle_items" USING btree("block_height" desc) WHERE state != 'ON_ARWEAVE'

func (BundleItem) TableName

func (BundleItem) TableName() string

type BundleItemNotification

type BundleItemNotification struct {
	InteractionID int           `json:"id"`
	Transaction   *pgtype.JSONB `json:"tx"`
	Tags          *pgtype.JSONB `json:"tg"`
	DataItem      *string       `json:"di"`
}

JSON message sent through the notification channel

type BundleState

type BundleState string
const (
	BundleStatePending   BundleState = "PENDING"
	BundleStateUploading BundleState = "UPLOADING"
	BundleStateUploaded  BundleState = "UPLOADED"
	BundleStateChecking  BundleState = "CHECKING"
	BundleStateOnArweave BundleState = "ON_ARWEAVE"
	BundleStateMalformed BundleState = "MALFORMED"
)

func (*BundleState) Scan

func (self *BundleState) Scan(value interface{}) error

func (BundleState) Value

func (self BundleState) Value() (driver.Value, error)

type Contract

type Contract struct {
	ContractId          string
	SrcTxId             pgtype.Varchar
	InitState           pgtype.JSONB
	Owner               pgtype.Varchar
	Type                pgtype.Varchar
	Project             pgtype.Varchar
	PstTicker           pgtype.Varchar
	PstName             pgtype.Varchar
	BlockHeight         uint64 // NOT NULL
	ContentType         pgtype.Varchar
	BundlerContractTxId pgtype.Varchar
	BundlerContractNode pgtype.Varchar
	ContractTx          pgtype.JSONB
	BlockTimestamp      uint64 // NOT NULL
	Testnet             pgtype.Varchar
	DeploymentType      pgtype.Varchar
	Manifest            pgtype.JSONB
	SyncTimestamp       pgtype.Int8
}

func NewContract

func NewContract() *Contract

type ContractNotification

type ContractNotification struct {
	ContractTxId string        `json:"contractTxId"`
	Test         bool          `json:"test"`
	Source       string        `json:"source"`
	InitialState pgtype.JSONB  `json:"initialState"`
	Tags         []arweave.Tag `json:"tags"`
	SrcTxId      string        `json:"srcTxId"`
}

func (*ContractNotification) MarshalBinary

func (self *ContractNotification) MarshalBinary() (data []byte, err error)

type ContractSource

type ContractSource struct {
	SrcTxId         string
	Src             pgtype.Text
	SrcContentType  pgtype.Varchar
	SrcBinary       pgtype.Bytea
	SrcWasmLang     pgtype.Varchar
	BundlerSrcTxId  pgtype.Varchar
	BundlerSrcNode  pgtype.Varchar
	SrcTx           pgtype.JSONB
	Owner           pgtype.Varchar
	Testnet         pgtype.Text
	BundlerResponse pgtype.Text
	DeploymentType  pgtype.Varchar
}

func NewContractSource

func NewContractSource() *ContractSource

func (*ContractSource) IsJS

func (self *ContractSource) IsJS() bool

func (ContractSource) TableName

func (ContractSource) TableName() string

type Interaction

type Interaction struct {
	ID                 int `json:"id"`
	InteractionId      arweave.Base64String
	Interaction        pgtype.JSONB `json:"interaction"`
	BlockHeight        int64
	BlockId            arweave.Base64String
	ContractId         string `json:"contractId"`
	Function           string
	Input              string
	ConfirmationStatus string
	InteractWrite      pq.StringArray `gorm:"type:text[]"`
	SortKey            string
	LastSortKey        pgtype.Text

	// Time when interaction was synced to te database
	SyncTimestamp pgtype.Int8

	// https://github.com/warp-contracts/gateway/blob/main/src/gateway/tasks/syncTransactions.ts#L175
	Evolve sql.NullString

	// https://github.com/warp-contracts/gateway/blob/ef7aad549045943f0127542cce36cd94a966bdc7/src/gateway/tasks/syncTransactions.ts#L187
	Testnet sql.NullString

	// Hardcoded arsyncer
	Source string

	// Wallet address, 44 characters
	Owner string

	// Not needed:
	BundlerTxId string

	// LastSortKey       string
	BlockTimestamp int64
}

func (*Interaction) GetInteraction

func (self *Interaction) GetInteraction() *smartweave.Interaction

type InteractionNotification

type InteractionNotification struct {
	ContractTxId string `json:"contractTxId"`
	Test         bool   `json:"test"`
	Source       string `json:"source"`
	Interaction  string `json:"interaction"`
	SrcTxId      string `json:"srcTxId"`
}

func (*InteractionNotification) MarshalBinary

func (self *InteractionNotification) MarshalBinary() (data []byte, err error)

type State

type State struct {
	// Name of the synced component (interactions, contracts)
	Name SyncedComponent `gorm:"primaryKey" json:"name"`

	// Timestamp of the last fully processed transaction block
	FinishedBlockTimestamp uint64 `json:"finished_block_timestamp"`

	// Height of the last fully processed  transaction block
	FinishedBlockHeight uint64 `json:"finished_block_height"`

	// Hash of the last fully processed transaction block
	// Next block needs to have this hash set as its previous block hash
	FinishedBlockHash arweave.Base64String `json:"finished_block_hash"`
}

func (State) TableName

func (State) TableName() string

type SyncedComponent

type SyncedComponent string
const (
	SyncedComponentInteractions SyncedComponent = "Interactions"
	SyncedComponentContracts    SyncedComponent = "Contracts"
	SyncedComponentForwarder    SyncedComponent = "Forwarder"
	SyncedComponentSequencer    SyncedComponent = "Sequencer"
	SyncedComponentRelayer      SyncedComponent = "Relayer"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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