database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package database provides database access functionality for the Service Layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailsToJSON

func DetailsToJSON(details map[string]interface{}) ([]byte, error)

DetailsToJSON converts verification details to JSON

func JSONToDetails

func JSONToDetails(data []byte) (map[string]interface{}, error)

JSONToDetails converts JSON to verification details

func JSONToParameters

func JSONToParameters(data json.RawMessage) (map[string]interface{}, error)

JSONToParameters converts JSON to parameters

func ParametersToJSON

func ParametersToJSON(parameters map[string]interface{}) (json.RawMessage, error)

ParametersToJSON converts parameters to JSON

Types

type ContractRepository

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

ContractRepository provides access to contract storage

func NewContractRepository

func NewContractRepository(db *sqlx.DB) *ContractRepository

NewContractRepository creates a new contract repository

func (*ContractRepository) Create

func (r *ContractRepository) Create(ctx context.Context, contract *models.Contract) error

Create creates a new contract

func (*ContractRepository) CreateVerification

func (r *ContractRepository) CreateVerification(ctx context.Context, verification *models.ContractVerification) error

CreateVerification creates a new contract verification

func (*ContractRepository) Delete

func (r *ContractRepository) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a contract

func (*ContractRepository) GetByAddress

func (r *ContractRepository) GetByAddress(ctx context.Context, address, network string) (*models.Contract, error)

GetByAddress retrieves a contract by address

func (*ContractRepository) GetByID

func (r *ContractRepository) GetByID(ctx context.Context, id uuid.UUID) (*models.Contract, error)

GetByID retrieves a contract by ID

func (*ContractRepository) GetByUserID

func (r *ContractRepository) GetByUserID(ctx context.Context, userID int) ([]*models.Contract, error)

GetByUserID retrieves contracts by user ID

func (*ContractRepository) GetLatestVerification

func (r *ContractRepository) GetLatestVerification(ctx context.Context, contractID uuid.UUID) (*models.ContractVerification, error)

GetLatestVerification retrieves the latest verification for a contract

func (*ContractRepository) GetVerificationsByContractID

func (r *ContractRepository) GetVerificationsByContractID(ctx context.Context, contractID uuid.UUID) ([]*models.ContractVerification, error)

GetVerificationsByContractID retrieves verifications by contract ID

func (*ContractRepository) Update

func (r *ContractRepository) Update(ctx context.Context, contract *models.Contract) error

Update updates a contract

type Database

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

Database represents the database connection

func New

func New(cfg *config.DatabaseConfig, log *logger.Logger) (*Database, error)

New creates a new database connection

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) DB

func (d *Database) DB() *sql.DB

DB returns the underlying sql.DB instance

func (*Database) RunMigrations

func (d *Database) RunMigrations(migrationsPath string) error

RunMigrations runs database migrations

func (*Database) Transaction

func (d *Database) Transaction(fn func(*sql.Tx) error) error

Transaction executes a function within a database transaction

type EventRepository

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

EventRepository provides access to event storage

func NewEventRepository

func NewEventRepository(db *sqlx.DB) *EventRepository

NewEventRepository creates a new event repository

func (*EventRepository) CountEvents

func (r *EventRepository) CountEvents(
	ctx context.Context,
	contractAddress string,
	eventName string,
	fromBlock int,
	toBlock int,
) (int, error)

CountEvents counts blockchain events based on filter criteria

func (*EventRepository) CreateEvent

func (r *EventRepository) CreateEvent(ctx context.Context, event *models.BlockchainEvent) error

CreateEvent creates a new blockchain event

func (*EventRepository) CreateNotification

func (r *EventRepository) CreateNotification(ctx context.Context, notification *models.EventNotification) error

CreateNotification creates a new event notification

func (*EventRepository) CreateSubscription

func (r *EventRepository) CreateSubscription(ctx context.Context, subscription *models.EventSubscription) error

CreateSubscription creates a new event subscription

