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