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