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

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.
Files changed (147) hide show
  1. package/CHANGELOG.md +165 -1
  2. package/README.md +300 -59
  3. package/dist/client.d.mts +257 -0
  4. package/dist/client.d.mts.map +1 -0
  5. package/dist/client.mjs +278 -0
  6. package/dist/client.mjs.map +1 -0
  7. package/dist/configs/package.mainnet.mjs +23 -0
  8. package/dist/configs/package.mainnet.mjs.map +1 -0
  9. package/dist/configs/package.mjs +19 -0
  10. package/dist/configs/package.mjs.map +1 -0
  11. package/dist/configs/package.testnet.mjs +23 -0
  12. package/dist/configs/package.testnet.mjs.map +1 -0
  13. package/dist/configs/registry.mainnet.mjs +6 -0
  14. package/dist/configs/registry.mainnet.mjs.map +1 -0
  15. package/dist/configs/registry.mjs +11 -0
  16. package/dist/configs/registry.mjs.map +1 -0
  17. package/dist/configs/registry.testnet.mjs +6 -0
  18. package/dist/configs/registry.testnet.mjs.map +1 -0
  19. package/dist/contracts/coinflip/coinflip.mjs +46 -0
  20. package/dist/contracts/coinflip/coinflip.mjs.map +1 -0
  21. package/dist/contracts/core/core.d.mts +54 -0
  22. package/dist/contracts/core/core.d.mts.map +1 -0
  23. package/dist/contracts/core/core.mjs +22 -0
  24. package/dist/contracts/core/core.mjs.map +1 -0
  25. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  26. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  27. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  28. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  29. package/dist/contracts/core/float.d.mts +13 -0
  30. package/dist/contracts/core/float.d.mts.map +1 -0
  31. package/dist/contracts/core/float.mjs +15 -0
  32. package/dist/contracts/core/float.mjs.map +1 -0
  33. package/dist/contracts/core/i64.mjs +10 -0
  34. package/dist/contracts/core/i64.mjs.map +1 -0
  35. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  36. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  37. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  38. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  39. package/dist/contracts/limbo/limbo.mjs +53 -0
  40. package/dist/contracts/limbo/limbo.mjs.map +1 -0
  41. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  42. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  43. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  44. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  45. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  46. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  47. package/dist/contracts/plinko/plinko.mjs +59 -0
  48. package/dist/contracts/plinko/plinko.mjs.map +1 -0
  49. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  50. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  51. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +10 -0
  52. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
  53. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  54. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  55. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts +33 -0
  56. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts.map +1 -0
  57. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs +131 -0
  58. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs.map +1 -0
  59. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  60. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  61. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  62. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  63. package/dist/contracts/range/range.mjs +53 -0
  64. package/dist/contracts/range/range.mjs.map +1 -0
  65. package/dist/contracts/utils/index.d.mts +68 -0
  66. package/dist/contracts/utils/index.d.mts.map +1 -0
  67. package/dist/contracts/utils/index.mjs +185 -0
  68. package/dist/contracts/utils/index.mjs.map +1 -0
  69. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  70. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  71. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  72. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  73. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  74. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  75. package/dist/contracts/wheel/wheel.mjs +59 -0
  76. package/dist/contracts/wheel/wheel.mjs.map +1 -0
  77. package/dist/games.d.mts +3 -0
  78. package/dist/games.mjs +1 -0
  79. package/dist/helpers/config.mjs +51 -0
  80. package/dist/helpers/config.mjs.map +1 -0
  81. package/dist/helpers/game-settings.mjs +19 -0
  82. package/dist/helpers/game-settings.mjs.map +1 -0
  83. package/dist/helpers/metadata.mjs +42 -0
  84. package/dist/helpers/metadata.mjs.map +1 -0
  85. package/dist/index.d.mts +2 -0
  86. package/dist/index.mjs +2 -0
  87. package/dist/transactions/coinflip.mjs +27 -0
  88. package/dist/transactions/coinflip.mjs.map +1 -0
  89. package/dist/transactions/limbo.mjs +31 -0
  90. package/dist/transactions/limbo.mjs.map +1 -0
  91. package/dist/transactions/plinko.mjs +29 -0
  92. package/dist/transactions/plinko.mjs.map +1 -0
  93. package/dist/transactions/pvp-coinflip.mjs +70 -0
  94. package/dist/transactions/pvp-coinflip.mjs.map +1 -0
  95. package/dist/transactions/range.mjs +33 -0
  96. package/dist/transactions/range.mjs.map +1 -0
  97. package/dist/transactions/shared.mjs +49 -0
  98. package/dist/transactions/shared.mjs.map +1 -0
  99. package/dist/transactions/wheel.mjs +29 -0
  100. package/dist/transactions/wheel.mjs.map +1 -0
  101. package/dist/ttl-cache.mjs +60 -0
  102. package/dist/ttl-cache.mjs.map +1 -0
  103. package/dist/types/bet-metadata.type.d.mts +7 -0
  104. package/dist/types/bet-metadata.type.d.mts.map +1 -0
  105. package/dist/types/build-game-transaction-options.type.d.mts +9 -0
  106. package/dist/types/build-game-transaction-options.type.d.mts.map +1 -0
  107. package/dist/types/game-details.type.d.mts +72 -0
  108. package/dist/types/game-details.type.d.mts.map +1 -0
  109. package/dist/types/game-details.type.mjs +59 -0
  110. package/dist/types/game-details.type.mjs.map +1 -0
  111. package/dist/types/game-settings.type.d.mts +200 -0
  112. package/dist/types/game-settings.type.d.mts.map +1 -0
  113. package/dist/types/game-settings.type.mjs +37 -0
  114. package/dist/types/game-settings.type.mjs.map +1 -0
  115. package/dist/types/game.type.d.mts +15 -0
  116. package/dist/types/game.type.d.mts.map +1 -0
  117. package/dist/types/game.type.mjs +19 -0
  118. package/dist/types/game.type.mjs.map +1 -0
  119. package/dist/types/index.d.mts +7 -0
  120. package/dist/types/move-float.type.d.mts +7 -0
  121. package/dist/types/move-float.type.d.mts.map +1 -0
  122. package/dist/types/network.type.d.mts +1 -0
  123. package/dist/types/network.type.mjs +6 -0
  124. package/dist/types/network.type.mjs.map +1 -0
  125. package/dist/types/suigar-config.type.d.mts +33 -0
  126. package/dist/types/suigar-config.type.d.mts.map +1 -0
  127. package/dist/types/transaction-options.type.d.mts +63 -0
  128. package/dist/types/transaction-options.type.d.mts.map +1 -0
  129. package/dist/utils/constants.d.mts +8 -0
  130. package/dist/utils/constants.d.mts.map +1 -0
  131. package/dist/utils/constants.mjs +10 -0
  132. package/dist/utils/constants.mjs.map +1 -0
  133. package/dist/utils/numeric.d.mts +86 -0
  134. package/dist/utils/numeric.d.mts.map +1 -0
  135. package/dist/utils/numeric.mjs +148 -0
  136. package/dist/utils/numeric.mjs.map +1 -0
  137. package/dist/utils/parser.d.mts +54 -0
  138. package/dist/utils/parser.d.mts.map +1 -0
  139. package/dist/utils/parser.mjs +94 -0
  140. package/dist/utils/parser.mjs.map +1 -0
  141. package/dist/utils.d.mts +4 -0
  142. package/dist/utils.mjs +4 -0
  143. package/package.json +80 -82
  144. package/dist/index.cjs +0 -1016
  145. package/dist/index.d.cts +0 -267
  146. package/dist/index.d.ts +0 -267
  147. package/dist/index.js +0 -1014
