@suigar/sdk 2.0.0-beta.2 → 2.0.0-beta.20

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 (147) hide show
  1. package/CHANGELOG.md +165 -1
  2. package/README.md +300 -59
  3. package/dist/client.d.mts +257 -0
  4. package/dist/client.d.mts.map +1 -0
  5. package/dist/client.mjs +278 -0
  6. package/dist/client.mjs.map +1 -0
  7. package/dist/configs/package.mainnet.mjs +23 -0
  8. package/dist/configs/package.mainnet.mjs.map +1 -0
  9. package/dist/configs/package.mjs +19 -0
  10. package/dist/configs/package.mjs.map +1 -0
  11. package/dist/configs/package.testnet.mjs +23 -0
  12. package/dist/configs/package.testnet.mjs.map +1 -0
  13. package/dist/configs/registry.mainnet.mjs +6 -0
  14. package/dist/configs/registry.mainnet.mjs.map +1 -0
  15. package/dist/configs/registry.mjs +11 -0
  16. package/dist/configs/registry.mjs.map +1 -0
  17. package/dist/configs/registry.testnet.mjs +6 -0
  18. package/dist/configs/registry.testnet.mjs.map +1 -0
  19. package/dist/contracts/coinflip/coinflip.mjs +46 -0
  20. package/dist/contracts/coinflip/coinflip.mjs.map +1 -0
  21. package/dist/contracts/core/core.d.mts +54 -0
  22. package/dist/contracts/core/core.d.mts.map +1 -0
  23. package/dist/contracts/core/core.mjs +22 -0
  24. package/dist/contracts/core/core.mjs.map +1 -0
  25. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  26. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  27. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  28. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  29. package/dist/contracts/core/float.d.mts +13 -0
  30. package/dist/contracts/core/float.d.mts.map +1 -0
  31. package/dist/contracts/core/float.mjs +15 -0
  32. package/dist/contracts/core/float.mjs.map +1 -0
  33. package/dist/contracts/core/i64.mjs +10 -0
  34. package/dist/contracts/core/i64.mjs.map +1 -0
  35. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  36. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  37. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  38. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  39. package/dist/contracts/limbo/limbo.mjs +53 -0
  40. package/dist/contracts/limbo/limbo.mjs.map +1 -0
  41. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  42. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  43. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  44. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  45. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  46. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  47. package/dist/contracts/plinko/plinko.mjs +59 -0
  48. package/dist/contracts/plinko/plinko.mjs.map +1 -0
  49. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  50. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  51. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +10 -0
  52. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
  53. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  54. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  55. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts +33 -0
  56. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts.map +1 -0
  57. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs +131 -0
  58. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs.map +1 -0
  59. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  60. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  61. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  62. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  63. package/dist/contracts/range/range.mjs +53 -0
  64. package/dist/contracts/range/range.mjs.map +1 -0
  65. package/dist/contracts/utils/index.d.mts +68 -0
  66. package/dist/contracts/utils/index.d.mts.map +1 -0
  67. package/dist/contracts/utils/index.mjs +185 -0
  68. package/dist/contracts/utils/index.mjs.map +1 -0
  69. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  70. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  71. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  72. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  73. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  74. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  75. package/dist/contracts/wheel/wheel.mjs +59 -0
  76. package/dist/contracts/wheel/wheel.mjs.map +1 -0
  77. package/dist/games.d.mts +3 -0
  78. package/dist/games.mjs +1 -0
  79. package/dist/helpers/config.mjs +51 -0
  80. package/dist/helpers/config.mjs.map +1 -0
  81. package/dist/helpers/game-settings.mjs +19 -0
  82. package/dist/helpers/game-settings.mjs.map +1 -0
  83. package/dist/helpers/metadata.mjs +42 -0
  84. package/dist/helpers/metadata.mjs.map +1 -0
  85. package/dist/index.d.mts +2 -0
  86. package/dist/index.mjs +2 -0
  87. package/dist/transactions/coinflip.mjs +27 -0
  88. package/dist/transactions/coinflip.mjs.map +1 -0
  89. package/dist/transactions/limbo.mjs +31 -0
  90. package/dist/transactions/limbo.mjs.map +1 -0
  91. package/dist/transactions/plinko.mjs +29 -0
  92. package/dist/transactions/plinko.mjs.map +1 -0
  93. package/dist/transactions/pvp-coinflip.mjs +70 -0
  94. package/dist/transactions/pvp-coinflip.mjs.map +1 -0
  95. package/dist/transactions/range.mjs +33 -0
  96. package/dist/transactions/range.mjs.map +1 -0
  97. package/dist/transactions/shared.mjs +49 -0
  98. package/dist/transactions/shared.mjs.map +1 -0
  99. package/dist/transactions/wheel.mjs +29 -0
  100. package/dist/transactions/wheel.mjs.map +1 -0
  101. package/dist/ttl-cache.mjs +60 -0
  102. package/dist/ttl-cache.mjs.map +1 -0
  103. package/dist/types/bet-metadata.type.d.mts +7 -0
  104. package/dist/types/bet-metadata.type.d.mts.map +1 -0
  105. package/dist/types/build-game-transaction-options.type.d.mts +9 -0
  106. package/dist/types/build-game-transaction-options.type.d.mts.map +1 -0
  107. package/dist/types/game-details.type.d.mts +72 -0
  108. package/dist/types/game-details.type.d.mts.map +1 -0
  109. package/dist/types/game-details.type.mjs +59 -0
  110. package/dist/types/game-details.type.mjs.map +1 -0
  111. package/dist/types/game-settings.type.d.mts +200 -0
  112. package/dist/types/game-settings.type.d.mts.map +1 -0
  113. package/dist/types/game-settings.type.mjs +37 -0
  114. package/dist/types/game-settings.type.mjs.map +1 -0
  115. package/dist/types/game.type.d.mts +15 -0
  116. package/dist/types/game.type.d.mts.map +1 -0
  117. package/dist/types/game.type.mjs +19 -0
  118. package/dist/types/game.type.mjs.map +1 -0
  119. package/dist/types/index.d.mts +7 -0
  120. package/dist/types/move-float.type.d.mts +7 -0
  121. package/dist/types/move-float.type.d.mts.map +1 -0
  122. package/dist/types/network.type.d.mts +1 -0
  123. package/dist/types/network.type.mjs +6 -0
  124. package/dist/types/network.type.mjs.map +1 -0
  125. package/dist/types/suigar-config.type.d.mts +33 -0
  126. package/dist/types/suigar-config.type.d.mts.map +1 -0
  127. package/dist/types/transaction-options.type.d.mts +63 -0
  128. package/dist/types/transaction-options.type.d.mts.map +1 -0
  129. package/dist/utils/constants.d.mts +8 -0
  130. package/dist/utils/constants.d.mts.map +1 -0
  131. package/dist/utils/constants.mjs +10 -0
  132. package/dist/utils/constants.mjs.map +1 -0
  133. package/dist/utils/numeric.d.mts +86 -0
  134. package/dist/utils/numeric.d.mts.map +1 -0
  135. package/dist/utils/numeric.mjs +148 -0
  136. package/dist/utils/numeric.mjs.map +1 -0
  137. package/dist/utils/parser.d.mts +54 -0
  138. package/dist/utils/parser.d.mts.map +1 -0
  139. package/dist/utils/parser.mjs +94 -0
  140. package/dist/utils/parser.mjs.map +1 -0
  141. package/dist/utils.d.mts +4 -0
  142. package/dist/utils.mjs +4 -0
  143. package/package.json +80 -82
  144. package/dist/index.cjs +0 -1016
  145. package/dist/index.d.cts +0 -267
  146. package/dist/index.d.ts +0 -267
  147. package/dist/index.js +0 -1014
