@suigar/sdk 2.0.0-beta.1 → 2.0.0-beta.3

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,37 @@
1
1
  # @suigar/sdk
2
2
 
3
+ ## 2.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e1cdedc: - Fix exported transaction option types so `BuildGameOptions` and `BuildPvPGameOptions` no longer require the internal `config` field
8
+ - Update installation and integration documentation for Sui 2.0+ by switching examples to `SuiGrpcClient`, clarifying required peer dependencies, and aligning transaction-result examples with the current client API.
9
+
10
+ ## 2.0.0-beta.2
11
+
12
+ ### Patch Changes
13
+
14
+ - 128cb6c: - `suigar()` now only accepts the extension `name`.
15
+ - The SDK now validates the connected client network and supports `mainnet` and `testnet`.
16
+ - Added `client.suigar.getConfig()` to inspect the resolved network config at runtime.
17
+ - Exported the `SuiNetwork` type and `resolveGamePackageId()` helper.
18
+ - Reworked `SuigarConfig` into a network-resolved structure with `packageIds`, `coinTypes`, and `priceInfoObjectIds`.
19
+ - Replaced the old Pyth-specific price object resolution flow with supported-coin-based `priceInfoObjectId` resolution.
20
+ - Split package and coin configuration into explicit `mainnet` and `testnet` maps and updated transaction builders to use the new structure.
21
+ - Updated generated event helpers, tests, and documentation to match the new configuration and event parsing flow.
22
+
23
+ Notes:
24
+ - Existing prerelease integrations using `suigar({ ...configOverrides })` will need to migrate to `suigar()`.
25
+ - Runtime config inspection should now use `client.suigar.getConfig()`.
26
+
27
+ ## 2.0.0-beta.1
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated the npm release workflows to install dependencies without a committed lockfile and removed the obsolete Node.js cache configuration.
32
+ - Simplified previous-release deprecation logic so prerelease publishes do not attempt to deprecate earlier npm versions.
33
+ - Stopped tracking `package-lock.json` and removed the obsolete changeset file after the version bump.
34
+
3
35
  ## 2.0.0-beta.0
4
36
 
5
37
  ### Major Changes
package/README.md CHANGED
@@ -5,13 +5,17 @@ TypeScript SDK for building Suigar v2 game transactions on Sui.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @suigar/sdk
8
+ npm install --save @suigar/sdk @mysten/sui @mysten/bcs
9
9
  ```
10
10
 
11
11
  Runtime requirements:
12
12
 
13
13
  - Node.js `>=22`
14
- - `@mysten/sui`
14
+ - ESM project configuration (`"type": "module"`)
15
+ - `@mysten/sui` v2
16
+ - `@mysten/bcs` v2
17
+
18
+ This SDK targets Sui TypeScript SDK 2.0+ only. Follow the official [Sui 2.0 migration guide](https://sdk.mystenlabs.com/sui/migrations/sui-2.0) if your app still uses the pre-2.0 client API.
15
19
 
16
20
  ## What This Package Exposes
17
21
 
@@ -27,9 +31,10 @@ It also does not export `SuigarClient` as a public root symbol.
27
31
  What you actually use at runtime is the registered extension instance:
28
32
 
29
33
  ```ts
30
- const client = new SuiClient({ url }).$extend(suigar());
34
+ const client = new SuiGrpcClient({ baseUrl, network }).$extend(suigar());
31
35
 
32
36
  client.suigar.serializeTransactionToBase64(...);
37
+ client.suigar.getConfig();
33
38
  client.suigar.bcs;
34
39
  client.suigar.tx;
35
40
  ```
@@ -37,19 +42,13 @@ client.suigar.tx;
37
42
  ## Quick Start
38
43
 
39
44
  ```ts
40
- import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
45
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
41
46
  import { suigar } from '@suigar/sdk';
42
47
 
