@suigar/sdk 2.0.0-beta.2 → 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 +7 -0
- package/README.md +25 -18
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## 2.0.0-beta.2
|
|
4
11
|
|
|
5
12
|
### Patch 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
|
-
-
|
|
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,7 +31,7 @@ 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
|
|
34
|
+
const client = new SuiGrpcClient({ baseUrl, network }).$extend(suigar());
|
|
31
35
|
|
|
32
36
|
client.suigar.serializeTransactionToBase64(...);
|
|
33
37
|
client.suigar.getConfig();
|
|
@@ -38,11 +42,12 @@ client.suigar.tx;
|
|
|
38
42
|
## Quick Start
|
|
39
43
|
|
|
40
44
|
```ts
|
|
41
|
-
import {
|
|
45
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
42
46
|
import { suigar } from '@suigar/sdk';
|
|
43
47
|
|
|
44
|
-
const client = new
|
|
45
|
-
|
|
48
|
+
const client = new SuiGrpcClient({
|
|
49
|
+
baseUrl: 'https://fullnode.testnet.sui.io:443',
|
|
50
|
+
network: 'testnet',
|
|
46
51
|
}).$extend(suigar());
|
|
47
52
|
|
|
48
53
|
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
@@ -62,7 +67,7 @@ const base64 = await client.suigar.serializeTransactionToBase64(tx);
|
|
|
62
67
|
Creates a named Sui client extension. By default, it registers under `client.suigar`.
|
|
63
68
|
|
|
64
69
|
```ts
|
|
65
|
-
const client = new
|
|
70
|
+
const client = new SuiGrpcClient({ baseUrl, network }).$extend(suigar());
|
|
66
71
|
|
|
67
72
|
client.suigar;
|
|
68
73
|
```
|
|
@@ -70,10 +75,12 @@ client.suigar;
|
|
|
70
75
|
You can rename the extension:
|
|
71
76
|
|
|
72
77
|
```ts
|
|
73
|
-
const client = new
|
|
78
|
+
const client = new SuiGrpcClient({ baseUrl, network }).$extend(
|
|
79
|
+
suigar({ name: 'games' }),
|
|
80
|
+
);
|
|
74
81
|
|
|
75
|
-
client.
|
|
76
|
-
client.
|
|
82
|
+
client.games.tx;
|
|
83
|
+
client.games.bcs;
|
|
77
84
|
```
|
|
78
85
|
|
|
79
86
|
## Config
|
|
@@ -83,7 +90,7 @@ client.casino.bcs;
|
|
|
83
90
|
- internal package ids by network
|
|
84
91
|
- internal supported coin types by network
|
|
85
92
|
- internal price info object ids by network
|
|
86
|
-
- the connected
|
|
93
|
+
- the connected client network
|
|
87
94
|
- the extension name
|
|
88
95
|
|
|
89
96
|
Supported override areas:
|
|
@@ -295,14 +302,13 @@ const finalResult = await client.core.waitForTransaction({
|
|
|
295
302
|
},
|
|
296
303
|
});
|
|
297
304
|
|
|
298
|
-
if (finalResult
|
|
299
|
-
|
|
300
|
-
} else if (finalResult.FailedTransaction) {
|
|
301
|
-
throw new Error(finalResult.FailedTransaction.status.error.message);
|
|
305
|
+
if (finalResult.$kind === 'FailedTransaction') {
|
|
306
|
+
throw new Error(finalResult.FailedTransaction.status.error?.message);
|
|
302
307
|
}
|
|
303
308
|
|
|
304
|
-
|
|
305
|
-
|
|
309
|
+
console.log(finalResult.Transaction.digest);
|
|
310
|
+
|
|
311
|
+
const transactionResult = finalResult.Transaction;
|
|
306
312
|
|
|
307
313
|
const betResults = [];
|
|
308
314
|
|
|
@@ -343,7 +349,8 @@ const metadata = new Map(
|
|
|
343
349
|
Important:
|
|
344
350
|
|
|
345
351
|
- execute or wait for the transaction with `include: { events: true }`
|
|
346
|
-
-
|
|
352
|
+
- unwrap the core API union with `result.$kind`, `result.Transaction`, and `result.FailedTransaction`
|
|
353
|
+
- parse emitted events from the unwrapped transaction result
|
|
347
354
|
- use `event.bcs` for consistent decoding across transports
|
|
348
355
|
- `waitForTransaction({ result, include: { effects: true, events: true } })` is useful when you want the finalized transaction result before decoding
|
|
349
356
|
- these helpers decode the event payload itself, not a full transaction response
|
package/dist/index.d.cts
CHANGED
|
@@ -105,7 +105,8 @@ type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOpti
|
|
|
105
105
|
};
|
|
106
106
|
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
107
107
|
|
|
108
|
-
type
|
|
108
|
+
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
109
|
+
type BuildGameOptions<GameId extends StandardGame> = GameId extends 'coinflip' ? WithoutConfig<BuildCoinflipTransactionOptions> : GameId extends 'wheel' ? WithoutConfig<BuildWheelTransactionOptions> : GameId extends 'limbo' ? WithoutConfig<BuildLimboTransactionOptions> : GameId extends 'plinko' ? WithoutConfig<BuildPlinkoTransactionOptions> : GameId extends 'range' ? WithoutConfig<BuildRangeTransactionOptions> : never;
|
|
109
110
|
|
|
110
111
|
declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
|
|
111
112
|
name: Name;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,7 +105,8 @@ type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOpti
|
|
|
105
105
|
};
|
|
106
106
|
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
107
107
|
|
|
108
|
-
type
|
|
108
|
+
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
109
|
+
type BuildGameOptions<GameId extends StandardGame> = GameId extends 'coinflip' ? WithoutConfig<BuildCoinflipTransactionOptions> : GameId extends 'wheel' ? WithoutConfig<BuildWheelTransactionOptions> : GameId extends 'limbo' ? WithoutConfig<BuildLimboTransactionOptions> : GameId extends 'plinko' ? WithoutConfig<BuildPlinkoTransactionOptions> : GameId extends 'range' ? WithoutConfig<BuildRangeTransactionOptions> : never;
|
|
109
110
|
|
|
110
111
|
declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
|
|
111
112
|
name: Name;
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suigar/sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"suigar",
|
|
7
|
+
"sui",
|
|
8
|
+
"sui-sdk",
|
|
9
|
+
"typescript",
|
|
10
|
+
"move",
|
|
11
|
+
"web3",
|
|
12
|
+
"games"
|
|
13
|
+
],
|
|
5
14
|
"license": "Apache-2.0",
|
|
6
15
|
"type": "module",
|
|
7
16
|
"sideEffects": false,
|