@suigar/sdk 2.0.0-beta.10 → 2.0.0-beta.11

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.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  var utils = require('@mysten/sui/utils');
4
4
  var bcs = require('@mysten/sui/bcs');
5
5
  var transactions = require('@mysten/sui/transactions');
6
+ var client = require('@mysten/sui/client');
6
7
 
7
8
  // src/client.ts
8
9
  var MOVE_STDLIB_ADDRESS = utils.normalizeSuiAddress("0x1");
@@ -239,6 +240,12 @@ function VecMap2(...typeParameters) {
239
240
 
240
241
  // src/contracts/pvp-coinflip/pvp_coinflip.ts
241
242
  var $moduleName9 = "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip";
243
+ var PvpCoinflipSettingsKey = new MoveStruct({
244
+ name: `${$moduleName9}::PvpCoinflipSettingsKey`,
245
+ fields: {
246
+ dummy_field: bcs.bcs.bool()
247
+ }
248
+ });
242
249
  var Game = new MoveStruct({
243
250
  name: `${$moduleName9}::Game<phantom T0>`,
244
251
  fields: {
@@ -295,6 +302,14 @@ var GameCancelledEvent = new MoveStruct({
295
302
  coin_type: TypeName2
296
303
  }
297
304
  });
305
+ var Parameters = new MoveStruct({
306
+ name: `${$moduleName9}::Parameters<phantom T0>`,
307
+ fields: {
308
+ id: bcs.bcs.Address,
309
+ house_edge_bps: bcs.bcs.u64(),
310
+ min_stake: bcs.bcs.u64()
311
+ }
312
+ });
298
313
  function createGame(options) {
299
314
  const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
300
315
  const argumentsTypes = [
@@ -416,6 +431,7 @@ var REGISTRY_IDS = {
416
431
  };
417
432
 
418
433
  // src/helpers/config.ts
434
+ var DEFAULT_CACHE_TTL_MS = 30 * 60 * 1e3;
419
435
  function resolveSuigarConfig(network) {
420
436
  const packageIds = PACKAGE_IDS[network];
421
437
  const registryIds = REGISTRY_IDS[network];
@@ -477,6 +493,22 @@ function resolveSupportedCoin(config, coinType) {
477
493
  }
478
494
  return supportedCoin;
479
495
  }
496
+ function replaceStructTagAddress(structName, address) {
497
+ return utils.normalizeStructTag({
498
+ ...utils.parseStructTag(structName),
499
+ address
500
+ });
501
+ }
502
+ function resolveGameSettingsKeyType(structName, packageId) {
503
+ return replaceStructTagAddress(structName, packageId);
504
+ }
505
+ function resolveCoinTypeNameForTypeNameKey(structName) {
506
+ const { address } = utils.parseStructTag(structName);
507
+ return replaceStructTagAddress(
508
+ structName,
509
+ utils.normalizeSuiAddress(address).replace(/^0x/, "")
510
+ );
511
+ }
480
512
  var PARTNER_METADATA_KEY = "partner";
481
513
  var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([PARTNER_METADATA_KEY, "referrer"]);
482
514
  var textEncoder = new TextEncoder();
@@ -521,8 +553,22 @@ function encodeBetMetadata(metadata, partner) {
521
553
  values
522
554
  };
523
555
  }
524
-
525
- // src/contracts/coinflip/coinflip.ts
556
+ var $moduleName10 = "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea::coinflip";
557
+ var CoinFlipSettingsKey = new MoveStruct({
558
+ name: `${$moduleName10}::CoinFlipSettingsKey`,
559
+ fields: {
560
+ dummy_field: bcs.bcs.bool()
561
+ }
562
+ });
563
+ var Parameters2 = new MoveStruct({
564
+ name: `${$moduleName10}::Parameters<phantom T0>`,
565
+ fields: {
566
+ id: bcs.bcs.Address,
567
+ house_edge: bcs.bcs.u64(),
568
+ min_stake: bcs.bcs.u64(),
569
+ max_stake: bcs.bcs.u64()
570
+ }
571
+ });
526
572
  function play(options) {
527
573
  const packageAddress = options.package ?? "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea";
528
574
  const argumentsTypes = [
@@ -550,36 +596,43 @@ var DEFAULT_RANGE_SCALE = 1e6;
550
596
  var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
551
597
 
552
598
  // src/utils/numeric.ts
553
- function isFiniteNumber(value, message) {
554
- if (typeof value !== "number") {
555
- throw new Error(`${message}: ${String(value)}`);
556
- }
557
- if (!Number.isFinite(value)) {
558
- throw new Error(`Value must be a finite number: ${value}`);
599
+ function assertFiniteNumber(value, errorMessage) {
600
+ if (typeof value !== "number" || !Number.isFinite(value)) {
601
+ throw new TypeError(`${errorMessage}: ${String(value)}`);
559
602
  }
560
603
  }
561
604
  function toBigInt(value) {
562
- if (typeof value === "bigint") {
563
- if (value < 0n) {
564
- throw new Error(`Value must be non-negative: ${value}`);
605
+ let result;
606
+ try {
607
+ if (typeof value === "bigint" || typeof value === "string" || typeof value === "boolean") {
608
+ result = BigInt(value);
609
+ } else {
610
+ assertFiniteNumber(
611
+ value,
612
+ "Value must be a bigint, number, integer string, or boolean"
613
+ );
614
+ result = BigInt(Math.trunc(value));
565
615
  }
566
- return value;
616
+ } catch {
617
+ throw new TypeError(
618
+ `Value must be a bigint, number, integer string, or boolean: ${value}`
619
+ );
567
620
  }
568
- isFiniteNumber(value, "Value must be a bigint or number");
569
- if (value < 0) {
570
- throw new Error(`Value must be a finite non-negative number: ${value}`);
621
+ if (result < 0n) {
622
+ throw new RangeError(`Value must be non-negative: ${value}`);
571
623
  }
572
- return BigInt(Math.trunc(value));
624
+ return result;
573
625
  }
574
- function toU8(value) {
575
- isFiniteNumber(value, "Value must be a number");
576
- if (!Number.isInteger(value)) {
577
- throw new Error(`Value must be an integer: ${value}`);
578
- }
579
- if (value < 0 || value > 255) {
580
- throw new Error(`Value must be an integer between 0 and 255: ${value}`);
626
+ function toBoundedInt(value, max, typeName) {
627
+ const num = typeof value === "string" && value.trim() === "" ? NaN : Number(value);
628
+ assertFiniteNumber(num, "Value must be a finite number or integer string");
629
+ if (typeof value === "boolean" || value == null || !Number.isInteger(num) || num < 0 || num > max) {
630
+ throw new Error(`Value must be a ${typeName} integer (0-${max}): ${value}`);
581
631
  }
582
- return value;
632
+ return num;
633
+ }
634
+ function toU8(value) {
635
+ return toBoundedInt(value, 255, "u8");
583
636
  }
584
637
 
585
638
  // src/types/network.type.ts
@@ -697,8 +750,47 @@ function buildCoinflipTransaction(options) {
697
750
  })(tx)
698
751
  });
699
752
  }
753
+ var $moduleName11 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
754
+ var I642 = new MoveStruct({
755
+ name: `${$moduleName11}::I64`,
756
+ fields: {
757
+ bits: bcs.bcs.u64()
758
+ }
759
+ });
760
+
761
+ // src/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.ts
762
+ var $moduleName12 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
763
+ var Float2 = new MoveStruct({
764
+ name: `${$moduleName12}::Float`,
765
+ fields: {
766
+ is_negative: bcs.bcs.bool(),
767
+ exp: I642,
768
+ mant: bcs.bcs.u64()
769
+ }
770
+ });
700
771
 
701
772
  // src/contracts/limbo/limbo.ts
773
+ var $moduleName13 = "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4::limbo";
774
+ var LimboSettingsKey = new MoveStruct({
775
+ name: `${$moduleName13}::LimboSettingsKey`,
776
+ fields: {
777
+ dummy_field: bcs.bcs.bool()
778
+ }
779
+ });
780
+ var Parameters3 = new MoveStruct({
781
+ name: `${$moduleName13}::Parameters<phantom T0>`,
782
+ fields: {
783
+ id: bcs.bcs.Address,
784
+ min_stake: bcs.bcs.u64(),
785
+ max_stake: bcs.bcs.u64(),
786
+ max_payout: bcs.bcs.u64(),
787
+ min_target_multiplier: Float2,
788
+ max_target_multiplier: Float2,
789
+ max_number_of_games: bcs.bcs.u64(),
790
+ min_rtp: Float2,
791
+ max_rtp: Float2
792
+ }
793
+ });
702
794
  function play2(options) {
703
795
  const packageAddress = options.package ?? "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4";
704
796
  const argumentsTypes = [
@@ -756,8 +848,71 @@ function buildLimboTransaction(options) {
756
848
  })(tx)
757
849
  });
758
850
  }
851
+ var $moduleName14 = "0x2::vec_map";
852
+ function Entry3(...typeParameters) {
853
+ return new MoveStruct({
854
+ name: `${$moduleName14}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
855
+ fields: {
856
+ key: typeParameters[0],
857
+ value: typeParameters[1]
858
+ }
859
+ });
860
+ }
861
+ function VecMap3(...typeParameters) {
862
+ return new MoveStruct({
863
+ name: `${$moduleName14}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
864
+ fields: {
865
+ contents: bcs.bcs.vector(Entry3(typeParameters[0], typeParameters[1]))
866
+ }
867
+ });
868
+ }
869
+ var $moduleName15 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
870
+ var I643 = new MoveStruct({
871
+ name: `${$moduleName15}::I64`,
872
+ fields: {
873
+ bits: bcs.bcs.u64()
874
+ }
875
+ });
876
+
877
+ // src/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.ts
878
+ var $moduleName16 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
879
+ var Float3 = new MoveStruct({
880
+ name: `${$moduleName16}::Float`,
881
+ fields: {
882
+ is_negative: bcs.bcs.bool(),
883
+ exp: I643,
884
+ mant: bcs.bcs.u64()
885
+ }
886
+ });
759
887
 
760
888
  // src/contracts/plinko/plinko.ts
889
+ var $moduleName17 = "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7::plinko";
890
+ var PlinkoSettingsKey = new MoveStruct({
891
+ name: `${$moduleName17}::PlinkoSettingsKey`,
892
+ fields: {
893
+ dummy_field: bcs.bcs.bool()
894
+ }
895
+ });
896
+ var PlinkoConfig = new MoveStruct({
897
+ name: `${$moduleName17}::PlinkoConfig`,
898
+ fields: {
899
+ num_rows: bcs.bcs.u8(),
900
+ multipliers: bcs.bcs.vector(Float3),
901
+ min_stake: bcs.bcs.u64(),
902
+ max_stake: bcs.bcs.u64(),
903
+ is_playable: bcs.bcs.bool()
904
+ }
905
+ });
906
+ var Parameters4 = new MoveStruct({
907
+ name: `${$moduleName17}::Parameters<phantom T0>`,
908
+ fields: {
909
+ id: bcs.bcs.Address,
910
+ min_stake: bcs.bcs.u64(),
911
+ max_stake: bcs.bcs.u64(),
912
+ max_number_of_balls: bcs.bcs.u64(),
913
+ configs: VecMap3(bcs.bcs.u8(), PlinkoConfig)
914
+ }
915
+ });
761
916
  function play3(options) {
762
917
  const packageAddress = options.package ?? "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7";
763
918
  const argumentsTypes = [
@@ -884,8 +1039,46 @@ function buildPvPCoinflipTransaction(action, options) {
884
1039
  throw new Error(`Unsupported PvP coinflip action: ${action}`);
885
1040
  }
886
1041
  }
1042
+ var $moduleName18 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
1043
+ var I644 = new MoveStruct({
1044
+ name: `${$moduleName18}::I64`,
1045
+ fields: {
1046
+ bits: bcs.bcs.u64()
1047
+ }
1048
+ });
1049
+
1050
+ // src/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.ts
1051
+ var $moduleName19 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
1052
+ var Float4 = new MoveStruct({
1053
+ name: `${$moduleName19}::Float`,
1054
+ fields: {
1055
+ is_negative: bcs.bcs.bool(),
1056
+ exp: I644,
1057
+ mant: bcs.bcs.u64()
1058
+ }
1059
+ });
887
1060
 
888
1061
  // src/contracts/range/range.ts
1062
+ var $moduleName20 = "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416::range";
1063
+ var RangeSettingsKey = new MoveStruct({
1064
+ name: `${$moduleName20}::RangeSettingsKey`,
1065
+ fields: {
1066
+ dummy_field: bcs.bcs.bool()
1067
+ }
1068
+ });
1069
+ var Parameters5 = new MoveStruct({
1070
+ name: `${$moduleName20}::Parameters<phantom T0>`,
1071
+ fields: {
1072
+ id: bcs.bcs.Address,
1073
+ min_stake: bcs.bcs.u64(),
1074
+ max_stake: bcs.bcs.u64(),
1075
+ min_zone_size: bcs.bcs.u64(),
1076
+ max_zone_size: bcs.bcs.u64(),
1077
+ max_number_of_games: bcs.bcs.u64(),
1078
+ min_rtp: Float4,
1079
+ max_rtp: Float4
1080
+ }
1081
+ });
889
1082
  function play4(options) {
890
1083
  const packageAddress = options.package ?? "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416";
891
1084
  const argumentsTypes = [
@@ -946,8 +1139,71 @@ function buildRangeTransaction(options) {
946
1139
  })(tx)
947
1140
  });
948
1141
  }
1142
+ var $moduleName21 = "0x2::vec_map";
1143
+ function Entry4(...typeParameters) {
1144
+ return new MoveStruct({
1145
+ name: `${$moduleName21}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
1146
+ fields: {
1147
+ key: typeParameters[0],
1148
+ value: typeParameters[1]
1149
+ }
1150
+ });
1151
+ }
1152
+ function VecMap4(...typeParameters) {
1153
+ return new MoveStruct({
1154
+ name: `${$moduleName21}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
1155
+ fields: {
1156
+ contents: bcs.bcs.vector(Entry4(typeParameters[0], typeParameters[1]))
1157
+ }
1158
+ });
1159
+ }
1160
+ var $moduleName22 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
1161
+ var I645 = new MoveStruct({
1162
+ name: `${$moduleName22}::I64`,
1163
+ fields: {
1164
+ bits: bcs.bcs.u64()
1165
+ }
1166
+ });
1167
+
1168
+ // src/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.ts
1169
+ var $moduleName23 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
1170
+ var Float5 = new MoveStruct({
1171
+ name: `${$moduleName23}::Float`,
1172
+ fields: {
1173
+ is_negative: bcs.bcs.bool(),
1174
+ exp: I645,
1175
+ mant: bcs.bcs.u64()
1176
+ }
1177
+ });
949
1178
 
950
1179
  // src/contracts/wheel/wheel.ts
1180
+ var $moduleName24 = "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7::wheel";
1181
+ var WheelSettingsKey = new MoveStruct({
1182
+ name: `${$moduleName24}::WheelSettingsKey`,
1183
+ fields: {
1184
+ dummy_field: bcs.bcs.bool()
1185
+ }
1186
+ });
1187
+ var WheelConfig = new MoveStruct({
1188
+ name: `${$moduleName24}::WheelConfig`,
1189
+ fields: {
1190
+ num_cases: bcs.bcs.u8(),
1191
+ multipliers: bcs.bcs.vector(Float5),
1192
+ min_stake: bcs.bcs.u64(),
1193
+ max_stake: bcs.bcs.u64(),
1194
+ is_playable: bcs.bcs.bool()
1195
+ }
1196
+ });
1197
+ var Parameters6 = new MoveStruct({
1198
+ name: `${$moduleName24}::Parameters<phantom T0>`,
1199
+ fields: {
1200
+ id: bcs.bcs.Address,
1201
+ min_stake: bcs.bcs.u64(),
1202
+ max_stake: bcs.bcs.u64(),
1203
+ max_number_of_spins: bcs.bcs.u64(),
1204
+ configs: VecMap4(bcs.bcs.u8(), WheelConfig)
1205
+ }
1206
+ });
951
1207
  function play5(options) {
952
1208
  const packageAddress = options.package ?? "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7";
953
1209
  const argumentsTypes = [
@@ -1002,16 +1258,127 @@ function buildWheelTransaction(options) {
1002
1258
  })(tx)
1003
1259
  });
1004
1260
  }
1261
+ var TtlClientCache = class extends client.ClientCache {
1262
+ #ttlMs;
1263
+ constructor({ ttlMs, ...options }) {
1264
+ super({
1265
+ ...options,
1266
+ prefix: options.prefix ?? ["ttl"]
1267
+ });
1268
+ this.#ttlMs = ttlMs;
1269
+ }
1270
+ read(key, load, options) {
1271
+ if (options?.ignoreCache) {
1272
+ super.clear(key);
1273
+ }
1274
+ if (this.#ttlMs <= 0) {
1275
+ return load();
1276
+ }
1277
+ const cached = super.read(
1278
+ key,
1279
+ () => this.#loadEntry(key, load)
1280
+ );
1281
+ if (cached && cached.expiresAt > Date.now()) {
1282
+ return cached.value;
1283
+ }
1284
+ super.clear(key);
1285
+ return super.read(
1286
+ key,
1287
+ () => this.#loadEntry(key, load)
1288
+ ).value;
1289
+ }
1290
+ readSync(key, load, options) {
1291
+ if (options?.ignoreCache) {
1292
+ super.clear(key);
1293
+ }
1294
+ if (this.#ttlMs <= 0) {
1295
+ return load();
1296
+ }
1297
+ const cached = super.readSync(
1298
+ key,
1299
+ () => this.#loadSyncEntry(load)
1300
+ );
1301
+ if (cached.expiresAt > Date.now()) {
1302
+ return cached.value;
1303
+ }
1304
+ super.clear(key);
1305
+ return super.readSync(key, () => this.#loadSyncEntry(load)).value;
1306
+ }
1307
+ #loadEntry(key, load) {
1308
+ const value = load();
1309
+ const entry = {
1310
+ value,
1311
+ expiresAt: Date.now() + this.#ttlMs
1312
+ };
1313
+ if (isPromiseLike(value)) {
1314
+ entry.value = Promise.resolve(value).then((resolved) => {
1315
+ super.clear(key);
1316
+ super.read(key, () => ({
1317
+ value: resolved,
1318
+ expiresAt: Date.now() + this.#ttlMs
1319
+ }));
1320
+ return resolved;
1321
+ }).catch((error) => {
1322
+ super.clear(key);
1323
+ throw error;
1324
+ });
1325
+ }
1326
+ return entry;
1327
+ }
1328
+ #loadSyncEntry(load) {
1329
+ return {
1330
+ value: load(),
1331
+ expiresAt: Date.now() + this.#ttlMs
1332
+ };
1333
+ }
1334
+ };
1335
+ function isPromiseLike(value) {
1336
+ return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value;
1337
+ }
1338
+
1339
+ // src/types/game-settings.type.ts
1340
+ var GAME_SETTINGS = {
1341
+ coinflip: {
1342
+ settingsKey: CoinFlipSettingsKey,
1343
+ parameters: Parameters2
1344
+ },
1345
+ limbo: {
1346
+ settingsKey: LimboSettingsKey,
1347
+ parameters: Parameters3
1348
+ },
1349
+ plinko: {
1350
+ settingsKey: PlinkoSettingsKey,
1351
+ parameters: Parameters4
1352
+ },
1353
+ "pvp-coinflip": {
1354
+ settingsKey: PvpCoinflipSettingsKey,
1355
+ parameters: Parameters
1356
+ },
1357
+ range: {
1358
+ settingsKey: RangeSettingsKey,
1359
+ parameters: Parameters5
1360
+ },
1361
+ wheel: {
1362
+ settingsKey: WheelSettingsKey,
1363
+ parameters: Parameters6
1364
+ }
1365
+ };
1005
1366
 
1006
1367
  // src/client.ts
1007
1368
  function suigar({
1008
1369
  name = "suigar",
1009
- partner
1370
+ partner,
1371
+ cacheTtl
1010
1372
  } = {}) {
1011
1373
  return {
1012
1374
  name,
1013
1375
  register: (client) => {
1014
- return new SuigarClient({ client, partner });
1376
+ return new SuigarClient({
1377
+ client,
1378
+ name: String(name),
1379
+ partner,
1380
+ cacheTtl
1381
+ });
1015
1382
  }
1016
1383
  };
1017
1384
  }
@@ -1019,12 +1386,20 @@ var SuigarClient = class {
1019
1386
  #client;
1020
1387
  #config;
1021
1388
  #partner;
1389
+ #cache;
1022
1390
  constructor({
1023
1391
  client,
1024
- partner
1392
+ name,
1393
+ partner,
1394
+ cacheTtl
1025
1395
  }) {
1026
1396
  this.#client = client;
1027
1397
  this.#partner = partner;
1398
+ this.#cache = client.cache.scope("@suigar/sdk").readSync([name, "ttl-cache"], () => {
1399
+ return new TtlClientCache({
1400
+ ttlMs: cacheTtl ?? DEFAULT_CACHE_TTL_MS
1401
+ });
1402
+ });
1028
1403
  const network = this.#client.network;
1029
1404
  if (!SUPPORTED_SUI_NETWORKS.includes(network)) {
1030
1405
  throw new Error(`Unsupported network: ${network}`);
@@ -1035,8 +1410,8 @@ var SuigarClient = class {
1035
1410
  * Returns the resolved SDK configuration for the connected network.
1036
1411
  *
1037
1412
  * This is primarily useful for debugging or inspecting which package ids,
1038
- * supported coin types, and price info object ids the SDK resolved for the
1039
- * current client network.
1413
+ * registry ids, supported coin types, and price info object ids the SDK
1414
+ * resolved for the current client network.
1040
1415
  *
1041
1416
  * @returns Network-resolved Suigar configuration.
1042
1417
  */
@@ -1058,6 +1433,29 @@ var SuigarClient = class {
1058
1433
  const bytes = await transaction.build({ ...options, client: this.#client });
1059
1434
  return utils.toBase64(bytes);
1060
1435
  }
1436
+ /**
1437
+ * Reads on-chain game parameters for the requested game.
1438
+ *
1439
+ * The SDK first reads the selected game's settings object from SweetHouse,
1440
+ * then reads that game's coin-specific `Parameters<T>` object. Results are
1441
+ * cached according to the extension `cacheTtl` option. Pass
1442
+ * `ignoreCache: true` to refresh the onchain read and replace the cached
1443
+ * value.
1444
+ *
1445
+ * @param game Game whose parameters should be loaded.
1446
+ * @param options Optional coin type, cache override, and abort signal.
1447
+ * @returns Parsed game parameters typed for the requested game.
1448
+ */
1449
+ async getGameParameters(game, options = {}) {
1450
+ const coinType = utils.normalizeStructTag(
1451
+ options.coinType ?? this.#config.coinTypes.sui
1452
+ );
1453
+ return this.#cache.read(
1454
+ ["parameters", this.#client.network, game, coinType],
1455
+ () => this.#fetchGameParameters(game, coinType, options.signal),
1456
+ { ignoreCache: options.ignoreCache }
1457
+ );
1458
+ }
1061
1459
  /**
1062
1460
  * Lists unresolved PvP coinflip games from the configured registry and resolves
1063
1461
  * each entry into parsed onchain game state.
@@ -1122,6 +1520,41 @@ var SuigarClient = class {
1122
1520
  (game) => game instanceof Error ? [] : [game]
1123
1521
  );
1124
1522
  }
1523
+ async #fetchGameParameters(game, coinType, signal) {
1524
+ const gameDefinition = GAME_SETTINGS[game];
1525
+ const { object: settingsObject } = await this.#client.core.getDynamicObjectField({
1526
+ parentId: this.#config.packageIds.sweetHouse,
1527
+ name: {
1528
+ type: resolveGameSettingsKeyType(
1529
+ gameDefinition.settingsKey.name,
1530
+ resolveGamePackageId(this.#config, game)
1531
+ ),
1532
+ bcs: gameDefinition.settingsKey.serialize({ dummy_field: false }).toBytes()
1533
+ },
1534
+ signal
1535
+ });
1536
+ const { object } = await this.#client.core.getDynamicObjectField({
1537
+ parentId: settingsObject.objectId,
1538
+ name: {
1539
+ type: TypeName.name,
1540
+ bcs: TypeName.serialize({
1541
+ name: resolveCoinTypeNameForTypeNameKey(coinType)
1542
+ }).toBytes()
1543
+ },
1544
+ include: {
1545
+ content: true
1546
+ },
1547
+ signal
1548
+ });
1549
+ if (!object?.content) {
1550
+ throw new Error(
1551
+ `Missing parameters object content for ${game} and coin type ${coinType}`
1552
+ );
1553
+ }
1554
+ return gameDefinition.parameters.parse(
1555
+ object.content
1556
+ );
1557
+ }
1125
1558
  /**
1126
1559
  * BCS struct constructors for decoding on-chain objects and events related to Suigar games.
1127
1560
  *