@suigar/sdk 2.0.0-beta.19 → 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.
- package/CHANGELOG.md +7 -0
- package/README.md +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +92 -105
- package/dist/client.mjs.map +1 -1
- package/dist/configs/registry.mainnet.mjs.map +1 -1
- package/dist/configs/registry.testnet.mjs.map +1 -1
- package/dist/contracts/core/core.d.mts +12 -12
- package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/contracts/core/float.d.mts +3 -3
- package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.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 -10
- package/dist/contracts/utils/index.d.mts +35 -0
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/contracts/utils/index.mjs +68 -2
- package/dist/contracts/utils/index.mjs.map +1 -1
- package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -1
- package/dist/helpers/config.mjs.map +1 -1
- package/dist/helpers/game-settings.mjs.map +1 -1
- package/dist/helpers/metadata.mjs +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/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/game-details.type.d.mts +7 -7
- package/dist/types/game-details.type.mjs.map +1 -1
- package/dist/types/game-settings.type.mjs.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 +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @suigar/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.20
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 84feb08: Refresh SDK dependency metadata for the latest Mysten package set and normalize the published Node engine range.
|
|
8
|
+
- bed0775: Update the SDK to the latest Mysten package set, NodeNext TypeScript module resolution, and explicit ESM source imports. Regenerated contract wrappers now expose helpers for building and resolving Move type tags from generated BCS types.
|
|
9
|
+
|
|
3
10
|
## 2.0.0-beta.19
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -584,7 +584,7 @@ pnpm --dir packages/sdk test
|
|
|
584
584
|
|
|
585
585
|
## Example App
|
|
586
586
|
|
|
587
|
-
This repository includes a Next.js integration playground in [
|
|
587
|
+
This repository includes a Next.js integration playground in [playground](../../playground).
|
|
588
588
|
|
|
589
589
|
It demonstrates:
|
|
590
590
|
|
|
@@ -602,5 +602,5 @@ Run it from the repo root with:
|
|
|
602
602
|
|
|
603
603
|
```bash
|
|
604
604
|
pnpm install
|
|
605
|
-
pnpm turbo run dev --filter='./
|
|
605
|
+
pnpm turbo run dev --filter='./playground'
|
|
606
606
|
```
|
package/dist/client.d.mts
CHANGED
|
@@ -3,8 +3,8 @@ import { SuigarConfig, SuigarExtensionOptions } from "./types/suigar-config.type
|
|
|
3
3
|
import { BuildPvPCoinflipTransactionOptions, PvPCoinflipAction, WithThrowOnError } from "./types/transaction-options.type.mjs";
|
|
4
4
|
import { MoveStruct } from "./contracts/utils/index.mjs";
|
|
5
5
|
import { Game as Game$1 } from "./contracts/pvp-coinflip/pvp_coinflip.mjs";
|
|
6
|
-
import { BuildGameOptions } from "./types/build-game-transaction-options.type.mjs";
|
|
7
6
|
import { GameParameters, GetGameParametersOptions } from "./types/game-settings.type.mjs";
|
|
7
|
+
import { BuildGameOptions } from "./types/build-game-transaction-options.type.mjs";
|
|
8
8
|
import { BuildTransactionOptions, Transaction } from "@mysten/sui/transactions";
|
|
9
9
|
import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
|
|
10
10
|
import { InferBcsType } from "@mysten/bcs";
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;;;iBA+DgB,MAAA
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;;;;;;;;iBA+DgB,MAAA;EACf,IAAA;EACA,OAAA;EACA;AAAA,IACE,sBAAA,CAAuB,IAAA;;qBAGL,iBAAA,KAAoB,YAAA;AAAA;AAAA,cAW5B,YAAA;EAAA;;IAUX,MAAA;IACA,IAAA;IACA,OAAA;IACA;EAAA;IAEA,MAAA,EAAQ,iBAAA;IACR,IAAA;IACA,OAAA;IACA,QAAA;EAAA;EAjCD;;;;;;;;;EA8DA,SAAA,IAAa,YAAA;EAhEb;;;;;;;;;;;EA+EM,4BAAA,CACL,WAAA,EAAa,WAAA,EACb,OAAA,GAAU,IAAA,CAAK,uBAAA,cACb,OAAA;EA5EqC;;AAAY;AAWrD;;;;;;;;;;EAmFO,iBAAA,eAAgC,IAAA,EACrC,IAAA,EAAM,KAAA,EACN,OAAA,GAAS,wBAAA,GACP,OAAA,CAAQ,cAAA,CAAe,KAAA;EAtBf;;;;;;;;;;;;;;;;;;;;;EAsDL,mBAAA,CACL,OAAA,GAAS,gBAAA,CACR,IAAA,CAAK,cAAA,CAAe,wBAAA,iBAInB,OAAA,EAAS,YAAA,QAAoB,MAAA;IAAqB,SAAA;EAAA;;;;;;;;;;;EA4DrD,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqCU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAjGP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwFH,EAAA;;;;;;;;0CAQuC,YAAA,EAAY,MAAA,EACzC,MAAA,EAAM,OAAA,EACL,gBAAA,CAAiB,MAAA,MACxB,WAAA;;;;;;;;kDA2C2C,iBAAA,EAAiB,MAAA,EACtD,MAAA,EAAM,OAAA,EACL,kCAAA,CAAmC,MAAA,MAC1C,WAAA;EAAA;AAAA"}
|
package/dist/client.mjs
CHANGED
|
@@ -34,6 +34,98 @@ var SuigarClient = class {
|
|
|
34
34
|
#partner;
|
|
35
35
|
#cache;
|
|
36
36
|
constructor({ client, name, partner, cacheTtl }) {
|
|
37
|
+
this.bcs = {
|
|
38
|
+
/**
|
|
39
|
+
* Object representing the state of a PvP coinflip game, as stored on-chain.
|
|
40
|
+
*/
|
|
41
|
+
PvPCoinflipGame: Game,
|
|
42
|
+
/**
|
|
43
|
+
* Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
|
|
44
|
+
*/
|
|
45
|
+
BetResultEvent,
|
|
46
|
+
/**
|
|
47
|
+
* Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
|
|
48
|
+
*/
|
|
49
|
+
PvPCoinflipGameCreatedEvent: GameCreatedEvent,
|
|
50
|
+
/**
|
|
51
|
+
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
52
|
+
*/
|
|
53
|
+
PvPCoinflipGameResolvedEvent: GameResolvedEvent,
|
|
54
|
+
/**
|
|
55
|
+
* Event emitted when a PvP Coinflip game is cancelled.
|
|
56
|
+
*/
|
|
57
|
+
PvPCoinflipGameCancelledEvent: GameCancelledEvent
|
|
58
|
+
};
|
|
59
|
+
this.tx = {
|
|
60
|
+
/**
|
|
61
|
+
* Creates a standard game transaction for the provided game id.
|
|
62
|
+
*
|
|
63
|
+
* @param gameId Supported standard game identifier.
|
|
64
|
+
* @param options Transaction builder options for the selected game.
|
|
65
|
+
* @returns Prepared transaction for the selected game.
|
|
66
|
+
*/
|
|
67
|
+
createBetTransaction: (gameId, options) => {
|
|
68
|
+
switch (gameId) {
|
|
69
|
+
case "coinflip": return buildCoinflipTransaction({
|
|
70
|
+
...options,
|
|
71
|
+
config: this.#config,
|
|
72
|
+
partner: this.#partner
|
|
73
|
+
});
|
|
74
|
+
case "limbo": return buildLimboTransaction({
|
|
75
|
+
...options,
|
|
76
|
+
config: this.#config,
|
|
77
|
+
partner: this.#partner
|
|
78
|
+
});
|
|
79
|
+
case "plinko": return buildPlinkoTransaction({
|
|
80
|
+
...options,
|
|
81
|
+
config: this.#config,
|
|
82
|
+
partner: this.#partner
|
|
83
|
+
});
|
|
84
|
+
case "range": return buildRangeTransaction({
|
|
85
|
+
...options,
|
|
86
|
+
config: this.#config,
|
|
87
|
+
partner: this.#partner
|
|
88
|
+
});
|
|
89
|
+
case "wheel": return buildWheelTransaction({
|
|
90
|
+
...options,
|
|
91
|
+
config: this.#config,
|
|
92
|
+
partner: this.#partner
|
|
93
|
+
});
|
|
94
|
+
default: throw new RangeError(`Unsupported game: ${gameId}`);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* Creates a PvP coinflip transaction for the requested action.
|
|
99
|
+
*
|
|
100
|
+
* @param action PvP coinflip action to perform.
|
|
101
|
+
* @param options Transaction builder options for the selected action.
|
|
102
|
+
* @returns Prepared PvP coinflip transaction.
|
|
103
|
+
*/
|
|
104
|
+
createPvPCoinflipTransaction: (action, options) => {
|
|
105
|
+
switch (action) {
|
|
106
|
+
case "create": return buildPvPCoinflipTransaction("create", {
|
|
107
|
+
...options,
|
|
108
|
+
config: this.#config,
|
|
109
|
+
partner: this.#partner
|
|
110
|
+
});
|
|
111
|
+
case "join": {
|
|
112
|
+
const joinOptions = options;
|
|
113
|
+
return buildPvPCoinflipTransaction("join", {
|
|
114
|
+
...joinOptions,
|
|
115
|
+
betCoin: this.#createPvPCoinflipBetCoin(joinOptions),
|
|
116
|
+
config: this.#config,
|
|
117
|
+
partner: this.#partner
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
case "cancel": return buildPvPCoinflipTransaction("cancel", {
|
|
121
|
+
...options,
|
|
122
|
+
config: this.#config,
|
|
123
|
+
partner: this.#partner
|
|
124
|
+
});
|
|
125
|
+
default: throw new RangeError(`Unsupported PvP coinflip action: ${action}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
37
129
|
this.#client = client;
|
|
38
130
|
this.#partner = partner;
|
|
39
131
|
this.#cache = client.cache.scope("@suigar/sdk").readSync([name, "ttl-cache"], () => {
|
|
@@ -144,111 +236,6 @@ var SuigarClient = class {
|
|
|
144
236
|
}
|
|
145
237
|
return resolvedGames.flatMap((game) => game instanceof Error ? [] : [game]);
|
|
146
238
|
}
|
|
147
|
-
/**
|
|
148
|
-
* BCS struct constructors for decoding on-chain objects and events related to Suigar games.
|
|
149
|
-
*
|
|
150
|
-
* These can be used to parse the `content` field of on-chain objects and events into structured data with the
|
|
151
|
-
* expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP
|
|
152
|
-
* coinflip game object.
|
|
153
|
-
*
|
|
154
|
-
* Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction
|
|
155
|
-
* builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.
|
|
156
|
-
*/
|
|
157
|
-
bcs = {
|
|
158
|
-
/**
|
|
159
|
-
* Object representing the state of a PvP coinflip game, as stored on-chain.
|
|
160
|
-
*/
|
|
161
|
-
PvPCoinflipGame: Game,
|
|
162
|
-
/**
|
|
163
|
-
* Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.
|
|
164
|
-
*/
|
|
165
|
-
BetResultEvent,
|
|
166
|
-
/**
|
|
167
|
-
* Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.
|
|
168
|
-
*/
|
|
169
|
-
PvPCoinflipGameCreatedEvent: GameCreatedEvent,
|
|
170
|
-
/**
|
|
171
|
-
* Event emitted when a PvP Coinflip game is resolved, containing the final outcome.
|
|
172
|
-
*/
|
|
173
|
-
PvPCoinflipGameResolvedEvent: GameResolvedEvent,
|
|
174
|
-
/**
|
|
175
|
-
* Event emitted when a PvP Coinflip game is cancelled.
|
|
176
|
-
*/
|
|
177
|
-
PvPCoinflipGameCancelledEvent: GameCancelledEvent
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Transaction builders for Suigar games.
|
|
181
|
-
*/
|
|
182
|
-
tx = {
|
|
183
|
-
/**
|
|
184
|
-
* Creates a standard game transaction for the provided game id.
|
|
185
|
-
*
|
|
186
|
-
* @param gameId Supported standard game identifier.
|
|
187
|
-
* @param options Transaction builder options for the selected game.
|
|
188
|
-
* @returns Prepared transaction for the selected game.
|
|
189
|
-
*/
|
|
190
|
-
createBetTransaction: (gameId, options) => {
|
|
191
|
-
switch (gameId) {
|
|
192
|
-
case "coinflip": return buildCoinflipTransaction({
|
|
193
|
-
...options,
|
|
194
|
-
config: this.#config,
|
|
195
|
-
partner: this.#partner
|
|
196
|
-
});
|
|
197
|
-
case "limbo": return buildLimboTransaction({
|
|
198
|
-
...options,
|
|
199
|
-
config: this.#config,
|
|
200
|
-
partner: this.#partner
|
|
201
|
-
});
|
|
202
|
-
case "plinko": return buildPlinkoTransaction({
|
|
203
|
-
...options,
|
|
204
|
-
config: this.#config,
|
|
205
|
-
partner: this.#partner
|
|
206
|
-
});
|
|
207
|
-
case "range": return buildRangeTransaction({
|
|
208
|
-
...options,
|
|
209
|
-
config: this.#config,
|
|
210
|
-
partner: this.#partner
|
|
211
|
-
});
|
|
212
|
-
case "wheel": return buildWheelTransaction({
|
|
213
|
-
...options,
|
|
214
|
-
config: this.#config,
|
|
215
|
-
partner: this.#partner
|
|
216
|
-
});
|
|
217
|
-
default: throw new RangeError(`Unsupported game: ${gameId}`);
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
/**
|
|
221
|
-
* Creates a PvP coinflip transaction for the requested action.
|
|
222
|
-
*
|
|
223
|
-
* @param action PvP coinflip action to perform.
|
|
224
|
-
* @param options Transaction builder options for the selected action.
|
|
225
|
-
* @returns Prepared PvP coinflip transaction.
|
|
226
|
-
*/
|
|
227
|
-
createPvPCoinflipTransaction: (action, options) => {
|
|
228
|
-
switch (action) {
|
|
229
|
-
case "create": return buildPvPCoinflipTransaction("create", {
|
|
230
|
-
...options,
|
|
231
|
-
config: this.#config,
|
|
232
|
-
partner: this.#partner
|
|
233
|
-
});
|
|
234
|
-
case "join": {
|
|
235
|
-
const joinOptions = options;
|
|
236
|
-
return buildPvPCoinflipTransaction("join", {
|
|
237
|
-
...joinOptions,
|
|
238
|
-
betCoin: this.#createPvPCoinflipBetCoin(joinOptions),
|
|
239
|
-
config: this.#config,
|
|
240
|
-
partner: this.#partner
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
case "cancel": return buildPvPCoinflipTransaction("cancel", {
|
|
244
|
-
...options,
|
|
245
|
-
config: this.#config,
|
|
246
|
-
partner: this.#partner
|
|
247
|
-
});
|
|
248
|
-
default: throw new RangeError(`Unsupported PvP coinflip action: ${action}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
239
|
#createPvPCoinflipBetCoin(options) {
|
|
253
240
|
return async (tx) => {
|
|
254
241
|
const { json } = await Game.get({
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["#client","#partner","#cache","#config","#fetchGameParameters","PvPCoinflipGame","#createPvPCoinflipBetCoin"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport {\n\tBuildTransactionOptions,\n\tTransaction,\n\tTransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, toBase64 } from '@mysten/sui/utils';\nimport { BetResultEvent } from './contracts/core/core';\nimport { TypeName } from './contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name';\nimport {\n\tGame as PvPCoinflipGame,\n\tGameCancelledEvent as PvPCoinflipGameCancelledEvent,\n\tGameCreatedEvent as PvPCoinflipGameCreatedEvent,\n\tGameResolvedEvent as PvPCoinflipGameResolvedEvent,\n} from './contracts/pvp-coinflip/pvp_coinflip';\nimport {\n\tDEFAULT_CACHE_TTL_MS,\n\tresolveCoinTypeNameForTypeNameKey,\n\tresolveGamePackageId,\n\tresolveGameSettingsKeyType,\n\tresolveSuigarConfig,\n} from './helpers/index.js';\nimport {\n\tbuildCoinflipTransaction,\n\tbuildLimboTransaction,\n\tbuildPlinkoTransaction,\n\tbuildPvPCoinflipTransaction,\n\tbuildRangeTransaction,\n\tbuildWheelTransaction,\n} from './transactions';\nimport { TtlClientCache } from './ttl-cache.js';\nimport {\n\tBuildCancelPvPCoinflipTransactionOptions,\n\tBuildCoinflipTransactionOptions,\n\tBuildCreatePvPCoinflipTransactionOptions,\n\tBuildGameOptions,\n\tBuildJoinPvPCoinflipTransactionOptions,\n\tBuildLimboTransactionOptions,\n\tBuildPlinkoTransactionOptions,\n\tBuildPvPCoinflipTransactionOptions,\n\tBuildRangeTransactionOptions,\n\tBuildWheelTransactionOptions,\n\tGame,\n\tPvPCoinflipAction,\n\tStandardGame,\n\tSuigarConfig,\n\tSuigarExtensionOptions,\n\tSuiNetwork,\n\tSUPPORTED_SUI_NETWORKS,\n\tWithPartner,\n\tWithThrowOnError,\n} from './types';\nimport {\n\tGAME_SETTINGS,\n\ttype GameParameters,\n\ttype GetGameParametersOptions,\n} from './types/game-settings.type.js';\nimport { parseCoinType } from './utils/index.js';\n\nexport function suigar<const Name = 'suigar'>({\n\tname = 'suigar' as Name,\n\tpartner,\n\tcacheTtl,\n}: SuigarExtensionOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi): SuigarClient => {\n\t\t\treturn new SuigarClient({\n\t\t\t\tclient,\n\t\t\t\tname: String(name),\n\t\t\t\tpartner,\n\t\t\t\tcacheTtl,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport class SuigarClient {\n\t#client: ClientWithCoreApi;\n\n\t#config: SuigarConfig;\n\n\t#partner: string | undefined;\n\n\t#cache: TtlClientCache;\n\n\tconstructor({\n\t\tclient,\n\t\tname,\n\t\tpartner,\n\t\tcacheTtl,\n\t}: {\n\t\tclient: ClientWithCoreApi;\n\t\tname: string;\n\t\tpartner?: string;\n\t\tcacheTtl?: number;\n\t}) {\n\t\tthis.#client = client;\n\t\tthis.#partner = partner;\n\t\tthis.#cache = client.cache\n\t\t\t.scope('@suigar/sdk')\n\t\t\t.readSync([name, 'ttl-cache'], () => {\n\t\t\t\treturn new TtlClientCache({\n\t\t\t\t\tttlMs: cacheTtl ?? DEFAULT_CACHE_TTL_MS,\n\t\t\t\t});\n\t\t\t});\n\n\t\tconst network = this.#client.network as SuiNetwork;\n\t\tif (!SUPPORTED_SUI_NETWORKS.includes(network)) {\n\t\t\tthrow new RangeError(`Unsupported network: ${network}`);\n\t\t}\n\n\t\tthis.#config = resolveSuigarConfig(network);\n\t}\n\n\t/**\n\t * Returns the resolved SDK configuration for the connected network.\n\t *\n\t * This is primarily useful for debugging or inspecting which package ids,\n\t * registry ids, supported coin types, and price info object ids the SDK\n\t * resolved for the current client network.\n\t *\n\t * @returns Network-resolved Suigar configuration.\n\t */\n\tgetConfig(): SuigarConfig {\n\t\treturn this.#config;\n\t}\n\n\t/**\n\t * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.\n\t *\n\t * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string\n\t * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard\n\t * transaction build options except for `client`.\n\t *\n\t * @param transaction Transaction to build and serialize.\n\t * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.\n\t * @returns Base64-encoded transaction bytes ready to send over the wire.\n\t */\n\tasync serializeTransactionToBase64(\n\t\ttransaction: Transaction,\n\t\toptions?: Omit<BuildTransactionOptions, 'client'>,\n\t): Promise<string> {\n\t\tconst bytes = await transaction.build({ ...options, client: this.#client });\n\t\treturn toBase64(bytes);\n\t}\n\n\t/**\n\t * Reads on-chain game parameters for the requested game.\n\t *\n\t * The SDK first reads the selected game's settings object from SweetHouse,\n\t * then reads that game's coin-specific `Parameters<T>` object. Results are\n\t * cached according to the extension `cacheTtl` option. Pass\n\t * `ignoreCache: true` to refresh the on-chain read and replace the cached\n\t * value.\n\t *\n\t * @param game Game whose parameters should be loaded.\n\t * @param options Optional coin type, cache override, and abort signal.\n\t * @returns Parsed game parameters typed for the requested game.\n\t */\n\tasync getGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\toptions: GetGameParametersOptions = {},\n\t): Promise<GameParameters<TGame>> {\n\t\tconst coinType = normalizeStructTag(\n\t\t\toptions.coinType ?? this.#config.coinTypes.sui,\n\t\t);\n\t\treturn this.#cache.read(\n\t\t\t['parameters', this.#client.network, game, coinType],\n\t\t\t() => this.#fetchGameParameters(game, coinType, options.signal),\n\t\t\t{ ignoreCache: options.ignoreCache },\n\t\t) as Promise<GameParameters<TGame>>;\n\t}\n\n\t/**\n\t * Lists unresolved PvP coinflip games from the configured registry and resolves\n\t * each entry into parsed on-chain game state.\n\t *\n\t * This fetches dynamic fields from the PvP coinflip registry object, then bulk\n\t * loads the referenced game objects through `client.core.getObjects()`. Registry\n\t * membership is the unresolved-state signal: when a game is joined and resolved,\n\t * the Move flow removes it from the registry and deletes the live `Game` object.\n\t * Use this when a product needs the current set of open PvP coinflip matches for\n\t * browsing or lobby views.\n\t *\n\t * @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.\n\t * Supported options such as `limit`, `cursor`, and `signal` are forwarded to the\n\t * underlying lookup calls. Pass `throwOnError: true` to fail the whole lookup\n\t * when any referenced game object cannot be fetched or parsed. By default,\n\t * failed per-object lookups are skipped and only successfully parsed unresolved\n\t * games are returned.\n\t * @returns Parsed unresolved PvP coinflip game objects for the requested\n\t * registry page. When `throwOnError` is `false`, entries that fail object fetch\n\t * or parse are omitted from the returned array.\n\t */\n\tasync getPvPCoinflipGames(\n\t\toptions: WithThrowOnError<\n\t\t\tOmit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>\n\t\t> = {\n\t\t\tlimit: 50,\n\t\t},\n\t): Promise<(InferBcsType<typeof PvPCoinflipGame> & { coin_type: string })[]> {\n\t\tconst { throwOnError = false, ...listOptions } = options;\n\t\tconst { dynamicFields } = await this.#client.core.listDynamicFields({\n\t\t\t...listOptions,\n\t\t\tparentId: this.#config.registryIds.pvpCoinflip,\n\t\t});\n\n\t\tconst { objects } = await this.#client.core.getObjects({\n\t\t\tobjectIds: dynamicFields.map(({ childId }) => childId!),\n\t\t\tsignal: listOptions.signal,\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t});\n\n\t\tconst resolvedGames = objects.map((object) => {\n\t\t\ttry {\n\t\t\t\tif (object instanceof Error) {\n\t\t\t\t\tthrow object;\n\t\t\t\t}\n\n\t\t\t\tif (!object.content) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unable to resolve PvP coinflip game from retrieved object',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...PvPCoinflipGame.parse(object.content),\n\t\t\t\t\tcoin_type: parseCoinType(object.type),\n\t\t\t\t} satisfies Awaited<\n\t\t\t\t\tReturnType<SuigarClient['getPvPCoinflipGames']>\n\t\t\t\t>[number];\n\t\t\t} catch (error) {\n\t\t\t\treturn error instanceof Error ? error : new Error(String(error));\n\t\t\t}\n\t\t});\n\n\t\tif (throwOnError) {\n\t\t\tconst firstError = resolvedGames.find((game) => game instanceof Error);\n\t\t\tif (firstError) {\n\t\t\t\tthrow firstError;\n\t\t\t}\n\t\t}\n\n\t\treturn resolvedGames.flatMap((game) =>\n\t\t\tgame instanceof Error ? [] : [game],\n\t\t);\n\t}\n\n\t/**\n\t * BCS struct constructors for decoding on-chain objects and events related to Suigar games.\n\t *\n\t * These can be used to parse the `content` field of on-chain objects and events into structured data with the\n\t * expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP\n\t * coinflip game object.\n\t *\n\t * Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction\n\t * builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.\n\t */\n\tbcs = {\n\t\t// Objects\n\t\t/**\n\t\t * Object representing the state of a PvP coinflip game, as stored on-chain.\n\t\t */\n\t\tPvPCoinflipGame,\n\t\t// Events\n\t\t/**\n\t\t * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.\n\t\t */\n\t\tBetResultEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.\n\t\t */\n\t\tPvPCoinflipGameCreatedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.\n\t\t */\n\t\tPvPCoinflipGameResolvedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is cancelled.\n\t\t */\n\t\tPvPCoinflipGameCancelledEvent,\n\t};\n\n\t/**\n\t * Transaction builders for Suigar games.\n\t */\n\ttx = {\n\t\t/**\n\t\t * Creates a standard game transaction for the provided game id.\n\t\t *\n\t\t * @param gameId Supported standard game identifier.\n\t\t * @param options Transaction builder options for the selected game.\n\t\t * @returns Prepared transaction for the selected game.\n\t\t */\n\t\tcreateBetTransaction: <GameId extends StandardGame>(\n\t\t\tgameId: GameId,\n\t\t\toptions: BuildGameOptions<GameId>,\n\t\t): Transaction => {\n\t\t\tswitch (gameId) {\n\t\t\t\tcase 'coinflip':\n\t\t\t\t\treturn buildCoinflipTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildCoinflipTransactionOptions>);\n\t\t\t\tcase 'limbo':\n\t\t\t\t\treturn buildLimboTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildLimboTransactionOptions>);\n\t\t\t\tcase 'plinko':\n\t\t\t\t\treturn buildPlinkoTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildPlinkoTransactionOptions>);\n\t\t\t\tcase 'range':\n\t\t\t\t\treturn buildRangeTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildRangeTransactionOptions>);\n\t\t\t\tcase 'wheel':\n\t\t\t\t\treturn buildWheelTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildWheelTransactionOptions>);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported game: ${gameId}`);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Creates a PvP coinflip transaction for the requested action.\n\t\t *\n\t\t * @param action PvP coinflip action to perform.\n\t\t * @param options Transaction builder options for the selected action.\n\t\t * @returns Prepared PvP coinflip transaction.\n\t\t */\n\t\tcreatePvPCoinflipTransaction: <Action extends PvPCoinflipAction>(\n\t\t\taction: Action,\n\t\t\toptions: BuildPvPCoinflipTransactionOptions<Action>,\n\t\t): Transaction => {\n\t\t\tswitch (action) {\n\t\t\t\tcase 'create':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('create', {\n\t\t\t\t\t\t...(options as BuildCreatePvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tcase 'join': {\n\t\t\t\t\tconst joinOptions = options as BuildJoinPvPCoinflipTransactionOptions;\n\t\t\t\t\treturn buildPvPCoinflipTransaction('join', {\n\t\t\t\t\t\t...joinOptions,\n\t\t\t\t\t\tbetCoin: this.#createPvPCoinflipBetCoin(joinOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcase 'cancel':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('cancel', {\n\t\t\t\t\t\t...(options as BuildCancelPvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported PvP coinflip action: ${action}`);\n\t\t\t}\n\t\t},\n\t};\n\n\t#createPvPCoinflipBetCoin(\n\t\toptions: BuildJoinPvPCoinflipTransactionOptions,\n\t): (tx: Transaction) => Promise<TransactionResult> {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst { json } = await PvPCoinflipGame.get({\n\t\t\t\tclient: this.#client,\n\t\t\t\tobjectId: options.gameId,\n\t\t\t});\n\n\t\t\treturn tx.coin({\n\t\t\t\ttype: options.coinType,\n\t\t\t\tbalance: BigInt(json.stake_per_player),\n\t\t\t\tuseGasCoin: options.allowGasCoinShortcut,\n\t\t\t});\n\t\t};\n\t}\n\n\tasync #fetchGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\tcoinType: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GameParameters<TGame>> {\n\t\tconst gameDefinition = GAME_SETTINGS[game];\n\n\t\tconst { object: settingsObject } =\n\t\t\tawait this.#client.core.getDynamicObjectField({\n\t\t\t\tparentId: this.#config.packageIds.sweetHouse,\n\t\t\t\tname: {\n\t\t\t\t\ttype: resolveGameSettingsKeyType(\n\t\t\t\t\t\tgameDefinition.settingsKey.name,\n\t\t\t\t\t\tresolveGamePackageId(this.#config, game),\n\t\t\t\t\t),\n\t\t\t\t\tbcs: gameDefinition.settingsKey\n\t\t\t\t\t\t.serialize({ dummy_field: false })\n\t\t\t\t\t\t.toBytes(),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\tconst { object } = await this.#client.core.getDynamicObjectField({\n\t\t\tparentId: settingsObject.objectId,\n\t\t\tname: {\n\t\t\t\ttype: TypeName.name,\n\t\t\t\tbcs: TypeName.serialize({\n\t\t\t\t\tname: resolveCoinTypeNameForTypeNameKey(coinType),\n\t\t\t\t}).toBytes(),\n\t\t\t},\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t\tsignal,\n\t\t});\n\n\t\tif (!object?.content) {\n\t\t\tthrow new Error(\n\t\t\t\t`Missing parameters object content for ${game} and coin type ${coinType}`,\n\t\t\t);\n\t\t}\n\n\t\treturn gameDefinition.parameters.parse(\n\t\t\tobject.content,\n\t\t) as GameParameters<TGame>;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+DA,SAAgB,OAA8B,EAC7C,OAAO,UACP,SACA,aACiC,CAAC,GAAG;CACrC,OAAO;EACN;EACA,WAAW,WAA4C;GACtD,OAAO,IAAI,aAAa;IACvB;IACA,MAAM,OAAO,IAAI;IACjB;IACA;GACD,CAAC;EACF;CACD;AACD;AAEA,IAAa,eAAb,MAA0B;CACzB;CAEA;CAEA;CAEA;CAEA,YAAY,EACX,QACA,MACA,SACA,YAME;EACF,KAAKA,UAAU;EACf,KAAKC,WAAW;EAChB,KAAKC,SAAS,OAAO,MACnB,MAAM,aAAa,EACnB,SAAS,CAAC,MAAM,WAAW,SAAS;GACpC,OAAO,IAAI,eAAe,EACzB,OAAO,YAAA,KACR,CAAC;EACF,CAAC;EAEF,MAAM,UAAU,KAAKF,QAAQ;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KAAKH;MACb,SAAS,KAAKF;KACf,CAAC;IACF;IACA,KAAK,UACJ,OAAO,4BAA4B,UAAU;KAC5C,GAAI;KACJ,QAAQ,KAAKE;KACb,SAAS,KAAKF;IACf,CAAC;IACF,SACC,MAAM,IAAI,WAAW,oCAAoC,QAAQ;GACnE;EACD;CACD;CAEA,0BACC,SACkD;EAClD,OAAO,OAAO,OAAoB;GACjC,MAAM,EAAE,SAAS,MAAMI,KAAgB,IAAI;IAC1C,QAAQ,KAAKL;IACb,UAAU,QAAQ;GACnB,CAAC;GAED,OAAO,GAAG,KAAK;IACd,MAAM,QAAQ;IACd,SAAS,OAAO,KAAK,gBAAgB;IACrC,YAAY,QAAQ;GACrB,CAAC;EACF;CACD;CAEA,MAAMI,qBACL,MACA,UACA,QACiC;EACjC,MAAM,iBAAiB,cAAc;EAErC,MAAM,EAAE,QAAQ,mBACf,MAAM,KAAKJ,QAAQ,KAAK,sBAAsB;GAC7C,UAAU,KAAKG,QAAQ,WAAW;GAClC,MAAM;IACL,MAAM,2BACL,eAAe,YAAY,MAC3B,qBAAqB,KAAKA,SAAS,IAAI,CACxC;IACA,KAAK,eAAe,YAClB,UAAU,EAAE,aAAa,MAAM,CAAC,EAChC,QAAQ;GACX;GACA;EACD,CAAC;EAEF,MAAM,EAAE,WAAW,MAAM,KAAKH,QAAQ,KAAK,sBAAsB;GAChE,UAAU,eAAe;GACzB,MAAM;IACL,MAAM,SAAS;IACf,KAAK,SAAS,UAAU,EACvB,MAAM,kCAAkC,QAAQ,EACjD,CAAC,EAAE,QAAQ;GACZ;GACA,SAAS,EACR,SAAS,KACV;GACA;EACD,CAAC;EAED,IAAI,CAAC,QAAQ,SACZ,MAAM,IAAI,MACT,yCAAyC,KAAK,iBAAiB,UAChE;EAGD,OAAO,eAAe,WAAW,MAChC,OAAO,OACR;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":["#config","#partner","#createPvPCoinflipBetCoin","#client","#cache","#fetchGameParameters","PvPCoinflipGame"],"sources":["../src/client.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferBcsType } from '@mysten/bcs';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport {\n\tBuildTransactionOptions,\n\tTransaction,\n\tTransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, toBase64 } from '@mysten/sui/utils';\nimport { BetResultEvent } from './contracts/core/core.js';\nimport { TypeName } from './contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.js';\nimport {\n\tGame as PvPCoinflipGame,\n\tGameCancelledEvent as PvPCoinflipGameCancelledEvent,\n\tGameCreatedEvent as PvPCoinflipGameCreatedEvent,\n\tGameResolvedEvent as PvPCoinflipGameResolvedEvent,\n} from './contracts/pvp-coinflip/pvp_coinflip.js';\nimport {\n\tDEFAULT_CACHE_TTL_MS,\n\tresolveCoinTypeNameForTypeNameKey,\n\tresolveGamePackageId,\n\tresolveGameSettingsKeyType,\n\tresolveSuigarConfig,\n} from './helpers/index.js';\nimport {\n\tbuildCoinflipTransaction,\n\tbuildLimboTransaction,\n\tbuildPlinkoTransaction,\n\tbuildPvPCoinflipTransaction,\n\tbuildRangeTransaction,\n\tbuildWheelTransaction,\n} from './transactions/index.js';\nimport { TtlClientCache } from './ttl-cache.js';\nimport {\n\tGAME_SETTINGS,\n\ttype GameParameters,\n\ttype GetGameParametersOptions,\n} from './types/game-settings.type.js';\nimport {\n\tBuildCancelPvPCoinflipTransactionOptions,\n\tBuildCoinflipTransactionOptions,\n\tBuildCreatePvPCoinflipTransactionOptions,\n\tBuildGameOptions,\n\tBuildJoinPvPCoinflipTransactionOptions,\n\tBuildLimboTransactionOptions,\n\tBuildPlinkoTransactionOptions,\n\tBuildPvPCoinflipTransactionOptions,\n\tBuildRangeTransactionOptions,\n\tBuildWheelTransactionOptions,\n\tGame,\n\tPvPCoinflipAction,\n\tStandardGame,\n\tSuigarConfig,\n\tSuigarExtensionOptions,\n\tSuiNetwork,\n\tSUPPORTED_SUI_NETWORKS,\n\tWithPartner,\n\tWithThrowOnError,\n} from './types/index.js';\nimport { parseCoinType } from './utils/index.js';\n\nexport function suigar<const Name = 'suigar'>({\n\tname = 'suigar' as Name,\n\tpartner,\n\tcacheTtl,\n}: SuigarExtensionOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi): SuigarClient => {\n\t\t\treturn new SuigarClient({\n\t\t\t\tclient,\n\t\t\t\tname: String(name),\n\t\t\t\tpartner,\n\t\t\t\tcacheTtl,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport class SuigarClient {\n\t#client: ClientWithCoreApi;\n\n\t#config: SuigarConfig;\n\n\t#partner: string | undefined;\n\n\t#cache: TtlClientCache;\n\n\tconstructor({\n\t\tclient,\n\t\tname,\n\t\tpartner,\n\t\tcacheTtl,\n\t}: {\n\t\tclient: ClientWithCoreApi;\n\t\tname: string;\n\t\tpartner?: string;\n\t\tcacheTtl?: number;\n\t}) {\n\t\tthis.#client = client;\n\t\tthis.#partner = partner;\n\t\tthis.#cache = client.cache\n\t\t\t.scope('@suigar/sdk')\n\t\t\t.readSync([name, 'ttl-cache'], () => {\n\t\t\t\treturn new TtlClientCache({\n\t\t\t\t\tttlMs: cacheTtl ?? DEFAULT_CACHE_TTL_MS,\n\t\t\t\t});\n\t\t\t});\n\n\t\tconst network = this.#client.network as SuiNetwork;\n\t\tif (!SUPPORTED_SUI_NETWORKS.includes(network)) {\n\t\t\tthrow new RangeError(`Unsupported network: ${network}`);\n\t\t}\n\n\t\tthis.#config = resolveSuigarConfig(network);\n\t}\n\n\t/**\n\t * Returns the resolved SDK configuration for the connected network.\n\t *\n\t * This is primarily useful for debugging or inspecting which package ids,\n\t * registry ids, supported coin types, and price info object ids the SDK\n\t * resolved for the current client network.\n\t *\n\t * @returns Network-resolved Suigar configuration.\n\t */\n\tgetConfig(): SuigarConfig {\n\t\treturn this.#config;\n\t}\n\n\t/**\n\t * Builds a transaction with the configured Sui client and encodes the resulting BCS bytes as base64.\n\t *\n\t * Use this when an external wallet, API, or transport expects the built transaction payload as a base64 string\n\t * instead of raw bytes. The SDK always injects the configured Sui client, so `options` accepts the standard\n\t * transaction build options except for `client`.\n\t *\n\t * @param transaction Transaction to build and serialize.\n\t * @param options Optional transaction build options forwarded to `transaction.build()`, excluding `client`.\n\t * @returns Base64-encoded transaction bytes ready to send over the wire.\n\t */\n\tasync serializeTransactionToBase64(\n\t\ttransaction: Transaction,\n\t\toptions?: Omit<BuildTransactionOptions, 'client'>,\n\t): Promise<string> {\n\t\tconst bytes = await transaction.build({ ...options, client: this.#client });\n\t\treturn toBase64(bytes);\n\t}\n\n\t/**\n\t * Reads on-chain game parameters for the requested game.\n\t *\n\t * The SDK first reads the selected game's settings object from SweetHouse,\n\t * then reads that game's coin-specific `Parameters<T>` object. Results are\n\t * cached according to the extension `cacheTtl` option. Pass\n\t * `ignoreCache: true` to refresh the on-chain read and replace the cached\n\t * value.\n\t *\n\t * @param game Game whose parameters should be loaded.\n\t * @param options Optional coin type, cache override, and abort signal.\n\t * @returns Parsed game parameters typed for the requested game.\n\t */\n\tasync getGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\toptions: GetGameParametersOptions = {},\n\t): Promise<GameParameters<TGame>> {\n\t\tconst coinType = normalizeStructTag(\n\t\t\toptions.coinType ?? this.#config.coinTypes.sui,\n\t\t);\n\t\treturn this.#cache.read(\n\t\t\t['parameters', this.#client.network, game, coinType],\n\t\t\t() => this.#fetchGameParameters(game, coinType, options.signal),\n\t\t\t{ ignoreCache: options.ignoreCache },\n\t\t) as Promise<GameParameters<TGame>>;\n\t}\n\n\t/**\n\t * Lists unresolved PvP coinflip games from the configured registry and resolves\n\t * each entry into parsed on-chain game state.\n\t *\n\t * This fetches dynamic fields from the PvP coinflip registry object, then bulk\n\t * loads the referenced game objects through `client.core.getObjects()`. Registry\n\t * membership is the unresolved-state signal: when a game is joined and resolved,\n\t * the Move flow removes it from the registry and deletes the live `Game` object.\n\t * Use this when a product needs the current set of open PvP coinflip matches for\n\t * browsing or lobby views.\n\t *\n\t * @param options Optional dynamic field pagination forwarded to `listDynamicFields()`, excluding `parentId`.\n\t * Supported options such as `limit`, `cursor`, and `signal` are forwarded to the\n\t * underlying lookup calls. Pass `throwOnError: true` to fail the whole lookup\n\t * when any referenced game object cannot be fetched or parsed. By default,\n\t * failed per-object lookups are skipped and only successfully parsed unresolved\n\t * games are returned.\n\t * @returns Parsed unresolved PvP coinflip game objects for the requested\n\t * registry page. When `throwOnError` is `false`, entries that fail object fetch\n\t * or parse are omitted from the returned array.\n\t */\n\tasync getPvPCoinflipGames(\n\t\toptions: WithThrowOnError<\n\t\t\tOmit<SuiClientTypes.ListDynamicFieldsOptions, 'parentId'>\n\t\t> = {\n\t\t\tlimit: 50,\n\t\t},\n\t): Promise<(InferBcsType<typeof PvPCoinflipGame> & { coin_type: string })[]> {\n\t\tconst { throwOnError = false, ...listOptions } = options;\n\t\tconst { dynamicFields } = await this.#client.core.listDynamicFields({\n\t\t\t...listOptions,\n\t\t\tparentId: this.#config.registryIds.pvpCoinflip,\n\t\t});\n\n\t\tconst { objects } = await this.#client.core.getObjects({\n\t\t\tobjectIds: dynamicFields.map(({ childId }) => childId!),\n\t\t\tsignal: listOptions.signal,\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t});\n\n\t\tconst resolvedGames = objects.map((object) => {\n\t\t\ttry {\n\t\t\t\tif (object instanceof Error) {\n\t\t\t\t\tthrow object;\n\t\t\t\t}\n\n\t\t\t\tif (!object.content) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unable to resolve PvP coinflip game from retrieved object',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...PvPCoinflipGame.parse(object.content),\n\t\t\t\t\tcoin_type: parseCoinType(object.type),\n\t\t\t\t} satisfies Awaited<\n\t\t\t\t\tReturnType<SuigarClient['getPvPCoinflipGames']>\n\t\t\t\t>[number];\n\t\t\t} catch (error) {\n\t\t\t\treturn error instanceof Error ? error : new Error(String(error));\n\t\t\t}\n\t\t});\n\n\t\tif (throwOnError) {\n\t\t\tconst firstError = resolvedGames.find((game) => game instanceof Error);\n\t\t\tif (firstError) {\n\t\t\t\tthrow firstError;\n\t\t\t}\n\t\t}\n\n\t\treturn resolvedGames.flatMap((game) =>\n\t\t\tgame instanceof Error ? [] : [game],\n\t\t);\n\t}\n\n\t/**\n\t * BCS struct constructors for decoding on-chain objects and events related to Suigar games.\n\t *\n\t * These can be used to parse the `content` field of on-chain objects and events into structured data with the\n\t * expected types. For example, use `client.suigar.bcs.PvPCoinflipGame.parse(object.content)` to decode a PvP\n\t * coinflip game object.\n\t *\n\t * Note that these constructors are not meant for encoding transaction arguments, as the SDK's transaction\n\t * builders handle argument serialization internally. Use these primarily for decoding and parsing on-chain data.\n\t */\n\tbcs = {\n\t\t// Objects\n\t\t/**\n\t\t * Object representing the state of a PvP coinflip game, as stored on-chain.\n\t\t */\n\t\tPvPCoinflipGame,\n\t\t// Events\n\t\t/**\n\t\t * Event emitted at the end of a standard game (e.g., Coinflip, Limbo), containing the result and payout information.\n\t\t */\n\t\tBetResultEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is created, containing the game configuration and initial state.\n\t\t */\n\t\tPvPCoinflipGameCreatedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is resolved, containing the final outcome.\n\t\t */\n\t\tPvPCoinflipGameResolvedEvent,\n\t\t/**\n\t\t * Event emitted when a PvP Coinflip game is cancelled.\n\t\t */\n\t\tPvPCoinflipGameCancelledEvent,\n\t};\n\n\t/**\n\t * Transaction builders for Suigar games.\n\t */\n\ttx = {\n\t\t/**\n\t\t * Creates a standard game transaction for the provided game id.\n\t\t *\n\t\t * @param gameId Supported standard game identifier.\n\t\t * @param options Transaction builder options for the selected game.\n\t\t * @returns Prepared transaction for the selected game.\n\t\t */\n\t\tcreateBetTransaction: <GameId extends StandardGame>(\n\t\t\tgameId: GameId,\n\t\t\toptions: BuildGameOptions<GameId>,\n\t\t): Transaction => {\n\t\t\tswitch (gameId) {\n\t\t\t\tcase 'coinflip':\n\t\t\t\t\treturn buildCoinflipTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildCoinflipTransactionOptions>);\n\t\t\t\tcase 'limbo':\n\t\t\t\t\treturn buildLimboTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildLimboTransactionOptions>);\n\t\t\t\tcase 'plinko':\n\t\t\t\t\treturn buildPlinkoTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildPlinkoTransactionOptions>);\n\t\t\t\tcase 'range':\n\t\t\t\t\treturn buildRangeTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildRangeTransactionOptions>);\n\t\t\t\tcase 'wheel':\n\t\t\t\t\treturn buildWheelTransaction({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t} as WithPartner<BuildWheelTransactionOptions>);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported game: ${gameId}`);\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Creates a PvP coinflip transaction for the requested action.\n\t\t *\n\t\t * @param action PvP coinflip action to perform.\n\t\t * @param options Transaction builder options for the selected action.\n\t\t * @returns Prepared PvP coinflip transaction.\n\t\t */\n\t\tcreatePvPCoinflipTransaction: <Action extends PvPCoinflipAction>(\n\t\t\taction: Action,\n\t\t\toptions: BuildPvPCoinflipTransactionOptions<Action>,\n\t\t): Transaction => {\n\t\t\tswitch (action) {\n\t\t\t\tcase 'create':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('create', {\n\t\t\t\t\t\t...(options as BuildCreatePvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tcase 'join': {\n\t\t\t\t\tconst joinOptions = options as BuildJoinPvPCoinflipTransactionOptions;\n\t\t\t\t\treturn buildPvPCoinflipTransaction('join', {\n\t\t\t\t\t\t...joinOptions,\n\t\t\t\t\t\tbetCoin: this.#createPvPCoinflipBetCoin(joinOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcase 'cancel':\n\t\t\t\t\treturn buildPvPCoinflipTransaction('cancel', {\n\t\t\t\t\t\t...(options as BuildCancelPvPCoinflipTransactionOptions),\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\tpartner: this.#partner,\n\t\t\t\t\t});\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RangeError(`Unsupported PvP coinflip action: ${action}`);\n\t\t\t}\n\t\t},\n\t};\n\n\t#createPvPCoinflipBetCoin(\n\t\toptions: BuildJoinPvPCoinflipTransactionOptions,\n\t): (tx: Transaction) => Promise<TransactionResult> {\n\t\treturn async (tx: Transaction) => {\n\t\t\tconst { json } = await PvPCoinflipGame.get({\n\t\t\t\tclient: this.#client,\n\t\t\t\tobjectId: options.gameId,\n\t\t\t});\n\n\t\t\treturn tx.coin({\n\t\t\t\ttype: options.coinType,\n\t\t\t\tbalance: BigInt(json.stake_per_player),\n\t\t\t\tuseGasCoin: options.allowGasCoinShortcut,\n\t\t\t});\n\t\t};\n\t}\n\n\tasync #fetchGameParameters<TGame extends Game>(\n\t\tgame: TGame,\n\t\tcoinType: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GameParameters<TGame>> {\n\t\tconst gameDefinition = GAME_SETTINGS[game];\n\n\t\tconst { object: settingsObject } =\n\t\t\tawait this.#client.core.getDynamicObjectField({\n\t\t\t\tparentId: this.#config.packageIds.sweetHouse,\n\t\t\t\tname: {\n\t\t\t\t\ttype: resolveGameSettingsKeyType(\n\t\t\t\t\t\tgameDefinition.settingsKey.name,\n\t\t\t\t\t\tresolveGamePackageId(this.#config, game),\n\t\t\t\t\t),\n\t\t\t\t\tbcs: gameDefinition.settingsKey\n\t\t\t\t\t\t.serialize({ dummy_field: false })\n\t\t\t\t\t\t.toBytes(),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t});\n\n\t\tconst { object } = await this.#client.core.getDynamicObjectField({\n\t\t\tparentId: settingsObject.objectId,\n\t\t\tname: {\n\t\t\t\ttype: TypeName.name,\n\t\t\t\tbcs: TypeName.serialize({\n\t\t\t\t\tname: resolveCoinTypeNameForTypeNameKey(coinType),\n\t\t\t\t}).toBytes(),\n\t\t\t},\n\t\t\tinclude: {\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t\tsignal,\n\t\t});\n\n\t\tif (!object?.content) {\n\t\t\tthrow new Error(\n\t\t\t\t`Missing parameters object content for ${game} and coin type ${coinType}`,\n\t\t\t);\n\t\t}\n\n\t\treturn gameDefinition.parameters.parse(\n\t\t\tobject.content,\n\t\t) as GameParameters<TGame>;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+DA,SAAgB,OAA8B,EAC7C,OAAO,UACP,SACA,aACiC,CAAC,GAAG;CACrC,OAAO;EACN;EACA,WAAW,WAA4C;GACtD,OAAO,IAAI,aAAa;IACvB;IACA,MAAM,OAAO,IAAI;IACjB;IACA;GACD,CAAC;EACF;CACD;AACD;AAEA,IAAa,eAAb,MAA0B;CACzB;CAEA;CAEA;CAEA;CAEA,YAAY,EACX,QACA,MACA,SACA,YAME;aA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AQ,SACZ,MAAM,IAAI,MACT,yCAAyC,KAAK,iBAAiB,UAChE;EAGD,OAAO,eAAe,WAAW,MAChC,OAAO,OACR;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.mainnet.mjs","names":[],"sources":["../../src/configs/registry.mainnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types';\n\nexport const MAINNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x3d73568546c539c1da3eb2b8fe917faef3c0acdbec78a67fe6d52800a0729349',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,qEACF"}
|
|
1
|
+
{"version":3,"file":"registry.mainnet.mjs","names":[],"sources":["../../src/configs/registry.mainnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types/index.js';\n\nexport const MAINNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x3d73568546c539c1da3eb2b8fe917faef3c0acdbec78a67fe6d52800a0729349',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,qEACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.testnet.mjs","names":[],"sources":["../../src/configs/registry.testnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types';\n\nexport const TESTNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x99f20d8e4be012ea14a681144ae72ac349d0a1a1585205880183eb167f075bad',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,qEACF"}
|
|
1
|
+
{"version":3,"file":"registry.testnet.mjs","names":[],"sources":["../../src/configs/registry.testnet.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { SuigarRegistryIds } from '../types/index.js';\n\nexport const TESTNET_REGISTRY_IDS: SuigarRegistryIds = {\n\tpvpCoinflip:\n\t\t'0x99f20d8e4be012ea14a681144ae72ac349d0a1a1585205880183eb167f075bad',\n};\n"],"mappings":";AAKA,MAAa,uBAA0C,EACtD,aACC,qEACF"}
|
|
@@ -2,28 +2,28 @@ import { MoveStruct } from "../utils/index.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/contracts/core/core.d.ts
|
|
4
4
|
declare const BetResultEvent: MoveStruct<{
|
|
5
|
-
player: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
5
|
+
player: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
6
6
|
coin_type: MoveStruct<{
|
|
7
|
-
name: import("@mysten/bcs").BcsType<string, string, "string">;
|
|
7
|
+
name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
8
8
|
}, "0x0000000000000000000000000000000000000000000000000000000000000001::type_name::TypeName">;
|
|
9
|
-
stake_amount: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
9
|
+
stake_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
10
10
|
unsafe_oracle_usd_coin_price: MoveStruct<{
|
|
11
|
-
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
11
|
+
is_negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
12
12
|
exp: MoveStruct<{
|
|
13
|
-
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
13
|
+
bits: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
14
14
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
15
|
-
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
15
|
+
mant: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
16
16
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
17
17
|
adjusted_oracle_usd_coin_price: MoveStruct<{
|
|
18
|
-
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
18
|
+
is_negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
19
19
|
exp: MoveStruct<{
|
|
20
|
-
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
20
|
+
bits: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
21
21
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
22
|
-
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
22
|
+
mant: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
23
23
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
24
|
-
outcome_amount: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
24
|
+
outcome_amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
25
25
|
game_details: MoveStruct<{
|
|
26
|
-
contents: import("@mysten/bcs").BcsType<{
|
|
26
|
+
contents: import("@mysten/sui/bcs").BcsType<{
|
|
27
27
|
key: string;
|
|
28
28
|
value: number[];
|
|
29
29
|
}[], Iterable<{
|
|
@@ -36,7 +36,7 @@ declare const BetResultEvent: MoveStruct<{
|
|
|
36
36
|
}, string>;
|
|
37
37
|
}, "0x2::vec_map::VecMap<string, vector<u8>>">;
|
|
38
38
|
metadata: MoveStruct<{
|
|
39
|
-
contents: import("@mysten/bcs").BcsType<{
|
|
39
|
+
contents: import("@mysten/sui/bcs").BcsType<{
|
|
40
40
|
key: string;
|
|
41
41
|
value: number[];
|
|
42
42
|
}[], Iterable<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC7G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;EACvB;CACD,CAAC;AACF;AACA,SAAgB,OACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC9G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,EAAE,CAAC,EACjE;CACD,CAAC;AACF"}
|
|
@@ -2,11 +2,11 @@ import { MoveStruct } from "../utils/index.mjs";
|
|
|
2
2
|
|
|
3
3
|
//#region src/contracts/core/float.d.ts
|
|
4
4
|
declare const Float: MoveStruct<{
|
|
5
|
-
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
5
|
+
is_negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
6
6
|
exp: MoveStruct<{
|
|
7
|
-
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
7
|
+
bits: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
8
8
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
9
|
-
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
9
|
+
mant: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
10
10
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Float };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC7G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;EACvB;CACD,CAAC;AACF;AACA,SAAgB,OACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC9G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,EAAE,CAAC,EACjE;CACD,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC7G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;EACvB;CACD,CAAC;AACF;AACA,SAAgB,OACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC9G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,EAAE,CAAC,EACjE;CACD,CAAC;AACF"}
|
|
@@ -3,12 +3,12 @@ import { Transaction } from "@mysten/sui/transactions";
|
|
|
3
3
|
|
|
4
4
|
//#region src/contracts/pvp-coinflip/pvp_coinflip.d.ts
|
|
5
5
|
declare const Game: MoveStruct<{
|
|
6
|
-
id: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
7
|
-
creator: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
-
creator_is_tails: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
9
|
-
is_private: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
6
|
+
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
7
|
+
creator: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
creator_is_tails: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
9
|
+
is_private: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
10
10
|
creator_metadata: MoveStruct<{
|
|
11
|
-
contents: import("@mysten/bcs").BcsType<{
|
|
11
|
+
contents: import("@mysten/sui/bcs").BcsType<{
|
|
12
12
|
key: string;
|
|
13
13
|
value: number[];
|
|
14
14
|
}[], Iterable<{
|
|
@@ -20,12 +20,12 @@ declare const Game: MoveStruct<{
|
|
|
20
20
|
length: number;
|
|
21
21
|
}, string>;
|
|
22
22
|
}, "0x2::vec_map::VecMap<string, vector<u8>>">;
|
|
23
|
-
joiner: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
24
|
-
winner: import("@mysten/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
25
|
-
stake_per_player: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
26
|
-
house_edge_bps: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
23
|
+
joiner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
24
|
+
winner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
25
|
+
stake_per_player: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
26
|
+
house_edge_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
27
27
|
stake_pot: MoveStruct<{
|
|
28
|
-
value: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
28
|
+
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
29
29
|
}, "0x2::balance::Balance<phantom T0>">;
|
|
30
30
|
}, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::Game<phantom T0>">;
|
|
31
31
|
//#endregion
|
|
@@ -8,7 +8,42 @@ type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> =
|
|
|
8
8
|
type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectsOptions<Include> & {
|
|
9
9
|
client: ClientWithCoreApi;
|
|
10
10
|
};
|
|
11
|
+
/** A type argument: a type tag string, or a BCS type whose name is a Move type. */
|
|
12
|
+
type TypeArgument = string | BcsType<any>;
|
|
13
|
+
interface TypeTagOptions {
|
|
14
|
+
package?: string;
|
|
15
|
+
typeArguments?: readonly TypeArgument[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `typeArguments` is required when the type's name contains unfilled
|
|
19
|
+
* `phantom X` parameters (at any depth). Everything else — argument arity,
|
|
20
|
+
* position contents, and tag validity — is validated at runtime.
|
|
21
|
+
*/
|
|
22
|
+
type TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}` ? [options: TypeTagOptions & {
|
|
23
|
+
typeArguments: readonly TypeArgument[];
|
|
24
|
+
}] : [options?: TypeTagOptions];
|
|
25
|
+
type ResolveTypeTagOptions<Name extends string> = {
|
|
26
|
+
client: ClientWithCoreApi;
|
|
27
|
+
} & (Name extends `${string}phantom ${string}` ? TypeTagOptions & {
|
|
28
|
+
typeArguments: readonly TypeArgument[];
|
|
29
|
+
} : TypeTagOptions);
|
|
11
30
|
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
31
|
+
/**
|
|
32
|
+
* Build the type tag for this struct.
|
|
33
|
+
*
|
|
34
|
+
* `typeArguments` is the full positional list, in Move declaration order, and
|
|
35
|
+
* is required when the struct has unfilled phantom parameters. The result may
|
|
36
|
+
* contain MVR names: those are valid in transaction `typeArguments`, but for
|
|
37
|
+
* queries or comparisons against on-chain data use `resolveTypeTag` instead.
|
|
38
|
+
*/
|
|
39
|
+
typeTag(...args: TypeTagParams<Name>): string;
|
|
40
|
+
/**
|
|
41
|
+
* Build the type tag for this struct, then resolve any MVR names through the
|
|
42
|
+
* client (using its configured overrides and the MVR API) and return the
|
|
43
|
+
* normalized, address-only form suitable for queries and comparisons against
|
|
44
|
+
* on-chain data.
|
|
45
|
+
*/
|
|
46
|
+
resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string>;
|
|
12
47
|
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
|
|
13
48
|
objectId,
|
|
14
49
|
...options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;KAqBY,UAAA,iBACK,IAAA,CAAK,cAAA,CAAe,aAAA,qBACjC,cAAA,CAAe,gBAAA,CAAiB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,KAE7C,cAAA,iBACK,IAAA,CAAK,cAAA,CAAe,aAAA,qBACjC,cAAA,CAAe,iBAAA,CAAkB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;KAqBY,UAAA,iBACK,IAAA,CAAK,cAAA,CAAe,aAAA,qBACjC,cAAA,CAAe,gBAAA,CAAiB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,KAE7C,cAAA,iBACK,IAAA,CAAK,cAAA,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ils";
|
|
2
2
|
import { BcsStruct, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
|
|
3
3
|
import { isArgument } from "@mysten/sui/transactions";
|
|
4
4
|
//#region src/contracts/utils/index.ts
|
|
@@ -83,7 +83,73 @@ function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
|
83
83
|
}
|
|
84
84
|
return normalizedArgs;
|
|
85
85
|
}
|
|
86
|
+
const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
|
|
87
|
+
function splitTopLevelTypeArgs(inner) {
|
|
88
|
+
const parts = [];
|
|
89
|
+
let depth = 0;
|
|
90
|
+
let current = "";
|
|
91
|
+
for (const char of inner) {
|
|
92
|
+
if (char === "," && depth === 0) {
|
|
93
|
+
parts.push(current.trim());
|
|
94
|
+
current = "";
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (char === "<") depth++;
|
|
98
|
+
if (char === ">") depth--;
|
|
99
|
+
current += char;
|
|
100
|
+
}
|
|
101
|
+
if (current) parts.push(current.trim());
|
|
102
|
+
return parts;
|
|
103
|
+
}
|
|
104
|
+
function buildTypeTag(name, options) {
|
|
105
|
+
const lt = name.indexOf("<");
|
|
106
|
+
const base = lt === -1 ? name : name.slice(0, lt);
|
|
107
|
+
if (base.split("::").length !== 3) throw new Error(`${name} is not a top-level Move type`);
|
|
108
|
+
let result = name;
|
|
109
|
+
if (options?.typeArguments) {
|
|
110
|
+
const baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));
|
|
111
|
+
const supplied = options.typeArguments.map((arg) => {
|
|
112
|
+
if (typeof arg === "string") return arg;
|
|
113
|
+
if (arg && typeof arg.serialize === "function" && typeof arg.name === "string") return arg.name;
|
|
114
|
+
throw new Error(`Invalid type argument ${stringify(arg)}`);
|
|
115
|
+
});
|
|
116
|
+
if (supplied.length !== baked.length) throw new Error(`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`);
|
|
117
|
+
result = supplied.length === 0 ? base : `${base}<${supplied.join(", ")}>`;
|
|
118
|
+
}
|
|
119
|
+
if (HAS_PHANTOM_REGEX.test(result)) throw new Error(options?.typeArguments ? `A type argument contains an unfilled phantom parameter in ${result}` : `Missing type arguments for ${result}`);
|
|
120
|
+
if (options?.package) {
|
|
121
|
+
const [, ...rest] = result.split("::");
|
|
122
|
+
result = [options.package, ...rest].join("::");
|
|
123
|
+
}
|
|
124
|
+
if (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) TypeTagSerializer.parseFromStr(result);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
async function resolveBuiltTypeTag(name, options) {
|
|
128
|
+
const { client, ...rest } = options;
|
|
129
|
+
const { type } = await client.core.mvr.resolveType({ type: buildTypeTag(name, rest) });
|
|
130
|
+
return normalizeStructTag(type);
|
|
131
|
+
}
|
|
86
132
|
var MoveStruct = class extends BcsStruct {
|
|
133
|
+
/**
|
|
134
|
+
* Build the type tag for this struct.
|
|
135
|
+
*
|
|
136
|
+
* `typeArguments` is the full positional list, in Move declaration order, and
|
|
137
|
+
* is required when the struct has unfilled phantom parameters. The result may
|
|
138
|
+
* contain MVR names: those are valid in transaction `typeArguments`, but for
|
|
139
|
+
* queries or comparisons against on-chain data use `resolveTypeTag` instead.
|
|
140
|
+
*/
|
|
141
|
+
typeTag(...args) {
|
|
142
|
+
return buildTypeTag(this.name, args[0]);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build the type tag for this struct, then resolve any MVR names through the
|
|
146
|
+
* client (using its configured overrides and the MVR API) and return the
|
|
147
|
+
* normalized, address-only form suitable for queries and comparisons against
|
|
148
|
+
* on-chain data.
|
|
149
|
+
*/
|
|
150
|
+
async resolveTypeTag(options) {
|
|
151
|
+
return resolveBuiltTypeTag(this.name, options);
|
|
152
|
+
}
|
|
87
153
|
async get({ objectId, ...options }) {
|
|
88
154
|
const [res] = await this.getMany({
|
|
89
155
|
...options,
|
|
@@ -109,7 +175,7 @@ var MoveStruct = class extends BcsStruct {
|
|
|
109
175
|
}
|
|
110
176
|
};
|
|
111
177
|
function stringify(val) {
|
|
112
|
-
if (typeof val === "object") return JSON.stringify(val, (
|
|
178
|
+
if (typeof val === "object") return JSON.stringify(val, (_key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
113
179
|
if (typeof val === "bigint") return val.toString();
|
|
114
180
|
return val;
|
|
115
181
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsEnum,\n\tBcsStruct,\n\tBcsTuple,\n\tTypeTagSerializer,\n\ttype BcsType,\n\ttype TypeTag,\n} from '@mysten/sui/bcs';\nimport {\n\ttype ClientWithCoreApi,\n\ttype SuiClientTypes,\n} from '@mysten/sui/client';\nimport { isArgument, type TransactionArgument } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(\n\ttypeTag: string | TypeTag,\n): BcsType<any> | null {\n\tconst parsedTag =\n\t\ttypeof typeTag === 'string'\n\t\t\t? TypeTagSerializer.parseFromStr(typeTag)\n\t\t\t: typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\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AAEA,IAAa,aAAb,cAGU,UAAmB;CAC5B,MAAM,IAEJ,EACD,UACA,GAAG,WAKF;EACD,MAAM,CAAC,OAAO,MAAM,KAAK,QAAiB;GACzC,GAAG;GACH,WAAW,CAAC,QAAQ;EACrB,CAAC;EAED,IAAI,CAAC,KACJ,MAAM,IAAI,MAAM,0BAA0B,UAAU;EAGrD,OAAO;CACR;CAEA,MAAM,QAEJ,EACD,QACA,GAAG,WAOF;EASD,QAAO,MARiB,OAAO,KAAK,WAAW;GAC9C,GAAG;GACH,SAAS;IACR,GAAG,QAAQ;IACX,SAAS;GACV;EACD,CAAC,GAEe,QAAQ,KAAK,QAAQ;GACpC,IAAI,eAAe,OAClB,MAAM;GAGP,OAAO;IACN,GAAG;IACH,MAAM,KAAK,MAAM,IAAI,OAAO;GAC7B;EACD,CAAC;CACF;AACD;AAYA,SAAS,UAAU,KAAc;CAChC,IAAI,OAAO,QAAQ,UAClB,OAAO,KAAK,UAAU,MAAM,QAAiB,GAAG;CAEjD,IAAI,OAAO,QAAQ,UAClB,OAAO,IAAI,SAAS;CAGrB,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsEnum,\n\tBcsStruct,\n\tBcsTuple,\n\tTypeTagSerializer,\n\ttype BcsType,\n\ttype TypeTag,\n} from '@mysten/sui/bcs';\nimport {\n\ttype ClientWithCoreApi,\n\ttype SuiClientTypes,\n} from '@mysten/sui/client';\nimport { isArgument, type TransactionArgument } from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(\n\ttypeTag: string | TypeTag,\n): BcsType<any> | null {\n\tconst parsedTag =\n\t\ttypeof typeTag === 'string'\n\t\t\t? TypeTagSerializer.parseFromStr(typeTag)\n\t\t\t: typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> =\n\tName extends `${string}phantom ${string}`\n\t\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(\n\tname: string,\n\toptions: TypeTagOptions | undefined,\n): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new Error(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked =\n\t\t\tlt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (\n\t\t\t\targ &&\n\t\t\t\ttypeof arg.serialize === 'function' &&\n\t\t\t\ttypeof arg.name === 'string'\n\t\t\t) {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new Error(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\n\tasync get<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {\n\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;AAgBA,MAAM,sBAAsB,oBAAoB,KAAK;AACrD,MAAM,wBAAwB,oBAAoB,KAAK;AAYvD,SAAgB,iBACf,SACsB;CACtB,MAAM,YACL,OAAO,YAAY,WAChB,kBAAkB,aAAa,OAAO,IACtC;CAEJ,IAAI,QAAQ,WACX,OAAO,IAAI;MACL,IAAI,SAAS,WACnB,OAAO,IAAI;MACL,IAAI,SAAS,WACnB,OAAO,IAAI;MACL,IAAI,SAAS,WACnB,OAAO,IAAI;MACL,IAAI,UAAU,WACpB,OAAO,IAAI;MACL,IAAI,UAAU,WACpB,OAAO,IAAI;MACL,IAAI,aAAa,WACvB,OAAO,IAAI;MACL,IAAI,UAAU,WACpB,OAAO,IAAI;MACL,IAAI,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,MAAM;EAC9C,OAAO,OAAO,IAAI,OAAO,IAAI,IAAI;CAClC,OAAO,IAAI,YAAY,WAAW;EACjC,MAAM,YAAY,UAAU;EAC5B,MAAM,MAAM,oBAAoB,UAAU,OAAO;EAEjD,IAAI,QAAQ,qBAAqB;GAChC,KACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,UAEnB,OAAO,IAAI;GAGZ,IAAI,UAAU,WAAW,YAAY,UAAU,SAAS,UAAU;IACjE,MAAM,QAAQ,UAAU,WAAW;IACnC,MAAM,OAAO,QAAQ,iBAAiB,KAAK,IAAI;IAC/C,OAAO,OAAO,IAAI,OAAO,IAAI,IAAI;GAClC;EACD;EAEA,IACC,QAAQ,yBACR,UAAU,WAAW,aACpB,UAAU,SAAS,QAAQ,UAAU,SAAS,QAE/C,OAAO,IAAI;CAEb;CAEA,OAAO;AACR;AAEA,SAAgB,uBACf,MACA,UACA,gBACC;CACD,MAAM,SAAS,MAAM,QAAQ,IAAI,IAA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,CAAC;CACF;AACD;AAsCA,SAAS,UAAU,KAAc;CAChC,IAAI,OAAO,QAAQ,UAClB,OAAO,KAAK,UAAU,MAAM,MAAM,UACjC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI,KAChD;CAED,IAAI,OAAO,QAAQ,UAClB,OAAO,IAAI,SAAS;CAGrB,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,
|
|
1
|
+
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC7G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;EACvB;CACD,CAAC;AACF;AACA,SAAgB,OACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC9G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,EAAE,CAAC,EACjE;CACD,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { normalizeStructTag } from '@mysten/sui/utils';\nimport {\n\tCOIN_TYPES,\n\tPACKAGE_IDS,\n\tPRICE_INFO_OBJECT_IDS,\n\tREGISTRY_IDS,\n} from '../configs/index.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { normalizeStructTag } from '@mysten/sui/utils';\nimport {\n\tCOIN_TYPES,\n\tPACKAGE_IDS,\n\tPRICE_INFO_OBJECT_IDS,\n\tREGISTRY_IDS,\n} from '../configs/index.js';\nimport type {\n\tGame,\n\tSuigarCoin,\n\tSuigarConfig,\n\tSuiNetwork,\n} from '../types/index.js';\n\nexport const DEFAULT_CACHE_TTL_MS = 30 * 60 * 1000;\n\nexport function resolveSuigarConfig(network: SuiNetwork): SuigarConfig {\n\tconst packageIds = PACKAGE_IDS[network];\n\tconst registryIds = REGISTRY_IDS[network];\n\tconst coinTypes = COIN_TYPES[network];\n\tconst priceInfoObjectIds = PRICE_INFO_OBJECT_IDS[network];\n\n\treturn {\n\t\tpackageIds: { ...packageIds },\n\t\tregistryIds: { ...registryIds },\n\t\tcoinTypes: {\n\t\t\tsui: normalizeStructTag(coinTypes.sui),\n\t\t\tusdc: normalizeStructTag(coinTypes.usdc),\n\t\t},\n\t\tpriceInfoObjectIds: {\n\t\t\tsui: priceInfoObjectIds.sui,\n\t\t\tusdc: priceInfoObjectIds.usdc,\n\t\t},\n\t};\n}\n\nexport function assertConfiguredBetGame(\n\tconfig: SuigarConfig,\n\tgame: Game,\n): void {\n\tif (!resolveGamePackageId(config, game)) {\n\t\tthrow new Error(`Missing required config for ${game}: packageIds.${game}`);\n\t}\n}\n\nexport function resolveGamePackageId(config: SuigarConfig, game: Game): string {\n\tswitch (game) {\n\t\tcase 'coinflip':\n\t\t\treturn config.packageIds.coinflip;\n\t\tcase 'limbo':\n\t\t\treturn config.packageIds.limbo;\n\t\tcase 'plinko':\n\t\t\treturn config.packageIds.plinko;\n\t\tcase 'pvp-coinflip':\n\t\t\treturn config.packageIds.pvpCoinflip;\n\t\tcase 'range':\n\t\t\treturn config.packageIds.range;\n\t\tcase 'wheel':\n\t\t\treturn config.packageIds.wheel;\n\t}\n}\n\nexport function resolvePriceInfoObjectId(\n\tconfig: SuigarConfig,\n\tcoinType: string,\n): string {\n\tconst normalizedCoinType = normalizeStructTag(coinType);\n\tconst supportedCoin = resolveSupportedCoin(config, normalizedCoinType);\n\tconst objectId = config.priceInfoObjectIds[supportedCoin];\n\n\tif (!objectId) {\n\t\tthrow new Error(\n\t\t\t`Missing price info object configuration for coin type ${coinType}`,\n\t\t);\n\t}\n\n\treturn objectId;\n}\n\nfunction resolveSupportedCoin(\n\tconfig: SuigarConfig,\n\tcoinType: string,\n): SuigarCoin {\n\tconst [supportedCoin] =\n\t\tObject.entries(config.coinTypes).find(([_, value]) => value === coinType) ??\n\t\t[];\n\n\tif (!supportedCoin) {\n\t\tthrow new RangeError(\n\t\t\t`Unsupported coin type ${coinType}. Supported coin types: ${Object.values(\n\t\t\t\tconfig.coinTypes,\n\t\t\t).join(', ')}`,\n\t\t);\n\t}\n\n\treturn supportedCoin as SuigarCoin;\n}\n"],"mappings":";;;;AAiBA,MAAa,uBAAuB,OAAU;AAE9C,SAAgB,oBAAoB,SAAmC;CACtE,MAAM,aAAa,YAAY;CAC/B,MAAM,cAAc,aAAa;CACjC,MAAM,YAAY,WAAW;CAC7B,MAAM,qBAAqB,sBAAsB;CAEjD,OAAO;EACN,YAAY,EAAE,GAAG,WAAW;EAC5B,aAAa,EAAE,GAAG,YAAY;EAC9B,WAAW;GACV,KAAK,mBAAmB,UAAU,GAAG;GACrC,MAAM,mBAAmB,UAAU,IAAI;EACxC;EACA,oBAAoB;GACnB,KAAK,mBAAmB;GACxB,MAAM,mBAAmB;EAC1B;CACD;AACD;AAEA,SAAgB,wBACf,QACA,MACO;CACP,IAAI,CAAC,qBAAqB,QAAQ,IAAI,GACrC,MAAM,IAAI,MAAM,+BAA+B,KAAK,eAAe,MAAM;AAE3E;AAEA,SAAgB,qBAAqB,QAAsB,MAAoB;CAC9E,QAAQ,MAAR;EACC,KAAK,YACJ,OAAO,OAAO,WAAW;EAC1B,KAAK,SACJ,OAAO,OAAO,WAAW;EAC1B,KAAK,UACJ,OAAO,OAAO,WAAW;EAC1B,KAAK,gBACJ,OAAO,OAAO,WAAW;EAC1B,KAAK,SACJ,OAAO,OAAO,WAAW;EAC1B,KAAK,SACJ,OAAO,OAAO,WAAW;CAC3B;AACD;AAEA,SAAgB,yBACf,QACA,UACS;CAET,MAAM,gBAAgB,qBAAqB,QADhB,mBAAmB,QACsB,CAAC;CACrE,MAAM,WAAW,OAAO,mBAAmB;CAE3C,IAAI,CAAC,UACJ,MAAM,IAAI,MACT,yDAAyD,UAC1D;CAGD,OAAO;AACR;AAEA,SAAS,qBACR,QACA,UACa;CACb,MAAM,CAAC,iBACN,OAAO,QAAQ,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,WAAW,UAAU,QAAQ,KACxE,CAAC;CAEF,IAAI,CAAC,eACJ,MAAM,IAAI,WACT,yBAAyB,SAAS,0BAA0B,OAAO,OAClE,OAAO,SACR,CAAC,CAAC,KAAK,IAAI,GACZ;CAGD,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-settings.mjs","names":[],"sources":["../../src/helpers/game-settings.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeStructTag,\n\tnormalizeSuiAddress,\n\tparseStructTag,\n} from '@mysten/sui/utils';\n\nfunction replaceStructTagAddress(structName: string, address: string): string {\n\treturn normalizeStructTag({\n\t\t...parseStructTag(structName),\n\t\taddress,\n\t});\n}\n\nexport function resolveGameSettingsKeyType(\n\tstructName: string,\n\tpackageId: string,\n): string {\n\treturn replaceStructTagAddress(structName, packageId);\n}\n\nexport function resolveCoinTypeNameForTypeNameKey(structName: string): string {\n\tconst { address } = parseStructTag(structName);\n\n\treturn replaceStructTagAddress(\n\t\tstructName,\n\t\tnormalizeSuiAddress(address).replace(/^0x/, ''),\n\t);\n}\n"],"mappings":";;AASA,SAAS,wBAAwB,YAAoB,SAAyB;CAC7E,OAAO,mBAAmB;EACzB,GAAG,eAAe,UAAU;EAC5B;CACD,CAAC;AACF;AAEA,SAAgB,2BACf,YACA,WACS;CACT,OAAO,wBAAwB,YAAY,SAAS;AACrD;AAEA,SAAgB,kCAAkC,YAA4B;CAC7E,MAAM,EAAE,YAAY,eAAe,UAAU;CAE7C,OAAO,wBACN,YACA,oBAAoB,OAAO,
|
|
1
|
+
{"version":3,"file":"game-settings.mjs","names":[],"sources":["../../src/helpers/game-settings.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tnormalizeStructTag,\n\tnormalizeSuiAddress,\n\tparseStructTag,\n} from '@mysten/sui/utils';\n\nfunction replaceStructTagAddress(structName: string, address: string): string {\n\treturn normalizeStructTag({\n\t\t...parseStructTag(structName),\n\t\taddress,\n\t});\n}\n\nexport function resolveGameSettingsKeyType(\n\tstructName: string,\n\tpackageId: string,\n): string {\n\treturn replaceStructTagAddress(structName, packageId);\n}\n\nexport function resolveCoinTypeNameForTypeNameKey(structName: string): string {\n\tconst { address } = parseStructTag(structName);\n\n\treturn replaceStructTagAddress(\n\t\tstructName,\n\t\tnormalizeSuiAddress(address).replace(/^0x/, ''),\n\t);\n}\n"],"mappings":";;AASA,SAAS,wBAAwB,YAAoB,SAAyB;CAC7E,OAAO,mBAAmB;EACzB,GAAG,eAAe,UAAU;EAC5B;CACD,CAAC;AACF;AAEA,SAAgB,2BACf,YACA,WACS;CACT,OAAO,wBAAwB,YAAY,SAAS;AACrD;AAEA,SAAgB,kCAAkC,YAA4B;CAC7E,MAAM,EAAE,YAAY,eAAe,UAAU;CAE7C,OAAO,wBACN,YACA,oBAAoB,OAAO,CAAC,CAAC,QAAQ,OAAO,EAAE,CAC/C;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fromHex } from "@mysten/sui/utils";
|
|
2
2
|
//#region src/helpers/metadata.ts
|
|
3
3
|
const PARTNER_METADATA_KEY = "partner";
|
|
4
|
-
const RESERVED_METADATA_KEYS = new Set([PARTNER_METADATA_KEY, "referrer"]);
|
|
4
|
+
const RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([PARTNER_METADATA_KEY, "referrer"]);
|
|
5
5
|
const textEncoder = new TextEncoder();
|
|
6
6
|
function encodeString(value) {
|
|
7
7
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.mjs","names":[],"sources":["../../src/helpers/metadata.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromHex } from '@mysten/sui/utils';\nimport type {\n\tBetMetadataInput,\n\tBetMetadataValue,\n\tEncodedBetMetadata,\n} from '../types';\n\nconst PARTNER_METADATA_KEY = 'partner';\n\nconst RESERVED_METADATA_KEYS = new Set([PARTNER_METADATA_KEY, 'referrer']);\nconst textEncoder = new TextEncoder();\n\nfunction encodeString(value: string) {\n\ttry {\n\t\treturn fromHex(value);\n\t} catch {\n\t\treturn textEncoder.encode(value);\n\t}\n}\n\nfunction encodeMetadataValue(value: BetMetadataValue) {\n\tif (value instanceof Uint8Array) {\n\t\treturn Array.from(value);\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value;\n\t}\n\n\treturn Array.from(encodeString(String(value)));\n}\n\nexport function encodeBetMetadata(\n\tmetadata?: BetMetadataInput,\n\tpartner?: string,\n): EncodedBetMetadata {\n\tconst keys: string[] = [];\n\tconst values: number[][] = [];\n\n\tfor (const [key, value] of Object.entries(metadata ?? {})) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) {\n\t\t\tconsole.warn(\n\t\t\t\t`Metadata key \"${key}\" is reserved and will be ignored when parsing metadata.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (value == null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tkeys.push(key);\n\t\tvalues.push(encodeMetadataValue(value));\n\t}\n\n\tif (partner?.trim()) {\n\t\tkeys.unshift(PARTNER_METADATA_KEY);\n\t\tvalues.unshift(encodeMetadataValue(partner));\n\t}\n\n\treturn {\n\t\tkeys,\n\t\tvalues,\n\t};\n}\n"],"mappings":";;AAUA,MAAM,uBAAuB;AAE7B,MAAM,
|
|
1
|
+
{"version":3,"file":"metadata.mjs","names":[],"sources":["../../src/helpers/metadata.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromHex } from '@mysten/sui/utils';\nimport type {\n\tBetMetadataInput,\n\tBetMetadataValue,\n\tEncodedBetMetadata,\n} from '../types/index.js';\n\nconst PARTNER_METADATA_KEY = 'partner';\n\nconst RESERVED_METADATA_KEYS = new Set([PARTNER_METADATA_KEY, 'referrer']);\nconst textEncoder = new TextEncoder();\n\nfunction encodeString(value: string) {\n\ttry {\n\t\treturn fromHex(value);\n\t} catch {\n\t\treturn textEncoder.encode(value);\n\t}\n}\n\nfunction encodeMetadataValue(value: BetMetadataValue) {\n\tif (value instanceof Uint8Array) {\n\t\treturn Array.from(value);\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value;\n\t}\n\n\treturn Array.from(encodeString(String(value)));\n}\n\nexport function encodeBetMetadata(\n\tmetadata?: BetMetadataInput,\n\tpartner?: string,\n): EncodedBetMetadata {\n\tconst keys: string[] = [];\n\tconst values: number[][] = [];\n\n\tfor (const [key, value] of Object.entries(metadata ?? {})) {\n\t\tif (RESERVED_METADATA_KEYS.has(key)) {\n\t\t\tconsole.warn(\n\t\t\t\t`Metadata key \"${key}\" is reserved and will be ignored when parsing metadata.`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (value == null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tkeys.push(key);\n\t\tvalues.push(encodeMetadataValue(value));\n\t}\n\n\tif (partner?.trim()) {\n\t\tkeys.unshift(PARTNER_METADATA_KEY);\n\t\tvalues.unshift(encodeMetadataValue(partner));\n\t}\n\n\treturn {\n\t\tkeys,\n\t\tvalues,\n\t};\n}\n"],"mappings":";;AAUA,MAAM,uBAAuB;AAE7B,MAAM,yCAAyB,IAAI,IAAI,CAAC,sBAAsB,UAAU,CAAC;AACzE,MAAM,cAAc,IAAI,YAAY;AAEpC,SAAS,aAAa,OAAe;CACpC,IAAI;EACH,OAAO,QAAQ,KAAK;CACrB,QAAQ;EACP,OAAO,YAAY,OAAO,KAAK;CAChC;AACD;AAEA,SAAS,oBAAoB,OAAyB;CACrD,IAAI,iBAAiB,YACpB,OAAO,MAAM,KAAK,KAAK;CAGxB,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO;CAGR,OAAO,MAAM,KAAK,aAAa,OAAO,KAAK,CAAC,CAAC;AAC9C;AAEA,SAAgB,kBACf,UACA,SACqB;CACrB,MAAM,OAAiB,CAAC;CACxB,MAAM,SAAqB,CAAC;CAE5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,CAAC,CAAC,GAAG;EAC1D,IAAI,uBAAuB,IAAI,GAAG,GAAG;GACpC,QAAQ,KACP,iBAAiB,IAAI,yDACtB;GACA;EACD;EAEA,IAAI,SAAS,MACZ;EAGD,KAAK,KAAK,GAAG;EACb,OAAO,KAAK,oBAAoB,KAAK,CAAC;CACvC;CAEA,IAAI,SAAS,KAAK,GAAG;EACpB,KAAK,QAAQ,oBAAoB;EACjC,OAAO,QAAQ,oBAAoB,OAAO,CAAC;CAC5C;CAEA,OAAO;EACN;EACA;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coinflip.mjs","names":[],"sources":["../../src/transactions/coinflip.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/coinflip/coinflip.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"coinflip.mjs","names":[],"sources":["../../src/transactions/coinflip.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/coinflip/coinflip.js';\nimport type {\n\tBuildCoinflipTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { buildSharedStandardGameBetTransaction } from './shared.js';\n\nexport function buildCoinflipTransaction(\n\toptions: WithPartner<BuildCoinflipTransactionOptions>,\n): Transaction {\n\treturn buildSharedStandardGameBetTransaction({\n\t\t...options,\n\t\tgame: 'coinflip',\n\t\tbuildRewardCoin: ({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\tcoinType,\n\t\t\tstake,\n\t\t\tbetCount,\n\t\t\tmetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t}) =>\n\t\t\tplay({\n\t\t\t\tpackage: config.packageIds.coinflip,\n\t\t\t\ttypeArguments: [coinType],\n\t\t\t\targuments: [\n\t\t\t\t\tconfig.packageIds.sweetHouse,\n\t\t\t\t\tstake,\n\t\t\t\t\tbetCoin,\n\t\t\t\t\tbetCount,\n\t\t\t\t\toptions.side === 'tails',\n\t\t\t\t\tmetadata.keys,\n\t\t\t\t\tmetadata.values,\n\t\t\t\t\tpriceInfoObjectId,\n\t\t\t\t],\n\t\t\t})(tx),\n\t});\n}\n"],"mappings":";;;AAWA,SAAgB,yBACf,SACc;CACd,OAAO,sCAAsC;EAC5C,GAAG;EACH,MAAM;EACN,kBAAkB,EACjB,IACA,QACA,UACA,OACA,UACA,UACA,mBACA,cAEA,KAAK;GACJ,SAAS,OAAO,WAAW;GAC3B,eAAe,CAAC,QAAQ;GACxB,WAAW;IACV,OAAO,WAAW;IAClB;IACA;IACA;IACA,QAAQ,SAAS;IACjB,SAAS;IACT,SAAS;IACT;GACD;EACD,CAAC,CAAC,CAAC,EAAE;CACP,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limbo.mjs","names":[],"sources":["../../src/transactions/limbo.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/limbo/limbo.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"limbo.mjs","names":[],"sources":["../../src/transactions/limbo.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/limbo/limbo.js';\nimport type {\n\tBuildLimboTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { DEFAULT_LIMBO_MULTIPLIER_SCALE } from '../utils/index.js';\nimport { buildSharedStandardGameBetTransaction } from './shared.js';\n\nexport function buildLimboTransaction(\n\toptions: WithPartner<BuildLimboTransactionOptions>,\n): Transaction {\n\tconst scale = options.scale ?? DEFAULT_LIMBO_MULTIPLIER_SCALE;\n\tconst numerator = Math.round(options.targetMultiplier * scale);\n\n\treturn buildSharedStandardGameBetTransaction({\n\t\t...options,\n\t\tgame: 'limbo',\n\t\tbuildRewardCoin: ({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\tcoinType,\n\t\t\tstake,\n\t\t\tbetCount,\n\t\t\tmetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t}) =>\n\t\t\tplay({\n\t\t\t\tpackage: config.packageIds.limbo,\n\t\t\t\ttypeArguments: [coinType],\n\t\t\t\targuments: [\n\t\t\t\t\tconfig.packageIds.sweetHouse,\n\t\t\t\t\tstake,\n\t\t\t\t\tbetCoin,\n\t\t\t\t\tbetCount,\n\t\t\t\t\tBigInt(numerator),\n\t\t\t\t\tBigInt(scale),\n\t\t\t\t\tmetadata.keys,\n\t\t\t\t\tmetadata.values,\n\t\t\t\t\tpriceInfoObjectId,\n\t\t\t\t],\n\t\t\t})(tx),\n\t});\n}\n"],"mappings":";;;;AAYA,SAAgB,sBACf,SACc;CACd,MAAM,QAAQ,QAAQ,SAAA;CACtB,MAAM,YAAY,KAAK,MAAM,QAAQ,mBAAmB,KAAK;CAE7D,OAAO,sCAAsC;EAC5C,GAAG;EACH,MAAM;EACN,kBAAkB,EACjB,IACA,QACA,UACA,OACA,UACA,UACA,mBACA,cAEA,KAAK;GACJ,SAAS,OAAO,WAAW;GAC3B,eAAe,CAAC,QAAQ;GACxB,WAAW;IACV,OAAO,WAAW;IAClB;IACA;IACA;IACA,OAAO,SAAS;IAChB,OAAO,KAAK;IACZ,SAAS;IACT,SAAS;IACT;GACD;EACD,CAAC,CAAC,CAAC,EAAE;CACP,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plinko.mjs","names":[],"sources":["../../src/transactions/plinko.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/plinko/plinko.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"plinko.mjs","names":[],"sources":["../../src/transactions/plinko.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/plinko/plinko.js';\nimport type {\n\tBuildPlinkoTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { toU8 } from '../utils/index.js';\nimport { buildSharedStandardGameBetTransaction } from './shared.js';\n\nexport function buildPlinkoTransaction(\n\toptions: WithPartner<BuildPlinkoTransactionOptions>,\n): Transaction {\n\tconst configId = toU8(options.configId);\n\n\treturn buildSharedStandardGameBetTransaction({\n\t\t...options,\n\t\tgame: 'plinko',\n\t\tbuildRewardCoin: ({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\tcoinType,\n\t\t\tstake,\n\t\t\tbetCount,\n\t\t\tmetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t}) =>\n\t\t\tplay({\n\t\t\t\tpackage: config.packageIds.plinko,\n\t\t\t\ttypeArguments: [coinType],\n\t\t\t\targuments: [\n\t\t\t\t\tconfig.packageIds.sweetHouse,\n\t\t\t\t\tstake,\n\t\t\t\t\tbetCoin,\n\t\t\t\t\tbetCount,\n\t\t\t\t\tconfigId,\n\t\t\t\t\tmetadata.keys,\n\t\t\t\t\tmetadata.values,\n\t\t\t\t\tpriceInfoObjectId,\n\t\t\t\t],\n\t\t\t})(tx),\n\t});\n}\n"],"mappings":";;;;AAYA,SAAgB,uBACf,SACc;CACd,MAAM,WAAW,KAAK,QAAQ,QAAQ;CAEtC,OAAO,sCAAsC;EAC5C,GAAG;EACH,MAAM;EACN,kBAAkB,EACjB,IACA,QACA,UACA,OACA,UACA,UACA,mBACA,cAEA,KAAK;GACJ,SAAS,OAAO,WAAW;GAC3B,eAAe,CAAC,QAAQ;GACxB,WAAW;IACV,OAAO,WAAW;IAClB;IACA;IACA;IACA;IACA,SAAS;IACT,SAAS;IACT;GACD;EACD,CAAC,CAAC,CAAC,EAAE;CACP,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.mjs","names":[],"sources":["../../src/transactions/range.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/range/range.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"range.mjs","names":[],"sources":["../../src/transactions/range.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/range/range.js';\nimport type {\n\tBuildRangeTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { DEFAULT_RANGE_SCALE } from '../utils/index.js';\nimport { buildSharedStandardGameBetTransaction } from './shared.js';\n\nexport function buildRangeTransaction(\n\toptions: WithPartner<BuildRangeTransactionOptions>,\n): Transaction {\n\tconst scale = options.scale ?? DEFAULT_RANGE_SCALE;\n\tconst leftPoint = Math.round(options.leftPoint * scale);\n\tconst rightPoint = Math.round(options.rightPoint * scale);\n\n\treturn buildSharedStandardGameBetTransaction({\n\t\t...options,\n\t\tgame: 'range',\n\t\tbuildRewardCoin: ({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\tcoinType,\n\t\t\tstake,\n\t\t\tbetCount,\n\t\t\tmetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t}) =>\n\t\t\tplay({\n\t\t\t\tpackage: config.packageIds.range,\n\t\t\t\ttypeArguments: [coinType],\n\t\t\t\targuments: [\n\t\t\t\t\tconfig.packageIds.sweetHouse,\n\t\t\t\t\tstake,\n\t\t\t\t\tbetCoin,\n\t\t\t\t\tbetCount,\n\t\t\t\t\tBigInt(leftPoint),\n\t\t\t\t\tBigInt(rightPoint),\n\t\t\t\t\tBoolean(options.outOfRange),\n\t\t\t\t\tmetadata.keys,\n\t\t\t\t\tmetadata.values,\n\t\t\t\t\tpriceInfoObjectId,\n\t\t\t\t],\n\t\t\t})(tx),\n\t});\n}\n"],"mappings":";;;;AAYA,SAAgB,sBACf,SACc;CACd,MAAM,QAAQ,QAAQ,SAAA;CACtB,MAAM,YAAY,KAAK,MAAM,QAAQ,YAAY,KAAK;CACtD,MAAM,aAAa,KAAK,MAAM,QAAQ,aAAa,KAAK;CAExD,OAAO,sCAAsC;EAC5C,GAAG;EACH,MAAM;EACN,kBAAkB,EACjB,IACA,QACA,UACA,OACA,UACA,UACA,mBACA,cAEA,KAAK;GACJ,SAAS,OAAO,WAAW;GAC3B,eAAe,CAAC,QAAQ;GACxB,WAAW;IACV,OAAO,WAAW;IAClB;IACA;IACA;IACA,OAAO,SAAS;IAChB,OAAO,UAAU;IACjB,QAAQ,QAAQ,UAAU;IAC1B,SAAS;IACT,SAAS;IACT;GACD;EACD,CAAC,CAAC,CAAC,EAAE;CACP,CAAC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.mjs","names":[],"sources":["../../src/transactions/shared.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport {\n\tassertConfiguredBetGame,\n\tencodeBetMetadata,\n\tresolvePriceInfoObjectId,\n} from '../helpers/index.js';\nimport type {\n\tBaseTransactionOptions,\n\tCoinTransactionOptions,\n\tEncodedBetMetadata,\n\tGame,\n\tSharedBetTransactionOptions,\n\tStakeTransactionOptions,\n\tWithPartner,\n} from '../types';\nimport { DEFAULT_GAS_BUDGET_MIST, toBigInt } from '../utils/index.js';\n\ntype StrictStakeTransactionOptions = {\n\t[K in keyof StakeTransactionOptions]-?: Exclude<\n\t\tStakeTransactionOptions[K],\n\t\tnumber\n\t>;\n};\n\nexport type BuildSharedBetTransactionContext = Pick<\n\tBaseTransactionOptions,\n\t'config' | 'owner'\n> &\n\tPick<CoinTransactionOptions, 'coinType'> &\n\tStrictStakeTransactionOptions & {\n\t\ttx: Transaction;\n\t\tmetadata: EncodedBetMetadata;\n\t\tpriceInfoObjectId: string;\n\t\tbetCoin: TransactionResult;\n\t};\n\nexport type CreateBaseGameTransactionOptions = BaseTransactionOptions & {\n\tgame: Game;\n};\n\nexport type BuildSharedBetTransactionOptions = WithPartner<\n\tSharedBetTransactionOptions & {\n\t\tgame: Game;\n\t\tbuildRewardCoin: (\n\t\t\tcontext: BuildSharedBetTransactionContext,\n\t\t) => TransactionResult;\n\t}\n>;\n\nexport function createBaseGameTransaction({\n\tconfig,\n\tgame,\n\towner,\n\tgasBudget,\n}: CreateBaseGameTransactionOptions): Transaction {\n\tassertConfiguredBetGame(config, game);\n\n\tconst tx = new Transaction();\n\ttx.setSenderIfNotSet(normalizeSuiAddress(owner));\n\ttx.setGasBudgetIfNotSet(gasBudget ?? DEFAULT_GAS_BUDGET_MIST);\n\n\treturn tx;\n}\n\nexport function buildSharedStandardGameBetCall({\n\tconfig,\n\towner,\n\tcoinType,\n\tstake,\n\tcashStake,\n\tbetCount,\n\tmetadata,\n\tpartner,\n\tallowGasCoinShortcut = true,\n\tbuildRewardCoin,\n}: BuildSharedBetTransactionOptions): (tx: Transaction) => TransactionArgument {\n\treturn (tx: Transaction) => {\n\t\tconst normalizedOwner = normalizeSuiAddress(owner);\n\t\tconst normalizedCoinType = normalizeStructTag(coinType);\n\t\tconst resolvedStake = toBigInt(stake);\n\t\tconst resolvedCashStake = toBigInt(cashStake ?? stake);\n\t\tconst resolvedBetCount = toBigInt(betCount ?? 1);\n\t\tconst encodedMetadata = encodeBetMetadata(metadata, partner);\n\t\tconst priceInfoObjectId = resolvePriceInfoObjectId(\n\t\t\tconfig,\n\t\t\tnormalizedCoinType,\n\t\t);\n\n\t\tconst betCoin = tx.coin({\n\t\t\ttype: normalizedCoinType,\n\t\t\tbalance: resolvedCashStake,\n\t\t\tuseGasCoin: allowGasCoinShortcut,\n\t\t});\n\n\t\tconst rewardCoin = buildRewardCoin({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\towner: normalizedOwner,\n\t\t\tcoinType: normalizedCoinType,\n\t\t\tstake: resolvedStake,\n\t\t\tcashStake: resolvedCashStake,\n\t\t\tbetCount: resolvedBetCount,\n\t\t\tmetadata: encodedMetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t});\n\n\t\ttx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));\n\t\treturn rewardCoin;\n\t};\n}\n\nexport function buildSharedStandardGameBetTransaction(\n\toptions: BuildSharedBetTransactionOptions,\n): Transaction {\n\tconst tx = createBaseGameTransaction(options);\n\ttx.add(buildSharedStandardGameBetCall(options));\n\treturn tx;\n}\n"],"mappings":";;;;;;;AAyDA,SAAgB,0BAA0B,EACzC,QACA,MACA,OACA,aACiD;CACjD,wBAAwB,QAAQ,IAAI;CAEpC,MAAM,KAAK,IAAI,YAAY;CAC3B,GAAG,kBAAkB,oBAAoB,KAAK,CAAC;CAC/C,GAAG,qBAAqB,aAAa,uBAAuB;CAE5D,OAAO;AACR;AAEA,SAAgB,+BAA+B,EAC9C,QACA,OACA,UACA,OACA,WACA,UACA,UACA,SACA,uBAAuB,MACvB,mBAC8E;CAC9E,QAAQ,OAAoB;EAC3B,MAAM,kBAAkB,oBAAoB,KAAK;EACjD,MAAM,qBAAqB,mBAAmB,QAAQ;EACtD,MAAM,gBAAgB,SAAS,KAAK;EACpC,MAAM,oBAAoB,SAAS,aAAa,KAAK;EAcrD,MAAM,aAAa,gBAAgB;GAClC;GACA;GACA,OAAO;GACP,UAAU;GACV,OAAO;GACP,WAAW;GACX,UApBwB,SAAS,YAAY,CAoBpB;GACzB,UApBuB,kBAAkB,UAAU,OAoB3B;GACxB,mBApByB,yBACzB,QACA,kBAkBgB;GAChB,SAhBe,GAAG,KAAK;IACvB,MAAM;IACN,SAAS;IACT,YAAY;GACb,CAYO;EACP,CAAC;EAED,GAAG,gBAAgB,CAAC,UAAU,GAAG,GAAG,KAAK,QAAQ,eAAe,CAAC;EACjE,OAAO;CACR;AACD;AAEA,SAAgB,sCACf,SACc;CACd,MAAM,KAAK,0BAA0B,OAAO;CAC5C,GAAG,IAAI,+BAA+B,OAAO,CAAC;CAC9C,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"shared.mjs","names":[],"sources":["../../src/transactions/shared.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport {\n\tassertConfiguredBetGame,\n\tencodeBetMetadata,\n\tresolvePriceInfoObjectId,\n} from '../helpers/index.js';\nimport type {\n\tBaseTransactionOptions,\n\tCoinTransactionOptions,\n\tEncodedBetMetadata,\n\tGame,\n\tSharedBetTransactionOptions,\n\tStakeTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { DEFAULT_GAS_BUDGET_MIST, toBigInt } from '../utils/index.js';\n\ntype StrictStakeTransactionOptions = {\n\t[K in keyof StakeTransactionOptions]-?: Exclude<\n\t\tStakeTransactionOptions[K],\n\t\tnumber\n\t>;\n};\n\nexport type BuildSharedBetTransactionContext = Pick<\n\tBaseTransactionOptions,\n\t'config' | 'owner'\n> &\n\tPick<CoinTransactionOptions, 'coinType'> &\n\tStrictStakeTransactionOptions & {\n\t\ttx: Transaction;\n\t\tmetadata: EncodedBetMetadata;\n\t\tpriceInfoObjectId: string;\n\t\tbetCoin: TransactionResult;\n\t};\n\nexport type CreateBaseGameTransactionOptions = BaseTransactionOptions & {\n\tgame: Game;\n};\n\nexport type BuildSharedBetTransactionOptions = WithPartner<\n\tSharedBetTransactionOptions & {\n\t\tgame: Game;\n\t\tbuildRewardCoin: (\n\t\t\tcontext: BuildSharedBetTransactionContext,\n\t\t) => TransactionResult;\n\t}\n>;\n\nexport function createBaseGameTransaction({\n\tconfig,\n\tgame,\n\towner,\n\tgasBudget,\n}: CreateBaseGameTransactionOptions): Transaction {\n\tassertConfiguredBetGame(config, game);\n\n\tconst tx = new Transaction();\n\ttx.setSenderIfNotSet(normalizeSuiAddress(owner));\n\ttx.setGasBudgetIfNotSet(gasBudget ?? DEFAULT_GAS_BUDGET_MIST);\n\n\treturn tx;\n}\n\nexport function buildSharedStandardGameBetCall({\n\tconfig,\n\towner,\n\tcoinType,\n\tstake,\n\tcashStake,\n\tbetCount,\n\tmetadata,\n\tpartner,\n\tallowGasCoinShortcut = true,\n\tbuildRewardCoin,\n}: BuildSharedBetTransactionOptions): (tx: Transaction) => TransactionArgument {\n\treturn (tx: Transaction) => {\n\t\tconst normalizedOwner = normalizeSuiAddress(owner);\n\t\tconst normalizedCoinType = normalizeStructTag(coinType);\n\t\tconst resolvedStake = toBigInt(stake);\n\t\tconst resolvedCashStake = toBigInt(cashStake ?? stake);\n\t\tconst resolvedBetCount = toBigInt(betCount ?? 1);\n\t\tconst encodedMetadata = encodeBetMetadata(metadata, partner);\n\t\tconst priceInfoObjectId = resolvePriceInfoObjectId(\n\t\t\tconfig,\n\t\t\tnormalizedCoinType,\n\t\t);\n\n\t\tconst betCoin = tx.coin({\n\t\t\ttype: normalizedCoinType,\n\t\t\tbalance: resolvedCashStake,\n\t\t\tuseGasCoin: allowGasCoinShortcut,\n\t\t});\n\n\t\tconst rewardCoin = buildRewardCoin({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\towner: normalizedOwner,\n\t\t\tcoinType: normalizedCoinType,\n\t\t\tstake: resolvedStake,\n\t\t\tcashStake: resolvedCashStake,\n\t\t\tbetCount: resolvedBetCount,\n\t\t\tmetadata: encodedMetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t});\n\n\t\ttx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));\n\t\treturn rewardCoin;\n\t};\n}\n\nexport function buildSharedStandardGameBetTransaction(\n\toptions: BuildSharedBetTransactionOptions,\n): Transaction {\n\tconst tx = createBaseGameTransaction(options);\n\ttx.add(buildSharedStandardGameBetCall(options));\n\treturn tx;\n}\n"],"mappings":";;;;;;;AAyDA,SAAgB,0BAA0B,EACzC,QACA,MACA,OACA,aACiD;CACjD,wBAAwB,QAAQ,IAAI;CAEpC,MAAM,KAAK,IAAI,YAAY;CAC3B,GAAG,kBAAkB,oBAAoB,KAAK,CAAC;CAC/C,GAAG,qBAAqB,aAAa,uBAAuB;CAE5D,OAAO;AACR;AAEA,SAAgB,+BAA+B,EAC9C,QACA,OACA,UACA,OACA,WACA,UACA,UACA,SACA,uBAAuB,MACvB,mBAC8E;CAC9E,QAAQ,OAAoB;EAC3B,MAAM,kBAAkB,oBAAoB,KAAK;EACjD,MAAM,qBAAqB,mBAAmB,QAAQ;EACtD,MAAM,gBAAgB,SAAS,KAAK;EACpC,MAAM,oBAAoB,SAAS,aAAa,KAAK;EAcrD,MAAM,aAAa,gBAAgB;GAClC;GACA;GACA,OAAO;GACP,UAAU;GACV,OAAO;GACP,WAAW;GACX,UApBwB,SAAS,YAAY,CAoBpB;GACzB,UApBuB,kBAAkB,UAAU,OAoB3B;GACxB,mBApByB,yBACzB,QACA,kBAkBgB;GAChB,SAhBe,GAAG,KAAK;IACvB,MAAM;IACN,SAAS;IACT,YAAY;GACb,CAYO;EACP,CAAC;EAED,GAAG,gBAAgB,CAAC,UAAU,GAAG,GAAG,KAAK,QAAQ,eAAe,CAAC;EACjE,OAAO;CACR;AACD;AAEA,SAAgB,sCACf,SACc;CACd,MAAM,KAAK,0BAA0B,OAAO;CAC5C,GAAG,IAAI,+BAA+B,OAAO,CAAC;CAC9C,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wheel.mjs","names":[],"sources":["../../src/transactions/wheel.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/wheel/wheel.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"wheel.mjs","names":[],"sources":["../../src/transactions/wheel.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Transaction } from '@mysten/sui/transactions';\nimport { play } from '../contracts/wheel/wheel.js';\nimport type {\n\tBuildWheelTransactionOptions,\n\tWithPartner,\n} from '../types/index.js';\nimport { toU8 } from '../utils/index.js';\nimport { buildSharedStandardGameBetTransaction } from './shared.js';\n\nexport function buildWheelTransaction(\n\toptions: WithPartner<BuildWheelTransactionOptions>,\n): Transaction {\n\tconst configId = toU8(options.configId);\n\n\treturn buildSharedStandardGameBetTransaction({\n\t\t...options,\n\t\tgame: 'wheel',\n\t\tbuildRewardCoin: ({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\tcoinType,\n\t\t\tstake,\n\t\t\tbetCount,\n\t\t\tmetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t}) =>\n\t\t\tplay({\n\t\t\t\tpackage: config.packageIds.wheel,\n\t\t\t\ttypeArguments: [coinType],\n\t\t\t\targuments: [\n\t\t\t\t\tconfig.packageIds.sweetHouse,\n\t\t\t\t\tstake,\n\t\t\t\t\tbetCoin,\n\t\t\t\t\tbetCount,\n\t\t\t\t\tconfigId,\n\t\t\t\t\tmetadata.keys,\n\t\t\t\t\tmetadata.values,\n\t\t\t\t\tpriceInfoObjectId,\n\t\t\t\t],\n\t\t\t})(tx),\n\t});\n}\n"],"mappings":";;;;AAYA,SAAgB,sBACf,SACc;CACd,MAAM,WAAW,KAAK,QAAQ,QAAQ;CAEtC,OAAO,sCAAsC;EAC5C,GAAG;EACH,MAAM;EACN,kBAAkB,EACjB,IACA,QACA,UACA,OACA,UACA,UACA,mBACA,cAEA,KAAK;GACJ,SAAS,OAAO,WAAW;GAC3B,eAAe,CAAC,QAAQ;GACxB,WAAW;IACV,OAAO,WAAW;IAClB;IACA;IACA;IACA;IACA,SAAS;IACT,SAAS;IACT;GACD;EACD,CAAC,CAAC,CAAC,EAAE;CACP,CAAC;AACF"}
|
package/dist/ttl-cache.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttl-cache.mjs","names":["#ttlMs","#loadEntry","#loadSyncEntry"],"sources":["../src/ttl-cache.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ClientCache, type ClientCacheOptions } from '@mysten/sui/client';\n\ntype CacheEntry<Value> = {\n\texpiresAt: number;\n\tvalue: Value;\n};\n\ntype TtlClientCacheReadOptions = {\n\tignoreCache?: boolean;\n};\n\nexport class TtlClientCache extends ClientCache {\n\t#ttlMs: number;\n\n\tconstructor({ ttlMs, ...options }: ClientCacheOptions & { ttlMs: number }) {\n\t\tsuper({\n\t\t\t...options,\n\t\t\tprefix: options.prefix ?? ['ttl'],\n\t\t});\n\t\tthis.#ttlMs = ttlMs;\n\t}\n\n\toverride read<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T | Promise<T>,\n\t\toptions?: TtlClientCacheReadOptions,\n\t): T | Promise<T> {\n\t\tif (options?.ignoreCache) {\n\t\t\tsuper.clear(key);\n\t\t}\n\n\t\tif (this.#ttlMs <= 0) {\n\t\t\treturn load();\n\t\t}\n\n\t\tconst cached = super.read<CacheEntry<T | Promise<T>>>(key, () =>\n\t\t\tthis.#loadEntry(key, load),\n\t\t) as CacheEntry<T | Promise<T>>;\n\n\t\tif (cached && cached.expiresAt > Date.now()) {\n\t\t\treturn cached.value as T;\n\t\t}\n\n\t\tsuper.clear(key);\n\t\treturn (\n\t\t\tsuper.read<CacheEntry<T | Promise<T>>>(key, () =>\n\t\t\t\tthis.#loadEntry(key, load),\n\t\t\t) as CacheEntry<T | Promise<T>>\n\t\t).value as T | Promise<T>;\n\t}\n\n\toverride readSync<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T,\n\t\toptions?: TtlClientCacheReadOptions,\n\t): T {\n\t\tif (options?.ignoreCache) {\n\t\t\tsuper.clear(key);\n\t\t}\n\n\t\tif (this.#ttlMs <= 0) {\n\t\t\treturn load();\n\t\t}\n\n\t\tconst cached = super.readSync<CacheEntry<T>>(key, () =>\n\t\t\tthis.#loadSyncEntry(load),\n\t\t);\n\n\t\tif (cached.expiresAt > Date.now()) {\n\t\t\treturn cached.value;\n\t\t}\n\n\t\tsuper.clear(key);\n\t\treturn super.readSync<CacheEntry<T>>(key, () => this.#loadSyncEntry(load))\n\t\t\t.value;\n\t}\n\n\t#loadEntry<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T | Promise<T>,\n\t): CacheEntry<T | Promise<T>> {\n\t\tconst value = load();\n\t\tconst entry: CacheEntry<T | Promise<T>> = {\n\t\t\tvalue,\n\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t};\n\n\t\tif (isPromiseLike(value)) {\n\t\t\tentry.value = Promise.resolve(value)\n\t\t\t\t.then((resolved) => {\n\t\t\t\t\tsuper.clear(key);\n\t\t\t\t\tsuper.read<CacheEntry<T>>(key, () => ({\n\t\t\t\t\t\tvalue: resolved,\n\t\t\t\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t\t\t\t}));\n\t\t\t\t\treturn resolved as T;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tsuper.clear(key);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\t#loadSyncEntry<T>(load: () => T): CacheEntry<T> {\n\t\treturn {\n\t\t\tvalue: load(),\n\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t};\n\t}\n}\n\nfunction isPromiseLike<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn (\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\tvalue !== null &&\n\t\t'then' in value\n\t);\n}\n"],"mappings":";;AAcA,IAAa,iBAAb,cAAoC,YAAY;CAC/C;CAEA,YAAY,EAAE,OAAO,GAAG,WAAmD;EAC1E,MAAM;GACL,GAAG;GACH,QAAQ,QAAQ,UAAU,CAAC,KAAK;EACjC,CAAC;EACD,KAAKA,SAAS;CACf;CAEA,KACC,KACA,MACA,SACiB;EACjB,IAAI,SAAS,aACZ,MAAM,MAAM,GAAG;EAGhB,IAAI,KAAKA,UAAU,GAClB,OAAO,KAAK;EAGb,MAAM,SAAS,MAAM,KAAiC,WACrD,KAAKC,WAAW,KAAK,IAAI,CAC1B;EAEA,IAAI,UAAU,OAAO,YAAY,KAAK,IAAI,GACzC,OAAO,OAAO;EAGf,MAAM,MAAM,GAAG;EACf,OACC,MAAM,KAAiC,WACtC,KAAKA,WAAW,KAAK,IAAI,CAC1B,
|
|
1
|
+
{"version":3,"file":"ttl-cache.mjs","names":["#ttlMs","#loadEntry","#loadSyncEntry"],"sources":["../src/ttl-cache.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ClientCache, type ClientCacheOptions } from '@mysten/sui/client';\n\ntype CacheEntry<Value> = {\n\texpiresAt: number;\n\tvalue: Value;\n};\n\ntype TtlClientCacheReadOptions = {\n\tignoreCache?: boolean;\n};\n\nexport class TtlClientCache extends ClientCache {\n\t#ttlMs: number;\n\n\tconstructor({ ttlMs, ...options }: ClientCacheOptions & { ttlMs: number }) {\n\t\tsuper({\n\t\t\t...options,\n\t\t\tprefix: options.prefix ?? ['ttl'],\n\t\t});\n\t\tthis.#ttlMs = ttlMs;\n\t}\n\n\toverride read<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T | Promise<T>,\n\t\toptions?: TtlClientCacheReadOptions,\n\t): T | Promise<T> {\n\t\tif (options?.ignoreCache) {\n\t\t\tsuper.clear(key);\n\t\t}\n\n\t\tif (this.#ttlMs <= 0) {\n\t\t\treturn load();\n\t\t}\n\n\t\tconst cached = super.read<CacheEntry<T | Promise<T>>>(key, () =>\n\t\t\tthis.#loadEntry(key, load),\n\t\t) as CacheEntry<T | Promise<T>>;\n\n\t\tif (cached && cached.expiresAt > Date.now()) {\n\t\t\treturn cached.value as T;\n\t\t}\n\n\t\tsuper.clear(key);\n\t\treturn (\n\t\t\tsuper.read<CacheEntry<T | Promise<T>>>(key, () =>\n\t\t\t\tthis.#loadEntry(key, load),\n\t\t\t) as CacheEntry<T | Promise<T>>\n\t\t).value as T | Promise<T>;\n\t}\n\n\toverride readSync<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T,\n\t\toptions?: TtlClientCacheReadOptions,\n\t): T {\n\t\tif (options?.ignoreCache) {\n\t\t\tsuper.clear(key);\n\t\t}\n\n\t\tif (this.#ttlMs <= 0) {\n\t\t\treturn load();\n\t\t}\n\n\t\tconst cached = super.readSync<CacheEntry<T>>(key, () =>\n\t\t\tthis.#loadSyncEntry(load),\n\t\t);\n\n\t\tif (cached.expiresAt > Date.now()) {\n\t\t\treturn cached.value;\n\t\t}\n\n\t\tsuper.clear(key);\n\t\treturn super.readSync<CacheEntry<T>>(key, () => this.#loadSyncEntry(load))\n\t\t\t.value;\n\t}\n\n\t#loadEntry<T>(\n\t\tkey: [string, ...string[]],\n\t\tload: () => T | Promise<T>,\n\t): CacheEntry<T | Promise<T>> {\n\t\tconst value = load();\n\t\tconst entry: CacheEntry<T | Promise<T>> = {\n\t\t\tvalue,\n\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t};\n\n\t\tif (isPromiseLike(value)) {\n\t\t\tentry.value = Promise.resolve(value)\n\t\t\t\t.then((resolved) => {\n\t\t\t\t\tsuper.clear(key);\n\t\t\t\t\tsuper.read<CacheEntry<T>>(key, () => ({\n\t\t\t\t\t\tvalue: resolved,\n\t\t\t\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t\t\t\t}));\n\t\t\t\t\treturn resolved as T;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tsuper.clear(key);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\t#loadSyncEntry<T>(load: () => T): CacheEntry<T> {\n\t\treturn {\n\t\t\tvalue: load(),\n\t\t\texpiresAt: Date.now() + this.#ttlMs,\n\t\t};\n\t}\n}\n\nfunction isPromiseLike<T>(value: T | Promise<T>): value is Promise<T> {\n\treturn (\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\tvalue !== null &&\n\t\t'then' in value\n\t);\n}\n"],"mappings":";;AAcA,IAAa,iBAAb,cAAoC,YAAY;CAC/C;CAEA,YAAY,EAAE,OAAO,GAAG,WAAmD;EAC1E,MAAM;GACL,GAAG;GACH,QAAQ,QAAQ,UAAU,CAAC,KAAK;EACjC,CAAC;EACD,KAAKA,SAAS;CACf;CAEA,KAC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,UAAU,YAAY,OAAO,UAAU,eAC/C,UAAU,QACV,UAAU;AAEZ"}
|
|
@@ -8,17 +8,17 @@ type GameDetailValueType = 'u8' | 'u64' | 'bool' | 'float' | 'string';
|
|
|
8
8
|
type GameDetail<TValueType extends GameDetailValueType> = TValueType extends 'float' | 'u64' ? number : ReturnType<(typeof GAME_DETAIL_BCS)[TValueType]['parse']>;
|
|
9
9
|
type GameDetails<TGame extends Game> = { [K in keyof (typeof GAME_DETAILS_SCHEMAS)[TGame]]: GameDetail<(typeof GAME_DETAILS_SCHEMAS)[TGame][K] & GameDetailValueType> };
|
|
10
10
|
declare const GAME_DETAIL_BCS: {
|
|
11
|
-
readonly u8: import("@mysten/bcs").BcsType<number, number, "u8">;
|
|
12
|
-
readonly u64: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
13
|
-
readonly bool: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
11
|
+
readonly u8: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
|
|
12
|
+
readonly u64: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
13
|
+
readonly bool: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
14
14
|
readonly float: MoveStruct<{
|
|
15
|
-
is_negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
|
|
15
|
+
is_negative: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
16
16
|
exp: MoveStruct<{
|
|
17
|
-
bits: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
17
|
+
bits: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
18
18
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64">;
|
|
19
|
-
mant: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
19
|
+
mant: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
20
20
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
21
|
-
readonly string: import("@mysten/bcs").BcsType<string, string, "string">;
|
|
21
|
+
readonly string: import("@mysten/sui/bcs").BcsType<string, string, "string">;
|
|
22
22
|
};
|
|
23
23
|
declare const GAME_DETAILS_SCHEMAS: {
|
|
24
24
|
coinflip: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game-details.type.mjs","names":[],"sources":["../../src/types/game-details.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { BetResultEvent } from '../contracts/core/core';\nimport { Float } from '../contracts/core/float';\nimport type { Game } from './game.type.js';\n\nexport type BetResultGameDetails = ReturnType<\n\t(typeof BetResultEvent)['parse']\n>['game_details'];\n\nexport type GameDetailValueType = 'u8' | 'u64' | 'bool' | 'float' | 'string';\nexport type GameDetailsSchema = Record<string, GameDetailValueType>;\n\nexport type GameDetail<TValueType extends GameDetailValueType> =\n\tTValueType extends 'float' | 'u64'\n\t\t? number\n\t\t: ReturnType<(typeof GAME_DETAIL_BCS)[TValueType]['parse']>;\n\nexport type GameDetails<TGame extends Game> = {\n\t[K in keyof (typeof GAME_DETAILS_SCHEMAS)[TGame]]: GameDetail<\n\t\t(typeof GAME_DETAILS_SCHEMAS)[TGame][K] & GameDetailValueType\n\t>;\n};\n\nexport const GAME_DETAIL_BCS = {\n\tu8: bcs.U8,\n\tu64: bcs.U64,\n\tbool: bcs.Bool,\n\tfloat: Float,\n\tstring: bcs.String,\n} as const;\n\nconst COINFLIP_GAME_DETAILS_SCHEMA = {\n\tplayer_bet: 'string',\n\tcoin_outcome: 'string',\n} satisfies GameDetailsSchema;\n\nconst PVP_COINFLIP_GAME_DETAILS_SCHEMA = {\n\tpvp_result: 'string',\n} satisfies GameDetailsSchema;\n\nconst LIMBO_GAME_DETAILS_SCHEMA = {\n\tpayout_amount: 'u64',\n\twin: 'bool',\n\troll_multiplier: 'float',\n\tpayout_multiplier: 'float',\n\ttarget_multiplier: 'float',\n\tactual_rtp: 'float',\n} satisfies GameDetailsSchema;\n\nconst RANGE_GAME_DETAILS_SCHEMA = {\n\troll_value: 'u64',\n\twin: 'bool',\n\tpayout_amount: 'u64',\n\tpayout_multiplier: 'float',\n\tleft_point: 'u64',\n\tright_point: 'u64',\n\tzone_size: 'u64',\n\twinning_zone_size: 'u64',\n\tis_out_range: 'bool',\n\tbet_threshold: 'u64',\n\troll_under: 'bool',\n\trange_mode: 'u8',\n\twin_probability: 'float',\n\twin_multiplier: 'float',\n\tactual_rtp: 'float',\n} satisfies GameDetailsSchema;\n\nconst PLINKO_GAME_DETAILS_SCHEMA = {\n\tslot_index: 'u8',\n\tmultiplier: 'float',\n\tpayout_amount: 'u64',\n\tplinko_config: 'u8',\n} satisfies GameDetailsSchema;\n\nconst WHEEL_GAME_DETAILS_SCHEMA = {\n\tcase_index: 'u8',\n\tmultiplier: 'float',\n\tpayout_amount: 'u64',\n\twheel_config: 'u8',\n\tspin_value: 'u64',\n} satisfies GameDetailsSchema;\n\nexport const GAME_DETAILS_SCHEMAS = {\n\tcoinflip: COINFLIP_GAME_DETAILS_SCHEMA,\n\tlimbo: LIMBO_GAME_DETAILS_SCHEMA,\n\tplinko: PLINKO_GAME_DETAILS_SCHEMA,\n\t'pvp-coinflip': PVP_COINFLIP_GAME_DETAILS_SCHEMA,\n\trange: RANGE_GAME_DETAILS_SCHEMA,\n\twheel: WHEEL_GAME_DETAILS_SCHEMA,\n} satisfies Record<Game, GameDetailsSchema>;\n"],"mappings":";;;AA0BA,MAAa,kBAAkB;CAC9B,IAAI,IAAI;CACR,KAAK,IAAI;CACT,MAAM,IAAI;CACV,OAAO;CACP,QAAQ,IAAI;AACb;AAqDA,MAAa,uBAAuB;CACnC,UAAU;EAnDV,YAAY;EACZ,cAAc;CAkDJ;CACV,OAAO;EA3CP,eAAe;EACf,KAAK;EACL,iBAAiB;EACjB,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;CAsCL;CACP,QAAQ;EAjBR,YAAY;EACZ,YAAY;EACZ,eAAe;EACf,eAAe;CAcP;CACR,gBAAgB,EAjDhB,YAAY,SAiDI;CAChB,OAAO;EArCP,YAAY;EACZ,KAAK;EACL,eAAe;EACf,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,WAAW;EACX,mBAAmB;EACnB,cAAc;EACd,eAAe;EACf,YAAY;EACZ,YAAY;EACZ,iBAAiB;EACjB,gBAAgB;EAChB,YAAY;CAuBL;CACP,OAAO;EAbP,YAAY;EACZ,YAAY;EACZ,eAAe;EACf,cAAc;EACd,YAAY;CASL;AACR"}
|
|
1
|
+
{"version":3,"file":"game-details.type.mjs","names":[],"sources":["../../src/types/game-details.type.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { BetResultEvent } from '../contracts/core/core.js';\nimport { Float } from '../contracts/core/float.js';\nimport type { Game } from './game.type.js';\n\nexport type BetResultGameDetails = ReturnType<\n\t(typeof BetResultEvent)['parse']\n>['game_details'];\n\nexport type GameDetailValueType = 'u8' | 'u64' | 'bool' | 'float' | 'string';\nexport type GameDetailsSchema = Record<string, GameDetailValueType>;\n\nexport type GameDetail<TValueType extends GameDetailValueType> =\n\tTValueType extends 'float' | 'u64'\n\t\t? number\n\t\t: ReturnType<(typeof GAME_DETAIL_BCS)[TValueType]['parse']>;\n\nexport type GameDetails<TGame extends Game> = {\n\t[K in keyof (typeof GAME_DETAILS_SCHEMAS)[TGame]]: GameDetail<\n\t\t(typeof GAME_DETAILS_SCHEMAS)[TGame][K] & GameDetailValueType\n\t>;\n};\n\nexport const GAME_DETAIL_BCS = {\n\tu8: bcs.U8,\n\tu64: bcs.U64,\n\tbool: bcs.Bool,\n\tfloat: Float,\n\tstring: bcs.String,\n} as const;\n\nconst COINFLIP_GAME_DETAILS_SCHEMA = {\n\tplayer_bet: 'string',\n\tcoin_outcome: 'string',\n} satisfies GameDetailsSchema;\n\nconst PVP_COINFLIP_GAME_DETAILS_SCHEMA = {\n\tpvp_result: 'string',\n} satisfies GameDetailsSchema;\n\nconst LIMBO_GAME_DETAILS_SCHEMA = {\n\tpayout_amount: 'u64',\n\twin: 'bool',\n\troll_multiplier: 'float',\n\tpayout_multiplier: 'float',\n\ttarget_multiplier: 'float',\n\tactual_rtp: 'float',\n} satisfies GameDetailsSchema;\n\nconst RANGE_GAME_DETAILS_SCHEMA = {\n\troll_value: 'u64',\n\twin: 'bool',\n\tpayout_amount: 'u64',\n\tpayout_multiplier: 'float',\n\tleft_point: 'u64',\n\tright_point: 'u64',\n\tzone_size: 'u64',\n\twinning_zone_size: 'u64',\n\tis_out_range: 'bool',\n\tbet_threshold: 'u64',\n\troll_under: 'bool',\n\trange_mode: 'u8',\n\twin_probability: 'float',\n\twin_multiplier: 'float',\n\tactual_rtp: 'float',\n} satisfies GameDetailsSchema;\n\nconst PLINKO_GAME_DETAILS_SCHEMA = {\n\tslot_index: 'u8',\n\tmultiplier: 'float',\n\tpayout_amount: 'u64',\n\tplinko_config: 'u8',\n} satisfies GameDetailsSchema;\n\nconst WHEEL_GAME_DETAILS_SCHEMA = {\n\tcase_index: 'u8',\n\tmultiplier: 'float',\n\tpayout_amount: 'u64',\n\twheel_config: 'u8',\n\tspin_value: 'u64',\n} satisfies GameDetailsSchema;\n\nexport const GAME_DETAILS_SCHEMAS = {\n\tcoinflip: COINFLIP_GAME_DETAILS_SCHEMA,\n\tlimbo: LIMBO_GAME_DETAILS_SCHEMA,\n\tplinko: PLINKO_GAME_DETAILS_SCHEMA,\n\t'pvp-coinflip': PVP_COINFLIP_GAME_DETAILS_SCHEMA,\n\trange: RANGE_GAME_DETAILS_SCHEMA,\n\twheel: WHEEL_GAME_DETAILS_SCHEMA,\n} satisfies Record<Game, GameDetailsSchema>;\n"],"mappings":";;;AA0BA,MAAa,kBAAkB;CAC9B,IAAI,IAAI;CACR,KAAK,IAAI;CACT,MAAM,IAAI;CACV,OAAO;CACP,QAAQ,IAAI;AACb;AAqDA,MAAa,uBAAuB;CACnC,UAAU;EAnDV,YAAY;EACZ,cAAc;CAkDJ;CACV,OAAO;EA3CP,eAAe;EACf,KAAK;EACL,iBAAiB;EACjB,mBAAmB;EACnB,mBAAmB;EACnB,YAAY;CAsCL;CACP,QAAQ;EAjBR,YAAY;EACZ,YAAY;EACZ,eAAe;EACf,eAAe;CAcP;CACR,gBAAgB,EAjDhB,YAAY,SAiDI;CAChB,OAAO;EArCP,YAAY;EACZ,KAAK;EACL,eAAe;EACf,mBAAmB;EACnB,YAAY;EACZ,aAAa;EACb,WAAW;EACX,mBAAmB;EACnB,cAAc;EACd,eAAe;EACf,YAAY;EACZ,YAAY;EACZ,iBAAiB;EACjB,gBAAgB;EAChB,YAAY;CAuBL;CACP,OAAO;EAbP,YAAY;EACZ,YAAY;EACZ,eAAe;EACf,cAAc;EACd,YAAY;CASL;AACR"}
|
|
@@ -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;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
|
+
{"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.js';\nimport {\n\tParameters as LimboParameters,\n\tLimboSettingsKey,\n} from '../contracts/limbo/limbo.js';\nimport {\n\tParameters as PlinkoParameters,\n\tPlinkoSettingsKey,\n} from '../contracts/plinko/plinko.js';\nimport {\n\tParameters as PvPCoinflipParameters,\n\tPvpCoinflipSettingsKey,\n} from '../contracts/pvp-coinflip/pvp_coinflip.js';\nimport {\n\tParameters as RangeParameters,\n\tRangeSettingsKey,\n} from '../contracts/range/range.js';\nimport {\n\tParameters as WheelParameters,\n\tWheelSettingsKey,\n} from '../contracts/wheel/wheel.js';\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":"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,SA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a,OAAO,OAAO,KAAK;AACxC"}
|
|
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/index.js';\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,IA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A,CAAc,IAAY;;;;;;;;AAuBxB;AAqElB;;;;iBAvEgB,cAAA,CACf,KAAA,EAAO,cAAA,CAAe,KAAA,GACpB,eAAe;;;;;;;;;;;;;;;AAwEE;;;;;;;iBAHJ,gBAAA,eAA+B,IAAA,
|
|
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,EAC9C,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,YAAY;;;;;;;;;;;AAYpC,SAAgB,cAAc,MAAsB;CACnD,MAAM,WAAW,eAAe,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/index.js';\nimport { fromMoveFloat } from './numeric.js';\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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;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.20",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suigar",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": "^22.18.0 || >=24"
|
|
42
|
+
"node": "^22.18.0 || >=24.0.0"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
@@ -53,23 +53,23 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://docs.suigar.com/sdk",
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mysten/bcs": "^2.0
|
|
57
|
-
"@mysten/sui": "^2.
|
|
56
|
+
"@mysten/bcs": "^2.1.0",
|
|
57
|
+
"@mysten/sui": "^2.20.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@mysten/bcs": "^2.0
|
|
61
|
-
"@mysten/codegen": "^0.
|
|
62
|
-
"@mysten/sui": "^2.
|
|
60
|
+
"@mysten/bcs": "^2.1.0",
|
|
61
|
+
"@mysten/codegen": "^0.11.2",
|
|
62
|
+
"@mysten/sui": "^2.20.0",
|
|
63
63
|
"@types/node": "^24.0.0",
|
|
64
|
-
"tsdown": "^0.22.
|
|
65
|
-
"tsx": "^4.22.
|
|
66
|
-
"typescript": "^
|
|
67
|
-
"vitest": "^4.1.
|
|
64
|
+
"tsdown": "^0.22.3",
|
|
65
|
+
"tsx": "^4.22.4",
|
|
66
|
+
"typescript": "^6.0.3",
|
|
67
|
+
"vitest": "^4.1.9"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "pnpm clean && pnpm codegen && tsdown",
|
|
71
71
|
"build:ci": "rm -rf dist && tsdown",
|
|
72
|
-
"clean": "rm -rf dist src/contracts
|
|
72
|
+
"clean": "rm -rf dist src/contracts",
|
|
73
73
|
"codegen": "node ./scripts/update-package-configs.mjs && sui-ts-codegen generate && pnpm lint",
|
|
74
74
|
"eslint:fix": "eslint . --fix",
|
|
75
75
|
"format": "pnpm prettier:fix",
|