@suigar/sdk 2.0.0-beta.10 → 2.0.0-beta.12

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/utils.d.cts CHANGED
@@ -62,30 +62,62 @@ declare const RANGE_POINT_LIMIT: number;
62
62
  declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
63
 
64
64
  /**
65
- * Normalizes a numeric input into a non-negative `bigint`.
65
+ * Normalizes a value into a non-negative `bigint`.
66
66
  *
67
- * This helper accepts the two number shapes the SDK commonly sees from app
68
- * code: plain JavaScript numbers and already-normalized `bigint` values.
69
- * Number inputs are truncated toward zero before conversion, so UI-friendly
70
- * values like `5.9` become `5n`.
67
+ * Accepted inputs:
68
+ * - `bigint`
69
+ * - finite `number`
70
+ * - base-10 integer `string`
71
+ * - `boolean`
71
72
  *
72
- * @param value Value to coerce into a `bigint`.
73
- * @returns The normalized non-negative `bigint`.
74
- * @throws When `value` is not a finite number or bigint, or when it is negative.
73
+ * Number inputs are truncated toward zero before conversion, so `5.9` becomes
74
+ * `5n`. String and boolean inputs are parsed through the native
75
+ * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,
76
+ * and only integer strings are accepted.
77
+ *
78
+ * @param value Value to normalize.
79
+ * @returns A non-negative `bigint`.
80
+ * @throws When `value` is not a bigint, finite number, integer string, or
81
+ * boolean.
82
+ * @throws When the normalized value is negative.
75
83
  */
76
84
  declare function toBigInt(value: unknown): bigint;
77
85
  /**
78
- * Validates that a value can be safely used as a Move `u8`.
86
+ * Validates that a value can be safely used as a Move `u8` in the `0..255`
87
+ * range.
88
+ *
89
+ * Accepted inputs:
90
+ * - finite `number`
91
+ * - base-10 integer `string`
79
92
  *
80
- * Use this for config ids and other small integer fields that must stay inside
81
- * the `0..255` range. Unlike `toBigInt`, this does not coerce fractional
82
- * values: the input must already be an integer.
93
+ * String inputs are accepted for parsed values such as `'1'`, but only when
94
+ * they are plain non-negative integer strings. This helper does not accept
95
+ * booleans and does not truncate fractional values.
83
96
  *
84
97
  * @param value Value to validate.
85
- * @returns The original number once it has been confirmed to be a valid `u8`.
86
- * @throws When `value` is not a finite integer between `0` and `255`.
98
+ * @returns The validated `u8` value as a JavaScript `number`.
99
+ * @throws When `value` is not a finite number or integer string.
100
+ * @throws When `value` is not an integer between `0` and `255`.
87
101
  */
88
102
  declare function toU8(value: unknown): number;
103
+ /**
104
+ * Validates that a value can be safely used as a Move `u16` in the
105
+ * `0..65535` range.
106
+ *
107
+ * Accepted inputs:
108
+ * - finite `number`
109
+ * - base-10 integer `string`
110
+ *
111
+ * String inputs are accepted for parsed values such as `'1'`, but only when
112
+ * they are plain non-negative integer strings. This helper does not accept
113
+ * booleans and does not truncate fractional values.
114
+ *
115
+ * @param value Value to validate.
116
+ * @returns The validated `u16` value as a JavaScript `number`.
117
+ * @throws When `value` is not a finite number or integer string.
118
+ * @throws When `value` is not an integer between `0` and `65535`.
119
+ */
120
+ declare function toU16(value: unknown): number;
89
121
 
90
122
  declare const Float: MoveStruct<{
91
123
  is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -145,4 +177,4 @@ declare function parseCoinType(type: string): string;
145
177
  */
146
178
  declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
147
179
 
148
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU8 };
180
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 };
package/dist/utils.d.ts CHANGED
@@ -62,30 +62,62 @@ declare const RANGE_POINT_LIMIT: number;
62
62
  declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
63
 
