@suigar/sdk 2.0.0-beta.18 → 2.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/client.d.mts +48 -49
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs.map +1 -1
- package/dist/configs/package.mainnet.mjs.map +1 -1
- package/dist/configs/package.mjs.map +1 -1
- package/dist/configs/package.testnet.mjs.map +1 -1
- package/dist/configs/registry.mainnet.mjs.map +1 -1
- package/dist/configs/registry.mjs.map +1 -1
- package/dist/configs/registry.testnet.mjs.map +1 -1
- package/dist/contracts/coinflip/coinflip.mjs.map +1 -1
- package/dist/contracts/core/core.d.mts +12 -13
- package/dist/contracts/core/core.d.mts.map +1 -1
- package/dist/contracts/core/core.mjs.map +1 -1
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -1
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/contracts/core/float.d.mts +3 -4
- package/dist/contracts/core/float.d.mts.map +1 -1
- package/dist/contracts/core/float.mjs.map +1 -1
- package/dist/contracts/core/i64.mjs.map +1 -1
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -1
- package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -1
- package/dist/contracts/limbo/limbo.mjs.map +1 -1
- package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -1
- package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -1
- package/dist/contracts/plinko/plinko.mjs.map +1 -1
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -1
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -1
- package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts +10 -11
- package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts.map +1 -1
- package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs.map +1 -1
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -1
- package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -1
- package/dist/contracts/range/range.mjs.map +1 -1
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -1
- package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -1
- package/dist/contracts/wheel/wheel.mjs.map +1 -1
- package/dist/games.d.mts +1 -1
- package/dist/helpers/config.mjs.map +1 -1
- package/dist/helpers/game-settings.mjs.map +1 -1
- package/dist/helpers/metadata.mjs.map +1 -1
- package/dist/transactions/coinflip.mjs.map +1 -1
- package/dist/transactions/limbo.mjs.map +1 -1
- package/dist/transactions/plinko.mjs.map +1 -1
- package/dist/transactions/pvp-coinflip.mjs.map +1 -1
- package/dist/transactions/range.mjs.map +1 -1
- package/dist/transactions/shared.mjs.map +1 -1
- package/dist/transactions/wheel.mjs.map +1 -1
- package/dist/ttl-cache.mjs.map +1 -1
- package/dist/types/bet-metadata.type.d.mts.map +1 -1
- package/dist/types/build-game-transaction-options.type.d.mts.map +1 -1
- package/dist/types/game-details.type.d.mts +7 -8
- package/dist/types/game-details.type.d.mts.map +1 -1
- package/dist/types/game-details.type.mjs.map +1 -1
- package/dist/types/game-settings.type.d.mts +52 -53
- package/dist/types/game-settings.type.d.mts.map +1 -1
- package/dist/types/game-settings.type.mjs.map +1 -1
- package/dist/types/game.type.d.mts.map +1 -1
- package/dist/types/game.type.mjs.map +1 -1
- package/dist/types/move-float.type.d.mts.map +1 -1
- package/dist/types/network.type.mjs.map +1 -1
- package/dist/types/suigar-config.type.d.mts.map +1 -1
- package/dist/types/transaction-options.type.d.mts.map +1 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/numeric.d.mts.map +1 -1
- package/dist/utils/numeric.mjs.map +1 -1
- package/dist/utils/parser.d.mts.map +1 -1
- package/dist/utils/parser.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
import { Game } from "./game.type.mjs";
|
|
2
2
|
import { MoveStruct } from "../contracts/utils/index.mjs";
|
|
3
3
|
import { SuiClientTypes } from "@mysten/sui/client";
|
|
4
|
-
import * as _$_mysten_bcs0 from "@mysten/bcs";
|
|
5
4
|
|
|
6
5
|
//#region src/types/game-settings.type.d.ts
|
|
7
6
|
declare const GAME_SETTINGS: {
|
|
8
7
|
readonly coinflip: {
|
|
9
8
|
readonly settingsKey: MoveStruct<{
|
|
10
|
-
dummy_field:
|
|
9
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
11
10
|
}, "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea::coinflip::CoinFlipSettingsKey">;
|
|
12
11
|
readonly parameters: MoveStruct<{
|
|
13
|
-
id:
|
|
14
|
-
house_edge:
|
|
15
|
-
min_stake:
|
|
16
|
-
max_stake:
|
|
12
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
13
|
+
house_edge: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
14
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
15
|
+
max_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
17
16
|
}, "0xb35c5f286c443752afc8ccb40125a578a4f32df35617170ccfa17fe180ab80ea::coinflip::Parameters<phantom T0>">;
|
|
18
17
|
};
|
|
19
18
|
readonly limbo: {
|
|
20
19
|
readonly settingsKey: MoveStruct<{
|
|
21
|
-
dummy_field:
|
|
20
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
22
21
|
}, "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4::limbo::LimboSettingsKey">;
|
|
23
22
|
readonly parameters: MoveStruct<{
|
|
24
|
-
id:
|
|
25
|
-
min_stake:
|
|
26
|
-
max_stake:
|
|
27
|
-
max_payout:
|
|
23
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
24
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
25
|
+
max_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
26
|
+
max_payout: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
28
27
|
min_target_multiplier: MoveStruct<{
|
|
29
|
-
is_negative:
|
|
28
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
30
29
|
exp: MoveStruct<{
|
|
31
|
-
bits:
|
|
30
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
32
31
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
33
|
-
mant:
|
|
32
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
34
33
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
35
34
|
max_target_multiplier: MoveStruct<{
|
|
36
|
-
is_negative:
|
|
35
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
37
36
|
exp: MoveStruct<{
|
|
38
|
-
bits:
|
|
37
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
39
38
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
40
|
-
mant:
|
|
39
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
41
40
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
42
|
-
max_number_of_games:
|
|
41
|
+
max_number_of_games: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
43
42
|
min_rtp: MoveStruct<{
|
|
44
|
-
is_negative:
|
|
43
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
45
44
|
exp: MoveStruct<{
|
|
46
|
-
bits:
|
|
45
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
47
46
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
48
|
-
mant:
|
|
47
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
49
48
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
50
49
|
max_rtp: MoveStruct<{
|
|
51
|
-
is_negative:
|
|
50
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
52
51
|
exp: MoveStruct<{
|
|
53
|
-
bits:
|
|
52
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
54
53
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
55
|
-
mant:
|
|
54
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
56
55
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
57
56
|
}, "0x96c7841b9b32c59a219760fd656f1c3aceb53cc74a68ec9844a3a696374309f4::limbo::Parameters<phantom T0>">;
|
|
58
57
|
};
|
|
59
58
|
readonly plinko: {
|
|
60
59
|
readonly settingsKey: MoveStruct<{
|
|
61
|
-
dummy_field:
|
|
60
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
62
61
|
}, "0xd3dd2200883af10811724f0bed97591ad155a02efd6332d471ff8b346030dfb7::plinko::PlinkoSettingsKey">;
|
|
63
62
|
readonly parameters: MoveStruct<{
|
|
64
|
-
id:
|
|
65
|
-
min_stake:
|
|
66
|
-
max_stake:
|
|
67
|
-
max_number_of_balls:
|
|
63
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
64
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
65
|
+
max_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
66
|
+
max_number_of_balls: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
68
67
|
configs: MoveStruct<{
|
|
69
|
-
contents:
|
|
68
|
+
contents: import("@mysten/bcs").BcsType<{
|
|
70
69
|
key: number;
|
|
71
70
|
value: {
|
|
72
71
|
num_rows: number;
|
|
@@ -106,52 +105,52 @@ declare const GAME_SETTINGS: {
|
|
|
106
105
|
};
|
|
107
106
|
readonly 'pvp-coinflip': {
|
|
108
107
|
readonly settingsKey: MoveStruct<{
|
|
109
|
-
dummy_field:
|
|
108
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
110
109
|
}, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::PvpCoinflipSettingsKey">;
|
|
111
110
|
readonly parameters: MoveStruct<{
|
|
112
|
-
id:
|
|
113
|
-
house_edge_bps:
|
|
114
|
-
min_stake:
|
|
111
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
112
|
+
house_edge_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
113
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
115
114
|
}, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::Parameters<phantom T0>">;
|
|
116
115
|
};
|
|
117
116
|
readonly range: {
|
|
118
117
|
readonly settingsKey: MoveStruct<{
|
|
119
|
-
dummy_field:
|
|
118
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
120
119
|
}, "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416::range::RangeSettingsKey">;
|
|
121
120
|
readonly parameters: MoveStruct<{
|
|
122
|
-
id:
|
|
123
|
-
min_stake:
|
|
124
|
-
max_stake:
|
|
125
|
-
min_zone_size:
|
|
126
|
-
max_zone_size:
|
|
127
|
-
max_number_of_games:
|
|
121
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
122
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
123
|
+
max_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
124
|
+
min_zone_size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
125
|
+
max_zone_size: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
126
|
+
max_number_of_games: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
128
127
|
min_rtp: MoveStruct<{
|
|
129
|
-
is_negative:
|
|
128
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
130
129
|
exp: MoveStruct<{
|
|
131
|
-
bits:
|
|
130
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
132
131
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
133
|
-
mant:
|
|
132
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
134
133
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
135
134
|
max_rtp: MoveStruct<{
|
|
136
|
-
is_negative:
|
|
135
|
+
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
137
136
|
exp: MoveStruct<{
|
|
138
|
-
bits:
|
|
137
|
+
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
139
138
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
140
|
-
mant:
|
|
139
|
+
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
141
140
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
142
141
|
}, "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416::range::Parameters<phantom T0>">;
|
|
143
142
|
};
|
|
144
143
|
readonly wheel: {
|
|
145
144
|
readonly settingsKey: MoveStruct<{
|
|
146
|
-
dummy_field:
|
|
145
|
+
dummy_field: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
147
146
|
}, "0x0997852ded7e13301c42317004bc49704a893aa82997c5706cebee59053a31b7::wheel::WheelSettingsKey">;
|
|
148
147
|
readonly parameters: MoveStruct<{
|
|
149
|
-
id:
|
|
150
|
-
min_stake:
|
|
151
|
-
max_stake:
|
|
152
|
-
max_number_of_spins:
|
|
148
|
+
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
149
|
+
min_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
150
|
+
max_stake: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
151
|
+
max_number_of_spins: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
153
152
|
configs: MoveStruct<{
|
|
154
|
-
contents:
|
|
153
|
+
contents: import("@mysten/bcs").BcsType<{
|
|
155
154
|
key: number;
|
|
156
155
|
value: {
|
|
157
156
|
num_cases: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-settings.type.d.mts","names":[],"sources":["../../src/types/game-settings.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"game-settings.type.d.mts","names":[],"sources":["../../src/types/game-settings.type.ts"],"mappings":";;;;;cA8Ba,aAAA;EAAA;0BAyBH,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEL,iBAAA,eACM,IAAA,GAAO,UAAA,SACR,aAAA,EAAe,KAAA;AAAA,KAIb,cAAA,eAA6B,IAAA,IAAQ,iBAAA,CAAkB,KAAA;AAAA,KAEvD,wBAAA,GACX,cAAA,CAAe,uBAAuB;EACrC,QAAA;EACA,WAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-settings.type.mjs","names":["CoinflipParameters","LimboParameters","PlinkoParameters","PvPCoinflipParameters","RangeParameters","WheelParameters"],"sources":["../../src/types/game-settings.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuiClientTypes } from '@mysten/sui/client';\nimport {\n\tParameters as CoinflipParameters,\n\tCoinFlipSettingsKey,\n} from '../contracts/coinflip/coinflip';\nimport {\n\tParameters as LimboParameters,\n\tLimboSettingsKey,\n} from '../contracts/limbo/limbo';\nimport {\n\tParameters as PlinkoParameters,\n\tPlinkoSettingsKey,\n} from '../contracts/plinko/plinko';\nimport {\n\tParameters as PvPCoinflipParameters,\n\tPvpCoinflipSettingsKey,\n} from '../contracts/pvp-coinflip/pvp_coinflip';\nimport {\n\tParameters as RangeParameters,\n\tRangeSettingsKey,\n} from '../contracts/range/range';\nimport {\n\tParameters as WheelParameters,\n\tWheelSettingsKey,\n} from '../contracts/wheel/wheel';\nimport type { Game } from './game.type.js';\n\nexport const GAME_SETTINGS = {\n\tcoinflip: {\n\t\tsettingsKey: CoinFlipSettingsKey,\n\t\tparameters: CoinflipParameters,\n\t},\n\tlimbo: {\n\t\tsettingsKey: LimboSettingsKey,\n\t\tparameters: LimboParameters,\n\t},\n\tplinko: {\n\t\tsettingsKey: PlinkoSettingsKey,\n\t\tparameters: PlinkoParameters,\n\t},\n\t'pvp-coinflip': {\n\t\tsettingsKey: PvpCoinflipSettingsKey,\n\t\tparameters: PvPCoinflipParameters,\n\t},\n\trange: {\n\t\tsettingsKey: RangeSettingsKey,\n\t\tparameters: RangeParameters,\n\t},\n\twheel: {\n\t\tsettingsKey: WheelSettingsKey,\n\t\tparameters: WheelParameters,\n\t},\n} as const;\n\ntype GameParametersMap = {\n\t[TGame in Game]: ReturnType<\n\t\t(typeof GAME_SETTINGS)[TGame]['parameters']['parse']\n\t>;\n};\n\nexport type GameParameters<TGame extends Game> = GameParametersMap[TGame];\n\nexport type GetGameParametersOptions =\n\tSuiClientTypes.CoreClientMethodOptions & {\n\t\tcoinType?: string;\n\t\tignoreCache?: boolean;\n\t};\n"],"mappings":";;;;;;;AA8BA,MAAa,gBAAgB;CAC5B,UAAU;EACT,aAAa;EACb,YAAYA;
|
|
1
|
+
{"version":3,"file":"game-settings.type.mjs","names":["CoinflipParameters","LimboParameters","PlinkoParameters","PvPCoinflipParameters","RangeParameters","WheelParameters"],"sources":["../../src/types/game-settings.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuiClientTypes } from '@mysten/sui/client';\nimport {\n\tParameters as CoinflipParameters,\n\tCoinFlipSettingsKey,\n} from '../contracts/coinflip/coinflip';\nimport {\n\tParameters as LimboParameters,\n\tLimboSettingsKey,\n} from '../contracts/limbo/limbo';\nimport {\n\tParameters as PlinkoParameters,\n\tPlinkoSettingsKey,\n} from '../contracts/plinko/plinko';\nimport {\n\tParameters as PvPCoinflipParameters,\n\tPvpCoinflipSettingsKey,\n} from '../contracts/pvp-coinflip/pvp_coinflip';\nimport {\n\tParameters as RangeParameters,\n\tRangeSettingsKey,\n} from '../contracts/range/range';\nimport {\n\tParameters as WheelParameters,\n\tWheelSettingsKey,\n} from '../contracts/wheel/wheel';\nimport type { Game } from './game.type.js';\n\nexport const GAME_SETTINGS = {\n\tcoinflip: {\n\t\tsettingsKey: CoinFlipSettingsKey,\n\t\tparameters: CoinflipParameters,\n\t},\n\tlimbo: {\n\t\tsettingsKey: LimboSettingsKey,\n\t\tparameters: LimboParameters,\n\t},\n\tplinko: {\n\t\tsettingsKey: PlinkoSettingsKey,\n\t\tparameters: PlinkoParameters,\n\t},\n\t'pvp-coinflip': {\n\t\tsettingsKey: PvpCoinflipSettingsKey,\n\t\tparameters: PvPCoinflipParameters,\n\t},\n\trange: {\n\t\tsettingsKey: RangeSettingsKey,\n\t\tparameters: RangeParameters,\n\t},\n\twheel: {\n\t\tsettingsKey: WheelSettingsKey,\n\t\tparameters: WheelParameters,\n\t},\n} as const;\n\ntype GameParametersMap = {\n\t[TGame in Game]: ReturnType<\n\t\t(typeof GAME_SETTINGS)[TGame]['parameters']['parse']\n\t>;\n};\n\nexport type GameParameters<TGame extends Game> = GameParametersMap[TGame];\n\nexport type GetGameParametersOptions =\n\tSuiClientTypes.CoreClientMethodOptions & {\n\t\tcoinType?: string;\n\t\tignoreCache?: boolean;\n\t};\n"],"mappings":";;;;;;;AA8BA,MAAa,gBAAgB;CAC5B,UAAU;EACT,aAAa;EACb,YAAYA;CACb;CACA,OAAO;EACN,aAAa;EACb,YAAYC;CACb;CACA,QAAQ;EACP,aAAa;EACb,YAAYC;CACb;CACA,gBAAgB;EACf,aAAa;EACb,YAAYC;CACb;CACA,OAAO;EACN,aAAa;EACb,YAAYC;CACb;CACA,OAAO;EACN,aAAa;EACb,YAAYC;CACb;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.type.d.mts","names":[],"sources":["../../src/types/game.type.ts"],"mappings":";cAGa,KAAA;AAAA,cASA,WAAA;AAAA,KAOD,IAAA,WAAe,
|
|
1
|
+
{"version":3,"file":"game.type.d.mts","names":[],"sources":["../../src/types/game.type.ts"],"mappings":";cAGa,KAAA;AAAA,cASA,WAAA;AAAA,KAOD,IAAA,WAAe,KAAK;AAAA,KAEpB,YAAA,GAAe,OAAA,CAAQ,IAAA,EAAM,OAAA;AAAA,KAC7B,OAAA,GAAU,OAAO,CAAC,IAAA;AAAA,KAElB,QAAA;AAAA,KAEA,SAAA,WAAoB,WAAW;AAAA,KAE/B,eAAA;EACX,MAAA,EAAQ,IAAA;EACR,SAAA,EAAW,SAAS;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.type.mjs","names":[],"sources":["../../src/types/game.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nexport const GAMES = [\n\t'coinflip',\n\t'limbo',\n\t'plinko',\n\t'pvp-coinflip',\n\t'range',\n\t'wheel',\n] as const;\n\nexport const GAME_EVENTS = [\n\t'BetResultEvent',\n\t'GameCreatedEvent',\n\t'GameResolvedEvent',\n\t'GameCancelledEvent',\n] as const;\n\nexport type Game = (typeof GAMES)[number];\n\nexport type StandardGame = Exclude<Game, PvPGame>;\nexport type PvPGame = Extract<Game, `pvp-${string}`>;\n\nexport type CoinSide = 'heads' | 'tails';\n\nexport type GameEvent = (typeof GAME_EVENTS)[number];\n\nexport type SuigarGameEvent = {\n\tgameId: Game;\n\teventName: GameEvent;\n};\n"],"mappings":";AAGA,MAAa,QAAQ;CACpB;CACA;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"game.type.mjs","names":[],"sources":["../../src/types/game.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nexport const GAMES = [\n\t'coinflip',\n\t'limbo',\n\t'plinko',\n\t'pvp-coinflip',\n\t'range',\n\t'wheel',\n] as const;\n\nexport const GAME_EVENTS = [\n\t'BetResultEvent',\n\t'GameCreatedEvent',\n\t'GameResolvedEvent',\n\t'GameCancelledEvent',\n] as const;\n\nexport type Game = (typeof GAMES)[number];\n\nexport type StandardGame = Exclude<Game, PvPGame>;\nexport type PvPGame = Extract<Game, `pvp-${string}`>;\n\nexport type CoinSide = 'heads' | 'tails';\n\nexport type GameEvent = (typeof GAME_EVENTS)[number];\n\nexport type SuigarGameEvent = {\n\tgameId: Game;\n\teventName: GameEvent;\n};\n"],"mappings":";AAGA,MAAa,QAAQ;CACpB;CACA;CACA;CACA;CACA;CACA;AACD;AAEA,MAAa,cAAc;CAC1B;CACA;CACA;CACA;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-float.type.d.mts","names":[],"sources":["../../src/types/move-float.type.ts"],"mappings":";;;KAKY,SAAA,GAAY,
|
|
1
|
+
{"version":3,"file":"move-float.type.d.mts","names":[],"sources":["../../src/types/move-float.type.ts"],"mappings":";;;KAKY,SAAA,GAAY,UAAU,SAAS,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.type.mjs","names":[],"sources":["../../src/types/network.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClientTypes } from '@mysten/sui/client';\n\nexport type SuiNetwork = Extract<SuiClientTypes.Network, 'mainnet' | 'testnet'>;\n\nexport const SUPPORTED_SUI_NETWORKS: SuiClientTypes.Network[] = [\n\t'mainnet',\n\t'testnet',\n];\n"],"mappings":";AAOA,MAAa,yBAAmD,CAC/D,WACA,
|
|
1
|
+
{"version":3,"file":"network.type.mjs","names":[],"sources":["../../src/types/network.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { SuiClientTypes } from '@mysten/sui/client';\n\nexport type SuiNetwork = Extract<SuiClientTypes.Network, 'mainnet' | 'testnet'>;\n\nexport const SUPPORTED_SUI_NETWORKS: SuiClientTypes.Network[] = [\n\t'mainnet',\n\t'testnet',\n];\n"],"mappings":";AAOA,MAAa,yBAAmD,CAC/D,WACA,SACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suigar-config.type.d.mts","names":[],"sources":["../../src/types/suigar-config.type.ts"],"mappings":";UAKiB,sBAAA;EAChB,IAAA,GAAO,
|
|
1
|
+
{"version":3,"file":"suigar-config.type.d.mts","names":[],"sources":["../../src/types/suigar-config.type.ts"],"mappings":";UAKiB,sBAAA;EAChB,IAAA,GAAO,IAAI;EADK;;;;;;EAQhB,OAAA;EAAA;;;AAMQ;AAGT;EAHC,QAAA;AAAA;AAAA,KAGW,UAAA;AAAA,KAEA,eAAA,GAAkB,MAAM,CAAC,UAAA;AAAA,KAEzB,aAAA;AAAA,KASA,gBAAA,GAAmB,MAAM,CAAC,aAAA;AAAA,KAE1B,cAAA;AAAA,KACA,iBAAA,GAAoB,MAAM,CAAC,cAAA;AAAA,KAE3B,wBAAA,GAA2B,MAAM,CAAC,UAAA;AAAA,KAIlC,YAAA;EACX,UAAA,EAAY,gBAAA;EACZ,WAAA,EAAa,iBAAA;EACb,SAAA,EAAW,eAAA;EACX,kBAAA,EAAoB,wBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-options.type.d.mts","names":[],"sources":["../../src/types/transaction-options.type.ts"],"mappings":";;;;;;KAQY,aAAA;EACX,SAAA,GAAY,
|
|
1
|
+
{"version":3,"file":"transaction-options.type.d.mts","names":[],"sources":["../../src/types/transaction-options.type.ts"],"mappings":";;;;;;KAQY,aAAA;EACX,SAAA,GAAY,UAAU,CAAC,WAAA;AAAA;AAAA,KAOZ,gBAAA,eAA+B,CAAC;EAC3C,YAAA;AAAA;AAAA,KAGW,sBAAA,GAAyB,aAAA;EACpC,MAAA,EAAQ,YAAY;EACpB,KAAA;AAAA;AAAA,KAGW,sBAAA;EACX,QAAA;EACA,QAAA,GAAW,gBAAgB;EAC3B,oBAAA;AAAA;AAAA,KAGW,uBAAA;EACX,KAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,KAGW,2BAAA,GAA8B,sBAAA,GACzC,sBAAA,GACA,uBAAA;AAAA,KAEW,+BAAA,GAAkC,2BAAA;EAC7C,IAAA,EAAM,QAAQ;AAAA;AAAA,KAGH,4BAAA,GAA+B,2BAA2B;EACrE,gBAAA;EACA,KAAA;AAAA;AAAA,KAGW,6BAAA,GAAgC,2BAA2B;EACtE,QAAQ;AAAA;AAAA,KAGG,4BAAA,GAA+B,2BAA2B;EACrE,SAAA;EACA,UAAA;EACA,UAAA;EACA,KAAA;AAAA;AAAA,KAGW,4BAAA,GAA+B,2BAA2B;EACrE,QAAQ;AAAA;AAAA,KAGG,iBAAA;AAAA,KAEA,mCAAA,GAAsC,sBAAA,GACjD,sBAAsB;AAAA,KAEX,wCAAA,GACX,mCAAA;EACC,KAAA,EAAO,uBAAA;EACP,IAAA,EAAM,QAAA;EACN,SAAA;AAAA;AAAA,KAGU,sCAAA,GACX,mCAAmC;EAClC,MAAM;AAAA;AAAA,KAQI,wCAAA,GACX,mCAAmC;EAClC,MAAM;AAAA;AAAA,KAGI,kCAAA,gBACI,iBAAA,GAAoB,iBAAA,IAChC,MAAA,oBACD,wCAAA,GACA,MAAA,kBACC,sCAAA,GACA,MAAA,oBACC,wCAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { parseToMist } from '@mysten/sui/utils';\n\nexport const DEFAULT_GAS_BUDGET_MIST: bigint = parseToMist('0.05');\nexport const DEFAULT_RANGE_SCALE = 1_000_000;\nexport const RANGE_POINT_LIMIT: number = DEFAULT_RANGE_SCALE * 100;\nexport const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;\n"],"mappings":";;AAKA,MAAa,0BAAkC,YAAY,
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { parseToMist } from '@mysten/sui/utils';\n\nexport const DEFAULT_GAS_BUDGET_MIST: bigint = parseToMist('0.05');\nexport const DEFAULT_RANGE_SCALE = 1_000_000;\nexport const RANGE_POINT_LIMIT: number = DEFAULT_RANGE_SCALE * 100;\nexport const DEFAULT_LIMBO_MULTIPLIER_SCALE = 100;\n"],"mappings":";;AAKA,MAAa,0BAAkC,YAAY,MAAM;AACjE,MAAa,sBAAsB;AACnC,MAAa,oBAA4B,sBAAsB;AAC/D,MAAa,iCAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric.d.mts","names":[],"sources":["../../src/utils/numeric.ts"],"mappings":";;;;;AAgBA
|
|
1
|
+
{"version":3,"file":"numeric.d.mts","names":[],"sources":["../../src/utils/numeric.ts"],"mappings":";;;;;AAgBA;;;;AAAiD;AAmBjD;;;iBAnBgB,WAAA,CAAY,GAAqB,EAAhB,SAAS;AAmBI;AA6C9C;;;;AAAuC;AAqFvC;;;;AAAmC;AAlIW,iBAA9B,aAAA,CAAc,KAAgB,EAAT,SAAS;;;;AAuJV;;;;;;;;;;;;;;;;;iBA1GpB,QAAA,CAAS,KAAc;;;;;;;;;;;;;;;;;;iBAqFvB,IAAA,CAAK,KAAc;;;;;;;;;;;;;;;;;;iBAqBnB,KAAA,CAAM,KAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numeric.mjs","names":[],"sources":["../../src/utils/numeric.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MoveFloat } from '../types';\n\n/**\n * Converts a generated Move `i64` wrapper into a JavaScript number.\n *\n * The generated bindings expose signed 64-bit integers through a `{ bits }`\n * field that stores the raw two's-complement bit pattern. This helper\n * reinterprets those bits as a signed `i64` and returns a plain JS number.\n * Invalid or missing input falls back to `0`.\n *\n * @param i64 Generated Move `i64` value, typically used for float exponents.\n * @returns The signed 64-bit value as a JavaScript number.\n */\nexport function fromMoveI64(i64: MoveFloat['exp']): number {\n\ttry {\n\t\treturn Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));\n\t} catch {\n\t\treturn 0;\n\t}\n}\n\n/**\n * Converts a generated Move `Float` struct into a JavaScript number.\n *\n * Suigar float values are represented as a sign flag, an unsigned mantissa,\n * and a Move `i64` exponent. This helper rebuilds the numeric value using the\n * same normalization expected by the on-chain format and applies the sign at\n * the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.\n *\n * @param float Generated Move float value with `mant`, `exp`, and `is_negative`.\n * @returns The decoded floating-point value as a JavaScript number.\n */\nexport function fromMoveFloat(float: MoveFloat): number {\n\tconst mantissa = BigInt(float.mant ?? 0);\n\tif (mantissa === 0n) {\n\t\treturn 0;\n\t}\n\tconst exponent = fromMoveI64(float.exp) - 52;\n\tconst magnitude = Number(mantissa) * 2 ** exponent;\n\treturn float.is_negative ? -magnitude : magnitude;\n}\n\n/**\n * Ensures a value is a finite JavaScript number.\n *\n * This is only used for helpers that accept raw `number` input before applying\n * additional integer or range validation.\n */\nfunction assertFiniteNumber(\n\tvalue: unknown,\n\terrorMessage: string,\n): asserts value is number {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) {\n\t\tthrow new TypeError(`${errorMessage}: ${String(value)}`);\n\t}\n}\n\n/**\n * Normalizes a value into a non-negative `bigint`.\n *\n * Accepted inputs:\n * - `bigint`\n * - finite `number`\n * - base-10 integer `string`\n * - `boolean`\n *\n * Number inputs are truncated toward zero before conversion, so `5.9` becomes\n * `5n`. String and boolean inputs are parsed through the native\n * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,\n * and only integer strings are accepted.\n *\n * @param value Value to normalize.\n * @returns A non-negative `bigint`.\n * @throws When `value` is not a bigint, finite number, integer string, or\n * boolean.\n * @throws When the normalized value is negative.\n */\nexport function toBigInt(value: unknown): bigint {\n\tlet result: bigint;\n\n\ttry {\n\t\tif (\n\t\t\ttypeof value === 'bigint' ||\n\t\t\ttypeof value === 'string' ||\n\t\t\ttypeof value === 'boolean'\n\t\t) {\n\t\t\tresult = BigInt(value);\n\t\t} else {\n\t\t\tassertFiniteNumber(\n\t\t\t\tvalue,\n\t\t\t\t'Value must be a bigint, number, integer string, or boolean',\n\t\t\t);\n\t\t\tresult = BigInt(Math.trunc(value));\n\t\t}\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t`Value must be a bigint, number, integer string, or boolean: ${value}`,\n\t\t);\n\t}\n\n\tif (result < 0n) {\n\t\tthrow new RangeError(`Value must be non-negative: ${value}`);\n\t}\n\n\treturn result;\n}\n\n/**\n * Validates and normalizes a bounded unsigned integer.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * This internal helper powers the public `toU8()` and `toU16()` helpers. It\n * accepts stringified integers such as `'1'` for parsed values, but rejects\n * booleans, empty strings, fractional values, and out-of-range numbers.\n *\n * @param value Value to validate.\n * @param max Inclusive upper bound.\n * @param typeName Move integer label used in error messages.\n * @returns The validated integer as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `max`.\n */\nfunction toBoundedInt(value: unknown, max: number, typeName: string): number {\n\tconst num =\n\t\ttypeof value === 'string' && value.trim() === '' ? NaN : Number(value);\n\n\tassertFiniteNumber(num, 'Value must be a finite number or integer string');\n\tif (\n\t\ttypeof value === 'boolean' ||\n\t\tvalue == null ||\n\t\t!Number.isInteger(num) ||\n\t\tnum < 0 ||\n\t\tnum > max\n\t) {\n\t\tthrow new RangeError(\n\t\t\t`Value must be a ${typeName} integer (0-${max}): ${value}`,\n\t\t);\n\t}\n\n\treturn num;\n}\n\n/**\n * Validates that a value can be safely used as a Move `u8` in the `0..255`\n * range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u8` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `255`.\n */\nexport function toU8(value: unknown): number {\n\treturn toBoundedInt(value, 255, 'u8');\n}\n\n/**\n * Validates that a value can be safely used as a Move `u16` in the\n * `0..65535` range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u16` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `65535`.\n */\nexport function toU16(value: unknown): number {\n\treturn toBoundedInt(value, 65535, 'u16');\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,YAAY,KAA+B;CAC1D,IAAI;EACH,OAAO,OAAO,OAAO,OAAO,IAAI,OAAO,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"numeric.mjs","names":[],"sources":["../../src/utils/numeric.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MoveFloat } from '../types';\n\n/**\n * Converts a generated Move `i64` wrapper into a JavaScript number.\n *\n * The generated bindings expose signed 64-bit integers through a `{ bits }`\n * field that stores the raw two's-complement bit pattern. This helper\n * reinterprets those bits as a signed `i64` and returns a plain JS number.\n * Invalid or missing input falls back to `0`.\n *\n * @param i64 Generated Move `i64` value, typically used for float exponents.\n * @returns The signed 64-bit value as a JavaScript number.\n */\nexport function fromMoveI64(i64: MoveFloat['exp']): number {\n\ttry {\n\t\treturn Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));\n\t} catch {\n\t\treturn 0;\n\t}\n}\n\n/**\n * Converts a generated Move `Float` struct into a JavaScript number.\n *\n * Suigar float values are represented as a sign flag, an unsigned mantissa,\n * and a Move `i64` exponent. This helper rebuilds the numeric value using the\n * same normalization expected by the on-chain format and applies the sign at\n * the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.\n *\n * @param float Generated Move float value with `mant`, `exp`, and `is_negative`.\n * @returns The decoded floating-point value as a JavaScript number.\n */\nexport function fromMoveFloat(float: MoveFloat): number {\n\tconst mantissa = BigInt(float.mant ?? 0);\n\tif (mantissa === 0n) {\n\t\treturn 0;\n\t}\n\tconst exponent = fromMoveI64(float.exp) - 52;\n\tconst magnitude = Number(mantissa) * 2 ** exponent;\n\treturn float.is_negative ? -magnitude : magnitude;\n}\n\n/**\n * Ensures a value is a finite JavaScript number.\n *\n * This is only used for helpers that accept raw `number` input before applying\n * additional integer or range validation.\n */\nfunction assertFiniteNumber(\n\tvalue: unknown,\n\terrorMessage: string,\n): asserts value is number {\n\tif (typeof value !== 'number' || !Number.isFinite(value)) {\n\t\tthrow new TypeError(`${errorMessage}: ${String(value)}`);\n\t}\n}\n\n/**\n * Normalizes a value into a non-negative `bigint`.\n *\n * Accepted inputs:\n * - `bigint`\n * - finite `number`\n * - base-10 integer `string`\n * - `boolean`\n *\n * Number inputs are truncated toward zero before conversion, so `5.9` becomes\n * `5n`. String and boolean inputs are parsed through the native\n * `BigInt(...)` constructor, so `true` becomes `1n`, `false` becomes `0n`,\n * and only integer strings are accepted.\n *\n * @param value Value to normalize.\n * @returns A non-negative `bigint`.\n * @throws When `value` is not a bigint, finite number, integer string, or\n * boolean.\n * @throws When the normalized value is negative.\n */\nexport function toBigInt(value: unknown): bigint {\n\tlet result: bigint;\n\n\ttry {\n\t\tif (\n\t\t\ttypeof value === 'bigint' ||\n\t\t\ttypeof value === 'string' ||\n\t\t\ttypeof value === 'boolean'\n\t\t) {\n\t\t\tresult = BigInt(value);\n\t\t} else {\n\t\t\tassertFiniteNumber(\n\t\t\t\tvalue,\n\t\t\t\t'Value must be a bigint, number, integer string, or boolean',\n\t\t\t);\n\t\t\tresult = BigInt(Math.trunc(value));\n\t\t}\n\t} catch {\n\t\tthrow new TypeError(\n\t\t\t`Value must be a bigint, number, integer string, or boolean: ${value}`,\n\t\t);\n\t}\n\n\tif (result < 0n) {\n\t\tthrow new RangeError(`Value must be non-negative: ${value}`);\n\t}\n\n\treturn result;\n}\n\n/**\n * Validates and normalizes a bounded unsigned integer.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * This internal helper powers the public `toU8()` and `toU16()` helpers. It\n * accepts stringified integers such as `'1'` for parsed values, but rejects\n * booleans, empty strings, fractional values, and out-of-range numbers.\n *\n * @param value Value to validate.\n * @param max Inclusive upper bound.\n * @param typeName Move integer label used in error messages.\n * @returns The validated integer as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `max`.\n */\nfunction toBoundedInt(value: unknown, max: number, typeName: string): number {\n\tconst num =\n\t\ttypeof value === 'string' && value.trim() === '' ? NaN : Number(value);\n\n\tassertFiniteNumber(num, 'Value must be a finite number or integer string');\n\tif (\n\t\ttypeof value === 'boolean' ||\n\t\tvalue == null ||\n\t\t!Number.isInteger(num) ||\n\t\tnum < 0 ||\n\t\tnum > max\n\t) {\n\t\tthrow new RangeError(\n\t\t\t`Value must be a ${typeName} integer (0-${max}): ${value}`,\n\t\t);\n\t}\n\n\treturn num;\n}\n\n/**\n * Validates that a value can be safely used as a Move `u8` in the `0..255`\n * range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u8` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `255`.\n */\nexport function toU8(value: unknown): number {\n\treturn toBoundedInt(value, 255, 'u8');\n}\n\n/**\n * Validates that a value can be safely used as a Move `u16` in the\n * `0..65535` range.\n *\n * Accepted inputs:\n * - finite `number`\n * - base-10 integer `string`\n *\n * String inputs are accepted for parsed values such as `'1'`, but only when\n * they are plain non-negative integer strings. This helper does not accept\n * booleans and does not truncate fractional values.\n *\n * @param value Value to validate.\n * @returns The validated `u16` value as a JavaScript `number`.\n * @throws When `value` is not a finite number or integer string.\n * @throws When `value` is not an integer between `0` and `65535`.\n */\nexport function toU16(value: unknown): number {\n\treturn toBoundedInt(value, 65535, 'u16');\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,YAAY,KAA+B;CAC1D,IAAI;EACH,OAAO,OAAO,OAAO,OAAO,IAAI,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC;CACvD,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;;;;;;AAaA,SAAgB,cAAc,OAA0B;CACvD,MAAM,WAAW,OAAO,MAAM,QAAQ,CAAC;CACvC,IAAI,aAAa,IAChB,OAAO;CAER,MAAM,WAAW,YAAY,MAAM,GAAG,IAAI;CAC1C,MAAM,YAAY,OAAO,QAAQ,IAAI,KAAK;CAC1C,OAAO,MAAM,cAAc,CAAC,YAAY;AACzC;;;;;;;AAQA,SAAS,mBACR,OACA,cAC0B;CAC1B,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GACtD,MAAM,IAAI,UAAU,GAAG,aAAa,IAAI,OAAO,KAAK,GAAG;AAEzD;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,SAAS,OAAwB;CAChD,IAAI;CAEJ,IAAI;EACH,IACC,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,WAEjB,SAAS,OAAO,KAAK;OACf;GACN,mBACC,OACA,4DACD;GACA,SAAS,OAAO,KAAK,MAAM,KAAK,CAAC;EAClC;CACD,QAAQ;EACP,MAAM,IAAI,UACT,+DAA+D,OAChE;CACD;CAEA,IAAI,SAAS,IACZ,MAAM,IAAI,WAAW,+BAA+B,OAAO;CAG5D,OAAO;AACR;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,aAAa,OAAgB,KAAa,UAA0B;CAC5E,MAAM,MACL,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,KAAK,MAAM,OAAO,KAAK;CAEtE,mBAAmB,KAAK,iDAAiD;CACzE,IACC,OAAO,UAAU,aACjB,SAAS,QACT,CAAC,OAAO,UAAU,GAAG,KACrB,MAAM,KACN,MAAM,KAEN,MAAM,IAAI,WACT,mBAAmB,SAAS,cAAc,IAAI,KAAK,OACpD;CAGD,OAAO;AACR;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,KAAK,OAAwB;CAC5C,OAAO,aAAa,OAAO,KAAK,IAAI;AACrC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,MAAM,OAAwB;CAC7C,OAAO,aAAa,OAAO,OAAO,KAAK;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.mts","names":[],"sources":["../../src/utils/parser.ts"],"mappings":";;;;;;;;;AAkCA
|
|
1
|
+
{"version":3,"file":"parser.d.mts","names":[],"sources":["../../src/utils/parser.ts"],"mappings":";;;;;;;;;AAkCA;;;;AAA0C;AAqB1C;iBArBgB,aAAA,CAAc,IAAY;;;;;;;;AAuBxB;AAqElB;;;;iBAvEgB,cAAA,CACf,KAAA,EAAO,cAAA,CAAe,KAAA,GACpB,eAAe;;;;;;;;;;;;;;;AAwEE;;;;;;;iBAHJ,gBAAA,eAA+B,IAAA,CAAA,CAC9C,MAAA,EAAQ,KAAA,EACR,WAAA,EAAa,oBAAA,GACX,WAAA,CAAY,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.mjs","names":[],"sources":["../../src/utils/parser.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport type { SuiClientTypes } from '@mysten/sui/client';\nimport { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';\nimport {\n\tBetResultGameDetails,\n\tGAME_DETAIL_BCS,\n\tGAME_DETAILS_SCHEMAS,\n\tGAME_EVENTS,\n\tGameDetail,\n\tGameDetails,\n\tGameEvent,\n\tGAMES,\n\tMoveFloat,\n\tSuigarGameEvent,\n\ttype Game,\n\ttype GameDetailValueType,\n} from '../types';\nimport { fromMoveFloat } from './numeric';\n\nconst textDecoder = new TextDecoder();\n\n/**\n * Extracts and normalizes the first generic coin type from a Move object type.\n *\n * PvP Coinflip game object types encode the wager coin as their first type parameter,\n * for example `Game<0x2::sui::SUI>`. This helper converts that generic type\n * argument into the SDK's canonical struct tag string.\n *\n * @param type Fully qualified Move object type with the coin type as its first generic argument.\n * @returns Normalized coin type struct tag.\n */\nexport function parseCoinType(type: string): string {\n\tconst coinType = parseStructTag(type).typeParams[0];\n\tif (!coinType) {\n\t\tthrow new TypeError(`Unable to parse coin type from ${type}`);\n\t}\n\n\treturn normalizeStructTag(coinType);\n}\n\n/**\n * Resolves a supported Suigar event into its normalized SDK game id and event name.\n *\n * This helper recognizes all supported Suigar event names in `GAME_EVENTS`.\n * Standard `BetResultEvent` payloads encode the game family through the core\n * client event module or generic type parameter, while PvP coinflip events\n * resolve to the `pvp-coinflip` game id from their `pvp_coinflip` module.\n *\n * @param event Sui event returned by the core client.\n * @returns Parsed SDK game id and raw Move event name, or `null` when the event\n * name is unsupported or the game id cannot be resolved.\n */\nexport function parseGameEvent(\n\tevent: SuiClientTypes.Event,\n): SuigarGameEvent | null {\n\tconst { name: eventName, typeParams } = parseStructTag(event.eventType);\n\tconst module = event.module.replaceAll('_', '-');\n\tconst gameId = GAMES.includes(module as Game) ? module : typeParams[0];\n\n\tif (\n\t\t!GAME_EVENTS.includes(eventName as GameEvent) ||\n\t\ttypeof gameId !== 'string'\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tgameId,\n\t\teventName,\n\t} as SuigarGameEvent;\n}\n\nfunction parseStringGameDetail(value: number[]): string {\n\tconst bytes = Uint8Array.from(value);\n\n\ttry {\n\t\treturn bcs.String.parse(bytes);\n\t} catch {\n\t\treturn textDecoder.decode(bytes);\n\t}\n}\n\nfunction parseGameDetail<TValueType extends GameDetailValueType>(\n\tvalueType: TValueType,\n\tvalue: number[],\n): GameDetail<TValueType> {\n\tif (valueType === 'string') {\n\t\treturn parseStringGameDetail(value) as GameDetail<TValueType>;\n\t}\n\n\tconst parsed = GAME_DETAIL_BCS[valueType].parse(Uint8Array.from(value));\n\n\tswitch (valueType) {\n\t\tcase 'float':\n\t\t\treturn fromMoveFloat(parsed as MoveFloat) as GameDetail<TValueType>;\n\t\tcase 'u64':\n\t\t\treturn Number(parsed) as GameDetail<TValueType>;\n\t\tdefault:\n\t\t\treturn parsed as GameDetail<TValueType>;\n\t}\n}\n\n/**\n * Decodes `BetResultEvent.game_details` into plain application values.\n *\n * Use this only with the `game_details` field from a decoded `BetResultEvent`.\n * Suigar stores those entries as `VecMap<string, vector<u8>>`, so raw BCS\n * decoding leaves each value as bytes. This helper uses the provided `gameId`\n * to narrow the known detail schema, parses each byte array into the expected\n * runtime type, and preserves the original on-chain keys in the returned\n * object. Unknown keys fall back to string decoding so newer detail fields\n * remain readable by default.\n *\n * Call `parseGameEvent(event)` first when you need to derive the matching\n * `gameId` from the raw `SuiClientTypes.Event` before decoding\n * `decoded.game_details`.\n *\n * @param gameId Suigar game id used to narrow the known detail keys and value\n * types for this bet result payload.\n * @param gameDetails Raw `game_details` map from a decoded `BetResultEvent`.\n * @returns A plain object with decoded values for the known keys of the\n * selected game.\n */\nexport function parseGameDetails<TGame extends Game>(\n\tgameId: TGame,\n\tgameDetails: BetResultGameDetails,\n): GameDetails<TGame> {\n\tconst schema: Record<string, GameDetailValueType> =\n\t\tGAME_DETAILS_SCHEMAS[gameId];\n\tconst details = gameDetails.contents.reduce<Record<string, unknown>>(\n\t\t(parsedDetails, entry) => {\n\t\t\tconst valueType = schema[entry.key] ?? 'string';\n\t\t\tparsedDetails[entry.key] = parseGameDetail(valueType, entry.value);\n\t\t\treturn parsedDetails;\n\t\t},\n\t\t{},\n\t);\n\n\treturn details as GameDetails<TGame>;\n}\n"],"mappings":";;;;;;AAsBA,MAAM,cAAc,IAAI,
|
|
1
|
+
{"version":3,"file":"parser.mjs","names":[],"sources":["../../src/utils/parser.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport type { SuiClientTypes } from '@mysten/sui/client';\nimport { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';\nimport {\n\tBetResultGameDetails,\n\tGAME_DETAIL_BCS,\n\tGAME_DETAILS_SCHEMAS,\n\tGAME_EVENTS,\n\tGameDetail,\n\tGameDetails,\n\tGameEvent,\n\tGAMES,\n\tMoveFloat,\n\tSuigarGameEvent,\n\ttype Game,\n\ttype GameDetailValueType,\n} from '../types';\nimport { fromMoveFloat } from './numeric';\n\nconst textDecoder = new TextDecoder();\n\n/**\n * Extracts and normalizes the first generic coin type from a Move object type.\n *\n * PvP Coinflip game object types encode the wager coin as their first type parameter,\n * for example `Game<0x2::sui::SUI>`. This helper converts that generic type\n * argument into the SDK's canonical struct tag string.\n *\n * @param type Fully qualified Move object type with the coin type as its first generic argument.\n * @returns Normalized coin type struct tag.\n */\nexport function parseCoinType(type: string): string {\n\tconst coinType = parseStructTag(type).typeParams[0];\n\tif (!coinType) {\n\t\tthrow new TypeError(`Unable to parse coin type from ${type}`);\n\t}\n\n\treturn normalizeStructTag(coinType);\n}\n\n/**\n * Resolves a supported Suigar event into its normalized SDK game id and event name.\n *\n * This helper recognizes all supported Suigar event names in `GAME_EVENTS`.\n * Standard `BetResultEvent` payloads encode the game family through the core\n * client event module or generic type parameter, while PvP coinflip events\n * resolve to the `pvp-coinflip` game id from their `pvp_coinflip` module.\n *\n * @param event Sui event returned by the core client.\n * @returns Parsed SDK game id and raw Move event name, or `null` when the event\n * name is unsupported or the game id cannot be resolved.\n */\nexport function parseGameEvent(\n\tevent: SuiClientTypes.Event,\n): SuigarGameEvent | null {\n\tconst { name: eventName, typeParams } = parseStructTag(event.eventType);\n\tconst module = event.module.replaceAll('_', '-');\n\tconst gameId = GAMES.includes(module as Game) ? module : typeParams[0];\n\n\tif (\n\t\t!GAME_EVENTS.includes(eventName as GameEvent) ||\n\t\ttypeof gameId !== 'string'\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tgameId,\n\t\teventName,\n\t} as SuigarGameEvent;\n}\n\nfunction parseStringGameDetail(value: number[]): string {\n\tconst bytes = Uint8Array.from(value);\n\n\ttry {\n\t\treturn bcs.String.parse(bytes);\n\t} catch {\n\t\treturn textDecoder.decode(bytes);\n\t}\n}\n\nfunction parseGameDetail<TValueType extends GameDetailValueType>(\n\tvalueType: TValueType,\n\tvalue: number[],\n): GameDetail<TValueType> {\n\tif (valueType === 'string') {\n\t\treturn parseStringGameDetail(value) as GameDetail<TValueType>;\n\t}\n\n\tconst parsed = GAME_DETAIL_BCS[valueType].parse(Uint8Array.from(value));\n\n\tswitch (valueType) {\n\t\tcase 'float':\n\t\t\treturn fromMoveFloat(parsed as MoveFloat) as GameDetail<TValueType>;\n\t\tcase 'u64':\n\t\t\treturn Number(parsed) as GameDetail<TValueType>;\n\t\tdefault:\n\t\t\treturn parsed as GameDetail<TValueType>;\n\t}\n}\n\n/**\n * Decodes `BetResultEvent.game_details` into plain application values.\n *\n * Use this only with the `game_details` field from a decoded `BetResultEvent`.\n * Suigar stores those entries as `VecMap<string, vector<u8>>`, so raw BCS\n * decoding leaves each value as bytes. This helper uses the provided `gameId`\n * to narrow the known detail schema, parses each byte array into the expected\n * runtime type, and preserves the original on-chain keys in the returned\n * object. Unknown keys fall back to string decoding so newer detail fields\n * remain readable by default.\n *\n * Call `parseGameEvent(event)` first when you need to derive the matching\n * `gameId` from the raw `SuiClientTypes.Event` before decoding\n * `decoded.game_details`.\n *\n * @param gameId Suigar game id used to narrow the known detail keys and value\n * types for this bet result payload.\n * @param gameDetails Raw `game_details` map from a decoded `BetResultEvent`.\n * @returns A plain object with decoded values for the known keys of the\n * selected game.\n */\nexport function parseGameDetails<TGame extends Game>(\n\tgameId: TGame,\n\tgameDetails: BetResultGameDetails,\n): GameDetails<TGame> {\n\tconst schema: Record<string, GameDetailValueType> =\n\t\tGAME_DETAILS_SCHEMAS[gameId];\n\tconst details = gameDetails.contents.reduce<Record<string, unknown>>(\n\t\t(parsedDetails, entry) => {\n\t\t\tconst valueType = schema[entry.key] ?? 'string';\n\t\t\tparsedDetails[entry.key] = parseGameDetail(valueType, entry.value);\n\t\t\treturn parsedDetails;\n\t\t},\n\t\t{},\n\t);\n\n\treturn details as GameDetails<TGame>;\n}\n"],"mappings":";;;;;;AAsBA,MAAM,cAAc,IAAI,YAAY;;;;;;;;;;;AAYpC,SAAgB,cAAc,MAAsB;CACnD,MAAM,WAAW,eAAe,IAAI,EAAE,WAAW;CACjD,IAAI,CAAC,UACJ,MAAM,IAAI,UAAU,kCAAkC,MAAM;CAG7D,OAAO,mBAAmB,QAAQ;AACnC;;;;;;;;;;;;;AAcA,SAAgB,eACf,OACyB;CACzB,MAAM,EAAE,MAAM,WAAW,eAAe,eAAe,MAAM,SAAS;CACtE,MAAM,SAAS,MAAM,OAAO,WAAW,KAAK,GAAG;CAC/C,MAAM,SAAS,MAAM,SAAS,MAAc,IAAI,SAAS,WAAW;CAEpE,IACC,CAAC,YAAY,SAAS,SAAsB,KAC5C,OAAO,WAAW,UAElB,OAAO;CAGR,OAAO;EACN;EACA;CACD;AACD;AAEA,SAAS,sBAAsB,OAAyB;CACvD,MAAM,QAAQ,WAAW,KAAK,KAAK;CAEnC,IAAI;EACH,OAAO,IAAI,OAAO,MAAM,KAAK;CAC9B,QAAQ;EACP,OAAO,YAAY,OAAO,KAAK;CAChC;AACD;AAEA,SAAS,gBACR,WACA,OACyB;CACzB,IAAI,cAAc,UACjB,OAAO,sBAAsB,KAAK;CAGnC,MAAM,SAAS,gBAAgB,WAAW,MAAM,WAAW,KAAK,KAAK,CAAC;CAEtE,QAAQ,WAAR;EACC,KAAK,SACJ,OAAO,cAAc,MAAmB;EACzC,KAAK,OACJ,OAAO,OAAO,MAAM;EACrB,SACC,OAAO;CACT;AACD;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,iBACf,QACA,aACqB;CACrB,MAAM,SACL,qBAAqB;CAUtB,OATgB,YAAY,SAAS,QACnC,eAAe,UAAU;EACzB,MAAM,YAAY,OAAO,MAAM,QAAQ;EACvC,cAAc,MAAM,OAAO,gBAAgB,WAAW,MAAM,KAAK;EACjE,OAAO;CACR,GACA,CAAC,CAGW;AACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suigar/sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.19",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suigar",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"homepage": "https://docs.suigar.com/sdk",
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@mysten/bcs": "^2.0.5",
|
|
57
|
-
"@mysten/sui": "^2.
|
|
57
|
+
"@mysten/sui": "^2.17.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@mysten/bcs": "^2.0.5",
|
|
61
61
|
"@mysten/codegen": "^0.10.6",
|
|
62
|
-
"@mysten/sui": "^2.
|
|
62
|
+
"@mysten/sui": "^2.17.0",
|
|
63
63
|
"@types/node": "^24.0.0",
|
|
64
64
|
"tsdown": "^0.22.0",
|
|
65
|
-
"tsx": "^4.22.
|
|
65
|
+
"tsx": "^4.22.2",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
67
|
"vitest": "^4.1.6"
|
|
68
68
|
},
|