Versions in this module Expand all Collapse all v1 v1.2.0 Mar 8, 2026 Changes in this version + const DefaultLimit + const ErrGetAccountBalance + const ErrRecordLedgerEntry + const MaxLimit + var ErrEventHasAlreadyBeenProcessed = errors.New("contract event has already been processed") + var ErrInvalidLedgerTransactionType = "invalid ledger transaction type" + var ErrRecordTransaction = "failed to record transaction" + func ConnectToDB(cnf DatabaseConfig, embedMigrations embed.FS) (*gorm.DB, error) + func SetupTestDB(t testing.TB) (*gorm.DB, func()) + type ActionLogEntryV1 struct + CreatedAt time.Time + GatedAction uint8 + ID uuid.UUID + UserWallet string + func (ActionLogEntryV1) TableName() string + type ActiveCountByLabel struct + Count uint64 + Label string + type AppLedgerEntryV1 struct + AccountID string + AssetSymbol string + CreatedAt time.Time + Credit decimal.Decimal + Debit decimal.Decimal + ID uuid.UUID + Wallet string + func (AppLedgerEntryV1) TableName() string + type AppParticipantV1 struct + AppSessionID string + SignatureWeight uint8 + WalletAddress string + func (AppParticipantV1) TableName() string + type AppSessionCount struct + Application string + Count uint64 + LastUpdated time.Time + Status app.AppSessionStatus + type AppSessionKeyAppSessionIDV1 struct + AppSessionID string + SessionKeyStateID string + func (AppSessionKeyAppSessionIDV1) TableName() string + type AppSessionKeyApplicationV1 struct + ApplicationID string + SessionKeyStateID string + func (AppSessionKeyApplicationV1) TableName() string + type AppSessionKeyStateV1 struct + AppSessionIDs []AppSessionKeyAppSessionIDV1 + ApplicationIDs []AppSessionKeyApplicationV1 + CreatedAt time.Time + ExpiresAt time.Time + ID string + SessionKey string + UserAddress string + UserSig string + Version uint64 + func (AppSessionKeyStateV1) TableName() string + type AppSessionV1 struct + ApplicationID string + CreatedAt time.Time + ID string + Nonce uint64 + Participants []AppParticipantV1 + Quorum uint8 + SessionData string + Status app.AppSessionStatus + UpdatedAt time.Time + Version uint64 + func (AppSessionV1) TableName() string + type AppV1 struct + CreatedAt time.Time + CreationApprovalNotRequired bool + ID string + Metadata string + OwnerWallet string + UpdatedAt time.Time + Version uint64 + func (AppV1) TableName() string + type BlockchainAction struct + BlockchainID uint64 + CreatedAt time.Time + Data datatypes.JSON + Error string + ID int64 + Retries uint8 + StateID string + Status BlockchainActionStatus + TxHash string + Type BlockchainActionType + UpdatedAt time.Time + func (BlockchainAction) TableName() string + type BlockchainActionStatus uint8 + const BlockchainActionStatusCompleted + const BlockchainActionStatusFailed + const BlockchainActionStatusPending + type BlockchainActionType uint8 + const ActionTypeCheckpoint + const ActionTypeFinalizeEscrowDeposit + const ActionTypeFinalizeEscrowWithdrawal + const ActionTypeInitiateEscrowDeposit + const ActionTypeInitiateEscrowWithdrawal + func (t BlockchainActionType) String() string + type Channel struct + ApprovedSigValidators string + Asset string + BlockchainID uint64 + ChallengeDuration uint32 + ChallengeExpiresAt *time.Time + ChannelID string + CreatedAt time.Time + Nonce uint64 + StateVersion uint64 + Status core.ChannelStatus + Token string + Type core.ChannelType + UpdatedAt time.Time + UserWallet string + func (Channel) TableName() string + type ChannelCount struct + Asset string + Count uint64 + LastUpdated time.Time + Status core.ChannelStatus + type ChannelSessionKeyAssetV1 struct + Asset string + SessionKeyStateID string + func (ChannelSessionKeyAssetV1) TableName() string + type ChannelSessionKeyStateV1 struct + Assets []ChannelSessionKeyAssetV1 + CreatedAt time.Time + ExpiresAt time.Time + ID string + MetadataHash string + SessionKey string + UserAddress string + UserSig string + Version uint64 + func (ChannelSessionKeyStateV1) TableName() string + type ContractEvent struct + BlockNumber uint64 + BlockchainID uint64 + ContractAddress string + CreatedAt time.Time + ID int64 + LogIndex uint32 + Name string + TransactionHash string + func (ContractEvent) TableName() string + type DBStore struct + func (s *DBStore) CheckOpenChannel(wallet, asset string) (string, bool, error) + func (s *DBStore) Complete(actionID int64, txHash string) error + func (s *DBStore) CountActiveAppSessions(window time.Duration) ([]ActiveCountByLabel, error) + func (s *DBStore) CountActiveUsers(window time.Duration) ([]ActiveCountByLabel, error) + func (s *DBStore) CreateApp(entry app.AppV1) error + func (s *DBStore) CreateAppSession(session app.AppSessionV1) error + func (s *DBStore) CreateChannel(channel core.Channel) error + func (s *DBStore) EnsureNoOngoingStateTransitions(wallet, asset string) error + func (s *DBStore) ExecuteInTransaction(txFunc StoreTxHandler) error + func (s *DBStore) Fail(actionID int64, err string) error + func (s *DBStore) FailNoRetry(actionID int64, err string) error + func (s *DBStore) GetActions(limit uint8, blockchainID uint64) ([]BlockchainAction, error) + func (s *DBStore) GetActiveHomeChannel(wallet, asset string) (*core.Channel, error) + func (s *DBStore) GetApp(appID string) (*app.AppInfoV1, error) + func (s *DBStore) GetAppCount(ownerWallet string) (uint64, error) + func (s *DBStore) GetAppSession(sessionID string) (*app.AppSessionV1, error) + func (s *DBStore) GetAppSessionBalances(appSessionID string) (map[string]decimal.Decimal, error) + func (s *DBStore) GetAppSessionKeyOwner(sessionKey, appSessionId string) (string, error) + func (s *DBStore) GetAppSessions(appSessionID *string, participant *string, status app.AppSessionStatus, ...) ([]app.AppSessionV1, core.PaginationMetadata, error) + func (s *DBStore) GetAppSessionsCountByLabels() ([]AppSessionCount, error) + func (s *DBStore) GetApps(appID *string, ownerWallet *string, pagination *core.PaginationParams) ([]app.AppInfoV1, core.PaginationMetadata, error) + func (s *DBStore) GetChannelByID(channelID string) (*core.Channel, error) + func (s *DBStore) GetChannelsCountByLabels() ([]ChannelCount, error) + func (s *DBStore) GetLastAppSessionKeyState(wallet, sessionKey string) (*app.AppSessionKeyStateV1, error) + func (s *DBStore) GetLastAppSessionKeyStates(wallet string, sessionKey *string) ([]app.AppSessionKeyStateV1, error) + func (s *DBStore) GetLastAppSessionKeyVersion(wallet, sessionKey string) (uint64, error) + func (s *DBStore) GetLastChannelSessionKeyStates(wallet string, sessionKey *string) ([]core.ChannelSessionKeyStateV1, error) + func (s *DBStore) GetLastChannelSessionKeyVersion(wallet, sessionKey string) (uint64, error) + func (s *DBStore) GetLastStateByChannelID(channelID string, signed bool) (*core.State, error) + func (s *DBStore) GetLastUserState(wallet, asset string, signed bool) (*core.State, error) + func (s *DBStore) GetLatestEvent(contractAddress string, blockchainID uint64) (core.BlockchainEvent, error) + func (s *DBStore) GetLifetimeMetricLastTimestamp(name string) (time.Time, error) + func (s *DBStore) GetParticipantAllocations(appSessionID string) (map[string]map[string]decimal.Decimal, error) + func (s *DBStore) GetStateByChannelIDAndVersion(channelID string, version uint64) (*core.State, error) + func (s *DBStore) GetStateByID(stateID string) (*core.State, error) + func (s *DBStore) GetTotalUserStaked(wallet string) (decimal.Decimal, error) + func (s *DBStore) GetTotalValueLocked() ([]TotalValueLocked, error) + func (s *DBStore) GetUserActionCount(wallet string, gatedAction core.GatedAction, window time.Duration) (uint64, error) + func (s *DBStore) GetUserActionCounts(userWallet string, window time.Duration) (map[core.GatedAction]uint64, error) + func (s *DBStore) GetUserBalances(wallet string) ([]core.BalanceEntry, error) + func (s *DBStore) GetUserChannels(wallet string, status *core.ChannelStatus, asset *string, ...) ([]core.Channel, uint32, error) + func (s *DBStore) GetUserTransactions(accountID string, asset *string, txType *core.TransactionType, ...) ([]core.Transaction, core.PaginationMetadata, error) + func (s *DBStore) LockUserState(wallet, asset string) (decimal.Decimal, error) + func (s *DBStore) RecordAction(wallet string, gatedAction core.GatedAction) error + func (s *DBStore) RecordAttempt(actionID int64, err string) error + func (s *DBStore) RecordLedgerEntry(userWallet, accountID, asset string, amount decimal.Decimal) error + func (s *DBStore) RecordTransaction(tx core.Transaction) error + func (s *DBStore) ScheduleCheckpoint(stateID string, blockchainID uint64) error + func (s *DBStore) ScheduleFinalizeEscrowDeposit(stateID string, blockchainID uint64) error + func (s *DBStore) ScheduleFinalizeEscrowWithdrawal(stateID string, blockchainID uint64) error + func (s *DBStore) ScheduleInitiateEscrowDeposit(stateID string, blockchainID uint64) error + func (s *DBStore) ScheduleInitiateEscrowWithdrawal(stateID string, blockchainID uint64) error + func (s *DBStore) StoreAppSessionKeyState(state app.AppSessionKeyStateV1) error + func (s *DBStore) StoreChannelSessionKeyState(state core.ChannelSessionKeyStateV1) error + func (s *DBStore) StoreContractEvent(ev core.BlockchainEvent) error + func (s *DBStore) StoreUserState(state core.State) error + func (s *DBStore) UpdateAppSession(session app.AppSessionV1) error + func (s *DBStore) UpdateChannel(channel core.Channel) error + func (s *DBStore) UpdateUserStaked(wallet string, blockchainID uint64, amount decimal.Decimal) error + func (s *DBStore) ValidateChannelSessionKeyForAsset(wallet, sessionKey, asset, metadataHash string) (bool, error) + type DatabaseConfig struct + ConnMaxIdleTime int + ConnMaxLifetime int + Driver string + Host string + MaxIdleConns int + MaxOpenConns int + Name string + Password string + Port string + Retries int + Schema string + URL string + Username string + type DatabaseStore interface + CheckOpenChannel func(wallet, asset string) (string, bool, error) + Complete func(actionID int64, txHash string) error + CountActiveAppSessions func(window time.Duration) ([]ActiveCountByLabel, error) + CountActiveUsers func(window time.Duration) ([]ActiveCountByLabel, error) + CreateApp func(entry app.AppV1) error + CreateAppSession func(session app.AppSessionV1) error + CreateChannel func(channel core.Channel) error + EnsureNoOngoingStateTransitions func(wallet, asset string) error + ExecuteInTransaction func(handler StoreTxHandler) error + Fail func(actionID int64, err string) error + FailNoRetry func(actionID int64, err string) error + GetActions func(limit uint8, chainID uint64) ([]BlockchainAction, error) + GetActiveHomeChannel func(wallet, asset string) (*core.Channel, error) + GetApp func(appID string) (*app.AppInfoV1, error) + GetAppCount func(ownerWallet string) (uint64, error) + GetAppSession func(sessionID string) (*app.AppSessionV1, error) + GetAppSessionBalances func(sessionID string) (map[string]decimal.Decimal, error) + GetAppSessionKeyOwner func(sessionKey, appSessionId string) (string, error) + GetAppSessions func(appSessionID *string, participant *string, status app.AppSessionStatus, ...) ([]app.AppSessionV1, core.PaginationMetadata, error) + GetAppSessionsCountByLabels func() ([]AppSessionCount, error) + GetApps func(appID *string, ownerWallet *string, pagination *core.PaginationParams) ([]app.AppInfoV1, core.PaginationMetadata, error) + GetChannelByID func(channelID string) (*core.Channel, error) + GetChannelsCountByLabels func() ([]ChannelCount, error) + GetLastAppSessionKeyState func(wallet, sessionKey string) (*app.AppSessionKeyStateV1, error) + GetLastAppSessionKeyStates func(wallet string, sessionKey *string) ([]app.AppSessionKeyStateV1, error) + GetLastAppSessionKeyVersion func(wallet, sessionKey string) (uint64, error) + GetLastChannelSessionKeyStates func(wallet string, sessionKey *string) ([]core.ChannelSessionKeyStateV1, error) + GetLastChannelSessionKeyVersion func(wallet, sessionKey string) (uint64, error) + GetLastStateByChannelID func(channelID string, signed bool) (*core.State, error) + GetLastUserState func(wallet, asset string, signed bool) (*core.State, error) + GetLatestEvent func(contractAddress string, blockchainID uint64) (core.BlockchainEvent, error) + GetLifetimeMetricLastTimestamp func(name string) (time.Time, error) + GetParticipantAllocations func(sessionID string) (map[string]map[string]decimal.Decimal, error) + GetStateByChannelIDAndVersion func(channelID string, version uint64) (*core.State, error) + GetStateByID func(stateID string) (*core.State, error) + GetTotalUserStaked func(wallet string) (decimal.Decimal, error) + GetTotalValueLocked func() ([]TotalValueLocked, error) + GetUserActionCount func(wallet string, gatedAction core.GatedAction, window time.Duration) (uint64, error) + GetUserActionCounts func(userWallet string, window time.Duration) (map[core.GatedAction]uint64, error) + GetUserBalances func(wallet string) ([]core.BalanceEntry, error) + GetUserChannels func(wallet string, status *core.ChannelStatus, asset *string, ...) ([]core.Channel, uint32, error) + GetUserTransactions func(wallet string, asset *string, txType *core.TransactionType, fromTime *uint64, ...) ([]core.Transaction, core.PaginationMetadata, error) + LockUserState func(wallet, asset string) (decimal.Decimal, error) + RecordAction func(wallet string, gatedAction core.GatedAction) error + RecordAttempt func(actionID int64, err string) error + RecordLedgerEntry func(userWallet, accountID, asset string, amount decimal.Decimal) error + RecordTransaction func(tx core.Transaction) error + ScheduleCheckpoint func(stateID string, chainID uint64) error + ScheduleFinalizeEscrowDeposit func(stateID string, chainID uint64) error + ScheduleFinalizeEscrowWithdrawal func(stateID string, chainID uint64) error + ScheduleInitiateEscrowDeposit func(stateID string, chainID uint64) error + ScheduleInitiateEscrowWithdrawal func(stateID string, chainID uint64) error + StoreAppSessionKeyState func(state app.AppSessionKeyStateV1) error + StoreChannelSessionKeyState func(state core.ChannelSessionKeyStateV1) error + StoreContractEvent func(ev core.BlockchainEvent) error + StoreUserState func(state core.State) error + UpdateAppSession func(session app.AppSessionV1) error + UpdateChannel func(channel core.Channel) error + UpdateUserStaked func(wallet string, blockchainID uint64, amount decimal.Decimal) error + ValidateChannelSessionKeyForAsset func(wallet, sessionKey, asset, metadataHash string) (bool, error) + func NewDBStore(db *gorm.DB) DatabaseStore + type LifespanMetric struct + ID string + Labels datatypes.JSON + LastTimestamp time.Time + Name string + UpdatedAt time.Time + Value decimal.Decimal + func (LifespanMetric) TableName() string + type ListOptions struct + Limit uint32 + Offset uint32 + Sort *SortType + type SortType string + const SortTypeAscending + const SortTypeDescending + func (s SortType) ToString() string + type State struct + Asset string + CreatedAt time.Time + Epoch uint64 + EscrowBlockchainID *uint64 + EscrowChannelID *string + EscrowNodeBalance decimal.Decimal + EscrowNodeNetFlow decimal.Decimal + EscrowTokenAddress *string + EscrowUserBalance decimal.Decimal + EscrowUserNetFlow decimal.Decimal + HomeBlockchainID *uint64 + HomeChannelID *string + HomeNodeBalance decimal.Decimal + HomeNodeNetFlow decimal.Decimal + HomeTokenAddress *string + HomeUserBalance decimal.Decimal + HomeUserNetFlow decimal.Decimal + ID string + NodeSig *string + TransitionAccountID string + TransitionAmount decimal.Decimal + TransitionTxID string + TransitionType uint8 + UserSig *string + UserWallet string + Version uint64 + func (State) TableName() string + type StoreTxHandler func(DatabaseStore) error + type TotalValueLocked struct + Asset string + Domain string + LastUpdated time.Time + Value decimal.Decimal + type Transaction struct + Amount decimal.Decimal + AssetSymbol string + CreatedAt time.Time + FromAccount string + ID string + ReceiverNewStateID *string + SenderNewStateID *string + ToAccount string + Type core.TransactionType + func (Transaction) TableName() string + type UserBalance struct + Asset string + Balance decimal.Decimal + CreatedAt time.Time + UpdatedAt time.Time + UserWallet string + func (UserBalance) TableName() string + type UserStakedV1 struct + Amount decimal.Decimal + BlockchainID uint64 + CreatedAt time.Time + UpdatedAt time.Time + UserWallet string + func (UserStakedV1) TableName() string