@suigar/sdk 2.0.0-beta.0 → 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/dist/index.js CHANGED
@@ -1,86 +1,127 @@
1
- import { normalizeSuiAddress, normalizeStructTag, SUI_TYPE_ARG } from '@mysten/sui/utils';
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/utils/config.ts
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-id.ts
8
- var DEFAULT_SWEETHOUSE_PACKAGE_ID = "0xb7f64e5a273aba1ede00caa0a6f8027cc7490c279d17eab12e7100ed20660603";
9
- var DEFAULT_GAMES_PACKAGE_ID = {
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
- pvp_coinflip: "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202",
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/usdc-coin-type.ts
19
- var DEFAULT_USDC_COIN_TYPE = "0xdba34672e30cb065b1f93e3a0e89fd79d1f22e12e55e88edbbcbac48609f4af0::usdc::USDC";
20
- var DEFAULT_USDC_FLOWX_COIN_TYPE = "0xbde4ba4c7f1193c4f1f5b9e8a9c1cdec42c6f3f3a73cf40e1f4cb12cc7e6a4c0::usdc::USDC";
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
- var trim = (value) => value?.trim() ?? "";
24
- function resolveSuigarConfig(options) {
25
- const suiCoinType = normalizeStructTag(
26
- options.coinTypes?.sui ?? SUI_TYPE_ARG
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
- sweetHousePackageId: trim(options.sweetHousePackageId) || trim(DEFAULT_SWEETHOUSE_PACKAGE_ID),
71
+ packageIds: { ...packageIds },
41
72
  coinTypes: {
42
- sui: suiCoinType,
43
- usdc: usdcCoinType,
44
- usdcFlowx: usdcFlowxCoinType
45
- },
46
- gamesPackageId: {
47
- coinflip: trim(options.gamesPackageId?.coinflip) || DEFAULT_GAMES_PACKAGE_ID.coinflip,
48
- limbo: trim(options.gamesPackageId?.limbo) || DEFAULT_GAMES_PACKAGE_ID.limbo,
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
73
+ sui: normalizeStructTag(coinTypes.sui),
74
+ usdc: normalizeStructTag(coinTypes.usdc)
53
75
  },
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 resolvePythPriceInfoObjectId(config, coinType) {
63
- const normalizedCoinType = normalizeStructTag(coinType);
64
- const explicitObjectId = config.pyth.priceInfoObjectIds[normalizedCoinType];
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
- if (normalizedCoinType === config.coinTypes.sui && config.pyth.suiPriceInfoObjectId) {
69
- return config.pyth.suiPriceInfoObjectId;
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
- if ((normalizedCoinType === config.coinTypes.usdc || normalizedCoinType === config.coinTypes.usdcFlowx) && config.pyth.usdcPriceInfoObjectId) {
72
- return config.pyth.usdcPriceInfoObjectId;
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 Pyth price object configuration for coin type ${coinType}`
111
+ `Missing price info object configuration for coin type ${coinType}`
76
112
  );
77
113
  }
78
- function assertConfiguredBetGame(config, game) {
79
- if (!config.gamesPackageId[game]) {
80
- throw new Error(
81
- `Missing required config for ${game}: gamesPackageId.${game}`
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 pythPriceInfoObjectId = resolvePythPriceInfoObjectId(
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
- pythPriceInfoObjectId,
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
- pythPriceInfoObjectId,
428
+ priceInfoObjectId,
388
429
  betCoin
389
430
  }) => play({
390
- package: config.gamesPackageId.coinflip,
431
+ package: config.packageIds.coinflip,
391
432
  typeArguments: [coinType],
392
433
  arguments: [
393
- config.sweetHousePackageId,
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
- pythPriceInfoObjectId
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
- pythPriceInfoObjectId,
486
+ priceInfoObjectId,
446
487
  betCoin
447
488
  }) => play2({
448
- package: config.gamesPackageId.limbo,
489
+ package: config.packageIds.limbo,
449
490
  typeArguments: [coinType],
450
491
  arguments: [
451
- config.sweetHousePackageId,
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
- pythPriceInfoObjectId
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
- pythPriceInfoObjectId,
543
+ priceInfoObjectId,
503
544
  betCoin
504
545
  }) => play3({
505
- package: config.gamesPackageId.plinko,
546
+ package: config.packageIds.plinko,
506
547
  typeArguments: [coinType],
507
548
  arguments: [
508
- config.sweetHousePackageId,
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
- pythPriceInfoObjectId
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
- function GameCreatedEvent(...typeParameters) {
528
- return new MoveStruct({ name: `${$moduleName2}::GameCreatedEvent<${typeParameters[0].name}>`, fields: {
529
- game_id: bcs.Address,
530
- creator: bcs.Address,
531
- creator_is_tails: bcs.bool(),
532
- is_private: bcs.bool(),
533
- joiner_is_tails: bcs.bool(),
534
- stake_per_player: bcs.u64(),
535
- house_edge_bps: bcs.u64(),
536
- coin_type: TypeName
537
- } });
538
- }
539
- function GameResolvedEvent(...typeParameters) {
540
- return new MoveStruct({ name: `${$moduleName2}::GameResolvedEvent<${typeParameters[0].name}>`, fields: {
541
- game_id: bcs.Address,
542
- creator: bcs.Address,
543
- joiner: bcs.Address,
544
- winner: bcs.Address,
545
- creator_is_tails: bcs.bool(),
546
- is_private: bcs.bool(),
547
- joiner_is_tails: bcs.bool(),
548
- stake_per_player: bcs.u64(),
549
- total_pot: bcs.u64(),
550
- house_edge_amount: bcs.u64(),
551
- payout_amount: bcs.u64(),
552
- coin_type: TypeName
553
- } });
554
- }
555
- function GameCancelledEvent(...typeParameters) {
556
- return new MoveStruct({ name: `${$moduleName2}::GameCancelledEvent<${typeParameters[0].name}>`, fields: {
557
- game_id: bcs.Address,
558
- creator: bcs.Address,
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.gamesPackageId["pvp-coinflip"],
672
+ package: createOptions.config.packageIds.pvpCoinflip,
638
673
  typeArguments: [normalizedCoinType],
639
674
  arguments: [
640
- createOptions.config.sweetHousePackageId,
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.gamesPackageId["pvp-coinflip"],
696
+ package: joinOptions.config.packageIds.pvpCoinflip,
662
697
  typeArguments: [normalizedCoinType],
663
698
  arguments: [
664
699
  joinOptions.gameId,
665
- joinOptions.config.sweetHousePackageId,
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.gamesPackageId["pvp-coinflip"],
714
+ package: cancelOptions.config.packageIds.pvpCoinflip,
680
715
  typeArguments: [normalizedCoinType],
681
716
  arguments: [
682
717
  cancelOptions.gameId,
683
- cancelOptions.config.sweetHousePackageId
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
- pythPriceInfoObjectId,
770
+ priceInfoObjectId,
736
771
  betCoin
737
772
  }) => play4({
738
- package: config.gamesPackageId.range,
773
+ package: config.packageIds.range,
739
774
  typeArguments: [coinType],
740
775
  arguments: [
741
- config.sweetHousePackageId,
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
- pythPriceInfoObjectId
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
- pythPriceInfoObjectId,
828
+ priceInfoObjectId,
794
829
  betCoin
795
830
  }) => play5({
796
- package: config.gamesPackageId.wheel,
831
+ package: config.packageIds.wheel,
797
832
  typeArguments: [coinType],
798
833
  arguments: [
799
- config.sweetHousePackageId,
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
- pythPriceInfoObjectId
841
+ priceInfoObjectId
807
842
  ]
808
843
  })(tx)
809
844
  });
@@ -839,50 +874,63 @@ function VecMap(...typeParameters) {
839
874
 
840
875
  // src/contracts/core/core.ts
841
876
  var $moduleName7 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core";
842
- function BetResultEvent(...typeParameters) {
843
- return new MoveStruct({ name: `${$moduleName7}::BetResultEvent<${typeParameters[0].name}>`, fields: {
844
- player: bcs.Address,
845
- coin_type: TypeName2,
846
- stake_amount: bcs.u64(),
847
- unsafe_oracle_usd_coin_price: Float,
848
- adjusted_oracle_usd_coin_price: Float,
849
- outcome_amount: bcs.u64(),
850
- game_details: VecMap(bcs.string(), bcs.vector(bcs.u8())),
851
- metadata: VecMap(bcs.string(), bcs.vector(bcs.u8()))
852
- } });
853
- }
854
-
855
- // src/client.ts
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
+ } });
856
887
  function suigar({
857
- name = "suigar",
858
- ...options
888
+ name = "suigar"
859
889
  } = {}) {
860
890
  return {
861
891
  name,
862
892
  register: (client) => {
863
- return new SuigarClient({ client, options });
893
+ return new SuigarClient({ client });
864
894
  }
865
895
  };
866
896
  }
867
897
  var SuigarClient = class {
868
898
  #client;
869
899
  #config;
870
- constructor({
871
- client,
872
- options
873
- }) {
900
+ constructor({ client }) {
874
901
  this.#client = client;
875
- this.#config = resolveSuigarConfig(options);
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);
876
907
  }
877
908
  /**
878
- * Builds a transaction with the configured Sui client and returns the BCS bytes as a base64 string.
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;
919
+ }
920
+ /**
921
+ * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.
922
+ *
923
+ * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string
924
+ * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard
925
+ * transaction build options except for `client`.
879
926
  *
880
- * @param transaction Transaction block to serialize.
927
+ * @param transaction Transaction to build and serialize.
928
+ * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
881
929
  * @returns Base64-encoded transaction bytes ready to send over the wire.
882
930
  */
883
- async serializeTransactionToBase64(transaction) {
884
- const bytes = await transaction.build({ client: this.#client });
885
- return Buffer.from(bytes).toString("base64");
931
+ async serializeTransactionToBase64(transaction, options) {
932
+ const bytes = await transaction.build({ ...options, client: this.#client });
933
+ return toBase64(bytes);
886
934
  }
887
935
  /**
888
936
  * BCS struct constructors for decoding Suigar events emitted on-chain.
@@ -963,4 +1011,4 @@ var SuigarClient = class {
963
1011
  };
964
1012
  };
965
1013
 
966
- export { SuigarClient, suigar };
1014
+ export { suigar };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suigar/sdk",
3
- "version": "2.0.0-beta.0",
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": {