transactions

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TransactionJobType = "transaction"

Variables

This section is empty.

Functions

func ArgAsCadence added in v0.8.0

func ArgAsCadence(a Argument) (cadence.Value, error)

func MustDecodeArgs added in v0.8.0

func MustDecodeArgs(aa []Argument) []cadence.Value

Types

type Argument added in v0.8.0

type Argument interface{}

type CadenceArgument added in v0.7.0

type CadenceArgument interface{}

type GormStore

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

func (*GormStore) GetOrCreateTransaction

func (s *GormStore) GetOrCreateTransaction(txId string) (t *Transaction)

func (*GormStore) InsertTransaction

func (s *GormStore) InsertTransaction(t *Transaction) error

func (*GormStore) Transaction

func (s *GormStore) Transaction(txId string) (t Transaction, err error)

func (*GormStore) TransactionForAccount added in v0.6.0

func (s *GormStore) TransactionForAccount(tType Type, address, txId string) (t Transaction, err error)

func (*GormStore) Transactions

func (s *GormStore) Transactions(o datastore.ListOptions) (tt []Transaction, err error)

func (*GormStore) TransactionsForAccount added in v0.6.0

func (s *GormStore) TransactionsForAccount(tType Type, address string, o datastore.ListOptions) (tt []Transaction, err error)

func (*GormStore) UpdateTransaction

func (s *GormStore) UpdateTransaction(t *Transaction) error

type JSONRequest added in v0.8.0

type JSONRequest struct {
	Code      string     `json:"code"`
	Arguments []Argument `json:"arguments"`
}

Transaction JSON HTTP request

type JSONResponse added in v0.6.0

type JSONResponse struct {
	TransactionId   string       `json:"transactionId"`
	TransactionType Type         `json:"transactionType"`
	Events          []flow.Event `json:"events,omitempty"`
	CreatedAt       time.Time    `json:"createdAt"`
	UpdatedAt       time.Time    `json:"updatedAt"`
}

Transaction JSON HTTP response

type ProposalKeyJSON added in v0.7.0

type ProposalKeyJSON struct {
	Address        string `json:"address"`
	KeyIndex       int    `json:"keyIndex"`
	SequenceNumber uint64 `json:"sequenceNumber"`
}

type Service

type Service interface {
	Create(ctx context.Context, sync bool, proposerAddress string, code string, args []Argument, tType Type) (*jobs.Job, *Transaction, error)
	Sign(ctx context.Context, proposerAddress string, code string, args []Argument) (*SignedTransaction, error)
	List(limit, offset int) ([]Transaction, error)
	ListForAccount(tType Type, address string, limit, offset int) ([]Transaction, error)
	Details(ctx context.Context, transactionId string) (*Transaction, error)
	DetailsForAccount(ctx context.Context, tType Type, address, transactionId string) (*Transaction, error)
	ExecuteScript(ctx context.Context, code string, args []Argument) (cadence.Value, error)
	UpdateTransaction(t *Transaction) error
	GetOrCreateTransaction(transactionId string) *Transaction
}

func NewService

func NewService(
	cfg *configs.Config,
	store Store,
	km keys.Manager,
	fc flow_helpers.FlowClient,
	wp jobs.WorkerPool,
	opts ...ServiceOption,
) Service

NewService initiates a new transaction service.

type ServiceImpl added in v0.10.0

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

ServiceImpl defines the API for transaction HTTP handlers.

func (*ServiceImpl) Create added in v0.10.0

func (s *ServiceImpl) Create(ctx context.Context, sync bool, proposerAddress string, code string, args []Argument, tType Type) (*jobs.Job, *Transaction, error)

func (*ServiceImpl) Details added in v0.10.0

func (s *ServiceImpl) Details(ctx context.Context, transactionId string) (*Transaction, error)

Details returns a specific transaction.

func (*ServiceImpl) DetailsForAccount added in v0.10.0

func (s *ServiceImpl) DetailsForAccount(ctx context.Context, tType Type, address, transactionId string) (*Transaction, error)

DetailsForAccount returns a specific transaction.

func (*ServiceImpl) ExecuteScript added in v0.10.0

func (s *ServiceImpl) ExecuteScript(ctx context.Context, code string, args []Argument) (cadence.Value, error)

