@moneypot/hub 1.18.0-dev.1 → 1.18.0-dev.2

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.
@@ -112,14 +112,15 @@ export function MakeOutcomeBetPlugin({ betConfigs }) {
112
112
  maxWager: Float
113
113
  }
114
114
 
115
- type HubRiskLimitWithCurrency {
115
+ type HubBulkRiskLimit {
116
+ betKind: BetKind!
116
117
  currency: String!
117
118
  maxPayout: Float!
118
119
  maxWager: Float
119
120
  }
120
121
 
121
122
  extend type Query {
122
- hubRiskLimits(betKind: BetKind!): [HubRiskLimitWithCurrency!]!
123
+ hubRiskLimits(betKinds: [BetKind!]!): [HubBulkRiskLimit!]!
123
124
  }
124
125
  `;
125
126
  return {
@@ -127,32 +128,43 @@ export function MakeOutcomeBetPlugin({ betConfigs }) {
127
128
  objects: {
128
129
  Query: {
129
130
  plans: {
130
- hubRiskLimits: (_, { $betKind }) => {
131
+ hubRiskLimits: (_, { $betKinds }) => {
131
132
  const $identity = context().get("identity");
132
133
  const $superuserPool = context().get("superuserPool");
133
- const $result = sideEffect([$identity, $superuserPool, $betKind], async ([identity, superuserPool, betKind]) => {
134
+ const $result = sideEffect([$identity, $superuserPool, $betKinds], async ([identity, superuserPool, inputBetKinds]) => {
134
135
  if (identity?.kind !== "user") {
135
136
  throw new GraphQLError("Unauthorized");
136
137
  }
137
- const betConfig = betConfigs[betKind];
138
- if (!betConfig) {
139
- throw new GraphQLError(`Invalid bet kind`);
138
+ if (inputBetKinds.length > 5) {
139
+ throw new GraphQLError("Maximum 5 bet kinds allowed");
140
+ }
141
+ if (new Set(inputBetKinds).size !== inputBetKinds.length) {
142
+ throw new GraphQLError("Duplicate bet kinds not allowed");
143
+ }
144
+ for (const kind of inputBetKinds) {
145
+ if (!betConfigs[kind]) {
146
+ throw new GraphQLError(`Invalid bet kind: ${kind}`);
147
+ }
140
148
  }
141
149
  const dbHouseBankrolls = await dbGetHouseBankrolls(superuserPool, {
142
150
  casinoId: identity.session.casino_id,
143
151
  });
144
- const limitsWithCurrency = dbHouseBankrolls.map((bankroll) => {
145
- const limits = betConfig.riskPolicy({
146
- type: "get-limits",
147
- currency: bankroll.currency_key,
148
- bankroll: bankroll.amount,
152
+ const limits = inputBetKinds.flatMap((betKind) => {
153
+ const betConfig = betConfigs[betKind];
154
+ return dbHouseBankrolls.map((bankroll) => {
155
+ const riskLimits = betConfig.riskPolicy({
156
+ type: "get-limits",
157
+ currency: bankroll.currency_key,
158
+ bankroll: bankroll.amount,
159
+ });
160
+ return {
161
+ betKind,
162
+ currency: bankroll.currency_key,
163
+ ...riskLimits,
164
+ };
149
165
  });
150
- return {
151
- currency: bankroll.currency_key,
152
- ...limits,
153
- };
154
166
  });
155
- return limitsWithCurrency;
167
+ return limits;
156
168
  });
157
169
  return $result;
158
170
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneypot/hub",
3
- "version": "1.18.0-dev.1",
3
+ "version": "1.18.0-dev.2",
4
4
  "author": "moneypot.com",
5
5
  "homepage": "https://moneypot.com/hub",
6
6
  "keywords": [