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

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,22 @@
1
1
  # @suigar/sdk
2
2
 
3
+ ## 2.0.0-beta.6
4
+
5
+ ### Patch Changes
6
+
7
+ - ef6bcd4: Rename getPvPCoinflipGames option from rejectOnError to throwOnError.
8
+
9
+ ## 2.0.0-beta.5
10
+
11
+ ### Patch Changes
12
+
13
+ - bf98e0a: Update PvP coinflip registry lookups so `getPvPCoinflipGames()` can skip
14
+ individual game resolution failures by default while still supporting
15
+ `rejectOnError: true` for strict rejection.
16
+ - Document the `rejectOnError` behavior in the public JSDoc and README examples.
17
+ - Clarify repo guidance and skill documentation to distinguish general PvP game
18
+ guidance from the current PvP coinflip-specific runtime surface.
19
+
3
20
  ## 2.0.0-beta.4
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -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
- > [!IMPORTANT]
113
- > `partner` is the partner wallet address. Configure it once when you
114
- > register the extension so the SDK can append that wallet address to supported
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(
@@ -208,6 +207,10 @@ the Move flow removes it from the registry and deletes the live `Game` object.
208
207
  Use this when a product needs the current set of open PvP coinflip matches for
209
208
  browsing or lobby views.
210
209
 
210
+ By default, failures to resolve an individual game are skipped so one broken or
211
+ already-deleted registry entry does not reject the full lookup. Pass
212
+ `throwOnError: true` if you want the call to reject instead.
213
+
211
214
  ```ts
212
215
  const games = await client.suigar.getPvPCoinflipGames({ limit: 20 });
213
216
 
@@ -217,6 +220,13 @@ for (const game of games) {
217
220
  }
218
221
  ```
219
222
 
223
+ ```ts
224
+ const games = await client.suigar.getPvPCoinflipGames({
225
+ limit: 20,
226
+ throwOnError: true,
227
+ });
228
+ ```
229
+
220
230
  ### `resolvePvPConflipGame(gameId)`
221
231
 
222
232
  Fetches a PvP coinflip game object from chain and parses it into the SDK's
@@ -239,14 +249,14 @@ console.log(game.stake_per_player);
239
249
  console.log(game.is_private);
240
250
  ```
241
251
 
242
- > [!NOTE]
252
+ > **Note:**
243
253
  >
244
254
  > - it throws if the object response does not include decodable `content`
245
255
  > - the PvP join builder uses this internally to derive the required join stake
246
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
247
257
 
248
- > [!TIP]
249
- > Prefer this helper over manual object parsing when you only need the parsed state for a live PvP game object.
258
+ > **Tip:** Prefer this helper over manual object parsing when you only need the
259
+ > parsed state for a live PvP coinflip game object.
250
260
 
251
261
  ## `tx`
252
262
 
@@ -323,7 +333,7 @@ const rangeTx = client.suigar.tx.createBetTransaction('range', {
323
333
  });
324
334
  ```
325
335
 
326
- > [!NOTE]
336
+ > **Note:**
327
337
  >
328
338
  > - limbo converts `targetMultiplier` with `Math.round(targetMultiplier * scale)`
329
339
  > - with the default limbo scale `100`, exposed as `DEFAULT_LIMBO_MULTIPLIER_SCALE`, a target multiplier of `2.5` becomes `250` onchain
@@ -332,7 +342,7 @@ const rangeTx = client.suigar.tx.createBetTransaction('range', {
332
342
  > - with the default range scale `1_000_000`, exposed as `DEFAULT_RANGE_SCALE`, valid UI values are `0` to `100`
333
343
  > - plinko and wheel `configId` must fit in `u8`
334
344
 
335
- > [!TIP]
345
+ > **Tip:**
336
346
  >
337
347
  > - if you set `scale` to `10_000_000`, valid UI values become `0` to `10`
338
348
  > - do not pre-scale range points before passing them to the SDK; pass the human value and let the SDK scale it once
@@ -501,7 +511,7 @@ const gameDetails = parseGameDetails(decoded.game_details);
501
511
  When the extension is configured with `partner`, decoded event `metadata` will
502
512
  contain that partner wallet address under the `partner` entry.
503
513
 
504
- > [!IMPORTANT]
514
+ > **Important:**
505
515
  >
506
516
  > - execute or wait for the transaction with `include: { events: true }`
507
517
  > - unwrap the core API union with `result.$kind`, `result.Transaction`, and `result.FailedTransaction`
@@ -509,7 +519,7 @@ contain that partner wallet address under the `partner` entry.
509
519
  > - use `event.bcs` for consistent decoding across transports
510
520
  > - use `parseGameDetails(decoded.game_details)` instead of hand-decoding standard game detail byte arrays
511
521
 
512
- > [!TIP]
522
+ > **Tip:**
513
523
  >
514
524
  > - `waitForTransaction({ result, include: { effects: true, events: true } })` is useful when you want the finalized transaction result before decoding
515
525
  > - these helpers decode the event payload itself, not a full transaction response
@@ -537,10 +547,12 @@ This repository now includes a Next.js integration example in [examples/game-int
537
547
  It demonstrates:
538
548
 
539
549
  - standard game transactions through `client.suigar.tx.createBetTransaction(...)`
540
- - PvP coinflip create, join, and cancel flows through `client.suigar.tx.createPvPCoinflipTransaction(...)`, exposed in the example through a PvP game selector ready for future PvP games
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
541
552
  - wallet connection and execution with `@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`
542
553
  - supported coin selection from `client.suigar.getConfig()`
543
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
544
556
  - decoding `BetResultEvent` and PvP events into a persistent event log
545
557
  - parsing `BetResultEvent.game_details` with `parseGameDetails`
546
558
 
@@ -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-nFnPbPuK.cjs';
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-nFnPbPuK.js';
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
@@ -1014,18 +1014,32 @@ var SuigarClient = class {
1014
1014
  * browsing or lobby views.
1015
1015
  *
1016
1016
  * @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
1017
- * @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
1017
+ * Pass `throwOnError: true` to fail the whole lookup when any referenced game
1018
+ * cannot be resolved. By default, failed game resolutions are skipped and only
1019
+ * successfully parsed unresolved games are returned.
1020
+ * @returns Parsed unresolved PvP coinflip game objects for the requested
1021
+ * registry page. When `throwOnError` is `false`, entries that fail
1022
+ * `resolvePvPConflipGame()` are omitted from the returned array.
1018
1023
  */
1019
1024
  async getPvPCoinflipGames(options = {
1020
1025
  limit: 50
1021
1026
  }) {
1027
+ const { throwOnError = false, ...listOptions } = options;
1022
1028
  const { dynamicFields } = await this.#client.core.listDynamicFields({
1023
1029
  parentId: this.#config.registryIds.pvpCoinflip,
1024
- ...options
1030
+ ...listOptions
1025
1031
  });
1026
- return await Promise.all(
1032
+ if (throwOnError) {
1033
+ return Promise.all(
1034
+ dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
1035
+ );
1036
+ }
1037
+ const settledGames = await Promise.allSettled(
1027
1038
  dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
1028
1039
  );
1040
+ return settledGames.flatMap(
1041
+ (result) => result.status === "fulfilled" ? [result.value] : []
1042
+ );
1029
1043
  }
1030
1044
  /**
1031
1045
  * Fetches a PvP coinflip game object from chain and parses it into the SDK's
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-nFnPbPuK.cjs';
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,9 +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
- * @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
55
+ * Pass `throwOnError: true` to fail the whole lookup when any referenced game
56
+ * cannot be resolved. By default, failed game resolutions are skipped and only
57
+ * successfully parsed unresolved games are returned.
58
+ * @returns Parsed unresolved PvP coinflip game objects for the requested
59
+ * registry page. When `throwOnError` is `false`, entries that fail
60
+ * `resolvePvPConflipGame()` are omitted from the returned array.
56
61
  */
57
- getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>): Promise<{
62
+ getPvPCoinflipGames(options?: WithThrowOnError<Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>>): Promise<{
58
63
  coinType: string;
59
64
  id: string;
60
65
  creator: string;
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-nFnPbPuK.js';
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,9 +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
- * @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
55
+ * Pass `throwOnError: true` to fail the whole lookup when any referenced game
56
+ * cannot be resolved. By default, failed game resolutions are skipped and only
57
+ * successfully parsed unresolved games are returned.
58
+ * @returns Parsed unresolved PvP coinflip game objects for the requested
59
+ * registry page. When `throwOnError` is `false`, entries that fail
60
+ * `resolvePvPConflipGame()` are omitted from the returned array.
56
61
  */
57
- getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>): Promise<{
62
+ getPvPCoinflipGames(options?: WithThrowOnError<Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>>): Promise<{
58
63
  coinType: string;
59
64
  id: string;
60
65
  creator: string;
package/dist/index.js CHANGED
@@ -839,18 +839,32 @@ 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
- * @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
842
+ * Pass `throwOnError: true` to fail the whole lookup when any referenced game
843
+ * cannot be resolved. By default, failed game resolutions are skipped and only
844
+ * successfully parsed unresolved games are returned.
845
+ * @returns Parsed unresolved PvP coinflip game objects for the requested
846
+ * registry page. When `throwOnError` is `false`, entries that fail
847
+ * `resolvePvPConflipGame()` are omitted from the returned array.
843
848
  */
844
849
  async getPvPCoinflipGames(options = {
845
850
  limit: 50
846
851
  }) {
852
+ const { throwOnError = false, ...listOptions } = options;
847
853
  const { dynamicFields } = await this.#client.core.listDynamicFields({
848
854
  parentId: this.#config.registryIds.pvpCoinflip,
849
- ...options
855
+ ...listOptions
850
856
  });
851
- return await Promise.all(
857
+ if (throwOnError) {
858
+ return Promise.all(
859
+ dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
860
+ );
861
+ }
862
+ const settledGames = await Promise.allSettled(
852
863
  dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
853
864
  );
865
+ return settledGames.flatMap(
866
+ (result) => result.status === "fulfilled" ? [result.value] : []
867
+ );
854
868
  }
855
869
  /**
856
870
  * Fetches a PvP coinflip game object from chain and parses it into the SDK's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suigar/sdk",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
5
5
  "keywords": [
6
6
  "suigar",