@suigar/sdk 2.0.0-beta.13 → 2.0.0-beta.15

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 (160) hide show
  1. package/CHANGELOG.md +23 -4
  2. package/README.md +22 -8
  3. package/dist/client.d.mts +258 -0
  4. package/dist/client.d.mts.map +1 -0
  5. package/dist/client.mjs +291 -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 +55 -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 +14 -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 +34 -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 +33 -0
  66. package/dist/contracts/utils/index.d.mts.map +1 -0
  67. package/dist/contracts/utils/index.mjs +119 -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 +73 -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 +201 -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 +16 -17
  144. package/dist/chunk-7N55D2TV.js +0 -343
  145. package/dist/games-BHYRg31e.d.cts +0 -98
  146. package/dist/games-BHYRg31e.d.ts +0 -98
  147. package/dist/games.cjs +0 -2
  148. package/dist/games.d.cts +0 -2
  149. package/dist/games.d.ts +0 -2
  150. package/dist/games.js +0 -1
  151. package/dist/index-3P_LBbDM.d.cts +0 -25
  152. package/dist/index-3P_LBbDM.d.ts +0 -25
  153. package/dist/index.cjs +0 -1692
  154. package/dist/index.d.cts +0 -457
  155. package/dist/index.d.ts +0 -457
  156. package/dist/index.js +0 -1470
  157. package/dist/utils.cjs +0 -243
  158. package/dist/utils.d.cts +0 -180
  159. package/dist/utils.d.ts +0 -180
  160. package/dist/utils.js +0 -1
