Documentation ¶
Index ¶
- type Db
- func (db *Db) CurrentEpoch(ctx context.Context) (uint64, error)
- func (db *Db) DatabaseTransaction(ctx context.Context, fn func(context.Context, *Db) error) error
- func (db *Db) IncreaseTotalAmountClaimed(ctx context.Context, amount *big.Int) error
- func (db *Db) IncreaseTotalAmountCollected(ctx context.Context, amount *big.Int) error
- func (db *Db) IncreaseTotalTransactionsCount(ctx context.Context, count uint64) error
- func (db *Db) LastProcessedBlock(ctx context.Context) (uint64, error)
- func (db *Db) ProjectContractQuery(ctx context.Context) ProjectContractQueryBuilder
- func (db *Db) ProjectQuery(ctx context.Context) ProjectQueryBuilder
- func (db *Db) SetTotalAmountClaimed(ctx context.Context, amount *big.Int) error
- func (db *Db) SetTotalAmountCollected(ctx context.Context, amount *big.Int) error
- func (db *Db) SetTotalTransactionsCount(ctx context.Context, count uint64) error
- func (db *Db) StoreProject(ctx context.Context, project *types.Project) error
- func (db *Db) StoreProjectContract(ctx context.Context, project *types.ProjectContract) error
- func (db *Db) StoreTransaction(ctx context.Context, trx *types.Transaction) error
- func (db *Db) StoreWithdrawalRequest(ctx context.Context, request *types.WithdrawalRequest) error
- func (db *Db) TotalAmountClaimed(ctx context.Context) (*big.Int, error)
- func (db *Db) TotalAmountCollected(ctx context.Context) (*big.Int, error)
- func (db *Db) TotalTransactionsCount(ctx context.Context) (uint64, error)
- func (db *Db) TransactionQuery(ctx context.Context) TransactionQueryBuilder
- func (db *Db) UpdateCurrentEpoch(ctx context.Context, epoch uint64) error
- func (db *Db) UpdateLastProcessedBlock(ctx context.Context, block uint64) error
- func (db *Db) UpdateProject(ctx context.Context, project *types.Project) error
- func (db *Db) UpdateWithdrawalRequest(ctx context.Context, request *types.WithdrawalRequest) error
- func (db *Db) WithdrawalRequestQuery(ctx context.Context) WithdrawalRequestQueryBuilder
- type ProjectContractQueryBuilder
- func (qb *ProjectContractQueryBuilder) Delete() error
- func (qb *ProjectContractQueryBuilder) GetAll() ([]T, error)
- func (qb *ProjectContractQueryBuilder) GetFirst() (*T, error)
- func (qb *ProjectContractQueryBuilder) GetFirstOrFail() (*T, error)
- func (qb *ProjectContractQueryBuilder) Select(fields ...string) *queryBuilder[T]
- func (qb *ProjectContractQueryBuilder) WhereAddress(address *types.Address) *ProjectContractQueryBuilder
- func (qb *ProjectContractQueryBuilder) WhereId(id int64) *queryBuilder[T]
- func (qb *ProjectContractQueryBuilder) WhereIsApproved(isApproved bool) *ProjectContractQueryBuilder
- func (qb *ProjectContractQueryBuilder) WhereProjectId(projectId int64) *ProjectContractQueryBuilder
- func (qb *ProjectContractQueryBuilder) WhereProjectIdIn(ids []int64) *ProjectContractQueryBuilder
- type ProjectQueryBuilder
- func (qb *ProjectQueryBuilder) Delete() error
- func (qb *ProjectQueryBuilder) GetAll() ([]T, error)
- func (qb *ProjectQueryBuilder) GetFirst() (*T, error)
- func (qb *ProjectQueryBuilder) GetFirstOrFail() (*T, error)
- func (qb *ProjectQueryBuilder) Select(fields ...string) *queryBuilder[T]
- func (qb *ProjectQueryBuilder) WhereActiveInEpoch(epoch uint64) *ProjectQueryBuilder
- func (qb *ProjectQueryBuilder) WhereId(id int64) *queryBuilder[T]
- func (qb *ProjectQueryBuilder) WhereOwner(owner *types.Address) *ProjectQueryBuilder
- func (qb *ProjectQueryBuilder) WhereProjectId(projectId uint64) *ProjectQueryBuilder
- type TestDatabase
- type TransactionQueryBuilder
- func (qb *TransactionQueryBuilder) Delete() error
- func (qb *TransactionQueryBuilder) GetAll() ([]T, error)
- func (qb *TransactionQueryBuilder) GetFirst() (*T, error)
- func (qb *TransactionQueryBuilder) GetFirstOrFail() (*T, error)
- func (qb *TransactionQueryBuilder) Select(fields ...string) *queryBuilder[T]
- func (qb *TransactionQueryBuilder) WhereEpoch(epoch uint64) *TransactionQueryBuilder
- func (qb *TransactionQueryBuilder) WhereEpochLt(epoch uint64) *TransactionQueryBuilder
- func (qb *TransactionQueryBuilder) WhereId(id int64) *queryBuilder[T]
- func (qb *TransactionQueryBuilder) WhereProjectId(id int64) *TransactionQueryBuilder
- type WithdrawalRequestQueryBuilder
- func (qb *WithdrawalRequestQueryBuilder) Delete() error
- func (qb *WithdrawalRequestQueryBuilder) GetAll() ([]T, error)
- func (qb *WithdrawalRequestQueryBuilder) GetFirst() (*T, error)
- func (qb *WithdrawalRequestQueryBuilder) GetFirstOrFail() (*T, error)
- func (qb *WithdrawalRequestQueryBuilder) Select(fields ...string) *queryBuilder[T]
- func (qb *WithdrawalRequestQueryBuilder) WhereId(id int64) *queryBuilder[T]
- func (qb *WithdrawalRequestQueryBuilder) WhereProjectId(projectId int64) *WithdrawalRequestQueryBuilder
- func (qb *WithdrawalRequestQueryBuilder) WhereRequestEpoch(epoch uint64) *WithdrawalRequestQueryBuilder
- func (qb *WithdrawalRequestQueryBuilder) WhereWithdrawEpoch(epoch uint64) *WithdrawalRequestQueryBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db defines the database repository.
func (*Db) CurrentEpoch ¶
CurrentEpoch returns the current epoch.
func (*Db) DatabaseTransaction ¶
DatabaseTransaction runs the given function in a database transaction.
func (*Db) IncreaseTotalAmountClaimed ¶
IncreaseTotalAmountClaimed increases the total amount claimed.
func (*Db) IncreaseTotalAmountCollected ¶
IncreaseTotalAmountCollected increases the total amount collected.
func (*Db) IncreaseTotalTransactionsCount ¶
IncreaseTotalTransactionsCount increases the total number of transactions.
func (*Db) LastProcessedBlock ¶
LastProcessedBlock returns the last processed block.
func (*Db) ProjectContractQuery ¶
func (db *Db) ProjectContractQuery(ctx context.Context) ProjectContractQueryBuilder
ProjectContractQuery returns a new project contract query builder.
func (*Db) ProjectQuery ¶
func (db *Db) ProjectQuery(ctx context.Context) ProjectQueryBuilder
ProjectQuery returns a new project query builder.
func (*Db) SetTotalAmountClaimed ¶
SetTotalAmountClaimed sets the total amount claimed.
func (*Db) SetTotalAmountCollected ¶
SetTotalAmountCollected sets the total amount collected.
func (*Db) SetTotalTransactionsCount ¶
SetTotalTransactionsCount sets the total number of transactions.
func (*Db) StoreProject ¶
StoreProject stores the project in the database.
func (*Db) StoreProjectContract ¶
StoreProjectContract stores the project contract in the database.
func (*Db) StoreTransaction ¶
StoreTransaction stores a transaction reference in connected persistent storage.
func (*Db) StoreWithdrawalRequest ¶
StoreWithdrawalRequest stores a new withdrawal request into the database.
func (*Db) TotalAmountClaimed ¶
TotalAmountClaimed returns the total amount claimed.
func (*Db) TotalAmountCollected ¶
TotalAmountCollected returns the total amount collected.
func (*Db) TotalTransactionsCount ¶
TotalTransactionsCount returns the total number of transactions.
func (*Db) TransactionQuery ¶
func (db *Db) TransactionQuery(ctx context.Context) TransactionQueryBuilder
TransactionQuery returns a new transaction query builder.
func (*Db) UpdateCurrentEpoch ¶
UpdateCurrentEpoch updates the current epoch.
func (*Db) UpdateLastProcessedBlock ¶
UpdateLastProcessedBlock updates the last processed block.
func (*Db) UpdateProject ¶
UpdateProject updates the project in the database.
func (*Db) UpdateWithdrawalRequest ¶
UpdateWithdrawalRequest updates the withdrawal request in the database.
func (*Db) WithdrawalRequestQuery ¶
func (db *Db) WithdrawalRequestQuery(ctx context.Context) WithdrawalRequestQueryBuilder
WithdrawalRequestQuery returns a new withdrawal request query builder.
type ProjectContractQueryBuilder ¶
type ProjectContractQueryBuilder struct {
// contains filtered or unexported fields
}
func (*ProjectContractQueryBuilder) Delete ¶
func (qb *ProjectContractQueryBuilder) Delete() error
Delete deletes all results of the query.
func (*ProjectContractQueryBuilder) GetAll ¶
func (qb *ProjectContractQueryBuilder) GetAll() ([]T, error)
GetAll returns all results of the query. If no result is found, nil is returned.
func (*ProjectContractQueryBuilder) GetFirst ¶
func (qb *ProjectContractQueryBuilder) GetFirst() (*T, error)
GetFirst returns the first result of the query. If no result is found, nil is returned.
func (*ProjectContractQueryBuilder) GetFirstOrFail ¶
func (qb *ProjectContractQueryBuilder) GetFirstOrFail() (*T, error)
GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.
func (*ProjectContractQueryBuilder) Select ¶
func (qb *ProjectContractQueryBuilder) Select(fields ...string) *queryBuilder[T]
Select sets the fields to select.
func (*ProjectContractQueryBuilder) WhereAddress ¶
func (qb *ProjectContractQueryBuilder) WhereAddress(address *types.Address) *ProjectContractQueryBuilder
WhereAddress adds a where clause to the query builder.
func (*ProjectContractQueryBuilder) WhereId ¶
func (qb *ProjectContractQueryBuilder) WhereId(id int64) *queryBuilder[T]
WhereId adds a where clause to the query builder.
func (*ProjectContractQueryBuilder) WhereIsApproved ¶
func (qb *ProjectContractQueryBuilder) WhereIsApproved(isApproved bool) *ProjectContractQueryBuilder
WhereIsApproved adds a where clause to the query builder.
func (*ProjectContractQueryBuilder) WhereProjectId ¶
func (qb *ProjectContractQueryBuilder) WhereProjectId(projectId int64) *ProjectContractQueryBuilder
WhereProjectId adds a where clause to the query builder.
func (*ProjectContractQueryBuilder) WhereProjectIdIn ¶
func (qb *ProjectContractQueryBuilder) WhereProjectIdIn(ids []int64) *ProjectContractQueryBuilder
WhereProjectIdIn adds a where clause to the query builder.
type ProjectQueryBuilder ¶
type ProjectQueryBuilder struct {
// contains filtered or unexported fields
}
func (*ProjectQueryBuilder) Delete ¶
func (qb *ProjectQueryBuilder) Delete() error
Delete deletes all results of the query.
func (*ProjectQueryBuilder) GetAll ¶
func (qb *ProjectQueryBuilder) GetAll() ([]T, error)
GetAll returns all results of the query. If no result is found, nil is returned.
func (*ProjectQueryBuilder) GetFirst ¶
func (qb *ProjectQueryBuilder) GetFirst() (*T, error)
GetFirst returns the first result of the query. If no result is found, nil is returned.
func (*ProjectQueryBuilder) GetFirstOrFail ¶
func (qb *ProjectQueryBuilder) GetFirstOrFail() (*T, error)
GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.
func (*ProjectQueryBuilder) Select ¶
func (qb *ProjectQueryBuilder) Select(fields ...string) *queryBuilder[T]
Select sets the fields to select.
func (*ProjectQueryBuilder) WhereActiveInEpoch ¶
func (qb *ProjectQueryBuilder) WhereActiveInEpoch(epoch uint64) *ProjectQueryBuilder
WhereActiveInEpoch adds a where clause to the query builder.
func (*ProjectQueryBuilder) WhereId ¶
func (qb *ProjectQueryBuilder) WhereId(id int64) *queryBuilder[T]
WhereId adds a where clause to the query builder.
func (*ProjectQueryBuilder) WhereOwner ¶
func (qb *ProjectQueryBuilder) WhereOwner(owner *types.Address) *ProjectQueryBuilder
WhereOwner adds a where clause to the query builder.
func (*ProjectQueryBuilder) WhereProjectId ¶
func (qb *ProjectQueryBuilder) WhereProjectId(projectId uint64) *ProjectQueryBuilder
WhereProjectId adds a where clause to the query builder.
type TestDatabase ¶
type TestDatabase struct { *Db // contains filtered or unexported fields }
func SetupTestDatabase ¶
func SetupTestDatabase(logger *logger.AppLogger) *TestDatabase
SetupTestDatabase creates a test container for postgres database and returns a database instance
func (*TestDatabase) Migrate ¶
func (tdb *TestDatabase) Migrate() error
Migrate runs the database migrations
func (*TestDatabase) TearDown ¶
func (tdb *TestDatabase) TearDown()
TearDown removes the test container and closes the database connection
type TransactionQueryBuilder ¶
type TransactionQueryBuilder struct {
// contains filtered or unexported fields
}
func (*TransactionQueryBuilder) Delete ¶
func (qb *TransactionQueryBuilder) Delete() error
Delete deletes all results of the query.
func (*TransactionQueryBuilder) GetAll ¶
func (qb *TransactionQueryBuilder) GetAll() ([]T, error)
GetAll returns all results of the query. If no result is found, nil is returned.
func (*TransactionQueryBuilder) GetFirst ¶
func (qb *TransactionQueryBuilder) GetFirst() (*T, error)
GetFirst returns the first result of the query. If no result is found, nil is returned.
func (*TransactionQueryBuilder) GetFirstOrFail ¶
func (qb *TransactionQueryBuilder) GetFirstOrFail() (*T, error)
GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.
func (*TransactionQueryBuilder) Select ¶
func (qb *TransactionQueryBuilder) Select(fields ...string) *queryBuilder[T]
Select sets the fields to select.
func (*TransactionQueryBuilder) WhereEpoch ¶
func (qb *TransactionQueryBuilder) WhereEpoch(epoch uint64) *TransactionQueryBuilder
WhereEpoch adds a where clause to the query builder.
func (*TransactionQueryBuilder) WhereEpochLt ¶
func (qb *TransactionQueryBuilder) WhereEpochLt(epoch uint64) *TransactionQueryBuilder
WhereEpochLt adds a where clause to the query builder.
func (*TransactionQueryBuilder) WhereId ¶
func (qb *TransactionQueryBuilder) WhereId(id int64) *queryBuilder[T]
WhereId adds a where clause to the query builder.
func (*TransactionQueryBuilder) WhereProjectId ¶
func (qb *TransactionQueryBuilder) WhereProjectId(id int64) *TransactionQueryBuilder
WhereProjectId adds a where clause to the query builder.
type WithdrawalRequestQueryBuilder ¶
type WithdrawalRequestQueryBuilder struct {
// contains filtered or unexported fields
}
func (*WithdrawalRequestQueryBuilder) Delete ¶
func (qb *WithdrawalRequestQueryBuilder) Delete() error
Delete deletes all results of the query.
func (*WithdrawalRequestQueryBuilder) GetAll ¶
func (qb *WithdrawalRequestQueryBuilder) GetAll() ([]T, error)
GetAll returns all results of the query. If no result is found, nil is returned.
func (*WithdrawalRequestQueryBuilder) GetFirst ¶
func (qb *WithdrawalRequestQueryBuilder) GetFirst() (*T, error)
GetFirst returns the first result of the query. If no result is found, nil is returned.
func (*WithdrawalRequestQueryBuilder) GetFirstOrFail ¶
func (qb *WithdrawalRequestQueryBuilder) GetFirstOrFail() (*T, error)
GetFirstOrFail returns the first result of the query. If no result is found, an error is returned.
func (*WithdrawalRequestQueryBuilder) Select ¶
func (qb *WithdrawalRequestQueryBuilder) Select(fields ...string) *queryBuilder[T]
Select sets the fields to select.
func (*WithdrawalRequestQueryBuilder) WhereId ¶
func (qb *WithdrawalRequestQueryBuilder) WhereId(id int64) *queryBuilder[T]
WhereId adds a where clause to the query builder.
func (*WithdrawalRequestQueryBuilder) WhereProjectId ¶
func (qb *WithdrawalRequestQueryBuilder) WhereProjectId(projectId int64) *WithdrawalRequestQueryBuilder
WhereProjectId adds a where clause to the query builder.
func (*WithdrawalRequestQueryBuilder) WhereRequestEpoch ¶
func (qb *WithdrawalRequestQueryBuilder) WhereRequestEpoch(epoch uint64) *WithdrawalRequestQueryBuilder
WhereRequestEpoch adds a where clause to the query builder.
func (*WithdrawalRequestQueryBuilder) WhereWithdrawEpoch ¶
func (qb *WithdrawalRequestQueryBuilder) WhereWithdrawEpoch(epoch uint64) *WithdrawalRequestQueryBuilder
WhereWithdrawEpoch adds a where clause to the query builder.