Documentation ¶
Overview ¶
Package promotion is a generated GoMock package.
Package promotion is a generated GoMock package.
Package promotion is a generated GoMock package.
Index ¶
- Constants
- func ClaimPromotion(service *Service) handlers.AppHandler
- func CreatePromotion(service *Service) handlers.AppHandler
- func DrainSuggestion(service *Service) handlers.AppHandler
- func DrainSuggestionV2(service *Service) handlers.AppHandler
- func GetAvailablePromotions(service *Service) handlers.AppHandler
- func GetClaim(service *Service) handlers.AppHandler
- func GetClaimSummary(service *Service) handlers.AppHandler
- func GetCustodianDrainInfo(service *Service) handlers.AppHandler
- func GetDrainPoll(service *Service) handlers.AppHandler
- func MakeSuggestion(service *Service) handlers.AppHandler
- func NewPostgres() (Datastore, ReadOnlyDatastore, error)
- func PostReportBAPEvent(service *Service) handlers.AppHandler
- func PostReportClobberedClaims(service *Service, version int) handlers.AppHandler
- func PostReportWalletEvent(service *Service) handlers.AppHandler
- func Router(service *Service) chi.Router
- func RouterV2(service *Service) chi.Router
- func SetAdminAttestationTopic(newTopic string)
- func SetSuggestionTopic(newTopic string)
- func SuggestionsRouter(service *Service) (chi.Router, error)
- func SuggestionsV2Router(service *Service) (chi.Router, error)
- func WalletEventRouter(service *Service) chi.Router
- type AdminAttestationEvent
- type BAPReport
- type BATLossEvent
- type BapReportPayload
- type BapReportResp
- type BatLossPayload
- type BatchTransferWorker
- type Claim
- type ClaimCreds
- type ClaimRequest
- type ClaimResponse
- type ClaimSummary
- type ClaimWorker
- type ClobberedClaimsRequest
- type ClobberedCreds
- type CreatePromotionRequest
- type CreatePromotionResponse
- type CredentialBinding
- type Custodian
- type CustodianDrain
- type CustodianDrainInfoResponse
- type Datastore
- type DatastoreWithPrometheus
- func (_d DatastoreWithPrometheus) ActivatePromotion(promotion *Promotion) (err error)
- func (_d DatastoreWithPrometheus) ClaimForWallet(promotion *Promotion, issuer *Issuer, wallet *walletutils.Info, ...) (cp1 *Claim, err error)
- func (_d DatastoreWithPrometheus) CreateClaim(promotionID uuid.UUID, walletID string, value decimal.Decimal, ...) (cp1 *Claim, err error)
- func (_d DatastoreWithPrometheus) CreatePromotion(promotionType string, numGrants int, value decimal.Decimal, platform string) (pp1 *Promotion, err error)
- func (_d DatastoreWithPrometheus) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, ...) (tp1 *Transaction, err error)
- func (_d DatastoreWithPrometheus) DeactivatePromotion(promotion *Promotion) (err error)
- func (_d DatastoreWithPrometheus) DrainClaim(drainID *uuid.UUID, claim *Claim, credentials []cbr.CredentialRedemption, ...) (err error)
- func (_d DatastoreWithPrometheus) EnqueueMintDrainJob(ctx context.Context, walletID uuid.UUID, promotionIDs ...uuid.UUID) (err error)
- func (_d DatastoreWithPrometheus) GetAvailablePromotions(platform string) (pa1 []Promotion, err error)
- func (_d DatastoreWithPrometheus) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) (pa1 []Promotion, err error)
- func (_d DatastoreWithPrometheus) GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (cp1 *Claim, err error)
- func (_d DatastoreWithPrometheus) GetClaimCreds(claimID uuid.UUID) (cp1 *ClaimCreds, err error)
- func (_d DatastoreWithPrometheus) GetClaimSummary(walletID uuid.UUID, grantType string) (cp1 *ClaimSummary, err error)
- func (_d DatastoreWithPrometheus) GetCustodianDrainInfo(paymentID *uuid.UUID) (ca1 []CustodianDrain, err error)
- func (_d DatastoreWithPrometheus) GetDrainPoll(drainID *uuid.UUID) (dp1 *DrainPoll, err error)
- func (_d DatastoreWithPrometheus) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) (da1 []DrainTransfer, err error)
- func (_d DatastoreWithPrometheus) GetIssuer(promotionID uuid.UUID, cohort string) (ip1 *Issuer, err error)
- func (_d DatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error)
- func (_d DatastoreWithPrometheus) GetOrder(orderID uuid.UUID) (op1 *Order, err error)
- func (_d DatastoreWithPrometheus) GetPreClaim(promotionID uuid.UUID, walletID string) (cp1 *Claim, err error)
- func (_d DatastoreWithPrometheus) GetPromotion(promotionID uuid.UUID) (pp1 *Promotion, err error)
- func (_d DatastoreWithPrometheus) GetPromotionsMissingIssuer(limit int) (ua1 []uuid.UUID, err error)
- func (_d DatastoreWithPrometheus) GetSumForTransactions(orderID uuid.UUID) (d1 decimal.Decimal, err error)
- func (_d DatastoreWithPrometheus) InsertBAPReportEvent(ctx context.Context, paymentID uuid.UUID, amount decimal.Decimal) (up1 *uuid.UUID, err error)
- func (_d DatastoreWithPrometheus) InsertBATLossEvent(ctx context.Context, paymentID uuid.UUID, reportID int, amount decimal.Decimal, ...) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) InsertClobberedClaims(ctx context.Context, ids []uuid.UUID, version int) (err error)
- func (_d DatastoreWithPrometheus) InsertIssuer(issuer *Issuer) (ip1 *Issuer, err error)
- func (_d DatastoreWithPrometheus) InsertSuggestion(credentials []cbr.CredentialRedemption, suggestionText string, ...) (err error)
- func (_d DatastoreWithPrometheus) MarkBatchTransferSubmitted(ctx context.Context, batchID *uuid.UUID) (err error)
- func (_d DatastoreWithPrometheus) Migrate(p1 ...uint) (err error)
- func (_d DatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)
- func (_d DatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)
- func (_d DatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)
- func (_d DatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)
- func (_d DatastoreWithPrometheus) RunNextBatchPaymentsJob(ctx context.Context, worker BatchTransferWorker) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) RunNextClaimJob(ctx context.Context, worker ClaimWorker) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) RunNextDrainJob(ctx context.Context, worker DrainWorker) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) RunNextDrainRetryJob(ctx context.Context, worker DrainRetryWorker) (err error)
- func (_d DatastoreWithPrometheus) RunNextMintDrainJob(ctx context.Context, worker MintWorker) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) RunNextSuggestionJob(ctx context.Context, worker SuggestionWorker) (b1 bool, err error)
- func (_d DatastoreWithPrometheus) SaveClaimCreds(claimCreds *ClaimCreds) (err error)
- func (_d DatastoreWithPrometheus) SetMintDrainPromotionTotal(ctx context.Context, walletID uuid.UUID, promotionID uuid.UUID, ...) (err error)
- func (_d DatastoreWithPrometheus) UpdateOrder(orderID uuid.UUID, status string) (err error)
- type DrainInfo
- type DrainJob
- type DrainPoll
- type DrainPollResponse
- type DrainRetryWorker
- type DrainSuggestionRequest
- type DrainSuggestionV2Request
- type DrainSuggestionV2Response
- type DrainTransfer
- type DrainWorker
- type FundingSource
- type GetClaimResponse
- type Issuer
- type KafkaReader
- type MintDrainJob
- type MintDrainPromotion
- type MintWorker
- type MockBatchTransferWorker
- type MockBatchTransferWorkerMockRecorder
- type MockClaimWorker
- type MockClaimWorkerMockRecorder
- type MockDrainRetryWorker
- type MockDrainRetryWorkerMockRecorder
- type MockDrainWorker
- type MockDrainWorkerMockRecorder
- type MockKafkaReader
- type MockKafkaReaderMockRecorder
- type MockMintWorker
- type MockMintWorkerMockRecorder
- type Order
- type OrderItem
- type Postgres
- func (pg *Postgres) ActivatePromotion(promotion *Promotion) error
- func (pg *Postgres) ClaimForWallet(promotion *Promotion, issuer *Issuer, wallet *walletutils.Info, ...) (*Claim, error)
- func (pg *Postgres) CreateClaim(promotionID uuid.UUID, walletID string, value decimal.Decimal, ...) (*Claim, error)
- func (pg *Postgres) CreatePromotion(promotionType string, numGrants int, value decimal.Decimal, platform string) (*Promotion, error)
- func (pg *Postgres) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, ...) (*Transaction, error)
- func (pg *Postgres) DeactivatePromotion(promotion *Promotion) error
- func (pg *Postgres) DrainClaim(drainPollID *uuid.UUID, claim *Claim, credentials []cbr.CredentialRedemption, ...) error
- func (pg *Postgres) EnqueueMintDrainJob(ctx context.Context, walletID uuid.UUID, promotionIDs ...uuid.UUID) error
- func (pg *Postgres) GetAvailablePromotions(platform string) ([]Promotion, error)
- func (pg *Postgres) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) ([]Promotion, error)
- func (pg *Postgres) GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotion *Promotion) (*Claim, error)
- func (pg *Postgres) GetClaimCreds(claimID uuid.UUID) (*ClaimCreds, error)
- func (pg *Postgres) GetClaimSummary(walletID uuid.UUID, grantType string) (*ClaimSummary, error)
- func (pg *Postgres) GetCustodianDrainInfo(paymentID *uuid.UUID) ([]CustodianDrain, error)
- func (pg *Postgres) GetDrainPoll(drainID *uuid.UUID) (*DrainPoll, error)
- func (pg *Postgres) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) ([]DrainTransfer, error)
- func (pg *Postgres) GetIssuer(promotionID uuid.UUID, cohort string) (*Issuer, error)
- func (pg *Postgres) GetIssuerByPublicKey(publicKey string) (*Issuer, error)
- func (pg *Postgres) GetOrder(orderID uuid.UUID) (*Order, error)
- func (pg *Postgres) GetPreClaim(promotionID uuid.UUID, walletID string) (*Claim, error)
- func (pg *Postgres) GetPromotion(promotionID uuid.UUID) (*Promotion, error)
- func (pg *Postgres) GetPromotionsMissingIssuer(limit int) ([]uuid.UUID, error)
- func (pg *Postgres) GetSumForTransactions(orderID uuid.UUID) (decimal.Decimal, error)
- func (pg *Postgres) InsertBAPReportEvent(ctx context.Context, paymentID uuid.UUID, amount decimal.Decimal) (*uuid.UUID, error)
- func (pg *Postgres) InsertBATLossEvent(ctx context.Context, paymentID uuid.UUID, reportID int, amount decimal.Decimal, ...) (bool, error)
- func (pg *Postgres) InsertClobberedClaims(ctx context.Context, ids []uuid.UUID, version int) error
- func (pg *Postgres) InsertIssuer(issuer *Issuer) (*Issuer, error)
- func (pg *Postgres) InsertSuggestion(credentials []cbr.CredentialRedemption, suggestionText string, ...) error
- func (pg *Postgres) MarkBatchTransferSubmitted(ctx context.Context, batchID *uuid.UUID) error
- func (pg *Postgres) RunNextBatchPaymentsJob(ctx context.Context, worker BatchTransferWorker) (bool, error)
- func (pg *Postgres) RunNextClaimJob(ctx context.Context, worker ClaimWorker) (bool, error)
- func (pg *Postgres) RunNextDrainJob(ctx context.Context, worker DrainWorker) (bool, error)
- func (pg *Postgres) RunNextDrainRetryJob(ctx context.Context, worker DrainRetryWorker) error
- func (pg *Postgres) RunNextMintDrainJob(ctx context.Context, worker MintWorker) (bool, error)
- func (pg *Postgres) RunNextSuggestionJob(ctx context.Context, worker SuggestionWorker) (bool, error)
- func (pg *Postgres) SaveClaimCreds(creds *ClaimCreds) error
- func (pg *Postgres) SetMintDrainPromotionTotal(ctx context.Context, walletID, promotionID uuid.UUID, total decimal.Decimal) error
- func (pg *Postgres) UpdateOrder(orderID uuid.UUID, status string) error
- type Promotion
- type PromotionsResponse
- type ReadOnlyDatastore
- type ReadOnlyDatastoreWithPrometheus
- func (_d ReadOnlyDatastoreWithPrometheus) GetAvailablePromotions(platform string) (pa1 []Promotion, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) (pa1 []Promotion, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (cp1 *Claim, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetClaimCreds(claimID uuid.UUID) (cp1 *ClaimCreds, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetClaimSummary(walletID uuid.UUID, grantType string) (cp1 *ClaimSummary, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetCustodianDrainInfo(paymentID *uuid.UUID) (ca1 []CustodianDrain, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetDrainPoll(drainID *uuid.UUID) (dp1 *DrainPoll, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) (da1 []DrainTransfer, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetIssuer(promotionID uuid.UUID, cohort string) (ip1 *Issuer, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetPreClaim(promotionID uuid.UUID, walletID string) (cp1 *Claim, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetPromotion(promotionID uuid.UUID) (pp1 *Promotion, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) GetPromotionsMissingIssuer(limit int) (ua1 []uuid.UUID, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) Migrate(p1 ...uint) (err error)
- func (_d ReadOnlyDatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)
- func (_d ReadOnlyDatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)
- func (_d ReadOnlyDatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)
- func (_d ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)
- type Service
- func (service *Service) ClaimPromotionForWallet(ctx context.Context, promotionID uuid.UUID, walletID uuid.UUID, ...) (*uuid.UUID, error)
- func (service *Service) CreateIssuer(ctx context.Context, promotionID uuid.UUID, cohort string) (*Issuer, error)
- func (service *Service) Drain(ctx context.Context, credentials []CredentialBinding, walletID uuid.UUID) (*uuid.UUID, error)
- func (service *Service) FetchAdminAttestationWalletID(ctx context.Context) (*uuid.UUID, error)
- func (service *Service) GetAvailablePromotions(ctx context.Context, walletID *uuid.UUID, platform string, migrate bool) (*[]Promotion, error)
- func (service *Service) GetCredentialRedemptions(ctx context.Context, credentials []CredentialBinding) (total decimal.Decimal, requestCredentials []cbr.CredentialRedemption, ...)
- func (service *Service) GetOrCreateIssuer(ctx context.Context, promotionID uuid.UUID, cohort string) (*Issuer, error)
- func (s *Service) InitHotWallet(ctx context.Context) error
- func (s *Service) InitKafka(ctx context.Context) error
- func (service *Service) IsPaused() bool
- func (s *Service) Jobs() []srv.Job
- func (service *Service) LookupVerifier(ctx context.Context, keyID string) (context.Context, *httpsignature.Verifier, error)
- func (service *Service) MintGrant(ctx context.Context, walletID uuid.UUID, total decimal.Decimal, ...) error
- func (service *Service) PauseWorker(until time.Time)
- func (s *Service) ReadableDatastore() ReadOnlyDatastore
- func (service *Service) RedeemAndCreateSuggestionEvent(ctx context.Context, credentials []cbr.CredentialRedemption, ...) error
- func (service *Service) RedeemAndTransferFunds(ctx context.Context, credentials []cbr.CredentialRedemption, ...) (*walletutils.TransactionInfo, error)
- func (s *Service) RunNextBatchPaymentsJob(ctx context.Context) (bool, error)
- func (s *Service) RunNextClaimJob(ctx context.Context) (bool, error)
- func (s *Service) RunNextDrainJob(ctx context.Context) (bool, error)
- func (s *Service) RunNextDrainRetryJob(ctx context.Context) (bool, error)
- func (s *Service) RunNextMintDrainJob(ctx context.Context) (bool, error)
- func (s *Service) RunNextPromotionMissingIssuer(ctx context.Context) (bool, error)
- func (s *Service) RunNextSuggestionJob(ctx context.Context) (bool, error)
- func (service *Service) SignClaimCreds(ctx context.Context, claimID uuid.UUID, issuer Issuer, blindedCreds []string) (*ClaimCreds, error)
- func (service *Service) SubmitBatchTransfer(ctx context.Context, batchID *uuid.UUID) error
- func (service *Service) Suggest(ctx context.Context, credentials []CredentialBinding, suggestionText string) error
- func (service *Service) TryUpgradeSuggestionEvent(suggestion []byte) ([]byte, error)
- func (service *Service) UpdateOrderStatus(orderID uuid.UUID) error
- type Suggestion
- type SuggestionEvent
- type SuggestionJob
- type SuggestionRequest
- type SuggestionWorker
- type Transaction
Constants ¶
const ( // MintDrainJobPending - pending status for the mint_drain job MintDrainJobPending = "pending" // MintDrainJobFailed - failed status for the mint_drain job MintDrainJobFailed = "failed" // MintDrainJobComplete - complete status for the mint_drain job MintDrainJobComplete = "complete" )
Variables ¶
This section is empty.
Functions ¶
func ClaimPromotion ¶
func ClaimPromotion(service *Service) handlers.AppHandler
ClaimPromotion is the handler for claiming a particular promotion by a wallet
func CreatePromotion ¶ added in v0.2.0
func CreatePromotion(service *Service) handlers.AppHandler
CreatePromotion is the handler for creating a promotion
func DrainSuggestion ¶ added in v0.3.0
func DrainSuggestion(service *Service) handlers.AppHandler
DrainSuggestion is the handler for draining ad suggestions for a verified wallet
func DrainSuggestionV2 ¶ added in v0.5.0
func DrainSuggestionV2(service *Service) handlers.AppHandler
DrainSuggestionV2 is the handler for draining ad suggestions for a verified wallet
func GetAvailablePromotions ¶
func GetAvailablePromotions(service *Service) handlers.AppHandler
GetAvailablePromotions is the handler for getting available promotions
func GetClaim ¶
func GetClaim(service *Service) handlers.AppHandler
GetClaim is the handler for checking on a particular claim's status
func GetClaimSummary ¶ added in v0.2.0
func GetClaimSummary(service *Service) handlers.AppHandler
GetClaimSummary returns an summary of grants claimed by a given wallet
func GetCustodianDrainInfo ¶ added in v0.5.0
func GetCustodianDrainInfo(service *Service) handlers.AppHandler
GetCustodianDrainInfo is the handler which provides information about a particular paymentId's drains
func GetDrainPoll ¶ added in v0.5.0
func GetDrainPoll(service *Service) handlers.AppHandler
GetDrainPoll is the handler for checking on a particular claim's status
func MakeSuggestion ¶ added in v0.2.0
func MakeSuggestion(service *Service) handlers.AppHandler
MakeSuggestion is the handler for making a suggestion using credentials
func NewPostgres ¶
func NewPostgres() (Datastore, ReadOnlyDatastore, error)
NewPostgres creates new postgres connections
func PostReportBAPEvent ¶ added in v0.5.0
func PostReportBAPEvent(service *Service) handlers.AppHandler
PostReportBAPEvent is the handler for reporting bat was lost by client bug
func PostReportClobberedClaims ¶ added in v0.3.0
func PostReportClobberedClaims(service *Service, version int) handlers.AppHandler
PostReportClobberedClaims is the handler for reporting claims that were clobbered by client bug
func PostReportWalletEvent ¶ added in v0.4.0
func PostReportWalletEvent(service *Service) handlers.AppHandler
PostReportWalletEvent is the handler for reporting bat was lost by client bug
func SetAdminAttestationTopic ¶ added in v0.5.1
func SetAdminAttestationTopic(newTopic string)
SetAdminAttestationTopic set admin attestation topic
func SetSuggestionTopic ¶ added in v0.3.0
func SetSuggestionTopic(newTopic string)
SetSuggestionTopic allows for a new topic to be suggested
func SuggestionsRouter ¶ added in v0.2.0
SuggestionsRouter for suggestions endpoints
func SuggestionsV2Router ¶ added in v0.5.0
SuggestionsV2Router for suggestions endpoints
func WalletEventRouter ¶ added in v0.4.0
WalletEventRouter for reporting bat loss events
Types ¶
type AdminAttestationEvent ¶ added in v0.5.1
type AdminAttestationEvent struct { WalletID string `json:"wallet_id"` Service string `json:"service"` Signal string `json:"signal"` Score int32 `json:"score"` Justification string `json:"justification"` CreatedAt string `json:"created_at"` }
AdminAttestationEvent - kafka admin attestation event
type BAPReport ¶ added in v0.5.0
type BAPReport struct { ID uuid.UUID `db:"id" json:"id"` WalletID uuid.UUID `db:"wallet_id" json:"walletId"` Amount decimal.Decimal `db:"amount" json:"amount"` CreatedAt time.Time `db:"created_at" json:"createdAt"` }
BAPReport holds info about wallet events
type BATLossEvent ¶ added in v0.4.0
type BATLossEvent struct { ID uuid.UUID `db:"id" json:"id"` WalletID uuid.UUID `db:"wallet_id" json:"walletId"` ReportID int `db:"report_id" json:"reportId"` Amount decimal.Decimal `db:"amount" json:"amount"` Platform string `db:"platform" json:"platform"` }
BATLossEvent holds info about wallet events
type BapReportPayload ¶ added in v0.5.0
BapReportPayload holds the data needed to report that bat has been lost by client bug
type BapReportResp ¶ added in v0.5.0
BapReportResp holds the data needed to report that bat has been lost by client bug
type BatLossPayload ¶ added in v0.4.0
BatLossPayload holds the data needed to report that bat has been lost by client bug
type BatchTransferWorker ¶ added in v0.5.1
type BatchTransferWorker interface {
SubmitBatchTransfer(ctx context.Context, batchID *uuid.UUID) error
}
BatchTransferWorker - Worker that has the ability to "submit" a batch of transactions with payments service. The DrainWorker tasks employ the payments GRPC client "prepare" method, and provide the "batch id" in the metadata of the grpc request. Payments GRPC server will append all TXs in a batch to a single transfer job. The SubmitBatchTransfer will notice claim_drain batches that are complete, and perform a submit to the Payments API
type Claim ¶
type Claim struct { ID uuid.UUID `db:"id"` CreatedAt time.Time `db:"created_at"` PromotionID uuid.UUID `db:"promotion_id"` WalletID uuid.UUID `db:"wallet_id"` ApproximateValue decimal.Decimal `db:"approximate_value"` Redeemed bool `db:"redeemed"` Bonus decimal.Decimal `db:"bonus"` LegacyClaimed bool `db:"legacy_claimed"` RedeemedAt pq.NullTime `db:"redeemed_at"` Drained bool `db:"drained"` DrainedAt pq.NullTime `db:"drained_at"` UpdatedAt pq.NullTime `db:"updated_at"` ClaimType *string `db:"claim_type"` }
Claim encapsulates a redeemed or unredeemed ("pre-registered") claim to a promotion by a wallet
type ClaimCreds ¶
type ClaimCreds struct { ID uuid.UUID `db:"claim_id"` IssuerID uuid.UUID `db:"issuer_id"` BlindedCreds jsonutils.JSONStringArray `db:"blinded_creds"` SignedCreds *jsonutils.JSONStringArray `db:"signed_creds"` BatchProof *string `db:"batch_proof"` PublicKey *string `db:"public_key"` }
ClaimCreds encapsulates the credentials to be signed in response to a valid claim
type ClaimRequest ¶
type ClaimRequest struct { WalletID uuid.UUID `json:"paymentId" valid:"-"` BlindedCreds []string `json:"blindedCreds" valid:"base64"` }
ClaimRequest includes the ID of the wallet attempting to claim and blinded credentials which to be signed
type ClaimResponse ¶
ClaimResponse includes a ClaimID which can later be used to check the status of the claim
type ClaimSummary ¶ added in v0.2.0
type ClaimSummary struct { Amount decimal.Decimal `json:"amount" db:"amount"` Earnings decimal.Decimal `json:"earnings" db:"earnings"` LastClaim time.Time `json:"lastClaim" db:"last_claim"` Type string `json:"type" db:"type"` }
ClaimSummary outlines the state of a wallet's claims
type ClaimWorker ¶ added in v0.2.0
type ClaimWorker interface {
SignClaimCreds(ctx context.Context, claimID uuid.UUID, issuer Issuer, blindedCreds []string) (*ClaimCreds, error)
}
ClaimWorker attempts to work on a claim job by signing the blinded credentials of the client
type ClobberedClaimsRequest ¶ added in v0.3.0
ClobberedClaimsRequest holds the data needed to report claims that were clobbered by client bug
type ClobberedCreds ¶ added in v0.3.0
type ClobberedCreds struct { ID uuid.UUID `db:"id"` CreatedAt time.Time `db:"created_at"` Version int `db:"version"` }
ClobberedCreds holds data of claims that have been clobbered and when they were first reported
type CreatePromotionRequest ¶ added in v0.2.0
type CreatePromotionRequest struct { Type string `json:"type" valid:"in(ads|ugp)"` NumGrants int `json:"numGrants" valid:"required"` Value decimal.Decimal `json:"value" valid:"required"` Platform string `json:"platform" valid:"platform,optional"` Active bool `json:"active" valid:"-"` }
CreatePromotionRequest includes information needed to create a promotion
type CreatePromotionResponse ¶ added in v0.2.0
type CreatePromotionResponse struct {
Promotion
}
CreatePromotionResponse includes information about the created promotion
type CredentialBinding ¶ added in v0.2.0
type CredentialBinding struct { PublicKey string `json:"publicKey" valid:"base64"` TokenPreimage string `json:"t" valid:"base64"` Signature string `json:"signature" valid:"base64"` }
CredentialBinding includes info needed to redeem a single credential
func DeduplicateCredentialBindings ¶ added in v0.3.0
func DeduplicateCredentialBindings(tokens ...CredentialBinding) []CredentialBinding
DeduplicateCredentialBindings - given a list of tokens return a deduplicated list
type Custodian ¶ added in v0.5.0
type Custodian struct { Provider string `json:"provider,omitempty" db:"user_deposit_account_provider"` DepositDestination string `json:"deposit_destination,omitempty" db:"user_deposit_destination"` }
Custodian - generic custodian output data
type CustodianDrain ¶ added in v0.5.0
type CustodianDrain struct { BatchID uuid.UUID `json:"batch_id"` Custodian Custodian `json:"custodian,omitempty"` PromotionsDrained []DrainInfo `json:"promotions_drained,omitempty"` Value decimal.Decimal `json:"value"` }
CustodianDrain - representation of a drain job
type CustodianDrainInfoResponse ¶ added in v0.5.0
type CustodianDrainInfoResponse struct { responses.Meta Drains []CustodianDrain `json:"drains,omitempty"` }
CustodianDrainInfoResponse - the response to a custodian drain info request
type Datastore ¶
type Datastore interface { grantserver.Datastore // ActivatePromotion marks a particular promotion as active ActivatePromotion(promotion *Promotion) error // DeactivatePromotion marks a particular promotion as inactive DeactivatePromotion(promotion *Promotion) error // ClaimForWallet is used to either create a new claim or convert a preregistered claim for a particular promotion ClaimForWallet(promotion *Promotion, issuer *Issuer, wallet *walletutils.Info, blindedCreds jsonutils.JSONStringArray) (*Claim, error) // CreateClaim is used to "pre-register" an unredeemed claim for a particular wallet CreateClaim(promotionID uuid.UUID, walletID string, value decimal.Decimal, bonus decimal.Decimal, legacy bool) (*Claim, error) // GetPreClaim is used to fetch a "pre-registered" claim for a particular wallet GetPreClaim(promotionID uuid.UUID, walletID string) (*Claim, error) // CreatePromotion given the promotion type, initial number of grants and the desired value of those grants CreatePromotion(promotionType string, numGrants int, value decimal.Decimal, platform string) (*Promotion, error) // GetAvailablePromotionsForWallet returns the list of available promotions for the wallet GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) ([]Promotion, error) // GetAvailablePromotions returns the list of available promotions for all wallets GetAvailablePromotions(platform string) ([]Promotion, error) // GetPromotionsMissingIssuer returns the list of promotions missing an issuer GetPromotionsMissingIssuer(limit int) ([]uuid.UUID, error) // GetClaimCreds returns the claim credentials for a ClaimID GetClaimCreds(claimID uuid.UUID) (*ClaimCreds, error) // SaveClaimCreds updates the stored claim credentials SaveClaimCreds(claimCreds *ClaimCreds) error // GetPromotion by ID GetPromotion(promotionID uuid.UUID) (*Promotion, error) // InsertIssuer inserts the given issuer InsertIssuer(issuer *Issuer) (*Issuer, error) // GetIssuer by PromotionID and cohort GetIssuer(promotionID uuid.UUID, cohort string) (*Issuer, error) // GetIssuerByPublicKey GetIssuerByPublicKey(publicKey string) (*Issuer, error) // GetClaimSummary gets the number of grants for a specific type GetClaimSummary(walletID uuid.UUID, grantType string) (*ClaimSummary, error) // GetClaimByWalletAndPromotion gets whether a wallet has a claimed grants // with the given promotion and returns the grant if so GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (*Claim, error) // RunNextClaimJob to sign claim credentials if there is a claim waiting RunNextClaimJob(ctx context.Context, worker ClaimWorker) (bool, error) // InsertSuggestion inserts a transaction awaiting validation InsertSuggestion(credentials []cbr.CredentialRedemption, suggestionText string, suggestion []byte) error // RunNextSuggestionJob to process a suggestion if there is one waiting RunNextSuggestionJob(ctx context.Context, worker SuggestionWorker) (bool, error) // InsertClobberedClaims inserts clobbered claim ids into the clobbered_claims table InsertClobberedClaims(ctx context.Context, ids []uuid.UUID, version int) error // InsertBATLossEvent inserts claims of lost bat InsertBATLossEvent(ctx context.Context, paymentID uuid.UUID, reportID int, amount decimal.Decimal, platform string) (bool, error) // InsertBAPReportEvent inserts a BAP report InsertBAPReportEvent(ctx context.Context, paymentID uuid.UUID, amount decimal.Decimal) (*uuid.UUID, error) // DrainClaim by marking the claim as drained and inserting a new drain entry DrainClaim(drainID *uuid.UUID, claim *Claim, credentials []cbr.CredentialRedemption, wallet *walletutils.Info, total decimal.Decimal, codedErr errorutils.DrainCodified) error // RunNextDrainJob to process deposits if there is one waiting RunNextDrainJob(ctx context.Context, worker DrainWorker) (bool, error) // RunNextDrainRetryJob toggles failed drain jobs to be reprocessed if eligible RunNextDrainRetryJob(ctx context.Context, worker DrainRetryWorker) error // EnqueueMintDrainJob - enqueue a mint drain job in "pending" status EnqueueMintDrainJob(ctx context.Context, walletID uuid.UUID, promotionIDs ...uuid.UUID) error // SetMintDrainPromotionTotal - set the per promotion total for the mint drain SetMintDrainPromotionTotal(ctx context.Context, walletID, promotionID uuid.UUID, total decimal.Decimal) error // RunNextMintDrainJob to create new grants from the mint queue RunNextMintDrainJob(ctx context.Context, worker MintWorker) (bool, error) // GetOrder by ID GetOrder(orderID uuid.UUID) (*Order, error) // UpdateOrder updates an order when it has been paid UpdateOrder(orderID uuid.UUID, status string) error // CreateTransaction creates a transaction CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error) // GetSumForTransactions gets a decimal sum of for transactions for an order GetSumForTransactions(orderID uuid.UUID) (decimal.Decimal, error) // GetDrainPoll gets the information about a drain poll job GetDrainPoll(drainID *uuid.UUID) (*DrainPoll, error) // GetDrainsByBatchID gets the information about a drain poll job GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) ([]DrainTransfer, error) // GetCustodianDrainInfo gets the information about a drain poll job GetCustodianDrainInfo(paymentID *uuid.UUID) ([]CustodianDrain, error) // MarkBatchTransferSubmitted mark this batch of transfers submitted MarkBatchTransferSubmitted(ctx context.Context, batchID *uuid.UUID) error // RunNextBatchPaymentsJob to sign claim credentials if there is a claim waiting RunNextBatchPaymentsJob(ctx context.Context, worker BatchTransferWorker) (bool, error) }
Datastore abstracts over the underlying datastore
type DatastoreWithPrometheus ¶ added in v0.3.0
type DatastoreWithPrometheus struct {
// contains filtered or unexported fields
}
DatastoreWithPrometheus implements Datastore interface with all methods wrapped with Prometheus metrics
func NewDatastoreWithPrometheus ¶ added in v0.3.0
func NewDatastoreWithPrometheus(base Datastore, instanceName string) DatastoreWithPrometheus
NewDatastoreWithPrometheus returns an instance of the Datastore decorated with prometheus summary metric
func (DatastoreWithPrometheus) ActivatePromotion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) ActivatePromotion(promotion *Promotion) (err error)
ActivatePromotion implements Datastore
func (DatastoreWithPrometheus) ClaimForWallet ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) ClaimForWallet(promotion *Promotion, issuer *Issuer, wallet *walletutils.Info, blindedCreds jsonutils.JSONStringArray) (cp1 *Claim, err error)
ClaimForWallet implements Datastore
func (DatastoreWithPrometheus) CreateClaim ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) CreateClaim(promotionID uuid.UUID, walletID string, value decimal.Decimal, bonus decimal.Decimal, legacy bool) (cp1 *Claim, err error)
CreateClaim implements Datastore
func (DatastoreWithPrometheus) CreatePromotion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) CreatePromotion(promotionType string, numGrants int, value decimal.Decimal, platform string) (pp1 *Promotion, err error)
CreatePromotion implements Datastore
func (DatastoreWithPrometheus) CreateTransaction ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (tp1 *Transaction, err error)
CreateTransaction implements Datastore
func (DatastoreWithPrometheus) DeactivatePromotion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) DeactivatePromotion(promotion *Promotion) (err error)
DeactivatePromotion implements Datastore
func (DatastoreWithPrometheus) DrainClaim ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) DrainClaim(drainID *uuid.UUID, claim *Claim, credentials []cbr.CredentialRedemption, wallet *walletutils.Info, total decimal.Decimal, codedErr errorutils.DrainCodified) (err error)
DrainClaim implements Datastore
func (DatastoreWithPrometheus) EnqueueMintDrainJob ¶ added in v0.4.0
func (_d DatastoreWithPrometheus) EnqueueMintDrainJob(ctx context.Context, walletID uuid.UUID, promotionIDs ...uuid.UUID) (err error)
EnqueueMintDrainJob implements Datastore
func (DatastoreWithPrometheus) GetAvailablePromotions ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetAvailablePromotions(platform string) (pa1 []Promotion, err error)
GetAvailablePromotions implements Datastore
func (DatastoreWithPrometheus) GetAvailablePromotionsForWallet ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) (pa1 []Promotion, err error)
GetAvailablePromotionsForWallet implements Datastore
func (DatastoreWithPrometheus) GetClaimByWalletAndPromotion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (cp1 *Claim, err error)
GetClaimByWalletAndPromotion implements Datastore
func (DatastoreWithPrometheus) GetClaimCreds ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetClaimCreds(claimID uuid.UUID) (cp1 *ClaimCreds, err error)
GetClaimCreds implements Datastore
func (DatastoreWithPrometheus) GetClaimSummary ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetClaimSummary(walletID uuid.UUID, grantType string) (cp1 *ClaimSummary, err error)
GetClaimSummary implements Datastore
func (DatastoreWithPrometheus) GetCustodianDrainInfo ¶ added in v0.5.0
func (_d DatastoreWithPrometheus) GetCustodianDrainInfo(paymentID *uuid.UUID) (ca1 []CustodianDrain, err error)
GetCustodianDrainInfo implements Datastore
func (DatastoreWithPrometheus) GetDrainPoll ¶ added in v0.5.0
func (_d DatastoreWithPrometheus) GetDrainPoll(drainID *uuid.UUID) (dp1 *DrainPoll, err error)
GetDrainPoll implements Datastore
func (DatastoreWithPrometheus) GetDrainsByBatchID ¶ added in v0.5.1
func (_d DatastoreWithPrometheus) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) (da1 []DrainTransfer, err error)
GetDrainsByBatchID implements Datastore
func (DatastoreWithPrometheus) GetIssuer ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetIssuer(promotionID uuid.UUID, cohort string) (ip1 *Issuer, err error)
GetIssuer implements Datastore
func (DatastoreWithPrometheus) GetIssuerByPublicKey ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error)
GetIssuerByPublicKey implements Datastore
func (DatastoreWithPrometheus) GetOrder ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetOrder(orderID uuid.UUID) (op1 *Order, err error)
GetOrder implements Datastore
func (DatastoreWithPrometheus) GetPreClaim ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetPreClaim(promotionID uuid.UUID, walletID string) (cp1 *Claim, err error)
GetPreClaim implements Datastore
func (DatastoreWithPrometheus) GetPromotion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetPromotion(promotionID uuid.UUID) (pp1 *Promotion, err error)
GetPromotion implements Datastore
func (DatastoreWithPrometheus) GetPromotionsMissingIssuer ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetPromotionsMissingIssuer(limit int) (ua1 []uuid.UUID, err error)
GetPromotionsMissingIssuer implements Datastore
func (DatastoreWithPrometheus) GetSumForTransactions ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) GetSumForTransactions(orderID uuid.UUID) (d1 decimal.Decimal, err error)
GetSumForTransactions implements Datastore
func (DatastoreWithPrometheus) InsertBAPReportEvent ¶ added in v0.5.0
func (_d DatastoreWithPrometheus) InsertBAPReportEvent(ctx context.Context, paymentID uuid.UUID, amount decimal.Decimal) (up1 *uuid.UUID, err error)
InsertBAPReportEvent implements Datastore
func (DatastoreWithPrometheus) InsertBATLossEvent ¶ added in v0.4.0
func (_d DatastoreWithPrometheus) InsertBATLossEvent(ctx context.Context, paymentID uuid.UUID, reportID int, amount decimal.Decimal, platform string) (b1 bool, err error)
InsertBATLossEvent implements Datastore
func (DatastoreWithPrometheus) InsertClobberedClaims ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) InsertClobberedClaims(ctx context.Context, ids []uuid.UUID, version int) (err error)
InsertClobberedClaims implements Datastore
func (DatastoreWithPrometheus) InsertIssuer ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) InsertIssuer(issuer *Issuer) (ip1 *Issuer, err error)
InsertIssuer implements Datastore
func (DatastoreWithPrometheus) InsertSuggestion ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) InsertSuggestion(credentials []cbr.CredentialRedemption, suggestionText string, suggestion []byte) (err error)
InsertSuggestion implements Datastore
func (DatastoreWithPrometheus) MarkBatchTransferSubmitted ¶ added in v0.5.1
func (_d DatastoreWithPrometheus) MarkBatchTransferSubmitted(ctx context.Context, batchID *uuid.UUID) (err error)
MarkBatchTransferSubmitted implements Datastore
func (DatastoreWithPrometheus) Migrate ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) Migrate(p1 ...uint) (err error)
Migrate implements Datastore
func (DatastoreWithPrometheus) NewMigrate ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)
NewMigrate implements Datastore
func (DatastoreWithPrometheus) RawDB ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)
RawDB implements Datastore
func (DatastoreWithPrometheus) RollbackTx ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)
RollbackTx implements Datastore
func (DatastoreWithPrometheus) RollbackTxAndHandle ¶ added in v0.4.0
func (_d DatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)
RollbackTxAndHandle implements Datastore
func (DatastoreWithPrometheus) RunNextBatchPaymentsJob ¶ added in v0.5.1
func (_d DatastoreWithPrometheus) RunNextBatchPaymentsJob(ctx context.Context, worker BatchTransferWorker) (b1 bool, err error)
RunNextBatchPaymentsJob implements Datastore
func (DatastoreWithPrometheus) RunNextClaimJob ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) RunNextClaimJob(ctx context.Context, worker ClaimWorker) (b1 bool, err error)
RunNextClaimJob implements Datastore
func (DatastoreWithPrometheus) RunNextDrainJob ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) RunNextDrainJob(ctx context.Context, worker DrainWorker) (b1 bool, err error)
RunNextDrainJob implements Datastore
func (DatastoreWithPrometheus) RunNextDrainRetryJob ¶ added in v0.5.1
func (_d DatastoreWithPrometheus) RunNextDrainRetryJob(ctx context.Context, worker DrainRetryWorker) (err error)
RunNextDrainRetryJob implements Datastore
func (DatastoreWithPrometheus) RunNextMintDrainJob ¶ added in v0.4.0
func (_d DatastoreWithPrometheus) RunNextMintDrainJob(ctx context.Context, worker MintWorker) (b1 bool, err error)
RunNextMintDrainJob implements Datastore
func (DatastoreWithPrometheus) RunNextSuggestionJob ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) RunNextSuggestionJob(ctx context.Context, worker SuggestionWorker) (b1 bool, err error)
RunNextSuggestionJob implements Datastore
func (DatastoreWithPrometheus) SaveClaimCreds ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) SaveClaimCreds(claimCreds *ClaimCreds) (err error)
SaveClaimCreds implements Datastore
func (DatastoreWithPrometheus) SetMintDrainPromotionTotal ¶ added in v0.4.0
func (_d DatastoreWithPrometheus) SetMintDrainPromotionTotal(ctx context.Context, walletID uuid.UUID, promotionID uuid.UUID, total decimal.Decimal) (err error)
SetMintDrainPromotionTotal implements Datastore
func (DatastoreWithPrometheus) UpdateOrder ¶ added in v0.3.0
func (_d DatastoreWithPrometheus) UpdateOrder(orderID uuid.UUID, status string) (err error)
UpdateOrder implements Datastore
type DrainInfo ¶ added in v0.5.0
type DrainInfo struct { PromotionID *uuid.UUID `json:"promotion_id,omitempty" db:"promotion_id"` TransactionID *uuid.UUID `json:"transaction_id,omitempty" db:"transaction_id"` CompletedAt *time.Time `json:"completed_at,omitempty" db:"completed_at"` State *string `json:"state,omitempty" db:"state"` ErrCode *string `json:"errcode,omitempty" db:"errcode"` Value decimal.Decimal `json:"value,omitempty" db:"value"` }
DrainInfo - generic custodian output data
type DrainJob ¶ added in v0.5.0
type DrainJob struct { ID uuid.UUID `db:"id"` ClaimID *uuid.UUID `db:"claim_id"` Credentials string `db:"credentials"` WalletID uuid.UUID `db:"wallet_id"` Total decimal.Decimal `db:"total"` TransactionID *string `db:"transaction_id"` Erred bool `db:"erred"` ErrCode *string `db:"errcode"` Status *string `db:"status"` BatchID *uuid.UUID `db:"batch_id"` Completed bool `db:"completed"` CompletedAt pq.NullTime `db:"completed_at"` UpdatedAt pq.NullTime `db:"updated_at"` DepositDestination *string `db:"deposit_destination"` }
DrainJob - definition of a drain job
type DrainPollResponse ¶ added in v0.5.0
DrainPollResponse - structure for a drain poll response
type DrainRetryWorker ¶ added in v0.5.1
type DrainRetryWorker interface {
FetchAdminAttestationWalletID(ctx context.Context) (*uuid.UUID, error)
}
DrainRetryWorker - reads walletID
type DrainSuggestionRequest ¶ added in v0.3.0
type DrainSuggestionRequest struct { WalletID uuid.UUID `json:"paymentId" valid:"-"` Credentials []CredentialBinding `json:"credentials"` }
DrainSuggestionRequest includes the ID of the verified wallet attempting to drain suggestions
type DrainSuggestionV2Request ¶ added in v0.5.0
type DrainSuggestionV2Request struct { WalletID uuid.UUID `json:"paymentId" valid:"-"` Credentials []CredentialBinding `json:"credentials"` }
DrainSuggestionV2Request includes the ID of the verified wallet attempting to drain suggestions and returns the drain_poll uuid so the client can poll for status updates on this draining
type DrainSuggestionV2Response ¶ added in v0.5.0
DrainSuggestionV2Response - the response structure of the token draining endpoint v2
type DrainTransfer ¶ added in v0.5.1
type DrainTransfer struct { ID *uuid.UUID `db:"transaction_id" json:"transaction_id"` Total decimal.Decimal `db:"total" json:"total"` DepositID *string `db:"deposit_destination" json:"deposit_destination"` }
DrainTransfer info about the drains
type DrainWorker ¶ added in v0.3.0
type DrainWorker interface {
RedeemAndTransferFunds(ctx context.Context, credentials []cbr.CredentialRedemption, walletID uuid.UUID, total decimal.Decimal) (*walletutils.TransactionInfo, error)
}
DrainWorker attempts to work on a drain job by redeeming the credentials and transferring funds
type FundingSource ¶ added in v0.2.0
type FundingSource struct { Type string `json:"type"` Amount decimal.Decimal `json:"amount"` Cohort string `json:"cohort"` PromotionID uuid.UUID `json:"promotion"` Credentials []cbr.CredentialRedemption `json:"-"` }
FundingSource describes where funds for this suggestion should come from
type GetClaimResponse ¶
type GetClaimResponse struct { SignedCreds jsonutils.JSONStringArray `json:"signedCreds"` BatchProof string `json:"batchProof"` PublicKey string `json:"publicKey"` }
GetClaimResponse includes signed credentials and a batch proof showing they were signed by the public key
type Issuer ¶
type Issuer struct { ID uuid.UUID `db:"id"` PromotionID uuid.UUID `db:"promotion_id"` Cohort string PublicKey string `db:"public_key"` }
Issuer includes information about a particular credential issuer
type KafkaReader ¶ added in v0.5.1
KafkaReader - reader interface
type MintDrainJob ¶ added in v0.4.0
type MintDrainJob struct { ID uuid.UUID `db:"id"` WalletID uuid.UUID `db:"wallet_id"` Total decimal.Decimal `db:"total"` Done bool `db:"done"` Status string `db:"status"` Erred bool `db:"erred"` }
MintDrainJob - Job structure for the mint_drain queue
type MintDrainPromotion ¶ added in v0.4.0
type MintDrainPromotion struct { MintJobID uuid.UUID `db:"mint_drain_id"` PromotionID uuid.UUID `db:"promotion_id"` Done bool `db:"done"` Total decimal.Decimal `db:"total"` }
MintDrainPromotion - a list of promotions associated with a mint job
type MintWorker ¶ added in v0.4.0
type MintWorker interface {
MintGrant(ctx context.Context, walletID uuid.UUID, total decimal.Decimal, promoIDs ...uuid.UUID) error
}
MintWorker mint worker describes what a mint worker is able to do, mint grants
type MockBatchTransferWorker ¶ added in v0.5.1
type MockBatchTransferWorker struct {
// contains filtered or unexported fields
}
MockBatchTransferWorker is a mock of BatchTransferWorker interface.
func NewMockBatchTransferWorker ¶ added in v0.5.1
func NewMockBatchTransferWorker(ctrl *gomock.Controller) *MockBatchTransferWorker
NewMockBatchTransferWorker creates a new mock instance.
func (*MockBatchTransferWorker) EXPECT ¶ added in v0.5.1
func (m *MockBatchTransferWorker) EXPECT() *MockBatchTransferWorkerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockBatchTransferWorker) SubmitBatchTransfer ¶ added in v0.5.1
func (m *MockBatchTransferWorker) SubmitBatchTransfer(ctx context.Context, batchID *uuid.UUID) error
SubmitBatchTransfer mocks base method.
type MockBatchTransferWorkerMockRecorder ¶ added in v0.5.1
type MockBatchTransferWorkerMockRecorder struct {
// contains filtered or unexported fields
}
MockBatchTransferWorkerMockRecorder is the mock recorder for MockBatchTransferWorker.
func (*MockBatchTransferWorkerMockRecorder) SubmitBatchTransfer ¶ added in v0.5.1
func (mr *MockBatchTransferWorkerMockRecorder) SubmitBatchTransfer(ctx, batchID interface{}) *gomock.Call
SubmitBatchTransfer indicates an expected call of SubmitBatchTransfer.
type MockClaimWorker ¶ added in v0.2.0
type MockClaimWorker struct {
// contains filtered or unexported fields
}
MockClaimWorker is a mock of ClaimWorker interface.
func NewMockClaimWorker ¶ added in v0.2.0
func NewMockClaimWorker(ctrl *gomock.Controller) *MockClaimWorker
NewMockClaimWorker creates a new mock instance.
func (*MockClaimWorker) EXPECT ¶ added in v0.2.0
func (m *MockClaimWorker) EXPECT() *MockClaimWorkerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockClaimWorker) SignClaimCreds ¶ added in v0.2.0
func (m *MockClaimWorker) SignClaimCreds(ctx context.Context, claimID go_uuid.UUID, issuer Issuer, blindedCreds []string) (*ClaimCreds, error)
SignClaimCreds mocks base method.
type MockClaimWorkerMockRecorder ¶ added in v0.2.0
type MockClaimWorkerMockRecorder struct {
// contains filtered or unexported fields
}
MockClaimWorkerMockRecorder is the mock recorder for MockClaimWorker.
func (*MockClaimWorkerMockRecorder) SignClaimCreds ¶ added in v0.2.0
func (mr *MockClaimWorkerMockRecorder) SignClaimCreds(ctx, claimID, issuer, blindedCreds interface{}) *gomock.Call
SignClaimCreds indicates an expected call of SignClaimCreds.
type MockDrainRetryWorker ¶ added in v0.5.1
type MockDrainRetryWorker struct {
// contains filtered or unexported fields
}
MockDrainRetryWorker is a mock of DrainRetryWorker interface.
func NewMockDrainRetryWorker ¶ added in v0.5.1
func NewMockDrainRetryWorker(ctrl *gomock.Controller) *MockDrainRetryWorker
NewMockDrainRetryWorker creates a new mock instance.
func (*MockDrainRetryWorker) EXPECT ¶ added in v0.5.1
func (m *MockDrainRetryWorker) EXPECT() *MockDrainRetryWorkerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDrainRetryWorker) FetchAdminAttestationWalletID ¶ added in v0.5.1
func (m *MockDrainRetryWorker) FetchAdminAttestationWalletID(ctx context.Context) (*uuid.UUID, error)
FetchAdminAttestationWalletID mocks base method.
type MockDrainRetryWorkerMockRecorder ¶ added in v0.5.1
type MockDrainRetryWorkerMockRecorder struct {
// contains filtered or unexported fields
}
MockDrainRetryWorkerMockRecorder is the mock recorder for MockDrainRetryWorker.
func (*MockDrainRetryWorkerMockRecorder) FetchAdminAttestationWalletID ¶ added in v0.5.1
func (mr *MockDrainRetryWorkerMockRecorder) FetchAdminAttestationWalletID(ctx interface{}) *gomock.Call
FetchAdminAttestationWalletID indicates an expected call of FetchAdminAttestationWalletID.
type MockDrainWorker ¶ added in v0.3.0
type MockDrainWorker struct {
// contains filtered or unexported fields
}
MockDrainWorker is a mock of DrainWorker interface.
func NewMockDrainWorker ¶ added in v0.3.0
func NewMockDrainWorker(ctrl *gomock.Controller) *MockDrainWorker
NewMockDrainWorker creates a new mock instance.
func (*MockDrainWorker) EXPECT ¶ added in v0.3.0
func (m *MockDrainWorker) EXPECT() *MockDrainWorkerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDrainWorker) RedeemAndTransferFunds ¶ added in v0.3.0
func (m *MockDrainWorker) RedeemAndTransferFunds(ctx context.Context, credentials []cbr.CredentialRedemption, walletID uuid.UUID, total decimal.Decimal) (*wallet.TransactionInfo, error)
RedeemAndTransferFunds mocks base method.
type MockDrainWorkerMockRecorder ¶ added in v0.3.0
type MockDrainWorkerMockRecorder struct {
// contains filtered or unexported fields
}
MockDrainWorkerMockRecorder is the mock recorder for MockDrainWorker.
func (*MockDrainWorkerMockRecorder) RedeemAndTransferFunds ¶ added in v0.3.0
func (mr *MockDrainWorkerMockRecorder) RedeemAndTransferFunds(ctx, credentials, walletID, total interface{}) *gomock.Call
RedeemAndTransferFunds indicates an expected call of RedeemAndTransferFunds.
type MockKafkaReader ¶ added in v0.5.1
type MockKafkaReader struct {
// contains filtered or unexported fields
}
MockKafkaReader is a mock of KafkaReader interface.
func NewMockKafkaReader ¶ added in v0.5.1
func NewMockKafkaReader(ctrl *gomock.Controller) *MockKafkaReader
NewMockKafkaReader creates a new mock instance.
func (*MockKafkaReader) EXPECT ¶ added in v0.5.1
func (m *MockKafkaReader) EXPECT() *MockKafkaReaderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockKafkaReader) ReadMessage ¶ added in v0.5.1
ReadMessage mocks base method.
type MockKafkaReaderMockRecorder ¶ added in v0.5.1
type MockKafkaReaderMockRecorder struct {
// contains filtered or unexported fields
}
MockKafkaReaderMockRecorder is the mock recorder for MockKafkaReader.
func (*MockKafkaReaderMockRecorder) ReadMessage ¶ added in v0.5.1
func (mr *MockKafkaReaderMockRecorder) ReadMessage(ctx interface{}) *gomock.Call
ReadMessage indicates an expected call of ReadMessage.
type MockMintWorker ¶ added in v0.5.0
type MockMintWorker struct {
// contains filtered or unexported fields
}
MockMintWorker is a mock of MintWorker interface.
func NewMockMintWorker ¶ added in v0.5.0
func NewMockMintWorker(ctrl *gomock.Controller) *MockMintWorker
NewMockMintWorker creates a new mock instance.
func (*MockMintWorker) EXPECT ¶ added in v0.5.0
func (m *MockMintWorker) EXPECT() *MockMintWorkerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockMintWorkerMockRecorder ¶ added in v0.5.0
type MockMintWorkerMockRecorder struct {
// contains filtered or unexported fields
}
MockMintWorkerMockRecorder is the mock recorder for MockMintWorker.
func (*MockMintWorkerMockRecorder) MintGrant ¶ added in v0.5.0
func (mr *MockMintWorkerMockRecorder) MintGrant(ctx, walletID, total interface{}, promoIDs ...interface{}) *gomock.Call
MintGrant indicates an expected call of MintGrant.
type Order ¶ added in v0.3.0
type Order struct { ID uuid.UUID `json:"id" db:"id"` CreatedAt time.Time `json:"createdAt" db:"created_at"` Currency string `json:"currency" db:"currency"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` TotalPrice decimal.Decimal `json:"totalPrice" db:"total_price"` MerchantID string `json:"merchantId" db:"merchant_id"` Location datastore.NullString `json:"location" db:"location"` Status string `json:"status" db:"status"` Items []OrderItem `json:"items"` AllowedPaymentMethods payment.Methods `json:"allowedPaymentMethods" db:"allowed_payment_methods"` Metadata datastore.Metadata `json:"metadata" db:"metadata"` LastPaidAt *time.Time `json:"lastPaidAt" db:"last_paid_at"` ExpiresAt *time.Time `json:"expiresAt" db:"expires_at"` ValidFor *time.Duration `json:"validFor" db:"valid_for"` TrialDays *int64 `json:"-" db:"trial_days"` }
Order includes information about a particular order
type OrderItem ¶ added in v0.3.0
type OrderItem struct { ID uuid.UUID `json:"id" db:"id"` OrderID uuid.UUID `json:"orderId" db:"order_id"` SKU string `json:"sku" db:"sku"` CreatedAt *time.Time `json:"createdAt" db:"created_at"` UpdatedAt *time.Time `json:"updatedAt" db:"updated_at"` Currency string `json:"currency" db:"currency"` Quantity int `json:"quantity" db:"quantity"` Price decimal.Decimal `json:"price" db:"price"` Subtotal decimal.Decimal `json:"subtotal"` Location datastore.NullString `json:"location" db:"location"` Description datastore.NullString `json:"description" db:"description"` CredentialType string `json:"credentialType" db:"credential_type"` ValidFor *time.Duration `json:"validFor" db:"valid_for"` ValidForISO *string `json:"validForIso" db:"valid_for_iso"` Metadata datastore.Metadata `json:"metadata" db:"metadata"` IssuanceIntervalISO *string `json:"issuanceInterval" db:"issuance_interval"` }
OrderItem includes information about a particular order item
type Postgres ¶
type Postgres struct {
grantserver.Postgres
}
Postgres is a Datastore wrapper around a postgres database
func (*Postgres) ActivatePromotion ¶
ActivatePromotion marks a particular promotion as active
func (*Postgres) ClaimForWallet ¶
func (pg *Postgres) ClaimForWallet(promotion *Promotion, issuer *Issuer, wallet *walletutils.Info, blindedCreds jsonutils.JSONStringArray) (*Claim, error)
ClaimForWallet is used to either create a new claim or convert a preregistered claim for a particular promotion
func (*Postgres) CreateClaim ¶
func (pg *Postgres) CreateClaim(promotionID uuid.UUID, walletID string, value decimal.Decimal, bonus decimal.Decimal, legacy bool) (*Claim, error)
CreateClaim is used to "pre-register" an unredeemed claim for a particular wallet
func (*Postgres) CreatePromotion ¶
func (pg *Postgres) CreatePromotion(promotionType string, numGrants int, value decimal.Decimal, platform string) (*Promotion, error)
CreatePromotion given the promotion type, initial number of grants and the desired value of those grants
func (*Postgres) CreateTransaction ¶ added in v0.3.0
func (pg *Postgres) CreateTransaction(orderID uuid.UUID, externalTransactionID string, status string, currency string, kind string, amount decimal.Decimal) (*Transaction, error)
CreateTransaction creates a transaction given an orderID, externalTransactionID, currency, and a kind of transaction
func (*Postgres) DeactivatePromotion ¶ added in v0.3.0
DeactivatePromotion marks a particular promotion as not active
func (*Postgres) DrainClaim ¶ added in v0.3.0
func (pg *Postgres) DrainClaim(drainPollID *uuid.UUID, claim *Claim, credentials []cbr.CredentialRedemption, wallet *walletutils.Info, total decimal.Decimal, codedErr errorutils.DrainCodified) error
DrainClaim by marking the claim as drained and inserting a new drain entry
func (*Postgres) EnqueueMintDrainJob ¶ added in v0.4.0
func (pg *Postgres) EnqueueMintDrainJob(ctx context.Context, walletID uuid.UUID, promotionIDs ...uuid.UUID) error
EnqueueMintDrainJob - enqueue a mint drain job in "pending" status
func (*Postgres) GetAvailablePromotions ¶ added in v0.2.0
GetAvailablePromotions returns the list of available promotions for all wallets
func (*Postgres) GetAvailablePromotionsForWallet ¶
func (pg *Postgres) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) ([]Promotion, error)
GetAvailablePromotionsForWallet returns the list of available promotions for the wallet
func (*Postgres) GetClaimByWalletAndPromotion ¶ added in v0.2.0
func (pg *Postgres) GetClaimByWalletAndPromotion( wallet *walletutils.Info, promotion *Promotion, ) (*Claim, error)
GetClaimByWalletAndPromotion gets whether a wallet has a claimed grants with the given promotion and returns the grant if so
func (*Postgres) GetClaimCreds ¶
func (pg *Postgres) GetClaimCreds(claimID uuid.UUID) (*ClaimCreds, error)
GetClaimCreds returns the claim credentials for a ClaimID
func (*Postgres) GetClaimSummary ¶ added in v0.2.0
GetClaimSummary aggregates the values of a single wallet's claims
func (*Postgres) GetCustodianDrainInfo ¶ added in v0.5.0
func (pg *Postgres) GetCustodianDrainInfo(paymentID *uuid.UUID) ([]CustodianDrain, error)
GetCustodianDrainInfo Get the status of the custodian drain info
func (*Postgres) GetDrainPoll ¶ added in v0.5.0
GetDrainPoll Get the status of the drain poll job
func (*Postgres) GetDrainsByBatchID ¶ added in v0.5.1
func (pg *Postgres) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) ([]DrainTransfer, error)
GetDrainsByBatchID - get the drain by the batch id
func (*Postgres) GetIssuerByPublicKey ¶ added in v0.2.0
GetIssuerByPublicKey or return an error
func (*Postgres) GetPreClaim ¶ added in v0.2.0
GetPreClaim is used to fetch a "pre-registered" claim for a particular wallet
func (*Postgres) GetPromotion ¶
GetPromotion by ID
func (*Postgres) GetPromotionsMissingIssuer ¶ added in v0.3.0
GetPromotionsMissingIssuer returns the list of promotions missing an issuer
func (*Postgres) GetSumForTransactions ¶ added in v0.3.0
GetSumForTransactions returns the calculated sum
func (*Postgres) InsertBAPReportEvent ¶ added in v0.5.0
func (pg *Postgres) InsertBAPReportEvent(ctx context.Context, paymentID uuid.UUID, amount decimal.Decimal) (*uuid.UUID, error)
InsertBAPReportEvent inserts a BAP report
func (*Postgres) InsertBATLossEvent ¶ added in v0.4.0
func (pg *Postgres) InsertBATLossEvent( ctx context.Context, paymentID uuid.UUID, reportID int, amount decimal.Decimal, platform string, ) (bool, error)
InsertBATLossEvent inserts claims of lost bat to db
func (*Postgres) InsertClobberedClaims ¶ added in v0.3.0
InsertClobberedClaims inserts clobbered claims to the db
func (*Postgres) InsertIssuer ¶
InsertIssuer inserts the given issuer
func (*Postgres) InsertSuggestion ¶ added in v0.2.0
func (pg *Postgres) InsertSuggestion(credentials []cbr.CredentialRedemption, suggestionText string, suggestionEvent []byte) error
InsertSuggestion inserts a transaction awaiting validation
func (*Postgres) MarkBatchTransferSubmitted ¶ added in v0.5.1
MarkBatchTransferSubmitted mark this batch of transfers submitted
func (*Postgres) RunNextBatchPaymentsJob ¶ added in v0.5.1
func (pg *Postgres) RunNextBatchPaymentsJob(ctx context.Context, worker BatchTransferWorker) (bool, error)
RunNextBatchPaymentsJob to sign claim credentials if there is a claim waiting, returning true if a job was attempted
func (*Postgres) RunNextClaimJob ¶ added in v0.2.0
RunNextClaimJob to sign claim credentials if there is a claim waiting, returning true if a job was attempted
func (*Postgres) RunNextDrainJob ¶ added in v0.3.0
RunNextDrainJob to process deposits if there is one waiting
func (*Postgres) RunNextDrainRetryJob ¶ added in v0.5.1
func (pg *Postgres) RunNextDrainRetryJob(ctx context.Context, worker DrainRetryWorker) error
RunNextDrainRetryJob - toggles failed drain jobs to be reprocessed if eligible
func (*Postgres) RunNextMintDrainJob ¶ added in v0.4.0
RunNextMintDrainJob to process mints vg
func (*Postgres) RunNextSuggestionJob ¶ added in v0.2.0
func (pg *Postgres) RunNextSuggestionJob(ctx context.Context, worker SuggestionWorker) (bool, error)
RunNextSuggestionJob to process a suggestion if there is one waiting
func (*Postgres) SaveClaimCreds ¶
func (pg *Postgres) SaveClaimCreds(creds *ClaimCreds) error
SaveClaimCreds updates the stored claim credentials
type Promotion ¶
type Promotion struct { ID uuid.UUID `json:"id" db:"id"` CreatedAt time.Time `json:"createdAt" db:"created_at"` ExpiresAt time.Time `json:"expiresAt" db:"expires_at"` Version int `json:"version" db:"version"` SuggestionsPerGrant int `json:"suggestionsPerGrant" db:"suggestions_per_grant"` ApproximateValue decimal.Decimal `json:"approximateValue" db:"approximate_value"` Type string `json:"type" db:"promotion_type"` RemainingGrants int `json:"-" db:"remaining_grants"` Active bool `json:"-" db:"active"` Available bool `json:"available" db:"available"` Platform string `json:"platform" db:"platform"` PublicKeys jsonutils.JSONStringArray `json:"publicKeys" db:"public_keys"` // warning, legacy claimed is not defined in promotions, but rather as a claim attribute LegacyClaimed bool `json:"legacyClaimed" db:"legacy_claimed"` }
Promotion includes information about a particular promotion
func (*Promotion) CredentialValue ¶ added in v0.2.0
CredentialValue returns the approximate value of a credential
type PromotionsResponse ¶
type PromotionsResponse struct {
Promotions []Promotion `json:"promotions"`
}
PromotionsResponse is a list of known promotions to be consumed by the browser
type ReadOnlyDatastore ¶ added in v0.2.0
type ReadOnlyDatastore interface { grantserver.Datastore // GetPreClaim is used to fetch a "pre-registered" claim for a particular wallet GetPreClaim(promotionID uuid.UUID, walletID string) (*Claim, error) // GetAvailablePromotionsForWallet returns the list of available promotions for the wallet GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) ([]Promotion, error) // GetAvailablePromotions returns the list of available promotions for all wallets GetAvailablePromotions(platform string) ([]Promotion, error) // GetPromotionsMissingIssuer returns the list of promotions missing an issuer GetPromotionsMissingIssuer(limit int) ([]uuid.UUID, error) // GetClaimCreds returns the claim credentials for a ClaimID GetClaimCreds(claimID uuid.UUID) (*ClaimCreds, error) // GetPromotion by ID GetPromotion(promotionID uuid.UUID) (*Promotion, error) // GetIssuer by PromotionID and cohort GetIssuer(promotionID uuid.UUID, cohort string) (*Issuer, error) // GetIssuerByPublicKey GetIssuerByPublicKey(publicKey string) (*Issuer, error) // GetClaimSummary gets the number of grants for a specific type GetClaimSummary(walletID uuid.UUID, grantType string) (*ClaimSummary, error) // GetClaimByWalletAndPromotion gets whether a wallet has a claimed grants // with the given promotion and returns the grant if so GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (*Claim, error) // GetDrainPoll gets the information about a drain poll job GetDrainPoll(drainID *uuid.UUID) (*DrainPoll, error) // GetCustodianDrainInfo gets the information about a drain poll job GetCustodianDrainInfo(paymentID *uuid.UUID) ([]CustodianDrain, error) // GetDrainsByBatchID gets the information about a drain poll job GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) ([]DrainTransfer, error) }
ReadOnlyDatastore includes all database methods that can be made with a read only db connection
type ReadOnlyDatastoreWithPrometheus ¶ added in v0.3.0
type ReadOnlyDatastoreWithPrometheus struct {
// contains filtered or unexported fields
}
ReadOnlyDatastoreWithPrometheus implements ReadOnlyDatastore interface with all methods wrapped with Prometheus metrics
func NewReadOnlyDatastoreWithPrometheus ¶ added in v0.3.0
func NewReadOnlyDatastoreWithPrometheus(base ReadOnlyDatastore, instanceName string) ReadOnlyDatastoreWithPrometheus
NewReadOnlyDatastoreWithPrometheus returns an instance of the ReadOnlyDatastore decorated with prometheus summary metric
func (ReadOnlyDatastoreWithPrometheus) GetAvailablePromotions ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetAvailablePromotions(platform string) (pa1 []Promotion, err error)
GetAvailablePromotions implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetAvailablePromotionsForWallet ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetAvailablePromotionsForWallet(wallet *walletutils.Info, platform string) (pa1 []Promotion, err error)
GetAvailablePromotionsForWallet implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetClaimByWalletAndPromotion ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetClaimByWalletAndPromotion(wallet *walletutils.Info, promotionID *Promotion) (cp1 *Claim, err error)
GetClaimByWalletAndPromotion implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetClaimCreds ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetClaimCreds(claimID uuid.UUID) (cp1 *ClaimCreds, err error)
GetClaimCreds implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetClaimSummary ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetClaimSummary(walletID uuid.UUID, grantType string) (cp1 *ClaimSummary, err error)
GetClaimSummary implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetCustodianDrainInfo ¶ added in v0.5.0
func (_d ReadOnlyDatastoreWithPrometheus) GetCustodianDrainInfo(paymentID *uuid.UUID) (ca1 []CustodianDrain, err error)
GetCustodianDrainInfo implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetDrainPoll ¶ added in v0.5.0
func (_d ReadOnlyDatastoreWithPrometheus) GetDrainPoll(drainID *uuid.UUID) (dp1 *DrainPoll, err error)
GetDrainPoll implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetDrainsByBatchID ¶ added in v0.5.1
func (_d ReadOnlyDatastoreWithPrometheus) GetDrainsByBatchID(ctx context.Context, batchID *uuid.UUID) (da1 []DrainTransfer, err error)
GetDrainsByBatchID implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetIssuer ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetIssuer(promotionID uuid.UUID, cohort string) (ip1 *Issuer, err error)
GetIssuer implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetIssuerByPublicKey ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error)
GetIssuerByPublicKey implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetPreClaim ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetPreClaim(promotionID uuid.UUID, walletID string) (cp1 *Claim, err error)
GetPreClaim implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetPromotion ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetPromotion(promotionID uuid.UUID) (pp1 *Promotion, err error)
GetPromotion implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) GetPromotionsMissingIssuer ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) GetPromotionsMissingIssuer(limit int) (ua1 []uuid.UUID, err error)
GetPromotionsMissingIssuer implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) Migrate ¶ added in v0.4.0
func (_d ReadOnlyDatastoreWithPrometheus) Migrate(p1 ...uint) (err error)
Migrate implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) NewMigrate ¶ added in v0.4.0
func (_d ReadOnlyDatastoreWithPrometheus) NewMigrate() (mp1 *migrate.Migrate, err error)
NewMigrate implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) RawDB ¶ added in v0.3.0
func (_d ReadOnlyDatastoreWithPrometheus) RawDB() (dp1 *sqlx.DB)
RawDB implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) RollbackTx ¶ added in v0.4.0
func (_d ReadOnlyDatastoreWithPrometheus) RollbackTx(tx *sqlx.Tx)
RollbackTx implements ReadOnlyDatastore
func (ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle ¶ added in v0.4.0
func (_d ReadOnlyDatastoreWithPrometheus) RollbackTxAndHandle(tx *sqlx.Tx) (err error)
RollbackTxAndHandle implements ReadOnlyDatastore
type Service ¶
type Service struct { Datastore Datastore RoDatastore ReadOnlyDatastore // contains filtered or unexported fields }
Service contains datastore and challenge bypass client connections
func InitService ¶
func InitService( ctx context.Context, promotionDB Datastore, promotionRODB ReadOnlyDatastore, walletService *wallet.Service, ) (*Service, error)
InitService creates a service using the passed datastore and clients configured from the environment
func (*Service) ClaimPromotionForWallet ¶
func (service *Service) ClaimPromotionForWallet( ctx context.Context, promotionID uuid.UUID, walletID uuid.UUID, blindedCreds []string, ) (*uuid.UUID, error)
ClaimPromotionForWallet attempts to claim the promotion on behalf of a wallet and returning the ClaimID It kicks off asynchronous signing of the credentials on success
func (*Service) CreateIssuer ¶
func (service *Service) CreateIssuer(ctx context.Context, promotionID uuid.UUID, cohort string) (*Issuer, error)
CreateIssuer creates a new challenge bypass credential issuer, saving it's information into the datastore
func (*Service) Drain ¶ added in v0.3.0
func (service *Service) Drain(ctx context.Context, credentials []CredentialBinding, walletID uuid.UUID) (*uuid.UUID, error)
Drain ad suggestions into verified wallet
func (*Service) FetchAdminAttestationWalletID ¶ added in v0.5.1
FetchAdminAttestationWalletID - retrieves walletID from topic
func (*Service) GetAvailablePromotions ¶
func (service *Service) GetAvailablePromotions( ctx context.Context, walletID *uuid.UUID, platform string, migrate bool, ) (*[]Promotion, error)
GetAvailablePromotions first tries to look up the wallet and then retrieves available promotions
func (*Service) GetCredentialRedemptions ¶ added in v0.3.0
func (service *Service) GetCredentialRedemptions(ctx context.Context, credentials []CredentialBinding) (total decimal.Decimal, requestCredentials []cbr.CredentialRedemption, fundingSources map[string]FundingSource, promotions map[string]*Promotion, err error)
GetCredentialRedemptions as well as total and funding sources from a list of credential bindings
func (*Service) GetOrCreateIssuer ¶
func (service *Service) GetOrCreateIssuer(ctx context.Context, promotionID uuid.UUID, cohort string) (*Issuer, error)
GetOrCreateIssuer gets a matching issuer if one exists and otherwise creates one
func (*Service) InitHotWallet ¶ added in v0.3.0
InitHotWallet by reading the keypair and card id from the environment
func (*Service) InitKafka ¶ added in v0.2.0
InitKafka by creating a kafka writer and creating local copies of codecs
func (*Service) LookupVerifier ¶ added in v0.5.0
func (service *Service) LookupVerifier(ctx context.Context, keyID string) (context.Context, *httpsignature.Verifier, error)
LookupVerifier based on the HTTP signing keyID, which in our case is the walletID
func (*Service) MintGrant ¶ added in v0.4.0
func (service *Service) MintGrant(ctx context.Context, walletID uuid.UUID, total decimal.Decimal, promotions ...uuid.UUID) error
MintGrant create a new grant for the wallet specified with the total specified
func (*Service) PauseWorker ¶ added in v0.4.0
PauseWorker - pause worker until time specified
func (*Service) ReadableDatastore ¶ added in v0.2.0
func (s *Service) ReadableDatastore() ReadOnlyDatastore
ReadableDatastore returns a read only datastore if available, otherwise a normal datastore
func (*Service) RedeemAndCreateSuggestionEvent ¶ added in v0.2.0
func (service *Service) RedeemAndCreateSuggestionEvent(ctx context.Context, credentials []cbr.CredentialRedemption, suggestionText string, suggestion []byte) error
RedeemAndCreateSuggestionEvent after validating that all the credential bindings
func (*Service) RedeemAndTransferFunds ¶ added in v0.3.0
func (service *Service) RedeemAndTransferFunds(ctx context.Context, credentials []cbr.CredentialRedemption, walletID uuid.UUID, total decimal.Decimal) (*walletutils.TransactionInfo, error)
RedeemAndTransferFunds after validating that all the credential bindings
func (*Service) RunNextBatchPaymentsJob ¶ added in v0.5.1
RunNextBatchPaymentsJob takes the next claim job and completes it
func (*Service) RunNextClaimJob ¶ added in v0.2.0
RunNextClaimJob takes the next claim job and completes it
func (*Service) RunNextDrainJob ¶ added in v0.3.0
RunNextDrainJob takes the next drain job and completes it
func (*Service) RunNextDrainRetryJob ¶ added in v0.5.1
RunNextDrainRetryJob - retires failed drain jobs
func (*Service) RunNextMintDrainJob ¶ added in v0.4.0
RunNextMintDrainJob takes the next mint job and completes it
func (*Service) RunNextPromotionMissingIssuer ¶ added in v0.3.0
RunNextPromotionMissingIssuer takes the next job and completes it
func (*Service) RunNextSuggestionJob ¶ added in v0.2.0
RunNextSuggestionJob takes the next suggestion job and completes it
func (*Service) SignClaimCreds ¶
func (service *Service) SignClaimCreds(ctx context.Context, claimID uuid.UUID, issuer Issuer, blindedCreds []string) (*ClaimCreds, error)
SignClaimCreds signs the blinded credentials
func (*Service) SubmitBatchTransfer ¶ added in v0.5.1
SubmitBatchTransfer after validating that all the credential bindings
func (*Service) Suggest ¶ added in v0.2.0
func (service *Service) Suggest(ctx context.Context, credentials []CredentialBinding, suggestionText string) error
Suggest that a contribution is made
func (*Service) TryUpgradeSuggestionEvent ¶ added in v0.2.0
TryUpgradeSuggestionEvent from JSON format to Avro, filling in any potentially missing fields
type Suggestion ¶
type Suggestion struct { Type string `json:"type" valid:"in(auto-contribute|oneoff-tip|recurring-tip|payment)"` Channel string `json:"channel" valid:"-"` OrderID *uuid.UUID `json:"orderId,omitempty" valid:"-"` }
Suggestion encapsulates information from the user about where /how they want to contribute
func (*Suggestion) Base64Decode ¶
func (s *Suggestion) Base64Decode(text string) error
Base64Decode unmarshalls the suggestion from a string.
type SuggestionEvent ¶ added in v0.2.0
type SuggestionEvent struct { ID uuid.UUID `json:"id"` CreatedAt time.Time `json:"createdAt"` Suggestion TotalAmount decimal.Decimal `json:"totalAmount"` Funding []FundingSource `json:"funding"` }
SuggestionEvent encapsulates user and server provided information about a request to contribute
type SuggestionJob ¶ added in v0.5.0
type SuggestionJob struct { ID uuid.UUID `db:"id"` Credentials string `db:"credentials"` SuggestionText string `db:"suggestion_text"` SuggestionEvent []byte `db:"suggestion_event"` Erred bool `db:"erred"` ErrCode *string `db:"errcode"` CreatedAt time.Time `db:"created_at"` }
SuggestionJob - representation of a suggestion job
type SuggestionRequest ¶ added in v0.2.0
type SuggestionRequest struct { Suggestion string `json:"suggestion" valid:"base64"` Credentials []CredentialBinding `json:"credentials"` }
SuggestionRequest includes a suggestion payload and credentials to be redeemed
type SuggestionWorker ¶ added in v0.2.0
type SuggestionWorker interface { RedeemAndCreateSuggestionEvent(ctx context.Context, credentials []cbr.CredentialRedemption, suggestionText string, suggestion []byte) error PauseWorker(until time.Time) IsPaused() bool }
SuggestionWorker attempts to work on a suggestion job by redeeming the credentials and emitting the event
type Transaction ¶ added in v0.3.0
type Transaction struct { ID uuid.UUID `json:"id" db:"id"` OrderID uuid.UUID `json:"order_id" db:"order_id"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` ExternalTransactionID string `json:"external_transaction_id" db:"external_transaction_id"` Status string `json:"status" db:"status"` Currency string `json:"currency" db:"currency"` Kind string `json:"kind" db:"kind"` Amount decimal.Decimal `json:"amount" db:"amount"` }
Transaction includes information about a particular order. Status can be pending, failure, completed, or error.