@suigar/sdk 2.0.0-beta.3 → 2.0.0-beta.4
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 +27 -2
- package/README.md +211 -31
- package/dist/chunk-W3WZ2BHO.js +310 -0
- package/dist/games-nFnPbPuK.d.cts +84 -0
- package/dist/games-nFnPbPuK.d.ts +84 -0
- package/dist/games.cjs +2 -0
- package/dist/games.d.cts +1 -0
- package/dist/games.d.ts +1 -0
- package/dist/games.js +1 -0
- package/dist/index-jwSXA8q3.d.cts +25 -0
- package/dist/index-jwSXA8q3.d.ts +25 -0
- package/dist/index.cjs +269 -97
- package/dist/index.d.cts +113 -108
- package/dist/index.d.ts +113 -108
- package/dist/index.js +229 -231
- package/dist/utils.cjs +208 -0
- package/dist/utils.d.cts +79 -0
- package/dist/utils.d.ts +79 -0
- package/dist/utils.js +1 -0
- package/package.json +20 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,121 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
1
|
+
import { M as MoveStruct } from './index-jwSXA8q3.cjs';
|
|
3
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
|
+
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
client: ClientWithCoreApi;
|
|
8
|
-
}
|
|
9
|
-
interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
|
|
10
|
-
client: ClientWithCoreApi;
|
|
11
|
-
}
|
|
12
|
-
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
13
|
-
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
14
|
-
content: true;
|
|
15
|
-
json: true;
|
|
16
|
-
}> & {
|
|
17
|
-
json: BcsStruct<T>['$inferType'];
|
|
18
|
-
}>;
|
|
19
|
-
getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ client, ...options }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
|
|
20
|
-
content: true;
|
|
21
|
-
json: true;
|
|
22
|
-
}> & {
|
|
23
|
-
json: BcsStruct<T>['$inferType'];
|
|
24
|
-
}>>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type BetMetadataPrimitive = string | number | boolean | bigint;
|
|
28
|
-
type BetMetadataValue = BetMetadataPrimitive | Uint8Array | number[];
|
|
29
|
-
type BetMetadataInput = Record<string, BetMetadataValue | null | undefined>;
|
|
30
|
-
|
|
31
|
-
declare const GAMES: readonly ["coinflip", "limbo", "plinko", "pvp-coinflip", "range", "wheel"];
|
|
32
|
-
type Game = (typeof GAMES)[number];
|
|
33
|
-
type StandardGame = Exclude<Game, PvPGame>;
|
|
34
|
-
type PvPGame = 'pvp-coinflip';
|
|
35
|
-
type CoinSide = 'heads' | 'tails';
|
|
36
|
-
|
|
37
|
-
interface SuigarExtensionOptions<Name = 'suigar'> {
|
|
38
|
-
name?: Name;
|
|
39
|
-
}
|
|
40
|
-
type SuigarCoin = 'sui' | 'usdc';
|
|
41
|
-
type SuigarCoinTypes = Record<SuigarCoin, string>;
|
|
42
|
-
type SuigarPackageKey = 'sweetHouse' | 'core' | 'coinflip' | 'limbo' | 'plinko' | 'pvpCoinflip' | 'range' | 'wheel';
|
|
43
|
-
type SuigarPackage = Record<SuigarPackageKey, string>;
|
|
44
|
-
type SuigarPriceInfoObjectId = Record<SuigarCoin, string>;
|
|
45
|
-
type SuigarConfig = {
|
|
46
|
-
packageIds: SuigarPackage;
|
|
47
|
-
coinTypes: SuigarCoinTypes;
|
|
48
|
-
priceInfoObjectIds: SuigarPriceInfoObjectId;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type SharedBetTransactionOptions = {
|
|
52
|
-
config: SuigarConfig;
|
|
53
|
-
owner: string;
|
|
54
|
-
coinType: string;
|
|
55
|
-
stake: number | bigint;
|
|
56
|
-
cashStake?: number | bigint;
|
|
57
|
-
betCount?: number | bigint;
|
|
58
|
-
metadata?: BetMetadataInput;
|
|
59
|
-
gasBudget?: number | bigint;
|
|
60
|
-
sender?: string;
|
|
61
|
-
allowGasCoinShortcut?: boolean;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
65
|
-
side: CoinSide;
|
|
66
|
-
};
|
|
67
|
-
type BuildLimboTransactionOptions = SharedBetTransactionOptions & {
|
|
68
|
-
targetMultiplier: number;
|
|
69
|
-
scale?: number;
|
|
70
|
-
};
|
|
71
|
-
type BuildPlinkoTransactionOptions = SharedBetTransactionOptions & {
|
|
72
|
-
configId: number;
|
|
73
|
-
};
|
|
74
|
-
type BuildRangeTransactionOptions = SharedBetTransactionOptions & {
|
|
75
|
-
leftPoint: number;
|
|
76
|
-
rightPoint: number;
|
|
77
|
-
outOfRange?: boolean;
|
|
78
|
-
scale?: number;
|
|
79
|
-
};
|
|
80
|
-
type BuildWheelTransactionOptions = SharedBetTransactionOptions & {
|
|
81
|
-
configId: number;
|
|
82
|
-
};
|
|
83
|
-
type PvPCoinflipAction = 'create' | 'join' | 'cancel';
|
|
84
|
-
type SharedPvPCoinflipTransactionOptions = {
|
|
85
|
-
config: SuigarConfig;
|
|
86
|
-
owner: string;
|
|
87
|
-
coinType: string;
|
|
88
|
-
metadata?: BetMetadataInput;
|
|
89
|
-
gasBudget?: number | bigint;
|
|
90
|
-
sender?: string;
|
|
91
|
-
allowGasCoinShortcut?: boolean;
|
|
92
|
-
};
|
|
93
|
-
type BuildCreatePvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
94
|
-
stake: number | bigint;
|
|
95
|
-
side: CoinSide;
|
|
96
|
-
isPrivate?: boolean;
|
|
97
|
-
};
|
|
98
|
-
type BuildJoinPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
99
|
-
gameId: string;
|
|
100
|
-
stake: number | bigint;
|
|
101
|
-
extraObjectId: string;
|
|
102
|
-
};
|
|
103
|
-
type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
104
|
-
gameId: string;
|
|
105
|
-
};
|
|
106
|
-
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
5
|
+
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games-nFnPbPuK.cjs';
|
|
6
|
+
import '@mysten/sui/bcs';
|
|
107
7
|
|
|
108
8
|
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
109
9
|
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;
|
|
110
10
|
|
|
111
|
-
declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
|
|
11
|
+
declare function suigar<const Name = 'suigar'>({ name, partner, }?: SuigarExtensionOptions<Name>): {
|
|
112
12
|
name: Name;
|
|
113
13
|
register: (client: ClientWithCoreApi) => SuigarClient;
|
|
114
14
|
};
|
|
115
15
|
declare class SuigarClient {
|
|
116
16
|
#private;
|
|
117
|
-
constructor({ client }: {
|
|
17
|
+
constructor({ client, partner, }: {
|
|
118
18
|
client: ClientWithCoreApi;
|
|
19
|
+
partner?: string;
|
|
119
20
|
});
|
|
120
21
|
/**
|
|
121
22
|
* Returns the resolved SDK configuration for the connected network.
|
|
@@ -140,9 +41,113 @@ declare class SuigarClient {
|
|
|
140
41
|
*/
|
|
141
42
|
serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
|
|
142
43
|
/**
|
|
143
|
-
*
|
|
44
|
+
* Lists unresolved PvP coinflip games from the configured registry and resolves
|
|
45
|
+
* each entry into parsed onchain game state.
|
|
46
|
+
*
|
|
47
|
+
* This fetches dynamic fields from the PvP coinflip registry object, then loads
|
|
48
|
+
* each referenced game object through `resolvePvPConflipGame()`. Registry
|
|
49
|
+
* membership is the unresolved-state signal: when a game is joined and resolved,
|
|
50
|
+
* the Move flow removes it from the registry and deletes the live `Game` object.
|
|
51
|
+
* Use this when a product needs the current set of open PvP coinflip matches for
|
|
52
|
+
* browsing or lobby views.
|
|
53
|
+
*
|
|
54
|
+
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
55
|
+
* @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
|
|
56
|
+
*/
|
|
57
|
+
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>): Promise<{
|
|
58
|
+
coinType: string;
|
|
59
|
+
id: string;
|
|
60
|
+
creator: string;
|
|
61
|
+
creator_is_tails: boolean;
|
|
62
|
+
is_private: boolean;
|
|
63
|
+
creator_metadata: {
|
|
64
|
+
contents: {
|
|
65
|
+
key: string;
|
|
66
|
+
value: number[];
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
joiner: string;
|
|
70
|
+
winner: string;
|
|
71
|
+
stake_per_player: string;
|
|
72
|
+
house_edge_bps: string;
|
|
73
|
+
stake_pot: {
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
}[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetches a PvP coinflip game object from chain and parses it into the SDK's
|
|
79
|
+
* normalized runtime shape.
|
|
80
|
+
*
|
|
81
|
+
* This resolves the raw object through the configured client, requires the
|
|
82
|
+
* object's `content` to be present, decodes that content with the generated
|
|
83
|
+
* `PvPCoinflipGame` BCS parser, and normalizes the generic coin type into a
|
|
84
|
+
* standard struct tag string. Use this when a product needs the current state
|
|
85
|
+
* of a specific PvP coinflip match before rendering join, cancel, or result UI.
|
|
86
|
+
*
|
|
87
|
+
* @param gameId On-chain object id of the PvP coinflip game.
|
|
88
|
+
* @returns Parsed PvP coinflip game state with a normalized `coinType`.
|
|
89
|
+
* @throws Error If the object cannot be decoded because no content was returned.
|
|
90
|
+
*/
|
|
91
|
+
resolvePvPConflipGame(gameId: string): Promise<{
|
|
92
|
+
coinType: string;
|
|
93
|
+
id: string;
|
|
94
|
+
creator: string;
|
|
95
|
+
creator_is_tails: boolean;
|
|
96
|
+
is_private: boolean;
|
|
97
|
+
creator_metadata: {
|
|
98
|
+
contents: {
|
|
99
|
+
key: string;
|
|
100
|
+
value: number[];
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
joiner: string;
|
|
104
|
+
winner: string;
|
|
105
|
+
stake_per_player: string;
|
|
106
|
+
house_edge_bps: string;
|
|
107
|
+
stake_pot: {
|
|
108
|
+
value: string;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* BCS struct constructors for decoding on-chain objects and events related to Suigar games.
|
|
113
|
+
*
|
|
114
|
+
* These can be used to parse the `content` field of on-chain objects and events into structured data with the
|
|
115
|
+
* expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP
|
|
116
|
+
* coinflip game object.
|
|
117
|
+
*
|
|
118
|
+
* Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction
|
|
119
|
+
* builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.
|
|
144
120
|
*/
|
|
145
121
|
bcs: {
|
|
122
|
+
/**
|
|
123
|
+
* Object representing the state of a PvP coinflip game, as stored on-chain.
|
|
124
|
+
*/
|
|
125
|
+
PvPCoinflipGame: MoveStruct<{
|
|
126
|
+
id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
127
|
+
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
128
|
+
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
129
|
+
is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
130
|
+
creator_metadata: MoveStruct<{
|
|
131
|
+
contents: _mysten_bcs.BcsType<{
|
|
132
|
+
key: string;
|
|
133
|
+
value: number[];
|
|
134
|
+
}[], Iterable<{
|
|
135
|
+
key: string;
|
|
136
|
+
value: Iterable<number> & {
|
|
137
|
+
length: number;
|
|
138
|
+
};
|
|
139
|
+
}> & {
|
|
140
|
+
length: number;
|
|
141
|
+
}, string>;
|
|
142
|
+
}, "0x2::vec_map::VecMap<string, vector<u8>>">;
|
|
143
|
+
joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
144
|
+
winner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
145
|
+
stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
146
|
+
house_edge_bps: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
147
|
+
stake_pot: MoveStruct<{
|
|
148
|
+
value: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
149
|
+
}, "0x2::balance::Balance<phantom T0>">;
|
|
150
|
+
}, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::Game<phantom T0>">;
|
|
146
151
|
/**
|
|
147
152
|
* Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
|
|
148
153
|
*/
|
|
@@ -265,4 +270,4 @@ declare class SuigarClient {
|
|
|
265
270
|
};
|
|
266
271
|
}
|
|
267
272
|
|
|
268
|
-
export { suigar };
|
|
273
|
+
export { SuigarClient, suigar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,121 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
1
|
+
import { M as MoveStruct } from './index-jwSXA8q3.js';
|
|
3
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
|
+
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
client: ClientWithCoreApi;
|
|
8
|
-
}
|
|
9
|
-
interface GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectsOptions<Include> {
|
|
10
|
-
client: ClientWithCoreApi;
|
|
11
|
-
}
|
|
12
|
-
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
13
|
-
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
14
|
-
content: true;
|
|
15
|
-
json: true;
|
|
16
|
-
}> & {
|
|
17
|
-
json: BcsStruct<T>['$inferType'];
|
|
18
|
-
}>;
|
|
19
|
-
getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ client, ...options }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
|
|
20
|
-
content: true;
|
|
21
|
-
json: true;
|
|
22
|
-
}> & {
|
|
23
|
-
json: BcsStruct<T>['$inferType'];
|
|
24
|
-
}>>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type BetMetadataPrimitive = string | number | boolean | bigint;
|
|
28
|
-
type BetMetadataValue = BetMetadataPrimitive | Uint8Array | number[];
|
|
29
|
-
type BetMetadataInput = Record<string, BetMetadataValue | null | undefined>;
|
|
30
|
-
|
|
31
|
-
declare const GAMES: readonly ["coinflip", "limbo", "plinko", "pvp-coinflip", "range", "wheel"];
|
|
32
|
-
type Game = (typeof GAMES)[number];
|
|
33
|
-
type StandardGame = Exclude<Game, PvPGame>;
|
|
34
|
-
type PvPGame = 'pvp-coinflip';
|
|
35
|
-
type CoinSide = 'heads' | 'tails';
|
|
36
|
-
|
|
37
|
-
interface SuigarExtensionOptions<Name = 'suigar'> {
|
|
38
|
-
name?: Name;
|
|
39
|
-
}
|
|
40
|
-
type SuigarCoin = 'sui' | 'usdc';
|
|
41
|
-
type SuigarCoinTypes = Record<SuigarCoin, string>;
|
|
42
|
-
type SuigarPackageKey = 'sweetHouse' | 'core' | 'coinflip' | 'limbo' | 'plinko' | 'pvpCoinflip' | 'range' | 'wheel';
|
|
43
|
-
type SuigarPackage = Record<SuigarPackageKey, string>;
|
|
44
|
-
type SuigarPriceInfoObjectId = Record<SuigarCoin, string>;
|
|
45
|
-
type SuigarConfig = {
|
|
46
|
-
packageIds: SuigarPackage;
|
|
47
|
-
coinTypes: SuigarCoinTypes;
|
|
48
|
-
priceInfoObjectIds: SuigarPriceInfoObjectId;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type SharedBetTransactionOptions = {
|
|
52
|
-
config: SuigarConfig;
|
|
53
|
-
owner: string;
|
|
54
|
-
coinType: string;
|
|
55
|
-
stake: number | bigint;
|
|
56
|
-
cashStake?: number | bigint;
|
|
57
|
-
betCount?: number | bigint;
|
|
58
|
-
metadata?: BetMetadataInput;
|
|
59
|
-
gasBudget?: number | bigint;
|
|
60
|
-
sender?: string;
|
|
61
|
-
allowGasCoinShortcut?: boolean;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
type BuildCoinflipTransactionOptions = SharedBetTransactionOptions & {
|
|
65
|
-
side: CoinSide;
|
|
66
|
-
};
|
|
67
|
-
type BuildLimboTransactionOptions = SharedBetTransactionOptions & {
|
|
68
|
-
targetMultiplier: number;
|
|
69
|
-
scale?: number;
|
|
70
|
-
};
|
|
71
|
-
type BuildPlinkoTransactionOptions = SharedBetTransactionOptions & {
|
|
72
|
-
configId: number;
|
|
73
|
-
};
|
|
74
|
-
type BuildRangeTransactionOptions = SharedBetTransactionOptions & {
|
|
75
|
-
leftPoint: number;
|
|
76
|
-
rightPoint: number;
|
|
77
|
-
outOfRange?: boolean;
|
|
78
|
-
scale?: number;
|
|
79
|
-
};
|
|
80
|
-
type BuildWheelTransactionOptions = SharedBetTransactionOptions & {
|
|
81
|
-
configId: number;
|
|
82
|
-
};
|
|
83
|
-
type PvPCoinflipAction = 'create' | 'join' | 'cancel';
|
|
84
|
-
type SharedPvPCoinflipTransactionOptions = {
|
|
85
|
-
config: SuigarConfig;
|
|
86
|
-
owner: string;
|
|
87
|
-
coinType: string;
|
|
88
|
-
metadata?: BetMetadataInput;
|
|
89
|
-
gasBudget?: number | bigint;
|
|
90
|
-
sender?: string;
|
|
91
|
-
allowGasCoinShortcut?: boolean;
|
|
92
|
-
};
|
|
93
|
-
type BuildCreatePvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
94
|
-
stake: number | bigint;
|
|
95
|
-
side: CoinSide;
|
|
96
|
-
isPrivate?: boolean;
|
|
97
|
-
};
|
|
98
|
-
type BuildJoinPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
99
|
-
gameId: string;
|
|
100
|
-
stake: number | bigint;
|
|
101
|
-
extraObjectId: string;
|
|
102
|
-
};
|
|
103
|
-
type BuildCancelPvPCoinflipTransactionOptions = SharedPvPCoinflipTransactionOptions & {
|
|
104
|
-
gameId: string;
|
|
105
|
-
};
|
|
106
|
-
type BuildPvPCoinflipTransactionOptions<Action extends PvPCoinflipAction = PvPCoinflipAction> = Action extends 'create' ? BuildCreatePvPCoinflipTransactionOptions : Action extends 'join' ? BuildJoinPvPCoinflipTransactionOptions : Action extends 'cancel' ? BuildCancelPvPCoinflipTransactionOptions : never;
|
|
5
|
+
import { S as StandardGame, B as BuildCoinflipTransactionOptions, a as BuildWheelTransactionOptions, b as BuildLimboTransactionOptions, c as BuildPlinkoTransactionOptions, d as BuildRangeTransactionOptions, e as SuigarConfig, P as PvPCoinflipAction, f as BuildPvPCoinflipTransactionOptions, g as SuigarExtensionOptions } from './games-nFnPbPuK.js';
|
|
6
|
+
import '@mysten/sui/bcs';
|
|
107
7
|
|
|
108
8
|
type WithoutConfig<T> = Omit<T, 'config'>;
|
|
109
9
|
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;
|
|
110
10
|
|
|
111
|
-
declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
|
|
11
|
+
declare function suigar<const Name = 'suigar'>({ name, partner, }?: SuigarExtensionOptions<Name>): {
|
|
112
12
|
name: Name;
|
|
113
13
|
register: (client: ClientWithCoreApi) => SuigarClient;
|
|
114
14
|
};
|
|
115
15
|
declare class SuigarClient {
|
|
116
16
|
#private;
|
|
117
|
-
constructor({ client }: {
|
|
17
|
+
constructor({ client, partner, }: {
|
|
118
18
|
client: ClientWithCoreApi;
|
|
19
|
+
partner?: string;
|
|
119
20
|
});
|
|
120
21
|
/**
|
|
121
22
|
* Returns the resolved SDK configuration for the connected network.
|
|
@@ -140,9 +41,113 @@ declare class SuigarClient {
|
|
|
140
41
|
*/
|
|
141
42
|
serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
|
|
142
43
|
/**
|
|
143
|
-
*
|
|
44
|
+
* Lists unresolved PvP coinflip games from the configured registry and resolves
|
|
45
|
+
* each entry into parsed onchain game state.
|
|
46
|
+
*
|
|
47
|
+
* This fetches dynamic fields from the PvP coinflip registry object, then loads
|
|
48
|
+
* each referenced game object through `resolvePvPConflipGame()`. Registry
|
|
49
|
+
* membership is the unresolved-state signal: when a game is joined and resolved,
|
|
50
|
+
* the Move flow removes it from the registry and deletes the live `Game` object.
|
|
51
|
+
* Use this when a product needs the current set of open PvP coinflip matches for
|
|
52
|
+
* browsing or lobby views.
|
|
53
|
+
*
|
|
54
|
+
* @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
|
|
55
|
+
* @returns Parsed unresolved PvP coinflip game objects for the requested registry page.
|
|
56
|
+
*/
|
|
57
|
+
getPvPCoinflipGames(options?: Omit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>): Promise<{
|
|
58
|
+
coinType: string;
|
|
59
|
+
id: string;
|
|
60
|
+
creator: string;
|
|
61
|
+
creator_is_tails: boolean;
|
|
62
|
+
is_private: boolean;
|
|
63
|
+
creator_metadata: {
|
|
64
|
+
contents: {
|
|
65
|
+
key: string;
|
|
66
|
+
value: number[];
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
joiner: string;
|
|
70
|
+
winner: string;
|
|
71
|
+
stake_per_player: string;
|
|
72
|
+
house_edge_bps: string;
|
|
73
|
+
stake_pot: {
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
}[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetches a PvP coinflip game object from chain and parses it into the SDK's
|
|
79
|
+
* normalized runtime shape.
|
|
80
|
+
*
|
|
81
|
+
* This resolves the raw object through the configured client, requires the
|
|
82
|
+
* object's `content` to be present, decodes that content with the generated
|
|
83
|
+
* `PvPCoinflipGame` BCS parser, and normalizes the generic coin type into a
|
|
84
|
+
* standard struct tag string. Use this when a product needs the current state
|
|
85
|
+
* of a specific PvP coinflip match before rendering join, cancel, or result UI.
|
|
86
|
+
*
|
|
87
|
+
* @param gameId On-chain object id of the PvP coinflip game.
|
|
88
|
+
* @returns Parsed PvP coinflip game state with a normalized `coinType`.
|
|
89
|
+
* @throws Error If the object cannot be decoded because no content was returned.
|
|
90
|
+
*/
|
|
91
|
+
resolvePvPConflipGame(gameId: string): Promise<{
|
|
92
|
+
coinType: string;
|
|
93
|
+
id: string;
|
|
94
|
+
creator: string;
|
|
95
|
+
creator_is_tails: boolean;
|
|
96
|
+
is_private: boolean;
|
|
97
|
+
creator_metadata: {
|
|
98
|
+
contents: {
|
|
99
|
+
key: string;
|
|
100
|
+
value: number[];
|
|
101
|
+
}[];
|
|
102
|
+
};
|
|
103
|
+
joiner: string;
|
|
104
|
+
winner: string;
|
|
105
|
+
stake_per_player: string;
|
|
106
|
+
house_edge_bps: string;
|
|
107
|
+
stake_pot: {
|
|
108
|
+
value: string;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* BCS struct constructors for decoding on-chain objects and events related to Suigar games.
|
|
113
|
+
*
|
|
114
|
+
* These can be used to parse the `content` field of on-chain objects and events into structured data with the
|
|
115
|
+
* expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP
|
|
116
|
+
* coinflip game object.
|
|
117
|
+
*
|
|
118
|
+
* Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction
|
|
119
|
+
* builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.
|
|
144
120
|
*/
|
|
145
121
|
bcs: {
|
|
122
|
+
/**
|
|
123
|
+
* Object representing the state of a PvP coinflip game, as stored on-chain.
|
|
124
|
+
*/
|
|
125
|
+
PvPCoinflipGame: MoveStruct<{
|
|
126
|
+
id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
127
|
+
creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
128
|
+
creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
129
|
+
is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
130
|
+
creator_metadata: MoveStruct<{
|
|
131
|
+
contents: _mysten_bcs.BcsType<{
|
|
132
|
+
key: string;
|
|
133
|
+
value: number[];
|
|
134
|
+
}[], Iterable<{
|
|
135
|
+
key: string;
|
|
136
|
+
value: Iterable<number> & {
|
|
137
|
+
length: number;
|
|
138
|
+
};
|
|
139
|
+
}> & {
|
|
140
|
+
length: number;
|
|
141
|
+
}, string>;
|
|
142
|
+
}, "0x2::vec_map::VecMap<string, vector<u8>>">;
|
|
143
|
+
joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
144
|
+
winner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
145
|
+
stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
146
|
+
house_edge_bps: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
147
|
+
stake_pot: MoveStruct<{
|
|
148
|
+
value: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
149
|
+
}, "0x2::balance::Balance<phantom T0>">;
|
|
150
|
+
}, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::Game<phantom T0>">;
|
|
146
151
|
/**
|
|
147
152
|
* Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
|
|
148
153
|
*/
|
|
@@ -265,4 +270,4 @@ declare class SuigarClient {
|
|
|
265
270
|
};
|
|
266
271
|
}
|
|
267
272
|
|
|
268
|
-
export { suigar };
|
|
273
|
+
export { SuigarClient, suigar };
|