package/dist/index.js DELETED
@@ -1,1014 +0,0 @@
1
- import { normalizeSuiAddress, toBase64, normalizeStructTag } from '@mysten/sui/utils';
2
- import { bcs, BcsStruct, TypeTagSerializer } from '@mysten/sui/bcs';
3
- import { Transaction, isArgument } from '@mysten/sui/transactions';
4
-
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
- };
30
-
31
- // src/configs/package.testnet.ts
32
- var TESTNET_PACKAGE_IDS = {
33
- sweetHouse: "0xb7f64e5a273aba1ede00caa0a6f8027cc7490c279d17eab12e7100ed20660603",
34
- core: "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc",
35
- coinflip: "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea",
36
- limbo: "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4",
37
- plinko: "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7",
38
- pvpCoinflip: "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202",
39
- range: "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416",
40
- wheel: "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7"
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
- };
50
-
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
- };
64
-
65
- // src/utils/config.ts
66
- function resolveSuigarConfig(network) {
67
- const packageIds = PACKAGE_IDS[network];
68
- const coinTypes = COIN_TYPES[network];
69
- const priceInfoObjectIds = PRICE_INFO_OBJECT_IDS[network];
70
- return {
71
- packageIds: { ...packageIds },
72
- coinTypes: {
73
- sui: normalizeStructTag(coinTypes.sui),
74
- usdc: normalizeStructTag(coinTypes.usdc)
75
- },
76
- priceInfoObjectIds: {
77
- sui: priceInfoObjectIds.sui,
78
- usdc: priceInfoObjectIds.usdc
79
- }
80
- };
81
- }
82
- function assertConfiguredBetGame(config, game) {
83
- if (!resolveGamePackageId(config, game)) {
84
- throw new Error(`Missing required config for ${game}: packageIds.${game}`);
85
- }
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;
101
- }
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;
109
- }
110
- throw new Error(
111
- `Missing price info object configuration for coin type ${coinType}`
112
- );
113
- }
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;
121
- }
122
- throw new Error(
123
- `Unsupported coin type ${coinType}. Supported coin types: ${entries.map(([, configuredCoinType]) => configuredCoinType).join(", ")}`
124
- );
125
- }
126
- var ADDRESS_METADATA_KEYS = /* @__PURE__ */ new Set(["referrer", "partner"]);
127
- var textEncoder = new TextEncoder();
128
- var parseHexAddress = (value) => {
129
- const trimmed = value.trim();
130
- if (!trimmed) return null;
131
- try {
132
- const normalized = normalizeSuiAddress(trimmed).slice(2);
133
- const bytes = new Uint8Array(normalized.length / 2);
134
- for (let index = 0; index < normalized.length; index += 2) {
135
- bytes[index / 2] = Number.parseInt(
136
- normalized.slice(index, index + 2),
137
- 16
138
- );
139
- }
140
- return bytes;
141
- } catch {
142
- return null;
143
- }
144
- };
145
- function encodeBetMetadata(metadata) {
146
- const keys = [];
147
- const values = [];
148
- for (const [key, value] of Object.entries(metadata ?? {})) {
149
- if (value === void 0 || value === null) {
150
- continue;
151
- }
152
- let encodedValue;
153
- if (value instanceof Uint8Array) {
154
- encodedValue = Array.from(value);
155
- } else if (Array.isArray(value)) {
156
- encodedValue = value;
157
- } else if (typeof value === "string" && ADDRESS_METADATA_KEYS.has(key)) {
158
- encodedValue = Array.from(
159
- parseHexAddress(value) ?? textEncoder.encode(value)
160
- );
161
- } else {
162
- encodedValue = Array.from(textEncoder.encode(String(value)));
163
- }
164
- keys.push(key);
165
- values.push(encodedValue);
166
- }
167
- return { keys, values };
168
- }
169
-
170
- // src/utils/shared.ts
171
- var DEFAULT_GAS_BUDGET_MIST = 5e7;
172
- var RANGE_FIXED_POINT_SCALE = 1e6;
173
- var LIMBO_MULTIPLIER_SCALE = 100;
174
- function toBigIntAmount(value, fieldName) {
175
- if (typeof value === "bigint") {
176
- if (value < 0n) {
177
- throw new Error(`${fieldName} must be non-negative`);
178
- }
179
- return value;
180
- }
181
- if (!Number.isFinite(value) || value < 0) {
182
- throw new Error(`${fieldName} must be a finite non-negative number`);
183
- }
184
- return BigInt(Math.trunc(value));
185
- }
186
- function toU8Number(value, fieldName) {
187
- if (!Number.isInteger(value) || value < 0 || value > 255) {
188
- throw new Error(`${fieldName} must be an integer between 0 and 255`);
189
- }
190
- return value;
191
- }
192
- var MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
193
- var SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
194
- function getPureBcsSchema(typeTag) {
195
- const parsedTag = typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
196
- if ("u8" in parsedTag) {
197
- return bcs.U8;
198
- } else if ("u16" in parsedTag) {
199
- return bcs.U16;
200
- } else if ("u32" in parsedTag) {
201
- return bcs.U32;
202
- } else if ("u64" in parsedTag) {
203
- return bcs.U64;
204
- } else if ("u128" in parsedTag) {
205
- return bcs.U128;
206
- } else if ("u256" in parsedTag) {
207
- return bcs.U256;
208
- } else if ("address" in parsedTag) {
209
- return bcs.Address;
210
- } else if ("bool" in parsedTag) {
211
- return bcs.Bool;
212
- } else if ("vector" in parsedTag) {
213
- const type = getPureBcsSchema(parsedTag.vector);
214
- return type ? bcs.vector(type) : null;
215
- } else if ("struct" in parsedTag) {
216
- const structTag = parsedTag.struct;
217
- const pkg = normalizeSuiAddress(structTag.address);
218
- if (pkg === MOVE_STDLIB_ADDRESS) {
219
- if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") {
220
- return bcs.String;
221
- }
222
- if (structTag.module === "option" && structTag.name === "Option") {
223
- const type = getPureBcsSchema(structTag.typeParams[0]);
224
- return type ? bcs.option(type) : null;
225
- }
226
- }
227
- if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === "object" && (structTag.name === "ID" || structTag.name === "UID")) {
228
- return bcs.Address;
229
- }
230
- }
231
- return null;
232
- }
233
- function normalizeMoveArguments(args, argTypes, parameterNames) {
234
- Array.isArray(args) ? args.length : Object.keys(args).length;
235
- const normalizedArgs = [];
236
- let index = 0;
237
- for (const [i, argType] of argTypes.entries()) {
238
- if (argType === "0x2::clock::Clock") {
239
- normalizedArgs.push((tx) => tx.object.clock());
240
- continue;
241
- }
242
- if (argType === "0x2::random::Random") {
243
- normalizedArgs.push((tx) => tx.object.random());
244
- continue;
245
- }
246
- if (argType === "0x2::deny_list::DenyList") {
247
- normalizedArgs.push((tx) => tx.object.denyList());
248
- continue;
249
- }
250
- if (argType === "0x3::sui_system::SuiSystemState") {
251
- normalizedArgs.push((tx) => tx.object.system());
252
- continue;
253
- }
254
- let arg;
255
- if (Array.isArray(args)) {
256
- if (index >= args.length) {
257
- throw new Error(
258
- `Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`
259
- );
260
- }
261
- arg = args[index];
262
- } else {
263
- {
264
- throw new Error(`Expected arguments to be passed as an array`);
265
- }
266
- }
267
- index += 1;
268
- if (typeof arg === "function" || isArgument(arg)) {
269
- normalizedArgs.push(arg);
270
- continue;
271
- }
272
- const type = argTypes[i];
273
- const bcsType = type === null ? null : getPureBcsSchema(type);
274
- if (bcsType) {
275
- const bytes = bcsType.serialize(arg);
276
- normalizedArgs.push((tx) => tx.pure(bytes));
277
- continue;
278
- }
279
- if (typeof arg === "string") {
280
- normalizedArgs.push((tx) => tx.object(arg));
281
- continue;
282
- }
283
- throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
284
- }
285
- return normalizedArgs;
286
- }
287
- var MoveStruct = class extends BcsStruct {
288
- async get({
289
- objectId,
290
- ...options
291
- }) {
292
- const [res] = await this.getMany({
293
- ...options,
294
- objectIds: [objectId]
295
- });
296
- return res;
297
- }
298
- async getMany({
299
- client,
300
- ...options
301
- }) {
302
- const response = await client.core.getObjects({
303
- ...options,
304
- include: {
305
- ...options.include,
306
- content: true
307
- }
308
- });
309
- return response.objects.map((obj) => {
310
- if (obj instanceof Error) {
311
- throw obj;
312
- }
313
- return {
314
- ...obj,
315
- json: this.parse(obj.content)
316
- };
317
- });
318
- }
319
- };
320
- function stringify(val) {
321
- if (typeof val === "object") {
322
- return JSON.stringify(val, (val2) => val2);
323
- }
324
- if (typeof val === "bigint") {
325
- return val.toString();
326
- }
327
- return val;
328
- }
329
-
330
- // src/contracts/coinflip/coinflip.ts
331
- function play(options) {
332
- const packageAddress = options.package ?? "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea";
333
- const argumentsTypes = [
334
- null,
335
- "u64",
336
- null,
337
- "u64",
338
- "bool",
339
- "vector<0x1::string::String>",
340
- "vector<vector<u8>>",
341
- null,
342
- "0x2::clock::Clock",
343
- "0x2::random::Random"
344
- ];
345
- return (tx) => tx.moveCall({
346
- package: packageAddress,
347
- module: "coinflip",
348
- function: "play",
349
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
350
- typeArguments: options.typeArguments
351
- });
352
- }
353
- function createBaseGameTransaction({
354
- config,
355
- game,
356
- owner,
357
- sender,
358
- gasBudget
359
- }) {
360
- assertConfiguredBetGame(config, game);
361
- const tx = new Transaction();
362
- tx.setSenderIfNotSet(normalizeSuiAddress(sender ?? owner));
363
- tx.setGasBudgetIfNotSet(gasBudget ?? DEFAULT_GAS_BUDGET_MIST);
364
- return tx;
365
- }
366
- function buildSharedStandardGameBetCall({
367
- config,
368
- owner,
369
- sender,
370
- coinType,
371
- stake,
372
- cashStake,
373
- betCount,
374
- metadata,
375
- allowGasCoinShortcut = true,
376
- buildRewardCoin
377
- }) {
378
- return (tx) => {
379
- const normalizedOwner = normalizeSuiAddress(sender ?? owner);
380
- const normalizedCoinType = normalizeStructTag(coinType);
381
- const resolvedStake = toBigIntAmount(stake, "stake");
382
- const resolvedCashStake = toBigIntAmount(cashStake ?? stake, "cashStake");
383
- const resolvedBetCount = toBigIntAmount(betCount ?? 1, "betCount");
384
- const encodedMetadata = encodeBetMetadata(metadata);
385
- const priceInfoObjectId = resolvePriceInfoObjectId(
386
- config,
387
- normalizedCoinType
388
- );
389
- const betCoin = tx.coin({
390
- type: normalizedCoinType,
391
- balance: resolvedCashStake,
392
- useGasCoin: allowGasCoinShortcut
393
- });
394
- const rewardCoin = buildRewardCoin({
395
- tx,
396
- config,
397
- owner: normalizedOwner,
398
- coinType: normalizedCoinType,
399
- stake: resolvedStake,
400
- cashStake: resolvedCashStake,
401
- betCount: resolvedBetCount,
402
- metadata: encodedMetadata,
403
- priceInfoObjectId,
404
- betCoin
405
- });
406
- tx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));
407
- return rewardCoin;
408
- };
409
- }
410
- function buildSharedStandardGameBetTransaction(options) {
411
- const tx = createBaseGameTransaction(options);
412
- tx.add(buildSharedStandardGameBetCall(options));
413
- return tx;
414
- }
415
-
416
- // src/transactions/coinflip.ts
417
- function buildCoinflipTransaction(options) {
418
- return buildSharedStandardGameBetTransaction({
419
- ...options,
420
- game: "coinflip",
421
- buildRewardCoin: ({
422
- tx,
423
- config,
424
- coinType,
425
- stake,
426
- betCount,
427
- metadata,
428
- priceInfoObjectId,
429
- betCoin
430
- }) => play({
431
- package: config.packageIds.coinflip,
432
- typeArguments: [coinType],
433
- arguments: [
434
- config.packageIds.sweetHouse,
435
- stake,
436
- betCoin,
437
- betCount,
438
- options.side === "tails",
439
- metadata.keys,
440
- metadata.values,
441
- priceInfoObjectId
442
- ]
443
- })(tx)
444
- });
445
- }
446
-
447
- // src/contracts/limbo/limbo.ts
448
- function play2(options) {
449
- const packageAddress = options.package ?? "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4";
450
- const argumentsTypes = [
451
- null,
452
- "u64",
453
- null,
454
- "u64",
455
- "u64",
456
- "u64",
457
- "vector<0x1::string::String>",
458
- "vector<vector<u8>>",
459
- null,
460
- "0x2::clock::Clock",
461
- "0x2::random::Random"
462
- ];
463
- return (tx) => tx.moveCall({
464
- package: packageAddress,
465
- module: "limbo",
466
- function: "play",
467
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
468
- typeArguments: options.typeArguments
469
- });
470
- }
471
-
472
- // src/transactions/limbo.ts
473
- function buildLimboTransaction(options) {
474
- const scale = options.scale ?? LIMBO_MULTIPLIER_SCALE;
475
- const numerator = Math.round(options.targetMultiplier * scale);
476
- return buildSharedStandardGameBetTransaction({
477
- ...options,
478
- game: "limbo",
479
- buildRewardCoin: ({
480
- tx,
481
- config,
482
- coinType,
483
- stake,
484
- betCount,
485
- metadata,
486
- priceInfoObjectId,
487
- betCoin
488
- }) => play2({
489
- package: config.packageIds.limbo,
490
- typeArguments: [coinType],
491
- arguments: [
492
- config.packageIds.sweetHouse,
493
- stake,
494
- betCoin,
495
- betCount,
496
- BigInt(numerator),
497
- BigInt(scale),
498
- metadata.keys,
499
- metadata.values,
500
- priceInfoObjectId
501
- ]
502
- })(tx)
503
- });
504
- }
505
-
506
- // src/contracts/plinko/plinko.ts
507
- function play3(options) {
508
- const packageAddress = options.package ?? "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7";
509
- const argumentsTypes = [
510
- null,
511
- "u64",
512
- null,
513
- "u64",
514
- "u8",
515
- "vector<0x1::string::String>",
516
- "vector<vector<u8>>",
517
- null,
518
- "0x2::clock::Clock",
519
- "0x2::random::Random"
520
- ];
521
- return (tx) => tx.moveCall({
522
- package: packageAddress,
523
- module: "plinko",
524
- function: "play",
525
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
526
- typeArguments: options.typeArguments
527
- });
528
- }
529
-
530
- // src/transactions/plinko.ts
531
- function buildPlinkoTransaction(options) {
532
- const configId = toU8Number(options.configId, "configId");
533
- return buildSharedStandardGameBetTransaction({
534
- ...options,
535
- game: "plinko",
536
- buildRewardCoin: ({
537
- tx,
538
- config,
539
- coinType,
540
- stake,
541
- betCount,
542
- metadata,
543
- priceInfoObjectId,
544
- betCoin
545
- }) => play3({
546
- package: config.packageIds.plinko,
547
- typeArguments: [coinType],
548
- arguments: [
549
- config.packageIds.sweetHouse,
550
- stake,
551
- betCoin,
552
- betCount,
553
- configId,
554
- metadata.keys,
555
- metadata.values,
556
- priceInfoObjectId
557
- ]
558
- })(tx)
559
- });
560
- }
561
- var $moduleName = "0x0000000000000000000000000000000000000000000000000000000000000001::type_name";
562
- var TypeName = new MoveStruct({ name: `${$moduleName}::TypeName`, fields: {
563
- name: bcs.string()
564
- } });
565
-
566
- // src/contracts/pvp-coinflip/pvp_coinflip.ts
567
- var $moduleName2 = "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip";
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
- } });
600
- function createGame(options) {
601
- const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
602
- const argumentsTypes = [
603
- null,
604
- null,
605
- "bool",
606
- "bool",
607
- "vector<0x1::string::String>",
608
- "vector<vector<u8>>"
609
- ];
610
- return (tx) => tx.moveCall({
611
- package: packageAddress,
612
- module: "pvp_coinflip",
613
- function: "create_game",
614
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
615
- typeArguments: options.typeArguments
616
- });
617
- }
618
- function joinGame(options) {
619
- const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
620
- const argumentsTypes = [
621
- "0x2::object::ID",
622
- null,
623
- null,
624
- "vector<0x1::string::String>",
625
- "vector<vector<u8>>",
626
- null,
627
- "0x2::clock::Clock",
628
- "0x2::random::Random"
629
- ];
630
- return (tx) => tx.moveCall({
631
- package: packageAddress,
632
- module: "pvp_coinflip",
633
- function: "join_game",
634
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
635
- typeArguments: options.typeArguments
636
- });
637
- }
638
- function cancelGame(options) {
639
- const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
640
- const argumentsTypes = [
641
- "0x2::object::ID",
642
- null
643
- ];
644
- return (tx) => tx.moveCall({
645
- package: packageAddress,
646
- module: "pvp_coinflip",
647
- function: "cancel_game",
648
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
649
- typeArguments: options.typeArguments
650
- });
651
- }
652
-
653
- // src/transactions/pvp-coinflip.ts
654
- function buildPvPCoinflipTransaction(action, options) {
655
- const tx = createBaseGameTransaction({
656
- ...options,
657
- game: "pvp-coinflip"
658
- });
659
- const normalizedCoinType = normalizeStructTag(options.coinType);
660
- const encodedMetadata = encodeBetMetadata(options.metadata);
661
- switch (action) {
662
- case "create": {
663
- const createOptions = options;
664
- const stake = toBigIntAmount(createOptions.stake, "stake");
665
- const betCoin = tx.coin({
666
- type: normalizedCoinType,
667
- balance: stake,
668
- useGasCoin: createOptions.allowGasCoinShortcut
669
- });
670
- tx.add(
671
- createGame({
672
- package: createOptions.config.packageIds.pvpCoinflip,
673
- typeArguments: [normalizedCoinType],
674
- arguments: [
675
- createOptions.config.packageIds.sweetHouse,
676
- betCoin,
677
- createOptions.side === "tails",
678
- Boolean(createOptions.isPrivate),
679
- encodedMetadata.keys,
680
- encodedMetadata.values
681
- ]
682
- })
683
- );
684
- return tx;
685
- }
686
- case "join": {
687
- const joinOptions = options;
688
- const stake = toBigIntAmount(joinOptions.stake, "stake");
689
- const betCoin = tx.coin({
690
- type: normalizedCoinType,
691
- balance: stake,
692
- useGasCoin: joinOptions.allowGasCoinShortcut
693
- });
694
- tx.add(
695
- joinGame({
696
- package: joinOptions.config.packageIds.pvpCoinflip,
697
- typeArguments: [normalizedCoinType],
698
- arguments: [
699
- joinOptions.gameId,
700
- joinOptions.config.packageIds.sweetHouse,
701
- betCoin,
702
- encodedMetadata.keys,
703
- encodedMetadata.values,
704
- joinOptions.extraObjectId
705
- ]
706
- })
707
- );
708
- return tx;
709
- }
710
- case "cancel": {
711
- const cancelOptions = options;
712
- tx.add(
713
- cancelGame({
714
- package: cancelOptions.config.packageIds.pvpCoinflip,
715
- typeArguments: [normalizedCoinType],
716
- arguments: [
717
- cancelOptions.gameId,
718
- cancelOptions.config.packageIds.sweetHouse
719
- ]
720
- })
721
- );
722
- return tx;
723
- }
724
- default:
725
- throw new Error(`Unsupported PvP coinflip action: ${action}`);
726
- }
727
- }
728
-
729
- // src/contracts/range/range.ts
730
- function play4(options) {
731
- const packageAddress = options.package ?? "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416";
732
- const argumentsTypes = [
733
- null,
734
- "u64",
735
- null,
736
- "u64",
737
- "u64",
738
- "u64",
739
- "bool",
740
- "vector<0x1::string::String>",
741
- "vector<vector<u8>>",
742
- null,
743
- "0x2::clock::Clock",
744
- "0x2::random::Random"
745
- ];
746
- return (tx) => tx.moveCall({
747
- package: packageAddress,
748
- module: "range",
749
- function: "play",
750
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
751
- typeArguments: options.typeArguments
752
- });
753
- }
754
-
755
- // src/transactions/range.ts
756
- function buildRangeTransaction(options) {
757
- const scale = options.scale ?? RANGE_FIXED_POINT_SCALE;
758
- const leftPoint = Math.round(options.leftPoint * scale);
759
- const rightPoint = Math.round(options.rightPoint * scale);
760
- return buildSharedStandardGameBetTransaction({
761
- ...options,
762
- game: "range",
763
- buildRewardCoin: ({
764
- tx,
765
- config,
766
- coinType,
767
- stake,
768
- betCount,
769
- metadata,
770
- priceInfoObjectId,
771
- betCoin
772
- }) => play4({
773
- package: config.packageIds.range,
774
- typeArguments: [coinType],
775
- arguments: [
776
- config.packageIds.sweetHouse,
777
- stake,
778
- betCoin,
779
- betCount,
780
- BigInt(leftPoint),
781
- BigInt(rightPoint),
782
- Boolean(options.outOfRange),
783
- metadata.keys,
784
- metadata.values,
785
- priceInfoObjectId
786
- ]
787
- })(tx)
788
- });
789
- }
790
-
791
- // src/contracts/wheel/wheel.ts
792
- function play5(options) {
793
- const packageAddress = options.package ?? "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7";
794
- const argumentsTypes = [
795
- null,
796
- "u64",
797
- null,
798
- "u64",
799
- "u8",
800
- "vector<0x1::string::String>",
801
- "vector<vector<u8>>",
802
- null,
803
- "0x2::clock::Clock",
804
- "0x2::random::Random"
805
- ];
806
- return (tx) => tx.moveCall({
807
- package: packageAddress,
808
- module: "wheel",
809
- function: "play",
810
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
811
- typeArguments: options.typeArguments
812
- });
813
- }
814
-
815
- // src/transactions/wheel.ts
816
- function buildWheelTransaction(options) {
817
- const configId = toU8Number(options.configId, "configId");
818
- return buildSharedStandardGameBetTransaction({
819
- ...options,
820
- game: "wheel",
821
- buildRewardCoin: ({
822
- tx,
823
- config,
824
- coinType,
825
- stake,
826
- betCount,
827
- metadata,
828
- priceInfoObjectId,
829
- betCoin
830
- }) => play5({
831
- package: config.packageIds.wheel,
832
- typeArguments: [coinType],
833
- arguments: [
834
- config.packageIds.sweetHouse,
835
- stake,
836
- betCoin,
837
- betCount,
838
- configId,
839
- metadata.keys,
840
- metadata.values,
841
- priceInfoObjectId
842
- ]
843
- })(tx)
844
- });
845
- }
846
- var $moduleName3 = "0x0000000000000000000000000000000000000000000000000000000000000001::type_name";
847
- var TypeName2 = new MoveStruct({ name: `${$moduleName3}::TypeName`, fields: {
848
- name: bcs.string()
849
- } });
850
- var $moduleName4 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
851
- var I64 = new MoveStruct({ name: `${$moduleName4}::I64`, fields: {
852
- bits: bcs.u64()
853
- } });
854
-
855
- // src/contracts/core/float.ts
856
- var $moduleName5 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
857
- var Float = new MoveStruct({ name: `${$moduleName5}::Float`, fields: {
858
- is_negative: bcs.bool(),
859
- exp: I64,
860
- mant: bcs.u64()
861
- } });
862
- var $moduleName6 = "0x2::vec_map";
863
- function Entry(...typeParameters) {
864
- return new MoveStruct({ name: `${$moduleName6}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
865
- key: typeParameters[0],
866
- value: typeParameters[1]
867
- } });
868
- }
869
- function VecMap(...typeParameters) {
870
- return new MoveStruct({ name: `${$moduleName6}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
871
- contents: bcs.vector(Entry(typeParameters[0], typeParameters[1]))
872
- } });
873
- }
874
-
875
- // src/contracts/core/core.ts
876
- var $moduleName7 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core";
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
- } });
887
- function suigar({
888
- name = "suigar"
889
- } = {}) {
890
- return {
891
- name,
892
- register: (client) => {
893
- return new SuigarClient({ client });
894
- }
895
- };
896
- }
897
- var SuigarClient = class {
898
- #client;
899
- #config;
900
- constructor({ client }) {
901
- this.#client = client;
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;
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`.
926
- *
927
- * @param transaction Transaction to build and serialize.
928
- * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.
929
- * @returns Base64-encoded transaction bytes ready to send over the wire.
930
- */
931
- async serializeTransactionToBase64(transaction, options) {
932
- const bytes = await transaction.build({ ...options, client: this.#client });
933
- return toBase64(bytes);
934
- }
935
- /**
936
- * BCS struct constructors for decoding Suigar events emitted on-chain.
937
- */
938
- bcs = {
939
- /**
940
- * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
941
- */
942
- BetResultEvent,
943
- /**
944
- * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
945
- */
946
- PvPCoinflipGameCreated: GameCreatedEvent,
947
- /**
948
- * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
949
- */
950
- PvPCoinflipGameResolved: GameResolvedEvent,
951
- /**
952
- * Event emitted when a PvP Coinflip game is cancelled.
953
- */
954
- PvPCoinflipGameCancelled: GameCancelledEvent
955
- };
956
- /**
957
- * Transaction builders for Suigar games.
958
- */
959
- tx = {
960
- /**
961
- * Creates a standard game transaction for the provided game id.
962
- *
963
- * @param gameId Supported standard game identifier.
964
- * @param options Transaction builder options for the selected game.
965
- * @returns Prepared transaction for the selected game.
966
- */
967
- createBetTransaction: (gameId, options) => {
968
- switch (gameId) {
969
- case "coinflip":
970
- return buildCoinflipTransaction({
971
- ...options,
972
- config: this.#config
973
- });
974
- case "limbo":
975
- return buildLimboTransaction({
976
- ...options,
977
- config: this.#config
978
- });
979
- case "plinko":
980
- return buildPlinkoTransaction({
981
- ...options,
982
- config: this.#config
983
- });
984
- case "range":
985
- return buildRangeTransaction({
986
- ...options,
987
- config: this.#config
988
- });
989
- case "wheel":
990
- return buildWheelTransaction({
991
- ...options,
992
- config: this.#config
993
- });
994
- default:
995
- throw new Error(`Unsupported game: ${gameId}`);
996
- }
997
- },
998
- /**
999
- * Creates a PvP coinflip transaction for the requested action.
1000
- *
1001
- * @param action PvP coinflip action to perform.
1002
- * @param options Transaction builder options for the selected action.
1003
- * @returns Prepared PvP coinflip transaction.
1004
- */
1005
- createPvPCoinflipTransaction: (action, options) => {
1006
- return buildPvPCoinflipTransaction(action, {
1007
- ...options,
1008
- config: this.#config
1009
- });
1010
- }
1011
- };
1012
- };
1013
-
1014
- export { suigar };