func (*EventRepository) DeleteSubscription

func (r *EventRepository) DeleteSubscription(ctx context.Context, id uuid.UUID) error

DeleteSubscription marks an event subscription as deleted

func (*EventRepository) GetActiveSubscriptions

func (r *EventRepository) GetActiveSubscriptions(ctx context.Context) ([]*models.EventSubscription, error)

GetActiveSubscriptions retrieves all active event subscriptions

func (*EventRepository) GetBlockProcessing

func (r *EventRepository) GetBlockProcessing(ctx context.Context, network string) (*models.BlockProcessing, error)

GetBlockProcessing retrieves the block processing state for a network

func (*EventRepository) GetEventByID

func (r *EventRepository) GetEventByID(ctx context.Context, id uuid.UUID) (*models.BlockchainEvent, error)

GetEventByID retrieves a blockchain event by ID

func (*EventRepository) GetEvents

func (r *EventRepository) GetEvents(
	ctx context.Context,
	contractAddress string,
	eventName string,
	fromBlock int,
	toBlock int,
	limit int,
	offset int,
) ([]*models.BlockchainEvent, error)

GetEvents retrieves blockchain events based on filter criteria

func (*EventRepository) GetMatchingSubscriptions

func (r *EventRepository) GetMatchingSubscriptions(
	ctx context.Context,
	contractAddress string,
	eventName string,
	blockNumber int,
) ([]*models.EventSubscription, error)

GetMatchingSubscriptions retrieves subscriptions matching event criteria

func (*EventRepository) GetPendingNotifications

func (r *EventRepository) GetPendingNotifications(ctx context.Context, limit int) ([]*models.EventNotification, error)

GetPendingNotifications retrieves pending event notifications

func (*EventRepository) GetSubscriptionByID

func (r *EventRepository) GetSubscriptionByID(ctx context.Context, id uuid.UUID) (*models.EventSubscription, error)

GetSubscriptionByID retrieves an event subscription by ID

func (*EventRepository) GetSubscriptionsByUserID

func (r *EventRepository) GetSubscriptionsByUserID(ctx context.Context, userID int) ([]*models.EventSubscription, error)

GetSubscriptionsByUserID retrieves event subscriptions by user ID

func (*EventRepository) UpdateBlockProcessing

func (r *EventRepository) UpdateBlockProcessing(ctx context.Context, blockProcessing *models.BlockProcessing) error

UpdateBlockProcessing updates the block processing state for a network

func (*EventRepository) UpdateNotification

func (r *EventRepository) UpdateNotification(ctx context.Context, notification *models.EventNotification) error

UpdateNotification updates an event notification

func (*EventRepository) UpdateSubscription

func (r *EventRepository) UpdateSubscription(ctx context.Context, subscription *models.EventSubscription) error

UpdateSubscription updates an event subscription

type Function

type Function struct {
	ID            string    `db:"id" json:"id"`
	UserID        int       `db:"user_id" json:"user_id"`
	Name          string    `db:"name" json:"name"`
	Description   string    `db:"description" json:"description"`
	SourceCode    string    `db:"source_code" json:"source_code"`
	SecretsAccess []string  `db:"secrets_access" json:"secrets_access"`
	TriggerType   string    `db:"trigger_type" json:"trigger_type"`
	CreatedAt     time.Time `db:"created_at" json:"created_at"`
	UpdatedAt     time.Time `db:"updated_at" json:"updated_at"`
}

Function represents a JavaScript function stored in the database

type FunctionExecution

type FunctionExecution struct {
	ID          string    `db:"id" json:"id"`
	FunctionID  string    `db:"function_id" json:"function_id"`
	UserID      int       `db:"user_id" json:"user_id"`
	Status      string    `db:"status" json:"status"`
	StartTime   time.Time `db:"start_time" json:"start_time"`
	EndTime     time.Time `db:"end_time" json:"end_time"`
	Duration    int64     `db:"duration" json:"duration"`
	InputParams string    `db:"input_params" json:"input_params"`
	Result      string    `db:"result" json:"result"`
	Error       string    `db:"error" json:"error"`
}

