store

package
v1.4.4-beta Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PENDING                 string = "PENDING"
	IN_NETWORK              string = "IN_NETWORK"
	SUCCESS                 string = "SUCCESS"
	REVERTED                string = "REVERTED"
	LOW_NONCE               string = "LOW_NONCE"
	NO_GAS                  string = "NO_GAS"
	LOW_GAS_PRICE           string = "LOW_GAS_PRICE"
	REPLACEMENT_UNDERPRICED string = "REPLACEMENT_UNDERPRICED"
	NETWORK_ERROR           string = "NETWORK_ERROR"
	EXTERNAL_DISPATCH       string = "EXTERNAL_DISPATCH"
	UNKNOWN_RPC_ERROR       string = "UNKNOWN_ERROR"
)
View Source
const (
	GAS_REFILL       string = "GAS_REFILL"
	ACCOUNT_REGISTER string = "ACCOUNT_REGISTER"
	GAS_TRANSFER     string = "GAS_TRANSFER"
	TOKEN_TRANSFER   string = "TOKEN_TRANSFER"
	TOKEN_APPROVE    string = "TOKEN_APPROVE"
	TOKEN_SWEEP      string = "TOKEN_SWEEP"
	POOL_SWAP        string = "POOL_SWAP"
	POOL_DEPSOIT     string = "POOL_DEPOSIT"
	OTHER_MANUAL     string = "OTHER_MANUAL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DispatchTx

type DispatchTx struct {
	ID        uint64    `db:"id" json:"id"`
	OTXID     uint64    `db:"otx_id" json:"otxId"`
	Status    string    `db:"status" json:"status"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}

type OTX

type OTX struct {
	ID             uint64    `db:"id" json:"id"`
	TrackingID     string    `db:"tracking_id" json:"trackingId"`
	OTXType        string    `db:"otx_type" json:"otxType"`
	SignerAccount  string    `db:"public_key" json:"signerAccount"`
	RawTx          string    `db:"raw_tx" json:"rawTx"`
	TxHash         string    `db:"tx_hash" json:"txHash"`
	Nonce          uint64    `db:"nonce" json:"nonce"`
	Replaced       bool      `db:"replaced" json:"replaced"`
	CreatedAt      time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt      time.Time `db:"updated_at" json:"updatedAt"`
	DispatchStatus string    `db:"status" json:"status"`
}

type Pg

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

func (*Pg) AcquireNonce

func (pg *Pg) AcquireNonce(ctx context.Context, tx pgx.Tx, publicKey string) (uint64, error)

func (*Pg) ActivateKeyPair

func (pg *Pg) ActivateKeyPair(ctx context.Context, tx pgx.Tx, publicKey string) error

func (*Pg) Bootstrap

func (s *Pg) Bootstrap() error

func (*Pg) CheckKeypair

func (pg *Pg) CheckKeypair(ctx context.Context, tx pgx.Tx, publicKey string) (bool, error)

func (*Pg) GetFailedOTX

func (pg *Pg) GetFailedOTX(ctx context.Context, tx pgx.Tx) ([]*OTX, error)

func (*Pg) GetOTXByAccount

func (pg *Pg) GetOTXByAccount(ctx context.Context, tx pgx.Tx, publicKey string, limit int) ([]*OTX, error)

func (*Pg) GetOTXByAccountNext

func (pg *Pg) GetOTXByAccountNext(ctx context.Context, tx pgx.Tx, publicKey string, cursor int, limit int) ([]*OTX, error)

func (*Pg) GetOTXByAccountPrevious

func (pg *Pg) GetOTXByAccountPrevious(ctx context.Context, tx pgx.Tx, publicKey string, cursor int, limit int) ([]*OTX, error)

func (*Pg) GetOTXByTrackingID

func (pg *Pg) GetOTXByTrackingID(ctx context.Context, tx pgx.Tx, trackingID string) ([]*OTX, error)

func (*Pg) GetOTXByTxHash

func (pg *Pg) GetOTXByTxHash(ctx context.Context, tx pgx.Tx, txHash string) (OTX, error)

func (*Pg) InsertDispatchTx

func (pg *Pg) InsertDispatchTx(ctx context.Context, tx pgx.Tx, dispatchTx DispatchTx) error

func (*Pg) InsertKeyPair

func (pg *Pg) InsertKeyPair(ctx context.Context, tx pgx.Tx, keypair keypair.Key) error

func (*Pg) InsertOTX

func (pg *Pg) InsertOTX(ctx context.Context, tx pgx.Tx, otx OTX) (uint64, error)

func (*Pg) LoadMasterSignerKey

func (pg *Pg) LoadMasterSignerKey(ctx context.Context, tx pgx.Tx) (keypair.Key, error)

func (*Pg) LoadPrivateKey

func (pg *Pg) LoadPrivateKey(ctx context.Context, tx pgx.Tx, publicKey string) (keypair.Key, error)

func (*Pg) PeekNonce

func (pg *Pg) PeekNonce(ctx context.Context, tx pgx.Tx, publicKey string) (uint64, error)

func (*Pg) Pool

func (s *Pg) Pool() *pgxpool.Pool

func (*Pg) SetAccountNonce

func (pg *Pg) SetAccountNonce(ctx context.Context, tx pgx.Tx, publicKey string, nonce uint64) error

func (*Pg) UpdateDispatchTxStatus

func (pg *Pg) UpdateDispatchTxStatus(ctx context.Context, tx pgx.Tx, dispatchTx DispatchTx) error

type PgOpts

type PgOpts struct {
	Logg                 *slog.Logger
	DSN                  string
	MigrationsFolderPath string
	QueriesFolderPath    string
}

type Queries

type Queries struct {
	InsertKeyPair           string `query:"insert-keypair"`
	ActivateKeyPair         string `query:"activate-keypair"`
	LoadKey                 string `query:"load-key"`
	CheckKeypair            string `query:"check-keypair"`
	LoadMasterKey           string `query:"load-master-key"`
	BootstrapMasterKey      string `query:"bootstrap-master-key"`
	PeekNonce               string `query:"peek-nonce"`
	AcquireNonce            string `query:"acquire-nonce"`
	SetAcccountNonce        string `query:"set-account-nonce"`
	InsertOTX               string `query:"insert-otx"`
	GetOTXByTxHash          string `query:"get-otx-by-tx-hash"`
	GetOTXByTrackingID      string `query:"get-otx-by-tracking-id"`
	GetOTXByAccount         string `query:"get-otx-by-account"`
	GetOTXByAccountNext     string `query:"get-otx-by-account-next"`
	GetOTXByAccountPrevious string `query:"get-otx-by-account-previous"`
	InsertDispatchTx        string `query:"insert-dispatch-tx"`
	UpdateDispatchTxStatus  string `query:"update-dispatch-tx-status"`
	GetFailedOTX            string `query:"get-failed-otx"`
}

type Store

type Store interface {
	Pool() *pgxpool.Pool
	Bootstrap() error
	// Keys
	InsertKeyPair(context.Context, pgx.Tx, keypair.Key) error
	ActivateKeyPair(context.Context, pgx.Tx, string) error
	CheckKeypair(context.Context, pgx.Tx, string) (bool, error)
	LoadPrivateKey(context.Context, pgx.Tx, string) (keypair.Key, error)
	LoadMasterSignerKey(context.Context, pgx.Tx) (keypair.Key, error)
	// Nonce
	PeekNonce(context.Context, pgx.Tx, string) (uint64, error)
	AcquireNonce(context.Context, pgx.Tx, string) (uint64, error)
	SetAccountNonce(context.Context, pgx.Tx, string, uint64) error
	// OTX
	InsertOTX(context.Context, pgx.Tx, OTX) (uint64, error)
	GetOTXByTxHash(context.Context, pgx.Tx, string) (OTX, error)
	GetOTXByTrackingID(context.Context, pgx.Tx, string) ([]*OTX, error)
	GetOTXByAccount(context.Context, pgx.Tx, string, int) ([]*OTX, error)
	GetOTXByAccountNext(context.Context, pgx.Tx, string, int, int) ([]*OTX, error)
	GetOTXByAccountPrevious(context.Context, pgx.Tx, string, int, int) ([]*OTX, error)
	GetFailedOTX(context.Context, pgx.Tx) ([]*OTX, error)
	// Dispatch
	InsertDispatchTx(context.Context, pgx.Tx, DispatchTx) error
	UpdateDispatchTxStatus(context.Context, pgx.Tx, DispatchTx) error
}

func NewPgStore

func NewPgStore(o PgOpts) (Store, error)

Jump to

Keyboard shortcuts

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