@suigar/sdk 2.0.0-beta.6 → 2.0.0-beta.8
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 +20 -0
- package/README.md +41 -32
- package/dist/{chunk-W3WZ2BHO.js → chunk-YGYMLRE4.js} +25 -12
- package/dist/{games--Haw_z7M.d.cts → games-BccpPyWd.d.cts} +19 -20
- package/dist/{games--Haw_z7M.d.ts → games-BccpPyWd.d.ts} +19 -20
- package/dist/games.d.cts +2 -1
- package/dist/games.d.ts +2 -1
- package/dist/index.cjs +86 -49
- package/dist/index.d.cts +17 -12
- package/dist/index.d.ts +17 -12
- package/dist/index.js +67 -43
- package/dist/utils.cjs +28 -15
- package/dist/utils.d.cts +41 -5
- package/dist/utils.d.ts +41 -5
- package/dist/utils.js +1 -1
- package/package.json +1 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @suigar/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0292edb: Rename transaction builder option `owner` to `playerAddress` and remove the separate `sender` option so all game transactions use a single explicit player address.
|
|
8
|
+
- 20311be: Improve the public JSDoc for `parseGameDetails`, `toBigInt`, and `toU8` so the
|
|
9
|
+
generated API surface explains their coercion, validation, and decoding
|
|
10
|
+
behavior more clearly.
|
|
11
|
+
- a2aa324: Update PvP coinflip lookup helpers to use bulk object reads for unresolved lobby discovery and support forwarded lookup options.
|
|
12
|
+
- Make `getPvPCoinflipGames()` parse bulk `client.core.getObjects()` results instead of resolving each game individually.
|
|
13
|
+
- Skip per-object fetch or parse failures by default and continue supporting strict rejection with `throwOnError: true`.
|
|
14
|
+
- Forward supported lookup options such as `signal` through `getPvPCoinflipGames()` and `resolvePvPConflipGame(gameId, options?)`.
|
|
15
|
+
- Update tests, README guidance, and repo-local PvP skill documentation to match the current client behavior.
|
|
16
|
+
|
|
17
|
+
## 2.0.0-beta.7
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- f0ea104: Align numeric utility names, Move decoding helpers, and PvP BCS event helper references with the current SDK API.
|
|
22
|
+
|
|
3
23
|
## 2.0.0-beta.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -42,11 +42,11 @@ import {
|
|
|
42
42
|
DEFAULT_LIMBO_MULTIPLIER_SCALE,
|
|
43
43
|
DEFAULT_RANGE_SCALE,
|
|
44
44
|
RANGE_POINT_LIMIT,
|
|
45
|
-
|
|
45
|
+
fromMoveFloat,
|
|
46
|
+
fromMoveI64,
|
|
46
47
|
parseGameDetails,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
toU8Number,
|
|
48
|
+
toBigInt,
|
|
49
|
+
toU8,
|
|
50
50
|
} from '@suigar/sdk/utils';
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -92,7 +92,7 @@ const client = new SuiGrpcClient({
|
|
|
92
92
|
}).$extend(suigar());
|
|
93
93
|
|
|
94
94
|
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
95
|
-
|
|
95
|
+
playerAddress: '0x123',
|
|
96
96
|
coinType: '0x2::sui::SUI',
|
|
97
97
|
stake: 1_000_000_000n,
|
|
98
98
|
side: 'heads',
|
|
@@ -200,17 +200,20 @@ const base64 = await client.suigar.serializeTransactionToBase64(tx);
|
|
|
200
200
|
Lists unresolved PvP coinflip games from the configured PvP registry.
|
|
201
201
|
|
|
202
202
|
This reads the registry dynamic fields for the active network and resolves each
|
|
203
|
-
entry into parsed game state through `
|
|
203
|
+
entry into parsed game state through a bulk `client.core.getObjects()` lookup. Registry
|
|
204
204
|
membership is the unresolved-state signal: once a match is joined and resolved,
|
|
205
205
|
the Move flow removes it from the registry and deletes the live `Game` object.
|
|
206
206
|
|
|
207
207
|
Use this when a product needs the current set of open PvP coinflip matches for
|
|
208
208
|
browsing or lobby views.
|
|
209
209
|
|
|
210
|
-
By default,
|
|
210
|
+
By default, per-object fetch or parse failures are skipped so one broken or
|
|
211
211
|
already-deleted registry entry does not reject the full lookup. Pass
|
|
212
212
|
`throwOnError: true` if you want the call to reject instead.
|
|
213
213
|
|
|
214
|
+
Any supported `listDynamicFields()` options such as `limit`, `cursor`, or
|
|
215
|
+
`signal` can be passed through `options`.
|
|
216
|
+
|
|
214
217
|
```ts
|
|
215
218
|
const games = await client.suigar.getPvPCoinflipGames({ limit: 20 });
|
|
216
219
|
|
|
@@ -227,14 +230,15 @@ const games = await client.suigar.getPvPCoinflipGames({
|
|
|
227
230
|
});
|
|
228
231
|
```
|
|
229
232
|
|
|
230
|
-
### `resolvePvPConflipGame(gameId)`
|
|
233
|
+
### `resolvePvPConflipGame(gameId, options?)`
|
|
231
234
|
|
|
232
235
|
Fetches a PvP coinflip game object from chain and parses it into the SDK's
|
|
233
236
|
normalized runtime shape.
|
|
234
237
|
|
|
235
238
|
This requires the object's `content`, decodes it with the generated
|
|
236
239
|
`PvPCoinflipGame` parser, and normalizes the generic coin type into a standard
|
|
237
|
-
struct tag string.
|
|
240
|
+
struct tag string. You can optionally pass through `getObject()` options such as
|
|
241
|
+
`signal`.
|
|
238
242
|
|
|
239
243
|
Use this when a product needs the live onchain match state for a specific
|
|
240
244
|
pending match before rendering join or cancel actions, or inspecting the stake
|
|
@@ -249,11 +253,19 @@ console.log(game.stake_per_player);
|
|
|
249
253
|
console.log(game.is_private);
|
|
250
254
|
```
|
|
251
255
|
|
|
256
|
+
```ts
|
|
257
|
+
const controller = new AbortController();
|
|
258
|
+
|
|
259
|
+
const game = await client.suigar.resolvePvPConflipGame('0xGAME_ID', {
|
|
260
|
+
signal: controller.signal,
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
252
264
|
> **Note:**
|
|
253
265
|
>
|
|
254
266
|
> - it throws if the object response does not include decodable `content`
|
|
255
267
|
> - the PvP join builder uses this internally to derive the required join stake
|
|
256
|
-
> - after a game is joined and resolved, the live `Game` object is removed from the registry and deleted, so inspect `
|
|
268
|
+
> - after a game is joined and resolved, the live `Game` object is removed from the registry and deleted, so inspect `PvPCoinflipGameResolvedEvent` to read the final result
|
|
257
269
|
|
|
258
270
|
> **Tip:** Prefer this helper over manual object parsing when you only need the
|
|
259
271
|
> parsed state for a live PvP coinflip game object.
|
|
@@ -274,7 +286,7 @@ Use `createBetTransaction(gameId, options)` for:
|
|
|
274
286
|
|
|
275
287
|
```ts
|
|
276
288
|
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
277
|
-
|
|
289
|
+
playerAddress: '0x123',
|
|
278
290
|
coinType: '0x2::sui::SUI',
|
|
279
291
|
stake: 1_000_000_000n,
|
|
280
292
|
side: 'tails',
|
|
@@ -283,14 +295,13 @@ const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
|
283
295
|
|
|
284
296
|
Shared option shape:
|
|
285
297
|
|
|
286
|
-
- `
|
|
298
|
+
- `playerAddress: string`
|
|
287
299
|
- `coinType: string`
|
|
288
300
|
- `stake: number | bigint`
|
|
289
301
|
- `cashStake?: number | bigint`
|
|
290
302
|
- `betCount?: number | bigint`
|
|
291
303
|
- `metadata?: Record<string, string | number | boolean | bigint | Uint8Array | number[] | null | undefined>`
|
|
292
304
|
- `gasBudget?: number | bigint`
|
|
293
|
-
- `sender?: string`
|
|
294
305
|
- `allowGasCoinShortcut?: boolean`
|
|
295
306
|
|
|
296
307
|
Shared behavior:
|
|
@@ -298,12 +309,11 @@ Shared behavior:
|
|
|
298
309
|
- `stake` is the logical stake passed into the Move call
|
|
299
310
|
- `cashStake` controls the withdrawn balance and defaults to `stake`
|
|
300
311
|
- `betCount` defaults to `1`
|
|
301
|
-
- `sender` overrides the transaction sender
|
|
302
312
|
- `metadata` is encoded into `keys` and `values` byte arrays
|
|
303
313
|
- `partner` configured via `suigar({ partner })` is appended automatically to metadata as the partner wallet address
|
|
304
314
|
- `metadata.partner` and `metadata.referrer` are reserved and ignored with a warning
|
|
305
315
|
- the SDK resolves the price info object from the configured supported-coin mapping
|
|
306
|
-
- the reward object is transferred back to `
|
|
316
|
+
- the reward object is transferred back to `playerAddress`
|
|
307
317
|
|
|
308
318
|
Per-game options:
|
|
309
319
|
|
|
@@ -317,14 +327,14 @@ Examples:
|
|
|
317
327
|
|
|
318
328
|
```ts
|
|
319
329
|
const limboTx = client.suigar.tx.createBetTransaction('limbo', {
|
|
320
|
-
|
|
330
|
+
playerAddress: '0x123',
|
|
321
331
|
coinType: '0x2::sui::SUI',
|
|
322
332
|
stake: 1_000_000_000n,
|
|
323
333
|
targetMultiplier: 2.5,
|
|
324
334
|
});
|
|
325
335
|
|
|
326
336
|
const rangeTx = client.suigar.tx.createBetTransaction('range', {
|
|
327
|
-
|
|
337
|
+
playerAddress: '0x123',
|
|
328
338
|
coinType: '0x2::sui::SUI',
|
|
329
339
|
stake: 1_000_000_000n,
|
|
330
340
|
leftPoint: 25,
|
|
@@ -359,7 +369,7 @@ Create:
|
|
|
359
369
|
|
|
360
370
|
```ts
|
|
361
371
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('create', {
|
|
362
|
-
|
|
372
|
+
playerAddress: '0x123',
|
|
363
373
|
coinType: '0x2::sui::SUI',
|
|
364
374
|
stake: 1_000_000_000n,
|
|
365
375
|
side: 'heads',
|
|
@@ -371,7 +381,7 @@ Join:
|
|
|
371
381
|
|
|
372
382
|
```ts
|
|
373
383
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('join', {
|
|
374
|
-
|
|
384
|
+
playerAddress: '0x123',
|
|
375
385
|
coinType: '0x2::sui::SUI',
|
|
376
386
|
gameId: '0xGAME_ID',
|
|
377
387
|
});
|
|
@@ -381,7 +391,7 @@ Cancel:
|
|
|
381
391
|
|
|
382
392
|
```ts
|
|
383
393
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('cancel', {
|
|
384
|
-
|
|
394
|
+
playerAddress: '0x123',
|
|
385
395
|
coinType: '0x2::sui::SUI',
|
|
386
396
|
gameId: '0xGAME_ID',
|
|
387
397
|
});
|
|
@@ -392,11 +402,10 @@ id for `coinType`.
|
|
|
392
402
|
|
|
393
403
|
PvP shared options:
|
|
394
404
|
|
|
395
|
-
- `
|
|
405
|
+
- `playerAddress: string`
|
|
396
406
|
- `coinType: string`
|
|
397
407
|
- `metadata?: Record<string, string | number | boolean | bigint | Uint8Array | number[] | null | undefined>`
|
|
398
408
|
- `gasBudget?: number | bigint`
|
|
399
|
-
- `sender?: string`
|
|
400
409
|
- `allowGasCoinShortcut?: boolean`
|
|
401
410
|
|
|
402
411
|
Action-specific options:
|
|
@@ -413,15 +422,15 @@ Current exposed helpers:
|
|
|
413
422
|
|
|
414
423
|
- `PvPCoinflipGame`
|
|
415
424
|
- `BetResultEvent`
|
|
416
|
-
- `
|
|
417
|
-
- `
|
|
418
|
-
- `
|
|
425
|
+
- `PvPCoinflipGameCreatedEvent`
|
|
426
|
+
- `PvPCoinflipGameResolvedEvent`
|
|
427
|
+
- `PvPCoinflipGameCancelledEvent`
|
|
419
428
|
|
|
420
429
|
These are generated Move event decoders. Use them to parse Suigar event payloads from transaction results. The `@suigar/sdk/utils` subpath also exposes parser helpers for generated BCS values:
|
|
421
430
|
|
|
422
431
|
- `PvPCoinflipGame` parses a PvP coinflip game object's `content`
|
|
423
|
-
- `
|
|
424
|
-
- `
|
|
432
|
+
- `fromMoveI64(float.exp)` converts a generated Move `i64` exponent to a JavaScript number
|
|
433
|
+
- `fromMoveFloat(float)` converts a generated Move `Float` struct to a JavaScript number
|
|
425
434
|
- `parseGameDetails(game_details)` decodes `BetResultEvent.game_details` entries into the expected string, number, and boolean values
|
|
426
435
|
|
|
427
436
|
### Parse PvP Coinflip Game Object Data
|
|
@@ -528,9 +537,9 @@ contain that partner wallet address under the `partner` entry.
|
|
|
528
537
|
|
|
529
538
|
Use the matching helper for each PvP coinflip event payload found in `transactionResult.events`:
|
|
530
539
|
|
|
531
|
-
- `client.suigar.bcs.
|
|
532
|
-
- `client.suigar.bcs.
|
|
533
|
-
- `client.suigar.bcs.
|
|
540
|
+
- `client.suigar.bcs.PvPCoinflipGameCreatedEvent`
|
|
541
|
+
- `client.suigar.bcs.PvPCoinflipGameResolvedEvent`
|
|
542
|
+
- `client.suigar.bcs.PvPCoinflipGameCancelledEvent`
|
|
534
543
|
|
|
535
544
|
## Development
|
|
536
545
|
|
|
@@ -542,13 +551,13 @@ npm test
|
|
|
542
551
|
|
|
543
552
|
## Example App
|
|
544
553
|
|
|
545
|
-
This repository
|
|
554
|
+
This repository includes a Next.js integration example in [examples/game-integration](examples/game-integration).
|
|
546
555
|
|
|
547
556
|
It demonstrates:
|
|
548
557
|
|
|
549
558
|
- standard game transactions through `client.suigar.tx.createBetTransaction(...)`
|
|
550
559
|
- PvP coinflip create, join, and cancel flows through `client.suigar.tx.createPvPCoinflipTransaction(...)`, exposed in the example through a PvP coinflip action selector
|
|
551
|
-
- unresolved PvP lobby browsing through `client.suigar.getPvPCoinflipGames(...)`,
|
|
560
|
+
- unresolved PvP lobby browsing through `client.suigar.getPvPCoinflipGames(...)`, including public join cards while disconnected, an optional private-lobby join toggle, and connected-wallet filtering for cancel
|
|
552
561
|
- wallet connection and execution with `@mysten/dapp-kit-core` and `@mysten/dapp-kit-react`
|
|
553
562
|
- supported coin selection from `client.suigar.getConfig()`
|
|
554
563
|
- connected-wallet balance display for each supported coin in the example app
|
|
@@ -9,21 +9,34 @@ var RANGE_POINT_LIMIT = DEFAULT_RANGE_SCALE * 100;
|
|
|
9
9
|
var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
|
|
10
10
|
|
|
11
11
|
// src/utils/numeric.ts
|
|
12
|
-
function
|
|
12
|
+
function isFiniteNumber(value, message) {
|
|
13
|
+
if (typeof value !== "number") {
|
|
14
|
+
throw new Error(`${message}: ${String(value)}`);
|
|
15
|
+
}
|
|
16
|
+
if (!Number.isFinite(value)) {
|
|
17
|
+
throw new Error(`Value must be a finite number: ${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toBigInt(value) {
|
|
13
21
|
if (typeof value === "bigint") {
|
|
14
22
|
if (value < 0n) {
|
|
15
|
-
throw new Error(
|
|
23
|
+
throw new Error(`Value must be non-negative: ${value}`);
|
|
16
24
|
}
|
|
17
25
|
return value;
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
isFiniteNumber(value, "Value must be a bigint or number");
|
|
28
|
+
if (value < 0) {
|
|
29
|
+
throw new Error(`Value must be a finite non-negative number: ${value}`);
|
|
21
30
|
}
|
|
22
31
|
return BigInt(Math.trunc(value));
|
|
23
32
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
function toU8(value) {
|
|
34
|
+
isFiniteNumber(value, "Value must be a number");
|
|
35
|
+
if (!Number.isInteger(value)) {
|
|
36
|
+
throw new Error(`Value must be an integer: ${value}`);
|
|
37
|
+
}
|
|
38
|
+
if (value < 0 || value > 255) {
|
|
39
|
+
throw new Error(`Value must be an integer between 0 and 255: ${value}`);
|
|
27
40
|
}
|
|
28
41
|
return value;
|
|
29
42
|
}
|
|
@@ -255,7 +268,7 @@ var GAME_DETAIL_BCS = {
|
|
|
255
268
|
float: Float,
|
|
256
269
|
string: bcsString
|
|
257
270
|
};
|
|
258
|
-
function
|
|
271
|
+
function fromMoveI64(i64) {
|
|
259
272
|
try {
|
|
260
273
|
const value = BigInt(i64.bits ?? 0);
|
|
261
274
|
const maxPositive = 1n << 63n;
|
|
@@ -266,18 +279,18 @@ function parseI64(i64) {
|
|
|
266
279
|
return 0;
|
|
267
280
|
}
|
|
268
281
|
}
|
|
269
|
-
function
|
|
282
|
+
function fromMoveFloat(float) {
|
|
270
283
|
const mantissa = BigInt(float.mant);
|
|
271
284
|
if (mantissa === 0n) {
|
|
272
285
|
return 0;
|
|
273
286
|
}
|
|
274
|
-
const exponent =
|
|
287
|
+
const exponent = fromMoveI64(float.exp) - 52;
|
|
275
288
|
const magnitude = Number(mantissa) * Math.pow(2, exponent);
|
|
276
289
|
return float.is_negative ? -magnitude : magnitude;
|
|
277
290
|
}
|
|
278
291
|
function normalizeGameDetailValue(valueType, parsed) {
|
|
279
292
|
if (valueType === "float") {
|
|
280
|
-
return
|
|
293
|
+
return fromMoveFloat(parsed);
|
|
281
294
|
}
|
|
282
295
|
if (valueType === "u64") {
|
|
283
296
|
return Number(parsed);
|
|
@@ -307,4 +320,4 @@ function parseGameDetails(gameDetails) {
|
|
|
307
320
|
}, {});
|
|
308
321
|
}
|
|
309
322
|
|
|
310
|
-
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, Float, MoveStruct, RANGE_POINT_LIMIT,
|
|
323
|
+
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, Float, MoveStruct, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, normalizeMoveArguments, parseGameDetails, toBigInt, toU8 };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
|
|
1
3
|
declare const GAMES: readonly ["coinflip", "limbo", "plinko", "pvp-coinflip", "range", "wheel"];
|
|
2
4
|
type Game = (typeof GAMES)[number];
|
|
3
5
|
type StandardGame = Exclude<Game, PvPGame>;
|
|
@@ -26,22 +28,27 @@ type SuigarConfig = {
|
|
|
26
28
|
priceInfoObjectIds: SuigarPriceInfoObjectId;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
type
|
|
31
|
+
type WithGasBudget = {
|
|
32
|
+
gasBudget?: Parameters<Transaction['setGasBudgetIfNotSet']>[0];
|
|
33
|
+
};
|
|
34
|
+
type WithThrowOnError<T = object> = T & {
|
|
35
|
+
throwOnError?: boolean;
|
|
36
|
+
};
|
|
37
|
+
type BaseTransactionOptions = WithGasBudget & {
|
|
30
38
|
config: SuigarConfig;
|
|
31
|
-
|
|
39
|
+
playerAddress: string;
|
|
40
|
+
};
|
|
41
|
+
type CoinTransactionOptions = {
|
|
32
42
|
coinType: string;
|
|
33
|
-
stake: number | bigint;
|
|
34
|
-
cashStake?: number | bigint;
|
|
35
|
-
betCount?: number | bigint;
|
|
36
43
|
metadata?: BetMetadataInput;
|
|
37
|
-
gasBudget?: number | bigint;
|
|
38
|
-
sender?: string;
|
|
39
44
|
allowGasCoinShortcut?: boolean;
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
type StakeTransactionOptions = {
|
|
47
|
+
stake: number | bigint;
|
|
48
|
+
cashStake?: number | bigint;
|
|
49
|
+
betCount?: number | bigint;
|
|
44
50
|
};
|
|
51
|
+
type SharedBetTransactionOptions = BaseTransactionOptions & CoinTransactionOptions & StakeTransactionOptions;
|
|
45
52
|
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
46
53
|
side: CoinSide;
|
|
47
54
|
};
|
|
@@ -62,17 +69,9 @@ type BuildWheelTransactionOptions = SharedBetTransactionOptions & {
|
|
|
62
69
|
configId: number;
|
|
63
70
|
};
|
|
64
71
|
type PvPCoinflipAction = 'create' | 'join' | 'cancel';
|
|
65
|
-
type SharedPvPCoinflipTransactionOptions =
|
|
66
|
-
config: SuigarConfig;
|
|
67
|
-
owner: string;
|
|
68
|
-
coinType: string;
|
|
69
|
-
metadata?: BetMetadataInput;
|
|
70
|
-
gasBudget?: number | bigint;
|
|
71
|
-
sender?: string;
|
|
72
|
-
allowGasCoinShortcut?: boolean;
|
|
73
|
-
};
|
|
72
|
+
type SharedPvPCoinflipTransactionOptions = BaseTransactionOptions & CoinTransactionOptions;
|
|
74
73
|
type BuildCreatePvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
75
|
-
stake:
|
|
74
|
+
stake: StakeTransactionOptions['stake'];
|
|
76
75
|
side: CoinSide;
|
|
77
76
|
isPrivate?: boolean;
|
|
78
77
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
|
|
1
3
|
declare const GAMES: readonly ["coinflip", "limbo", "plinko", "pvp-coinflip", "range", "wheel"];
|
|
2
4
|
type Game = (typeof GAMES)[number];
|
|
3
5
|
type StandardGame = Exclude<Game, PvPGame>;
|
|
@@ -26,22 +28,27 @@ type SuigarConfig = {
|
|
|
26
28
|
priceInfoObjectIds: SuigarPriceInfoObjectId;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
type
|
|
31
|
+
type WithGasBudget = {
|
|
32
|
+
gasBudget?: Parameters<Transaction['setGasBudgetIfNotSet']>[0];
|
|
33
|
+
};
|
|
34
|
+
type WithThrowOnError<T = object> = T & {
|
|
35
|
+
throwOnError?: boolean;
|
|
36
|
+
};
|
|
37
|
+
type BaseTransactionOptions = WithGasBudget & {
|
|
30
38
|
config: SuigarConfig;
|
|
31
|
-
|
|
39
|
+
playerAddress: string;
|
|
40
|
+
};
|
|
41
|
+
type CoinTransactionOptions = {
|
|
32
42
|
coinType: string;
|
|
33
|
-
stake: number | bigint;
|
|
34
|
-
cashStake?: number | bigint;
|
|
35
|
-
betCount?: number | bigint;
|
|
36
43
|
metadata?: BetMetadataInput;
|
|
37
|
-
gasBudget?: number | bigint;
|
|
38
|
-
sender?: string;
|
|
39
44
|
allowGasCoinShortcut?: boolean;
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
type StakeTransactionOptions = {
|
|
47
|
+
stake: number | bigint;
|
|
48
|
+
cashStake?: number | bigint;
|
|
49
|
+
betCount?: number | bigint;
|
|
44
50
|
};
|
|
51
|
+
type SharedBetTransactionOptions = BaseTransactionOptions & CoinTransactionOptions & StakeTransactionOptions;
|
|
45
52
|
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
46
53
|
side: CoinSide;
|
|
47
54
|
};
|
|
@@ -62,17 +69,9 @@ type BuildWheelTransactionOptions = SharedBetTransactionOptions & {
|
|
|
62
69
|
configId: number;
|
|
63
70
|
};
|
|
64
71
|
type PvPCoinflipAction = 'create' | 'join' | 'cancel';
|
|
65
|
-
type SharedPvPCoinflipTransactionOptions =
|
|
66
|
-
config: SuigarConfig;
|
|
67
|
-
owner: string;
|
|
68
|
-
coinType: string;
|
|
69
|
-
metadata?: BetMetadataInput;
|
|
70
|
-
gasBudget?: number | bigint;
|
|
71
|
-
sender?: string;
|
|
72
|
-
allowGasCoinShortcut?: boolean;
|
|
73
|
-
};
|
|
72
|
+
type SharedPvPCoinflipTransactionOptions = BaseTransactionOptions & CoinTransactionOptions;
|
|
74
73
|
type BuildCreatePvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
75
|
-
stake:
|
|
74
|
+
stake: StakeTransactionOptions['stake'];
|
|
76
75
|
side: CoinSide;
|
|
77
76
|
isPrivate?: boolean;
|
|
78
77
|
};
|
package/dist/games.d.cts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games
|
|
1
|
+
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games-BccpPyWd.cjs';
|
|
2
|
+
import '@mysten/sui/transactions';
|
package/dist/games.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games
|
|
1
|
+
export { h as BuildCancelPvPCoinflipTransactionOptions, B as BuildCoinflipTransactionOptions, i as BuildCreatePvPCoinflipTransactionOptions, j as BuildJoinPvPCoinflipTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, a as BuildWheelTransactionOptions, C as CoinSide, P as PvPCoinflipAction } from './games-BccpPyWd.js';
|
|
2
|
+
import '@mysten/sui/transactions';
|