@moneypot/hub 1.4.2 → 1.4.3

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.
@@ -1,8 +1,8 @@
1
1
  import * as pg from "pg";
2
2
  import { DbBalance, DbBankroll, DbCurrency, DbSession } from "./types.js";
3
3
  import { PgClientInTransaction } from "./index.js";
4
- export declare function getActiveSessionById(pgClient: pg.PoolClient, sessionId: string): Promise<DbSession | undefined>;
5
- export declare function getCasinoCurrencyByKey(pgClient: pg.PoolClient, { currencyKey, casinoId }: {
4
+ export declare function dbGetActiveSessionById(pgClient: pg.PoolClient, sessionId: string): Promise<DbSession | undefined>;
5
+ export declare function dbGetCasinoCurrencyByKey(pgClient: pg.PoolClient, { currencyKey, casinoId }: {
6
6
  currencyKey: string;
7
7
  casinoId: string;
8
8
  }): Promise<DbCurrency | undefined>;
@@ -17,6 +17,6 @@ export declare function dbLockPlayerBalanceAndHouseBankroll(pgClient: PgClientIn
17
17
  dbHouseBankroll: null;
18
18
  } | {
19
19
  found: true;
20
- dbPlayerBalance: DbBalance["amount"];
21
- dbHouseBankroll: DbBankroll["amount"];
20
+ dbPlayerBalance: Pick<DbBalance, "id" | "amount">;
21
+ dbHouseBankroll: Pick<DbBankroll, "id" | "amount">;
22
22
  }>;
@@ -1,13 +1,13 @@
1
1
  import { maybeOneRow } from "./util.js";
2
2
  import { assert } from "tsafe";
3
- export async function getActiveSessionById(pgClient, sessionId) {
3
+ export async function dbGetActiveSessionById(pgClient, sessionId) {
4
4
  return pgClient
5
5
  .query("select * from hub.active_session where id = $1", [
6
6
  sessionId,
7
7
  ])
8
8
  .then(maybeOneRow);
9
9
  }
10
- export async function getCasinoCurrencyByKey(pgClient, { currencyKey, casinoId }) {
10
+ export async function dbGetCasinoCurrencyByKey(pgClient, { currencyKey, casinoId }) {
11
11
  return pgClient
12
12
  .query({
13
13
  text: `
@@ -24,7 +24,7 @@ export async function dbLockPlayerBalanceAndHouseBankroll(pgClient, { userId, ca
24
24
  const row = await pgClient
25
25
  .query(`
26
26
  WITH locked_balance AS (
27
- SELECT amount
27
+ SELECT id, amount
28
28
  FROM hub.balance
29
29
  WHERE user_id = $1
30
30
  AND casino_id = $2
@@ -34,8 +34,8 @@ export async function dbLockPlayerBalanceAndHouseBankroll(pgClient, { userId, ca
34
34
  FOR UPDATE
35
35
  )
36
36
  SELECT
37
- pb.amount as player_balance,
38
- br.amount as house_bankroll
37
+ json_build_object('id', pb.id, 'amount', pb.amount) as player_balance,
38
+ json_build_object('id', br.id, 'amount', br.amount) as house_bankroll
39
39
  FROM locked_balance pb
40
40
  JOIN hub.bankroll br
41
41
  ON br.casino_id = $2
@@ -167,7 +167,7 @@ export function MakeOutcomeBetPlugin({ betConfigs }) {
167
167
  maxPlayerLoss,
168
168
  dbPlayerBalance,
169
169
  });
170
- if (dbPlayerBalance < maxPlayerLoss) {
170
+ if (dbPlayerBalance.amount < maxPlayerLoss) {
171
171
  if (minProfit === -1) {
172
172
  throw new GraphQLError(`You cannot afford wager`);
173
173
  }
@@ -175,7 +175,7 @@ export function MakeOutcomeBetPlugin({ betConfigs }) {
175
175
  }
176
176
  const maxProfitMultiplier = Math.max(...input.outcomes.map((o) => o.profit));
177
177
  const maxPotentialPayout = input.wager * maxProfitMultiplier;
178
- const maxAllowablePayout = dbHouseBankroll * 0.01;
178
+ const maxAllowablePayout = dbHouseBankroll.amount * 0.01;
179
179
  if (maxPotentialPayout > maxAllowablePayout) {
180
180
  throw new GraphQLError(`House risk limit exceeded. Max payout: ${maxPotentialPayout.toFixed(4)}`);
181
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [