All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
54 lines
2.1 KiB
Go
54 lines
2.1 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/tech/sendico/gateway/chain/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)
|
|
}
|