@suigar/sdk 2.0.0-beta.14 → 2.0.0-beta.15

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 (160) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +22 -8
  3. package/dist/client.d.mts +258 -0
  4. package/dist/client.d.mts.map +1 -0
  5. package/dist/client.mjs +291 -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 +55 -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 +14 -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 +34 -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 +33 -0
  66. package/dist/contracts/utils/index.d.mts.map +1 -0
  67. package/dist/contracts/utils/index.mjs +119 -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 +73 -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 +201 -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 +16 -17
  144. package/dist/chunk-7N55D2TV.js +0 -343
  145. package/dist/games-Da2uZvVJ.d.cts +0 -98
  146. package/dist/games-Da2uZvVJ.d.ts +0 -98
  147. package/dist/games.cjs +0 -2
  148. package/dist/games.d.cts +0 -2
  149. package/dist/games.d.ts +0 -2
  150. package/dist/games.js +0 -1
  151. package/dist/index-3P_LBbDM.d.cts +0 -25
  152. package/dist/index-3P_LBbDM.d.ts +0 -25
  153. package/dist/index.cjs +0 -1692
  154. package/dist/index.d.cts +0 -467
  155. package/dist/index.d.ts +0 -467
  156. package/dist/index.js +0 -1470
  157. package/dist/utils.cjs +0 -243
  158. package/dist/utils.d.cts +0 -180
  159. package/dist/utils.d.ts +0 -180
  160. package/dist/utils.js +0 -1
