@suigar/sdk 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +65 -57
- package/dist/index.cjs +187 -142
- package/dist/index.d.cts +130 -148
- package/dist/index.d.ts +130 -148
- package/dist/index.js +188 -143
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -4,85 +4,126 @@ var utils = require('@mysten/sui/utils');
|
|
|
4
4
|
var bcs = require('@mysten/sui/bcs');
|
|
5
5
|
var transactions = require('@mysten/sui/transactions');
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/types/network.type.ts
|
|
8
|
+
var SUPPORTED_SUI_NETWORKS = [
|
|
9
|
+
"mainnet",
|
|
10
|
+
"testnet"
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// src/configs/package.mainnet.ts
|
|
14
|
+
var MAINNET_PACKAGE_IDS = {
|
|
15
|
+
sweetHouse: "0xa1549d73230118716bc08865b8d62454f360ddaf40eee2158e458e52125d4ef1",
|
|
16
|
+
core: "0xcbb0929f21450013ebe5e86e7139f2409da2e3ed212c51126a7e6448b795a43f",
|
|
17
|
+
coinflip: "0xca96885371150f55653f7fab9e9b146f5a19698b1002bdff42159ea9d2ba7d7e",
|
|
18
|
+
limbo: "0x89db6a55ad4e650cad641b6f9fd90b391b22b1d9adbb2cabbfeb94a9eeda7026",
|
|
19
|
+
plinko: "0x74a73daff11c11ed05299c93ed770c62ec4dc6756fa99e271e251c2399f49fef",
|
|
20
|
+
pvpCoinflip: "0x29162faf01a8135630e0a32bbe4ce47f69607b24dbb1edea3800861f91d0030a",
|
|
21
|
+
range: "0xd19e32b0f2a5e541fbd345b4602f8a93a2eee25c16029595b6fef0b1e0461a54",
|
|
22
|
+
wheel: "0x6791eac73fe7bf463b7f3b1ea391df265fbc1b96201270664a5a11e2441e9955"
|
|
23
|
+
};
|
|
24
|
+
var MAINNET_COIN_TYPES = {
|
|
25
|
+
sui: "0x2::sui::SUI",
|
|
26
|
+
usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
|
|
27
|
+
};
|
|
28
|
+
var MAINNET_PRICE_INFO_OBJECT_IDS = {
|
|
29
|
+
sui: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37",
|
|
30
|
+
usdc: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
31
|
+
};
|
|
8
32
|
|
|
9
|
-
// src/configs/package
|
|
10
|
-
var
|
|
11
|
-
|
|
33
|
+
// src/configs/package.testnet.ts
|
|
34
|
+
var TESTNET_PACKAGE_IDS = {
|
|
35
|
+
sweetHouse: "0xb7f64e5a273aba1ede00caa0a6f8027cc7490c279d17eab12e7100ed20660603",
|
|
36
|
+
core: "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc",
|
|
12
37
|
coinflip: "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea",
|
|
13
38
|
limbo: "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4",
|
|
14
39
|
plinko: "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7",
|
|
15
|
-
|
|
40
|
+
pvpCoinflip: "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202",
|
|
16
41
|
range: "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416",
|
|
17
42
|
wheel: "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7"
|
|
18
43
|
};
|
|
44
|
+
var TESTNET_COIN_TYPES = {
|
|
45
|
+
sui: "0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_sui::TEST_SUI",
|
|
46
|
+
usdc: "0x47c67b9594069c32caa7a6e875ddf31d7fa52602dd22ccb9ebd8d3482aed76dc::test_usdc::TEST_USDC"
|
|
47
|
+
};
|
|
48
|
+
var TESTNET_PRICE_INFO_OBJECT_IDS = {
|
|
49
|
+
sui: "0x1ebb295c789cc42b3b2a1606482cd1c7124076a0f5676718501fda8c7fd075a0",
|
|
50
|
+
usdc: "0x9c4dd4008297ffa5e480684b8100ec21cc934405ed9a25d4e4d7b6259aad9c81"
|
|
51
|
+
};
|
|
19
52
|
|
|
20
|
-
// src/configs/
|
|
21
|
-
var
|
|
22
|
-
|
|
53
|
+
// src/configs/package.ts
|
|
54
|
+
var PACKAGE_IDS = {
|
|
55
|
+
mainnet: { ...MAINNET_PACKAGE_IDS },
|
|
56
|
+
testnet: { ...TESTNET_PACKAGE_IDS }
|
|
57
|
+
};
|
|
58
|
+
var COIN_TYPES = {
|
|
59
|
+
mainnet: { ...MAINNET_COIN_TYPES },
|
|
60
|
+
testnet: { ...TESTNET_COIN_TYPES }
|
|
61
|
+
};
|
|
62
|
+
var PRICE_INFO_OBJECT_IDS = {
|
|
63
|
+
mainnet: { ...MAINNET_PRICE_INFO_OBJECT_IDS },
|
|
64
|
+
testnet: { ...TESTNET_PRICE_INFO_OBJECT_IDS }
|
|
65
|
+
};
|
|
23
66
|
|
|
24
67
|
// src/utils/config.ts
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
const usdcCoinType = utils.normalizeStructTag(
|
|
31
|
-
options.coinTypes?.usdc ?? DEFAULT_USDC_COIN_TYPE
|
|
32
|
-
);
|
|
33
|
-
const usdcFlowxCoinType = utils.normalizeStructTag(
|
|
34
|
-
options.coinTypes?.usdcFlowx ?? DEFAULT_USDC_FLOWX_COIN_TYPE
|
|
35
|
-
);
|
|
36
|
-
const explicitPriceInfoObjectIds = Object.fromEntries(
|
|
37
|
-
Object.entries(options.pyth?.priceInfoObjectIds ?? {}).map(
|
|
38
|
-
([coinType, objectId]) => [utils.normalizeStructTag(coinType), objectId]
|
|
39
|
-
)
|
|
40
|
-
);
|
|
68
|
+
function resolveSuigarConfig(network) {
|
|
69
|
+
const packageIds = PACKAGE_IDS[network];
|
|
70
|
+
const coinTypes = COIN_TYPES[network];
|
|
71
|
+
const priceInfoObjectIds = PRICE_INFO_OBJECT_IDS[network];
|
|
41
72
|
return {
|
|
42
|
-
|
|
73
|
+
packageIds: { ...packageIds },
|
|
43
74
|
coinTypes: {
|
|
44
|
-
sui:
|
|
45
|
-
usdc:
|
|
46
|
-
usdcFlowx: usdcFlowxCoinType
|
|
75
|
+
sui: utils.normalizeStructTag(coinTypes.sui),
|
|
76
|
+
usdc: utils.normalizeStructTag(coinTypes.usdc)
|
|
47
77
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
plinko: trim(options.gamesPackageId?.plinko) || DEFAULT_GAMES_PACKAGE_ID.plinko,
|
|
52
|
-
"pvp-coinflip": trim(options.gamesPackageId?.["pvp-coinflip"]) || DEFAULT_GAMES_PACKAGE_ID.pvp_coinflip,
|
|
53
|
-
range: trim(options.gamesPackageId?.range) || DEFAULT_GAMES_PACKAGE_ID.range,
|
|
54
|
-
wheel: trim(options.gamesPackageId?.wheel) || DEFAULT_GAMES_PACKAGE_ID.wheel
|
|
55
|
-
},
|
|
56
|
-
pyth: {
|
|
57
|
-
packageId: trim(options.pyth?.packageId) || void 0,
|
|
58
|
-
suiPriceInfoObjectId: trim(options.pyth?.suiPriceInfoObjectId),
|
|
59
|
-
usdcPriceInfoObjectId: trim(options.pyth?.usdcPriceInfoObjectId),
|
|
60
|
-
priceInfoObjectIds: explicitPriceInfoObjectIds
|
|
78
|
+
priceInfoObjectIds: {
|
|
79
|
+
sui: priceInfoObjectIds.sui,
|
|
80
|
+
usdc: priceInfoObjectIds.usdc
|
|
61
81
|
}
|
|
62
82
|
};
|
|
63
83
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (explicitObjectId) {
|
|
68
|
-
return explicitObjectId;
|
|
84
|
+
function assertConfiguredBetGame(config, game) {
|
|
85
|
+
if (!resolveGamePackageId(config, game)) {
|
|
86
|
+
throw new Error(`Missing required config for ${game}: packageIds.${game}`);
|
|
69
87
|
}
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
}
|
|
89
|
+
function resolveGamePackageId(config, game) {
|
|
90
|
+
switch (game) {
|
|
91
|
+
case "coinflip":
|
|
92
|
+
return config.packageIds.coinflip;
|
|
93
|
+
case "limbo":
|
|
94
|
+
return config.packageIds.limbo;
|
|
95
|
+
case "plinko":
|
|
96
|
+
return config.packageIds.plinko;
|
|
97
|
+
case "pvp-coinflip":
|
|
98
|
+
return config.packageIds.pvpCoinflip;
|
|
99
|
+
case "range":
|
|
100
|
+
return config.packageIds.range;
|
|
101
|
+
case "wheel":
|
|
102
|
+
return config.packageIds.wheel;
|
|
72
103
|
}
|
|
73
|
-
|
|
74
|
-
|
|
104
|
+
}
|
|
105
|
+
function resolvePriceInfoObjectId(config, coinType) {
|
|
106
|
+
const normalizedCoinType = utils.normalizeStructTag(coinType);
|
|
107
|
+
const supportedCoin = resolveSupportedCoin(config, normalizedCoinType);
|
|
108
|
+
const objectId = config.priceInfoObjectIds[supportedCoin];
|
|
109
|
+
if (objectId) {
|
|
110
|
+
return objectId;
|
|
75
111
|
}
|
|
76
112
|
throw new Error(
|
|
77
|
-
`Missing
|
|
113
|
+
`Missing price info object configuration for coin type ${coinType}`
|
|
78
114
|
);
|
|
79
115
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
116
|
+
function resolveSupportedCoin(config, coinType) {
|
|
117
|
+
const entries = Object.entries(config.coinTypes);
|
|
118
|
+
const supportedCoin = entries.find(
|
|
119
|
+
([, configuredCoinType]) => configuredCoinType === coinType
|
|
120
|
+
)?.[0];
|
|
121
|
+
if (supportedCoin) {
|
|
122
|
+
return supportedCoin;
|
|
85
123
|
}
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Unsupported coin type ${coinType}. Supported coin types: ${entries.map(([, configuredCoinType]) => configuredCoinType).join(", ")}`
|
|
126
|
+
);
|
|
86
127
|
}
|
|
87
128
|
var ADDRESS_METADATA_KEYS = /* @__PURE__ */ new Set(["referrer", "partner"]);
|
|
88
129
|
var textEncoder = new TextEncoder();
|
|
@@ -343,7 +384,7 @@ function buildSharedStandardGameBetCall({
|
|
|
343
384
|
const resolvedCashStake = toBigIntAmount(cashStake ?? stake, "cashStake");
|
|
344
385
|
const resolvedBetCount = toBigIntAmount(betCount ?? 1, "betCount");
|
|
345
386
|
const encodedMetadata = encodeBetMetadata(metadata);
|
|
346
|
-
const
|
|
387
|
+
const priceInfoObjectId = resolvePriceInfoObjectId(
|
|
347
388
|
config,
|
|
348
389
|
normalizedCoinType
|
|
349
390
|
);
|
|
@@ -361,7 +402,7 @@ function buildSharedStandardGameBetCall({
|
|
|
361
402
|
cashStake: resolvedCashStake,
|
|
362
403
|
betCount: resolvedBetCount,
|
|
363
404
|
metadata: encodedMetadata,
|
|
364
|
-
|
|
405
|
+
priceInfoObjectId,
|
|
365
406
|
betCoin
|
|
366
407
|
});
|
|
367
408
|
tx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));
|
|
@@ -386,20 +427,20 @@ function buildCoinflipTransaction(options) {
|
|
|
386
427
|
stake,
|
|
387
428
|
betCount,
|
|
388
429
|
metadata,
|
|
389
|
-
|
|
430
|
+
priceInfoObjectId,
|
|
390
431
|
betCoin
|
|
391
432
|
}) => play({
|
|
392
|
-
package: config.
|
|
433
|
+
package: config.packageIds.coinflip,
|
|
393
434
|
typeArguments: [coinType],
|
|
394
435
|
arguments: [
|
|
395
|
-
config.
|
|
436
|
+
config.packageIds.sweetHouse,
|
|
396
437
|
stake,
|
|
397
438
|
betCoin,
|
|
398
439
|
betCount,
|
|
399
440
|
options.side === "tails",
|
|
400
441
|
metadata.keys,
|
|
401
442
|
metadata.values,
|
|
402
|
-
|
|
443
|
+
priceInfoObjectId
|
|
403
444
|
]
|
|
404
445
|
})(tx)
|
|
405
446
|
});
|
|
@@ -444,13 +485,13 @@ function buildLimboTransaction(options) {
|
|
|
444
485
|
stake,
|
|
445
486
|
betCount,
|
|
446
487
|
metadata,
|
|
447
|
-
|
|
488
|
+
priceInfoObjectId,
|
|
448
489
|
betCoin
|
|
449
490
|
}) => play2({
|
|
450
|
-
package: config.
|
|
491
|
+
package: config.packageIds.limbo,
|
|
451
492
|
typeArguments: [coinType],
|
|
452
493
|
arguments: [
|
|
453
|
-
config.
|
|
494
|
+
config.packageIds.sweetHouse,
|
|
454
495
|
stake,
|
|
455
496
|
betCoin,
|
|
456
497
|
betCount,
|
|
@@ -458,7 +499,7 @@ function buildLimboTransaction(options) {
|
|
|
458
499
|
BigInt(scale),
|
|
459
500
|
metadata.keys,
|
|
460
501
|
metadata.values,
|
|
461
|
-
|
|
502
|
+
priceInfoObjectId
|
|
462
503
|
]
|
|
463
504
|
})(tx)
|
|
464
505
|
});
|
|
@@ -501,20 +542,20 @@ function buildPlinkoTransaction(options) {
|
|
|
501
542
|
stake,
|
|
502
543
|
betCount,
|
|
503
544
|
metadata,
|
|
504
|
-
|
|
545
|
+
priceInfoObjectId,
|
|
505
546
|
betCoin
|
|
506
547
|
}) => play3({
|
|
507
|
-
package: config.
|
|
548
|
+
package: config.packageIds.plinko,
|
|
508
549
|
typeArguments: [coinType],
|
|
509
550
|
arguments: [
|
|
510
|
-
config.
|
|
551
|
+
config.packageIds.sweetHouse,
|
|
511
552
|
stake,
|
|
512
553
|
betCoin,
|
|
513
554
|
betCount,
|
|
514
555
|
configId,
|
|
515
556
|
metadata.keys,
|
|
516
557
|
metadata.values,
|
|
517
|
-
|
|
558
|
+
priceInfoObjectId
|
|
518
559
|
]
|
|
519
560
|
})(tx)
|
|
520
561
|
});
|
|
@@ -526,44 +567,38 @@ var TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: {
|
|
|
526
567
|
|
|
527
568
|
// src/contracts/pvp-coinflip/pvp_coinflip.ts
|
|
528
569
|
var $moduleName2 = "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip";
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
creator_is_tails: bcs.bcs.bool(),
|
|
562
|
-
is_private: bcs.bcs.bool(),
|
|
563
|
-
stake_per_player: bcs.bcs.u64(),
|
|
564
|
-
coin_type: TypeName
|
|
565
|
-
} });
|
|
566
|
-
}
|
|
570
|
+
var GameCreatedEvent = new MoveStruct({ name: `${$moduleName2}::GameCreatedEvent<phantom T0>`, fields: {
|
|
571
|
+
game_id: bcs.bcs.Address,
|
|
572
|
+
creator: bcs.bcs.Address,
|
|
573
|
+
creator_is_tails: bcs.bcs.bool(),
|
|
574
|
+
is_private: bcs.bcs.bool(),
|
|
575
|
+
joiner_is_tails: bcs.bcs.bool(),
|
|
576
|
+
stake_per_player: bcs.bcs.u64(),
|
|
577
|
+
house_edge_bps: bcs.bcs.u64(),
|
|
578
|
+
coin_type: TypeName
|
|
579
|
+
} });
|
|
580
|
+
var GameResolvedEvent = new MoveStruct({ name: `${$moduleName2}::GameResolvedEvent<phantom T0>`, fields: {
|
|
581
|
+
game_id: bcs.bcs.Address,
|
|
582
|
+
creator: bcs.bcs.Address,
|
|
583
|
+
joiner: bcs.bcs.Address,
|
|
584
|
+
winner: bcs.bcs.Address,
|
|
585
|
+
creator_is_tails: bcs.bcs.bool(),
|
|
586
|
+
is_private: bcs.bcs.bool(),
|
|
587
|
+
joiner_is_tails: bcs.bcs.bool(),
|
|
588
|
+
stake_per_player: bcs.bcs.u64(),
|
|
589
|
+
total_pot: bcs.bcs.u64(),
|
|
590
|
+
house_edge_amount: bcs.bcs.u64(),
|
|
591
|
+
payout_amount: bcs.bcs.u64(),
|
|
592
|
+
coin_type: TypeName
|
|
593
|
+
} });
|
|
594
|
+
var GameCancelledEvent = new MoveStruct({ name: `${$moduleName2}::GameCancelledEvent<phantom T0>`, fields: {
|
|
595
|
+
game_id: bcs.bcs.Address,
|
|
596
|
+
creator: bcs.bcs.Address,
|
|
597
|
+
creator_is_tails: bcs.bcs.bool(),
|
|
598
|
+
is_private: bcs.bcs.bool(),
|
|
599
|
+
stake_per_player: bcs.bcs.u64(),
|
|
600
|
+
coin_type: TypeName
|
|
601
|
+
} });
|
|
567
602
|
function createGame(options) {
|
|
568
603
|
const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
|
|
569
604
|
const argumentsTypes = [
|
|
@@ -636,10 +671,10 @@ function buildPvPCoinflipTransaction(action, options) {
|
|
|
636
671
|
});
|
|
637
672
|
tx.add(
|
|
638
673
|
createGame({
|
|
639
|
-
package: createOptions.config.
|
|
674
|
+
package: createOptions.config.packageIds.pvpCoinflip,
|
|
640
675
|
typeArguments: [normalizedCoinType],
|
|
641
676
|
arguments: [
|
|
642
|
-
createOptions.config.
|
|
677
|
+
createOptions.config.packageIds.sweetHouse,
|
|
643
678
|
betCoin,
|
|
644
679
|
createOptions.side === "tails",
|
|
645
680
|
Boolean(createOptions.isPrivate),
|
|
@@ -660,11 +695,11 @@ function buildPvPCoinflipTransaction(action, options) {
|
|
|
660
695
|
});
|
|
661
696
|
tx.add(
|
|
662
697
|
joinGame({
|
|
663
|
-
package: joinOptions.config.
|
|
698
|
+
package: joinOptions.config.packageIds.pvpCoinflip,
|
|
664
699
|
typeArguments: [normalizedCoinType],
|
|
665
700
|
arguments: [
|
|
666
701
|
joinOptions.gameId,
|
|
667
|
-
joinOptions.config.
|
|
702
|
+
joinOptions.config.packageIds.sweetHouse,
|
|
668
703
|
betCoin,
|
|
669
704
|
encodedMetadata.keys,
|
|
670
705
|
encodedMetadata.values,
|
|
@@ -678,11 +713,11 @@ function buildPvPCoinflipTransaction(action, options) {
|
|
|
678
713
|
const cancelOptions = options;
|
|
679
714
|
tx.add(
|
|
680
715
|
cancelGame({
|
|
681
|
-
package: cancelOptions.config.
|
|
716
|
+
package: cancelOptions.config.packageIds.pvpCoinflip,
|
|
682
717
|
typeArguments: [normalizedCoinType],
|
|
683
718
|
arguments: [
|
|
684
719
|
cancelOptions.gameId,
|
|
685
|
-
cancelOptions.config.
|
|
720
|
+
cancelOptions.config.packageIds.sweetHouse
|
|
686
721
|
]
|
|
687
722
|
})
|
|
688
723
|
);
|
|
@@ -734,13 +769,13 @@ function buildRangeTransaction(options) {
|
|
|
734
769
|
stake,
|
|
735
770
|
betCount,
|
|
736
771
|
metadata,
|
|
737
|
-
|
|
772
|
+
priceInfoObjectId,
|
|
738
773
|
betCoin
|
|
739
774
|
}) => play4({
|
|
740
|
-
package: config.
|
|
775
|
+
package: config.packageIds.range,
|
|
741
776
|
typeArguments: [coinType],
|
|
742
777
|
arguments: [
|
|
743
|
-
config.
|
|
778
|
+
config.packageIds.sweetHouse,
|
|
744
779
|
stake,
|
|
745
780
|
betCoin,
|
|
746
781
|
betCount,
|
|
@@ -749,7 +784,7 @@ function buildRangeTransaction(options) {
|
|
|
749
784
|
Boolean(options.outOfRange),
|
|
750
785
|
metadata.keys,
|
|
751
786
|
metadata.values,
|
|
752
|
-
|
|
787
|
+
priceInfoObjectId
|
|
753
788
|
]
|
|
754
789
|
})(tx)
|
|
755
790
|
});
|
|
@@ -792,20 +827,20 @@ function buildWheelTransaction(options) {
|
|
|
792
827
|
stake,
|
|
793
828
|
betCount,
|
|
794
829
|
metadata,
|
|
795
|
-
|
|
830
|
+
priceInfoObjectId,
|
|
796
831
|
betCoin
|
|
797
832
|
}) => play5({
|
|
798
|
-
package: config.
|
|
833
|
+
package: config.packageIds.wheel,
|
|
799
834
|
typeArguments: [coinType],
|
|
800
835
|
arguments: [
|
|
801
|
-
config.
|
|
836
|
+
config.packageIds.sweetHouse,
|
|
802
837
|
stake,
|
|
803
838
|
betCoin,
|
|
804
839
|
betCount,
|
|
805
840
|
configId,
|
|
806
841
|
metadata.keys,
|
|
807
842
|
metadata.values,
|
|
808
|
-
|
|
843
|
+
priceInfoObjectId
|
|
809
844
|
]
|
|
810
845
|
})(tx)
|
|
811
846
|
});
|
|
@@ -841,38 +876,48 @@ function VecMap(...typeParameters) {
|
|
|
841
876
|
|
|
842
877
|
// src/contracts/core/core.ts
|
|
843
878
|
var $moduleName7 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core";
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
} });
|
|
855
|
-
}
|
|
879
|
+
var BetResultEvent = new MoveStruct({ name: `${$moduleName7}::BetResultEvent<phantom T0>`, fields: {
|
|
880
|
+
player: bcs.bcs.Address,
|
|
881
|
+
coin_type: TypeName2,
|
|
882
|
+
stake_amount: bcs.bcs.u64(),
|
|
883
|
+
unsafe_oracle_usd_coin_price: Float,
|
|
884
|
+
adjusted_oracle_usd_coin_price: Float,
|
|
885
|
+
outcome_amount: bcs.bcs.u64(),
|
|
886
|
+
game_details: VecMap(bcs.bcs.string(), bcs.bcs.vector(bcs.bcs.u8())),
|
|
887
|
+
metadata: VecMap(bcs.bcs.string(), bcs.bcs.vector(bcs.bcs.u8()))
|
|
888
|
+
} });
|
|
856
889
|
function suigar({
|
|
857
|
-
name = "suigar"
|
|
858
|
-
...options
|
|
890
|
+
name = "suigar"
|
|
859
891
|
} = {}) {
|
|
860
892
|
return {
|
|
861
893
|
name,
|
|
862
894
|
register: (client) => {
|
|
863
|
-
return new SuigarClient({ client
|
|
895
|
+
return new SuigarClient({ client });
|
|
864
896
|
}
|
|
865
897
|
};
|
|
866
898
|
}
|
|
867
899
|
var SuigarClient = class {
|
|
868
900
|
#client;
|
|
869
901
|
#config;
|
|
870
|
-
constructor({
|
|
871
|
-
client,
|
|
872
|
-
options
|
|
873
|
-
}) {
|
|
902
|
+
constructor({ client }) {
|
|
874
903
|
this.#client = client;
|
|
875
|
-
|
|
904
|
+
const network = this.#client.network;
|
|
905
|
+
if (!SUPPORTED_SUI_NETWORKS.includes(network)) {
|
|
906
|
+
throw new Error(`Unsupported network: ${network}`);
|
|
907
|
+
}
|
|
908
|
+
this.#config = resolveSuigarConfig(network);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Returns the resolved SDK configuration for the connected network.
|
|
912
|
+
*
|
|
913
|
+
* This is primarily useful for debugging or inspecting which package ids,
|
|
914
|
+
* supported coin types, and price info object ids the SDK resolved for the
|
|
915
|
+
* current client network.
|
|
916
|
+
*
|
|
917
|
+
* @returns Network-resolved Suigar configuration.
|
|
918
|
+
*/
|
|
919
|
+
getConfig() {
|
|
920
|
+
return this.#config;
|
|
876
921
|
}
|
|
877
922
|
/**
|
|
878
923
|
* Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
|