service

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLimit     = 200
	DefaultLimit = 50
)

Variables

This section is empty.

Functions

func RegisterPrivateRoutes

func RegisterPrivateRoutes(r chi.Router, svc Service, logger *zap.Logger)

RegisterPrivateRoutes registers the indexer admin API on the given chi router. All routes are mounted under /indexer/v1/admin.

These routes are unauthenticated and intended for internal/trusted callers only (e.g. backend services, ops tooling). A public, JWT-protected read API will be added in a future iteration — at that point these routes will remain separate. Callers are responsible for restricting network access to this port.

Types

type HTTP

type HTTP struct {
	// contains filtered or unexported fields
}

HTTP wraps the Service to provide HTTP endpoints.

type Service

type Service interface {
	// Token queries
	GetToken(ctx context.Context, admin, id string) (*indexer.Token, error)
	ListTokens(ctx context.Context, p indexer.Pagination) (*indexer.Page[*indexer.Token], error)

	// ERC-20 analogs
	TotalSupply(ctx context.Context, admin, id string) (string, error) // totalSupply()

	// Rich balance queries (beyond ERC-20)
	GetBalance(ctx context.Context, partyID, admin, id string) (*indexer.Balance, error)
	ListBalancesForParty(ctx context.Context, partyID string, p indexer.Pagination) (*indexer.Page[*indexer.Balance], error)
	ListBalancesForToken(ctx context.Context, admin, id string, p indexer.Pagination) (*indexer.Page[*indexer.Balance], error)

	// Audit trail (immutable, ordered by ledger_offset ASC)
	GetEvent(ctx context.Context, contractID string) (*indexer.ParsedEvent, error)
	ListTokenEvents(
		ctx context.Context,
		admin, id string,
		f indexer.EventFilter,
		p indexer.Pagination,
	) (*indexer.Page[*indexer.ParsedEvent], error)
	ListPartyEvents(
		ctx context.Context,
		partyID string,
		f indexer.EventFilter,
		p indexer.Pagination,
	) (*indexer.Page[*indexer.ParsedEvent], error)

	// GetPendingOffersForParty returns paginated PENDING TransferOffers for a custodial party.
	GetPendingOffersForParty(ctx context.Context, partyID string, p indexer.Pagination) (*indexer.Page[indexer.PendingOffer], error)
	// GetAllPendingOffers returns all PENDING TransferOffers across all parties, paginated.
	GetAllPendingOffers(ctx context.Context, p indexer.Pagination) (*indexer.Page[indexer.PendingOffer], error)
}

func NewLog

func NewLog(svc Service, logger *zap.Logger) Service

NewLog creates a logging decorator for the indexer Service.

func NewService

func NewService(store Store, logger *zap.Logger) Service

NewService creates a new indexer Service backed by store.

type Store

type Store interface {
	GetToken(ctx context.Context, admin, id string) (*indexer.Token, error)
	ListTokens(ctx context.Context, p indexer.Pagination) ([]*indexer.Token, int64, error)
	GetBalance(ctx context.Context, partyID, admin, id string) (*indexer.Balance, error)
	ListBalancesForParty(ctx context.Context, partyID string, p indexer.Pagination) ([]*indexer.Balance, int64, error)
	ListBalancesForToken(ctx context.Context, admin, id string, p indexer.Pagination) ([]*indexer.Balance, int64, error)
	// ListEvents returns events in ascending ledger_offset order (immutable audit trail).
	// Zero-value EventFilter fields are ignored (no filter applied).
	ListEvents(ctx context.Context, f indexer.EventFilter, p indexer.Pagination) ([]*indexer.ParsedEvent, int64, error)
	// GetEvent looks up a single event by its unique contract ID.
	GetEvent(ctx context.Context, contractID string) (*indexer.ParsedEvent, error)
	// ListPendingOffersForParty returns PENDING TransferOffers for the given receiver party.
	ListPendingOffersForParty(ctx context.Context, partyID string, p indexer.Pagination) ([]indexer.PendingOffer, int64, error)
	// ListAllPendingOffers returns all PENDING TransferOffers across all parties.
	ListAllPendingOffers(ctx context.Context, p indexer.Pagination) ([]indexer.PendingOffer, int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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