FunctionExecution represents a record of a function execution

type FunctionRepository

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

FunctionRepository handles database operations for functions

func NewFunctionRepository

func NewFunctionRepository(db *sqlx.DB, cacheManager *cache.Manager, logger zerolog.Logger) *FunctionRepository

NewFunctionRepository creates a new function repository

func (*FunctionRepository) Create

func (r *FunctionRepository) Create(ctx context.Context, function *Function) error

Create creates a new function

func (*FunctionRepository) Delete

func (r *FunctionRepository) Delete(ctx context.Context, id string, userID int) error

Delete deletes a function

func (*FunctionRepository) GetByID

func (r *FunctionRepository) GetByID(ctx context.Context, id string) (*Function, error)

GetByID retrieves a function by its ID

func (*FunctionRepository) ListByUserID

func (r *FunctionRepository) ListByUserID(ctx context.Context, userID int, page, limit int) ([]Function, int, error)

ListByUserID retrieves all functions for a user with pagination

func (*FunctionRepository) ListExecutionsByFunctionID

func (r *FunctionRepository) ListExecutionsByFunctionID(ctx context.Context, functionID string, page, limit int) ([]FunctionExecution, int, error)

ListExecutionsByFunctionID retrieves execution history for a function with pagination

func (*FunctionRepository) Update

func (r *FunctionRepository) Update(ctx context.Context, function *Function) error

Update updates an existing function

type OptimizedTransactionRepository

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

OptimizedTransactionRepository implements TransactionRepository using SQL with optimized queries

func (*OptimizedTransactionRepository) AddTransactionEvent

func (r *OptimizedTransactionRepository) AddTransactionEvent(ctx context.Context, event *models.TransactionEvent) error

AddTransactionEvent adds an event for a transaction The event_count in the transactions table will be automatically updated by the database trigger

func (*OptimizedTransactionRepository) CreateTransaction

func (r *OptimizedTransactionRepository) CreateTransaction(ctx context.Context, tx *models.Transaction) error

CreateTransaction creates a new transaction record

func (*OptimizedTransactionRepository) CreateWalletAccount

func (r *OptimizedTransactionRepository) CreateWalletAccount(ctx context.Context, wallet *models.WalletAccount) error

CreateWalletAccount creates a new wallet account

func (*OptimizedTransactionRepository) DeleteTransaction

func (r *OptimizedTransactionRepository) DeleteTransaction(ctx context.Context, id uuid.UUID) error

DeleteTransaction soft deletes a transaction

func (*OptimizedTransactionRepository) DeleteWalletAccount

func (r *OptimizedTransactionRepository) DeleteWalletAccount(ctx context.Context, id uuid.UUID) error

DeleteWalletAccount soft deletes a wallet account

func (*OptimizedTransactionRepository) GetTransactionByHash

func (r *OptimizedTransactionRepository) GetTransactionByHash(ctx context.Context, hash string) (*models.Transaction, error)

GetTransactionByHash retrieves a transaction by hash

func (*OptimizedTransactionRepository) GetTransactionByID

func (r *OptimizedTransactionRepository) GetTransactionByID(ctx context.Context, id uuid.UUID) (*models.Transaction, error)

GetTransactionByID retrieves a transaction by ID

func (*OptimizedTransactionRepository) GetTransactionEvents

func (r *OptimizedTransactionRepository) GetTransactionEvents(ctx context.Context, transactionID uuid.UUID) ([]models.TransactionEvent, error)

GetTransactionEvents retrieves events for a transaction This uses the index on transaction_id

func (*OptimizedTransactionRepository) GetWalletByAddress

func (r *OptimizedTransactionRepository) GetWalletByAddress(ctx context.Context, address string) (*models.WalletAccount, error)

