Skip to content

💰 Currency / Decorators

🎯 Purpose

The Decorators concept in Currency refers to internal wrapper services that extend ICurrencyService behaviour.

These implementations are not part of the public extension surface and are composed through CurrencyFactories.

Decorators enable cross-cutting behaviour while keeping the public API surface small.


⚠️ Important Notes

  • Decorators are implementation details
  • They should not be referenced directly
  • Behaviour depends on composition order
  • Implementations may change without notice

🧩 What Lives Here

Decorators are distributed across internal folders based on responsibility.

Internal decorators

  • AuditedCurrencyService
  • IdempotencyCurrencyService
  • BatchEventCurrencyService
  • CappedCurrencyService
  • EscrowCurrencyService
  • RequireEscrowCurrencyService

Authority decorator

  • AuthorityCurrencyService

These wrappers:

  • Implement ICurrencyService
  • Wrap another service
  • Add behaviour without changing the public contract
  • Do not own wallet storage

🧠 Usage Guidance

How decorators are applied

Decorators are applied through CurrencyFactories.

svc = CurrencyFactories.WithCapsAuditAuthorityIdemBatch(svc, policy, this);

Factories:

  • Control ordering
  • Hide implementation details
  • Prevent incorrect composition

Behavioural overview

Each decorator provides a specific responsibility:

  • Audit — records mutations
  • Caps — enforces limits
  • Authority — gates mutations
  • Escrow — adds hold semantics
  • RequireEscrow — enforces escrow presence
  • Idempotency — drops duplicate requests
  • Batch Events — aggregates notifications

All decorators are optional and composition-dependent.


Ordering

A typical composition order is:

  1. Caps
  2. Audit
  3. Authority
  4. Escrow / RequireEscrow
  5. Idempotency
  6. Batch Events

Changing order changes behaviour and should be done intentionally.


🚫 Internal Use Only

Decorators are not a supported extension surface.

Do not:

  • Instantiate decorator types directly
  • Depend on specific decorator implementations
  • Assume implementation stability

🧹 Safe to Remove

This folder should not be removed.

Decorators are required for composed Currency behaviour.


  • Core — factories and composition helpers
  • Authority — authority resolution and gating
  • Internal — shared implementation seams
  • Bootstrap — service composition