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

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,30 @@
1
1
  # @suigar/sdk
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 128cb6c: - `suigar()` now only accepts the extension `name`.
8
+ - The SDK now validates the connected client network and supports `mainnet` and `testnet`.
9
+ - Added `client.suigar.getConfig()` to inspect the resolved network config at runtime.
10
+ - Exported the `SuiNetwork` type and `resolveGamePackageId()` helper.
11
+ - Reworked `SuigarConfig` into a network-resolved structure with `packageIds`, `coinTypes`, and `priceInfoObjectIds`.
12
+ - Replaced the old Pyth-specific price object resolution flow with supported-coin-based `priceInfoObjectId` resolution.
13
+ - Split package and coin configuration into explicit `mainnet` and `testnet` maps and updated transaction builders to use the new structure.
14
+ - Updated generated event helpers, tests, and documentation to match the new configuration and event parsing flow.
15
+
16
+ Notes:
17
+ - Existing prerelease integrations using `suigar({ ...configOverrides })` will need to migrate to `suigar()`.
18
+ - Runtime config inspection should now use `client.suigar.getConfig()`.
19
+
20
+ ## 2.0.0-beta.1
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated the npm release workflows to install dependencies without a committed lockfile and removed the obsolete Node.js cache configuration.
25
+ - Simplified previous-release deprecation logic so prerelease publishes do not attempt to deprecate earlier npm versions.
26
+ - Stopped tracking `package-lock.json` and removed the obsolete changeset file after the version bump.
27
+
3
28
  ## 2.0.0-beta.0
4
29
 
5
30
  ### Major Changes
package/README.md CHANGED
@@ -30,6 +30,7 @@ What you actually use at runtime is the registered extension instance:
30
30
  const client = new SuiClient({ url }).$extend(suigar());
31
31
 
32
32
  client.suigar.serializeTransactionToBase64(...);
33
+ client.suigar.getConfig();
33
34
  client.suigar.bcs;
34
35
  client.suigar.tx;
35
36
  ```
@@ -42,14 +43,7 @@ import { suigar } from '@suigar/sdk';
42
43
 
43
44
  const client = new SuiClient({
44
45
  url: getFullnodeUrl('testnet'),
45
- }).$extend(
46
- suigar({
47
- pyth: {
48
- suiPriceInfoObjectId: '0xPYTH_SUI_PRICE_INFO',
49
- usdcPriceInfoObjectId: '0xPYTH_USDC_PRICE_INFO',
50
- },
51
- }),
52
- );
46
+ }).$extend(suigar());
53
47
 
54
48
  const tx = client.suigar.tx.createBetTransaction('coinflip', {
55
49
  owner: '0x123',
@@ -86,59 +80,43 @@ client.casino.bcs;
86
80
 
87
81
  `suigar(options?)` resolves config from:
88
82
 
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
83
+ - internal package ids by network
84
+ - internal supported coin types by network
85
+ - internal price info object ids by network
86
+ - the connected Sui client network
87
+ - the extension name
94
88
 
95
89
  Supported override areas:
96
90
 
97
91
  - `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
92
 
134
93
  ## Runtime Surface
135
94
 
136
95
  The registered extension instance exposes three main areas:
137
96
 
97
+ - `getConfig()`
138
98
  - `serializeTransactionToBase64(transaction, options?)`
139
99
  - `bcs`
140
100
  - `tx`
141
101
 
102
+ ### `getConfig()`
103
+
104
+ Returns the resolved SDK configuration for the connected network.
105
+
106
+ This is intended mainly for debugging and inspection, for example to verify the
107
+ resolved package ids or supported coin mappings for the active client network.
108
+
109
+ It includes:
110
+
111
+ - `packageIds`
112
+ - `coinTypes`
113
+ - `priceInfoObjectIds`
114
+
115
+ ```ts
116
+ const config = client.suigar.getConfig();
117
+ console.log(config.packageIds);
118
+ ```
119
+
142
120
  ### `serializeTransactionToBase64(transaction, options?)`
143
121
 
144
122
  Builds a transaction with the configured Sui client and returns base64-encoded transaction bytes.
@@ -191,7 +169,7 @@ Shared behavior:
191
169
  - `betCount` defaults to `1`
192
170
  - `sender` overrides the transaction sender
193
171
  - `metadata` is encoded into `keys` and `values` byte arrays
194
- - the SDK resolves the Pyth price info object from the configured coin mapping
172
+ - the SDK resolves the price info object from the configured supported-coin mapping
195
173
  - the reward object is transferred back to `owner`
196
174
 
197
175
  Per-game options:
@@ -296,19 +274,46 @@ Current exposed helpers:
296
274
  - `PvPCoinflipGameResolved`
297
275
  - `PvPCoinflipGameCancelled`
298
276
 
299
- These are generated Move struct/event decoders. Use them to parse Suigar event payloads and structured onchain content.
277
+ These are generated Move event decoders. Use them to parse Suigar event payloads from transaction results.
300
278
 
301
279
  ### Parse Standard Bet Result Data
302
280
 
303
281
  ```ts
304
- const { object } = await client.core.getObject({
305
- objectId: '0xOBJECT_ID',
282
+ const executeResult = await client.core.executeTransaction({
283
+ transaction: transactionBytes,
284
+ signatures: [signature],
285
+ include: {
286
+ events: true,
287
+ },
288
+ });
289
+
290
+ const finalResult = await client.core.waitForTransaction({
291
+ result: executeResult,
306
292
  include: {
307
- content: true,
293
+ effects: true,
294
+ events: true,
308
295
  },
309
296
  });
310
297
 
311
- const decoded = client.suigar.bcs.BetResultEvent.parse(object.content);
298
+ if (finalResult.Transaction) {
299
+ console.log(finalResult.Transaction.digest);
300
+ } else if (finalResult.FailedTransaction) {
301
+ throw new Error(finalResult.FailedTransaction.status.error.message);
302
+ }
303
+
304
+ const transactionResult =
305
+ finalResult.Transaction ?? finalResult.FailedTransaction;
306
+
307
+ const betResults = [];
308
+
309
+ for (const event of transactionResult.events ?? []) {
310
+ try {
311
+ const decoded = client.suigar.bcs.BetResultEvent.parse(event.bcs);
312
+ betResults.push(decoded);
313
+ } catch {
314
+ // Ignore non-BetResultEvent payloads.
315
+ }
316
+ }
312
317
  ```
313
318
 
314
319
  Parsed fields include:
@@ -337,12 +342,15 @@ const metadata = new Map(
337
342
 
338
343
  Important:
339
344
 
340
- - use `content`, not `objectBcs`, with these generated parsers
341
- - the generated parser expects the struct payload, not a full object envelope
345
+ - execute or wait for the transaction with `include: { events: true }`
346
+ - parse emitted events from `result.Transaction.events` or `result.FailedTransaction.events`
347
+ - use `event.bcs` for consistent decoding across transports
348
+ - `waitForTransaction({ result, include: { effects: true, events: true } })` is useful when you want the finalized transaction result before decoding
349
+ - these helpers decode the event payload itself, not a full transaction response
342
350
 
343
351
  ### Parse PvP Coinflip Event Data
344
352
 
345
- Use the matching helper for the PvP coinflip event payload you fetched from chain:
353
+ Use the matching helper for each PvP coinflip event payload found in `transactionResult.events`:
346
354
 
347
355
  - `client.suigar.bcs.PvPCoinflipGameCreated`
348
356
  - `client.suigar.bcs.PvPCoinflipGameResolved`