@suigar/mcp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/bin.cjs +1 -1
  3. package/dist/bin.mjs +1 -1
  4. package/dist/index.cjs +43 -50
  5. package/dist/index.d.cts +818 -8
  6. package/dist/index.d.mts +818 -8
  7. package/dist/index.mjs +1 -8
  8. package/{node_modules/@suigar/sui-rpc-pool/dist/index.cjs → dist/server-BD-123-u.mjs} +2084 -671
  9. package/{node_modules/@suigar/sui-rpc-pool/dist/index.mjs → dist/server-Cmo8UaHE.cjs} +2341 -645
  10. package/dist/server.cjs +3 -432
  11. package/dist/server.mjs +1 -430
  12. package/package.json +75 -61
  13. package/dist/client.cjs +0 -46
  14. package/dist/client.d.cts +0 -17
  15. package/dist/client.d.mts +0 -17
  16. package/dist/client.mjs +0 -43
  17. package/dist/coin.cjs +0 -86
  18. package/dist/coin.d.cts +0 -35
  19. package/dist/coin.d.mts +0 -35
  20. package/dist/coin.mjs +0 -86
  21. package/dist/config.cjs +0 -183
  22. package/dist/config.d.cts +0 -15
  23. package/dist/config.d.mts +0 -15
  24. package/dist/config.mjs +0 -174
  25. package/dist/mcp-support.cjs +0 -62
  26. package/dist/mcp-support.d.cts +0 -16
  27. package/dist/mcp-support.d.mts +0 -16
  28. package/dist/mcp-support.mjs +0 -60
  29. package/dist/metadata.cjs +0 -51
  30. package/dist/metadata.d.cts +0 -52
  31. package/dist/metadata.d.mts +0 -52
  32. package/dist/metadata.mjs +0 -47
  33. package/dist/tools.cjs +0 -617
  34. package/dist/tools.d.cts +0 -158
  35. package/dist/tools.d.mts +0 -158
  36. package/dist/tools.mjs +0 -608
  37. package/dist/transactions.cjs +0 -294
  38. package/dist/transactions.d.cts +0 -40
  39. package/dist/transactions.d.mts +0 -40
  40. package/dist/transactions.mjs +0 -286
  41. package/dist/types.d.cts +0 -111
  42. package/dist/types.d.mts +0 -111
  43. package/node_modules/@suigar/currency-registry/dist/index.cjs +0 -121
  44. package/node_modules/@suigar/currency-registry/dist/index.d.cts +0 -50
  45. package/node_modules/@suigar/currency-registry/dist/index.d.mts +0 -50
  46. package/node_modules/@suigar/currency-registry/dist/index.mjs +0 -110
  47. package/node_modules/@suigar/currency-registry/package.json +0 -31
  48. package/node_modules/@suigar/game-registry/dist/index.cjs +0 -310
  49. package/node_modules/@suigar/game-registry/dist/index.d.cts +0 -65
  50. package/node_modules/@suigar/game-registry/dist/index.d.mts +0 -65
  51. package/node_modules/@suigar/game-registry/dist/index.mjs +0 -292
  52. package/node_modules/@suigar/game-registry/package.json +0 -31
  53. package/node_modules/@suigar/sui-rpc-pool/dist/index.d.cts +0 -465
  54. package/node_modules/@suigar/sui-rpc-pool/dist/index.d.mts +0 -465
  55. package/node_modules/@suigar/sui-rpc-pool/package.json +0 -31