package/dist/utils.cjs DELETED
@@ -1,243 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@mysten/sui/utils');
4
- var bcs = require('@mysten/sui/bcs');
5
- require('@mysten/sui/transactions');
6
-
7
- // src/utils/constants.ts
8
- var DEFAULT_GAS_BUDGET_MIST = utils.parseToMist("0.05");
9
- var DEFAULT_RANGE_SCALE = 1e6;
10
- var RANGE_POINT_LIMIT = DEFAULT_RANGE_SCALE * 100;
11
- var DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
12
-
13
- // src/utils/numeric.ts
14
- function assertFiniteNumber(value, errorMessage) {
15
- if (typeof value !== "number" || !Number.isFinite(value)) {
16
- throw new TypeError(`${errorMessage}: ${String(value)}`);
17
- }
18
- }
19
- function toBigInt(value) {
20
- let result;
21
- try {
22
- if (typeof value === "bigint" || typeof value === "string" || typeof value === "boolean") {
23
- result = BigInt(value);
24
- } else {
25
- assertFiniteNumber(
26
- value,
27
- "Value must be a bigint, number, integer string, or boolean"
28
- );
29
- result = BigInt(Math.trunc(value));
30
- }
31
- } catch {
32
- throw new TypeError(
33
- `Value must be a bigint, number, integer string, or boolean: ${value}`
34
- );
35
- }
36
- if (result < 0n) {
37
- throw new RangeError(`Value must be non-negative: ${value}`);
38
- }
39
- return result;
40
- }
41
- function toBoundedInt(value, max, typeName) {
42
- const num = typeof value === "string" && value.trim() === "" ? NaN : Number(value);
43
- assertFiniteNumber(num, "Value must be a finite number or integer string");
44
- if (typeof value === "boolean" || value == null || !Number.isInteger(num) || num < 0 || num > max) {
45
- throw new RangeError(
46
- `Value must be a ${typeName} integer (0-${max}): ${value}`
47
- );
48
- }
49
- return num;
50
- }
51
- function toU8(value) {
52
- return toBoundedInt(value, 255, "u8");
53
- }
54
- function toU16(value) {
55
- return toBoundedInt(value, 65535, "u16");
56
- }
57
- utils.normalizeSuiAddress("0x1");
58
- utils.normalizeSuiAddress("0x2");
59
- var MoveStruct = class extends bcs.BcsStruct {
60
- async get({
61
- objectId,
62
- ...options
63
- }) {
64
- const [res] = await this.getMany({
65
- ...options,
66
- objectIds: [objectId]
67
- });
68
- if (!res) {
69
- throw new Error(`No object found for id ${objectId}`);
70
- }
71
- return res;
72
- }
73
- async getMany({
74
- client,
75
- ...options
76
- }) {
77
- const response = await client.core.getObjects({
78
- ...options,
79
- include: {
80
- ...options.include,
81
- content: true
82
- }
83
- });
84
- return response.objects.map((obj) => {
85
- if (obj instanceof Error) {
86
- throw obj;
87
- }
88
- return {
89
- ...obj,
90
- json: this.parse(obj.content)
91
- };
92
- });
93
- }
94
- };
95
- var $moduleName = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64";
96
- var I64 = new MoveStruct({
97
- name: `${$moduleName}::I64`,
98
- fields: {
99
- bits: bcs.bcs.u64()
100
- }
101
- });
102
-
103
- // src/contracts/core/float.ts
104
- var $moduleName2 = "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float";
105
- var Float = new MoveStruct({
106
- name: `${$moduleName2}::Float`,
107
- fields: {
108
- is_negative: bcs.bcs.bool(),
109
- exp: I64,
110
- mant: bcs.bcs.u64()
111
- }
112
- });
113
-
114
- // src/types/game-details.type.ts
115
- var COINFLIP_GAME_DETAILS_SCHEMA = {
116
- player_bet: "string",
117
- coin_outcome: "string"
118
- };
119
- var PVP_COINFLIP_GAME_DETAILS_SCHEMA = {
120
- pvp_result: "string"
121
- };
122
- var LIMBO_GAME_DETAILS_SCHEMA = {
123
- payout_amount: "u64",
124
- win: "bool",
125
- roll_multiplier: "float",
126
- payout_multiplier: "float",
127
- target_multiplier: "float",
128
- actual_rtp: "float"
129
- };
130
- var RANGE_GAME_DETAILS_SCHEMA = {
131
- roll_value: "u64",
132
- win: "bool",
133
- payout_amount: "u64",
134
- payout_multiplier: "float",
135
- left_point: "u64",
136
- right_point: "u64",
137
- zone_size: "u64",
138
- winning_zone_size: "u64",
139
- is_out_range: "bool",
140
- bet_threshold: "u64",
141
- roll_under: "bool",
142
- range_mode: "u8",
143
- win_probability: "float",
144
- win_multiplier: "float",
145
- actual_rtp: "float"
146
- };
147
- var PLINKO_GAME_DETAILS_SCHEMA = {
148
- slot_index: "u8",
149
- multiplier: "float",
150
- payout_amount: "u64",
151
- plinko_config: "u8"
152
- };
153
- var WHEEL_GAME_DETAILS_SCHEMA = {
154
- case_index: "u8",
155
- multiplier: "float",
156
- payout_amount: "u64",
157
- wheel_config: "u8",
158
- spin_value: "u64"
159
- };
160
- var GAME_DETAILS_SCHEMA = {
161
- ...COINFLIP_GAME_DETAILS_SCHEMA,
162
- ...PVP_COINFLIP_GAME_DETAILS_SCHEMA,
163
- ...LIMBO_GAME_DETAILS_SCHEMA,
164
- ...RANGE_GAME_DETAILS_SCHEMA,
165
- ...PLINKO_GAME_DETAILS_SCHEMA,
166
- ...WHEEL_GAME_DETAILS_SCHEMA
167
- };
168
-
169
- // src/utils/parser.ts
170
- var textDecoder = new TextDecoder();
171
- var GAME_DETAIL_BCS = {
172
- u8: bcs.bcs.U8,
173
- u64: bcs.bcs.U64,
174
- bool: bcs.bcs.Bool,
175
- float: Float,
176
- string: bcs.bcs.String
177
- };
178
- function fromMoveI64(i64) {
179
- try {
180
- return Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));
181
- } catch {
182
- return 0;
183
- }
184
- }
185
- function fromMoveFloat(float) {
186
- const mantissa = BigInt(float.mant ?? 0);
187
- if (mantissa === 0n) {
188
- return 0;
189
- }
190
- const exponent = fromMoveI64(float.exp) - 52;
191
- const magnitude = Number(mantissa) * 2 ** exponent;
192
- return float.is_negative ? -magnitude : magnitude;
193
- }
194
- function parseCoinType(type) {
195
- const coinType = utils.parseStructTag(type).typeParams[0];
196
- if (!coinType) {
197
- throw new TypeError(`Unable to parse coin type from ${type}`);
198
- }
199
- return utils.normalizeStructTag(coinType);
200
- }
201
- function normalizeGameDetailValue(valueType, parsed) {
202
- if (valueType === "float") {
203
- return fromMoveFloat(parsed);
204
- }
205
- if (valueType === "u64") {
206
- return Number(parsed);
207
- }
208
- return parsed;
209
- }
210
- function parseStringGameDetail(value) {
211
- const bytes = Uint8Array.from(value);
212
- try {
213
- return bcs.bcs.String.parse(bytes);
214
- } catch {
215
- return textDecoder.decode(bytes);
216
- }
217
- }
218
- function parseGameDetail(valueType, value) {
219
- if (valueType === "string") {
220
- return parseStringGameDetail(value);
221
- }
222
- const parsed = GAME_DETAIL_BCS[valueType].parse(Uint8Array.from(value));
223
- return normalizeGameDetailValue(valueType, parsed);
224
- }
225
- function parseGameDetails(gameDetails) {
226
- return gameDetails.contents.reduce((details, entry) => {
227
- const valueType = GAME_DETAILS_SCHEMA[entry.key] ?? "string";
228
- details[entry.key] = parseGameDetail(valueType, entry.value);
229
- return details;
230
- }, {});
231
- }
232
-
233
- exports.DEFAULT_GAS_BUDGET_MIST = DEFAULT_GAS_BUDGET_MIST;
234
- exports.DEFAULT_LIMBO_MULTIPLIER_SCALE = DEFAULT_LIMBO_MULTIPLIER_SCALE;
235
- exports.DEFAULT_RANGE_SCALE = DEFAULT_RANGE_SCALE;
236
- exports.RANGE_POINT_LIMIT = RANGE_POINT_LIMIT;
237
- exports.fromMoveFloat = fromMoveFloat;
238
- exports.fromMoveI64 = fromMoveI64;
239
- exports.parseCoinType = parseCoinType;
240
- exports.parseGameDetails = parseGameDetails;
241
- exports.toBigInt = toBigInt;
242
- exports.toU16 = toU16;
243
- exports.toU8 = toU8;
package/dist/utils.d.cts DELETED
@@ -1,180 +0,0 @@
1
- import * as _mysten_bcs from '@mysten/bcs';
2
- import { M as MoveStruct } from './index-3P_LBbDM.cjs';
3
- import '@mysten/sui/bcs';
4
- import '@mysten/sui/client';
5
-
6
- declare const BetResultEvent: MoveStruct<{
7
- player: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
- coin_type: MoveStruct<{
9
- name: _mysten_bcs.BcsType<string, string, "string">;
10
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
11
- stake_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
12
- unsafe_oracle_usd_coin_price: MoveStruct<{
13
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
14
- exp: MoveStruct<{
15
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
16
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
17
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
18
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
19
- adjusted_oracle_usd_coin_price: MoveStruct<{
20
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
21
- exp: MoveStruct<{
22
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
23
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
24
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
25
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
26
- outcome_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
27
- game_details: MoveStruct<{
28
- contents: _mysten_bcs.BcsType<{
29
- key: string;
30
- value: number[];
31
- }[], Iterable<{
32
- key: string;
33
- value: Iterable<number> & {
34
- length: number;
35
- };
36
- }> & {
37
- length: number;
38
- }, string>;
39
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
40
- metadata: MoveStruct<{
41
- contents: _mysten_bcs.BcsType<{
42
- key: string;
43
- value: number[];
44
- }[], Iterable<{
45
- key: string;
46
- value: Iterable<number> & {
47
- length: number;
48
- };
49
- }> & {
50
- length: number;
51
- }, string>;
52
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
53
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>">;
54
-
55
- type BetResultGameDetails = ReturnType<(typeof BetResultEvent)['parse']>['game_details'];
56
- type ParsedGameDetailValue = string | number | boolean;
57
- type ParsedGameDetails = Record<string, ParsedGameDetailValue>;
58
-
59
- declare const DEFAULT_GAS_BUDGET_MIST: bigint;
60
- declare const DEFAULT_RANGE_SCALE = 1000000;
61
- declare const RANGE_POINT_LIMIT: number;
62
- declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
-
64
- /**
65
- * Normalizes a value into a non-negative `bigint`.
66
- *
67
- * Accepted inputs:
68
- * - `bigint`
69
- * - finite `number`
70
- * - base-10 integer `string`
71
- * - `boolean`
72
- *
73
- * Number inputs are truncated toward zero before conversion, so `5.9` becomes
74
- * `5n`. String and boolean inputs are parsed through the native
75
- * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,
76
- * and only integer strings are accepted.
77
- *
78
- * @param value Value to normalize.
79
- * @returns A non-negative `bigint`.
80
- * @throws When `value` is not a bigint, finite number, integer string, or
81
- * boolean.
82
- * @throws When the normalized value is negative.
83
- */
84
- declare function toBigInt(value: unknown): bigint;
85
- /**
86
- * Validates that a value can be safely used as a Move `u8` in the `0..255`
87
- * range.
88
- *
89
- * Accepted inputs:
90
- * - finite `number`
91
- * - base-10 integer `string`
92
- *
93
- * String inputs are accepted for parsed values such as `'1'`, but only when
94
- * they are plain non-negative integer strings. This helper does not accept
95
- * booleans and does not truncate fractional values.
96
- *
97
- * @param value Value to validate.
98
- * @returns The validated `u8` value as a JavaScript `number`.
99
- * @throws When `value` is not a finite number or integer string.
100
- * @throws When `value` is not an integer between `0` and `255`.
101
- */
102
- declare function toU8(value: unknown): number;
103
- /**
104
- * Validates that a value can be safely used as a Move `u16` in the
105
- * `0..65535` range.
106
- *
107
- * Accepted inputs:
108
- * - finite `number`
109
- * - base-10 integer `string`
110
- *
111
- * String inputs are accepted for parsed values such as `'1'`, but only when
112
- * they are plain non-negative integer strings. This helper does not accept
113
- * booleans and does not truncate fractional values.
114
- *
115
- * @param value Value to validate.
116
- * @returns The validated `u16` value as a JavaScript `number`.
117
- * @throws When `value` is not a finite number or integer string.
118
- * @throws When `value` is not an integer between `0` and `65535`.
119
- */
120
- declare function toU16(value: unknown): number;
121
-
122
- declare const Float: MoveStruct<{
123
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
124
- exp: MoveStruct<{
125
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
126
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
127
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
128
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
129
-
130
- type MoveFloat = ReturnType<(typeof Float)['parse']>;
131
- /**
132
- * Converts a generated Move `i64` wrapper into a JavaScript number.
133
- *
134
- * The generated bindings expose signed 64-bit integers through a `{ bits }`
135
- * field that stores the raw two's-complement bit pattern. This helper
136
- * reinterprets those bits as a signed `i64` and returns a plain JS number.
137
- * Invalid or missing input falls back to `0`.
138
- *
139
- * @param i64 Generated Move `i64` value, typically used for float exponents.
140
- * @returns The signed 64-bit value as a JavaScript number.
141
- */
142
- declare function fromMoveI64(i64: MoveFloat['exp']): number;
143
- /**
144
- * Converts a generated Move `Float` struct into a JavaScript number.
145
- *
146
- * Suigar float values are represented as a sign flag, an unsigned mantissa,
147
- * and a Move `i64` exponent. This helper rebuilds the numeric value using the
148
- * same normalization expected by the on-chain format and applies the sign at
149
- * the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.
150
- *
151
- * @param float Generated Move float value with `mant`, `exp`, and `is_negative`.
152
- * @returns The decoded floating-point value as a JavaScript number.
153
- */
154
- declare function fromMoveFloat(float: MoveFloat): number;
155
- /**
156
- * Extracts and normalizes the first generic coin type from a Move object type.
157
- *
158
- * PvP game object types encode the wager coin as their first type parameter,
159
- * for example `Game<0x2::sui::SUI>`. This helper converts that generic type
160
- * argument into the SDK's canonical struct tag string.
161
- *
162
- * @param type Fully qualified Move object type with the coin type as its first generic argument.
163
- * @returns Normalized coin type struct tag.
164
- */
165
- declare function parseCoinType(type: string): string;
166
- /**
167
- * Decodes `BetResultEvent.game_details` into plain application values.
168
- *
169
- * Suigar stores game detail entries as `VecMap<string, vector<u8>>`, so raw BCS
170
- * decoding leaves each value as bytes. This helper looks up the known schema for
171
- * each key, parses the bytes into the expected runtime type, and preserves the
172
- * original on-chain keys in the returned object. Unknown keys fall back to
173
- * string decoding so newer detail fields remain readable by default.
174
- *
175
- * @param gameDetails Raw `game_details` map from a decoded bet result event.
176
- * @returns A plain object with the same keys and decoded string, number, or boolean values.
177
- */
178
- declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
179
-
180
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 };
package/dist/utils.d.ts DELETED
@@ -1,180 +0,0 @@
1
- import * as _mysten_bcs from '@mysten/bcs';
2
- import { M as MoveStruct } from './index-3P_LBbDM.js';
3
- import '@mysten/sui/bcs';
4
- import '@mysten/sui/client';
5
-
6
- declare const BetResultEvent: MoveStruct<{
7
- player: _mysten_bcs.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
- coin_type: MoveStruct<{
9
- name: _mysten_bcs.BcsType<string, string, "string">;
10
- }, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
11
- stake_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
12
- unsafe_oracle_usd_coin_price: MoveStruct<{
13
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
14
- exp: MoveStruct<{
15
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
16
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
17
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
18
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
19
- adjusted_oracle_usd_coin_price: MoveStruct<{
20
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
21
- exp: MoveStruct<{
22
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
23
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
24
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
25
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
26
- outcome_amount: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
27
- game_details: MoveStruct<{
28
- contents: _mysten_bcs.BcsType<{
29
- key: string;
30
- value: number[];
31
- }[], Iterable<{
32
- key: string;
33
- value: Iterable<number> & {
34
- length: number;
35
- };
36
- }> & {
37
- length: number;
38
- }, string>;
39
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
40
- metadata: MoveStruct<{
41
- contents: _mysten_bcs.BcsType<{
42
- key: string;
43
- value: number[];
44
- }[], Iterable<{
45
- key: string;
46
- value: Iterable<number> & {
47
- length: number;
48
- };
49
- }> & {
50
- length: number;
51
- }, string>;
52
- }, "0x2::vec_map::VecMap<string, vector<u8>>">;
53
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::core::BetResultEvent<phantom T0>">;
54
-
55
- type BetResultGameDetails = ReturnType<(typeof BetResultEvent)['parse']>['game_details'];
56
- type ParsedGameDetailValue = string | number | boolean;
57
- type ParsedGameDetails = Record<string, ParsedGameDetailValue>;
58
-
59
- declare const DEFAULT_GAS_BUDGET_MIST: bigint;
60
- declare const DEFAULT_RANGE_SCALE = 1000000;
61
- declare const RANGE_POINT_LIMIT: number;
62
- declare const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;
63
-
64
- /**
65
- * Normalizes a value into a non-negative `bigint`.
66
- *
67
- * Accepted inputs:
68
- * - `bigint`
69
- * - finite `number`
70
- * - base-10 integer `string`
71
- * - `boolean`
72
- *
73
- * Number inputs are truncated toward zero before conversion, so `5.9` becomes
74
- * `5n`. String and boolean inputs are parsed through the native
75
- * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,
76
- * and only integer strings are accepted.
77
- *
78
- * @param value Value to normalize.
79
- * @returns A non-negative `bigint`.
80
- * @throws When `value` is not a bigint, finite number, integer string, or
81
- * boolean.
82
- * @throws When the normalized value is negative.
83
- */
84
- declare function toBigInt(value: unknown): bigint;
85
- /**
86
- * Validates that a value can be safely used as a Move `u8` in the `0..255`
87
- * range.
88
- *
89
- * Accepted inputs:
90
- * - finite `number`
91
- * - base-10 integer `string`
92
- *
93
- * String inputs are accepted for parsed values such as `'1'`, but only when
94
- * they are plain non-negative integer strings. This helper does not accept
95
- * booleans and does not truncate fractional values.
96
- *
97
- * @param value Value to validate.
98
- * @returns The validated `u8` value as a JavaScript `number`.
99
- * @throws When `value` is not a finite number or integer string.
100
- * @throws When `value` is not an integer between `0` and `255`.
101
- */
102
- declare function toU8(value: unknown): number;
103
- /**
104
- * Validates that a value can be safely used as a Move `u16` in the
105
- * `0..65535` range.
106
- *
107
- * Accepted inputs:
108
- * - finite `number`
109
- * - base-10 integer `string`
110
- *
111
- * String inputs are accepted for parsed values such as `'1'`, but only when
112
- * they are plain non-negative integer strings. This helper does not accept
113
- * booleans and does not truncate fractional values.
114
- *
115
- * @param value Value to validate.
116
- * @returns The validated `u16` value as a JavaScript `number`.
117
- * @throws When `value` is not a finite number or integer string.
118
- * @throws When `value` is not an integer between `0` and `65535`.
119
- */
120
- declare function toU16(value: unknown): number;
121
-
122
- declare const Float: MoveStruct<{
123
- is_negative: _mysten_bcs.BcsType<boolean, boolean, "bool">;
124
- exp: MoveStruct<{
125
- bits: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
126
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
127
- mant: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
128
- }, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
129
-
130
- type MoveFloat = ReturnType<(typeof Float)['parse']>;
131
- /**
132
- * Converts a generated Move `i64` wrapper into a JavaScript number.
133
- *
134
- * The generated bindings expose signed 64-bit integers through a `{ bits }`
135
- * field that stores the raw two's-complement bit pattern. This helper
136
- * reinterprets those bits as a signed `i64` and returns a plain JS number.
137
- * Invalid or missing input falls back to `0`.
138
- *
139
- * @param i64 Generated Move `i64` value, typically used for float exponents.
140
- * @returns The signed 64-bit value as a JavaScript number.
141
- */
142
- declare function fromMoveI64(i64: MoveFloat['exp']): number;
143
- /**
144
- * Converts a generated Move `Float` struct into a JavaScript number.
145
- *
146
- * Suigar float values are represented as a sign flag, an unsigned mantissa,
147
- * and a Move `i64` exponent. This helper rebuilds the numeric value using the
148
- * same normalization expected by the on-chain format and applies the sign at
149
- * the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.
150
- *
151
- * @param float Generated Move float value with `mant`, `exp`, and `is_negative`.
152
- * @returns The decoded floating-point value as a JavaScript number.
153
- */
154
- declare function fromMoveFloat(float: MoveFloat): number;
155
- /**
156
- * Extracts and normalizes the first generic coin type from a Move object type.
157
- *
158
- * PvP game object types encode the wager coin as their first type parameter,
159
- * for example `Game<0x2::sui::SUI>`. This helper converts that generic type
160
- * argument into the SDK's canonical struct tag string.
161
- *
162
- * @param type Fully qualified Move object type with the coin type as its first generic argument.
163
- * @returns Normalized coin type struct tag.
164
- */
165
- declare function parseCoinType(type: string): string;
166
- /**
167
- * Decodes `BetResultEvent.game_details` into plain application values.
168
- *
169
- * Suigar stores game detail entries as `VecMap<string, vector<u8>>`, so raw BCS
170
- * decoding leaves each value as bytes. This helper looks up the known schema for
171
- * each key, parses the bytes into the expected runtime type, and preserves the
172
- * original on-chain keys in the returned object. Unknown keys fall back to
173
- * string decoding so newer detail fields remain readable by default.
174
- *
175
- * @param gameDetails Raw `game_details` map from a decoded bet result event.
176
- * @returns A plain object with the same keys and decoded string, number, or boolean values.
177
- */
178
- declare function parseGameDetails(gameDetails: BetResultGameDetails): ParsedGameDetails;
179
-
180
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 };
package/dist/utils.js DELETED
@@ -1 +0,0 @@
1
- export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseCoinType, parseGameDetails, toBigInt, toU16, toU8 } from './chunk-7N55D2TV.js';