GetWalletByAddress retrieves a wallet account by address

func (*OptimizedTransactionRepository) GetWalletByService

func (r *OptimizedTransactionRepository) GetWalletByService(ctx context.Context, service string) (*models.WalletAccount, error)

GetWalletByService retrieves a wallet account by service (one per service)

func (*OptimizedTransactionRepository) ListTransactions

func (r *OptimizedTransactionRepository) ListTransactions(
	ctx context.Context,
	service string,
	status models.TransactionStatus,
	entityID *uuid.UUID,
	page, limit int,
) (*models.TransactionListResponse, error)

ListTransactions retrieves a paginated list of transactions with filters This query is optimized to use the appropriate indexes and select only necessary fields

func (*OptimizedTransactionRepository) ListWalletsByService

func (r *OptimizedTransactionRepository) ListWalletsByService(ctx context.Context, service string) ([]models.WalletAccount, error)

ListWalletsByService retrieves all wallet accounts for a service

func (*OptimizedTransactionRepository) UpdateTransactionStatus

func (r *OptimizedTransactionRepository) UpdateTransactionStatus(
	ctx context.Context,
	id uuid.UUID,
	status models.TransactionStatus,
	result json.RawMessage,
	gasConsumed *int64,
	blockHeight *int64,
	blockTime *time.Time,
	err string,
) error

UpdateTransactionStatus updates a transaction's status and related fields

type OracleRepository

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

OracleRepository implements the models.OracleRepository interface

func NewOracleRepository

func NewOracleRepository(db *sqlx.DB) *OracleRepository

NewOracleRepository creates a new oracle repository

func (*OracleRepository) CreateOracle

func (r *OracleRepository) CreateOracle(oracle *models.Oracle) (*models.Oracle, error)

CreateOracle creates a new oracle data source configuration

func (*OracleRepository) CreateOracleRequest

func (r *OracleRepository) CreateOracleRequest(request *models.OracleRequest) (*models.OracleRequest, error)

CreateOracleRequest creates a new oracle data request

func (*OracleRepository) DeleteOracle

func (r *OracleRepository) DeleteOracle(id int) error

DeleteOracle deletes an oracle data source configuration

func (*OracleRepository) GetOracleByID

func (r *OracleRepository) GetOracleByID(id int) (*models.Oracle, error)

GetOracleByID gets an oracle data source configuration by ID

func (*OracleRepository) GetOracleByName

func (r *OracleRepository) GetOracleByName(name string) (*models.Oracle, error)

GetOracleByName gets an oracle data source configuration by name

func (*OracleRepository) GetOracleRequestByID

func (r *OracleRepository) GetOracleRequestByID(id int) (*models.OracleRequest, error)

GetOracleRequestByID gets an oracle data request by ID

func (*OracleRepository) GetOracleStatistics

func (r *OracleRepository) GetOracleStatistics() (map[string]interface{}, error)

GetOracleStatistics gets statistics for oracle data

func (*OracleRepository) ListOracleRequests

func (r *OracleRepository) ListOracleRequests(oracleID int, offset, limit int) ([]*models.OracleRequest, error)

ListOracleRequests lists oracle data requests for an oracle

func (*OracleRepository) ListOracles

func (r *OracleRepository) ListOracles(userID int, offset, limit int) ([]*models.Oracle, error)

ListOracles lists oracle data source configurations

func (*OracleRepository) ListPendingOracleRequests

func (r *OracleRepository) ListPendingOracleRequests() ([]*models.OracleRequest, error)

ListPendingOracleRequests lists all pending oracle data requests

func (*OracleRepository) UpdateOracle

func (r *OracleRepository) UpdateOracle(oracle *models.Oracle) (*models.Oracle, error)

UpdateOracle updates an oracle data source configuration

func (*OracleRepository) UpdateOracleRequest

func (r *OracleRepository) UpdateOracleRequest(request *models.OracleRequest) (*models.OracleRequest, error)