Execute a script

func (*ServiceImpl) GetOrCreateTransaction added in v0.10.0

func (s *ServiceImpl) GetOrCreateTransaction(transactionId string) *Transaction

func (*ServiceImpl) List added in v0.10.0

func (s *ServiceImpl) List(limit, offset int) ([]Transaction, error)

List returns all transactions in the datastore.

func (*ServiceImpl) ListForAccount added in v0.10.0

func (s *ServiceImpl) ListForAccount(tType Type, address string, limit, offset int) ([]Transaction, error)

ListForAccount returns all transactions in the datastore for a given account.

func (*ServiceImpl) Sign added in v0.10.0

func (s *ServiceImpl) Sign(ctx context.Context, proposerAddress string, code string, args []Argument) (*SignedTransaction, error)

func (*ServiceImpl) UpdateTransaction added in v0.10.0

func (s *ServiceImpl) UpdateTransaction(t *Transaction) error

type ServiceOption added in v0.9.0

type ServiceOption func(*ServiceImpl)

func WithTxRatelimiter added in v0.9.0

func WithTxRatelimiter(limiter ratelimit.Limiter) ServiceOption

type SignedTransaction added in v0.7.0

type SignedTransaction struct {
	flow.Transaction
}

func (*SignedTransaction) ToJSONResponse added in v0.7.0

func (st *SignedTransaction) ToJSONResponse() (SignedTransactionJSONResponse, error)

type SignedTransactionJSONResponse added in v0.7.0

type SignedTransactionJSONResponse struct {
	Code               string                     `json:"code"`
	Arguments          [][]byte                   `json:"arguments"`
	ReferenceBlockID   string                     `json:"referenceBlockId"`
	GasLimit           uint64                     `json:"gasLimit"`
	ProposalKey        ProposalKeyJSON            `json:"proposalKey"`
	Payer              string                     `json:"payer"`
	Authorizers        []string                   `json:"authorizers"`
	PayloadSignatures  []TransactionSignatureJSON `json:"payloadSignatures"`
	EnvelopeSignatures []TransactionSignatureJSON `json:"envelopeSignatures"`
}

Signatures JSON HTTP response

type Store

type Store interface {
	Transactions(opt datastore.ListOptions) ([]Transaction, error)
	Transaction(txId string) (Transaction, error)
	TransactionsForAccount(tType Type, address string, opt datastore.ListOptions) ([]Transaction, error)
	TransactionForAccount(tType Type, address, txId string) (Transaction, error)
	GetOrCreateTransaction(txId string) *Transaction
	InsertTransaction(*Transaction) error
	UpdateTransaction(*Transaction) error
}

Store manages data regarding transactions.

func NewGormStore

func NewGormStore(db *gorm.DB) Store

type Transaction

type Transaction struct {
	TransactionId   string         `gorm:"column:transaction_id;primaryKey"`
	TransactionType Type           `gorm:"column:transaction_type;index"`
	ProposerAddress string         `gorm:"column:proposer_address;index"`
	FlowTransaction []byte         `gorm:"column:flow_transaction;type:bytes"`
	CreatedAt       time.Time      `gorm:"column:created_at"`
	UpdatedAt       time.Time      `gorm:"column:updated_at"`
	DeletedAt       gorm.DeletedAt `gorm:"column:deleted_at;index"`
	Events          []flow.Event   `gorm:"-"`
}

Transaction is the database model for all transactions.

func (Transaction) TableName added in v0.6.0

func (Transaction) TableName() string

func (Transaction) ToJSONResponse added in v0.6.0

func (t Transaction) ToJSONResponse() JSONResponse

type TransactionSignatureJSON added in v0.7.0

type TransactionSignatureJSON struct {
	Address   string `json:"address"`
	KeyIndex  int    `json:"keyIndex"`
	Signature string `json:"signature"`
}

type Type

type Type int
const (
	Unknown Type = iota
	General
	FtSetup
	FtTransfer
	NftSetup
	NftTransfer
)

func StatusFromText

func StatusFromText(text string) Type

func (Type) MarshalText

func (s Type) MarshalText() ([]byte, error)

func (Type) String

func (i Type) String() string

func (*Type) UnmarshalText

func (s *Type) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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