@suigar/sdk 2.0.0-beta.5 → 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,11 @@
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
+
3
9
  ## 2.0.0-beta.5
4
10
 
5
11
  ### 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(
@@ -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
- `rejectOnError: true` if you want the call to reject instead.
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
- rejectOnError: true,
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
- > [!NOTE]
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
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
258
257
 
259
- > [!TIP]
260
- > Prefer this helper over manual object parsing when you only need the parsed state for a live PvP coinflip 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.
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
- > [!NOTE]
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
- > [!TIP]
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
@@ -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
- > [!IMPORTANT]
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
- > [!TIP]
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
@@ -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(...)`, rendered as compact join/cancel cards filtered by the connected wallet
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
 
@@ -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,22 +1014,22 @@ 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
- * Pass `rejectOnError: true` to fail the whole lookup when any referenced game
1017
+ * Pass `throwOnError: true` to fail the whole lookup when any referenced game
1018
1018
  * cannot be resolved. By default, failed game resolutions are skipped and only
1019
1019
  * successfully parsed unresolved games are returned.
1020
1020
  * @returns Parsed unresolved PvP coinflip game objects for the requested
1021
- * registry page. When `rejectOnError` is `false`, entries that fail
1021
+ * registry page. When `throwOnError` is `false`, entries that fail
1022
1022
  * `resolvePvPConflipGame()` are omitted from the returned array.
1023
1023
  */
1024
1024
  async getPvPCoinflipGames(options = {
1025
1025
  limit: 50
1026
1026
  }) {
1027
- const { rejectOnError = false, ...listOptions } = options;
1027
+ const { throwOnError = false, ...listOptions } = options;
1028
1028
  const { dynamicFields } = await this.#client.core.listDynamicFields({
1029
1029
  parentId: this.#config.registryIds.pvpCoinflip,
1030
1030
  ...listOptions
1031
1031
  });
1032
- if (rejectOnError) {
1032
+ if (throwOnError) {
1033
1033
  return Promise.all(
1034
1034
  dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
1035
1035
  );
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,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 `rejectOnError: true` to fail the whole lookup when any referenced game
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 `rejectOnError` is `false`, entries that fail
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;
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,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 `rejectOnError: true` to fail the whole lookup when any referenced game
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 `rejectOnError` is `false`, entries that fail
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;
package/dist/index.js CHANGED
@@ -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 `rejectOnError: true` to fail the whole lookup when any referenced game
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 `rejectOnError` is `false`, entries that fail
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 { rejectOnError = false, ...listOptions } = options;
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 (rejectOnError) {
857
+ if (throwOnError) {
858
858
  return Promise.all(
859
859
  dynamicFields.map(({ childId }) => this.resolvePvPConflipGame(childId))
860
860
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suigar/sdk",
3
- "version": "2.0.0-beta.5",
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",