@levrbet/shared 0.4.18 → 0.4.20
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/dist/core/types/notifications/system.alerts.types.d.ts +7 -13
- package/dist/core/types/notifications/system.alerts.types.js +9 -3
- package/dist/core/types/notifications/system.alerts.types.js.map +1 -1
- package/dist/core/types/oracle/requests/user.request.type.d.ts +14 -1
- package/dist/server/utils/game_progress/game.simulation.d.ts +1 -0
- package/dist/server/utils/game_progress/game.simulation.js +166 -0
- package/dist/server/utils/game_progress/game.simulation.js.map +1 -0
- package/dist/server/utils/index.d.ts +1 -0
- package/dist/server/utils/index.js +1 -0
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/referral.utils.d.ts +13 -0
- package/dist/server/utils/referral.utils.js +37 -0
- package/dist/server/utils/referral.utils.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +5 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare
|
|
3
|
-
LOW
|
|
4
|
-
MEDIUM
|
|
5
|
-
HIGH
|
|
6
|
-
CRITICAL
|
|
7
|
-
}
|
|
2
|
+
export declare enum AlertSeverity {
|
|
3
|
+
LOW = "LOW",
|
|
4
|
+
MEDIUM = "MEDIUM",
|
|
5
|
+
HIGH = "HIGH",
|
|
6
|
+
CRITICAL = "CRITICAL"
|
|
7
|
+
}
|
|
8
8
|
export declare const AlertMessageSchema: z.ZodObject<{
|
|
9
9
|
id: z.ZodString;
|
|
10
10
|
type: z.ZodEnum<{
|
|
@@ -16,15 +16,9 @@ export declare const AlertMessageSchema: z.ZodObject<{
|
|
|
16
16
|
title: z.ZodString;
|
|
17
17
|
message: z.ZodString;
|
|
18
18
|
timestamp: z.ZodDate;
|
|
19
|
-
severity: z.ZodEnum<
|
|
20
|
-
LOW: "LOW";
|
|
21
|
-
MEDIUM: "MEDIUM";
|
|
22
|
-
HIGH: "HIGH";
|
|
23
|
-
CRITICAL: "CRITICAL";
|
|
24
|
-
}>;
|
|
19
|
+
severity: z.ZodEnum<typeof AlertSeverity>;
|
|
25
20
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
21
|
acknowledged: z.ZodOptional<z.ZodBoolean>;
|
|
27
22
|
description: z.ZodOptional<z.ZodString>;
|
|
28
23
|
}, z.core.$strip>;
|
|
29
|
-
export type AlertSeverity = z.infer<typeof AlertSeveritySchema>;
|
|
30
24
|
export type AlertMessage = z.infer<typeof AlertMessageSchema>;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlertMessageSchema = exports.
|
|
3
|
+
exports.AlertMessageSchema = exports.AlertSeverity = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
|
|
5
|
+
var AlertSeverity;
|
|
6
|
+
(function (AlertSeverity) {
|
|
7
|
+
AlertSeverity["LOW"] = "LOW";
|
|
8
|
+
AlertSeverity["MEDIUM"] = "MEDIUM";
|
|
9
|
+
AlertSeverity["HIGH"] = "HIGH";
|
|
10
|
+
AlertSeverity["CRITICAL"] = "CRITICAL";
|
|
11
|
+
})(AlertSeverity || (exports.AlertSeverity = AlertSeverity = {}));
|
|
6
12
|
exports.AlertMessageSchema = zod_1.z.object({
|
|
7
13
|
id: zod_1.z.string(),
|
|
8
14
|
type: zod_1.z.enum(["info", "warning", "error", "success"]),
|
|
9
15
|
title: zod_1.z.string(),
|
|
10
16
|
message: zod_1.z.string().max(300),
|
|
11
17
|
timestamp: zod_1.z.date(),
|
|
12
|
-
severity:
|
|
18
|
+
severity: zod_1.z.enum(AlertSeverity),
|
|
13
19
|
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
14
20
|
acknowledged: zod_1.z.boolean().optional(),
|
|
15
21
|
description: zod_1.z.string().max(200).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.alerts.types.js","sourceRoot":"","sources":["../../../../src/core/types/notifications/system.alerts.types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;
|
|
1
|
+
{"version":3,"file":"system.alerts.types.js","sourceRoot":"","sources":["../../../../src/core/types/notifications/system.alerts.types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEvB,IAAY,aAKX;AALD,WAAY,aAAa;IACrB,4BAAW,CAAA;IACX,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACzB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAEY,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;IAC5B,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE;IACnB,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,aAAa,CAAC;IAC/B,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtD,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC9C,CAAC,CAAA"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { User } from "@prisma/client";
|
|
1
|
+
import type { User } from "@prisma/client";
|
|
2
|
+
/**
|
|
3
|
+
* Input for creating/saving a full user profile (settings page, profile modal).
|
|
4
|
+
* All fields except objectId/timestamps are settable.
|
|
5
|
+
*/
|
|
2
6
|
export interface SaveUserProfile extends Omit<User, "objectId" | "createdAt" | "updatedAt" | "email"> {
|
|
3
7
|
imageData?: string;
|
|
4
8
|
email?: string;
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Minimal input for ensuring a user profile exists (idempotent create-or-return).
|
|
12
|
+
* The backend fills in all defaults server-side.
|
|
13
|
+
*/
|
|
14
|
+
export interface EnsureUserProfileInput {
|
|
15
|
+
walletAddress: string;
|
|
16
|
+
referrerCode?: string | null;
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_1 = require("@prisma/client");
|
|
4
|
+
const core_1 = require("../../../core");
|
|
5
|
+
const caclulate_game_progress_1 = require("./caclulate.game.progress");
|
|
6
|
+
const game_utils_1 = require("./game.utils");
|
|
7
|
+
const parser_1 = require("./parser");
|
|
8
|
+
const formatBPS = (bps) => {
|
|
9
|
+
if (bps === null)
|
|
10
|
+
return " null (invalid period/clock)";
|
|
11
|
+
const pct = (bps / 100).toFixed(1);
|
|
12
|
+
return `${String(bps).padStart(5)} BPS (${pct}%)`;
|
|
13
|
+
};
|
|
14
|
+
const runSimulation = () => {
|
|
15
|
+
console.log("\n" + "=".repeat(70));
|
|
16
|
+
console.log(" GAME PROGRESS BPS SIMULATION");
|
|
17
|
+
console.log("=".repeat(70));
|
|
18
|
+
// Direct test of getGameProgressBPS
|
|
19
|
+
console.log("\n🔧 DIRECT getGameProgressBPS TESTS");
|
|
20
|
+
console.log("-".repeat(60));
|
|
21
|
+
// Basketball countdown: Q1 start, 12:00 remaining
|
|
22
|
+
const bball1 = (0, game_utils_1.getGameProgressBPS)(720, 720, 1, 4, client_1.SportGroup.Basketball, false);
|
|
23
|
+
console.log(` Basketball Q1 Start (720s remaining) → ${formatBPS(bball1)} (expected: 0)`);
|
|
24
|
+
// Basketball countdown: Q1, 6:00 remaining
|
|
25
|
+
const bball2 = (0, game_utils_1.getGameProgressBPS)(360, 720, 1, 4, client_1.SportGroup.Basketball, false);
|
|
26
|
+
console.log(` Basketball Q1 6:00 rem (360s remaining) → ${formatBPS(bball2)} (expected: 1250)`);
|
|
27
|
+
// Basketball countdown: Q4 start
|
|
28
|
+
const bball3 = (0, game_utils_1.getGameProgressBPS)(720, 720, 4, 4, client_1.SportGroup.Basketball, false);
|
|
29
|
+
console.log(` Basketball Q4 Start (720s remaining) → ${formatBPS(bball3)} (expected: 7500)`);
|
|
30
|
+
// Soccer count-up cumulative
|
|
31
|
+
const soccer1 = (0, game_utils_1.getGameProgressBPS)(0, 2700, 1, 2, client_1.SportGroup.Soccer, true);
|
|
32
|
+
console.log(` Soccer 0:00 (0s cumulative) → ${formatBPS(soccer1)} (expected: 0)`);
|
|
33
|
+
const soccer2 = (0, game_utils_1.getGameProgressBPS)(2700, 2700, 1, 2, client_1.SportGroup.Soccer, true);
|
|
34
|
+
console.log(` Soccer 45:00 (2700s cumulative) → ${formatBPS(soccer2)} (expected: 5000)`);
|
|
35
|
+
const soccer3 = (0, game_utils_1.getGameProgressBPS)(5400, 2700, 2, 2, client_1.SportGroup.Soccer, true);
|
|
36
|
+
console.log(` Soccer 90:00 (5400s cumulative) → ${formatBPS(soccer3)} (expected: 10000)`);
|
|
37
|
+
// Football countdown
|
|
38
|
+
const fb1 = (0, game_utils_1.getGameProgressBPS)(900, 900, 1, 4, client_1.SportGroup.Football, false);
|
|
39
|
+
console.log(` Football Q1 Start (900s remaining) → ${formatBPS(fb1)} (expected: 0)`);
|
|
40
|
+
const fb2 = (0, game_utils_1.getGameProgressBPS)(0, 900, 1, 4, client_1.SportGroup.Football, false);
|
|
41
|
+
console.log(` Football Q1 End (0s remaining) → ${formatBPS(fb2)} (expected: 2500)`);
|
|
42
|
+
// Baseball
|
|
43
|
+
const bb1 = (0, game_utils_1.getGameProgressBPS)(0, 0, 1, 9, client_1.SportGroup.Baseball, true, true);
|
|
44
|
+
console.log(` Baseball Inn 1 Top → ${formatBPS(bb1)} (expected: 0)`);
|
|
45
|
+
const bb2 = (0, game_utils_1.getGameProgressBPS)(0, 0, 5, 9, client_1.SportGroup.Baseball, true, true);
|
|
46
|
+
console.log(` Baseball Inn 5 Top → ${formatBPS(bb2)} (expected: 4444)`);
|
|
47
|
+
console.log("\n" + "=".repeat(70));
|
|
48
|
+
console.log(" CALCULATE FUNCTIONS (with parser)");
|
|
49
|
+
console.log("=".repeat(70));
|
|
50
|
+
// Test parser
|
|
51
|
+
console.log("\n🔧 PARSER TESTS");
|
|
52
|
+
console.log("-".repeat(60));
|
|
53
|
+
console.log(` parseGameClockToSeconds("0:00") = ${(0, parser_1.parseGameClockToSeconds)("0:00")}`);
|
|
54
|
+
console.log(` parseGameClockToSeconds("12:00") = ${(0, parser_1.parseGameClockToSeconds)("12:00")}`);
|
|
55
|
+
console.log(` parseGameClockToSeconds("45:00") = ${(0, parser_1.parseGameClockToSeconds)("45:00")}`);
|
|
56
|
+
// ===== SOCCER (LSports) - period 10=1st half, 20=2nd half =====
|
|
57
|
+
console.log("\n⚽ SOCCER (LSports) - 2 x 45 min, count-up cumulative clock");
|
|
58
|
+
console.log(" Period 10 = 1st Half, Period 20 = 2nd Half");
|
|
59
|
+
console.log("-".repeat(60));
|
|
60
|
+
const soccerLSportsTests = [
|
|
61
|
+
{ period: 10, clock: "0:00", desc: "1st Half Start" },
|
|
62
|
+
{ period: 10, clock: "22:30", desc: "1st Half 22:30" },
|
|
63
|
+
{ period: 10, clock: "45:00", desc: "1st Half End" },
|
|
64
|
+
{ period: 10, clock: "46:30", desc: "1st Half 46:30 injury time" },
|
|
65
|
+
{ period: 20, clock: "45:00", desc: "2nd Half Start (cumulative)" },
|
|
66
|
+
{ period: 20, clock: "57:20", desc: "2nd Half 57:20" },
|
|
67
|
+
{ period: 20, clock: "67:30", desc: "2nd Half 67:30" },
|
|
68
|
+
{ period: 20, clock: "90:00", desc: "Game End" },
|
|
69
|
+
];
|
|
70
|
+
for (const test of soccerLSportsTests) {
|
|
71
|
+
const bps = (0, caclulate_game_progress_1.calculateSoccerProgress)(test.period, test.clock, core_1.OddsServices.LSPORTS);
|
|
72
|
+
console.log(` ${test.desc.padEnd(35)} P:${test.period} Clock:${test.clock.padEnd(6)} → ${formatBPS(bps)}`);
|
|
73
|
+
}
|
|
74
|
+
// ===== BASKETBALL (LSports) =====
|
|
75
|
+
console.log("\n🏀 BASKETBALL (LSports) - 4 x 12 min, count-DOWN clock");
|
|
76
|
+
console.log("-".repeat(60));
|
|
77
|
+
const basketballLSportsTests = [
|
|
78
|
+
{ period: 1, clock: "12:00", desc: "Q1 Start (12:00 remaining)" },
|
|
79
|
+
{ period: 1, clock: "6:00", desc: "Q1 6:00 remaining" },
|
|
80
|
+
{ period: 1, clock: "0:50", desc: "Q1 End" },
|
|
81
|
+
{ period: 2, clock: "12:00", desc: "Q2 Start" },
|
|
82
|
+
{ period: 2, clock: "0:00", desc: "Halftime" },
|
|
83
|
+
{ period: 3, clock: "12:00", desc: "Q3 Start" },
|
|
84
|
+
{ period: 3, clock: "6:00", desc: "Q3 6:00 remaining" },
|
|
85
|
+
{ period: 4, clock: "12:00", desc: "Q4 Start" },
|
|
86
|
+
{ period: 4, clock: "0:24", desc: "Q4 24 seconds left!" },
|
|
87
|
+
{ period: 4, clock: "0:00", desc: "Game End" },
|
|
88
|
+
];
|
|
89
|
+
for (const test of basketballLSportsTests) {
|
|
90
|
+
const bps = (0, caclulate_game_progress_1.calculateBasketballProgress)(test.period, test.clock, core_1.OddsServices.LSPORTS);
|
|
91
|
+
console.log(` ${test.desc.padEnd(35)} P:${test.period} Clock:${test.clock.padEnd(6)} → ${formatBPS(bps)}`);
|
|
92
|
+
}
|
|
93
|
+
// ===== FOOTBALL (LSports) =====
|
|
94
|
+
console.log("\n🏈 FOOTBALL (LSports) - 4 x 15 min, count-DOWN clock");
|
|
95
|
+
console.log("-".repeat(60));
|
|
96
|
+
const footballTests = [
|
|
97
|
+
{ period: 1, clock: "15:00", desc: "Q1 Start (15:00 remaining)" },
|
|
98
|
+
{ period: 1, clock: "7:30", desc: "Q1 7:30 remaining" },
|
|
99
|
+
{ period: 1, clock: "0:00", desc: "Q1 End" },
|
|
100
|
+
{ period: 2, clock: "15:00", desc: "Q2 Start" },
|
|
101
|
+
{ period: 2, clock: "0:00", desc: "Halftime" },
|
|
102
|
+
{ period: 4, clock: "15:00", desc: "Q4 Start" },
|
|
103
|
+
{ period: 4, clock: "2:00", desc: "Q4 2-minute warning" },
|
|
104
|
+
{ period: 4, clock: "0:00", desc: "Game End" },
|
|
105
|
+
];
|
|
106
|
+
for (const test of footballTests) {
|
|
107
|
+
const bps = (0, caclulate_game_progress_1.calculateFootballProgress)(test.period, test.clock, core_1.OddsServices.LSPORTS);
|
|
108
|
+
console.log(` ${test.desc.padEnd(35)} P:${test.period} Clock:${test.clock.padEnd(6)} → ${formatBPS(bps)}`);
|
|
109
|
+
}
|
|
110
|
+
// ===== BASEBALL (LSports) =====
|
|
111
|
+
console.log("\n⚾ BASEBALL (LSports) - 9 innings, top/bottom");
|
|
112
|
+
console.log("-".repeat(60));
|
|
113
|
+
const baseballTests = [
|
|
114
|
+
{ inning: 1, isTop: true, desc: "Inning 1, Top" },
|
|
115
|
+
{ inning: 1, isTop: false, desc: "Inning 1, Bottom" },
|
|
116
|
+
{ inning: 5, isTop: true, desc: "Inning 5, Top (mid-game)" },
|
|
117
|
+
{ inning: 5, isTop: false, desc: "Inning 5, Bottom" },
|
|
118
|
+
{ inning: 9, isTop: true, desc: "Inning 9, Top" },
|
|
119
|
+
{ inning: 9, isTop: false, desc: "Inning 9, Bottom (last chance)" },
|
|
120
|
+
];
|
|
121
|
+
for (const test of baseballTests) {
|
|
122
|
+
const bps = (0, caclulate_game_progress_1.calculateBaseballProgress)(test.inning, test.isTop);
|
|
123
|
+
const half = test.isTop ? "Top" : "Bot";
|
|
124
|
+
console.log(` ${test.desc.padEnd(35)} Inn:${test.inning} ${half.padEnd(3)} → ${formatBPS(bps)}`);
|
|
125
|
+
}
|
|
126
|
+
// ===== NCAA BASKETBALL (LSports) =====
|
|
127
|
+
console.log("\n🏀 NCAA BASKETBALL (LSports) - 2 x 20 min halves, count-DOWN clock");
|
|
128
|
+
console.log(" Period 10 = 1st Half, Period 20 = 2nd Half");
|
|
129
|
+
console.log("-".repeat(60));
|
|
130
|
+
const ncaabTests = [
|
|
131
|
+
{ period: 10, clock: "20:00", desc: "1st Half Start (20:00 remaining)" },
|
|
132
|
+
{ period: 10, clock: "10:00", desc: "1st Half 10:00 remaining" },
|
|
133
|
+
{ period: 10, clock: "0:00", desc: "1st Half End / Halftime" },
|
|
134
|
+
{ period: 20, clock: "20:00", desc: "2nd Half Start" },
|
|
135
|
+
{ period: 20, clock: "10:00", desc: "2nd Half 10:00 remaining" },
|
|
136
|
+
{ period: 20, clock: "2:00", desc: "2nd Half 2:00 remaining" },
|
|
137
|
+
{ period: 20, clock: "0:00", desc: "Game End" },
|
|
138
|
+
];
|
|
139
|
+
for (const test of ncaabTests) {
|
|
140
|
+
const bps = (0, caclulate_game_progress_1.calculateNCAABProgress)(test.period, test.clock, core_1.OddsServices.LSPORTS);
|
|
141
|
+
console.log(` ${test.desc.padEnd(35)} P:${test.period} Clock:${test.clock.padEnd(6)} → ${formatBPS(bps)}`);
|
|
142
|
+
}
|
|
143
|
+
// ===== NCAA FOOTBALL (LSports) =====
|
|
144
|
+
console.log("\n🏈 NCAA FOOTBALL (LSports) - 2 x 30 min halves, count-UP clock");
|
|
145
|
+
console.log(" Period 10 = 1st Half, Period 20 = 2nd Half");
|
|
146
|
+
console.log("-".repeat(60));
|
|
147
|
+
const ncaafTests = [
|
|
148
|
+
{ period: 10, clock: "0:00", desc: "1st Half Start" },
|
|
149
|
+
{ period: 10, clock: "15:00", desc: "1st Half 15:00 (end Q1)" },
|
|
150
|
+
{ period: 10, clock: "30:00", desc: "1st Half End / Halftime" },
|
|
151
|
+
{ period: 20, clock: "0:00", desc: "2nd Half Start" },
|
|
152
|
+
{ period: 20, clock: "15:00", desc: "2nd Half 15:00 (end Q3)" },
|
|
153
|
+
{ period: 20, clock: "28:00", desc: "2nd Half 28:00 (2-min warning)" },
|
|
154
|
+
{ period: 20, clock: "30:00", desc: "Game End" },
|
|
155
|
+
];
|
|
156
|
+
for (const test of ncaafTests) {
|
|
157
|
+
const bps = (0, caclulate_game_progress_1.calculateNCAAFProgress)(test.period, test.clock, core_1.OddsServices.LSPORTS);
|
|
158
|
+
console.log(` ${test.desc.padEnd(35)} P:${test.period} Clock:${test.clock.padEnd(6)} → ${formatBPS(bps)}`);
|
|
159
|
+
}
|
|
160
|
+
console.log("\n" + "=".repeat(70));
|
|
161
|
+
console.log("✅ SIMULATION COMPLETE");
|
|
162
|
+
console.log("=".repeat(70) + "\n");
|
|
163
|
+
};
|
|
164
|
+
// Run the simulation
|
|
165
|
+
runSimulation();
|
|
166
|
+
//# sourceMappingURL=game.simulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game.simulation.js","sourceRoot":"","sources":["../../../../src/server/utils/game_progress/game.simulation.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAC3C,wCAA4C;AAC5C,uEAOkC;AAClC,6CAAiD;AACjD,qCAAkD;AAElD,MAAM,SAAS,GAAG,CAAC,GAAkB,EAAU,EAAE;IAC7C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,+BAA+B,CAAA;IACxD,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,GAAG,EAA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AAC,CAAA;IACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;AACtC,CAAC,CAAA;AAED,qBAAqB;AACrB,aAAa,EAAE,CAAA"}
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./express.utils"), exports);
|
|
18
18
|
__exportStar(require("./tracing"), exports);
|
|
19
19
|
__exportStar(require("./game_progress"), exports);
|
|
20
|
+
__exportStar(require("./referral.utils"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,4CAAyB;AACzB,kDAA+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,4CAAyB;AACzB,kDAA+B;AAC/B,mDAAgC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a deterministic referral code from a wallet address.
|
|
3
|
+
*
|
|
4
|
+
* The same wallet address + attempt number always produces the same code.
|
|
5
|
+
* Use `attempt` > 0 only to resolve collisions — each attempt derives a
|
|
6
|
+
* different 8-character base-36 code from a different segment of the
|
|
7
|
+
* SHA-256 hash.
|
|
8
|
+
*
|
|
9
|
+
* @param walletAddress - Ethereum wallet address (any casing)
|
|
10
|
+
* @param attempt - Collision-resolution attempt (0 = first try)
|
|
11
|
+
* @returns 8-character uppercase alphanumeric referral code
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateReferralCode(walletAddress: string, attempt?: number): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateReferralCode = generateReferralCode;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
+
const BASE36_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
9
|
+
const CODE_LENGTH = 8;
|
|
10
|
+
/**
|
|
11
|
+
* Generates a deterministic referral code from a wallet address.
|
|
12
|
+
*
|
|
13
|
+
* The same wallet address + attempt number always produces the same code.
|
|
14
|
+
* Use `attempt` > 0 only to resolve collisions — each attempt derives a
|
|
15
|
+
* different 8-character base-36 code from a different segment of the
|
|
16
|
+
* SHA-256 hash.
|
|
17
|
+
*
|
|
18
|
+
* @param walletAddress - Ethereum wallet address (any casing)
|
|
19
|
+
* @param attempt - Collision-resolution attempt (0 = first try)
|
|
20
|
+
* @returns 8-character uppercase alphanumeric referral code
|
|
21
|
+
*/
|
|
22
|
+
function generateReferralCode(walletAddress, attempt = 0) {
|
|
23
|
+
const hash = node_crypto_1.default
|
|
24
|
+
.createHash("sha256")
|
|
25
|
+
.update(walletAddress.toLowerCase())
|
|
26
|
+
.digest("hex");
|
|
27
|
+
const hashOffset = attempt * 8;
|
|
28
|
+
const hashSegment = hash.slice(hashOffset, hashOffset + 16) || hash.slice(0, 16);
|
|
29
|
+
let num = BigInt(`0x${hashSegment}`);
|
|
30
|
+
let code = "";
|
|
31
|
+
for (let i = 0; i < CODE_LENGTH; i++) {
|
|
32
|
+
code = BASE36_CHARS[Number(num % BigInt(36))] + code;
|
|
33
|
+
num = num / BigInt(36);
|
|
34
|
+
}
|
|
35
|
+
return code;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=referral.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referral.utils.js","sourceRoot":"","sources":["../../../src/server/utils/referral.utils.ts"],"names":[],"mappings":";;;;;AAiBA,oDAsBC;AAvCD,8DAAiC;AAEjC,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAC5D,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CACnC,aAAqB,EACrB,OAAO,GAAG,CAAC;IAEX,MAAM,IAAI,GAAG,qBAAM;SACjB,UAAU,CAAC,QAAQ,CAAC;SACpB,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;SACnC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEhB,MAAM,UAAU,GAAG,OAAO,GAAG,CAAC,CAAC;IAC/B,MAAM,WAAW,GAChB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9D,IAAI,GAAG,GAAG,MAAM,CAAC,KAAK,WAAW,EAAE,CAAC,CAAC;IACrC,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACrD,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
|
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -307,13 +307,13 @@ enum UserOddsPreference {
|
|
|
307
307
|
model User {
|
|
308
308
|
objectId String @id @default(auto()) @map("_id") @db.ObjectId
|
|
309
309
|
walletAddress String @unique
|
|
310
|
-
userName String
|
|
311
|
-
email String
|
|
312
|
-
referralCode String
|
|
310
|
+
userName String? @unique
|
|
311
|
+
email String?
|
|
312
|
+
referralCode String? @unique
|
|
313
313
|
referrerCode String?
|
|
314
|
-
timeZone String
|
|
314
|
+
timeZone String @default("UTC")
|
|
315
315
|
preferredTimeZone String?
|
|
316
|
-
userOddsPreference UserOddsPreference
|
|
316
|
+
userOddsPreference UserOddsPreference @default(American)
|
|
317
317
|
profileImageUrl String?
|
|
318
318
|
profileImageKey String?
|
|
319
319
|
language String @default("en")
|