model

package
v0.2.201 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 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 (
	TableDataItem = "data_items"
)
View Source
const (
	TableInteraction = "interactions"
)
View Source
const TableState = "sync_state"
View Source
const TableWarpySyncerAssets = "warpy_syncer_assets"
View Source
const TableWarpySyncerTransactions = "warpy_syncer_transactions"

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
	// Which bundling service was used to send this data item
	Service pgtype.Text
	// 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"
	BundleStateDuplicate BundleState = "DUPLICATE"
)

func (*BundleState) Scan

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

func (BundleState) Value

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

type BundlingService added in v0.2.105

type BundlingService string
const (
	BundlingServiceIrys  BundlingService = "IRYS"
	BundlingServiceTurbo BundlingService = "TURBO"
)

func (BundlingService) String added in v0.2.131

func (self BundlingService) String() string

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 DataItem added in v0.2.105

type DataItem struct {
	// Id of the data item
	DataItemID string `gorm:"primaryKey"`

	// Data item, ready to be sent. This is a nested bundle or a plain data item
	DataItem pgtype.Bytea

	// State of bundle
	State BundleState

	// Which bundling service was used to send this data item
	Service pgtype.Text

	// Block height upon which interaction was bundled. Used to trigger verification later
	BlockHeight pgtype.Int8

	// Response from bundlr.network
	Response pgtype.JSONB

	// Time of the last update to this row
	UpdatedAt time.Time

	// Time of creation
	CreatedAt time.Time
}

func (DataItem) TableName added in v0.2.105

func (DataItem) TableName() string

type DataItemNotification added in v0.2.105

type DataItemNotification struct {
	DataItemId string `json:"id"`
}

JSON message sent through the notification channel

type DiscordIdRolesPayload added in v0.2.199

type DiscordIdRolesPayload struct {
	IdToRoles map[string][]string `json:"id_to_roles"`
}

type Interaction

type Interaction struct {
	ID                 int `json:"id" gorm:"primaryKey"`
	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

func (Interaction) TableName added in v0.2.79

func (Interaction) TableName() string

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"
	SyncedComponentWarpySyncerAvax     SyncedComponent = "WarpySyncerAvax"
	SyncedComponentWarpySyncerArbitrum SyncedComponent = "WarpySyncerArbitrum"
	SyncedComponentWarpySyncerMode     SyncedComponent = "WarpySyncerMode"
	SyncedComponentWarpySyncerManta    SyncedComponent = "WarpySyncerManta"
)

type WalletDiscordIdPayload added in v0.2.199

type WalletDiscordIdPayload struct {
	WalletToDiscordId map[string]string `json:"wallet_to_id"`
}

type WarpySyncerAssets added in v0.2.173

type WarpySyncerAssets struct {
	TxId        string  `gorm:"primaryKey" json:"tx_id"`
	FromAddress string  `json:"from_address"`
	Assets      float64 `json:"assets"`
	Timestamp   uint64  `json:"timestamp"`
	Protocol    string  `json:"protocol"`
	Chain       string  `json:"chain"`
}

type WarpySyncerTransaction added in v0.2.173

type WarpySyncerTransaction struct {
	TxId           string       `gorm:"primaryKey" json:"tx_id"`
	FromAddress    string       `json:"from_address"`
	ToAddress      string       `json:"to_address"`
	BlockHeight    uint64       `json:"block_height"`
	BlockTimestamp uint64       `json:"block_timestamp"`
	SyncTimestamp  uint64       `json:"sync_timestamp"`
	MethodName     string       `json:"method_name"`
	Chain          string       `json:"chain"`
	Protocol       string       `json:"protocol"`
	Input          pgtype.JSONB `json:"input"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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