MemoryWallet
Defined in: core/wallet.ts:67
An in-memory ledger implementing the full Wallet contract, for development and tests. Not for real money: balances live in process memory only.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MemoryWallet(
options?):MemoryWallet
Defined in: core/wallet.ts:73
Parameters
Section titled “Parameters”options?
Section titled “options?”balances?
Section titled “balances?”Record<string, number>
startingBalance?
Section titled “startingBalance?”number
Returns
Section titled “Returns”MemoryWallet
Methods
Section titled “Methods”balance()
Section titled “balance()”balance(
playerId):Promise<number>
Defined in: core/wallet.ts:139
Available funds, excluding reservations.
Parameters
Section titled “Parameters”playerId
Section titled “playerId”string
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”commit()
Section titled “commit()”commit(
key):Promise<void>
Defined in: core/wallet.ts:114
The reservation becomes a final debit.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”credit()
Section titled “credit()”credit(
playerId,amount,key):Promise<void>
Defined in: core/wallet.ts:143
Payouts. Idempotent by key.
Parameters
Section titled “Parameters”playerId
Section titled “playerId”string
amount
Section titled “amount”number
string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”release()
Section titled “release()”release(
key):Promise<void>
Defined in: core/wallet.ts:123
The reservation is cancelled and the funds returned.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”reservation()
Section titled “reservation()”reservation(
key):WalletReservation|undefined
Defined in: core/wallet.ts:86
The state of a reservation key, for tests.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”WalletReservation | undefined
reserve()
Section titled “reserve()”reserve(
playerId,amount,key):Promise<ReserveResult>
Defined in: core/wallet.ts:95
Parameters
Section titled “Parameters”playerId
Section titled “playerId”string
amount
Section titled “amount”number
string
Returns
Section titled “Returns”Promise<ReserveResult>
Implementation of
Section titled “Implementation of”set(
playerId,amount):void
Defined in: core/wallet.ts:80
Sets a player's available balance.
Parameters
Section titled “Parameters”playerId
Section titled “playerId”string
amount
Section titled “amount”number
Returns
Section titled “Returns”void