64
64
  /**
65
- * Normalizes a numeric input into a non-negative `bigint`.
65
+ * Normalizes a value into a non-negative `bigint`.
66
66
  *
67
- * This helper accepts the two number shapes the SDK commonly sees from app
68
- * code: plain JavaScript numbers and already-normalized `bigint` values.
69
- * Number inputs are truncated toward zero before conversion, so UI-friendly
70
- * values like `5.9` become `5n`.
67
+ * Accepted inputs:
68
+ * - `bigint`
69
+ * - finite `number`
70
+ * - base-10 integer `string`
71
+ * - `boolean`
71
72
  *
72
- * @param value Value to coerce into a `bigint`.
73
- * @returns The normalized non-negative `bigint`.
74
- * @throws When `value` is not a finite number or bigint, or when it is negative.
73
+ * Number inputs are truncated toward zero before conversion, so `5.9` becomes
74
+ * `5n`. String and boolean inputs are parsed through the native
75
+ * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,
76
+ * and only integer strings are accepted.
77
+ *
78
+ * @param value Value to normalize.
79
+ * @returns A non-negative `bigint`.
80
+ * @throws When `value` is not a bigint, finite number, integer string, or
81
+ * boolean.
82
+ * @throws When the normalized value is negative.
75
83
  */
76
84
  declare function toBigInt(value: unknown): bigint;
77
85
  /**
78
- * Validates that a value can be safely used as a Move `u8`.
86
+ * Validates that a value can be safely used as a Move `u8` in the `0..255`
87
+ * range.
88
+ *
89
+ * Accepted inputs:
90
+ * - finite `number`
91
+ * - base-10 integer `string`
79
92
  *
80
- * Use this for config ids and other small integer fields that must stay inside
81
- * the `0..255` range. Unlike `toBigInt`, this does not coerce fractional
82
- * values: the input must already be an integer.
93
+ * String inputs are accepted for parsed values such as `'1'`, but only when
94
+ * they are plain non-negative integer strings. This helper does not accept
95
+ * booleans and does not truncate fractional values.
83
96
  *
84
97
  * @param value Value to validate.
85
- * @returns The original number once it has been confirmed to be a valid `u8`.
86
- * @throws When `value` is not a finite integer between `0` and `255`.
98
+ * @returns The validated `u8` value as a JavaScript `number`.
99
+ * @throws When `value` is not a finite number or integer string.
100
+ * @throws When `value` is not an integer between `0` and `255`.
87
101
  */
88
102
  declare function toU8(value: unknown): number;
103
+ /**
104
+ * Validates that a value can be safely used as a Move `u16` in the
105
+ * `0..65535` range.
106
+ *
107
+ * Accepted inputs:
108
+ * - finite `number`
109
+ * - base-10 integer `string`
110
+ *
111
+ * String inputs are accepted for parsed values such as `'1'`, but only when
112
+ * they are plain non-negative integer strings. This helper does not accept
113
+ * booleans and does not truncate fractional values.
114
+ *
115
+ * @param value Value to validate.
116
+ * @returns The validated `u16` value as a JavaScript `number`.
117
+ * @throws When `value` is not a finite number or integer string.
118
+ * @throws When `value` is not an integer between `0` and `65535`.
119
+ */
120
+ declare function toU16(value: unknown): number;
89
121
 
90
122
  declare const Float: MoveStruct<{
91
123
  is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -145,4 +177,4 @@ declare function parseCoinType(type: string): string;
145
177
  */
146
178
  declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
147
179
 
148
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU8 };
180
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU8 } from './chunk-PPUDLRHA.js';
1
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 } from './chunk-7N55D2TV.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suigar/sdk",
3
- "version": "2.0.0-beta.10",
3
+ "version": "2.0.0-beta.12",
4
4
  "description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
5
5
  "keywords": [
6
6
  "suigar",
@@ -68,13 +68,13 @@
68
68
  "vitest": "^4.1.5"
69
69
  },
70
70
  "scripts": {
71
- "build": "pnpm run clean && pnpm run codegen && tsup",
71
+ "build": "pnpm clean && pnpm codegen && tsup",
72
72
  "build:ci": "rm -rf dist && tsup",
73
73
  "clean": "rm -rf dist src/contracts .vitest-cache",
74
- "codegen": "node ./scripts/update-package-configs.mjs && sui-ts-codegen generate && pnpm run lint",
74
+ "codegen": "node ./scripts/update-package-configs.mjs && sui-ts-codegen generate && pnpm lint",
75
75
  "eslint:fix": "eslint . --fix",
76
- "format": "pnpm run prettier:fix",
77
- "lint": "pnpm run eslint:fix && pnpm run prettier:fix",
76
+ "format": "pnpm prettier:fix",
77
+ "lint": "pnpm eslint:fix && pnpm prettier:fix",
78
78
  "prettier:fix": "prettier --write --ignore-unknown .",
79
79
  "test": "vitest run",
80
80
  "typecheck": "tsc --noEmit"