@moneypot/hub 1.20.0-dev.4 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,29 +79,14 @@ You should always keep your hub server up to date as soon as possible. Never ins
79
79
 
80
80
  ### 1.20.x
81
81
 
82
- Introduces a way to represent the part of a bankroll that is reserved by pending multi-stage games.
83
-
84
- Example
85
-
86
- 1. Player starts a mines game with a max potential payout of $100
87
- 2. Operator calls `dbCreateLiability({ refType: "MINES", refId: game.id, maxPayout: 100, ... })`
88
- - Hub adds 100 to `hub.bankroll.liability`
89
- 3. (Some time later...)
90
- 4. Game ends and player wins or loses
91
- 5. Operator calls `dbResolveLiability({ refType: "MINES", refId: game.id })`
92
-
93
- Changes
94
-
95
- - New column `hub.bankroll.liability`
96
- - Available bankroll = `amount - liability`
97
- - New table `hub.liability`
98
- - Triggers an update in `hub.bankroll.liability` when created/modified
99
- - Various type renames including
100
- - `DbBalance` -> `DbPlayerBalance`
101
- - `DbBankroll` -> `DbHouseBankroll`
102
- - More specific return types
103
- - `dbLockedHouseBankroll(): DbHouseBankroll` -> `DbLockedHouseBankrollWithAvailable` (has `grossAmount` and `available` field to help you avoid mistaking amount vs available)
104
- - `dbLockedPlayerBalance(): DbPlayerBalance` -> `DbLockedPlayerBalance`
82
+ Adds liability tracking for multistage games (mines, crash, etc.) that lock up bankroll before resolution.
83
+
84
+ - (DB migration) New `hub.bankroll.liability` column
85
+ - (DB migration) New `hub.liability` table (each row ties to a game row like `app.mines_game`)
86
+ - `dbCreateLiability()` to reserve bankroll when a game starts, `dbResolveLiability()` to release it when it ends
87
+ - Available bankroll = `amount - liability`
88
+ - Type renames: `DbBalance` `DbPlayerBalance`, `DbBankroll` → `DbHouseBankroll`
89
+ - `dbLockedHouseBankroll()` now returns `DbLockedHouseBankrollWithAvailable` (has `available` field)
105
90
 
106
91
  ### 1.19.x
107
92
 
@@ -3,7 +3,7 @@ import { DbUser, DbPlayerBalance, DbHashChain, DbCasino, DbExperience, DbCurrenc
3
3
  import { GraphQLClient } from "graphql-request";
4
4
  import { ServerOptions } from "../index.js";
5
5
  import type { QueryExecutor } from "../db/util.js";
6
- import { LiabilityConfigInternal } from "../liability/public/config.js";
6
+ import { LiabilityConfig } from "../liability/public/config.js";
7
7
  export { type QueryExecutor };
8
8
  export declare function uniqueTestId(): string;
9
9
  export type HubTestServer = {
@@ -65,7 +65,7 @@ export declare function getPlayerBalance(pgClient: QueryExecutor, { userId, expe
65
65
  currencyKey: DbCurrency["key"];
66
66
  }): Promise<DbPlayerBalance | null>;
67
67
  export declare function processOneDeadlinedLiability<RefType extends string>(dbPool: pg.Pool, { liabilityConfig, refType, refId, }: {
68
- liabilityConfig: LiabilityConfigInternal<RefType>;
68
+ liabilityConfig: LiabilityConfig<RefType>;
69
69
  refType: RefType;
70
70
  refId: string;
71
71
  }): Promise<void>;
@@ -176,13 +176,16 @@ export async function getPlayerBalance(pgClient, { userId, experienceId, currenc
176
176
  .then((row) => row ?? null);
177
177
  }
178
178
  export async function processOneDeadlinedLiability(dbPool, { liabilityConfig, refType, refId, }) {
179
+ if (!("_refTypes" in liabilityConfig)) {
180
+ throw new Error("liabilityConfig must be created via createLiabilityConfig()");
181
+ }
179
182
  await withPgPoolTransaction(dbPool, async (pgClient) => {
180
183
  const dbLiability = await dbGetLiabilityByRef(pgClient, { refType, refId });
181
184
  if (!dbLiability) {
182
185
  throw new Error(`Liability not found: refType=${refType}, refId=${refId}`);
183
186
  }
184
187
  return internalProcessOneDeadlinedLiability(pgClient, {
185
- liabilityConfig,
188
+ liabilityConfig: liabilityConfig,
186
189
  liabilityId: dbLiability.id,
187
190
  });
188
191
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.20.0-dev.4",
3
+ "version": "1.20.1",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [