@moneypot/hub 1.9.0-dev.4 → 1.9.0-dev.9

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.
@@ -132,7 +132,7 @@ export async function getTransferCursor(pgClient, { casinoId, }) {
132
132
  return row?.cursor;
133
133
  }
134
134
  export async function setTransferCursor(pgClient, { cursor, casinoId, }) {
135
- logger.debug(cursor, `[setTransferCursor] Setting cursor`);
135
+ logger.debug({ cursor }, `[setTransferCursor] Setting cursor`);
136
136
  await pgClient.query(`
137
137
  insert into hub_hidden.transfer_cursor (casino_id, cursor)
138
138
  values ($1, $2)
package/dist/src/index.js CHANGED
@@ -22,7 +22,7 @@ async function initialize(options) {
22
22
  });
23
23
  }
24
24
  catch (e) {
25
- logger.error("Error upgrading core schema", e);
25
+ logger.error(e, "Error upgrading core schema");
26
26
  if (e instanceof DatabaseAheadError) {
27
27
  logger.error(`${"⚠️".repeat(10)}\n@moneypot/hub database was reset to prepare for a production release and you must reset your database to continue. Please see <https://www.npmjs.com/package/@moneypot/hub#change-log> for more info.`);
28
28
  process.exit(1);
@@ -1,3 +1,3 @@
1
- import { type Logger } from "pino";
1
+ import pino, { type Logger } from "pino";
2
2
  export { type Logger };
3
- export declare const logger: Logger;
3
+ export declare const logger: pino.Logger;
@@ -1,4 +1,4 @@
1
- import { pino } from "pino";
1
+ import pino from "pino";
2
2
  import { LOG_LEVEL, LOG_PRETTY, NODE_ENV } from "./config.js";
3
3
  function createLogger(options) {
4
4
  const prettify = LOG_PRETTY === undefined ? NODE_ENV !== "production" : LOG_PRETTY;
@@ -75,10 +75,11 @@ export type OutcomeBetConfig = {
75
75
  export type OutcomeBetConfigMap<BetKind extends string> = {
76
76
  [betKind in BetKind]: OutcomeBetConfig;
77
77
  };
78
- export type RiskLimits = {
78
+ type AtLeastOneKey<T, Keys extends keyof T = keyof T> = Keys extends keyof T ? Required<Pick<T, Keys>> & Partial<Omit<T, Keys>> : never;
79
+ export type RiskLimits = AtLeastOneKey<{
79
80
  maxWager?: number;
80
81
  maxPayout?: number;
81
- };
82
+ }>;
82
83
  export type RiskPolicy = (args: {
83
84
  currency: string;
84
85
  wager: number;
@@ -65,9 +65,14 @@ const BetConfigsSchema = z.record(BetKindSchema, z.object({
65
65
  .function()
66
66
  .optional(),
67
67
  }));
68
- const RiskLimitsSchema = z.object({
69
- maxWager: z.number().finite().int().positive().optional(),
70
- maxPayout: z.number().finite().int().positive().optional(),
68
+ const RiskLimitsSchema = z
69
+ .object({
70
+ maxWager: z.number().int().positive().optional(),
71
+ maxPayout: z.number().int().positive().optional(),
72
+ })
73
+ .strict()
74
+ .refine((v) => v.maxWager !== undefined || v.maxPayout !== undefined, {
75
+ message: "Provide at least one of maxWager or maxPayout.",
71
76
  });
72
77
  export function MakeOutcomeBetPlugin({ betConfigs }) {
73
78
  BetConfigsSchema.parse(betConfigs);
@@ -193,7 +198,13 @@ export function MakeOutcomeBetPlugin({ betConfigs }) {
193
198
  const maxProfitMultiplier = Math.max(...input.outcomes.map((o) => o.profit));
194
199
  const maxPayout = input.wager * maxProfitMultiplier;
195
200
  if (maxPayout > dbHouseBankroll.amount) {
196
- throw new GraphQLError(`House cannot cover potential payout (${maxPayout} units). Bankroll: ${dbHouseBankroll.amount} units`);
201
+ throw new GraphQLError(`House cannot cover potential payout (${formatCurrency(maxPayout, {
202
+ displayUnitName: dbCurrency.display_unit_name,
203
+ displayUnitScale: dbCurrency.display_unit_scale,
204
+ })}). Bankroll: ${formatCurrency(dbHouseBankroll.amount, {
205
+ displayUnitName: dbCurrency.display_unit_name,
206
+ displayUnitScale: dbCurrency.display_unit_scale,
207
+ })}`);
197
208
  }
198
209
  const riskLimitsResult = RiskLimitsSchema.safeParse(betConfig.riskPolicy
199
210
  ? betConfig.riskPolicy({
@@ -46,7 +46,7 @@ export function initializeTransferProcessors({ signal, }) {
46
46
  await listenForNewCasinos({ signal });
47
47
  }
48
48
  catch (e) {
49
- logger.error(`Error initializing transfer processors:`, e);
49
+ logger.error(e, `Error initializing transfer processors`);
50
50
  }
51
51
  })();
52
52
  }
@@ -139,7 +139,7 @@ export async function processWithdrawalRequests({ casinoId, graphqlClient, }) {
139
139
  });
140
140
  }
141
141
  catch (error) {
142
- logger.error(`Failed to process withdrawal request ${request.id}:`, error);
142
+ logger.error(error, `Failed to process withdrawal request ${request.id}`);
143
143
  }
144
144
  }
145
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.9.0-dev.4",
3
+ "version": "1.9.0-dev.9",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [