RevFramework – Sample Scene: 07_Currency_BatchAndTxn¶
Goal¶
Teach grouped currency changes from both sides:
Stage operations with CurrencyTxn → commit through ICurrencyService → optionally observe grouped deltas through ICurrencyBatchEvents.
What This Scene Demonstrates¶
This scene shows two related currency concepts:
- batch events are optional grouped readout
CurrencyTxnis a public fluent helper for staging and committing multiple service operations
The flow is:
Owner A / Owner B → ICurrencyService → local stages → CurrencyTxn.Begin → Commit() → CurOpResult → optional OnWalletBatchChanged
- Owner A is the primary wallet
- Owner B is used for Owner-B operations and transfers
- Stages are local until Commit Txn is pressed
CurrencyTxncommits staged operations through the real service- Batch events are only available when the stack exposes
ICurrencyBatchEvents - Missing batch support does not stop transactions from working
Batch is readout.
Transaction is orchestration.
The service result is truth.
What To Look For¶
Use the CurrencyBatchAndTxnPanel to separate staging, commit, and grouped readout.
-
Setup tab
-
Owner A is required
- Owner B is optional until using Owner-B operations or transfers
- Service shows the resolved
ICurrencyServicestack - BatchEvents shows whether
ICurrencyBatchEventsis available -
Reason / SourceId are passed into the transaction builder
-
Batch tab
-
Subscribe listens for
OnWalletBatchChanged - Last batch displays grouped
CurrencyDeltaentries - No batch appears until a supported stack emits one
-
Missing batch support is not a transaction failure
-
Txn tab
-
Select a currency
- Enter Amount and SetVal values
- Add staged operations locally
- Review the staged list
-
Press Commit Txn to build and commit a
CurrencyTxn -
Staging list
-
+A/-Astage Credit / Debit for Owner A +B/-Bstage Credit / Debit for Owner B- Set A / Set B stage absolute balance writes
- A → B / B → A stage transfers
- Nothing mutates until commit
Sample Scope¶
This scene covers:
- Detecting optional
ICurrencyBatchEvents - Subscribing to batch event readout
- Staging local transaction operations
- Building a transaction with
CurrencyTxn.Begin - Committing staged operations through
Commit() - Reading success/failure through
CurOpResult - Observing grouped deltas when batch events are supported
- Explaining rollback as an attempted recovery path, not magic
This scene does NOT cover:
- Database transactions
- Guaranteed rollback across arbitrary external side effects
- Internal decorator inspection
- Persistent transaction logs
- Backend transaction coordinators
- Multiplayer replication or networking
Those are project-level or backend concerns.
Authority Note¶
This scene may include a permissive sample authority setup so it runs without additional configuration.
Networking Reminder¶
RevFramework does not include networking.
For multiplayer projects, grouped currency operations must be validated and executed through your own authority and networking layer. Batch events are local service readout, not network replication.
How To Use¶
- Enter Play Mode.
- Toggle the
CurrencyBatchAndTxnPanelwithF8. -
In Setup:
-
Confirm Owner A is assigned
- Confirm
ICurrencyServiceis resolved - Confirm whether BatchEvents is present
- Assign Owner B if testing Owner-B stages or transfers
-
In Batch:
-
Press Subscribe if batch events are present
- Leave the tab after subscribing if you want to commit from Txn
-
In Txn:
-
Select a currency
- Enter Amount for Credit / Debit / Transfer stages
- Enter SetVal for Set stages
- Add one or more stages
- Review the staging list
- Press Commit Txn
- Check the result message.
- If subscribed and supported, return to Batch and inspect the grouped delta list.
- Use another panel or live balance display to verify wallet changes if needed.
Failure Behaviour¶
Failures are shown through dependency messages, staging errors, commit results, or missing batch readout.
Common causes:
-
Play Mode required
-
Batch events and transaction commits run against live wallet state
-
Fix: enter Play Mode
-
Service missing
-
No
ICurrencyServicewas resolved -
Fix: add
SceneCurrencyService, addCurrencyServiceBootstrap, or publish a composed service -
Owner A missing
-
Owner A is required for transaction staging
-
Fix: assign Owner A or tag the player GameObject as
Player -
BatchEvents missing
-
The service stack does not expose
ICurrencyBatchEvents - Fix: compose batch event support if you want grouped delta readout
-
Transactions still work without it
-
Owner B missing
-
Owner-B operations and transfers need Owner B
-
Fix: assign Owner B or use Owner-A-only stages
-
No currencies bound
-
No
CurrencyDefinitionassets are available for staging -
Fix: assign currencies in the Inspector or provide a
CurrencySet -
Invalid currency stage
-
A stage references a missing or invalid currency
-
Fix: remove the stage and add it again with a valid CurrencyDefinition
-
Invalid amount
-
Credit, Debit, and Transfer need positive amounts; Set needs zero or greater
-
Fix: remove the bad stage and add it again with a valid amount
-
Commit failed
-
One staged operation was rejected by the live service
-
Fix: check the first failing stage, balances, caps/policy, authority, escrow, idempotency, and service composition
-
Rollback did not behave as expected
-
Rollback is constrained by the same live service rules as forward operations
-
Fix: inspect the result, balances, and stack rules; do not assume rollback can bypass the original failure condition
-
No batch received after commit
-
Batch events may be unsupported, not subscribed, or no successful batch was emitted
- Fix: confirm BatchEvents is present, subscribe, then commit a successful transaction
Behind The Scenes¶
The panel uses real Currency APIs:
-
CurrencyResolve.ServiceFrom -
resolves the active
ICurrencyService -
ICurrencyBatchEvents -
OnWalletBatchChanged -
CurrencyDelta -
owner
- currency
- before
-
after
-
CurrencyTxn -
Begin CreditDebitSetTransfer-
Commit -
ICurrencyService -
all staged operations still execute through the resolved service stack
-
CurOpResult -
Success CodeMessage
The panel does not inspect decorators.
CurrencyTxn is not a database transaction.
It stages public service operations, commits them in order, and reports the result.
Key Takeaway¶
Batch events tell you what changed after a grouped operation.
CurrencyTxn helps stage and commit multiple service calls together.
Neither bypasses the live service stack: policy, authority, escrow, idempotency, and rollback constraints s