UpdateOracleRequest updates an oracle data request

type PriceFeedRepository

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

PriceFeedRepository implements the models.PriceFeedRepository interface

func NewPriceFeedRepository

func NewPriceFeedRepository(db *sqlx.DB) *PriceFeedRepository

NewPriceFeedRepository creates a new price feed repository

func (*PriceFeedRepository) CreatePriceData

func (r *PriceFeedRepository) CreatePriceData(data *models.PriceData) (*models.PriceData, error)

CreatePriceData creates a new price data entry

func (*PriceFeedRepository) CreatePriceFeed

func (r *PriceFeedRepository) CreatePriceFeed(feed *models.PriceFeed) (*models.PriceFeed, error)

CreatePriceFeed creates a new price feed in the database

func (*PriceFeedRepository) CreatePriceSource

func (r *PriceFeedRepository) CreatePriceSource(source *models.PriceSource) (*models.PriceSource, error)

CreatePriceSource creates a new price source

func (*PriceFeedRepository) DeletePriceFeed

func (r *PriceFeedRepository) DeletePriceFeed(id int) error

DeletePriceFeed deletes a price feed

func (*PriceFeedRepository) DeletePriceSource

func (r *PriceFeedRepository) DeletePriceSource(id int) error

DeletePriceSource deletes a price source

func (*PriceFeedRepository) GetLatestPriceData

func (r *PriceFeedRepository) GetLatestPriceData(priceFeedID int) (*models.PriceData, error)

GetLatestPriceData gets the latest price data for a price feed

func (*PriceFeedRepository) GetPriceDataHistory

func (r *PriceFeedRepository) GetPriceDataHistory(priceFeedID int, limit int, offset int) ([]*models.PriceData, error)

GetPriceDataHistory gets the price data history for a price feed

func (*PriceFeedRepository) GetPriceFeedByID

func (r *PriceFeedRepository) GetPriceFeedByID(id int) (*models.PriceFeed, error)

GetPriceFeedByID gets a price feed by ID

func (*PriceFeedRepository) GetPriceFeedByPair

func (r *PriceFeedRepository) GetPriceFeedByPair(pair string) (*models.PriceFeed, error)

GetPriceFeedByPair gets a price feed by token pair

func (*PriceFeedRepository) GetPriceSourceByID

func (r *PriceFeedRepository) GetPriceSourceByID(id int) (*models.PriceSource, error)

GetPriceSourceByID gets a price source by ID

func (*PriceFeedRepository) GetPriceSourceByName

func (r *PriceFeedRepository) GetPriceSourceByName(name string) (*models.PriceSource, error)

GetPriceSourceByName gets a price source by name

func (*PriceFeedRepository) ListPriceFeeds

func (r *PriceFeedRepository) ListPriceFeeds() ([]*models.PriceFeed, error)

ListPriceFeeds lists all price feeds

func (*PriceFeedRepository) ListPriceSources

func (r *PriceFeedRepository) ListPriceSources() ([]*models.PriceSource, error)

ListPriceSources lists all price sources

func (*PriceFeedRepository) UpdatePriceFeed

func (r *PriceFeedRepository) UpdatePriceFeed(feed *models.PriceFeed) (*models.PriceFeed, error)

UpdatePriceFeed updates a price feed

func (*PriceFeedRepository) UpdatePriceSource

func (r *PriceFeedRepository) UpdatePriceSource(source *models.PriceSource) (*models.PriceSource, error)

UpdatePriceSource updates a price source

type RandomRepository

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

RandomRepository implements the models.RandomRepository interface

func NewRandomRepository

func NewRandomRepository(db *sqlx.DB) *RandomRepository

NewRandomRepository creates a new random repository

func (*RandomRepository) CreateEntropySource

func (r *RandomRepository) CreateEntropySource(source *models.EntropySource) (*models.EntropySource, error)

CreateEntropySource creates a new entropy source

func (*RandomRepository) CreateRequest

