Files
sendico/api/chain/gateway/storage/storage.go
Stephan D 62a6631b9a
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
service backend
2025-11-07 18:35:26 +01:00

54 lines
2.1 KiB
Go

package storage
import (
"context"
"github.com/tech/sendico/chain/gateway/storage/model"
)
type storageError string
func (e storageError) Error() string {
return string(e)
}
var (
// ErrWalletNotFound indicates that a wallet record was not found.
ErrWalletNotFound = storageError("chain.gateway.storage: wallet not found")
// ErrTransferNotFound indicates that a transfer record was not found.
ErrTransferNotFound = storageError("chain.gateway.storage: transfer not found")
// ErrDepositNotFound indicates that a deposit record was not found.
ErrDepositNotFound = storageError("chain.gateway.storage: deposit not found")
)
// Repository represents the root storage contract for the chain gateway module.
type Repository interface {
Ping(ctx context.Context) error
Wallets() WalletsStore
Transfers() TransfersStore
Deposits() DepositsStore
}
// WalletsStore exposes persistence operations for managed wallets.
type WalletsStore interface {
Create(ctx context.Context, wallet *model.ManagedWallet) (*model.ManagedWallet, error)
Get(ctx context.Context, walletRef string) (*model.ManagedWallet, error)
List(ctx context.Context, filter model.ManagedWalletFilter) (*model.ManagedWalletList, error)
SaveBalance(ctx context.Context, balance *model.WalletBalance) error
GetBalance(ctx context.Context, walletRef string) (*model.WalletBalance, error)
}
// TransfersStore exposes persistence operations for transfers.
type TransfersStore interface {
Create(ctx context.Context, transfer *model.Transfer) (*model.Transfer, error)
Get(ctx context.Context, transferRef string) (*model.Transfer, error)
List(ctx context.Context, filter model.TransferFilter) (*model.TransferList, error)
UpdateStatus(ctx context.Context, transferRef string, status model.TransferStatus, failureReason string, txHash string) (*model.Transfer, error)
}
// DepositsStore exposes persistence operations for observed deposits.
type DepositsStore interface {
Record(ctx context.Context, deposit *model.Deposit) error
ListPending(ctx context.Context, network string, limit int32) ([]*model.Deposit, error)
}