43
- const client = new SuiClient({
44
- url: getFullnodeUrl('testnet'),
45
- }).$extend(
46
- suigar({
47
- pyth: {
48
- suiPriceInfoObjectId: '0xPYTH_SUI_PRICE_INFO',
49
- usdcPriceInfoObjectId: '0xPYTH_USDC_PRICE_INFO',
50
- },
51
- }),
52
- );
48
+ const client = new SuiGrpcClient({
49
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
50
+ network: 'testnet',
51
+ }).$extend(suigar());
53
52
 
54
53
  const tx = client.suigar.tx.createBetTransaction('coinflip', {
55
54
  owner: '0x123',
@@ -68,7 +67,7 @@ const base64 = await client.suigar.serializeTransactionToBase64(tx);
68
67
  Creates a named Sui client extension. By default, it registers under `client.suigar`.
69
68
 
70
69
  ```ts
71
- const client = new SuiClient({ url }).$extend(suigar());
70
+ const client = new SuiGrpcClient({ baseUrl, network }).$extend(suigar());
72
71
 
73
72
  client.suigar;
74
73
  ```
@@ -76,69 +75,55 @@ client.suigar;
76
75
  You can rename the extension:
77
76
 
78
77
  ```ts
79
- const client = new SuiClient({ url }).$extend(suigar({ name: 'casino' }));
78
+ const client = new SuiGrpcClient({ baseUrl, network }).$extend(
79
+ suigar({ name: 'games' }),
80
+ );
80
81
 
81
- client.casino.tx;
82
- client.casino.bcs;
82
+ client.games.tx;
83
+ client.games.bcs;
83
84
  ```
84
85
 
85
86
  ## Config
86
87
 
87
88
  `suigar(options?)` resolves config from:
88
89
 
89
- - the connected Sui network
90
- - internal default package ids
91
- - internal default SweetHouse package id by network
92
- - default coin types for `SUI`, `USDC`, and FlowX `USDC`
93
- - user overrides
90
+ - internal package ids by network
91
+ - internal supported coin types by network
92
+ - internal price info object ids by network
93
+ - the connected client network
94
+ - the extension name
94
95
 
95
96
  Supported override areas:
96
97
 
97
98
  - `name`
98
- - `sweetHousePackageId`
99
- - `coinTypes.sui`
100
- - `coinTypes.usdc`
101
- - `coinTypes.usdcFlowx`
102
- - `gamesPackageId.coinflip`
103
- - `gamesPackageId.limbo`
104
- - `gamesPackageId.plinko`
105
- - `gamesPackageId['pvp-coinflip']`
106
- - `gamesPackageId.range`
107
- - `gamesPackageId.wheel`
108
- - `pyth.packageId`
109
- - `pyth.suiPriceInfoObjectId`
110
- - `pyth.usdcPriceInfoObjectId`
111
- - `pyth.priceInfoObjectIds[coinType]`
112
-
113
- Example:
114
-
115
- ```ts
116
- const client = new SuiClient({ url }).$extend(
117
- suigar({
118
- sweetHousePackageId: '0xsweethouse',
119
- pyth: {
120
- suiPriceInfoObjectId: '0xsui',
121
- usdcPriceInfoObjectId: '0xusdc',
122
- priceInfoObjectIds: {
123
- '0x123::custom::TOKEN': '0xprice',
124
- },
125
- },
126
- gamesPackageId: {
127
- coinflip: '0xcoinflip',
128
- wheel: '0xwheel',
129
- },
130
- }),
131
- );
132
- ```
133
99
 
134
100
  ## Runtime Surface
135
101
 
136
102
  The registered extension instance exposes three main areas:
137
103
 
104
+ - `getConfig()`
138
105
  - `serializeTransactionToBase64(transaction, options?)`
139
106
  - `bcs`
140
107
  - `tx`
141
108
 
109
+ ### `getConfig()`
110
+
111
+ Returns the resolved SDK configuration for the connected network.
112
+
113
+ This is intended mainly for debugging and inspection, for example to verify the
114
+ resolved package ids or supported coin mappings for the active client network.
115
+
116
+ It includes:
117
+
118
+ - `packageIds`
119
+ - `coinTypes`
120
+ - `priceInfoObjectIds`
121
+
122
+ ```ts
123
+ const config = client.suigar.getConfig();
124
+ console.log(config.packageIds);
125
+ ```
126
+
142
127
  ### `serializeTransactionToBase64(transaction, options?)`
143
128
 
144
129
  Builds a transaction with the configured Sui client and returns base64-encoded transaction bytes.
@@ -191,7 +176,7 @@ Shared behavior:
191
176
  - `betCount` defaults to `1`
192
177
  - `sender` overrides the transaction sender
193
178
  - `metadata` is encoded into `keys` and `values` byte arrays
194
- - the SDK resolves the Pyth price info object from the configured coin mapping
179
+ - the SDK resolves the price info object from the configured supported-coin mapping
195
180
  - the reward object is transferred back to `owner`
196
181
 
197
182
  Per-game options:
@@ -296,19 +281,45 @@ Current exposed helpers:
296
281
  - `PvPCoinflipGameResolved`
297
282
  - `PvPCoinflipGameCancelled`
298
283
 
299
- These are generated Move struct/event decoders. Use them to parse Suigar event payloads and structured onchain content.
284
+ These are generated Move event decoders. Use them to parse Suigar event payloads from transaction results.
300
285
 
301
286
  ### Parse Standard Bet Result Data
302
287
 
303
288
  ```ts
304
- const { object } = await client.core.getObject({
305
- objectId: '0xOBJECT_ID',
289
+ const executeResult = await client.core.executeTransaction({
290
+ transaction: transactionBytes,
291
+ signatures: [signature],
306
292
  include: {
307
- content: true,
293
+ events: true,
308
294
  },
309
295
  });
310
296
 
311
- const decoded = client.suigar.bcs.BetResultEvent.parse(object.content);
297
+ const finalResult = await client.core.waitForTransaction({
298
+ result: executeResult,
299
+ include: {
300
+ effects: true,
301
+ events: true,
302
+ },
303
+ });
304
+
305
+ if (finalResult.$kind === 'FailedTransaction') {
306
+ throw new Error(finalResult.FailedTransaction.status.error?.message);
307
+ }
308
+
309
+ console.log(finalResult.Transaction.digest);
310
+
311
+ const transactionResult = finalResult.Transaction;
312
+
313
+ const betResults = [];
314
+
315
+ for (const event of transactionResult.events ?? []) {
316
+ try {
317
+ const decoded = client.suigar.bcs.BetResultEvent.parse(event.bcs);
318
+ betResults.push(decoded);
319
+ } catch {
320
+ // Ignore non-BetResultEvent payloads.
321
+ }
322
+ }
312
323
  ```
313
324
 
314
325
  Parsed fields include:
@@ -337,12 +348,16 @@ const metadata = new Map(
337
348
 
338
349
  Important:
339
350
 
340
- - use `content`, not `objectBcs`, with these generated parsers
341
- - the generated parser expects the struct payload, not a full object envelope
351
+ - execute or wait for the transaction with `include: { events: true }`
352
+ - unwrap the core API union with `result.$kind`, `result.Transaction`, and `result.FailedTransaction`
353
+ - parse emitted events from the unwrapped transaction result
354
+ - use `event.bcs` for consistent decoding across transports
355
+ - `waitForTransaction({ result, include: { effects: true, events: true } })` is useful when you want the finalized transaction result before decoding
356
+ - these helpers decode the event payload itself, not a full transaction response
342
357
 
343
358
  ### Parse PvP Coinflip Event Data
344
359
 
345
- Use the matching helper for the PvP coinflip event payload you fetched from chain:
360
+ Use the matching helper for each PvP coinflip event payload found in `transactionResult.events`:
346
361
 
347
362
  - `client.suigar.bcs.PvPCoinflipGameCreated`
348
363
  - `client.suigar.bcs.PvPCoinflipGameResolved`