func (r *RandomRepository) CreateRequest(req *models.RandomRequest) (*models.RandomRequest, error)

CreateRequest creates a new random number request

func (*RandomRepository) GetEntropySourceByID

func (r *RandomRepository) GetEntropySourceByID(id int) (*models.EntropySource, error)

GetEntropySourceByID gets an entropy source by ID

func (*RandomRepository) GetEntropySourceByName

func (r *RandomRepository) GetEntropySourceByName(name string) (*models.EntropySource, error)

GetEntropySourceByName gets an entropy source by name

func (*RandomRepository) GetRandomStatistics

func (r *RandomRepository) GetRandomStatistics() (map[string]interface{}, error)

GetRandomStatistics gets statistics for random number generation

func (*RandomRepository) GetRequestByID

func (r *RandomRepository) GetRequestByID(id int) (*models.RandomRequest, error)

GetRequestByID gets a random number request by ID

func (*RandomRepository) ListCommittedRequests

func (r *RandomRepository) ListCommittedRequests() ([]*models.RandomRequest, error)

ListCommittedRequests lists all committed random number requests

func (*RandomRepository) ListEntropySources

func (r *RandomRepository) ListEntropySources() ([]*models.EntropySource, error)

ListEntropySources lists all entropy sources

func (*RandomRepository) ListPendingRequests

func (r *RandomRepository) ListPendingRequests() ([]*models.RandomRequest, error)

ListPendingRequests lists all pending random number requests

func (*RandomRepository) ListRequests

func (r *RandomRepository) ListRequests(userID int, offset, limit int) ([]*models.RandomRequest, error)

ListRequests lists random number requests for a user

func (*RandomRepository) UpdateEntropySource

func (r *RandomRepository) UpdateEntropySource(source *models.EntropySource) (*models.EntropySource, error)

UpdateEntropySource updates an entropy source

func (*RandomRepository) UpdateRequest

func (r *RandomRepository) UpdateRequest(req *models.RandomRequest) (*models.RandomRequest, error)

UpdateRequest updates a random number request

type RepositoryFactory

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

RepositoryFactory provides methods to create repository instances

func NewRepositoryFactory

func NewRepositoryFactory(db *sqlx.DB, logger *zerolog.Logger) *RepositoryFactory

NewRepositoryFactory creates a new repository factory

func (*RepositoryFactory) CreateTransactionRepository

func (f *RepositoryFactory) CreateTransactionRepository(useOptimized bool) TransactionRepository

CreateTransactionRepository creates a transaction repository instance useOptimized: if true, returns an optimized implementation that utilizes enhanced schema and query performance improvements

type SQLTransactionRepository

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

SQLTransactionRepository implements TransactionRepository using SQL

func (*SQLTransactionRepository) AddTransactionEvent

func (r *SQLTransactionRepository) AddTransactionEvent(ctx context.Context, event *models.TransactionEvent) error

AddTransactionEvent adds an event for a transaction

func (*SQLTransactionRepository) CreateTransaction

func (r *SQLTransactionRepository) CreateTransaction(ctx context.Context, tx *models.Transaction) error

CreateTransaction creates a new transaction record

func (*SQLTransactionRepository) CreateWalletAccount

func (r *SQLTransactionRepository) CreateWalletAccount(ctx context.Context, wallet *models.WalletAccount) error

CreateWalletAccount creates a new wallet account

func (*SQLTransactionRepository) DeleteTransaction

func (r *SQLTransactionRepository) DeleteTransaction(ctx context.Context, id uuid.UUID) error

DeleteTransaction soft deletes a transaction

func (*SQLTransactionRepository) DeleteWalletAccount

func (r *SQLTransactionRepository) DeleteWalletAccount(ctx context.Context, id uuid.UUID) error

DeleteWalletAccount soft deletes a wallet account

func (*SQLTransactionRepository) GetTransactionByHash

func (r *SQLTransactionRepository) GetTransactionByHash(ctx context.Context, hash string) (*models.Transaction, error)