package/dist/tools.mjs DELETED
@@ -1,608 +0,0 @@
1
- import { getRequiredConfigKeysForGame, inspectResolvedConfig, resolveGamePackageId, resolveSuigarConfig } from "./config.mjs";
2
- import { getCurrencyInfo, getGameMetadata, readConfigMetadata } from "./metadata.mjs";
3
- import { createReadOnlyClientBundle, dryRunTransaction, serializeTransactionToBase64 } from "./client.mjs";
4
- import { buildCoinflipTransaction, buildLimboTransaction, buildPlinkoTransaction, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCreateTransaction, buildPvpCoinflipJoinTransaction, buildRangeTransaction, buildWheelTransaction, summarizeTransaction } from "./transactions.mjs";
5
- import { normalizeCoinType } from "@suigar/currency-registry";
6
- import { SuiGrpcClient } from "@mysten/sui/grpc";
7
- import { suigar } from "@suigar/sdk";
8
- //#region src/tools.ts
9
- const asRecord = (value) => value && typeof value === "object" ? value : {};
10
- const asString = (value, fieldName, fallback) => {
11
- if (typeof value === "string" && value.trim()) return value.trim();
12
- if (fallback !== void 0) return fallback;
13
- throw new Error(`Missing required string field: ${fieldName}`);
14
- };
15
- const asOptionalString = (value) => typeof value === "string" && value.trim() ? value.trim() : void 0;
16
- const asNumber = (value, fieldName) => {
17
- const numeric = typeof value === "bigint" ? Number(value) : Number(value);
18
- if (!Number.isFinite(numeric)) throw new Error(`Missing or invalid numeric field: ${fieldName}`);
19
- return numeric;
20
- };
21
- const asBoolean = (value, fallback = false) => typeof value === "boolean" ? value : fallback;
22
- const asStringArray = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.trim().length > 0) : [];
23
- const asMode = (value) => value === "dry-run" || value === "read-only" || value === "build" ? value : "build";
24
- const SDK_BUILD_NETWORKS = /* @__PURE__ */ new Set(["mainnet", "testnet"]);
25
- const SDK_UNSUPPORTED_CONFIG_OVERRIDE_KEYS = [
26
- "suigarPackageId",
27
- "coinflipPackageId",
28
- "pvpCoinflipPackageId",
29
- "plinkoPackageId",
30
- "limboPackageId",
31
- "rangePackageId",
32
- "wheelPackageId",
33
- "sweethouseId",
34
- "suiPythPriceInfoObjectId",
35
- "usdcPythPriceInfoObjectId",
36
- "pvpCoinflipRegistryId"
37
- ];
38
- const buildReadOnlyPlan = ({ game, config, coinType, targetSuffix, notes }) => {
39
- const resolvedConfig = resolveSuigarConfig(config);
40
- const packageId = resolveGamePackageId(game, resolvedConfig);
41
- return {
42
- mode: "read-only",
43
- network: resolvedConfig.network,
44
- game,
45
- config: inspectResolvedConfig(resolvedConfig),
46
- plan: {
47
- target: packageId ? `${packageId}${targetSuffix}` : null,
48
- typeArguments: coinType ? [normalizeCoinType(coinType)] : [],
49
- requiredConfigKeys: getRequiredConfigKeysForGame(game),
50
- notes
51
- }
52
- };
53
- };
54
- const buildTransactionResult = async ({ mode, config, transaction, context }) => {
55
- const bundle = createReadOnlyClientBundle(config);
56
- const summary = summarizeTransaction(transaction, context);
57
- if (mode === "dry-run") return {
58
- mode,
59
- network: bundle.config.network,
60
- config: inspectResolvedConfig(bundle.config),
61
- summary,
62
- dryRun: await dryRunTransaction(transaction, bundle.config)
63
- };
64
- return {
65
- mode,
66
- network: bundle.config.network,
67
- config: inspectResolvedConfig(bundle.config),
68
- summary,
69
- transactionBytesBase64: await serializeTransactionToBase64(transaction, bundle.rawClient)
70
- };
71
- };
72
- const extractConfigInput = (input) => {
73
- const nestedConfig = asRecord(input.config);
74
- return {
75
- ...nestedConfig,
76
- network: asOptionalString(input.network) ?? asOptionalString(nestedConfig.network),
77
- providerUrl: asOptionalString(input.providerUrl) ?? asOptionalString(nestedConfig.providerUrl),
78
- graphqlUrl: asOptionalString(input.graphqlUrl) ?? asOptionalString(nestedConfig.graphqlUrl)
79
- };
80
- };
81
- const extractPartner = (input) => asOptionalString(input.partner) ?? asOptionalString(asRecord(input.config).partner);
82
- const hasSdkUnsupportedConfigOverrides = (input) => {
83
- const mergedInput = {
84
- ...asRecord(input.config),
85
- ...input
86
- };
87
- return SDK_UNSUPPORTED_CONFIG_OVERRIDE_KEYS.some((key) => asOptionalString(mergedInput[key]));
88
- };
89
- const buildCommonSdkOptions = (record, coinType) => {
90
- const owner = asString(record.owner, "owner");
91
- return {
92
- owner,
93
- playerAddress: owner,
94
- coinType,
95
- metadata: asRecord(record.metadata),
96
- allowGasCoinShortcut: asBoolean(record.allowGasCoinShortcut, true),
97
- ...record.gasBudget == null ? {} : { gasBudget: asNumber(record.gasBudget, "gasBudget") }
98
- };
99
- };
100
- const buildStakeSdkOptions = (record, coinType) => ({
101
- ...buildCommonSdkOptions(record, coinType),
102
- stake: asNumber(record.stake, "stake"),
103
- ...record.cashStake == null ? {} : { cashStake: asNumber(record.cashStake, "cashStake") },
104
- ...record.betCount == null ? {} : { betCount: asNumber(record.betCount, "betCount") }
105
- });
106
- const tryBuildSdkTransaction = ({ record, config, coinType, game, pvpAction }) => {
107
- if (asStringArray(record.coinObjectIds).length > 0 || hasSdkUnsupportedConfigOverrides(record)) return null;
108
- const resolvedConfig = resolveSuigarConfig(config);
109
- if (!SDK_BUILD_NETWORKS.has(resolvedConfig.network)) return null;
110
- const partner = extractPartner(record);
111
- const client = new SuiGrpcClient({
112
- baseUrl: resolvedConfig.providerUrl,
113
- network: resolvedConfig.network
114
- }).$extend(suigar(partner ? { partner } : void 0));
115
- try {
116
- switch (game) {
117
- case "coinflip": return client.suigar.tx.createBetTransaction("coinflip", {
118
- ...buildStakeSdkOptions(record, coinType),
119
- side: asString(record.side, "side")
120
- });
121
- case "limbo": return client.suigar.tx.createBetTransaction("limbo", {
122
- ...buildStakeSdkOptions(record, coinType),
123
- targetMultiplier: asNumber(record.targetMultiplier, "targetMultiplier")
124
- });
125
- case "plinko": return client.suigar.tx.createBetTransaction("plinko", {
126
- ...buildStakeSdkOptions(record, coinType),
127
- configId: asNumber(record.configId, "configId")
128
- });
129
- case "wheel": return client.suigar.tx.createBetTransaction("wheel", {
130
- ...buildStakeSdkOptions(record, coinType),
131
- configId: asNumber(record.configId, "configId")
132
- });
133
- case "range": return client.suigar.tx.createBetTransaction("range", {
134
- ...buildStakeSdkOptions(record, coinType),
135
- leftPoint: asNumber(record.leftPoint, "leftPoint"),
136
- rightPoint: asNumber(record.rightPoint, "rightPoint"),
137
- outOfRange: asBoolean(record.outOfRange)
138
- });
139
- case "pvp-coinflip":
140
- if (pvpAction === "join" || pvpAction === "cancel") return client.suigar.tx.createPvPCoinflipTransaction(pvpAction, {
141
- ...buildCommonSdkOptions(record, coinType),
142
- config: client.suigar.getConfig(),
143
- gameId: asString(record.gameId, "gameId")
144
- });
145
- return client.suigar.tx.createPvPCoinflipTransaction("create", {
146
- ...buildCommonSdkOptions(record, coinType),
147
- config: client.suigar.getConfig(),
148
- stake: asNumber(record.stake, "stake"),
149
- side: asString(record.creatorSide, "creatorSide"),
150
- isPrivate: asBoolean(record.isPrivate)
151
- });
152
- }
153
- } catch {
154
- return null;
155
- }
156
- };
157
- const readConfigTool = async (input = {}) => {
158
- return readConfigMetadata(extractConfigInput(asRecord(input)));
159
- };
160
- const readGameMetadataTool = async (input = {}) => {
161
- const record = asRecord(input);
162
- const config = extractConfigInput(record);
163
- const game = asOptionalString(record.game);
164
- const coinType = asOptionalString(record.coinType);
165
- return {
166
- config: readConfigMetadata(config),
167
- game: game ? getGameMetadata(game, config) : null,
168
- currency: coinType ? getCurrencyInfo(coinType, config) : null
169
- };
170
- };
171
- const buildCoinflipTransactionTool = async (input = {}) => {
172
- const record = asRecord(input);
173
- const config = extractConfigInput(record);
174
- const mode = asMode(record.mode);
175
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
176
- if (mode === "read-only") return buildReadOnlyPlan({
177
- game: "coinflip",
178
- config,
179
- coinType,
180
- targetSuffix: "::coinflip::play",
181
- notes: ["Uses the sweethouse shared object, a prepared bet coin, Pyth price info, clock, and random."]
182
- });
183
- const sdkTransaction = tryBuildSdkTransaction({
184
- record,
185
- config,
186
- coinType,
187
- game: "coinflip"
188
- });
189
- if (sdkTransaction) return buildTransactionResult({
190
- mode,
191
- config,
192
- transaction: sdkTransaction,
193
- context: {
194
- game: "coinflip",
195
- coinType,
196
- stake: asNumber(record.stake, "stake")
197
- }
198
- });
199
- const bundle = createReadOnlyClientBundle(config);
200
- const transaction = await buildCoinflipTransaction({
201
- client: bundle.client,
202
- config: bundle.config,
203
- owner: asString(record.owner, "owner"),
204
- coinType,
205
- stake: asNumber(record.stake, "stake"),
206
- cashStake: record.cashStake == null ? void 0 : asNumber(record.cashStake, "cashStake"),
207
- betCount: record.betCount == null ? void 0 : asNumber(record.betCount, "betCount"),
208
- side: asString(record.side, "side"),
209
- metadata: asRecord(record.metadata),
210
- partner: extractPartner(record),
211
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
212
- kind: "object-ids",
213
- objectIds: asStringArray(record.coinObjectIds)
214
- } : void 0
215
- });
216
- return buildTransactionResult({
217
- mode,
218
- config: bundle.config,
219
- transaction,
220
- context: {
221
- game: "coinflip",
222
- coinType,
223
- stake: asNumber(record.stake, "stake")
224
- }
225
- });
226
- };
227
- const buildLimboTransactionTool = async (input = {}) => {
228
- const record = asRecord(input);
229
- const config = extractConfigInput(record);
230
- const mode = asMode(record.mode);
231
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
232
- if (mode === "read-only") return buildReadOnlyPlan({
233
- game: "limbo",
234
- config,
235
- coinType,
236
- targetSuffix: "::limbo::play",
237
- notes: ["Target multiplier is encoded as a fixed-point numerator and denominator."]
238
- });
239
- const sdkTransaction = tryBuildSdkTransaction({
240
- record,
241
- config,
242
- coinType,
243
- game: "limbo"
244
- });
245
- if (sdkTransaction) return buildTransactionResult({
246
- mode,
247
- config,
248
- transaction: sdkTransaction,
249
- context: {
250
- game: "limbo",
251
- coinType,
252
- stake: asNumber(record.stake, "stake")
253
- }
254
- });
255
- const bundle = createReadOnlyClientBundle(config);
256
- const transaction = await buildLimboTransaction({
257
- client: bundle.client,
258
- config: bundle.config,
259
- owner: asString(record.owner, "owner"),
260
- coinType,
261
- stake: asNumber(record.stake, "stake"),
262
- cashStake: record.cashStake == null ? void 0 : asNumber(record.cashStake, "cashStake"),
263
- betCount: record.betCount == null ? void 0 : asNumber(record.betCount, "betCount"),
264
- targetMultiplier: asNumber(record.targetMultiplier, "targetMultiplier"),
265
- metadata: asRecord(record.metadata),
266
- partner: extractPartner(record),
267
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
268
- kind: "object-ids",
269
- objectIds: asStringArray(record.coinObjectIds)
270
- } : void 0
271
- });
272
- return buildTransactionResult({
273
- mode,
274
- config: bundle.config,
275
- transaction,
276
- context: {
277
- game: "limbo",
278
- coinType,
279
- stake: asNumber(record.stake, "stake")
280
- }
281
- });
282
- };
283
- const buildPlinkoTransactionTool = async (input = {}) => {
284
- const record = asRecord(input);
285
- const config = extractConfigInput(record);
286
- const mode = asMode(record.mode);
287
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
288
- if (mode === "read-only") return buildReadOnlyPlan({
289
- game: "plinko",
290
- config,
291
- coinType,
292
- targetSuffix: "::plinko::play",
293
- notes: ["The config id is a u8 that selects the on-chain plinko board setup."]
294
- });
295
- const sdkTransaction = tryBuildSdkTransaction({
296
- record,
297
- config,
298
- coinType,
299
- game: "plinko"
300
- });
301
- if (sdkTransaction) return buildTransactionResult({
302
- mode,
303
- config,
304
- transaction: sdkTransaction,
305
- context: {
306
- game: "plinko",
307
- coinType,
308
- stake: asNumber(record.stake, "stake")
309
- }
310
- });
311
- const bundle = createReadOnlyClientBundle(config);
312
- const transaction = await buildPlinkoTransaction({
313
- client: bundle.client,
314
- config: bundle.config,
315
- owner: asString(record.owner, "owner"),
316
- coinType,
317
- stake: asNumber(record.stake, "stake"),
318
- cashStake: record.cashStake == null ? void 0 : asNumber(record.cashStake, "cashStake"),
319
- betCount: record.betCount == null ? void 0 : asNumber(record.betCount, "betCount"),
320
- configId: asNumber(record.configId, "configId"),
321
- metadata: asRecord(record.metadata),
322
- partner: extractPartner(record),
323
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
324
- kind: "object-ids",
325
- objectIds: asStringArray(record.coinObjectIds)
326
- } : void 0
327
- });
328
- return buildTransactionResult({
329
- mode,
330
- config: bundle.config,
331
- transaction,
332
- context: {
333
- game: "plinko",
334
- coinType,
335
- stake: asNumber(record.stake, "stake")
336
- }
337
- });
338
- };
339
- const buildWheelTransactionTool = async (input = {}) => {
340
- const record = asRecord(input);
341
- const config = extractConfigInput(record);
342
- const mode = asMode(record.mode);
343
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
344
- if (mode === "read-only") return buildReadOnlyPlan({
345
- game: "wheel",
346
- config,
347
- coinType,
348
- targetSuffix: "::wheel::play",
349
- notes: ["The config id is a u8 that selects the on-chain wheel table."]
350
- });
351
- const sdkTransaction = tryBuildSdkTransaction({
352
- record,
353
- config,
354
- coinType,
355
- game: "wheel"
356
- });
357
- if (sdkTransaction) return buildTransactionResult({
358
- mode,
359
- config,
360
- transaction: sdkTransaction,
361
- context: {
362
- game: "wheel",
363
- coinType,
364
- stake: asNumber(record.stake, "stake")
365
- }
366
- });
367
- const bundle = createReadOnlyClientBundle(config);
368
- const transaction = await buildWheelTransaction({
369
- client: bundle.client,
370
- config: bundle.config,
371
- owner: asString(record.owner, "owner"),
372
- coinType,
373
- stake: asNumber(record.stake, "stake"),
374
- cashStake: record.cashStake == null ? void 0 : asNumber(record.cashStake, "cashStake"),
375
- betCount: record.betCount == null ? void 0 : asNumber(record.betCount, "betCount"),
376
- configId: asNumber(record.configId, "configId"),
377
- metadata: asRecord(record.metadata),
378
- partner: extractPartner(record),
379
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
380
- kind: "object-ids",
381
- objectIds: asStringArray(record.coinObjectIds)
382
- } : void 0
383
- });
384
- return buildTransactionResult({
385
- mode,
386
- config: bundle.config,
387
- transaction,
388
- context: {
389
- game: "wheel",
390
- coinType,
391
- stake: asNumber(record.stake, "stake")
392
- }
393
- });
394
- };
395
- const buildRangeTransactionTool = async (input = {}) => {
396
- const record = asRecord(input);
397
- const config = extractConfigInput(record);
398
- const mode = asMode(record.mode);
399
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
400
- if (mode === "read-only") return buildReadOnlyPlan({
401
- game: "range",
402
- config,
403
- coinType,
404
- targetSuffix: "::range::play",
405
- notes: ["Range points are encoded as fixed-point integers with a 1e6 scale by default."]
406
- });
407
- const sdkTransaction = tryBuildSdkTransaction({
408
- record,
409
- config,
410
- coinType,
411
- game: "range"
412
- });
413
- if (sdkTransaction) return buildTransactionResult({
414
- mode,
415
- config,
416
- transaction: sdkTransaction,
417
- context: {
418
- game: "range",
419
- coinType,
420
- stake: asNumber(record.stake, "stake")
421
- }
422
- });
423
- const bundle = createReadOnlyClientBundle(config);
424
- const transaction = await buildRangeTransaction({
425
- client: bundle.client,
426
- config: bundle.config,
427
- owner: asString(record.owner, "owner"),
428
- coinType,
429
- stake: asNumber(record.stake, "stake"),
430
- cashStake: record.cashStake == null ? void 0 : asNumber(record.cashStake, "cashStake"),
431
- betCount: record.betCount == null ? void 0 : asNumber(record.betCount, "betCount"),
432
- leftPoint: asNumber(record.leftPoint, "leftPoint"),
433
- rightPoint: asNumber(record.rightPoint, "rightPoint"),
434
- outOfRange: asBoolean(record.outOfRange),
435
- metadata: asRecord(record.metadata),
436
- partner: extractPartner(record),
437
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
438
- kind: "object-ids",
439
- objectIds: asStringArray(record.coinObjectIds)
440
- } : void 0
441
- });
442
- return buildTransactionResult({
443
- mode,
444
- config: bundle.config,
445
- transaction,
446
- context: {
447
- game: "range",
448
- coinType,
449
- stake: asNumber(record.stake, "stake")
450
- }
451
- });
452
- };
453
- const buildPvpCoinflipCreateTransactionTool = async (input = {}) => {
454
- const record = asRecord(input);
455
- const config = extractConfigInput(record);
456
- const mode = asMode(record.mode);
457
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
458
- if (mode === "read-only") return buildReadOnlyPlan({
459
- game: "pvp-coinflip",
460
- config,
461
- coinType,
462
- targetSuffix: "::pvp_coinflip::create_game",
463
- notes: ["Creates a public or private PvP lobby without needing a private key."]
464
- });
465
- const sdkTransaction = tryBuildSdkTransaction({
466
- record,
467
- config,
468
- coinType,
469
- game: "pvp-coinflip",
470
- pvpAction: "create"
471
- });
472
- if (sdkTransaction) return buildTransactionResult({
473
- mode,
474
- config,
475
- transaction: sdkTransaction,
476
- context: {
477
- game: "pvp-coinflip",
478
- coinType,
479
- stake: asNumber(record.stake, "stake")
480
- }
481
- });
482
- const bundle = createReadOnlyClientBundle(config);
483
- const transaction = await buildPvpCoinflipCreateTransaction({
484
- client: bundle.client,
485
- config: bundle.config,
486
- owner: asString(record.owner, "owner"),
487
- coinType,
488
- stake: asNumber(record.stake, "stake"),
489
- creatorSide: asString(record.creatorSide, "creatorSide"),
490
- isPrivate: asBoolean(record.isPrivate),
491
- metadata: asRecord(record.metadata),
492
- partner: extractPartner(record),
493
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
494
- kind: "object-ids",
495
- objectIds: asStringArray(record.coinObjectIds)
496
- } : void 0
497
- });
498
- return buildTransactionResult({
499
- mode,
500
- config: bundle.config,
501
- transaction,
502
- context: {
503
- game: "pvp-coinflip",
504
- coinType,
505
- stake: asNumber(record.stake, "stake")
506
- }
507
- });
508
- };
509
- const buildPvpCoinflipJoinTransactionTool = async (input = {}) => {
510
- const record = asRecord(input);
511
- const config = extractConfigInput(record);
512
- const mode = asMode(record.mode);
513
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
514
- if (mode === "read-only") return buildReadOnlyPlan({
515
- game: "pvp-coinflip",
516
- config,
517
- coinType,
518
- targetSuffix: "::pvp_coinflip::join_game",
519
- notes: ["Joining requires the game id, stake amount, and a price info object for the selected coin."]
520
- });
521
- const sdkTransaction = tryBuildSdkTransaction({
522
- record,
523
- config,
524
- coinType,
525
- game: "pvp-coinflip",
526
- pvpAction: "join"
527
- });
528
- if (sdkTransaction) return buildTransactionResult({
529
- mode,
530
- config,
531
- transaction: sdkTransaction,
532
- context: {
533
- game: "pvp-coinflip",
534
- coinType,
535
- stake: asNumber(record.stake, "stake")
536
- }
537
- });
538
- const bundle = createReadOnlyClientBundle(config);
539
- const transaction = await buildPvpCoinflipJoinTransaction({
540
- client: bundle.client,
541
- config: bundle.config,
542
- owner: asString(record.owner, "owner"),
543
- gameId: asString(record.gameId, "gameId"),
544
- coinType,
545
- stake: asNumber(record.stake, "stake"),
546
- metadata: asRecord(record.metadata),
547
- partner: extractPartner(record),
548
- coinSource: asStringArray(record.coinObjectIds).length > 0 ? {
549
- kind: "object-ids",
550
- objectIds: asStringArray(record.coinObjectIds)
551
- } : void 0
552
- });
553
- return buildTransactionResult({
554
- mode,
555
- config: bundle.config,
556
- transaction,
557
- context: {
558
- game: "pvp-coinflip",
559
- coinType,
560
- stake: asNumber(record.stake, "stake")
561
- }
562
- });
563
- };
564
- const buildPvpCoinflipCancelTransactionTool = async (input = {}) => {
565
- const record = asRecord(input);
566
- const config = extractConfigInput(record);
567
- const mode = asMode(record.mode);
568
- const coinType = asString(record.coinType, "coinType", resolveSuigarConfig(config).suiCoinType);
569
- if (mode === "read-only") return buildReadOnlyPlan({
570
- game: "pvp-coinflip",
571
- config,
572
- coinType,
573
- targetSuffix: "::pvp_coinflip::cancel_game",
574
- notes: ["Cancel only needs the game id, sweethouse object, and coin type argument."]
575
- });
576
- const sdkTransaction = tryBuildSdkTransaction({
577
- record,
578
- config,
579
- coinType,
580
- game: "pvp-coinflip",
581
- pvpAction: "cancel"
582
- });
583
- if (sdkTransaction) return buildTransactionResult({
584
- mode,
585
- config,
586
- transaction: sdkTransaction,
587
- context: {
588
- game: "pvp-coinflip",
589
- coinType
590
- }
591
- });
592
- return buildTransactionResult({
593
- mode,
594
- config,
595
- transaction: buildPvpCoinflipCancelTransaction({
596
- config,
597
- owner: asString(record.owner, "owner"),
598
- gameId: asString(record.gameId, "gameId"),
599
- coinType
600
- }),
601
- context: {
602
- game: "pvp-coinflip",
603
- coinType
604
- }
605
- });
606
- };
607
- //#endregion
608
- export { buildCoinflipTransactionTool, buildLimboTransactionTool, buildPlinkoTransactionTool, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransactionTool, buildRangeTransactionTool, buildWheelTransactionTool, readConfigTool, readGameMetadataTool };