@@ -0,0 +1,291 @@
1
+ import { TypeName } from "./contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs";
2
+ import { BetResultEvent } from "./contracts/core/core.mjs";
3
+ import { Game, GameCancelledEvent, GameCreatedEvent, GameResolvedEvent } from "./contracts/pvp-coinflip/pvp_coinflip.mjs";
4
+ import { resolveGamePackageId, resolveSuigarConfig } from "./helpers/config.mjs";
5
+ import { resolveCoinTypeNameForTypeNameKey, resolveGameSettingsKeyType } from "./helpers/game-settings.mjs";
6
+ import { SUPPORTED_SUI_NETWORKS } from "./types/network.type.mjs";
7
+ import { parseCoinType } from "./utils/parser.mjs";
8
+ import { buildCoinflipTransaction } from "./transactions/coinflip.mjs";
9
+ import { buildLimboTransaction } from "./transactions/limbo.mjs";
10
+ import { buildPlinkoTransaction } from "./transactions/plinko.mjs";
11
+ import { buildPvPCoinflipTransaction } from "./transactions/pvp-coinflip.mjs";
12
+ import { buildRangeTransaction } from "./transactions/range.mjs";
13
+ import { buildWheelTransaction } from "./transactions/wheel.mjs";
14
+ import { TtlClientCache } from "./ttl-cache.mjs";
15
+ import { GAME_SETTINGS } from "./types/game-settings.type.mjs";
16
+ import { normalizeStructTag, toBase64 } from "@mysten/sui/utils";
17
+ //#region src/client.ts
18
+ function suigar({ name = "suigar", partner, cacheTtl } = {}) {
19
+ return {
20
+ name,
21
+ register: (client) => {
22
+ return new SuigarClient({
23
+ client,
24
+ name: String(name),
25
+ partner,
26
+ cacheTtl
27
+ });
28
+ }
29
+ };
30
+ }
31
+ var SuigarClient = class {
32
+ #client;
33
+ #config;
34
+ #partner;
35
+ #cache;
36
+ constructor({ client, name, partner, cacheTtl }) {
37
+ this.#client = client;
38
+ this.#partner = partner;
39
+ this.#cache = client.cache.scope("@suigar/sdk").readSync([name, "ttl-cache"], () => {
40
+ return new TtlClientCache({ ttlMs: cacheTtl ?? 18e5 });
41
+ });
42
+ const network = this.#client.network;
43
+ if (!SUPPORTED_SUI_NETWORKS.includes(network)) throw new RangeError(`Unsupported network: ${network}`);
44
+ this.#config = resolveSuigarConfig(network);
45
+ }
46
+ /**
47
+ * Returns the resolved SDK configuration for the connected network.
48
+ *
49
+ * This is primarily useful for debugging or inspecting which package ids,
50
+ * registry ids, supported coin types, and price info object ids the SDK
51
+ * resolved for the current client network.
52
+ *
53
+ * @returns Network-resolved Suigar configuration.
54
+ */
55
+ getConfig() {
56
+ return this.#config;
57
+ }
58
+ /**
59
+ * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
60
+ *
61
+ * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
62
+ * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
63
+ * transaction build options except for `client`.
64
+ *
65
+ * @param transaction Transaction to build and serialize.
66
+ * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
67
+ * @returns Base64-encoded transaction bytes ready to send over the wire.
68
+ */
69
+ async serializeTransactionToBase64(transaction, options) {
70
+ return toBase64(await transaction.build({
71
+ ...options,
72
+ client: this.#client
73
+ }));
74
+ }
75
+ /**
76
+ * Reads on-chain game parameters for the requested game.
77
+ *
78
+ * The SDK first reads the selected game's settings object from SweetHouse,
79
+ * then reads that game's coin-specific `Parameters<T>` object. Results are
80
+ * cached according to the extension `cacheTtl` option. Pass
81
+ * `ignoreCache: true` to refresh the on-chain read and replace the cached
82
+ * value.
83
+ *
84
+ * @param game Game whose parameters should be loaded.
85
+ * @param options Optional coin type, cache override, and abort signal.
86
+ * @returns Parsed game parameters typed for the requested game.
87
+ */
88
+ async getGameParameters(game, options = {}) {
89
+ const coinType = normalizeStructTag(options.coinType ?? this.#config.coinTypes.sui);
90
+ return this.#cache.read([
91
+ "parameters",
92
+ this.#client.network,
93
+ game,
94
+ coinType
95
+ ], () => this.#fetchGameParameters(game, coinType, options.signal), { ignoreCache: options.ignoreCache });
96
+ }
97
+ /**
98
+ * Lists unresolved PvP coinflip games from the configured registry and resolves
99
+ * each entry into parsed on-chain game state.
100
+ *
101
+ * This fetches dynamic fields from the PvP coinflip registry object, then bulk
102
+ * loads the referenced game objects through `client.core.getObjects()`. Registry
103
+ * membership is the unresolved-state signal: when a game is joined and resolved,
104
+ * the Move flow removes it from the registry and deletes the live `Game` object.
105
+ * Use this when a product needs the current set of open PvP coinflip matches for
106
+ * browsing or lobby views.
107
+ *
108
+ * @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.
109
+ * Supported options such as `limit`, `cursor`, and `signal` are forwarded to the
110
+ * underlying lookup calls. Pass `throwOnError: true` to fail the whole lookup
111
+ * when any referenced game object cannot be fetched or parsed. By default,
112
+ * failed per-object lookups are skipped and only successfully parsed unresolved
113
+ * games are returned.
114
+ * @returns Parsed unresolved PvP coinflip game objects for the requested
115
+ * registry page. When `throwOnError` is `false`, entries that fail object fetch
116
+ * or parse are omitted from the returned array.
117
+ */
118
+ async getPvPCoinflipGames(options = { limit: 50 }) {
119
+ const { throwOnError = false, ...listOptions } = options;
120
+ const { dynamicFields } = await this.#client.core.listDynamicFields({
121
+ ...listOptions,
122
+ parentId: this.#config.registryIds.pvpCoinflip
123
+ });
124
+ const { objects } = await this.#client.core.getObjects({
125
+ objectIds: dynamicFields.map(({ childId }) => childId),
126
+ signal: listOptions.signal,
127
+ include: { content: true }
128
+ });
129
+ const resolvedGames = objects.map((object) => {
130
+ try {
131
+ if (object instanceof Error) throw object;
132
+ if (!object.content) throw new Error("Unable to resolve PvP coinflip game from retrieved object");
133
+ return {
134
+ ...Game.parse(object.content),
135
+ coin_type: parseCoinType(object.type)
136
+ };
137
+ } catch (error) {
138
+ return error instanceof Error ? error : new Error(String(error));
139
+ }
140
+ });
141
+ if (throwOnError) {
142
+ const firstError = resolvedGames.find((game) => game instanceof Error);
143
+ if (firstError) throw firstError;
144
+ }
145
+ return resolvedGames.flatMap((game) => game instanceof Error ? [] : [game]);
146
+ }
147
+ /**
148
+ * BCS struct constructors for decoding on-chain objects and events related to Suigar games.
149
+ *
150
+ * These can be used to parse the `content` field of on-chain objects and events into structured data with the
151
+ * expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP
152
+ * coinflip game object.
153
+ *
154
+ * Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction
155
+ * builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.
156
+ */
157
+ bcs = {
158
+ /**
159
+ * Object representing the state of a PvP coinflip game, as stored on-chain.
160
+ */
161
+ PvPCoinflipGame: Game,
162
+ /**
163
+ * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
164
+ */
165
+ BetResultEvent,
166
+ /**
167
+ * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
168
+ */
169
+ PvPCoinflipGameCreatedEvent: GameCreatedEvent,
170
+ /**
171
+ * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
172
+ */
173
+ PvPCoinflipGameResolvedEvent: GameResolvedEvent,
174
+ /**
175
+ * Event emitted when a PvP Coinflip game is cancelled.
176
+ */
177
+ PvPCoinflipGameCancelledEvent: GameCancelledEvent
178
+ };
179
+ /**
180
+ * Transaction builders for Suigar games.
181
+ */
182
+ tx = {
183
+ /**
184
+ * Creates a standard game transaction for the provided game id.
185
+ *
186
+ * @param gameId Supported standard game identifier.
187
+ * @param options Transaction builder options for the selected game.
188
+ * @returns Prepared transaction for the selected game.
189
+ */
190
+ createBetTransaction: (gameId, options) => {
191
+ switch (gameId) {
192
+ case "coinflip": return buildCoinflipTransaction({
193
+ ...options,
194
+ config: this.#config,
195
+ partner: this.#partner
196
+ });
197
+ case "limbo": return buildLimboTransaction({
198
+ ...options,
199
+ config: this.#config,
200
+ partner: this.#partner
201
+ });
202
+ case "plinko": return buildPlinkoTransaction({
203
+ ...options,
204
+ config: this.#config,
205
+ partner: this.#partner
206
+ });
207
+ case "range": return buildRangeTransaction({
208
+ ...options,
209
+ config: this.#config,
210
+ partner: this.#partner
211
+ });
212
+ case "wheel": return buildWheelTransaction({
213
+ ...options,
214
+ config: this.#config,
215
+ partner: this.#partner
216
+ });
217
+ default: throw new RangeError(`Unsupported game: ${gameId}`);
218
+ }
219
+ },
220
+ /**
221
+ * Creates a PvP coinflip transaction for the requested action.
222
+ *
223
+ * @param action PvP coinflip action to perform.
224
+ * @param options Transaction builder options for the selected action.
225
+ * @returns Prepared PvP coinflip transaction.
226
+ */
227
+ createPvPCoinflipTransaction: (action, options) => {
228
+ switch (action) {
229
+ case "create": return buildPvPCoinflipTransaction("create", {
230
+ ...options,
231
+ config: this.#config,
232
+ partner: this.#partner
233
+ });
234
+ case "join": {
235
+ const joinOptions = options;
236
+ return buildPvPCoinflipTransaction("join", {
237
+ ...joinOptions,
238
+ betCoin: this.#createPvPCoinflipBetCoin(joinOptions),
239
+ config: this.#config,
240
+ partner: this.#partner
241
+ });
242
+ }
243
+ case "cancel": return buildPvPCoinflipTransaction("cancel", {
244
+ ...options,
245
+ config: this.#config,
246
+ partner: this.#partner
247
+ });
248
+ default: throw new RangeError(`Unsupported PvP coinflip action: ${action}`);
249
+ }
250
+ }
251
+ };
252
+ #createPvPCoinflipBetCoin(options) {
253
+ return async (tx) => {
254
+ const { json } = await Game.get({
255
+ client: this.#client,
256
+ objectId: options.gameId
257
+ });
258
+ return tx.coin({
259
+ type: options.coinType,
260
+ balance: BigInt(json.stake_per_player),
261
+ useGasCoin: options.allowGasCoinShortcut
262
+ });
263
+ };
264
+ }
265
+ async #fetchGameParameters(game, coinType, signal) {
266
+ const gameDefinition = GAME_SETTINGS[game];
267
+ const { object: settingsObject } = await this.#client.core.getDynamicObjectField({
268
+ parentId: this.#config.packageIds.sweetHouse,
269
+ name: {
270
+ type: resolveGameSettingsKeyType(gameDefinition.settingsKey.name, resolveGamePackageId(this.#config, game)),
271
+ bcs: gameDefinition.settingsKey.serialize({ dummy_field: false }).toBytes()
272
+ },
273
+ signal
274
+ });
275
+ const { object } = await this.#client.core.getDynamicObjectField({
276
+ parentId: settingsObject.objectId,
277
+ name: {
278
+ type: TypeName.name,
279
+ bcs: TypeName.serialize({ name: resolveCoinTypeNameForTypeNameKey(coinType) }).toBytes()
280
+ },
281
+ include: { content: true },
282
+ signal
283
+ });
284
+ if (!object?.content) throw new Error(`Missing parameters object content for ${game} and coin type ${coinType}`);
285
+ return gameDefinition.parameters.parse(object.content);
286
+ }
287
+ };
288
+ //#endregion
289
+ export { SuigarClient, suigar };
290
+
291
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.mjs","names":["#client","#partner","#cache","#config","#fetchGameParameters","PvPCoinflipGame","#createPvPCoinflipBetCoin"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport {\n\tBuildTransactionOptions,\n\tTransaction,\n\tTransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, toBase64 } from '@mysten/sui/utils';\nimport { BetResultEvent } from './contracts/core/core';\nimport { TypeName } from './contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name';\nimport {\n\tGame as PvPCoinflipGame,\n\tGameCancelledEvent as PvPCoinflipGameCancelledEvent,\n\tGameCreatedEvent as PvPCoinflipGameCreatedEvent,\n\tGameResolvedEvent as PvPCoinflipGameResolvedEvent,\n} from './contracts/pvp-coinflip/pvp_coinflip';\nimport {\n\tDEFAULT_CACHE_TTL_MS,\n\tresolveCoinTypeNameForTypeNameKey,\n\tresolveGamePackageId,\n\tresolveGameSettingsKeyType,\n\tresolveSuigarConfig,\n} from './helpers/index.js';\nimport {\n\tbuildCoinflipTransaction,\n\tbuildLimboTransaction,\n\tbuildPlinkoTransaction,\n\tbuildPvPCoinflipTransaction,\n\tbuildRangeTransaction,\n\tbuildWheelTransaction,\n} from './transactions';\nimport { TtlClientCache } from './ttl-cache.js';\nimport {\n\tBuildCancelPvPCoinflipTransactionOptions,\n\tBuildCoinflipTransactionOptions,\n\tBuildCreatePvPCoinflipTransactionOptions,\n\tBuildGameOptions,\n\tBuildJoinPvPCoinflipTransactionOptions,\n\tBuildLimboTransactionOptions,\n\tBuildPlinkoTransactionOptions,\n\tBuildPvPCoinflipTransactionOptions,\n\tBuildRangeTransactionOptions,\n\tBuildWheelTransactionOptions,\n\tGame,\n\tPvPCoinflipAction,\n\tStandardGame,\n\tSuigarConfig,\n\tSuigarExtensionOptions,\n\tSuiNetwork,\n\tSUPPORTED_SUI_NETWORKS,\n\tWithPartner,\n\tWithThrowOnError,\n} from './types';\nimport {\n\tGAME_SETTINGS,\n\ttype GameParameters,\n\ttype GetGameParametersOptions,\n} from './types/game-settings.type.js';\nimport { parseCoinType } from './utils/index.js';\n\nexport function suigar<const Name = 'suigar'>({\n\tname = 'suigar' as Name,\n\tpartner,\n\tcacheTtl,\n}: SuigarExtensionOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi): SuigarClient => {\n\t\t\treturn new SuigarClient({\n\t\t\t\tclient,\n\t\t\t\tname: String(name),\n\t\t\t\tpartner,\n\t\t\t\tcacheTtl,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport class SuigarClient {\n\t#client: ClientWithCoreApi;\n\n\t#config: SuigarConfig;\n\n\t#partner: string | undefined;\n\n\t#cache: TtlClientCache;\n\n\tconstructor({\n\t\tclient,\n\t\tname,\n\t\tpartner,\n\t\tcacheTtl,\n\t}: {\n\t\tclient: ClientWithCoreApi;\n\t\tname: string;\n\t\tpartner?: string;\n\t\tcacheTtl?: number;\n\t}) {\n\t\tthis.#client = client;\n\t\tthis.#partner = partner;\n\t\tthis.#cache = client.cache\n\t\t\t.scope('@suigar/sdk')\n\t\t\t.readSync([name, 'ttl-cache'], () => {\n\t\t\t\treturn new TtlClientCache({\n\t\t\t\t\tttlMs: cacheTtl ?? DEFAULT_CACHE_TTL_MS,\n\t\t\t\t});\n\t\t\t});\n\n\t\tconst network = this.#client.network as SuiNetwork;\n\t\tif (!SUPPORTED_SUI_NETWORKS.includes(network)) {\n\t\t\tthrow new RangeError(`Unsupported network: ${network}`);\n\t\t}\n\n\t\tthis.#config = resolveSuigarConfig(network);\n\t}\n\n\t/**\n\t * Returns the resolved SDK configuration for the connected network.\n\t *\n\t * This is primarily useful for debugging or inspecting which package ids,\n\t * registry ids, supported coin types, and price info object ids the SDK\n\t * resolved for the current client network.\n\t *\n\t * @returns Network-resolved Suigar configuration.\n\t */\n\tgetConfig(): SuigarConfig {\n\t\treturn this.#config;\n\t}\n\n\t/**\n\t * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.\n\t *\n\t * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string\n\t * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard\n\t * transaction build options except for `client`.\n\t *\n\t * @param transaction Transaction to build and serialize.\n\t * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.\n\t * @returns Base64-encoded transaction bytes ready to send over the wire.\n\t */\n\tasync serializeTransactionToBase64(\n\t\ttransaction: Transaction,\n\t\toptions?: Omit<BuildTransactionOptions, 'client'>,\n\t): Promise<string> {\n\t\tconst bytes = await transaction.build({ ...options, client: this.#client });\n\t\treturn toBase64(bytes);\n\t}\n\n\t/**\n\t * Reads on-chain game parameters for the requested game.\n\t *\n\t * The SDK first reads the selected game's settings object from SweetHouse,\n\t * then reads that game's coin-specific `Parameters<T>` object. Results are\n\t * cached according to the extension `cacheTtl` option. Pass\n\t * `ignoreCache: true` to refresh the on-chain read and replace the cached\n\t * value.\n\t *\n\t * @param game Game whose parameters should be loaded.\n\t * @param options Optional coin type, cache override, and abort signal.\n\t * @returns Parsed game parameters typed for the requested game.\n\t */\n\tasync getGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\toptions: GetGameParametersOptions = {},\n\t): Promise<GameParameters<TGame>> {\n\t\tconst coinType = normalizeStructTag(\n\t\t\toptions.coinType ?? this.#config.coinTypes.sui,\n\t\t);\n\t\treturn this.#cache.read(\n\t\t\t['parameters', this.#client.network, game, coinType],\n\t\t\t() => this.#fetchGameParameters(game, coinType, options.signal),\n\t\t\t{ ignoreCache: options.ignoreCache },\n\t\t) as Promise<GameParameters<TGame>>;\n\t}\n\n\t/**\n\t * Lists unresolved PvP coinflip games from the configured registry and resolves\n\t * each entry into parsed on-chain game state.\n\t *\n\t * This fetches dynamic fields from the PvP coinflip registry object, then bulk\n\t * loads the referenced game objects through `client.core.getObjects()`. Registry\n\t * membership is the unresolved-state signal: when a game is joined and resolved,\n\t * the Move flow removes it from the registry and deletes the live `Game` object.\n\t * Use this when a product needs the current set of open PvP coinflip matches for\n\t * browsing or lobby views.\n\t *\n\t * @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.\n\t * Supported options such as `limit`, `cursor`, and `signal` are forwarded to the\n\t * underlying lookup calls. Pass `throwOnError: true` to fail the whole lookup\n\t * when any referenced game object cannot be fetched or parsed. By default,\n\t * failed per-object lookups are skipped and only successfully parsed unresolved\n\t * games are returned.\n\t * @returns Parsed unresolved PvP coinflip game objects for the requested\n\t * registry page. When `throwOnError` is `false`, entries that fail object fetch\n\t * or parse are omitted from the returned array.\n\t */\n\tasync getPvPCoinflipGames(\n\t\toptions: WithThrowOnError<\n\t\t\tOmit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>\n\t\t> = {\n\t\t\tlimit: 50,\n\t\t},\n\t): Promise<(InferBcsType<typeof PvPCoinflipGame> & { coin_type: string })[]> {\n\t\tconst { throwOnError = false, ...listOptions } = options;\n\t\tconst { dynamicFields } = await this.#client.core.listDynamicFields({\n\t\t\t...listOptions,\n\t\t\tparentId: this.#config.registryIds.pvpCoinflip,\n\t\t});\n\n\t\tconst { objects } = await this.#client.core.getObjects({\n\t\t\tobjectIds: dynamicFields.map(({ childId }) => childId!),\n\t\t\tsignal: listOptions.signal,\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t});\n\n\t\tconst resolvedGames = objects.map((object) => {\n\t\t\ttry {\n\t\t\t\tif (object instanceof Error) {\n\t\t\t\t\tthrow object;\n\t\t\t\t}\n\n\t\t\t\tif (!object.content) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unable to resolve PvP coinflip game from retrieved object',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...PvPCoinflipGame.parse(object.content),\n\t\t\t\t\tcoin_type: parseCoinType(object.type),\n\t\t\t\t} satisfies Awaited<\n\t\t\t\t\tReturnType<SuigarClient['getPvPCoinflipGames']>\n\t\t\t\t>[number];\n\t\t\t} catch (error) {\n\t\t\t\treturn error instanceof Error ? error : new Error(String(error));\n\t\t\t}\n\t\t});\n\n\t\tif (throwOnError) {\n\t\t\tconst firstError = resolvedGames.find((game) => game instanceof Error);\n\t\t\tif (firstError) {\n\t\t\t\tthrow firstError;\n\t\t\t}\n\t\t}\n\n\t\treturn resolvedGames.flatMap((game) =>\n\t\t\tgame instanceof Error ? [] : [game],\n\t\t);\n\t}\n\n\t/**\n\t * BCS struct constructors for decoding on-chain objects and events related to Suigar games.\n\t *\n\t * These can be used to parse the `content` field of on-chain objects and events into structured data with the\n\t * expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP\n\t * coinflip game object.\n\t *\n\t * Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction\n\t * builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.\n\t */\n\tbcs = {\n\t\t// Objects\n\t\t/**\n\t\t * Object representing the state of a PvP coinflip game, as stored on-chain.\n\t\t */\n\t\tPvPCoinflipGame,\n\t\t// Events\n\t\t/**\n\t\t * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.\n\t\t */\n\t\tBetResultEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.\n\t\t */\n\t\tPvPCoinflipGameCreatedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.\n\t\t */\n\t\tPvPCoinflipGameResolvedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is cancelled.\n\t\t */\n\t\tPvPCoinflipGameCancelledEvent,\n\t};\n\n\t/**\n\t * Transaction builders for Suigar games.\n\t */\n\ttx = {\n\t\t/**\n\t\t * Creates a standard game transaction for the provided game id.\n\t\t *\n\t\t * @param gameId Supported standard game identifier.\n\t\t * @param options Transaction builder options for the selected game.\n\t\t * @returns Prepared transaction for the selected game.\n\t\t */\n\t\tcreateBetTransaction: <GameId extends StandardGame>(\n\t\t\tgameId: GameId,\n\t\t\toptions: BuildGameOptions<GameId>,\n\t\t): Transaction => {\n\t\t\tswitch (gameId) {\n\t\t\t\tcase 'coinflip':\n\t\t\t\t\treturn buildCoinflipTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildCoinflipTransactionOptions>);\n\t\t\t\tcase 'limbo':\n\t\t\t\t\treturn buildLimboTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildLimboTransactionOptions>);\n\t\t\t\tcase 'plinko':\n\t\t\t\t\treturn buildPlinkoTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildPlinkoTransactionOptions>);\n\t\t\t\tcase 'range':\n\t\t\t\t\treturn buildRangeTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildRangeTransactionOptions>);\n\t\t\t\tcase 'wheel':\n\t\t\t\t\treturn buildWheelTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildWheelTransactionOptions>);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported game: ${gameId}`);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Creates a PvP coinflip transaction for the requested action.\n\t\t *\n\t\t * @param action PvP coinflip action to perform.\n\t\t * @param options Transaction builder options for the selected action.\n\t\t * @returns Prepared PvP coinflip transaction.\n\t\t */\n\t\tcreatePvPCoinflipTransaction: <Action extends PvPCoinflipAction>(\n\t\t\taction: Action,\n\t\t\toptions: BuildPvPCoinflipTransactionOptions<Action>,\n\t\t): Transaction => {\n\t\t\tswitch (action) {\n\t\t\t\tcase 'create':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('create', {\n\t\t\t\t\t\t...(options as BuildCreatePvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tcase 'join': {\n\t\t\t\t\tconst joinOptions = options as BuildJoinPvPCoinflipTransactionOptions;\n\t\t\t\t\treturn buildPvPCoinflipTransaction('join', {\n\t\t\t\t\t\t...joinOptions,\n\t\t\t\t\t\tbetCoin: this.#createPvPCoinflipBetCoin(joinOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcase 'cancel':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('cancel', {\n\t\t\t\t\t\t...(options as BuildCancelPvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported PvP coinflip action: ${action}`);\n\t\t\t}\n\t\t},\n\t};\n\n\t#createPvPCoinflipBetCoin(\n\t\toptions: BuildJoinPvPCoinflipTransactionOptions,\n\t): (tx: Transaction) => Promise<TransactionResult> {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst { json } = await PvPCoinflipGame.get({\n\t\t\t\tclient: this.#client,\n\t\t\t\tobjectId: options.gameId,\n\t\t\t});\n\n\t\t\treturn tx.coin({\n\t\t\t\ttype: options.coinType,\n\t\t\t\tbalance: BigInt(json.stake_per_player),\n\t\t\t\tuseGasCoin: options.allowGasCoinShortcut,\n\t\t\t});\n\t\t};\n\t}\n\n\tasync #fetchGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\tcoinType: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GameParameters<TGame>> {\n\t\tconst gameDefinition = GAME_SETTINGS[game];\n\n\t\tconst { object: settingsObject } =\n\t\t\tawait this.#client.core.getDynamicObjectField({\n\t\t\t\tparentId: this.#config.packageIds.sweetHouse,\n\t\t\t\tname: {\n\t\t\t\t\ttype: resolveGameSettingsKeyType(\n\t\t\t\t\t\tgameDefinition.settingsKey.name,\n\t\t\t\t\t\tresolveGamePackageId(this.#config, game),\n\t\t\t\t\t),\n\t\t\t\t\tbcs: gameDefinition.settingsKey\n\t\t\t\t\t\t.serialize({ dummy_field: false })\n\t\t\t\t\t\t.toBytes(),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\tconst { object } = await this.#client.core.getDynamicObjectField({\n\t\t\tparentId: settingsObject.objectId,\n\t\t\tname: {\n\t\t\t\ttype: TypeName.name,\n\t\t\t\tbcs: TypeName.serialize({\n\t\t\t\t\tname: resolveCoinTypeNameForTypeNameKey(coinType),\n\t\t\t\t}).toBytes(),\n\t\t\t},\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t\tsignal,\n\t\t});\n\n\t\tif (!object?.content) {\n\t\t\tthrow new Error(\n\t\t\t\t`Missing parameters object content for ${game} and coin type ${coinType}`,\n\t\t\t);\n\t\t}\n\n\t\treturn gameDefinition.parameters.parse(\n\t\t\tobject.content,\n\t\t) as GameParameters<TGame>;\n\t}\n}\n"],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ //#region src/configs/package.mainnet.ts
2
+ const MAINNET_PACKAGE_IDS = {
3
+ sweetHouse: "0xa1549d73230118716bc08865b8d62454f360ddaf40eee2158e458e52125d4ef1",
4
+ core: "0xcbb0929f21450013ebe5e86e7139f2409da2e3ed212c51126a7e6448b795a43f",
5
+ coinflip: "0xca96885371150f55653f7fab9e9b146f5a19698b1002bdff42159ea9d2ba7d7e",
6
+ limbo: "0x89db6a55ad4e650cad641b6f9fd90b391b22b1d9adbb2cabbfeb94a9eeda7026",
7
+ plinko: "0x74a73daff11c11ed05299c93ed770c62ec4dc6756fa99e271e251c2399f49fef",
8
+ pvpCoinflip: "0x29162faf01a8135630e0a32bbe4ce47f69607b24dbb1edea3800861f91d0030a",
9
+ range: "0xd19e32b0f2a5e541fbd345b4602f8a93a2eee25c16029595b6fef0b1e0461a54",
10
+ wheel: "0x6791eac73fe7bf463b7f3b1ea391df265fbc1b96201270664a5a11e2441e9955"
11
+ };
12
+ const MAINNET_COIN_TYPES = {
13
+ sui: "0x2::sui::SUI",
14
+ usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
15
+ };
16
+ const MAINNET_PRICE_INFO_OBJECT_IDS = {
17
+ sui: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37",
18
+ usdc: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
19
+ };
20
+ //#endregion
21
+ export { MAINNET_COIN_TYPES, MAINNET_PACKAGE_IDS, MAINNET_PRICE_INFO_OBJECT_IDS };
22
+
23
+ //# sourceMappingURL=package.mainnet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.mainnet.mjs","names":[],"sources":["../../src/configs/package.mainnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tSuigarCoinTypes,\n\tSuigarPackageIds,\n\tSuigarPriceInfoObjectIds,\n} from '../types/suigar-config.type.js';\n\n// `sweetHouse` is preserved manually because it is not currently resolved from MVR.\nexport const MAINNET_PACKAGE_IDS: SuigarPackageIds = {\n\tsweetHouse:\n\t\t'0xa1549d73230118716bc08865b8d62454f360ddaf40eee2158e458e52125d4ef1',\n\tcore: '0xcbb0929f21450013ebe5e86e7139f2409da2e3ed212c51126a7e6448b795a43f',\n\tcoinflip:\n\t\t'0xca96885371150f55653f7fab9e9b146f5a19698b1002bdff42159ea9d2ba7d7e',\n\tlimbo: '0x89db6a55ad4e650cad641b6f9fd90b391b22b1d9adbb2cabbfeb94a9eeda7026',\n\tplinko: '0x74a73daff11c11ed05299c93ed770c62ec4dc6756fa99e271e251c2399f49fef',\n\tpvpCoinflip:\n\t\t'0x29162faf01a8135630e0a32bbe4ce47f69607b24dbb1edea3800861f91d0030a',\n\trange: '0xd19e32b0f2a5e541fbd345b4602f8a93a2eee25c16029595b6fef0b1e0461a54',\n\twheel: '0x6791eac73fe7bf463b7f3b1ea391df265fbc1b96201270664a5a11e2441e9955',\n};\n\nexport const MAINNET_COIN_TYPES: SuigarCoinTypes = {\n\tsui: '0x2::sui::SUI',\n\tusdc: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',\n};\n\nexport const MAINNET_PRICE_INFO_OBJECT_IDS: SuigarPriceInfoObjectIds = {\n\tsui: '0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37',\n\tusdc: '0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab',\n};\n"],"mappings":";AAUA,MAAa,sBAAwC;CACpD,YACC;CACD,MAAM;CACN,UACC;CACD,OAAO;CACP,QAAQ;CACR,aACC;CACD,OAAO;CACP,OAAO;CACP;AAED,MAAa,qBAAsC;CAClD,KAAK;CACL,MAAM;CACN;AAED,MAAa,gCAA0D;CACtE,KAAK;CACL,MAAM;CACN"}
@@ -0,0 +1,19 @@
1
+ import { MAINNET_COIN_TYPES, MAINNET_PACKAGE_IDS, MAINNET_PRICE_INFO_OBJECT_IDS } from "./package.mainnet.mjs";
2
+ import { TESTNET_COIN_TYPES, TESTNET_PACKAGE_IDS, TESTNET_PRICE_INFO_OBJECT_IDS } from "./package.testnet.mjs";
3
+ //#region src/configs/package.ts
4
+ const PACKAGE_IDS = {
5
+ mainnet: { ...MAINNET_PACKAGE_IDS },
6
+ testnet: { ...TESTNET_PACKAGE_IDS }
7
+ };
8
+ const COIN_TYPES = {
9
+ mainnet: { ...MAINNET_COIN_TYPES },
10
+ testnet: { ...TESTNET_COIN_TYPES }
11
+ };
12
+ const PRICE_INFO_OBJECT_IDS = {
13
+ mainnet: { ...MAINNET_PRICE_INFO_OBJECT_IDS },
14
+ testnet: { ...TESTNET_PRICE_INFO_OBJECT_IDS }
15
+ };
16
+ //#endregion
17
+ export { COIN_TYPES, PACKAGE_IDS, PRICE_INFO_OBJECT_IDS };
18
+
19
+ //# sourceMappingURL=package.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.mjs","names":[],"sources":["../../src/configs/package.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tSuigarCoinTypes,\n\tSuigarPackageIds,\n\tSuigarPriceInfoObjectIds,\n\tSuiNetworkRegistry,\n} from '../types/suigar-config.type.js';\nimport {\n\tMAINNET_COIN_TYPES,\n\tMAINNET_PACKAGE_IDS,\n\tMAINNET_PRICE_INFO_OBJECT_IDS,\n} from './package.mainnet.js';\nimport {\n\tTESTNET_COIN_TYPES,\n\tTESTNET_PACKAGE_IDS,\n\tTESTNET_PRICE_INFO_OBJECT_IDS,\n} from './package.testnet.js';\n\nexport const PACKAGE_IDS: SuiNetworkRegistry<SuigarPackageIds> = {\n\tmainnet: { ...MAINNET_PACKAGE_IDS },\n\ttestnet: { ...TESTNET_PACKAGE_IDS },\n};\n\nexport const COIN_TYPES: SuiNetworkRegistry<SuigarCoinTypes> = {\n\tmainnet: { ...MAINNET_COIN_TYPES },\n\ttestnet: { ...TESTNET_COIN_TYPES },\n};\n\nexport const PRICE_INFO_OBJECT_IDS: SuiNetworkRegistry<SuigarPriceInfoObjectIds> =\n\t{\n\t\tmainnet: { ...MAINNET_PRICE_INFO_OBJECT_IDS },\n\t\ttestnet: { ...TESTNET_PRICE_INFO_OBJECT_IDS },\n\t};\n"],"mappings":";;;AAoBA,MAAa,cAAoD;CAChE,SAAS,EAAE,GAAG,qBAAqB;CACnC,SAAS,EAAE,GAAG,qBAAqB;CACnC;AAED,MAAa,aAAkD;CAC9D,SAAS,EAAE,GAAG,oBAAoB;CAClC,SAAS,EAAE,GAAG,oBAAoB;CAClC;AAED,MAAa,wBACZ;CACC,SAAS,EAAE,GAAG,+BAA+B;CAC7C,SAAS,EAAE,GAAG,+BAA+B;CAC7C"}
@@ -0,0 +1,23 @@
1
+ //#region src/configs/package.testnet.ts
2
+ const TESTNET_PACKAGE_IDS = {
3
+ sweetHouse: "0xb7f64e5a273aba1ede00caa0a6f8027cc7490c279d17eab12e7100ed20660603",
4
+ core: "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc",
5
+ coinflip: "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea",
6
+ limbo: "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4",
7
+ plinko: "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7",
8
+ pvpCoinflip: "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202",
9
+ range: "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416",
10
+ wheel: "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7"
11
+ };
12
+ const TESTNET_COIN_TYPES = {
13
+ sui: "0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_sui::TEST_SUI",
14
+ usdc: "0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_usdc::TEST_USDC"
15
+ };
16
+ const TESTNET_PRICE_INFO_OBJECT_IDS = {
17
+ sui: "0x1ebb295c789cc42b3b2a1606482cd1c7124076a0f5676718501fda8c7fd075a0",
18
+ usdc: "0x9c4dd4008297ffa5e480684b8100ec21cc934405ed9a25d4e4d7b6259aad9c81"
19
+ };
20
+ //#endregion
21
+ export { TESTNET_COIN_TYPES, TESTNET_PACKAGE_IDS, TESTNET_PRICE_INFO_OBJECT_IDS };
22
+
23
+ //# sourceMappingURL=package.testnet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.testnet.mjs","names":[],"sources":["../../src/configs/package.testnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tSuigarCoinTypes,\n\tSuigarPackageIds,\n\tSuigarPriceInfoObjectIds,\n} from '../types/suigar-config.type.js';\n\n// `sweetHouse` is preserved manually because it is not currently resolved from MVR.\nexport const TESTNET_PACKAGE_IDS: SuigarPackageIds = {\n\tsweetHouse:\n\t\t'0xb7f64e5a273aba1ede00caa0a6f8027cc7490c279d17eab12e7100ed20660603',\n\tcore: '0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc',\n\tcoinflip:\n\t\t'0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea',\n\tlimbo: '0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4',\n\tplinko: '0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7',\n\tpvpCoinflip:\n\t\t'0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202',\n\trange: '0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416',\n\twheel: '0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7',\n};\n\nexport const TESTNET_COIN_TYPES: SuigarCoinTypes = {\n\tsui: '0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_sui::TEST_SUI',\n\tusdc: '0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_usdc::TEST_USDC',\n};\n\nexport const TESTNET_PRICE_INFO_OBJECT_IDS: SuigarPriceInfoObjectIds = {\n\tsui: '0x1ebb295c789cc42b3b2a1606482cd1c7124076a0f5676718501fda8c7fd075a0',\n\tusdc: '0x9c4dd4008297ffa5e480684b8100ec21cc934405ed9a25d4e4d7b6259aad9c81',\n};\n"],"mappings":";AAUA,MAAa,sBAAwC;CACpD,YACC;CACD,MAAM;CACN,UACC;CACD,OAAO;CACP,QAAQ;CACR,aACC;CACD,OAAO;CACP,OAAO;CACP;AAED,MAAa,qBAAsC;CAClD,KAAK;CACL,MAAM;CACN;AAED,MAAa,gCAA0D;CACtE,KAAK;CACL,MAAM;CACN"}
@@ -0,0 +1,6 @@
1
+ //#region src/configs/registry.mainnet.ts
2
+ const MAINNET_REGISTRY_IDS = { pvpCoinflip: "0x3d73568546c539c1da3eb2b8fe917faef3c0acdbec78a67fe6d52800a0729349" };
3
+ //#endregion
4
+ export { MAINNET_REGISTRY_IDS };
5
+
6
+ //# sourceMappingURL=registry.mainnet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.mainnet.mjs","names":[],"sources":["../../src/configs/registry.mainnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types';\n\nexport const MAINNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x3d73568546c539c1da3eb2b8fe917faef3c0acdbec78a67fe6d52800a0729349',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,sEACD"}
@@ -0,0 +1,11 @@
1
+ import { MAINNET_REGISTRY_IDS } from "./registry.mainnet.mjs";
2
+ import { TESTNET_REGISTRY_IDS } from "./registry.testnet.mjs";
3
+ //#region src/configs/registry.ts
4
+ const REGISTRY_IDS = {
5
+ mainnet: { ...MAINNET_REGISTRY_IDS },
6
+ testnet: { ...TESTNET_REGISTRY_IDS }
7
+ };
8
+ //#endregion
9
+ export { REGISTRY_IDS };
10
+
11
+ //# sourceMappingURL=registry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.mjs","names":[],"sources":["../../src/configs/registry.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tSuigarRegistryIds,\n\tSuiNetworkRegistry,\n} from '../types/suigar-config.type.js';\nimport { MAINNET_REGISTRY_IDS } from './registry.mainnet.js';\nimport { TESTNET_REGISTRY_IDS } from './registry.testnet.js';\n\nexport const REGISTRY_IDS: SuiNetworkRegistry<SuigarRegistryIds> = {\n\tmainnet: { ...MAINNET_REGISTRY_IDS },\n\ttestnet: { ...TESTNET_REGISTRY_IDS },\n};\n"],"mappings":";;;AAUA,MAAa,eAAsD;CAClE,SAAS,EAAE,GAAG,sBAAsB;CACpC,SAAS,EAAE,GAAG,sBAAsB;CACpC"}
@@ -0,0 +1,6 @@
1
+ //#region src/configs/registry.testnet.ts
2
+ const TESTNET_REGISTRY_IDS = { pvpCoinflip: "0x99f20d8e4be012ea14a681144ae72ac349d0a1a1585205880183eb167f075bad" };
3
+ //#endregion
4
+ export { TESTNET_REGISTRY_IDS };
5
+
6
+ //# sourceMappingURL=registry.testnet.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.testnet.mjs","names":[],"sources":["../../src/configs/registry.testnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types';\n\nexport const TESTNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x99f20d8e4be012ea14a681144ae72ac349d0a1a1585205880183eb167f075bad',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,sEACD"}
@@ -0,0 +1,46 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+ //#region src/contracts/coinflip/coinflip.ts
4
+ /**************************************************************
5
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
6
+ **************************************************************/
7
+ const $moduleName = "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea::coinflip";
8
+ const CoinFlipSettingsKey = new MoveStruct({
9
+ name: `${$moduleName}::CoinFlipSettingsKey`,
10
+ fields: { dummy_field: bcs.bool() }
11
+ });
12
+ const Parameters = new MoveStruct({
13
+ name: `${$moduleName}::Parameters<phantom T0>`,
14
+ fields: {
15
+ id: bcs.Address,
16
+ house_edge: bcs.u64(),
17
+ min_stake: bcs.u64(),
18
+ max_stake: bcs.u64()
19
+ }
20
+ });
21
+ function play(options) {
22
+ const packageAddress = options.package ?? "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea";
23
+ const argumentsTypes = [
24
+ null,
25
+ "u64",
26
+ null,
27
+ "u64",
28
+ "bool",
29
+ "vector<0x1::string::String>",
30
+ "vector<vector<u8>>",
31
+ null,
32
+ "0x2::clock::Clock",
33
+ "0x2::random::Random"
34
+ ];
35
+ return (tx) => tx.moveCall({
36
+ package: packageAddress,
37
+ module: "coinflip",
38
+ function: "play",
39
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
40
+ typeArguments: options.typeArguments
41
+ });
42
+ }
43
+ //#endregion
44
+ export { CoinFlipSettingsKey, Parameters, play };
45
+
46
+ //# sourceMappingURL=coinflip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coinflip.mjs","names":[],"sources":["../../../src/contracts/coinflip/coinflip.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport {\n\tMoveStruct,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} from '../utils/index.js';\n\nconst $moduleName =\n\t'0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea::coinflip';\nexport const CoinFlipSettingsKey = new MoveStruct({\n\tname: `${$moduleName}::CoinFlipSettingsKey`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Parameters = new MoveStruct({\n\tname: `${$moduleName}::Parameters<phantom T0>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\thouse_edge: bcs.u64(),\n\t\tmin_stake: bcs.u64(),\n\t\tmax_stake: bcs.u64(),\n\t},\n});\nexport interface PlayOptions {\n\tpackage?: string;\n\targuments: [\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<boolean>,\n\t\tRawTransactionArgument<Array<string>>,\n\t\tRawTransactionArgument<Array<Array<number>>>,\n\t\tRawTransactionArgument<string>,\n\t];\n\ttypeArguments: [string];\n}\nexport function play(options: PlayOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\t'0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\t'u64',\n\t\tnull,\n\t\t'u64',\n\t\t'bool',\n\t\t'vector<0x1::string::String>',\n\t\t'vector<vector<u8>>',\n\t\tnull,\n\t\t'0x2::clock::Clock',\n\t\t'0x2::random::Random',\n\t] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'coinflip',\n\t\t\tfunction: 'play',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;AAWA,MAAM,cACL;AACD,MAAa,sBAAsB,IAAI,WAAW;CACjD,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,YAAY,IAAI,KAAK;EACrB,WAAW,IAAI,KAAK;EACpB,WAAW,IAAI,KAAK;EACpB;CACD,CAAC;AAeF,SAAgB,KAAK,SAAsB;CAC1C,MAAM,iBACL,QAAQ,WACR;CACD,MAAM,iBAAiB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,QAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,eAAe;EACpE,eAAe,QAAQ;EACvB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { MoveStruct } from "../utils/index.mjs";
2
+ import * as _$_mysten_bcs0 from "@mysten/bcs";
3
+
4
+ //#region src/contracts/core/core.d.ts
5
+ declare const BetResultEvent: MoveStruct<{
6
+ player: _$_mysten_bcs0.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
7
+ coin_type: MoveStruct<{
8
+ name: _$_mysten_bcs0.BcsType<string, string, "string">;
9
+ }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
10
+ stake_amount: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
11
+ unsafe_oracle_usd_coin_price: MoveStruct<{
12
+ is_negative: _$_mysten_bcs0.BcsType<boolean, boolean, "bool">;
13
+ exp: MoveStruct<{
14
+ bits: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
15
+ }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
16
+ mant: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
17
+ }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
18
+ adjusted_oracle_usd_coin_price: MoveStruct<{
19
+ is_negative: _$_mysten_bcs0.BcsType<boolean, boolean, "bool">;
20
+ exp: MoveStruct<{
21
+ bits: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
22
+ }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
23
+ mant: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
24
+ }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
25
+ outcome_amount: _$_mysten_bcs0.BcsType<string, string | number | bigint, "u64">;
26
+ game_details: MoveStruct<{
27
+ contents: _$_mysten_bcs0.BcsType<{
28
+ key: string;
29
+ value: number[];
30
+ }[], Iterable<{
31
+ key: string;
32
+ value: Iterable<number> & {
33
+ length: number;
34
+ };
35
+ }> & {
36
+ length: number;
37
+ }, string>;
38
+ }, "0x2::vec_map::VecMap<string, vector<u8>>">;
39
+ metadata: MoveStruct<{
40
+ contents: _$_mysten_bcs0.BcsType<{
41
+ key: string;
42
+ value: number[];
43
+ }[], Iterable<{
44
+ key: string;
45
+ value: Iterable<number> & {
46
+ length: number;
47
+ };
48
+ }> & {
49
+ length: number;
50
+ }, string>;
51
+ }, "0x2::vec_map::VecMap<string, vector<u8>>">;
52
+ }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>">;
53
+ //#endregion
54
+ export { BetResultEvent };
55
+ //# sourceMappingURL=core.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.mts","names":[],"sources":["../../../src/contracts/core/core.ts"],"mappings":";;;;cAWa,cAAA,EAAc,UAAA"}
@@ -0,0 +1,22 @@
1
+ import { MoveStruct } from "../utils/index.mjs";
2
+ import { TypeName } from "./deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs";
3
+ import { VecMap } from "./deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs";
4
+ import { Float } from "./float.mjs";
5
+ import { bcs } from "@mysten/sui/bcs";
6
+ const BetResultEvent = new MoveStruct({
7
+ name: `0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>`,
8
+ fields: {
9
+ player: bcs.Address,
10
+ coin_type: TypeName,
11
+ stake_amount: bcs.u64(),
12
+ unsafe_oracle_usd_coin_price: Float,
13
+ adjusted_oracle_usd_coin_price: Float,
14
+ outcome_amount: bcs.u64(),
15
+ game_details: VecMap(bcs.string(), bcs.vector(bcs.u8())),
16
+ metadata: VecMap(bcs.string(), bcs.vector(bcs.u8()))
17
+ }
18
+ });
19
+ //#endregion
20
+ export { BetResultEvent };
21
+
22
+ //# sourceMappingURL=core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.mjs","names":["type_name.TypeName","float.Float","vec_map.VecMap"],"sources":["../../../src/contracts/core/core.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../utils/index.js';\nimport * as type_name from './deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.js';\nimport * as vec_map from './deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.js';\nimport * as float from './float.js';\n\nconst $moduleName =\n\t'0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core';\nexport const BetResultEvent = new MoveStruct({\n\tname: `${$moduleName}::BetResultEvent<phantom T0>`,\n\tfields: {\n\t\tplayer: bcs.Address,\n\t\tcoin_type: type_name.TypeName,\n\t\tstake_amount: bcs.u64(),\n\t\tunsafe_oracle_usd_coin_price: float.Float,\n\t\tadjusted_oracle_usd_coin_price: float.Float,\n\t\toutcome_amount: bcs.u64(),\n\t\tgame_details: vec_map.VecMap(bcs.string(), bcs.vector(bcs.u8())),\n\t\tmetadata: vec_map.VecMap(bcs.string(), bcs.vector(bcs.u8())),\n\t},\n});\n"],"mappings":";;;;;AAWA,MAAa,iBAAiB,IAAI,WAAW;CAC5C,MAAM;CACN,QAAQ;EACP,QAAQ,IAAI;EACZ,WAAWA;EACX,cAAc,IAAI,KAAK;EACvB,8BAA8BC;EAC9B,gCAAgCA;EAChC,gBAAgB,IAAI,KAAK;EACzB,cAAcC,OAAe,IAAI,QAAQ,EAAE,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC;EAChE,UAAUA,OAAe,IAAI,QAAQ,EAAE,IAAI,OAAO,IAAI,IAAI,CAAC,CAAC;EAC5D;CACD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { MoveStruct } from "../../../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+ const TypeName = new MoveStruct({
4
+ name: `0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName`,
5
+ fields: { name: bcs.string() }
6
+ });
7
+ //#endregion
8
+ export { TypeName };
9
+
10
+ //# sourceMappingURL=type_name.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type_name.mjs","names":[],"sources":["../../../../../src/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName =\n\t'0x0000000000000000000000000000000000000000000000000000000000000001::type_name';\nexport const TypeName = new MoveStruct({\n\tname: `${$moduleName}::TypeName`,\n\tfields: {\n\t\tname: bcs.string(),\n\t},\n});\n"],"mappings":";;AAQA,MAAa,WAAW,IAAI,WAAW;CACtC,MAAM;CACN,QAAQ,EACP,MAAM,IAAI,QAAQ,EAClB;CACD,CAAC"}