GetTransactionByHash retrieves a transaction by hash

func (*SQLTransactionRepository) GetTransactionByID

func (r *SQLTransactionRepository) GetTransactionByID(ctx context.Context, id uuid.UUID) (*models.Transaction, error)

GetTransactionByID retrieves a transaction by ID

func (*SQLTransactionRepository) GetTransactionEvents

func (r *SQLTransactionRepository) GetTransactionEvents(ctx context.Context, transactionID uuid.UUID) ([]models.TransactionEvent, error)

GetTransactionEvents retrieves events for a transaction

func (*SQLTransactionRepository) GetWalletByAddress

func (r *SQLTransactionRepository) GetWalletByAddress(ctx context.Context, address string) (*models.WalletAccount, error)

GetWalletByAddress retrieves a wallet account by address

func (*SQLTransactionRepository) GetWalletByService

func (r *SQLTransactionRepository) GetWalletByService(ctx context.Context, service string) (*models.WalletAccount, error)

GetWalletByService retrieves a wallet account by service (one per service)

func (*SQLTransactionRepository) ListTransactions

func (r *SQLTransactionRepository) ListTransactions(
	ctx context.Context,
	service string,
	status models.TransactionStatus,
	entityID *uuid.UUID,
	page, limit int,
) (*models.TransactionListResponse, error)

ListTransactions retrieves a paginated list of transactions with filters

func (*SQLTransactionRepository) ListWalletsByService

func (r *SQLTransactionRepository) ListWalletsByService(ctx context.Context, service string) ([]models.WalletAccount, error)

ListWalletsByService retrieves all wallet accounts for a service

func (*SQLTransactionRepository) UpdateTransactionStatus

func (r *SQLTransactionRepository) UpdateTransactionStatus(
	ctx context.Context,
	id uuid.UUID,
	status models.TransactionStatus,
	result json.RawMessage,
	gasConsumed *int64,
	blockHeight *int64,
	blockTime *time.Time,
	err string,
) error

UpdateTransactionStatus updates a transaction's status and related fields

type TransactionRepository

type TransactionRepository interface {
	CreateTransaction(ctx context.Context, tx *models.Transaction) error
	GetTransactionByID(ctx context.Context, id uuid.UUID) (*models.Transaction, error)
	GetTransactionByHash(ctx context.Context, hash string) (*models.Transaction, error)
	UpdateTransactionStatus(ctx context.Context, id uuid.UUID, status models.TransactionStatus, result json.RawMessage, gasConsumed *int64, blockHeight *int64, blockTime *time.Time, err string) error
	ListTransactions(ctx context.Context, service string, status models.TransactionStatus, entityID *uuid.UUID, page, limit int) (*models.TransactionListResponse, error)
	AddTransactionEvent(ctx context.Context, event *models.TransactionEvent) error
	GetTransactionEvents(ctx context.Context, transactionID uuid.UUID) ([]models.TransactionEvent, error)
	DeleteTransaction(ctx context.Context, id uuid.UUID) error

	CreateWalletAccount(ctx context.Context, wallet *models.WalletAccount) error
	GetWalletByService(ctx context.Context, service string) (*models.WalletAccount, error)
	GetWalletByAddress(ctx context.Context, address string) (*models.WalletAccount, error)
	ListWalletsByService(ctx context.Context, service string) ([]models.WalletAccount, error)
	DeleteWalletAccount(ctx context.Context, id uuid.UUID) error
}

TransactionRepository defines the interface for transaction operations

func NewOptimizedTransactionRepository

func NewOptimizedTransactionRepository(db *sqlx.DB) TransactionRepository

NewOptimizedTransactionRepository creates a new OptimizedTransactionRepository

func NewSQLTransactionRepository

func NewSQLTransactionRepository(db *sqlx.DB) TransactionRepository

NewSQLTransactionRepository creates a new SQLTransactionRepository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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