@suigar/sdk 2.0.0-beta.6 → 2.0.0-beta.7

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @suigar/sdk
2
2
 
3
+ ## 2.0.0-beta.7
4
+
5
+ ### Patch Changes
6
+
7
+ - f0ea104: Align numeric utility names, Move decoding helpers, and PvP BCS event helper references with the current SDK API.
8
+
3
9
  ## 2.0.0-beta.6
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -42,11 +42,11 @@ import {
42
42
  DEFAULT_LIMBO_MULTIPLIER_SCALE,
43
43
  DEFAULT_RANGE_SCALE,
44
44
  RANGE_POINT_LIMIT,
45
- parseFloat,
45
+ fromMoveFloat,
46
+ fromMoveI64,
46
47
  parseGameDetails,
47
- parseI64,
48
- toBigIntAmount,
49
- toU8Number,
48
+ toBigInt,
49
+ toU8,
50
50
  } from '@suigar/sdk/utils';
51
51
  ```
52
52
 
@@ -253,7 +253,7 @@ console.log(game.is_private);
253
253
  >
254
254
  > - it throws if the object response does not include decodable `content`
255
255
  > - the PvP join builder uses this internally to derive the required join stake
256
- > - after a game is joined and resolved, the live `Game` object is removed from the registry and deleted, so inspect `PvPCoinflipGameResolved` to read the final result
256
+ > - after a game is joined and resolved, the live `Game` object is removed from the registry and deleted, so inspect `PvPCoinflipGameResolvedEvent` to read the final result
257
257
 
258
258
  > **Tip:** Prefer this helper over manual object parsing when you only need the
259
259
  > parsed state for a live PvP coinflip game object.
@@ -413,15 +413,15 @@ Current exposed helpers:
413
413
 
414
414
  - `PvPCoinflipGame`
415
415
  - `BetResultEvent`
416
- - `PvPCoinflipGameCreated`
417
- - `PvPCoinflipGameResolved`
418
- - `PvPCoinflipGameCancelled`
416
+ - `PvPCoinflipGameCreatedEvent`
417
+ - `PvPCoinflipGameResolvedEvent`
418
+ - `PvPCoinflipGameCancelledEvent`
419
419
 
420
420
  These are generated Move event decoders. Use them to parse Suigar event payloads from transaction results. The `@suigar/sdk/utils` subpath also exposes parser helpers for generated BCS values:
421
421
 
422
422
  - `PvPCoinflipGame` parses a PvP coinflip game object's `content`
423
- - `parseI64(float.exp)` converts a generated Move `i64` exponent to a JavaScript number
424
- - `parseFloat(float)` converts a generated Move `Float` struct to a JavaScript number
423
+ - `fromMoveI64(float.exp)` converts a generated Move `i64` exponent to a JavaScript number
424
+ - `fromMoveFloat(float)` converts a generated Move `Float` struct to a JavaScript number
425
425
  - `parseGameDetails(game_details)` decodes `BetResultEvent.game_details` entries into the expected string, number, and boolean values
426
426
 
427
427
  ### Parse PvP Coinflip Game Object Data
@@ -528,9 +528,9 @@ contain that partner wallet address under the `partner` entry.
528
528
 
529
529
  Use the matching helper for each PvP coinflip event payload found in `transactionResult.events`:
530
530
 
531
- - `client.suigar.bcs.PvPCoinflipGameCreated`
532
- - `client.suigar.bcs.PvPCoinflipGameResolved`
533
- - `client.suigar.bcs.PvPCoinflipGameCancelled`
531
+ - `client.suigar.bcs.PvPCoinflipGameCreatedEvent`
532
+ - `client.suigar.bcs.PvPCoinflipGameResolvedEvent`
533
+ - `client.suigar.bcs.PvPCoinflipGameCancelledEvent`
534
534
 
535
535
  ## Development
536
536
 
@@ -548,7 +548,7 @@ It demonstrates:
548
548
 
549
549
  - standard game transactions through `client.suigar.tx.createBetTransaction(...)`
550
550
  - PvP coinflip create, join, and cancel flows through `client.suigar.tx.createPvPCoinflipTransaction(...)`, exposed in the example through a PvP coinflip action selector
551
- - unresolved PvP lobby browsing through `client.suigar.getPvPCoinflipGames(...)`, rendered as compact join/cancel cards filtered by the connected wallet
551
+ - unresolved PvP lobby browsing through `client.suigar.getPvPCoinflipGames(...)`, including public join cards while disconnected, an optional private-lobby join toggle, and connected-wallet filtering for cancel
552
552
  - wallet connection and execution with `@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`
553
553
  - supported coin selection from `client.suigar.getConfig()`
554
554
  - connected-wallet balance display for each supported coin in the example app
@@ -9,21 +9,34 @@ var RANGE_POINT_LIMIT = DEFAULT_RANGE_SCALE * 100;
9
9
  var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
10
10
 
11
11
  // src/utils/numeric.ts
12
- function toBigIntAmount(value, fieldName) {
12
+ function isFiniteNumber(value, message) {
13
+ if (typeof value !== "number") {
14
+ throw new Error(`${message}: ${String(value)}`);
15
+ }
16
+ if (!Number.isFinite(value)) {
17
+ throw new Error(`Value must be a finite number: ${value}`);
18
+ }
19
+ }
20
+ function toBigInt(value) {
13
21
  if (typeof value === "bigint") {
14
22
  if (value < 0n) {
15
- throw new Error(`${fieldName} must be non-negative`);
23
+ throw new Error(`Value must be non-negative: ${value}`);
16
24
  }
17
25
  return value;
18
26
  }
19
- if (!Number.isFinite(value) || value < 0) {
20
- throw new Error(`${fieldName} must be a finite non-negative number`);
27
+ isFiniteNumber(value, "Value must be a bigint or number");
28
+ if (value < 0) {
29
+ throw new Error(`Value must be a finite non-negative number: ${value}`);
21
30
  }
22
31
  return BigInt(Math.trunc(value));
23
32
  }
24
- function toU8Number(value, fieldName) {
25
- if (!Number.isInteger(value) || value < 0 || value > 255) {
26
- throw new Error(`${fieldName} must be an integer between 0 and 255`);
33
+ function toU8(value) {
34
+ isFiniteNumber(value, "Value must be a number");
35
+ if (!Number.isInteger(value)) {
36
+ throw new Error(`Value must be an integer: ${value}`);
37
+ }
38
+ if (value < 0 || value > 255) {
39
+ throw new Error(`Value must be an integer between 0 and 255: ${value}`);
27
40
  }
28
41
  return value;
29
42
  }
@@ -255,7 +268,7 @@ var GAME_DETAIL_BCS = {
255
268
  float: Float,
256
269
  string: bcsString
257
270
  };
258
- function parseI64(i64) {
271
+ function fromMoveI64(i64) {
259
272
  try {
260
273
  const value = BigInt(i64.bits ?? 0);
261
274
  const maxPositive = 1n << 63n;
@@ -266,18 +279,18 @@ function parseI64(i64) {
266
279
  return 0;
267
280
  }
268
281
  }
269
- function parseFloat(float) {
282
+ function fromMoveFloat(float) {
270
283
  const mantissa = BigInt(float.mant);
271
284
  if (mantissa === 0n) {
272
285
  return 0;
273
286
  }
274
- const exponent = parseI64(float.exp) - 52;
287
+ const exponent = fromMoveI64(float.exp) - 52;
275
288
  const magnitude = Number(mantissa) * Math.pow(2, exponent);
276
289
  return float.is_negative ? -magnitude : magnitude;
277
290
  }
278
291
  function normalizeGameDetailValue(valueType, parsed) {
279
292
  if (valueType === "float") {
280
- return parseFloat(parsed);
293
+ return fromMoveFloat(parsed);
281
294
  }
282
295
  if (valueType === "u64") {
283
296
  return Number(parsed);
@@ -307,4 +320,4 @@ function parseGameDetails(gameDetails) {
307
320
  }, {});
308
321
  }
309
322
 
310
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, Float, MoveStruct, RANGE_POINT_LIMIT, normalizeMoveArguments, parseFloat, parseGameDetails, parseI64, toBigIntAmount, toU8Number };
323
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, Float, MoveStruct, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, normalizeMoveArguments, parseGameDetails, toBigInt, toU8 };
package/dist/index.cjs CHANGED
@@ -367,21 +367,34 @@ var DEFAULT_RANGE_SCALE = 1e6;
367
367
  var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
368
368
 
369
369
  // src/utils/numeric.ts
370
- function toBigIntAmount(value, fieldName) {
370
+ function isFiniteNumber(value, message) {
371
+ if (typeof value !== "number") {
372
+ throw new Error(`${message}: ${String(value)}`);
373
+ }
374
+ if (!Number.isFinite(value)) {
375
+ throw new Error(`Value must be a finite number: ${value}`);
376
+ }
377
+ }
378
+ function toBigInt(value) {
371
379
  if (typeof value === "bigint") {
372
380
  if (value < 0n) {
373
- throw new Error(`${fieldName} must be non-negative`);
381
+ throw new Error(`Value must be non-negative: ${value}`);
374
382
  }
375
383
  return value;
376
384
  }
377
- if (!Number.isFinite(value) || value < 0) {
378
- throw new Error(`${fieldName} must be a finite non-negative number`);
385
+ isFiniteNumber(value, "Value must be a bigint or number");
386
+ if (value < 0) {
387
+ throw new Error(`Value must be a finite non-negative number: ${value}`);
379
388
  }
380
389
  return BigInt(Math.trunc(value));
381
390
  }
382
- function toU8Number(value, fieldName) {
383
- if (!Number.isInteger(value) || value < 0 || value > 255) {
384
- throw new Error(`${fieldName} must be an integer between 0 and 255`);
391
+ function toU8(value) {
392
+ isFiniteNumber(value, "Value must be a number");
393
+ if (!Number.isInteger(value)) {
394
+ throw new Error(`Value must be an integer: ${value}`);
395
+ }
396
+ if (value < 0 || value > 255) {
397
+ throw new Error(`Value must be an integer between 0 and 255: ${value}`);
385
398
  }
386
399
  return value;
387
400
  }
@@ -426,9 +439,9 @@ function buildSharedStandardGameBetCall({
426
439
  return (tx) => {
427
440
  const normalizedOwner = utils.normalizeSuiAddress(sender ?? owner);
428
441
  const normalizedCoinType = utils.normalizeStructTag(coinType);
429
- const resolvedStake = toBigIntAmount(stake, "stake");
430
- const resolvedCashStake = toBigIntAmount(cashStake ?? stake, "cashStake");
431
- const resolvedBetCount = toBigIntAmount(betCount ?? 1, "betCount");
442
+ const resolvedStake = toBigInt(stake);
443
+ const resolvedCashStake = toBigInt(cashStake ?? stake);
444
+ const resolvedBetCount = toBigInt(betCount ?? 1);
432
445
  const encodedMetadata = encodeBetMetadata(metadata, partner);
433
446
  const priceInfoObjectId = resolvePriceInfoObjectId(
434
447
  config,
@@ -577,7 +590,7 @@ function play3(options) {
577
590
 
578
591
  // src/transactions/plinko.ts
579
592
  function buildPlinkoTransaction(options) {
580
- const configId = toU8Number(options.configId, "configId");
593
+ const configId = toU8(options.configId);
581
594
  return buildSharedStandardGameBetTransaction({
582
595
  ...options,
583
596
  game: "plinko",
@@ -737,7 +750,7 @@ function buildPvPCoinflipTransaction(action, options) {
737
750
  switch (action) {
738
751
  case "create": {
739
752
  const createOptions = options;
740
- const stake = toBigIntAmount(createOptions.stake, "stake");
753
+ const stake = toBigInt(createOptions.stake);
741
754
  const betCoin = tx.coin({
742
755
  type: normalizedCoinType,
743
756
  balance: stake,
@@ -888,7 +901,7 @@ function play5(options) {
888
901
 
889
902
  // src/transactions/wheel.ts
890
903
  function buildWheelTransaction(options) {
891
- const configId = toU8Number(options.configId, "configId");
904
+ const configId = toU8(options.configId);
892
905
  return buildSharedStandardGameBetTransaction({
893
906
  ...options,
894
907
  game: "wheel",
@@ -1092,15 +1105,15 @@ var SuigarClient = class {
1092
1105
  /**
1093
1106
  * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
1094
1107
  */
1095
- PvPCoinflipGameCreated: GameCreatedEvent,
1108
+ PvPCoinflipGameCreatedEvent: GameCreatedEvent,
1096
1109
  /**
1097
1110
  * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
1098
1111
  */
1099
- PvPCoinflipGameResolved: GameResolvedEvent,
1112
+ PvPCoinflipGameResolvedEvent: GameResolvedEvent,
1100
1113
  /**
1101
1114
  * Event emitted when a PvP Coinflip game is cancelled.
1102
1115
  */
1103
- PvPCoinflipGameCancelled: GameCancelledEvent
1116
+ PvPCoinflipGameCancelledEvent: GameCancelledEvent
1104
1117
  };
1105
1118
  /**
1106
1119
  * Transaction builders for Suigar games.
package/dist/index.d.cts CHANGED
@@ -207,7 +207,7 @@ declare class SuigarClient {
207
207
  /**
208
208
  * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
209
209
  */
210
- PvPCoinflipGameCreated: MoveStruct<{
210
+ PvPCoinflipGameCreatedEvent: MoveStruct<{
211
211
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
212
212
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
213
213
  creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -222,7 +222,7 @@ declare class SuigarClient {
222
222
  /**
223
223
  * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
224
224
  */
225
- PvPCoinflipGameResolved: MoveStruct<{
225
+ PvPCoinflipGameResolvedEvent: MoveStruct<{
226
226
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
227
227
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
228
228
  joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
@@ -241,7 +241,7 @@ declare class SuigarClient {
241
241
  /**
242
242
  * Event emitted when a PvP Coinflip game is cancelled.
243
243
  */
244
- PvPCoinflipGameCancelled: MoveStruct<{
244
+ PvPCoinflipGameCancelledEvent: MoveStruct<{
245
245
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
246
246
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
247
247
  creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
package/dist/index.d.ts CHANGED
@@ -207,7 +207,7 @@ declare class SuigarClient {
207
207
  /**
208
208
  * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
209
209
  */
210
- PvPCoinflipGameCreated: MoveStruct<{
210
+ PvPCoinflipGameCreatedEvent: MoveStruct<{
211
211
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
212
212
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
213
213
  creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -222,7 +222,7 @@ declare class SuigarClient {
222
222
  /**
223
223
  * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
224
224
  */
225
- PvPCoinflipGameResolved: MoveStruct<{
225
+ PvPCoinflipGameResolvedEvent: MoveStruct<{
226
226
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
227
227
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
228
228
  joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
@@ -241,7 +241,7 @@ declare class SuigarClient {
241
241
  /**
242
242
  * Event emitted when a PvP Coinflip game is cancelled.
243
243
  */
244
- PvPCoinflipGameCancelled: MoveStruct<{
244
+ PvPCoinflipGameCancelledEvent: MoveStruct<{
245
245
  game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
246
246
  creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
247
247
  creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MoveStruct, Float, toBigIntAmount, toU8Number, DEFAULT_GAS_BUDGET_MIST, normalizeMoveArguments, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE } from './chunk-W3WZ2BHO.js';
1
+ import { MoveStruct, Float, toBigInt, toU8, DEFAULT_GAS_BUDGET_MIST, normalizeMoveArguments, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE } from './chunk-YGYMLRE4.js';
2
2
  import { toBase64, normalizeStructTag, parseStructTag, normalizeSuiAddress, isValidSuiAddress } from '@mysten/sui/utils';
3
3
  import { Transaction } from '@mysten/sui/transactions';
4
4
  import { bcs } from '@mysten/sui/bcs';
@@ -251,9 +251,9 @@ function buildSharedStandardGameBetCall({
251
251
  return (tx) => {
252
252
  const normalizedOwner = normalizeSuiAddress(sender ?? owner);
253
253
  const normalizedCoinType = normalizeStructTag(coinType);
254
- const resolvedStake = toBigIntAmount(stake, "stake");
255
- const resolvedCashStake = toBigIntAmount(cashStake ?? stake, "cashStake");
256
- const resolvedBetCount = toBigIntAmount(betCount ?? 1, "betCount");
254
+ const resolvedStake = toBigInt(stake);
255
+ const resolvedCashStake = toBigInt(cashStake ?? stake);
256
+ const resolvedBetCount = toBigInt(betCount ?? 1);
257
257
  const encodedMetadata = encodeBetMetadata(metadata, partner);
258
258
  const priceInfoObjectId = resolvePriceInfoObjectId(
259
259
  config,
@@ -402,7 +402,7 @@ function play3(options) {
402
402
 
403
403
  // src/transactions/plinko.ts
404
404
  function buildPlinkoTransaction(options) {
405
- const configId = toU8Number(options.configId, "configId");
405
+ const configId = toU8(options.configId);
406
406
  return buildSharedStandardGameBetTransaction({
407
407
  ...options,
408
408
  game: "plinko",
@@ -562,7 +562,7 @@ function buildPvPCoinflipTransaction(action, options) {
562
562
  switch (action) {
563
563
  case "create": {
564
564
  const createOptions = options;
565
- const stake = toBigIntAmount(createOptions.stake, "stake");
565
+ const stake = toBigInt(createOptions.stake);
566
566
  const betCoin = tx.coin({
567
567
  type: normalizedCoinType,
568
568
  balance: stake,
@@ -713,7 +713,7 @@ function play5(options) {
713
713
 
714
714
  // src/transactions/wheel.ts
715
715
  function buildWheelTransaction(options) {
716
- const configId = toU8Number(options.configId, "configId");
716
+ const configId = toU8(options.configId);
717
717
  return buildSharedStandardGameBetTransaction({
718
718
  ...options,
719
719
  game: "wheel",
@@ -917,15 +917,15 @@ var SuigarClient = class {
917
917
  /**
918
918
  * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
919
919
  */
920
- PvPCoinflipGameCreated: GameCreatedEvent,
920
+ PvPCoinflipGameCreatedEvent: GameCreatedEvent,
921
921
  /**
922
922
  * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
923
923
  */
924
- PvPCoinflipGameResolved: GameResolvedEvent,
924
+ PvPCoinflipGameResolvedEvent: GameResolvedEvent,
925
925
  /**
926
926
  * Event emitted when a PvP Coinflip game is cancelled.
927
927
  */
928
- PvPCoinflipGameCancelled: GameCancelledEvent
928
+ PvPCoinflipGameCancelledEvent: GameCancelledEvent
929
929
  };
930
930
  /**
931
931
  * Transaction builders for Suigar games.
package/dist/utils.cjs CHANGED
@@ -11,21 +11,34 @@ var RANGE_POINT_LIMIT = DEFAULT_RANGE_SCALE * 100;
11
11
  var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
12
12
 
13
13
  // src/utils/numeric.ts
14
- function toBigIntAmount(value, fieldName) {
14
+ function isFiniteNumber(value, message) {
15
+ if (typeof value !== "number") {
16
+ throw new Error(`${message}: ${String(value)}`);
17
+ }
18
+ if (!Number.isFinite(value)) {
19
+ throw new Error(`Value must be a finite number: ${value}`);
20
+ }
21
+ }
22
+ function toBigInt(value) {
15
23
  if (typeof value === "bigint") {
16
24
  if (value < 0n) {
17
- throw new Error(`${fieldName} must be non-negative`);
25
+ throw new Error(`Value must be non-negative: ${value}`);
18
26
  }
19
27
  return value;
20
28
  }
21
- if (!Number.isFinite(value) || value < 0) {
22
- throw new Error(`${fieldName} must be a finite non-negative number`);
29
+ isFiniteNumber(value, "Value must be a bigint or number");
30
+ if (value < 0) {
31
+ throw new Error(`Value must be a finite non-negative number: ${value}`);
23
32
  }
24
33
  return BigInt(Math.trunc(value));
25
34
  }
26
- function toU8Number(value, fieldName) {
27
- if (!Number.isInteger(value) || value < 0 || value > 255) {
28
- throw new Error(`${fieldName} must be an integer between 0 and 255`);
35
+ function toU8(value) {
36
+ isFiniteNumber(value, "Value must be a number");
37
+ if (!Number.isInteger(value)) {
38
+ throw new Error(`Value must be an integer: ${value}`);
39
+ }
40
+ if (value < 0 || value > 255) {
41
+ throw new Error(`Value must be an integer between 0 and 255: ${value}`);
29
42
  }
30
43
  return value;
31
44
  }
@@ -145,7 +158,7 @@ var GAME_DETAIL_BCS = {
145
158
  float: Float,
146
159
  string: bcsString
147
160
  };
148
- function parseI64(i64) {
161
+ function fromMoveI64(i64) {
149
162
  try {
150
163
  const value = BigInt(i64.bits ?? 0);
151
164
  const maxPositive = 1n << 63n;
@@ -156,18 +169,18 @@ function parseI64(i64) {
156
169
  return 0;
157
170
  }
158
171
  }
159
- function parseFloat(float) {
172
+ function fromMoveFloat(float) {
160
173
  const mantissa = BigInt(float.mant);
161
174
  if (mantissa === 0n) {
162
175
  return 0;
163
176
  }
164
- const exponent = parseI64(float.exp) - 52;
177
+ const exponent = fromMoveI64(float.exp) - 52;
165
178
  const magnitude = Number(mantissa) * Math.pow(2, exponent);
166
179
  return float.is_negative ? -magnitude : magnitude;
167
180
  }
168
181
  function normalizeGameDetailValue(valueType, parsed) {
169
182
  if (valueType === "float") {
170
- return parseFloat(parsed);
183
+ return fromMoveFloat(parsed);
171
184
  }
172
185
  if (valueType === "u64") {
173
186
  return Number(parsed);
@@ -201,8 +214,8 @@ exports.DEFAULT_GAS_BUDGET_MIST = DEFAULT_GAS_BUDGET_MIST;
201
214
  exports.DEFAULT_LIMBO_MULTIPLIER_SCALE = DEFAULT_LIMBO_MULTIPLIER_SCALE;
202
215
  exports.DEFAULT_RANGE_SCALE = DEFAULT_RANGE_SCALE;
203
216
  exports.RANGE_POINT_LIMIT = RANGE_POINT_LIMIT;
204
- exports.parseFloat = parseFloat;
217
+ exports.fromMoveFloat = fromMoveFloat;
218
+ exports.fromMoveI64 = fromMoveI64;
205
219
  exports.parseGameDetails = parseGameDetails;
206
- exports.parseI64 = parseI64;
207
- exports.toBigIntAmount = toBigIntAmount;
208
- exports.toU8Number = toU8Number;
220
+ exports.toBigInt = toBigInt;
221
+ exports.toU8 = toU8;
package/dist/utils.d.cts CHANGED
@@ -61,8 +61,8 @@ declare const DEFAULT_RANGE_SCALE = 1000000;
61
61
  declare const RANGE_POINT_LIMIT: number;
62
62
  declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
63
 
64
- declare function toBigIntAmount(value: bigint | number, fieldName: string): bigint;
65
- declare function toU8Number(value: number, fieldName: string): number;
64
+ declare function toBigInt(value: unknown): bigint;
65
+ declare function toU8(value: unknown): number;
66
66
 
67
67
  declare const Float: MoveStruct<{
68
68
  is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -72,8 +72,9 @@ declare const Float: MoveStruct<{
72
72
  mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
73
73
  }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
74
74
 
75
- declare function parseI64(i64: ReturnType<(typeof Float)['parse']>['exp']): number;
76
- declare function parseFloat(float: ReturnType<(typeof Float)['parse']>): number;
75
+ type MoveFloat = ReturnType<(typeof Float)['parse']>;
76
+ declare function fromMoveI64(i64: MoveFloat['exp']): number;
77
+ declare function fromMoveFloat(float: MoveFloat): number;
77
78
  declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
78
79
 
79
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, parseFloat, parseGameDetails, parseI64, toBigIntAmount, toU8Number };
80
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseGameDetails, toBigInt, toU8 };
package/dist/utils.d.ts CHANGED
@@ -61,8 +61,8 @@ declare const DEFAULT_RANGE_SCALE = 1000000;
61
61
  declare const RANGE_POINT_LIMIT: number;
62
62
  declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
63
 
64
- declare function toBigIntAmount(value: bigint | number, fieldName: string): bigint;
65
- declare function toU8Number(value: number, fieldName: string): number;
64
+ declare function toBigInt(value: unknown): bigint;
65
+ declare function toU8(value: unknown): number;
66
66
 
67
67
  declare const Float: MoveStruct<{
68
68
  is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
@@ -72,8 +72,9 @@ declare const Float: MoveStruct<{
72
72
  mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
73
73
  }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
74
74
 
75
- declare function parseI64(i64: ReturnType<(typeof Float)['parse']>['exp']): number;
76
- declare function parseFloat(float: ReturnType<(typeof Float)['parse']>): number;
75
+ type MoveFloat = ReturnType<(typeof Float)['parse']>;
76
+ declare function fromMoveI64(i64: MoveFloat['exp']): number;
77
+ declare function fromMoveFloat(float: MoveFloat): number;
77
78
  declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
78
79
 
79
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, parseFloat, parseGameDetails, parseI64, toBigIntAmount, toU8Number };
80
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseGameDetails, toBigInt, toU8 };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, parseFloat, parseGameDetails, parseI64, toBigIntAmount, toU8Number } from './chunk-W3WZ2BHO.js';
1
+ export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseGameDetails, toBigInt, toU8 } from './chunk-YGYMLRE4.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suigar/sdk",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
5
5
  "keywords": [
6
6
  "suigar",
@@ -91,20 +91,5 @@
91
91
  "typescript": "^5.9.3",
92
92
  "typescript-eslint": "^8.59.0",
93
93
  "vitest": "^4.1.5"
94
- },
95
- "lint-staged": {
96
- "{src,test,scripts}/**/*.{ts,tsx,js,mjs,cjs}": [
97
- "eslint --fix",
98
- "prettier --write"
99
- ],
100
- "./*.{ts,tsx,js,mjs,cjs}": [
101
- "eslint --fix",
102
- "prettier --write"
103
- ],
104
- "examples/game-integration/**/*.{ts,tsx,js,mjs,cjs}": [
105
- "npm --prefix examples/game-integration exec eslint -- --fix",
106
- "prettier --write"
107
- ],
108
- "*.{json,md,yml,yaml}": "prettier --write"
109
94
  }
110
95
  }