Skip to content

💰 Currency – Internal / Core

Namespace: RevGaming.RevFramework.Currency.Internal

⚠️ Internal plumbing. Do not reference directly.

This folder contains core internal helpers used by Currency’s decorators and higher-level helpers (e.g. transactions, persistence, batching).

These types are not part of the public API and are not supported extension points. They exist solely to keep the public surface small while enabling advanced behaviour internally.

If you think you need something from this folder, you almost certainly want a public helper instead.


Purpose

  • Provide shared internal utilities for decorators and core helpers.
  • Centralise logic that would otherwise leak into public APIs.
  • Support advanced flows (batching, policy application, idempotency plumbing) without exposing implementation details.
  • Keep public contracts (ICurrencyService, helpers, factories) clean and stable.

This folder answers “how Currency works internally”, not “how you should use Currency.”


What lives here

Typical responsibilities in this folder include:

  • Batch capture helpers used by transactions and persistence restores
  • Policy application utilities shared by caps / previews / transfers
  • Request-id helpers for idempotency plumbing
  • Small internal data helpers that would be noise if made public

All of these are deliberately hidden behind: - CurrencyFactories - CurrencyTxn - CurrencyPurchase - CurrencyBatching - CurrencyServiceExtensions


Key internal helpers

CurrencyBatch

Internal batch capture utility.

  • Subscribes to ICurrencyService.OnWalletChanged
  • Captures per-op CurrencyDelta values
  • Emits one aggregated batch event (when supported and explicitly emitted)
  • Used by:
  • CurrencyTxn
  • Persistence restore helpers
  • Editor batching wrappers

You should never construct or interact with this directly.

Use instead: - CurrencyTxn (runtime) - CurrencyBatching.BeginBatch(...) (public wrapper) - CurrencyEditorApi.BeginBatch(...) (editor tooling)


CurrencyPolicyUtil

Shared helper for applying cap rules to tentative balances.

  • Centralises min/max + clamp/fail behaviour
  • Used by:
  • Cap decorators
  • Preview helpers (TryComputeEffective*)
  • Transaction previews

This avoids duplicating policy logic across multiple layers.


CurrencyRequestId

Low-level helper for generating idempotency tokens.

  • Returns a compact GUID string
  • Used internally by tooling and helpers

Public code should treat request IDs as opaque strings passed via sourceId.


Design rules (non-negotiable)

  • All types here are internal.
  • They may change or move between versions.
  • They are not supported extension points.
  • Internal utilities are required to uphold public contract guarantees (e.g. audit ordering, batch semantics).

If you reference something here:

You are coupling to implementation details.

Before doing that, check the public alternatives:

  • CoreCurrencyTxn, CurrencyPurchase, CurrencyAwaiters
  • PublicAPICurrencyBatching, transfer policy providers
  • EditorApi — editor-safe batching helpers

  • Internal — shared internal seams (audit-aware, batch emitter)
  • Core — public helpers built on top of this plumbing
  • Policies — authoring assets that feed into policy utilities
  • Persistence — restore helpers that rely on internal batching