account

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Resource not found errors
	ErrAccountNotFound = errors.New("account not found")

	// Conflict errors
	ErrPublicKeyAlreadyExists = errors.New("public key already registered")
	ErrAccountAlreadyDeleted  = errors.New("account is already deleted")

	// Business logic errors
	ErrCannotModifyDeletedAccount = errors.New("cannot modify deleted account")
	ErrInvalidStatusTransition    = errors.New("invalid status transition")
	ErrCannotDeleteLastAccount    = errors.New("cannot delete the last active account")

	// Validation errors
	ErrInvalidInput        = errors.New("invalid input")
	ErrInvalidPublicKey    = errors.New("invalid public key format")
	ErrInvalidStatus       = errors.New("invalid account status")
	ErrInvalidAccountIndex = errors.New("invalid account index")
)

Account service specific errors

Functions

This section is empty.

Types

type AccountResponse

type AccountResponse struct {
	ID           string    `json:"id"`
	UserID       string    `json:"user_id"`
	PublicKey    string    `json:"public_key"`
	AccountIndex int       `json:"account_index"`
	Status       string    `json:"status"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

AccountResponse represents the response containing account information

type CreateAccountRequest

type CreateAccountRequest struct {
	UserID       string `json:"user_id" validate:"required"`
	PublicKey    string `json:"public_key" validate:"required"`
	AccountIndex *int   `json:"account_index,omitempty"` // Optional: if provided, use this index instead of auto-generating
}

CreateAccountRequest represents the request to create a new Stellar account

type Service

type Service interface {
	// Account management
	Create(ctx context.Context, req CreateAccountRequest) (*AccountResponse, error)
	CreateWithTx(ctx context.Context, tx *gorm.DB, req CreateAccountRequest) (*AccountResponse, error)
	GetByID(ctx context.Context, id string) (*AccountResponse, error)
	GetByPublicKey(ctx context.Context, publicKey string) (*AccountResponse, error)
	GetByUserID(ctx context.Context, userID string) (*AccountResponse, error)
	GetNextAccountIndex(ctx context.Context, userID string) (int, error)
	GetNextAccountIndexWithTx(ctx context.Context, tx *gorm.DB) (int, error)
	Delete(ctx context.Context, id string) error
	Restore(ctx context.Context, id string) error

	// Status management
	UpdateStatus(ctx context.Context, id string, req UpdateAccountStatusRequest) (*AccountResponse, error)
}

Service defines the interface for account business logic operations

func NewService

NewService creates a new account service instance

type UpdateAccountStatusRequest

type UpdateAccountStatusRequest struct {
	Status string `json:"status" validate:"required,oneof=active suspended frozen closed"`
}

UpdateAccountStatusRequest represents the request to update account status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL