@suigar/sdk 2.0.0-beta.0 → 2.0.0-beta.1
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/README.md +182 -176
- package/dist/index.cjs +10 -8
- package/dist/index.d.cts +10 -5
- package/dist/index.d.ts +10 -5
- package/dist/index.js +12 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for building Suigar v2 game transactions on Sui.
|
|
4
4
|
|
|
5
|
-
The published package entrypoint currently exposes:
|
|
6
|
-
|
|
7
|
-
- `suigar`
|
|
8
|
-
- `SuigarClient`
|
|
9
|
-
|
|
10
|
-
It does not currently export the individual game builder functions from the package root.
|
|
11
|
-
|
|
12
5
|
## Installation
|
|
13
6
|
|
|
14
7
|
```bash
|
|
@@ -18,42 +11,33 @@ npm install @suigar/sdk
|
|
|
18
11
|
Runtime requirements:
|
|
19
12
|
|
|
20
13
|
- Node.js `>=22`
|
|
14
|
+
- `@mysten/sui`
|
|
15
|
+
|
|
16
|
+
## What This Package Exposes
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
The package root currently exposes the extension factory:
|
|
23
19
|
|
|
24
20
|
```ts
|
|
25
21
|
import { suigar } from '@suigar/sdk';
|
|
26
22
|
```
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
It does not export the individual transaction builders from the package root.
|
|
25
|
+
It also does not export `SuigarClient` as a public root symbol.
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
What you actually use at runtime is the registered extension instance:
|
|
31
28
|
|
|
32
29
|
```ts
|
|
33
30
|
const client = new SuiClient({ url }).$extend(suigar());
|
|
34
|
-
client.suigar;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
You can rename the extension:
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
const client = new SuiClient({ url }).$extend(suigar({ name: 'casino' }));
|
|
41
31
|
|
|
42
|
-
client.
|
|
32
|
+
client.suigar.serializeTransactionToBase64(...);
|
|
33
|
+
client.suigar.bcs;
|
|
34
|
+
client.suigar.tx;
|
|
43
35
|
```
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
The registered extension instance exposes:
|
|
48
|
-
|
|
49
|
-
- `serializeTransactionToBase64(transaction)`
|
|
50
|
-
- `bcs.BetResultEvent`
|
|
51
|
-
- `tx.createBetTransaction(gameId, options)`
|
|
52
|
-
|
|
53
|
-
## Quick start
|
|
37
|
+
## Quick Start
|
|
54
38
|
|
|
55
39
|
```ts
|
|
56
|
-
import {
|
|
40
|
+
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
|
|
57
41
|
import { suigar } from '@suigar/sdk';
|
|
58
42
|
|
|
59
43
|
const client = new SuiClient({
|
|
@@ -77,9 +61,101 @@ const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
|
77
61
|
const base64 = await client.suigar.serializeTransactionToBase64(tx);
|
|
78
62
|
```
|
|
79
63
|
|
|
80
|
-
##
|
|
64
|
+
## Extension Registration
|
|
65
|
+
|
|
66
|
+
### `suigar(options?)`
|
|
67
|
+
|
|
68
|
+
Creates a named Sui client extension. By default, it registers under `client.suigar`.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const client = new SuiClient({ url }).$extend(suigar());
|
|
72
|
+
|
|
73
|
+
client.suigar;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can rename the extension:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const client = new SuiClient({ url }).$extend(suigar({ name: 'casino' }));
|
|
80
|
+
|
|
81
|
+
client.casino.tx;
|
|
82
|
+
client.casino.bcs;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Config
|
|
86
|
+
|
|
87
|
+
`suigar(options?)` resolves config from:
|
|
88
|
+
|
|
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
|
|
94
|
+
|
|
95
|
+
Supported override areas:
|
|
96
|
+
|
|
97
|
+
- `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
|
+
|
|
134
|
+
## Runtime Surface
|
|
135
|
+
|
|
136
|
+
The registered extension instance exposes three main areas:
|
|
137
|
+
|
|
138
|
+
- `serializeTransactionToBase64(transaction, options?)`
|
|
139
|
+
- `bcs`
|
|
140
|
+
- `tx`
|
|
141
|
+
|
|
142
|
+
### `serializeTransactionToBase64(transaction, options?)`
|
|
143
|
+
|
|
144
|
+
Builds a transaction with the configured Sui client and returns base64-encoded transaction bytes.
|
|
145
|
+
|
|
146
|
+
Use this when you need a transport-safe payload for a wallet, API, or external signer.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const base64 = await client.suigar.serializeTransactionToBase64(tx);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## `tx`
|
|
153
|
+
|
|
154
|
+
Transaction builders live under `client.suigar.tx`.
|
|
155
|
+
|
|
156
|
+
### Standard Games
|
|
81
157
|
|
|
82
|
-
`
|
|
158
|
+
Use `createBetTransaction(gameId, options)` for:
|
|
83
159
|
|
|
84
160
|
- `coinflip`
|
|
85
161
|
- `limbo`
|
|
@@ -87,7 +163,16 @@ const base64 = await client.suigar.serializeTransactionToBase64(tx);
|
|
|
87
163
|
- `range`
|
|
88
164
|
- `wheel`
|
|
89
165
|
|
|
90
|
-
|
|
166
|
+
```ts
|
|
167
|
+
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
168
|
+
owner: '0x123',
|
|
169
|
+
coinType: '0x2::sui::SUI',
|
|
170
|
+
stake: 1_000_000_000n,
|
|
171
|
+
side: 'tails',
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Shared option shape:
|
|
91
176
|
|
|
92
177
|
- `owner: string`
|
|
93
178
|
- `coinType: string`
|
|
@@ -101,159 +186,119 @@ All games share this base option shape:
|
|
|
101
186
|
|
|
102
187
|
Shared behavior:
|
|
103
188
|
|
|
104
|
-
- `stake` is the logical
|
|
105
|
-
- `cashStake`
|
|
189
|
+
- `stake` is the logical stake passed into the Move call
|
|
190
|
+
- `cashStake` controls the withdrawn balance and defaults to `stake`
|
|
106
191
|
- `betCount` defaults to `1`
|
|
107
192
|
- `sender` overrides the transaction sender
|
|
108
193
|
- `metadata` is encoded into `keys` and `values` byte arrays
|
|
109
|
-
- the SDK resolves the Pyth price object from the configured coin mapping
|
|
110
|
-
- the
|
|
194
|
+
- the SDK resolves the Pyth price info object from the configured coin mapping
|
|
195
|
+
- the reward object is transferred back to `owner`
|
|
111
196
|
|
|
112
|
-
|
|
197
|
+
Per-game options:
|
|
113
198
|
|
|
114
|
-
|
|
199
|
+
- `coinflip`: `side: 'heads' | 'tails'`
|
|
200
|
+
- `limbo`: `targetMultiplier: number`, `scale?: number`
|
|
201
|
+
- `plinko`: `configId: number`
|
|
202
|
+
- `range`: `leftPoint: number`, `rightPoint: number`, `outOfRange?: boolean`, `scale?: number`
|
|
203
|
+
- `wheel`: `configId: number`
|
|
115
204
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Example:
|
|
205
|
+
Examples:
|
|
119
206
|
|
|
120
207
|
```ts
|
|
121
|
-
const
|
|
208
|
+
const limboTx = client.suigar.tx.createBetTransaction('limbo', {
|
|
122
209
|
owner: '0x123',
|
|
123
210
|
coinType: '0x2::sui::SUI',
|
|
124
211
|
stake: 1_000_000_000n,
|
|
125
|
-
|
|
212
|
+
targetMultiplier: 2.5,
|
|
126
213
|
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Limbo
|
|
130
214
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- `targetMultiplier: number`
|
|
134
|
-
- `scale?: number`
|
|
135
|
-
|
|
136
|
-
Behavior:
|
|
137
|
-
|
|
138
|
-
- `scale` defaults to the SDK limbo multiplier scale
|
|
139
|
-
- `targetMultiplier` is converted with `Math.round(targetMultiplier * scale)`
|
|
140
|
-
|
|
141
|
-
Example:
|
|
142
|
-
|
|
143
|
-
```ts
|
|
144
|
-
const tx = client.suigar.tx.createBetTransaction('limbo', {
|
|
215
|
+
const rangeTx = client.suigar.tx.createBetTransaction('range', {
|
|
145
216
|
owner: '0x123',
|
|
146
217
|
coinType: '0x2::sui::SUI',
|
|
147
218
|
stake: 1_000_000_000n,
|
|
148
|
-
|
|
219
|
+
leftPoint: 0.95,
|
|
220
|
+
rightPoint: 1.05,
|
|
221
|
+
outOfRange: false,
|
|
149
222
|
});
|
|
150
223
|
```
|
|
151
224
|
|
|
152
|
-
|
|
225
|
+
Notes:
|
|
153
226
|
|
|
154
|
-
|
|
227
|
+
- limbo converts `targetMultiplier` with `Math.round(targetMultiplier * scale)`
|
|
228
|
+
- range converts each point with `Math.round(value * scale)`
|
|
229
|
+
- plinko and wheel `configId` must fit in `u8`
|
|
155
230
|
|
|
156
|
-
|
|
231
|
+
### PvP Coinflip
|
|
157
232
|
|
|
158
|
-
|
|
233
|
+
Use `createPvPCoinflipTransaction(action, options)` for PvP coinflip flows:
|
|
159
234
|
|
|
160
|
-
- `
|
|
235
|
+
- `create`
|
|
236
|
+
- `join`
|
|
237
|
+
- `cancel`
|
|
161
238
|
|
|
162
|
-
|
|
239
|
+
Create:
|
|
163
240
|
|
|
164
241
|
```ts
|
|
165
|
-
const tx = client.suigar.tx.
|
|
242
|
+
const tx = client.suigar.tx.createPvPCoinflipTransaction('create', {
|
|
166
243
|
owner: '0x123',
|
|
167
244
|
coinType: '0x2::sui::SUI',
|
|
168
245
|
stake: 1_000_000_000n,
|
|
169
|
-
|
|
246
|
+
side: 'heads',
|
|
247
|
+
isPrivate: false,
|
|
170
248
|
});
|
|
171
249
|
```
|
|
172
250
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Additional options:
|
|
176
|
-
|
|
177
|
-
- `leftPoint: number`
|
|
178
|
-
- `rightPoint: number`
|
|
179
|
-
- `outOfRange?: boolean`
|
|
180
|
-
- `scale?: number`
|
|
181
|
-
|
|
182
|
-
Behavior:
|
|
183
|
-
|
|
184
|
-
- `scale` defaults to the SDK fixed-point range scale
|
|
185
|
-
- `leftPoint` and `rightPoint` are converted with `Math.round(value * scale)`
|
|
186
|
-
- `outOfRange` is coerced with `Boolean(...)`
|
|
187
|
-
|
|
188
|
-
Example:
|
|
251
|
+
Join:
|
|
189
252
|
|
|
190
253
|
```ts
|
|
191
|
-
const tx = client.suigar.tx.
|
|
254
|
+
const tx = client.suigar.tx.createPvPCoinflipTransaction('join', {
|
|
192
255
|
owner: '0x123',
|
|
193
256
|
coinType: '0x2::sui::SUI',
|
|
257
|
+
gameId: '0xGAME_ID',
|
|
258
|
+
extraObjectId: '0xEXTRA_OBJECT_ID',
|
|
194
259
|
stake: 1_000_000_000n,
|
|
195
|
-
leftPoint: 0.95,
|
|
196
|
-
rightPoint: 1.05,
|
|
197
|
-
outOfRange: false,
|
|
198
260
|
});
|
|
199
261
|
```
|
|
200
262
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
Additional options:
|
|
204
|
-
|
|
205
|
-
- `configId: number`
|
|
206
|
-
|
|
207
|
-
Behavior:
|
|
208
|
-
|
|
209
|
-
- `configId` must fit in `u8`
|
|
210
|
-
|
|
211
|
-
Example:
|
|
263
|
+
Cancel:
|
|
212
264
|
|
|
213
265
|
```ts
|
|
214
|
-
const tx = client.suigar.tx.
|
|
266
|
+
const tx = client.suigar.tx.createPvPCoinflipTransaction('cancel', {
|
|
215
267
|
owner: '0x123',
|
|
216
268
|
coinType: '0x2::sui::SUI',
|
|
217
|
-
|
|
218
|
-
configId: 1,
|
|
269
|
+
gameId: '0xGAME_ID',
|
|
219
270
|
});
|
|
220
271
|
```
|
|
221
272
|
|
|
222
|
-
|
|
273
|
+
PvP shared options:
|
|
223
274
|
|
|
224
|
-
|
|
275
|
+
- `owner: string`
|
|
276
|
+
- `coinType: string`
|
|
277
|
+
- `metadata?: ...`
|
|
278
|
+
- `gasBudget?: number | bigint`
|
|
279
|
+
- `sender?: string`
|
|
280
|
+
- `allowGasCoinShortcut?: boolean`
|
|
225
281
|
|
|
226
|
-
-
|
|
282
|
+
Action-specific options:
|
|
227
283
|
|
|
228
|
-
|
|
284
|
+
- `create`: `stake`, `side`, `isPrivate?`
|
|
285
|
+
- `join`: `gameId`, `extraObjectId`, `stake`
|
|
286
|
+
- `cancel`: `gameId`
|
|
229
287
|
|
|
230
|
-
|
|
288
|
+
## `bcs`
|
|
231
289
|
|
|
232
|
-
|
|
290
|
+
BCS helpers live under `client.suigar.bcs`.
|
|
233
291
|
|
|
234
|
-
|
|
235
|
-
async function readBetResult(client: ClientWithCoreApi, id: string) {
|
|
236
|
-
const { object } = await client.core.getObject({
|
|
237
|
-
objectId: id,
|
|
238
|
-
include: {
|
|
239
|
-
content: true,
|
|
240
|
-
},
|
|
241
|
-
});
|
|
292
|
+
Current exposed helpers:
|
|
242
293
|
|
|
243
|
-
|
|
294
|
+
- `BetResultEvent`
|
|
295
|
+
- `PvPCoinflipGameCreated`
|
|
296
|
+
- `PvPCoinflipGameResolved`
|
|
297
|
+
- `PvPCoinflipGameCancelled`
|
|
244
298
|
|
|
245
|
-
|
|
246
|
-
console.log(parsed.coin_type.name);
|
|
247
|
-
console.log(parsed.stake_amount);
|
|
248
|
-
console.log(parsed.outcome_amount);
|
|
299
|
+
These are generated Move struct/event decoders. Use them to parse Suigar event payloads and structured onchain content.
|
|
249
300
|
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Using the generated helper directly
|
|
255
|
-
|
|
256
|
-
If you already have a content-bearing object response, parse `object.content` directly:
|
|
301
|
+
### Parse Standard Bet Result Data
|
|
257
302
|
|
|
258
303
|
```ts
|
|
259
304
|
const { object } = await client.core.getObject({
|
|
@@ -277,12 +322,9 @@ Parsed fields include:
|
|
|
277
322
|
- `game_details`
|
|
278
323
|
- `metadata`
|
|
279
324
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
Example conversion to strings:
|
|
325
|
+
`game_details` and `metadata` decode as `VecMap<string, vector<u8>>`-shaped data, so values come back as byte arrays.
|
|
283
326
|
|
|
284
327
|
```ts
|
|
285
|
-
const decoded = client.suigar.bcs.BetResultEvent.parse(object.data.content);
|
|
286
328
|
const textDecoder = new TextDecoder();
|
|
287
329
|
|
|
288
330
|
const metadata = new Map(
|
|
@@ -293,54 +335,18 @@ const metadata = new Map(
|
|
|
293
335
|
);
|
|
294
336
|
```
|
|
295
337
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
`suigar(options?)` resolves config from:
|
|
299
|
-
|
|
300
|
-
- the connected Sui network
|
|
301
|
-
- internal default package ids
|
|
302
|
-
- internal default SweetHouse package id by network
|
|
303
|
-
- default coin types for `SUI`, `USDC`, and FlowX `USDC`
|
|
304
|
-
- user overrides
|
|
338
|
+
Important:
|
|
305
339
|
|
|
306
|
-
|
|
340
|
+
- use `content`, not `objectBcs`, with these generated parsers
|
|
341
|
+
- the generated parser expects the struct payload, not a full object envelope
|
|
307
342
|
|
|
308
|
-
|
|
309
|
-
- `sweetHousePackageId`
|
|
310
|
-
- `coinTypes.sui`
|
|
311
|
-
- `coinTypes.usdc`
|
|
312
|
-
- `coinTypes.usdcFlowx`
|
|
313
|
-
- `gamesPackageId.coinflip`
|
|
314
|
-
- `gamesPackageId.limbo`
|
|
315
|
-
- `gamesPackageId.plinko`
|
|
316
|
-
- `gamesPackageId['pvp-coinflip']`
|
|
317
|
-
- `gamesPackageId.range`
|
|
318
|
-
- `gamesPackageId.wheel`
|
|
319
|
-
- `pyth.packageId`
|
|
320
|
-
- `pyth.suiPriceInfoObjectId`
|
|
321
|
-
- `pyth.usdcPriceInfoObjectId`
|
|
322
|
-
- `pyth.priceInfoObjectIds[coinType]`
|
|
343
|
+
### Parse PvP Coinflip Event Data
|
|
323
344
|
|
|
324
|
-
|
|
345
|
+
Use the matching helper for the PvP coinflip event payload you fetched from chain:
|
|
325
346
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
sweetHousePackageId: '0xsweethouse',
|
|
330
|
-
pyth: {
|
|
331
|
-
suiPriceInfoObjectId: '0xsui',
|
|
332
|
-
usdcPriceInfoObjectId: '0xusdc',
|
|
333
|
-
priceInfoObjectIds: {
|
|
334
|
-
'0x123::custom::TOKEN': '0xprice',
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
gamesPackageId: {
|
|
338
|
-
coinflip: '0xcoinflip',
|
|
339
|
-
wheel: '0xwheel',
|
|
340
|
-
},
|
|
341
|
-
}),
|
|
342
|
-
);
|
|
343
|
-
```
|
|
347
|
+
- `client.suigar.bcs.PvPCoinflipGameCreated`
|
|
348
|
+
- `client.suigar.bcs.PvPCoinflipGameResolved`
|
|
349
|
+
- `client.suigar.bcs.PvPCoinflipGameCancelled`
|
|
344
350
|
|
|
345
351
|
## Development
|
|
346
352
|
|
package/dist/index.cjs
CHANGED
|
@@ -853,8 +853,6 @@ function BetResultEvent(...typeParameters) {
|
|
|
853
853
|
metadata: VecMap(bcs.bcs.string(), bcs.bcs.vector(bcs.bcs.u8()))
|
|
854
854
|
} });
|
|
855
855
|
}
|
|
856
|
-
|
|
857
|
-
// src/client.ts
|
|
858
856
|
function suigar({
|
|
859
857
|
name = "suigar",
|
|
860
858
|
...options
|
|
@@ -877,14 +875,19 @@ var SuigarClient = class {
|
|
|
877
875
|
this.#config = resolveSuigarConfig(options);
|
|
878
876
|
}
|
|
879
877
|
/**
|
|
880
|
-
* Builds a transaction with the configured Sui client and
|
|
878
|
+
* Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
|
|
879
|
+
*
|
|
880
|
+
* Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
|
|
881
|
+
* instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
|
|
882
|
+
* transaction build options except for `client`.
|
|
881
883
|
*
|
|
882
|
-
* @param transaction Transaction
|
|
884
|
+
* @param transaction Transaction to build and serialize.
|
|
885
|
+
* @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
|
|
883
886
|
* @returns Base64-encoded transaction bytes ready to send over the wire.
|
|
884
887
|
*/
|
|
885
|
-
async serializeTransactionToBase64(transaction) {
|
|
886
|
-
const bytes = await transaction.build({ client: this.#client });
|
|
887
|
-
return
|
|
888
|
+
async serializeTransactionToBase64(transaction, options) {
|
|
889
|
+
const bytes = await transaction.build({ ...options, client: this.#client });
|
|
890
|
+
return utils.toBase64(bytes);
|
|
888
891
|
}
|
|
889
892
|
/**
|
|
890
893
|
* BCS struct constructors for decoding Suigar events emitted on-chain.
|
|
@@ -965,5 +968,4 @@ var SuigarClient = class {
|
|
|
965
968
|
};
|
|
966
969
|
};
|
|
967
970
|
|
|
968
|
-
exports.SuigarClient = SuigarClient;
|
|
969
971
|
exports.suigar = suigar;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
2
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
3
3
|
import { BcsType, BcsStruct } from '@mysten/sui/bcs';
|
|
4
4
|
|
|
5
5
|
type BetMetadataPrimitive = string | number | boolean | bigint;
|
|
@@ -227,12 +227,17 @@ declare class SuigarClient {
|
|
|
227
227
|
options: SuigarOptions;
|
|
228
228
|
});
|
|
229
229
|
/**
|
|
230
|
-
* Builds a transaction with the configured Sui client and
|
|
230
|
+
* Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
|
|
231
231
|
*
|
|
232
|
-
*
|
|
232
|
+
* Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
|
|
233
|
+
* instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
|
|
234
|
+
* transaction build options except for `client`.
|
|
235
|
+
*
|
|
236
|
+
* @param transaction Transaction to build and serialize.
|
|
237
|
+
* @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
|
|
233
238
|
* @returns Base64-encoded transaction bytes ready to send over the wire.
|
|
234
239
|
*/
|
|
235
|
-
serializeTransactionToBase64(transaction: Transaction): Promise<string>;
|
|
240
|
+
serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
|
|
236
241
|
/**
|
|
237
242
|
* BCS struct constructors for decoding Suigar events emitted on-chain.
|
|
238
243
|
*/
|
|
@@ -277,4 +282,4 @@ declare class SuigarClient {
|
|
|
277
282
|
};
|
|
278
283
|
}
|
|
279
284
|
|
|
280
|
-
export {
|
|
285
|
+
export { suigar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
2
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
3
3
|
import { BcsType, BcsStruct } from '@mysten/sui/bcs';
|
|
4
4
|
|
|
5
5
|
type BetMetadataPrimitive = string | number | boolean | bigint;
|
|
@@ -227,12 +227,17 @@ declare class SuigarClient {
|
|
|
227
227
|
options: SuigarOptions;
|
|
228
228
|
});
|
|
229
229
|
/**
|
|
230
|
-
* Builds a transaction with the configured Sui client and
|
|
230
|
+
* Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
|
|
231
231
|
*
|
|
232
|
-
*
|
|
232
|
+
* Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
|
|
233
|
+
* instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
|
|
234
|
+
* transaction build options except for `client`.
|
|
235
|
+
*
|
|
236
|
+
* @param transaction Transaction to build and serialize.
|
|
237
|
+
* @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
|
|
233
238
|
* @returns Base64-encoded transaction bytes ready to send over the wire.
|
|
234
239
|
*/
|
|
235
|
-
serializeTransactionToBase64(transaction: Transaction): Promise<string>;
|
|
240
|
+
serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
|
|
236
241
|
/**
|
|
237
242
|
* BCS struct constructors for decoding Suigar events emitted on-chain.
|
|
238
243
|
*/
|
|
@@ -277,4 +282,4 @@ declare class SuigarClient {
|
|
|
277
282
|
};
|
|
278
283
|
}
|
|
279
284
|
|
|
280
|
-
export {
|
|
285
|
+
export { suigar };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeSuiAddress, normalizeStructTag, SUI_TYPE_ARG } from '@mysten/sui/utils';
|
|
1
|
+
import { normalizeSuiAddress, toBase64, normalizeStructTag, SUI_TYPE_ARG } from '@mysten/sui/utils';
|
|
2
2
|
import { bcs, BcsStruct, TypeTagSerializer } from '@mysten/sui/bcs';
|
|
3
3
|
import { Transaction, isArgument } from '@mysten/sui/transactions';
|
|
4
4
|
|
|
@@ -851,8 +851,6 @@ function BetResultEvent(...typeParameters) {
|
|
|
851
851
|
metadata: VecMap(bcs.string(), bcs.vector(bcs.u8()))
|
|
852
852
|
} });
|
|
853
853
|
}
|
|
854
|
-
|
|
855
|
-
// src/client.ts
|
|
856
854
|
function suigar({
|
|
857
855
|
name = "suigar",
|
|
858
856
|
...options
|
|
@@ -875,14 +873,19 @@ var SuigarClient = class {
|
|
|
875
873
|
this.#config = resolveSuigarConfig(options);
|
|
876
874
|
}
|
|
877
875
|
/**
|
|
878
|
-
* Builds a transaction with the configured Sui client and
|
|
876
|
+
* Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
|
|
877
|
+
*
|
|
878
|
+
* Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
|
|
879
|
+
* instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
|
|
880
|
+
* transaction build options except for `client`.
|
|
879
881
|
*
|
|
880
|
-
* @param transaction Transaction
|
|
882
|
+
* @param transaction Transaction to build and serialize.
|
|
883
|
+
* @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
|
|
881
884
|
* @returns Base64-encoded transaction bytes ready to send over the wire.
|
|
882
885
|
*/
|
|
883
|
-
async serializeTransactionToBase64(transaction) {
|
|
884
|
-
const bytes = await transaction.build({ client: this.#client });
|
|
885
|
-
return
|
|
886
|
+
async serializeTransactionToBase64(transaction, options) {
|
|
887
|
+
const bytes = await transaction.build({ ...options, client: this.#client });
|
|
888
|
+
return toBase64(bytes);
|
|
886
889
|
}
|
|
887
890
|
/**
|
|
888
891
|
* BCS struct constructors for decoding Suigar events emitted on-chain.
|
|
@@ -963,4 +966,4 @@ var SuigarClient = class {
|
|
|
963
966
|
};
|
|
964
967
|
};
|
|
965
968
|
|
|
966
|
-
export {
|
|
969
|
+
export { suigar };
|