@levrbet/shared 0.4.22 → 0.4.23
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/server/utils/index.d.ts +0 -1
- package/dist/server/utils/index.js +0 -1
- package/dist/server/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/server/utils/referral.utils.d.ts +0 -13
- package/dist/server/utils/referral.utils.js +0 -37
- package/dist/server/utils/referral.utils.js.map +0 -1
|
@@ -17,5 +17,4 @@ 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);
|
|
21
20
|
//# 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"}
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|