@suigar/sdk 2.0.0-beta.13 → 2.0.0-beta.15
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/CHANGELOG.md +23 -4
- package/README.md +22 -8
- package/dist/client.d.mts +258 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +291 -0
- package/dist/client.mjs.map +1 -0
- package/dist/configs/package.mainnet.mjs +23 -0
- package/dist/configs/package.mainnet.mjs.map +1 -0
- package/dist/configs/package.mjs +19 -0
- package/dist/configs/package.mjs.map +1 -0
- package/dist/configs/package.testnet.mjs +23 -0
- package/dist/configs/package.testnet.mjs.map +1 -0
- package/dist/configs/registry.mainnet.mjs +6 -0
- package/dist/configs/registry.mainnet.mjs.map +1 -0
- package/dist/configs/registry.mjs +11 -0
- package/dist/configs/registry.mjs.map +1 -0
- package/dist/configs/registry.testnet.mjs +6 -0
- package/dist/configs/registry.testnet.mjs.map +1 -0
- package/dist/contracts/coinflip/coinflip.mjs +46 -0
- package/dist/contracts/coinflip/coinflip.mjs.map +1 -0
- package/dist/contracts/core/core.d.mts +55 -0
- package/dist/contracts/core/core.d.mts.map +1 -0
- package/dist/contracts/core/core.mjs +22 -0
- package/dist/contracts/core/core.mjs.map +1 -0
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
- package/dist/contracts/core/float.d.mts +14 -0
- package/dist/contracts/core/float.d.mts.map +1 -0
- package/dist/contracts/core/float.mjs +15 -0
- package/dist/contracts/core/float.mjs.map +1 -0
- package/dist/contracts/core/i64.mjs +10 -0
- package/dist/contracts/core/i64.mjs.map +1 -0
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
- package/dist/contracts/limbo/limbo.mjs +53 -0
- package/dist/contracts/limbo/limbo.mjs.map +1 -0
- package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
- package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
- package/dist/contracts/plinko/plinko.mjs +59 -0
- package/dist/contracts/plinko/plinko.mjs.map +1 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +10 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
- package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts +34 -0
- package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts.map +1 -0
- package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs +131 -0
- package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs.map +1 -0
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
- package/dist/contracts/range/range.mjs +53 -0
- package/dist/contracts/range/range.mjs.map +1 -0
- package/dist/contracts/utils/index.d.mts +33 -0
- package/dist/contracts/utils/index.d.mts.map +1 -0
- package/dist/contracts/utils/index.mjs +119 -0
- package/dist/contracts/utils/index.mjs.map +1 -0
- package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
- package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
- package/dist/contracts/wheel/wheel.mjs +59 -0
- package/dist/contracts/wheel/wheel.mjs.map +1 -0
- package/dist/games.d.mts +3 -0
- package/dist/games.mjs +1 -0
- package/dist/helpers/config.mjs +51 -0
- package/dist/helpers/config.mjs.map +1 -0
- package/dist/helpers/game-settings.mjs +19 -0
- package/dist/helpers/game-settings.mjs.map +1 -0
- package/dist/helpers/metadata.mjs +42 -0
- package/dist/helpers/metadata.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/transactions/coinflip.mjs +27 -0
- package/dist/transactions/coinflip.mjs.map +1 -0
- package/dist/transactions/limbo.mjs +31 -0
- package/dist/transactions/limbo.mjs.map +1 -0
- package/dist/transactions/plinko.mjs +29 -0
- package/dist/transactions/plinko.mjs.map +1 -0
- package/dist/transactions/pvp-coinflip.mjs +70 -0
- package/dist/transactions/pvp-coinflip.mjs.map +1 -0
- package/dist/transactions/range.mjs +33 -0
- package/dist/transactions/range.mjs.map +1 -0
- package/dist/transactions/shared.mjs +49 -0
- package/dist/transactions/shared.mjs.map +1 -0
- package/dist/transactions/wheel.mjs +29 -0
- package/dist/transactions/wheel.mjs.map +1 -0
- package/dist/ttl-cache.mjs +60 -0
- package/dist/ttl-cache.mjs.map +1 -0
- package/dist/types/bet-metadata.type.d.mts +7 -0
- package/dist/types/bet-metadata.type.d.mts.map +1 -0
- package/dist/types/build-game-transaction-options.type.d.mts +9 -0
- package/dist/types/build-game-transaction-options.type.d.mts.map +1 -0
- package/dist/types/game-details.type.d.mts +73 -0
- package/dist/types/game-details.type.d.mts.map +1 -0
- package/dist/types/game-details.type.mjs +59 -0
- package/dist/types/game-details.type.mjs.map +1 -0
- package/dist/types/game-settings.type.d.mts +201 -0
- package/dist/types/game-settings.type.d.mts.map +1 -0
- package/dist/types/game-settings.type.mjs +37 -0
- package/dist/types/game-settings.type.mjs.map +1 -0
- package/dist/types/game.type.d.mts +15 -0
- package/dist/types/game.type.d.mts.map +1 -0
- package/dist/types/game.type.mjs +19 -0
- package/dist/types/game.type.mjs.map +1 -0
- package/dist/types/index.d.mts +7 -0
- package/dist/types/move-float.type.d.mts +7 -0
- package/dist/types/move-float.type.d.mts.map +1 -0
- package/dist/types/network.type.d.mts +1 -0
- package/dist/types/network.type.mjs +6 -0
- package/dist/types/network.type.mjs.map +1 -0
- package/dist/types/suigar-config.type.d.mts +33 -0
- package/dist/types/suigar-config.type.d.mts.map +1 -0
- package/dist/types/transaction-options.type.d.mts +63 -0
- package/dist/types/transaction-options.type.d.mts.map +1 -0
- package/dist/utils/constants.d.mts +8 -0
- package/dist/utils/constants.d.mts.map +1 -0
- package/dist/utils/constants.mjs +10 -0
- package/dist/utils/constants.mjs.map +1 -0
- package/dist/utils/numeric.d.mts +86 -0
- package/dist/utils/numeric.d.mts.map +1 -0
- package/dist/utils/numeric.mjs +148 -0
- package/dist/utils/numeric.mjs.map +1 -0
- package/dist/utils/parser.d.mts +54 -0
- package/dist/utils/parser.d.mts.map +1 -0
- package/dist/utils/parser.mjs +94 -0
- package/dist/utils/parser.mjs.map +1 -0
- package/dist/utils.d.mts +4 -0
- package/dist/utils.mjs +4 -0
- package/package.json +16 -17
- package/dist/chunk-7N55D2TV.js +0 -343
- package/dist/games-BHYRg31e.d.cts +0 -98
- package/dist/games-BHYRg31e.d.ts +0 -98
- package/dist/games.cjs +0 -2
- package/dist/games.d.cts +0 -2
- package/dist/games.d.ts +0 -2
- package/dist/games.js +0 -1
- package/dist/index-3P_LBbDM.d.cts +0 -25
- package/dist/index-3P_LBbDM.d.ts +0 -25
- package/dist/index.cjs +0 -1692
- package/dist/index.d.cts +0 -457
- package/dist/index.d.ts +0 -457
- package/dist/index.js +0 -1470
- package/dist/utils.cjs +0 -243
- package/dist/utils.d.cts +0 -180
- package/dist/utils.d.ts +0 -180
- package/dist/utils.js +0 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
//#region src/utils/numeric.ts
|
|
2
|
+
/**
|
|
3
|
+
* Converts a generated Move `i64` wrapper into a JavaScript number.
|
|
4
|
+
*
|
|
5
|
+
* The generated bindings expose signed 64-bit integers through a `{ bits }`
|
|
6
|
+
* field that stores the raw two's-complement bit pattern. This helper
|
|
7
|
+
* reinterprets those bits as a signed `i64` and returns a plain JS number.
|
|
8
|
+
* Invalid or missing input falls back to `0`.
|
|
9
|
+
*
|
|
10
|
+
* @param i64 Generated Move `i64` value, typically used for float exponents.
|
|
11
|
+
* @returns The signed 64-bit value as a JavaScript number.
|
|
12
|
+
*/
|
|
13
|
+
function fromMoveI64(i64) {
|
|
14
|
+
try {
|
|
15
|
+
return Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));
|
|
16
|
+
} catch {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts a generated Move `Float` struct into a JavaScript number.
|
|
22
|
+
*
|
|
23
|
+
* Suigar float values are represented as a sign flag, an unsigned mantissa,
|
|
24
|
+
* and a Move `i64` exponent. This helper rebuilds the numeric value using the
|
|
25
|
+
* same normalization expected by the on-chain format and applies the sign at
|
|
26
|
+
* the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.
|
|
27
|
+
*
|
|
28
|
+
* @param float Generated Move float value with `mant`, `exp`, and `is_negative`.
|
|
29
|
+
* @returns The decoded floating-point value as a JavaScript number.
|
|
30
|
+
*/
|
|
31
|
+
function fromMoveFloat(float) {
|
|
32
|
+
const mantissa = BigInt(float.mant ?? 0);
|
|
33
|
+
if (mantissa === 0n) return 0;
|
|
34
|
+
const exponent = fromMoveI64(float.exp) - 52;
|
|
35
|
+
const magnitude = Number(mantissa) * 2 ** exponent;
|
|
36
|
+
return float.is_negative ? -magnitude : magnitude;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Ensures a value is a finite JavaScript number.
|
|
40
|
+
*
|
|
41
|
+
* This is only used for helpers that accept raw `number` input before applying
|
|
42
|
+
* additional integer or range validation.
|
|
43
|
+
*/
|
|
44
|
+
function assertFiniteNumber(value, errorMessage) {
|
|
45
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new TypeError(`${errorMessage}: ${String(value)}`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Normalizes a value into a non-negative `bigint`.
|
|
49
|
+
*
|
|
50
|
+
* Accepted inputs:
|
|
51
|
+
* - `bigint`
|
|
52
|
+
* - finite `number`
|
|
53
|
+
* - base-10 integer `string`
|
|
54
|
+
* - `boolean`
|
|
55
|
+
*
|
|
56
|
+
* Number inputs are truncated toward zero before conversion, so `5.9` becomes
|
|
57
|
+
* `5n`. String and boolean inputs are parsed through the native
|
|
58
|
+
* `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,
|
|
59
|
+
* and only integer strings are accepted.
|
|
60
|
+
*
|
|
61
|
+
* @param value Value to normalize.
|
|
62
|
+
* @returns A non-negative `bigint`.
|
|
63
|
+
* @throws When `value` is not a bigint, finite number, integer string, or
|
|
64
|
+
* boolean.
|
|
65
|
+
* @throws When the normalized value is negative.
|
|
66
|
+
*/
|
|
67
|
+
function toBigInt(value) {
|
|
68
|
+
let result;
|
|
69
|
+
try {
|
|
70
|
+
if (typeof value === "bigint" || typeof value === "string" || typeof value === "boolean") result = BigInt(value);
|
|
71
|
+
else {
|
|
72
|
+
assertFiniteNumber(value, "Value must be a bigint, number, integer string, or boolean");
|
|
73
|
+
result = BigInt(Math.trunc(value));
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
throw new TypeError(`Value must be a bigint, number, integer string, or boolean: ${value}`);
|
|
77
|
+
}
|
|
78
|
+
if (result < 0n) throw new RangeError(`Value must be non-negative: ${value}`);
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Validates and normalizes a bounded unsigned integer.
|
|
83
|
+
*
|
|
84
|
+
* Accepted inputs:
|
|
85
|
+
* - finite `number`
|
|
86
|
+
* - base-10 integer `string`
|
|
87
|
+
*
|
|
88
|
+
* This internal helper powers the public `toU8()` and `toU16()` helpers. It
|
|
89
|
+
* accepts stringified integers such as `'1'` for parsed values, but rejects
|
|
90
|
+
* booleans, empty strings, fractional values, and out-of-range numbers.
|
|
91
|
+
*
|
|
92
|
+
* @param value Value to validate.
|
|
93
|
+
* @param max Inclusive upper bound.
|
|
94
|
+
* @param typeName Move integer label used in error messages.
|
|
95
|
+
* @returns The validated integer as a JavaScript `number`.
|
|
96
|
+
* @throws When `value` is not a finite number or integer string.
|
|
97
|
+
* @throws When `value` is not an integer between `0` and `max`.
|
|
98
|
+
*/
|
|
99
|
+
function toBoundedInt(value, max, typeName) {
|
|
100
|
+
const num = typeof value === "string" && value.trim() === "" ? NaN : Number(value);
|
|
101
|
+
assertFiniteNumber(num, "Value must be a finite number or integer string");
|
|
102
|
+
if (typeof value === "boolean" || value == null || !Number.isInteger(num) || num < 0 || num > max) throw new RangeError(`Value must be a ${typeName} integer (0-${max}): ${value}`);
|
|
103
|
+
return num;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Validates that a value can be safely used as a Move `u8` in the `0..255`
|
|
107
|
+
* range.
|
|
108
|
+
*
|
|
109
|
+
* Accepted inputs:
|
|
110
|
+
* - finite `number`
|
|
111
|
+
* - base-10 integer `string`
|
|
112
|
+
*
|
|
113
|
+
* String inputs are accepted for parsed values such as `'1'`, but only when
|
|
114
|
+
* they are plain non-negative integer strings. This helper does not accept
|
|
115
|
+
* booleans and does not truncate fractional values.
|
|
116
|
+
*
|
|
117
|
+
* @param value Value to validate.
|
|
118
|
+
* @returns The validated `u8` value as a JavaScript `number`.
|
|
119
|
+
* @throws When `value` is not a finite number or integer string.
|
|
120
|
+
* @throws When `value` is not an integer between `0` and `255`.
|
|
121
|
+
*/
|
|
122
|
+
function toU8(value) {
|
|
123
|
+
return toBoundedInt(value, 255, "u8");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Validates that a value can be safely used as a Move `u16` in the
|
|
127
|
+
* `0..65535` range.
|
|
128
|
+
*
|
|
129
|
+
* Accepted inputs:
|
|
130
|
+
* - finite `number`
|
|
131
|
+
* - base-10 integer `string`
|
|
132
|
+
*
|
|
133
|
+
* String inputs are accepted for parsed values such as `'1'`, but only when
|
|
134
|
+
* they are plain non-negative integer strings. This helper does not accept
|
|
135
|
+
* booleans and does not truncate fractional values.
|
|
136
|
+
*
|
|
137
|
+
* @param value Value to validate.
|
|
138
|
+
* @returns The validated `u16` value as a JavaScript `number`.
|
|
139
|
+
* @throws When `value` is not a finite number or integer string.
|
|
140
|
+
* @throws When `value` is not an integer between `0` and `65535`.
|
|
141
|
+
*/
|
|
142
|
+
function toU16(value) {
|
|
143
|
+
return toBoundedInt(value, 65535, "u16");
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { fromMoveFloat, fromMoveI64, toBigInt, toU16, toU8 };
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=numeric.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric.mjs","names":[],"sources":["../../src/utils/numeric.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MoveFloat } from '../types';\n\n/**\n * Converts a generated Move `i64` wrapper into a JavaScript number.\n *\n * The generated bindings expose signed 64-bit integers through a `{ bits }`\n * field that stores the raw two's-complement bit pattern. This helper\n * reinterprets those bits as a signed `i64` and returns a plain JS number.\n * Invalid or missing input falls back to `0`.\n *\n * @param i64 Generated Move `i64` value, typically used for float exponents.\n * @returns The signed 64-bit value as a JavaScript number.\n */\nexport function fromMoveI64(i64: MoveFloat['exp']): number {\n\ttry {\n\t\treturn Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));\n\t} catch {\n\t\treturn 0;\n\t}\n}\n\n/**\n * Converts a generated Move `Float` struct into a JavaScript number.\n *\n * Suigar float values are represented as a sign flag, an unsigned mantissa,\n * and a Move `i64` exponent. This helper rebuilds the numeric value using the\n * same normalization expected by the on-chain format and applies the sign at\n * the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.\n *\n * @param float Generated Move float value with `mant`, `exp`, and `is_negative`.\n * @returns The decoded floating-point value as a JavaScript number.\n */\nexport function fromMoveFloat(float: MoveFloat): number {\n\tconst mantissa = BigInt(float.mant ?? 0);\n\tif (mantissa === 0n) {\n\t\treturn 0;\n\t}\n\tconst exponent = fromMoveI64(float.exp) - 52;\n\tconst magnitude = Number(mantissa) * 2 ** exponent;\n\treturn float.is_negative ? -magnitude : magnitude;\n}\n\n/**\n * Ensures a value is a finite JavaScript number.\n *\n * This is only used for helpers that accept raw `number` input before applying\n * additional integer or range validation.\n */\nfunction assertFiniteNumber(\n\tvalue: unknown,\n\terrorMessage: string,\n): asserts value is number {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) {\n\t\tthrow new TypeError(`${errorMessage}: ${String(value)}`);\n\t}\n}\n\n/**\n * Normalizes a value into a non-negative `bigint`.\n *\n * Accepted inputs:\n * - `bigint`\n * - finite `number`\n * - base-10 integer `string`\n * - `boolean`\n *\n * Number inputs are truncated toward zero before conversion, so `5.9` becomes\n * `5n`. String and boolean inputs are parsed through the native\n * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,\n * and only integer strings are accepted.\n *\n * @param value Value to normalize.\n * @returns A non-negative `bigint`.\n * @throws When `value` is not a bigint, finite number, integer string, or\n * boolean.\n * @throws When the normalized value is negative.\n */\nexport function toBigInt(value: unknown): bigint {\n\tlet result: bigint;\n\n\ttry {\n\t\tif (\n\t\t\ttypeof value === 'bigint' ||\n\t\t\ttypeof value === 'string' ||\n\t\t\ttypeof value === 'boolean'\n\t\t) {\n\t\t\tresult = BigInt(value);\n\t\t} else {\n\t\t\tassertFiniteNumber(\n\t\t\t\tvalue,\n\t\t\t\t'Value must be a bigint, number, integer string, or boolean',\n\t\t\t);\n\t\t\tresult = BigInt(Math.trunc(value));\n\t\t}\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t`Value must be a bigint, number, integer string, or boolean: ${value}`,\n\t\t);\n\t}\n\n\tif (result < 0n) {\n\t\tthrow new RangeError(`Value must be non-negative: ${value}`);\n\t}\n\n\treturn result;\n}\n\n/**\n * Validates and normalizes a bounded unsigned integer.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * This internal helper powers the public `toU8()` and `toU16()` helpers. It\n * accepts stringified integers such as `'1'` for parsed values, but rejects\n * booleans, empty strings, fractional values, and out-of-range numbers.\n *\n * @param value Value to validate.\n * @param max Inclusive upper bound.\n * @param typeName Move integer label used in error messages.\n * @returns The validated integer as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `max`.\n */\nfunction toBoundedInt(value: unknown, max: number, typeName: string): number {\n\tconst num =\n\t\ttypeof value === 'string' && value.trim() === '' ? NaN : Number(value);\n\n\tassertFiniteNumber(num, 'Value must be a finite number or integer string');\n\tif (\n\t\ttypeof value === 'boolean' ||\n\t\tvalue == null ||\n\t\t!Number.isInteger(num) ||\n\t\tnum < 0 ||\n\t\tnum > max\n\t) {\n\t\tthrow new RangeError(\n\t\t\t`Value must be a ${typeName} integer (0-${max}): ${value}`,\n\t\t);\n\t}\n\n\treturn num;\n}\n\n/**\n * Validates that a value can be safely used as a Move `u8` in the `0..255`\n * range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u8` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `255`.\n */\nexport function toU8(value: unknown): number {\n\treturn toBoundedInt(value, 255, 'u8');\n}\n\n/**\n * Validates that a value can be safely used as a Move `u16` in the\n * `0..65535` range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u16` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `65535`.\n */\nexport function toU16(value: unknown): number {\n\treturn toBoundedInt(value, 65535, 'u16');\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,YAAY,KAA+B;CAC1D,IAAI;EACH,OAAO,OAAO,OAAO,OAAO,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC,CAAC;SAChD;EACP,OAAO;;;;;;;;;;;;;;AAeT,SAAgB,cAAc,OAA0B;CACvD,MAAM,WAAW,OAAO,MAAM,QAAQ,EAAE;CACxC,IAAI,aAAa,IAChB,OAAO;CAER,MAAM,WAAW,YAAY,MAAM,IAAI,GAAG;CAC1C,MAAM,YAAY,OAAO,SAAS,GAAG,KAAK;CAC1C,OAAO,MAAM,cAAc,CAAC,YAAY;;;;;;;;AASzC,SAAS,mBACR,OACA,cAC0B;CAC1B,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,MAAM,EACvD,MAAM,IAAI,UAAU,GAAG,aAAa,IAAI,OAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;AAwB1D,SAAgB,SAAS,OAAwB;CAChD,IAAI;CAEJ,IAAI;EACH,IACC,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WAEjB,SAAS,OAAO,MAAM;OAChB;GACN,mBACC,OACA,6DACA;GACD,SAAS,OAAO,KAAK,MAAM,MAAM,CAAC;;SAE5B;EACP,MAAM,IAAI,UACT,+DAA+D,QAC/D;;CAGF,IAAI,SAAS,IACZ,MAAM,IAAI,WAAW,+BAA+B,QAAQ;CAG7D,OAAO;;;;;;;;;;;;;;;;;;;;AAqBR,SAAS,aAAa,OAAgB,KAAa,UAA0B;CAC5E,MAAM,MACL,OAAO,UAAU,YAAY,MAAM,MAAM,KAAK,KAAK,MAAM,OAAO,MAAM;CAEvE,mBAAmB,KAAK,kDAAkD;CAC1E,IACC,OAAO,UAAU,aACjB,SAAS,QACT,CAAC,OAAO,UAAU,IAAI,IACtB,MAAM,KACN,MAAM,KAEN,MAAM,IAAI,WACT,mBAAmB,SAAS,cAAc,IAAI,KAAK,QACnD;CAGF,OAAO;;;;;;;;;;;;;;;;;;;AAoBR,SAAgB,KAAK,OAAwB;CAC5C,OAAO,aAAa,OAAO,KAAK,KAAK;;;;;;;;;;;;;;;;;;;AAoBtC,SAAgB,MAAM,OAAwB;CAC7C,OAAO,aAAa,OAAO,OAAO,MAAM"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Game, SuigarGameEvent } from "../types/game.type.mjs";
|
|
2
|
+
import { BetResultGameDetails, GameDetails } from "../types/game-details.type.mjs";
|
|
3
|
+
import { SuiClientTypes } from "@mysten/sui/client";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/parser.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Extracts and normalizes the first generic coin type from a Move object type.
|
|
8
|
+
*
|
|
9
|
+
* PvP Coinflip game object types encode the wager coin as their first type parameter,
|
|
10
|
+
* for example `Game<0x2::sui::SUI>`. This helper converts that generic type
|
|
11
|
+
* argument into the SDK's canonical struct tag string.
|
|
12
|
+
*
|
|
13
|
+
* @param type Fully qualified Move object type with the coin type as its first generic argument.
|
|
14
|
+
* @returns Normalized coin type struct tag.
|
|
15
|
+
*/
|
|
16
|
+
declare function parseCoinType(type: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a supported Suigar event into its normalized SDK game id and event name.
|
|
19
|
+
*
|
|
20
|
+
* This helper recognizes all supported Suigar event names in `GAME_EVENTS`.
|
|
21
|
+
* Standard `BetResultEvent` payloads encode the game family through the core
|
|
22
|
+
* client event module or generic type parameter, while PvP coinflip events
|
|
23
|
+
* resolve to the `pvp-coinflip` game id from their `pvp_coinflip` module.
|
|
24
|
+
*
|
|
25
|
+
* @param event Sui event returned by the core client.
|
|
26
|
+
* @returns Parsed SDK game id and raw Move event name, or `null` when the event
|
|
27
|
+
* name is unsupported or the game id cannot be resolved.
|
|
28
|
+
*/
|
|
29
|
+
declare function parseGameEvent(event: SuiClientTypes.Event): SuigarGameEvent | null;
|
|
30
|
+
/**
|
|
31
|
+
* Decodes `BetResultEvent.game_details` into plain application values.
|
|
32
|
+
*
|
|
33
|
+
* Use this only with the `game_details` field from a decoded `BetResultEvent`.
|
|
34
|
+
* Suigar stores those entries as `VecMap<string, vector<u8>>`, so raw BCS
|
|
35
|
+
* decoding leaves each value as bytes. This helper uses the provided `gameId`
|
|
36
|
+
* to narrow the known detail schema, parses each byte array into the expected
|
|
37
|
+
* runtime type, and preserves the original on-chain keys in the returned
|
|
38
|
+
* object. Unknown keys fall back to string decoding so newer detail fields
|
|
39
|
+
* remain readable by default.
|
|
40
|
+
*
|
|
41
|
+
* Call `parseGameEvent(event)` first when you need to derive the matching
|
|
42
|
+
* `gameId` from the raw `SuiClientTypes.Event` before decoding
|
|
43
|
+
* `decoded.game_details`.
|
|
44
|
+
*
|
|
45
|
+
* @param gameId Suigar game id used to narrow the known detail keys and value
|
|
46
|
+
* types for this bet result payload.
|
|
47
|
+
* @param gameDetails Raw `game_details` map from a decoded `BetResultEvent`.
|
|
48
|
+
* @returns A plain object with decoded values for the known keys of the
|
|
49
|
+
* selected game.
|
|
50
|
+
*/
|
|
51
|
+
declare function parseGameDetails<TGame extends Game>(gameId: TGame, gameDetails: BetResultGameDetails): GameDetails<TGame>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { parseCoinType, parseGameDetails, parseGameEvent };
|
|
54
|
+
//# sourceMappingURL=parser.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.mts","names":[],"sources":["../../src/utils/parser.ts"],"mappings":";;;;;;;;;AAkCA;;;;;AAqBA;iBArBgB,aAAA,CAAc,IAAA;;;;;;;;;AA4F9B;;;;iBAvEgB,cAAA,CACf,KAAA,EAAO,cAAA,CAAe,KAAA,GACpB,eAAA;;;;;;;;;;;;;;;;;;;;;;iBAqEa,gBAAA,eAA+B,IAAA,CAAA,CAC9C,MAAA,EAAQ,KAAA,EACR,WAAA,EAAa,oBAAA,GACX,WAAA,CAAY,KAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { fromMoveFloat } from "./numeric.mjs";
|
|
2
|
+
import { GAME_DETAILS_SCHEMAS, GAME_DETAIL_BCS } from "../types/game-details.type.mjs";
|
|
3
|
+
import { GAMES, GAME_EVENTS } from "../types/game.type.mjs";
|
|
4
|
+
import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
|
|
5
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
6
|
+
//#region src/utils/parser.ts
|
|
7
|
+
const textDecoder = new TextDecoder();
|
|
8
|
+
/**
|
|
9
|
+
* Extracts and normalizes the first generic coin type from a Move object type.
|
|
10
|
+
*
|
|
11
|
+
* PvP Coinflip game object types encode the wager coin as their first type parameter,
|
|
12
|
+
* for example `Game<0x2::sui::SUI>`. This helper converts that generic type
|
|
13
|
+
* argument into the SDK's canonical struct tag string.
|
|
14
|
+
*
|
|
15
|
+
* @param type Fully qualified Move object type with the coin type as its first generic argument.
|
|
16
|
+
* @returns Normalized coin type struct tag.
|
|
17
|
+
*/
|
|
18
|
+
function parseCoinType(type) {
|
|
19
|
+
const coinType = parseStructTag(type).typeParams[0];
|
|
20
|
+
if (!coinType) throw new TypeError(`Unable to parse coin type from ${type}`);
|
|
21
|
+
return normalizeStructTag(coinType);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a supported Suigar event into its normalized SDK game id and event name.
|
|
25
|
+
*
|
|
26
|
+
* This helper recognizes all supported Suigar event names in `GAME_EVENTS`.
|
|
27
|
+
* Standard `BetResultEvent` payloads encode the game family through the core
|
|
28
|
+
* client event module or generic type parameter, while PvP coinflip events
|
|
29
|
+
* resolve to the `pvp-coinflip` game id from their `pvp_coinflip` module.
|
|
30
|
+
*
|
|
31
|
+
* @param event Sui event returned by the core client.
|
|
32
|
+
* @returns Parsed SDK game id and raw Move event name, or `null` when the event
|
|
33
|
+
* name is unsupported or the game id cannot be resolved.
|
|
34
|
+
*/
|
|
35
|
+
function parseGameEvent(event) {
|
|
36
|
+
const { name: eventName, typeParams } = parseStructTag(event.eventType);
|
|
37
|
+
const module = event.module.replaceAll("_", "-");
|
|
38
|
+
const gameId = GAMES.includes(module) ? module : typeParams[0];
|
|
39
|
+
if (!GAME_EVENTS.includes(eventName) || typeof gameId !== "string") return null;
|
|
40
|
+
return {
|
|
41
|
+
gameId,
|
|
42
|
+
eventName
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function parseStringGameDetail(value) {
|
|
46
|
+
const bytes = Uint8Array.from(value);
|
|
47
|
+
try {
|
|
48
|
+
return bcs.String.parse(bytes);
|
|
49
|
+
} catch {
|
|
50
|
+
return textDecoder.decode(bytes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function parseGameDetail(valueType, value) {
|
|
54
|
+
if (valueType === "string") return parseStringGameDetail(value);
|
|
55
|
+
const parsed = GAME_DETAIL_BCS[valueType].parse(Uint8Array.from(value));
|
|
56
|
+
switch (valueType) {
|
|
57
|
+
case "float": return fromMoveFloat(parsed);
|
|
58
|
+
case "u64": return Number(parsed);
|
|
59
|
+
default: return parsed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Decodes `BetResultEvent.game_details` into plain application values.
|
|
64
|
+
*
|
|
65
|
+
* Use this only with the `game_details` field from a decoded `BetResultEvent`.
|
|
66
|
+
* Suigar stores those entries as `VecMap<string, vector<u8>>`, so raw BCS
|
|
67
|
+
* decoding leaves each value as bytes. This helper uses the provided `gameId`
|
|
68
|
+
* to narrow the known detail schema, parses each byte array into the expected
|
|
69
|
+
* runtime type, and preserves the original on-chain keys in the returned
|
|
70
|
+
* object. Unknown keys fall back to string decoding so newer detail fields
|
|
71
|
+
* remain readable by default.
|
|
72
|
+
*
|
|
73
|
+
* Call `parseGameEvent(event)` first when you need to derive the matching
|
|
74
|
+
* `gameId` from the raw `SuiClientTypes.Event` before decoding
|
|
75
|
+
* `decoded.game_details`.
|
|
76
|
+
*
|
|
77
|
+
* @param gameId Suigar game id used to narrow the known detail keys and value
|
|
78
|
+
* types for this bet result payload.
|
|
79
|
+
* @param gameDetails Raw `game_details` map from a decoded `BetResultEvent`.
|
|
80
|
+
* @returns A plain object with decoded values for the known keys of the
|
|
81
|
+
* selected game.
|
|
82
|
+
*/
|
|
83
|
+
function parseGameDetails(gameId, gameDetails) {
|
|
84
|
+
const schema = GAME_DETAILS_SCHEMAS[gameId];
|
|
85
|
+
return gameDetails.contents.reduce((parsedDetails, entry) => {
|
|
86
|
+
const valueType = schema[entry.key] ?? "string";
|
|
87
|
+
parsedDetails[entry.key] = parseGameDetail(valueType, entry.value);
|
|
88
|
+
return parsedDetails;
|
|
89
|
+
}, {});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { parseCoinType, parseGameDetails, parseGameEvent };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=parser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.mjs","names":[],"sources":["../../src/utils/parser.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport type { SuiClientTypes } from '@mysten/sui/client';\nimport { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';\nimport {\n\tBetResultGameDetails,\n\tGAME_DETAIL_BCS,\n\tGAME_DETAILS_SCHEMAS,\n\tGAME_EVENTS,\n\tGameDetail,\n\tGameDetails,\n\tGameEvent,\n\tGAMES,\n\tMoveFloat,\n\tSuigarGameEvent,\n\ttype Game,\n\ttype GameDetailValueType,\n} from '../types';\nimport { fromMoveFloat } from './numeric';\n\nconst textDecoder = new TextDecoder();\n\n/**\n * Extracts and normalizes the first generic coin type from a Move object type.\n *\n * PvP Coinflip game object types encode the wager coin as their first type parameter,\n * for example `Game<0x2::sui::SUI>`. This helper converts that generic type\n * argument into the SDK's canonical struct tag string.\n *\n * @param type Fully qualified Move object type with the coin type as its first generic argument.\n * @returns Normalized coin type struct tag.\n */\nexport function parseCoinType(type: string): string {\n\tconst coinType = parseStructTag(type).typeParams[0];\n\tif (!coinType) {\n\t\tthrow new TypeError(`Unable to parse coin type from ${type}`);\n\t}\n\n\treturn normalizeStructTag(coinType);\n}\n\n/**\n * Resolves a supported Suigar event into its normalized SDK game id and event name.\n *\n * This helper recognizes all supported Suigar event names in `GAME_EVENTS`.\n * Standard `BetResultEvent` payloads encode the game family through the core\n * client event module or generic type parameter, while PvP coinflip events\n * resolve to the `pvp-coinflip` game id from their `pvp_coinflip` module.\n *\n * @param event Sui event returned by the core client.\n * @returns Parsed SDK game id and raw Move event name, or `null` when the event\n * name is unsupported or the game id cannot be resolved.\n */\nexport function parseGameEvent(\n\tevent: SuiClientTypes.Event,\n): SuigarGameEvent | null {\n\tconst { name: eventName, typeParams } = parseStructTag(event.eventType);\n\tconst module = event.module.replaceAll('_', '-');\n\tconst gameId = GAMES.includes(module as Game) ? module : typeParams[0];\n\n\tif (\n\t\t!GAME_EVENTS.includes(eventName as GameEvent) ||\n\t\ttypeof gameId !== 'string'\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tgameId,\n\t\teventName,\n\t} as SuigarGameEvent;\n}\n\nfunction parseStringGameDetail(value: number[]): string {\n\tconst bytes = Uint8Array.from(value);\n\n\ttry {\n\t\treturn bcs.String.parse(bytes);\n\t} catch {\n\t\treturn textDecoder.decode(bytes);\n\t}\n}\n\nfunction parseGameDetail<TValueType extends GameDetailValueType>(\n\tvalueType: TValueType,\n\tvalue: number[],\n): GameDetail<TValueType> {\n\tif (valueType === 'string') {\n\t\treturn parseStringGameDetail(value) as GameDetail<TValueType>;\n\t}\n\n\tconst parsed = GAME_DETAIL_BCS[valueType].parse(Uint8Array.from(value));\n\n\tswitch (valueType) {\n\t\tcase 'float':\n\t\t\treturn fromMoveFloat(parsed as MoveFloat) as GameDetail<TValueType>;\n\t\tcase 'u64':\n\t\t\treturn Number(parsed) as GameDetail<TValueType>;\n\t\tdefault:\n\t\t\treturn parsed as GameDetail<TValueType>;\n\t}\n}\n\n/**\n * Decodes `BetResultEvent.game_details` into plain application values.\n *\n * Use this only with the `game_details` field from a decoded `BetResultEvent`.\n * Suigar stores those entries as `VecMap<string, vector<u8>>`, so raw BCS\n * decoding leaves each value as bytes. This helper uses the provided `gameId`\n * to narrow the known detail schema, parses each byte array into the expected\n * runtime type, and preserves the original on-chain keys in the returned\n * object. Unknown keys fall back to string decoding so newer detail fields\n * remain readable by default.\n *\n * Call `parseGameEvent(event)` first when you need to derive the matching\n * `gameId` from the raw `SuiClientTypes.Event` before decoding\n * `decoded.game_details`.\n *\n * @param gameId Suigar game id used to narrow the known detail keys and value\n * types for this bet result payload.\n * @param gameDetails Raw `game_details` map from a decoded `BetResultEvent`.\n * @returns A plain object with decoded values for the known keys of the\n * selected game.\n */\nexport function parseGameDetails<TGame extends Game>(\n\tgameId: TGame,\n\tgameDetails: BetResultGameDetails,\n): GameDetails<TGame> {\n\tconst schema: Record<string, GameDetailValueType> =\n\t\tGAME_DETAILS_SCHEMAS[gameId];\n\tconst details = gameDetails.contents.reduce<Record<string, unknown>>(\n\t\t(parsedDetails, entry) => {\n\t\t\tconst valueType = schema[entry.key] ?? 'string';\n\t\t\tparsedDetails[entry.key] = parseGameDetail(valueType, entry.value);\n\t\t\treturn parsedDetails;\n\t\t},\n\t\t{},\n\t);\n\n\treturn details as GameDetails<TGame>;\n}\n"],"mappings":";;;;;;AAsBA,MAAM,cAAc,IAAI,aAAa;;;;;;;;;;;AAYrC,SAAgB,cAAc,MAAsB;CACnD,MAAM,WAAW,eAAe,KAAK,CAAC,WAAW;CACjD,IAAI,CAAC,UACJ,MAAM,IAAI,UAAU,kCAAkC,OAAO;CAG9D,OAAO,mBAAmB,SAAS;;;;;;;;;;;;;;AAepC,SAAgB,eACf,OACyB;CACzB,MAAM,EAAE,MAAM,WAAW,eAAe,eAAe,MAAM,UAAU;CACvE,MAAM,SAAS,MAAM,OAAO,WAAW,KAAK,IAAI;CAChD,MAAM,SAAS,MAAM,SAAS,OAAe,GAAG,SAAS,WAAW;CAEpE,IACC,CAAC,YAAY,SAAS,UAAuB,IAC7C,OAAO,WAAW,UAElB,OAAO;CAGR,OAAO;EACN;EACA;EACA;;AAGF,SAAS,sBAAsB,OAAyB;CACvD,MAAM,QAAQ,WAAW,KAAK,MAAM;CAEpC,IAAI;EACH,OAAO,IAAI,OAAO,MAAM,MAAM;SACvB;EACP,OAAO,YAAY,OAAO,MAAM;;;AAIlC,SAAS,gBACR,WACA,OACyB;CACzB,IAAI,cAAc,UACjB,OAAO,sBAAsB,MAAM;CAGpC,MAAM,SAAS,gBAAgB,WAAW,MAAM,WAAW,KAAK,MAAM,CAAC;CAEvE,QAAQ,WAAR;EACC,KAAK,SACJ,OAAO,cAAc,OAAoB;EAC1C,KAAK,OACJ,OAAO,OAAO,OAAO;EACtB,SACC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBV,SAAgB,iBACf,QACA,aACqB;CACrB,MAAM,SACL,qBAAqB;CAUtB,OATgB,YAAY,SAAS,QACnC,eAAe,UAAU;EACzB,MAAM,YAAY,OAAO,MAAM,QAAQ;EACvC,cAAc,MAAM,OAAO,gBAAgB,WAAW,MAAM,MAAM;EAClE,OAAO;IAER,EAAE,CAGW"}
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT } from "./utils/constants.mjs";
|
|
2
|
+
import { fromMoveFloat, fromMoveI64, toBigInt, toU16, toU8 } from "./utils/numeric.mjs";
|
|
3
|
+
import { parseCoinType, parseGameDetails, parseGameEvent } from "./utils/parser.mjs";
|
|
4
|
+
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, parseGameEvent, toBigInt, toU16, toU8 };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT } from "./utils/constants.mjs";
|
|
2
|
+
import { fromMoveFloat, fromMoveI64, toBigInt, toU16, toU8 } from "./utils/numeric.mjs";
|
|
3
|
+
import { parseCoinType, parseGameDetails, parseGameEvent } from "./utils/parser.mjs";
|
|
4
|
+
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, parseGameEvent, toBigInt, toU16, toU8 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suigar/sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.15",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suigar",
|
|
@@ -19,28 +19,27 @@
|
|
|
19
19
|
"CHANGELOG.md",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
-
"main": "./dist/index.
|
|
23
|
-
"
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
22
|
+
"main": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
25
24
|
"exports": {
|
|
26
25
|
".": {
|
|
27
|
-
"types": "./dist/index.d.
|
|
28
|
-
"import": "./dist/index.
|
|
29
|
-
"
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
30
29
|
},
|
|
31
30
|
"./games": {
|
|
32
|
-
"types": "./dist/games.d.
|
|
33
|
-
"import": "./dist/games.
|
|
34
|
-
"
|
|
31
|
+
"types": "./dist/games.d.mts",
|
|
32
|
+
"import": "./dist/games.mjs",
|
|
33
|
+
"default": "./dist/games.mjs"
|
|
35
34
|
},
|
|
36
35
|
"./utils": {
|
|
37
|
-
"types": "./dist/utils.d.
|
|
38
|
-
"import": "./dist/utils.
|
|
39
|
-
"
|
|
36
|
+
"types": "./dist/utils.d.mts",
|
|
37
|
+
"import": "./dist/utils.mjs",
|
|
38
|
+
"default": "./dist/utils.mjs"
|
|
40
39
|
}
|
|
41
40
|
},
|
|
42
41
|
"engines": {
|
|
43
|
-
"node": ">=24"
|
|
42
|
+
"node": "^22.18.0 || >=24"
|
|
44
43
|
},
|
|
45
44
|
"repository": {
|
|
46
45
|
"type": "git",
|
|
@@ -62,14 +61,14 @@
|
|
|
62
61
|
"@mysten/codegen": "^0.10.4",
|
|
63
62
|
"@mysten/sui": "^2.16.0",
|
|
64
63
|
"@types/node": "^24.0.0",
|
|
65
|
-
"
|
|
64
|
+
"tsdown": "^0.22.0",
|
|
66
65
|
"tsx": "^4.21.0",
|
|
67
66
|
"typescript": "^5.9.3",
|
|
68
67
|
"vitest": "^4.1.5"
|
|
69
68
|
},
|
|
70
69
|
"scripts": {
|
|
71
|
-
"build": "pnpm clean && pnpm codegen &&
|
|
72
|
-
"build:ci": "rm -rf dist &&
|
|
70
|
+
"build": "pnpm clean && pnpm codegen && tsdown",
|
|
71
|
+
"build:ci": "rm -rf dist && tsdown",
|
|
73
72
|
"clean": "rm -rf dist src/contracts .vitest-cache",
|
|
74
73
|
"codegen": "node ./scripts/update-package-configs.mjs && sui-ts-codegen generate && pnpm lint",
|
|
75
74
|
"eslint:fix": "eslint . --fix",
|