@suigar/sdk 2.0.0-beta.5 → 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 +12 -0
- package/README.md +27 -26
- package/dist/{chunk-W3WZ2BHO.js → chunk-YGYMLRE4.js} +25 -12
- package/dist/{games-nFnPbPuK.d.cts → games--Haw_z7M.d.cts} +4 -1
- package/dist/{games-nFnPbPuK.d.ts → games--Haw_z7M.d.ts} +4 -1
- package/dist/games.d.cts +1 -1
- package/dist/games.d.ts +1 -1
- package/dist/index.cjs +33 -20
- package/dist/index.d.cts +7 -9
- package/dist/index.d.ts +7 -9
- package/dist/index.js +14 -14
- package/dist/utils.cjs +28 -15
- package/dist/utils.d.cts +6 -5
- package/dist/utils.d.ts +6 -5
- package/dist/utils.js +1 -1
- package/package.json +1 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 2.0.0-beta.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ef6bcd4: Rename getPvPCoinflipGames option from rejectOnError to throwOnError.
|
|
14
|
+
|
|
3
15
|
## 2.0.0-beta.5
|
|
4
16
|
|
|
5
17
|
### 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
|
-
|
|
45
|
+
fromMoveFloat,
|
|
46
|
+
fromMoveI64,
|
|
46
47
|
parseGameDetails,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
toU8Number,
|
|
48
|
+
toBigInt,
|
|
49
|
+
toU8,
|
|
50
50
|
} from '@suigar/sdk/utils';
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -109,10 +109,9 @@ Creates a named Sui client extension. By default, it registers under `client.sui
|
|
|
109
109
|
|
|
110
110
|
### Partner Setup
|
|
111
111
|
|
|
112
|
-
>
|
|
113
|
-
>
|
|
114
|
-
>
|
|
115
|
-
> bet metadata automatically.
|
|
112
|
+
> **Important:** `partner` is the partner wallet address. Configure it once
|
|
113
|
+
> when you register the extension so the SDK can append that wallet address to
|
|
114
|
+
> supported bet metadata automatically.
|
|
116
115
|
|
|
117
116
|
```ts
|
|
118
117
|
const client = new SuiGrpcClient({ baseUrl, network }).$extend(
|
|
@@ -210,7 +209,7 @@ browsing or lobby views.
|
|
|
210
209
|
|
|
211
210
|
By default, failures to resolve an individual game are skipped so one broken or
|
|
212
211
|
already-deleted registry entry does not reject the full lookup. Pass
|
|
213
|
-
`
|
|
212
|
+
`throwOnError: true` if you want the call to reject instead.
|
|
214
213
|
|
|
215
214
|
```ts
|
|
216
215
|
const games = await client.suigar.getPvPCoinflipGames({ limit: 20 });
|
|
@@ -224,7 +223,7 @@ for (const game of games) {
|
|
|
224
223
|
```ts
|
|
225
224
|
const games = await client.suigar.getPvPCoinflipGames({
|
|
226
225
|
limit: 20,
|
|
227
|
-
|
|
226
|
+
throwOnError: true,
|
|
228
227
|
});
|
|
229
228
|
```
|
|
230
229
|
|
|
@@ -250,14 +249,14 @@ console.log(game.stake_per_player);
|
|
|
250
249
|
console.log(game.is_private);
|
|
251
250
|
```
|
|
252
251
|
|
|
253
|
-
>
|
|
252
|
+
> **Note:**
|
|
254
253
|
>
|
|
255
254
|
> - it throws if the object response does not include decodable `content`
|
|
256
255
|
> - the PvP join builder uses this internally to derive the required join stake
|
|
257
|
-
> - after a game is joined and resolved, the live `Game` object is removed from the registry and deleted, so inspect `
|
|
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
|
|
258
257
|
|
|
259
|
-
>
|
|
260
|
-
>
|
|
258
|
+
> **Tip:** Prefer this helper over manual object parsing when you only need the
|
|
259
|
+
> parsed state for a live PvP coinflip game object.
|
|
261
260
|
|
|
262
261
|
## `tx`
|
|
263
262
|
|
|
@@ -334,7 +333,7 @@ const rangeTx = client.suigar.tx.createBetTransaction('range', {
|
|
|
334
333
|
});
|
|
335
334
|
```
|
|
336
335
|
|
|
337
|
-
>
|
|
336
|
+
> **Note:**
|
|
338
337
|
>
|
|
339
338
|
> - limbo converts `targetMultiplier` with `Math.round(targetMultiplier * scale)`
|
|
340
339
|
> - with the default limbo scale `100`, exposed as `DEFAULT_LIMBO_MULTIPLIER_SCALE`, a target multiplier of `2.5` becomes `250` onchain
|
|
@@ -343,7 +342,7 @@ const rangeTx = client.suigar.tx.createBetTransaction('range', {
|
|
|
343
342
|
> - with the default range scale `1_000_000`, exposed as `DEFAULT_RANGE_SCALE`, valid UI values are `0` to `100`
|
|
344
343
|
> - plinko and wheel `configId` must fit in `u8`
|
|
345
344
|
|
|
346
|
-
>
|
|
345
|
+
> **Tip:**
|
|
347
346
|
>
|
|
348
347
|
> - if you set `scale` to `10_000_000`, valid UI values become `0` to `10`
|
|
349
348
|
> - do not pre-scale range points before passing them to the SDK; pass the human value and let the SDK scale it once
|
|
@@ -414,15 +413,15 @@ Current exposed helpers:
|
|
|
414
413
|
|
|
415
414
|
- `PvPCoinflipGame`
|
|
416
415
|
- `BetResultEvent`
|
|
417
|
-
- `
|
|
418
|
-
- `
|
|
419
|
-
- `
|
|
416
|
+
- `PvPCoinflipGameCreatedEvent`
|
|
417
|
+
- `PvPCoinflipGameResolvedEvent`
|
|
418
|
+
- `PvPCoinflipGameCancelledEvent`
|
|
420
419
|
|
|
421
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:
|
|
422
421
|
|
|
423
422
|
- `PvPCoinflipGame` parses a PvP coinflip game object's `content`
|
|
424
|
-
- `
|
|
425
|
-
- `
|
|
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
|
|
426
425
|
- `parseGameDetails(game_details)` decodes `BetResultEvent.game_details` entries into the expected string, number, and boolean values
|
|
427
426
|
|
|
428
427
|
### Parse PvP Coinflip Game Object Data
|
|
@@ -512,7 +511,7 @@ const gameDetails = parseGameDetails(decoded.game_details);
|
|
|
512
511
|
When the extension is configured with `partner`, decoded event `metadata` will
|
|
513
512
|
contain that partner wallet address under the `partner` entry.
|
|
514
513
|
|
|
515
|
-
>
|
|
514
|
+
> **Important:**
|
|
516
515
|
>
|
|
517
516
|
> - execute or wait for the transaction with `include: { events: true }`
|
|
518
517
|
> - unwrap the core API union with `result.$kind`, `result.Transaction`, and `result.FailedTransaction`
|
|
@@ -520,7 +519,7 @@ contain that partner wallet address under the `partner` entry.
|
|
|
520
519
|
> - use `event.bcs` for consistent decoding across transports
|
|
521
520
|
> - use `parseGameDetails(decoded.game_details)` instead of hand-decoding standard game detail byte arrays
|
|
522
521
|
|
|
523
|
-
>
|
|
522
|
+
> **Tip:**
|
|
524
523
|
>
|
|
525
524
|
> - `waitForTransaction({ result, include: { effects: true, events: true } })` is useful when you want the finalized transaction result before decoding
|
|
526
525
|
> - these helpers decode the event payload itself, not a full transaction response
|
|
@@ -529,9 +528,9 @@ contain that partner wallet address under the `partner` entry.
|
|
|
529
528
|
|
|
530
529
|
Use the matching helper for each PvP coinflip event payload found in `transactionResult.events`:
|
|
531
530
|
|
|
532
|
-
- `client.suigar.bcs.
|
|
533
|
-
- `client.suigar.bcs.
|
|
534
|
-
- `client.suigar.bcs.
|
|
531
|
+
- `client.suigar.bcs.PvPCoinflipGameCreatedEvent`
|
|
532
|
+
- `client.suigar.bcs.PvPCoinflipGameResolvedEvent`
|
|
533
|
+
- `client.suigar.bcs.PvPCoinflipGameCancelledEvent`
|
|
535
534
|
|
|
536
535
|
## Development
|
|
537
536
|
|
|
@@ -549,9 +548,11 @@ It demonstrates:
|
|
|
549
548
|
|
|
550
549
|
- standard game transactions through `client.suigar.tx.createBetTransaction(...)`
|
|
551
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(...)`, 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
|
|
555
|
+
- privacy badges and copyable PvP game ids in the lobby UI
|
|
555
556
|
- decoding `BetResultEvent` and PvP events into a persistent event log
|
|
556
557
|
- parsing `BetResultEvent.game_details` with `parseGameDetails`
|
|
557
558
|
|
|
@@ -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
|
|
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(
|
|
23
|
+
throw new Error(`Value must be non-negative: ${value}`);
|
|
16
24
|
}
|
|
17
25
|
return value;
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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,
|
|
323
|
+
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, Float, MoveStruct, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, normalizeMoveArguments, parseGameDetails, toBigInt, toU8 };
|
|
@@ -39,6 +39,9 @@ type SharedBetTransactionOptions = {
|
|
|
39
39
|
allowGasCoinShortcut?: boolean;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
type WithThrowOnError<T = object> = T & {
|
|
43
|
+
throwOnError?: boolean;
|
|
44
|
+
};
|
|
42
45
|
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
43
46
|
side: CoinSide;
|
|
44
47
|
};
|
|
@@ -81,4 +84,4 @@ type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOpti
|
|
|
81
84
|
};
|
|
82
85
|
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
83
86
|
|
|
84
|
-
export type { BuildCoinflipTransactionOptions as B, CoinSide as C, PvPCoinflipAction as P, StandardGame as S, BuildWheelTransactionOptions as a, BuildLimboTransactionOptions as b, BuildPlinkoTransactionOptions as c, BuildRangeTransactionOptions as d, SuigarConfig as e, BuildPvPCoinflipTransactionOptions as f, SuigarExtensionOptions as g, BuildCancelPvPCoinflipTransactionOptions as h, BuildCreatePvPCoinflipTransactionOptions as i, BuildJoinPvPCoinflipTransactionOptions as j };
|
|
87
|
+
export type { BuildCoinflipTransactionOptions as B, CoinSide as C, PvPCoinflipAction as P, StandardGame as S, WithThrowOnError as W, BuildWheelTransactionOptions as a, BuildLimboTransactionOptions as b, BuildPlinkoTransactionOptions as c, BuildRangeTransactionOptions as d, SuigarConfig as e, BuildPvPCoinflipTransactionOptions as f, SuigarExtensionOptions as g, BuildCancelPvPCoinflipTransactionOptions as h, BuildCreatePvPCoinflipTransactionOptions as i, BuildJoinPvPCoinflipTransactionOptions as j };
|
|
@@ -39,6 +39,9 @@ type SharedBetTransactionOptions = {
|
|
|
39
39
|
allowGasCoinShortcut?: boolean;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
type WithThrowOnError<T = object> = T & {
|
|
43
|
+
throwOnError?: boolean;
|
|
44
|
+
};
|
|
42
45
|
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
43
46
|
side: CoinSide;
|
|
44
47
|
};
|
|
@@ -81,4 +84,4 @@ type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOpti
|
|
|
81
84
|
};
|
|
82
85
|
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
83
86
|
|
|
84
|
-
export type { BuildCoinflipTransactionOptions as B, CoinSide as C, PvPCoinflipAction as P, StandardGame as S, BuildWheelTransactionOptions as a, BuildLimboTransactionOptions as b, BuildPlinkoTransactionOptions as c, BuildRangeTransactionOptions as d, SuigarConfig as e, BuildPvPCoinflipTransactionOptions as f, SuigarExtensionOptions as g, BuildCancelPvPCoinflipTransactionOptions as h, BuildCreatePvPCoinflipTransactionOptions as i, BuildJoinPvPCoinflipTransactionOptions as j };
|
|
87
|
+
export type { BuildCoinflipTransactionOptions as B, CoinSide as C, PvPCoinflipAction as P, StandardGame as S, WithThrowOnError as W, BuildWheelTransactionOptions as a, BuildLimboTransactionOptions as b, BuildPlinkoTransactionOptions as c, BuildRangeTransactionOptions as d, SuigarConfig as e, BuildPvPCoinflipTransactionOptions as f, SuigarExtensionOptions as g, BuildCancelPvPCoinflipTransactionOptions as h, BuildCreatePvPCoinflipTransactionOptions as i, BuildJoinPvPCoinflipTransactionOptions as j };
|
package/dist/games.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games
|
|
1
|
+
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games--Haw_z7M.cjs';
|
package/dist/games.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games
|
|
1
|
+
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games--Haw_z7M.js';
|
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
|
|
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(
|
|
381
|
+
throw new Error(`Value must be non-negative: ${value}`);
|
|
374
382
|
}
|
|
375
383
|
return value;
|
|
376
384
|
}
|
|
377
|
-
|
|
378
|
-
|
|
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
|
|
383
|
-
|
|
384
|
-
|
|
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 =
|
|
430
|
-
const resolvedCashStake =
|
|
431
|
-
const resolvedBetCount =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
904
|
+
const configId = toU8(options.configId);
|
|
892
905
|
return buildSharedStandardGameBetTransaction({
|
|
893
906
|
...options,
|
|
894
907
|
game: "wheel",
|
|
@@ -1014,22 +1027,22 @@ var SuigarClient = class {
|
|
|
1014
1027
|
* browsing or lobby views.
|
|
1015
1028
|
*
|
|
1016
1029
|
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
1017
|
-
* Pass `
|
|
1030
|
+
* Pass `throwOnError: true` to fail the whole lookup when any referenced game
|
|
1018
1031
|
* cannot be resolved. By default, failed game resolutions are skipped and only
|
|
1019
1032
|
* successfully parsed unresolved games are returned.
|
|
1020
1033
|
* @returns Parsed unresolved PvP coinflip game objects for the requested
|
|
1021
|
-
* registry page. When `
|
|
1034
|
+
* registry page. When `throwOnError` is `false`, entries that fail
|
|
1022
1035
|
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
1023
1036
|
*/
|
|
1024
1037
|
async getPvPCoinflipGames(options = {
|
|
1025
1038
|
limit: 50
|
|
1026
1039
|
}) {
|
|
1027
|
-
const {
|
|
1040
|
+
const { throwOnError = false, ...listOptions } = options;
|
|
1028
1041
|
const { dynamicFields } = await this.#client.core.listDynamicFields({
|
|
1029
1042
|
parentId: this.#config.registryIds.pvpCoinflip,
|
|
1030
1043
|
...listOptions
|
|
1031
1044
|
});
|
|
1032
|
-
if (
|
|
1045
|
+
if (throwOnError) {
|
|
1033
1046
|
return Promise.all(
|
|
1034
1047
|
dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
|
|
1035
1048
|
);
|
|
@@ -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
|
-
|
|
1108
|
+
PvPCoinflipGameCreatedEvent: GameCreatedEvent,
|
|
1096
1109
|
/**
|
|
1097
1110
|
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
1098
1111
|
*/
|
|
1099
|
-
|
|
1112
|
+
PvPCoinflipGameResolvedEvent: GameResolvedEvent,
|
|
1100
1113
|
/**
|
|
1101
1114
|
* Event emitted when a PvP Coinflip game is cancelled.
|
|
1102
1115
|
*/
|
|
1103
|
-
|
|
1116
|
+
PvPCoinflipGameCancelledEvent: GameCancelledEvent
|
|
1104
1117
|
};
|
|
1105
1118
|
/**
|
|
1106
1119
|
* Transaction builders for Suigar games.
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { M as MoveStruct } from './index-jwSXA8q3.cjs';
|
|
|
2
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
3
|
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
5
|
-
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games
|
|
5
|
+
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, W as WithThrowOnError, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games--Haw_z7M.cjs';
|
|
6
6
|
import '@mysten/sui/bcs';
|
|
7
7
|
|
|
8
8
|
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
@@ -52,16 +52,14 @@ declare class SuigarClient {
|
|
|
52
52
|
* browsing or lobby views.
|
|
53
53
|
*
|
|
54
54
|
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
55
|
-
* Pass `
|
|
55
|
+
* Pass `throwOnError: true` to fail the whole lookup when any referenced game
|
|
56
56
|
* cannot be resolved. By default, failed game resolutions are skipped and only
|
|
57
57
|
* successfully parsed unresolved games are returned.
|
|
58
58
|
* @returns Parsed unresolved PvP coinflip game objects for the requested
|
|
59
|
-
* registry page. When `
|
|
59
|
+
* registry page. When `throwOnError` is `false`, entries that fail
|
|
60
60
|
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
61
61
|
*/
|
|
62
|
-
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'
|
|
63
|
-
rejectOnError?: boolean;
|
|
64
|
-
}): Promise<{
|
|
62
|
+
getPvPCoinflipGames(options?: WithThrowOnError<Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>>): Promise<{
|
|
65
63
|
coinType: string;
|
|
66
64
|
id: string;
|
|
67
65
|
creator: string;
|
|
@@ -209,7 +207,7 @@ declare class SuigarClient {
|
|
|
209
207
|
/**
|
|
210
208
|
* Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
|
|
211
209
|
*/
|
|
212
|
-
|
|
210
|
+
PvPCoinflipGameCreatedEvent: MoveStruct<{
|
|
213
211
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
214
212
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
215
213
|
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
@@ -224,7 +222,7 @@ declare class SuigarClient {
|
|
|
224
222
|
/**
|
|
225
223
|
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
226
224
|
*/
|
|
227
|
-
|
|
225
|
+
PvPCoinflipGameResolvedEvent: MoveStruct<{
|
|
228
226
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
229
227
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
230
228
|
joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
@@ -243,7 +241,7 @@ declare class SuigarClient {
|
|
|
243
241
|
/**
|
|
244
242
|
* Event emitted when a PvP Coinflip game is cancelled.
|
|
245
243
|
*/
|
|
246
|
-
|
|
244
|
+
PvPCoinflipGameCancelledEvent: MoveStruct<{
|
|
247
245
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
248
246
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
249
247
|
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { M as MoveStruct } from './index-jwSXA8q3.js';
|
|
|
2
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
3
|
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
5
|
-
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games
|
|
5
|
+
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, W as WithThrowOnError, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games--Haw_z7M.js';
|
|
6
6
|
import '@mysten/sui/bcs';
|
|
7
7
|
|
|
8
8
|
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
@@ -52,16 +52,14 @@ declare class SuigarClient {
|
|
|
52
52
|
* browsing or lobby views.
|
|
53
53
|
*
|
|
54
54
|
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
55
|
-
* Pass `
|
|
55
|
+
* Pass `throwOnError: true` to fail the whole lookup when any referenced game
|
|
56
56
|
* cannot be resolved. By default, failed game resolutions are skipped and only
|
|
57
57
|
* successfully parsed unresolved games are returned.
|
|
58
58
|
* @returns Parsed unresolved PvP coinflip game objects for the requested
|
|
59
|
-
* registry page. When `
|
|
59
|
+
* registry page. When `throwOnError` is `false`, entries that fail
|
|
60
60
|
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
61
61
|
*/
|
|
62
|
-
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'
|
|
63
|
-
rejectOnError?: boolean;
|
|
64
|
-
}): Promise<{
|
|
62
|
+
getPvPCoinflipGames(options?: WithThrowOnError<Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>>): Promise<{
|
|
65
63
|
coinType: string;
|
|
66
64
|
id: string;
|
|
67
65
|
creator: string;
|
|
@@ -209,7 +207,7 @@ declare class SuigarClient {
|
|
|
209
207
|
/**
|
|
210
208
|
* Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
|
|
211
209
|
*/
|
|
212
|
-
|
|
210
|
+
PvPCoinflipGameCreatedEvent: MoveStruct<{
|
|
213
211
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
214
212
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
215
213
|
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
@@ -224,7 +222,7 @@ declare class SuigarClient {
|
|
|
224
222
|
/**
|
|
225
223
|
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
226
224
|
*/
|
|
227
|
-
|
|
225
|
+
PvPCoinflipGameResolvedEvent: MoveStruct<{
|
|
228
226
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
229
227
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
230
228
|
joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
@@ -243,7 +241,7 @@ declare class SuigarClient {
|
|
|
243
241
|
/**
|
|
244
242
|
* Event emitted when a PvP Coinflip game is cancelled.
|
|
245
243
|
*/
|
|
246
|
-
|
|
244
|
+
PvPCoinflipGameCancelledEvent: MoveStruct<{
|
|
247
245
|
game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
248
246
|
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
249
247
|
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MoveStruct, Float,
|
|
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 =
|
|
255
|
-
const resolvedCashStake =
|
|
256
|
-
const resolvedBetCount =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
716
|
+
const configId = toU8(options.configId);
|
|
717
717
|
return buildSharedStandardGameBetTransaction({
|
|
718
718
|
...options,
|
|
719
719
|
game: "wheel",
|
|
@@ -839,22 +839,22 @@ var SuigarClient = class {
|
|
|
839
839
|
* browsing or lobby views.
|
|
840
840
|
*
|
|
841
841
|
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
842
|
-
* Pass `
|
|
842
|
+
* Pass `throwOnError: true` to fail the whole lookup when any referenced game
|
|
843
843
|
* cannot be resolved. By default, failed game resolutions are skipped and only
|
|
844
844
|
* successfully parsed unresolved games are returned.
|
|
845
845
|
* @returns Parsed unresolved PvP coinflip game objects for the requested
|
|
846
|
-
* registry page. When `
|
|
846
|
+
* registry page. When `throwOnError` is `false`, entries that fail
|
|
847
847
|
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
848
848
|
*/
|
|
849
849
|
async getPvPCoinflipGames(options = {
|
|
850
850
|
limit: 50
|
|
851
851
|
}) {
|
|
852
|
-
const {
|
|
852
|
+
const { throwOnError = false, ...listOptions } = options;
|
|
853
853
|
const { dynamicFields } = await this.#client.core.listDynamicFields({
|
|
854
854
|
parentId: this.#config.registryIds.pvpCoinflip,
|
|
855
855
|
...listOptions
|
|
856
856
|
});
|
|
857
|
-
if (
|
|
857
|
+
if (throwOnError) {
|
|
858
858
|
return Promise.all(
|
|
859
859
|
dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
|
|
860
860
|
);
|
|
@@ -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
|
-
|
|
920
|
+
PvPCoinflipGameCreatedEvent: GameCreatedEvent,
|
|
921
921
|
/**
|
|
922
922
|
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
923
923
|
*/
|
|
924
|
-
|
|
924
|
+
PvPCoinflipGameResolvedEvent: GameResolvedEvent,
|
|
925
925
|
/**
|
|
926
926
|
* Event emitted when a PvP Coinflip game is cancelled.
|
|
927
927
|
*/
|
|
928
|
-
|
|
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
|
|
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(
|
|
25
|
+
throw new Error(`Value must be non-negative: ${value}`);
|
|
18
26
|
}
|
|
19
27
|
return value;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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.
|
|
217
|
+
exports.fromMoveFloat = fromMoveFloat;
|
|
218
|
+
exports.fromMoveI64 = fromMoveI64;
|
|
205
219
|
exports.parseGameDetails = parseGameDetails;
|
|
206
|
-
exports.
|
|
207
|
-
exports.
|
|
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
|
|
65
|
-
declare function
|
|
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
|
-
|
|
76
|
-
declare function
|
|
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,
|
|
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
|
|
65
|
-
declare function
|
|
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
|
-
|
|
76
|
-
declare function
|
|
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,
|
|
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,
|
|
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.
|
|
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
|
}
|