/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { Amount } from '../money.js'; import type { AccountRef } from '../accounts.js'; import type { Clock, Digest, Leg, Ledger, Store } from '../ports.js'; interface Journal { begin(): void; commit(): void; rollback(): void; recording(): boolean; record(undo: () => void): void; mark(): number; rollbackTo(mark: number): void; } interface Participant { journal: Journal; } /** * In-memory ledger plus test-only back doors (the `__` prefix). `__tamper` edits a stored * posting's legs without recomputing the chain head — the corruption the chain check must detect. */ export type MemoryLedger = Ledger & Participant & { __tamper(txnId: string, mutate: (legs: Leg[]) => void): void; __seedBalance(account: AccountRef, amount: Amount): void; }; /** * Build an in-memory {@link Store} with working transaction rollback, for tests and * development. If the work inside a `transaction` throws, every store that joined the * transaction is rolled back, each independently so one store's failing rollback can't stop the * others. The checkpoint store is written outside transactions and isn't rolled back. The hash * function and clock default to deterministic versions, so a plain `memoryStore()` is * reproducible. * * Overlapping `transaction` calls queue and run one at a time in arrival order, so the memory * store never interleaves writers. `velocityWindowMs` sets the trust store's velocity window and * defaults to one hour, matching the SQL stores. * * @see {@link https://economy-lab-docs.pages.dev/economy/ports/storage/ Storage} for the store ports this adapter implements. */ export declare function memoryStore(deps?: { digest?: Digest; clock?: Clock; velocityWindowMs?: number; }): Store; export {};