@suigar/sdk 2.0.0-beta.4 → 2.0.0-beta.5
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 +11 -0
- package/README.md +13 -2
- package/dist/index.cjs +17 -3
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +17 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @suigar/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bf98e0a: Update PvP coinflip registry lookups so `getPvPCoinflipGames()` can skip
|
|
8
|
+
individual game resolution failures by default while still supporting
|
|
9
|
+
`rejectOnError: true` for strict rejection.
|
|
10
|
+
- Document the `rejectOnError` behavior in the public JSDoc and README examples.
|
|
11
|
+
- Clarify repo guidance and skill documentation to distinguish general PvP game
|
|
12
|
+
guidance from the current PvP coinflip-specific runtime surface.
|
|
13
|
+
|
|
3
14
|
## 2.0.0-beta.4
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -208,6 +208,10 @@ the Move flow removes it from the registry and deletes the live `Game` object.
|
|
|
208
208
|
Use this when a product needs the current set of open PvP coinflip matches for
|
|
209
209
|
browsing or lobby views.
|
|
210
210
|
|
|
211
|
+
By default, failures to resolve an individual game are skipped so one broken or
|
|
212
|
+
already-deleted registry entry does not reject the full lookup. Pass
|
|
213
|
+
`rejectOnError: true` if you want the call to reject instead.
|
|
214
|
+
|
|
211
215
|
```ts
|
|
212
216
|
const games = await client.suigar.getPvPCoinflipGames({ limit: 20 });
|
|
213
217
|
|
|
@@ -217,6 +221,13 @@ for (const game of games) {
|
|
|
217
221
|
}
|
|
218
222
|
```
|
|
219
223
|
|
|
224
|
+
```ts
|
|
225
|
+
const games = await client.suigar.getPvPCoinflipGames({
|
|
226
|
+
limit: 20,
|
|
227
|
+
rejectOnError: true,
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
220
231
|
### `resolvePvPConflipGame(gameId)`
|
|
221
232
|
|
|
222
233
|
Fetches a PvP coinflip game object from chain and parses it into the SDK's
|
|
@@ -246,7 +257,7 @@ console.log(game.is_private);
|
|
|
246
257
|
> - 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
258
|
|
|
248
259
|
> [!TIP]
|
|
249
|
-
> Prefer this helper over manual object parsing when you only need the parsed state for a live PvP game object.
|
|
260
|
+
> Prefer this helper over manual object parsing when you only need the parsed state for a live PvP coinflip game object.
|
|
250
261
|
|
|
251
262
|
## `tx`
|
|
252
263
|
|
|
@@ -537,7 +548,7 @@ This repository now includes a Next.js integration example in [examples/game-int
|
|
|
537
548
|
It demonstrates:
|
|
538
549
|
|
|
539
550
|
- 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
|
|
551
|
+
- PvP coinflip create, join, and cancel flows through `client.suigar.tx.createPvPCoinflipTransaction(...)`, exposed in the example through a PvP coinflip action selector
|
|
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
|
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
|
-
*
|
|
1017
|
+
* Pass `rejectOnError: 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 `rejectOnError` 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 { rejectOnError = false, ...listOptions } = options;
|
|
1022
1028
|
const { dynamicFields } = await this.#client.core.listDynamicFields({
|
|
1023
1029
|
parentId: this.#config.registryIds.pvpCoinflip,
|
|
1024
|
-
...
|
|
1030
|
+
...listOptions
|
|
1025
1031
|
});
|
|
1026
|
-
|
|
1032
|
+
if (rejectOnError) {
|
|
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
|
@@ -52,9 +52,16 @@ 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
|
-
*
|
|
55
|
+
* Pass `rejectOnError: 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 `rejectOnError` is `false`, entries that fail
|
|
60
|
+
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
56
61
|
*/
|
|
57
|
-
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>
|
|
62
|
+
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'> & {
|
|
63
|
+
rejectOnError?: boolean;
|
|
64
|
+
}): Promise<{
|
|
58
65
|
coinType: string;
|
|
59
66
|
id: string;
|
|
60
67
|
creator: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,9 +52,16 @@ 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
|
-
*
|
|
55
|
+
* Pass `rejectOnError: 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 `rejectOnError` is `false`, entries that fail
|
|
60
|
+
* `resolvePvPConflipGame()` are omitted from the returned array.
|
|
56
61
|
*/
|
|
57
|
-
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>
|
|
62
|
+
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'> & {
|
|
63
|
+
rejectOnError?: boolean;
|
|
64
|
+
}): Promise<{
|
|
58
65
|
coinType: string;
|
|
59
66
|
id: string;
|
|
60
67
|
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
|
-
*
|
|
842
|
+
* Pass `rejectOnError: 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 `rejectOnError` 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 { rejectOnError = false, ...listOptions } = options;
|
|
847
853
|
const { dynamicFields } = await this.#client.core.listDynamicFields({
|
|
848
854
|
parentId: this.#config.registryIds.pvpCoinflip,
|
|
849
|
-
...
|
|
855
|
+
...listOptions
|
|
850
856
|
});
|
|
851
|
-
|
|
857
|
+
if (rejectOnError) {
|
|
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
|