package/dist/index.d.cts DELETED
@@ -1,267 +0,0 @@
1
- import { BcsType, BcsStruct } from '@mysten/sui/bcs';
2
- import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
3
- import * as _mysten_bcs from '@mysten/bcs';
4
- import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
5
-
6
- interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
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;
107
-
108
- type BuildGameOptions<GameId extends StandardGame> = GameId extends 'coinflip' ? BuildCoinflipTransactionOptions : GameId extends 'wheel' ? BuildWheelTransactionOptions : GameId extends 'limbo' ? BuildLimboTransactionOptions : GameId extends 'plinko' ? BuildPlinkoTransactionOptions : GameId extends 'range' ? BuildRangeTransactionOptions : never;
109
-
110
- declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
111
- name: Name;
112
- register: (client: ClientWithCoreApi) => SuigarClient;
113
- };
114
- declare class SuigarClient {
115
- #private;
116
- constructor({ client }: {
117
- client: ClientWithCoreApi;
118
- });
119
- /**
120
- * Returns the resolved SDK configuration for the connected network.
121
- *
122
- * This is primarily useful for debugging or inspecting which package ids,
123
- * supported coin types, and price info object ids the SDK resolved for the
124
- * current client network.
125
- *
126
- * @returns Network-resolved Suigar configuration.
127
- */
128
- getConfig(): SuigarConfig;
129
- /**
130
- * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
131
- *
132
- * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
133
- * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
134
- * transaction build options except for `client`.
135
- *
136
- * @param transaction Transaction to build and serialize.
137
- * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
138
- * @returns Base64-encoded transaction bytes ready to send over the wire.
139
- */
140
- serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
141
- /**
142
- * BCS struct constructors for decoding Suigar events emitted on-chain.
143
- */
144
- bcs: {
145
- /**
146
- * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
147
- */
148
- BetResultEvent: MoveStruct<{
149
- player: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
150
- coin_type: MoveStruct<{
151
- name: _mysten_bcs.BcsType<string, string, "string">;
152
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
153
- stake_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
154
- unsafe_oracle_usd_coin_price: MoveStruct<{
155
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
156
- exp: MoveStruct<{
157
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
158
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
159
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
160
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
161
- adjusted_oracle_usd_coin_price: MoveStruct<{
162
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
163
- exp: MoveStruct<{
164
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
165
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
166
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
167
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
168
- outcome_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
169
- game_details: MoveStruct<{
170
- contents: _mysten_bcs.BcsType<{
171
- key: string;
172
- value: number[];
173
- }[], Iterable<{
174
- key: string;
175
- value: Iterable<number> & {
176
- length: number;
177
- };
178
- }> & {
179
- length: number;
180
- }, string>;
181
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
182
- metadata: MoveStruct<{
183
- contents: _mysten_bcs.BcsType<{
184
- key: string;
185
- value: number[];
186
- }[], Iterable<{
187
- key: string;
188
- value: Iterable<number> & {
189
- length: number;
190
- };
191
- }> & {
192
- length: number;
193
- }, string>;
194
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
195
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>">;
196
- /**
197
- * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
198
- */
199
- PvPCoinflipGameCreated: MoveStruct<{
200
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
201
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
202
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
203
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
204
- joiner_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
205
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
206
- house_edge_bps: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
207
- coin_type: MoveStruct<{
208
- name: _mysten_bcs.BcsType<string, string, "string">;
209
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
210
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameCreatedEvent<phantom T0>">;
211
- /**
212
- * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
213
- */
214
- PvPCoinflipGameResolved: MoveStruct<{
215
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
216
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
217
- joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
218
- winner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
219
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
220
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
221
- joiner_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
222
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
223
- total_pot: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
224
- house_edge_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
225
- payout_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
226
- coin_type: MoveStruct<{
227
- name: _mysten_bcs.BcsType<string, string, "string">;
228
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
229
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameResolvedEvent<phantom T0>">;
230
- /**
231
- * Event emitted when a PvP Coinflip game is cancelled.
232
- */
233
- PvPCoinflipGameCancelled: MoveStruct<{
234
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
235
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
236
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
237
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
238
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
239
- coin_type: MoveStruct<{
240
- name: _mysten_bcs.BcsType<string, string, "string">;
241
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
242
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameCancelledEvent<phantom T0>">;
243
- };
244
- /**
245
- * Transaction builders for Suigar games.
246
- */
247
- tx: {
248
- /**
249
- * Creates a standard game transaction for the provided game id.
250
- *
251
- * @param gameId Supported standard game identifier.
252
- * @param options Transaction builder options for the selected game.
253
- * @returns Prepared transaction for the selected game.
254
- */
255
- createBetTransaction: <GameId extends StandardGame>(gameId: GameId, options: BuildGameOptions<GameId>) => Transaction;
256
- /**
257
- * Creates a PvP coinflip transaction for the requested action.
258
- *
259
- * @param action PvP coinflip action to perform.
260
- * @param options Transaction builder options for the selected action.
261
- * @returns Prepared PvP coinflip transaction.
262
- */
263
- createPvPCoinflipTransaction: <Action extends PvPCoinflipAction>(action: Action, options: BuildPvPCoinflipTransactionOptions<Action>) => Transaction;
264
- };
265
- }
266
-
267
- export { suigar };
package/dist/index.d.ts DELETED
@@ -1,267 +0,0 @@
1
- import { BcsType, BcsStruct } from '@mysten/sui/bcs';
2
- import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
3
- import * as _mysten_bcs from '@mysten/bcs';
4
- import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
5
-
6
- interface GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> extends SuiClientTypes.GetObjectOptions<Include> {
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;
107
-
108
- type BuildGameOptions<GameId extends StandardGame> = GameId extends 'coinflip' ? BuildCoinflipTransactionOptions : GameId extends 'wheel' ? BuildWheelTransactionOptions : GameId extends 'limbo' ? BuildLimboTransactionOptions : GameId extends 'plinko' ? BuildPlinkoTransactionOptions : GameId extends 'range' ? BuildRangeTransactionOptions : never;
109
-
110
- declare function suigar<const Name = 'suigar'>({ name, }?: SuigarExtensionOptions<Name>): {
111
- name: Name;
112
- register: (client: ClientWithCoreApi) => SuigarClient;
113
- };
114
- declare class SuigarClient {
115
- #private;
116
- constructor({ client }: {
117
- client: ClientWithCoreApi;
118
- });
119
- /**
120
- * Returns the resolved SDK configuration for the connected network.
121
- *
122
- * This is primarily useful for debugging or inspecting which package ids,
123
- * supported coin types, and price info object ids the SDK resolved for the
124
- * current client network.
125
- *
126
- * @returns Network-resolved Suigar configuration.
127
- */
128
- getConfig(): SuigarConfig;
129
- /**
130
- * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
131
- *
132
- * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
133
- * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
134
- * transaction build options except for `client`.
135
- *
136
- * @param transaction Transaction to build and serialize.
137
- * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
138
- * @returns Base64-encoded transaction bytes ready to send over the wire.
139
- */
140
- serializeTransactionToBase64(transaction: Transaction, options?: Omit<BuildTransactionOptions, 'client'>): Promise<string>;
141
- /**
142
- * BCS struct constructors for decoding Suigar events emitted on-chain.
143
- */
144
- bcs: {
145
- /**
146
- * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
147
- */
148
- BetResultEvent: MoveStruct<{
149
- player: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
150
- coin_type: MoveStruct<{
151
- name: _mysten_bcs.BcsType<string, string, "string">;
152
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
153
- stake_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
154
- unsafe_oracle_usd_coin_price: MoveStruct<{
155
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
156
- exp: MoveStruct<{
157
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
158
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
159
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
160
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
161
- adjusted_oracle_usd_coin_price: MoveStruct<{
162
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
163
- exp: MoveStruct<{
164
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
165
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
166
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
167
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
168
- outcome_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
169
- game_details: MoveStruct<{
170
- contents: _mysten_bcs.BcsType<{
171
- key: string;
172
- value: number[];
173
- }[], Iterable<{
174
- key: string;
175
- value: Iterable<number> & {
176
- length: number;
177
- };
178
- }> & {
179
- length: number;
180
- }, string>;
181
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
182
- metadata: MoveStruct<{
183
- contents: _mysten_bcs.BcsType<{
184
- key: string;
185
- value: number[];
186
- }[], Iterable<{
187
- key: string;
188
- value: Iterable<number> & {
189
- length: number;
190
- };
191
- }> & {
192
- length: number;
193
- }, string>;
194
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
195
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>">;
196
- /**
197
- * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
198
- */
199
- PvPCoinflipGameCreated: MoveStruct<{
200
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
201
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
202
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
203
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
204
- joiner_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
205
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
206
- house_edge_bps: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
207
- coin_type: MoveStruct<{
208
- name: _mysten_bcs.BcsType<string, string, "string">;
209
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
210
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameCreatedEvent<phantom T0>">;
211
- /**
212
- * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
213
- */
214
- PvPCoinflipGameResolved: MoveStruct<{
215
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
216
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
217
- joiner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
218
- winner: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
219
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
220
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
221
- joiner_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
222
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
223
- total_pot: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
224
- house_edge_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
225
- payout_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
226
- coin_type: MoveStruct<{
227
- name: _mysten_bcs.BcsType<string, string, "string">;
228
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
229
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameResolvedEvent<phantom T0>">;
230
- /**
231
- * Event emitted when a PvP Coinflip game is cancelled.
232
- */
233
- PvPCoinflipGameCancelled: MoveStruct<{
234
- game_id: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
235
- creator: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
236
- creator_is_tails: _mysten_bcs.BcsType<boolean, boolean, "bool">;
237
- is_private: _mysten_bcs.BcsType<boolean, boolean, "bool">;
238
- stake_per_player: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
239
- coin_type: MoveStruct<{
240
- name: _mysten_bcs.BcsType<string, string, "string">;
241
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
242
- }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::GameCancelledEvent<phantom T0>">;
243
- };
244
- /**
245
- * Transaction builders for Suigar games.
246
- */
247
- tx: {
248
- /**
249
- * Creates a standard game transaction for the provided game id.
250
- *
251
- * @param gameId Supported standard game identifier.
252
- * @param options Transaction builder options for the selected game.
253
- * @returns Prepared transaction for the selected game.
254
- */
255
- createBetTransaction: <GameId extends StandardGame>(gameId: GameId, options: BuildGameOptions<GameId>) => Transaction;
256
- /**
257
- * Creates a PvP coinflip transaction for the requested action.
258
- *
259
- * @param action PvP coinflip action to perform.
260
- * @param options Transaction builder options for the selected action.
261
- * @returns Prepared PvP coinflip transaction.
262
- */
263
- createPvPCoinflipTransaction: <Action extends PvPCoinflipAction>(action: Action, options: BuildPvPCoinflipTransactionOptions<Action>) => Transaction;
264
- };
265
- }
266
-
267
- export { suigar };