@suigar/mcp 0.1.0
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/README.md +164 -0
- package/dist/bin.cjs +11 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +12 -0
- package/dist/client.cjs +46 -0
- package/dist/client.d.cts +17 -0
- package/dist/client.d.mts +17 -0
- package/dist/client.mjs +43 -0
- package/dist/coin.cjs +86 -0
- package/dist/coin.d.cts +35 -0
- package/dist/coin.d.mts +35 -0
- package/dist/coin.mjs +86 -0
- package/dist/config.cjs +183 -0
- package/dist/config.d.cts +15 -0
- package/dist/config.d.mts +15 -0
- package/dist/config.mjs +174 -0
- package/dist/index.cjs +53 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +9 -0
- package/dist/mcp-support.cjs +62 -0
- package/dist/mcp-support.d.cts +16 -0
- package/dist/mcp-support.d.mts +16 -0
- package/dist/mcp-support.mjs +60 -0
- package/dist/metadata.cjs +51 -0
- package/dist/metadata.d.cts +52 -0
- package/dist/metadata.d.mts +52 -0
- package/dist/metadata.mjs +47 -0
- package/dist/server.cjs +433 -0
- package/dist/server.d.cts +73 -0
- package/dist/server.d.mts +73 -0
- package/dist/server.mjs +431 -0
- package/dist/tools.cjs +617 -0
- package/dist/tools.d.cts +158 -0
- package/dist/tools.d.mts +158 -0
- package/dist/tools.mjs +608 -0
- package/dist/transactions.cjs +294 -0
- package/dist/transactions.d.cts +40 -0
- package/dist/transactions.d.mts +40 -0
- package/dist/transactions.mjs +286 -0
- package/dist/types.d.cts +111 -0
- package/dist/types.d.mts +111 -0
- package/node_modules/@suigar/currency-registry/dist/index.cjs +121 -0
- package/node_modules/@suigar/currency-registry/dist/index.d.cts +50 -0
- package/node_modules/@suigar/currency-registry/dist/index.d.mts +50 -0
- package/node_modules/@suigar/currency-registry/dist/index.mjs +110 -0
- package/node_modules/@suigar/currency-registry/package.json +31 -0
- package/node_modules/@suigar/game-registry/dist/index.cjs +310 -0
- package/node_modules/@suigar/game-registry/dist/index.d.cts +65 -0
- package/node_modules/@suigar/game-registry/dist/index.d.mts +65 -0
- package/node_modules/@suigar/game-registry/dist/index.mjs +292 -0
- package/node_modules/@suigar/game-registry/package.json +31 -0
- package/node_modules/@suigar/sui-rpc-pool/dist/index.cjs +45590 -0
- package/node_modules/@suigar/sui-rpc-pool/dist/index.d.cts +465 -0
- package/node_modules/@suigar/sui-rpc-pool/dist/index.d.mts +465 -0
- package/node_modules/@suigar/sui-rpc-pool/dist/index.mjs +45570 -0
- package/node_modules/@suigar/sui-rpc-pool/package.json +31 -0
- package/package.json +62 -0
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const require_mcp_support = require("./mcp-support.cjs");
|
|
2
|
+
let _suigar_currency_registry = require("@suigar/currency-registry");
|
|
3
|
+
let _suigar_game_registry = require("@suigar/game-registry");
|
|
4
|
+
let _mysten_sui_grpc = require("@mysten/sui/grpc");
|
|
5
|
+
let _suigar_sdk = require("@suigar/sdk");
|
|
6
|
+
//#region src/config.ts
|
|
7
|
+
const EMPTY = "";
|
|
8
|
+
const DEFAULT_NETWORK = "testnet";
|
|
9
|
+
const DEFAULT_SUI_COIN_TYPE = "0x2::sui::SUI";
|
|
10
|
+
const SDK_CONFIG_NETWORKS = /* @__PURE__ */ new Set(["mainnet", "testnet"]);
|
|
11
|
+
const DEFAULT_GRAPHQL_URL = (network) => `https://graphql.${network}.sui.io/graphql`;
|
|
12
|
+
const DEFAULT_PROVIDER_URL = (network) => {
|
|
13
|
+
switch (network) {
|
|
14
|
+
case "mainnet": return "https://fullnode.mainnet.sui.io:443";
|
|
15
|
+
case "devnet": return "https://fullnode.devnet.sui.io:443";
|
|
16
|
+
case "localnet": return "http://127.0.0.1:9000";
|
|
17
|
+
default: return "https://fullnode.testnet.sui.io:443";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const parseApiLikeUrl = (value) => value?.trim().replace(/\/+$/, "") ?? EMPTY;
|
|
21
|
+
const trim = (value) => value?.trim() ?? EMPTY;
|
|
22
|
+
const pickFirst = (...values) => {
|
|
23
|
+
for (const value of values) if (typeof value === "string" && value.trim().length > 0) return value.trim();
|
|
24
|
+
return EMPTY;
|
|
25
|
+
};
|
|
26
|
+
const env = (...keys) => pickFirst(...keys.map((key) => process.env[key]));
|
|
27
|
+
const normalizeNetwork = (value) => {
|
|
28
|
+
const normalized = value?.trim().toLowerCase();
|
|
29
|
+
return normalized ? normalized : DEFAULT_NETWORK;
|
|
30
|
+
};
|
|
31
|
+
const resolveSdkConfig = (network) => {
|
|
32
|
+
if (!SDK_CONFIG_NETWORKS.has(network)) return null;
|
|
33
|
+
try {
|
|
34
|
+
return new _mysten_sui_grpc.SuiGrpcClient({
|
|
35
|
+
baseUrl: DEFAULT_PROVIDER_URL(network),
|
|
36
|
+
network
|
|
37
|
+
}).$extend((0, _suigar_sdk.suigar)()).suigar.getConfig();
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const resolveSharedPackageId = (input) => pickFirst(input.suigarPackageId, env("SUIGAR_PACKAGE_ID", "VITE_SUIGAR_PACKAGE_ID"));
|
|
43
|
+
const resolveSuigarConfig = (input = {}) => {
|
|
44
|
+
const mergedInput = {
|
|
45
|
+
...input.config ?? {},
|
|
46
|
+
...input
|
|
47
|
+
};
|
|
48
|
+
const network = normalizeNetwork(mergedInput.network ?? env("SUIGAR_NETWORK", "VITE_NETWORK", "NETWORK"));
|
|
49
|
+
const sdkConfig = resolveSdkConfig(network);
|
|
50
|
+
const explicitSharedPackageId = resolveSharedPackageId(mergedInput);
|
|
51
|
+
const sharedPackageId = pickFirst(explicitSharedPackageId, sdkConfig?.packageIds.core);
|
|
52
|
+
return {
|
|
53
|
+
network,
|
|
54
|
+
providerUrl: pickFirst(mergedInput.providerUrl, env("SUIGAR_PROVIDER_URL", "VITE_SUI_GRPC_URL")) || DEFAULT_PROVIDER_URL(network),
|
|
55
|
+
graphqlUrl: pickFirst(mergedInput.graphqlUrl, env("SUIGAR_GRAPHQL_URL", "VITE_SUI_GRAPHQL_URL")) || DEFAULT_GRAPHQL_URL(network),
|
|
56
|
+
siteUrl: pickFirst(mergedInput.siteUrl, env("SUIGAR_SITE_URL", "VITE_SITE_URL")) || "https://suigar.com",
|
|
57
|
+
suigarPackageId: sharedPackageId,
|
|
58
|
+
coinflipPackageId: pickFirst(mergedInput.coinflipPackageId, env("COINFLIP_PACKAGE_ID", "VITE_COINFLIP_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.coinflip),
|
|
59
|
+
pvpCoinflipPackageId: pickFirst(mergedInput.pvpCoinflipPackageId, env("PVP_COINFLIP_PACKAGE_ID", "VITE_PVP_COINFLIP_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.pvpCoinflip),
|
|
60
|
+
plinkoPackageId: pickFirst(mergedInput.plinkoPackageId, env("PLINKO_PACKAGE_ID", "VITE_PLINKO_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.plinko),
|
|
61
|
+
limboPackageId: pickFirst(mergedInput.limboPackageId, env("LIMBO_PACKAGE_ID", "VITE_LIMBO_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.limbo),
|
|
62
|
+
rangePackageId: pickFirst(mergedInput.rangePackageId, env("RANGE_PACKAGE_ID", "VITE_RANGE_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.range),
|
|
63
|
+
wheelPackageId: pickFirst(mergedInput.wheelPackageId, env("WHEEL_PACKAGE_ID", "VITE_WHEEL_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.wheel),
|
|
64
|
+
sweethouseId: pickFirst(mergedInput.sweethouseId, env("SWEETHOUSE_ID", "VITE_SWEETHOUSE_ID"), sdkConfig?.packageIds.sweetHouse),
|
|
65
|
+
suiCoinType: pickFirst(mergedInput.suiCoinType, env("SUI_COIN_TYPE", "VITE_SUI_COIN_TYPE"), sdkConfig?.coinTypes.sui) || DEFAULT_SUI_COIN_TYPE,
|
|
66
|
+
usdcCoinType: pickFirst(mergedInput.usdcCoinType, env("USDC_COIN_TYPE", "VITE_USDC_COIN_TYPE"), sdkConfig?.coinTypes.usdc),
|
|
67
|
+
suiPythPriceInfoObjectId: pickFirst(mergedInput.suiPythPriceInfoObjectId, env("SUI_PYTH_PRICE_INFO_OBJECT_ID", "VITE_SUI_PYTH_PRICE_INFO_OBJECT_ID"), sdkConfig?.priceInfoObjectIds.sui),
|
|
68
|
+
usdcPythPriceInfoObjectId: pickFirst(mergedInput.usdcPythPriceInfoObjectId, env("USDC_PYTH_PRICE_INFO_OBJECT_ID", "VITE_USDC_PYTH_PRICE_INFO_OBJECT_ID"), sdkConfig?.priceInfoObjectIds.usdc),
|
|
69
|
+
coinflipSettingsId: pickFirst(mergedInput.coinflipSettingsId, env("COINFLIP_SETTINGS_ID", "VITE_COINFLIP_SETTINGS_ID")),
|
|
70
|
+
pvpCoinflipSettingsId: pickFirst(mergedInput.pvpCoinflipSettingsId, env("PVP_COINFLIP_SETTINGS_ID", "VITE_PVP_COINFLIP_SETTINGS_ID")),
|
|
71
|
+
plinkoSettingsId: pickFirst(mergedInput.plinkoSettingsId, env("PLINKO_SETTINGS_ID", "VITE_PLINKO_SETTINGS_ID")),
|
|
72
|
+
limboSettingsId: pickFirst(mergedInput.limboSettingsId, env("LIMBO_SETTINGS_ID", "VITE_LIMBO_SETTINGS_ID")),
|
|
73
|
+
rangeSettingsId: pickFirst(mergedInput.rangeSettingsId, env("RANGE_SETTINGS_ID", "VITE_RANGE_SETTINGS_ID")),
|
|
74
|
+
wheelSettingsId: pickFirst(mergedInput.wheelSettingsId, env("WHEEL_SETTINGS_ID", "VITE_WHEEL_SETTINGS_ID")),
|
|
75
|
+
pvpCoinflipRegistryId: pickFirst(mergedInput.pvpCoinflipRegistryId, env("PVP_COINFLIP_REGISTRY_ID", "VITE_PVP_COINFLIP_REGISTRY_ID"), sdkConfig?.registryIds.pvpCoinflip)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const REQUIRED_CONFIG_KEYS_BY_GAME = {
|
|
79
|
+
coinflip: [
|
|
80
|
+
"coinflipPackageId",
|
|
81
|
+
"sweethouseId",
|
|
82
|
+
"suiCoinType",
|
|
83
|
+
"suiPythPriceInfoObjectId"
|
|
84
|
+
],
|
|
85
|
+
limbo: [
|
|
86
|
+
"limboPackageId",
|
|
87
|
+
"sweethouseId",
|
|
88
|
+
"suiCoinType",
|
|
89
|
+
"suiPythPriceInfoObjectId"
|
|
90
|
+
],
|
|
91
|
+
plinko: [
|
|
92
|
+
"plinkoPackageId",
|
|
93
|
+
"sweethouseId",
|
|
94
|
+
"suiCoinType",
|
|
95
|
+
"suiPythPriceInfoObjectId"
|
|
96
|
+
],
|
|
97
|
+
wheel: [
|
|
98
|
+
"wheelPackageId",
|
|
99
|
+
"sweethouseId",
|
|
100
|
+
"suiCoinType",
|
|
101
|
+
"suiPythPriceInfoObjectId"
|
|
102
|
+
],
|
|
103
|
+
range: [
|
|
104
|
+
"rangePackageId",
|
|
105
|
+
"sweethouseId",
|
|
106
|
+
"suiCoinType",
|
|
107
|
+
"suiPythPriceInfoObjectId"
|
|
108
|
+
],
|
|
109
|
+
"pvp-coinflip": [
|
|
110
|
+
"pvpCoinflipPackageId",
|
|
111
|
+
"sweethouseId",
|
|
112
|
+
"suiCoinType"
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
const getRequiredConfigKeysForGame = (game) => REQUIRED_CONFIG_KEYS_BY_GAME[game];
|
|
116
|
+
const inspectResolvedConfig = (input = {}) => {
|
|
117
|
+
const config = resolveSuigarConfig(input);
|
|
118
|
+
const configuredCurrencies = (0, _suigar_currency_registry.buildConfiguredCurrencies)({
|
|
119
|
+
suiCoinType: config.suiCoinType,
|
|
120
|
+
usdcCoinType: config.usdcCoinType
|
|
121
|
+
});
|
|
122
|
+
const missingValues = Object.entries(config).flatMap(([key, value]) => trim(value) ? [] : [key]);
|
|
123
|
+
return {
|
|
124
|
+
config,
|
|
125
|
+
configuredCurrencies,
|
|
126
|
+
availableGames: (0, _suigar_game_registry.getActiveGames)().map((game) => ({
|
|
127
|
+
...game,
|
|
128
|
+
mcpSupport: require_mcp_support.getMcpSupportForGame(game.id)
|
|
129
|
+
})),
|
|
130
|
+
missingValues,
|
|
131
|
+
mcp: require_mcp_support.buildMcpSupportCatalog()
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const resolvePythPriceInfoId = (coinType, configInput = {}) => {
|
|
135
|
+
const config = resolveSuigarConfig(configInput);
|
|
136
|
+
const normalizedCoinType = (0, _suigar_currency_registry.normalizeCoinTypeKey)(coinType);
|
|
137
|
+
if (normalizedCoinType === (0, _suigar_currency_registry.normalizeCoinTypeKey)(config.suiCoinType) && config.suiPythPriceInfoObjectId) return config.suiPythPriceInfoObjectId;
|
|
138
|
+
if ([config.usdcCoinType].filter((value) => Boolean(trim(value))).map((value) => (0, _suigar_currency_registry.normalizeCoinTypeKey)(value)).includes(normalizedCoinType) && config.usdcPythPriceInfoObjectId) return config.usdcPythPriceInfoObjectId;
|
|
139
|
+
if ((0, _suigar_currency_registry.resolveCurrencyMetadata)(coinType, inspectResolvedConfig(config).configuredCurrencies).symbol === "USDC" && config.usdcPythPriceInfoObjectId) return config.usdcPythPriceInfoObjectId;
|
|
140
|
+
throw new Error(`Missing Pyth price object configuration for coin type ${coinType}`);
|
|
141
|
+
};
|
|
142
|
+
const resolveGamePackageId = (game, configInput = {}) => {
|
|
143
|
+
const config = resolveSuigarConfig(configInput);
|
|
144
|
+
switch (game) {
|
|
145
|
+
case "coinflip": return config.coinflipPackageId;
|
|
146
|
+
case "limbo": return config.limboPackageId;
|
|
147
|
+
case "plinko": return config.plinkoPackageId;
|
|
148
|
+
case "wheel": return config.wheelPackageId;
|
|
149
|
+
case "range": return config.rangePackageId;
|
|
150
|
+
case "pvp-coinflip": return config.pvpCoinflipPackageId;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const resolveGameSettingsId = (game, configInput = {}) => {
|
|
154
|
+
const config = resolveSuigarConfig(configInput);
|
|
155
|
+
switch (game) {
|
|
156
|
+
case "coinflip": return config.coinflipSettingsId;
|
|
157
|
+
case "limbo": return config.limboSettingsId;
|
|
158
|
+
case "plinko": return config.plinkoSettingsId;
|
|
159
|
+
case "wheel": return config.wheelSettingsId;
|
|
160
|
+
case "range": return config.rangeSettingsId;
|
|
161
|
+
case "pvp-coinflip": return config.pvpCoinflipSettingsId;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const assertRequiredConfig = (game, configInput = {}) => {
|
|
165
|
+
const inspection = inspectResolvedConfig(configInput);
|
|
166
|
+
const missing = getRequiredConfigKeysForGame(game).filter((key) => !trim(inspection.config[key]));
|
|
167
|
+
if (missing.length > 0) throw new Error(`Missing required config for ${game}: ${missing.join(", ")}`);
|
|
168
|
+
return inspection.config;
|
|
169
|
+
};
|
|
170
|
+
const buildProviderUrl = (network) => DEFAULT_PROVIDER_URL(network);
|
|
171
|
+
const buildGraphqlUrl = (network) => DEFAULT_GRAPHQL_URL(network);
|
|
172
|
+
const parseApiUrl = parseApiLikeUrl;
|
|
173
|
+
//#endregion
|
|
174
|
+
exports.assertRequiredConfig = assertRequiredConfig;
|
|
175
|
+
exports.buildGraphqlUrl = buildGraphqlUrl;
|
|
176
|
+
exports.buildProviderUrl = buildProviderUrl;
|
|
177
|
+
exports.getRequiredConfigKeysForGame = getRequiredConfigKeysForGame;
|
|
178
|
+
exports.inspectResolvedConfig = inspectResolvedConfig;
|
|
179
|
+
exports.parseApiUrl = parseApiUrl;
|
|
180
|
+
exports.resolveGamePackageId = resolveGamePackageId;
|
|
181
|
+
exports.resolveGameSettingsId = resolveGameSettingsId;
|
|
182
|
+
exports.resolvePythPriceInfoId = resolvePythPriceInfoId;
|
|
183
|
+
exports.resolveSuigarConfig = resolveSuigarConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CasinoBetGameId, ConfigInspection, SuigarConfig, SuigarConfigInput, SupportedGameId } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
declare const resolveSuigarConfig: (input?: SuigarConfigInput) => SuigarConfig;
|
|
5
|
+
declare const getRequiredConfigKeysForGame: (game: SupportedGameId) => Array<keyof SuigarConfig>;
|
|
6
|
+
declare const inspectResolvedConfig: (input?: SuigarConfigInput) => ConfigInspection;
|
|
7
|
+
declare const resolvePythPriceInfoId: (coinType: string, configInput?: SuigarConfigInput) => string;
|
|
8
|
+
declare const resolveGamePackageId: (game: SupportedGameId, configInput?: SuigarConfigInput) => string | null;
|
|
9
|
+
declare const resolveGameSettingsId: (game: CasinoBetGameId | "pvp-coinflip", configInput?: SuigarConfigInput) => string | null;
|
|
10
|
+
declare const assertRequiredConfig: (game: SupportedGameId, configInput?: SuigarConfigInput) => SuigarConfig;
|
|
11
|
+
declare const buildProviderUrl: (network: string) => "https://fullnode.mainnet.sui.io:443" | "https://fullnode.devnet.sui.io:443" | "http://127.0.0.1:9000" | "https://fullnode.testnet.sui.io:443";
|
|
12
|
+
declare const buildGraphqlUrl: (network: string) => string;
|
|
13
|
+
declare const parseApiUrl: (value: string | undefined) => string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CasinoBetGameId, ConfigInspection, SuigarConfig, SuigarConfigInput, SupportedGameId } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
declare const resolveSuigarConfig: (input?: SuigarConfigInput) => SuigarConfig;
|
|
5
|
+
declare const getRequiredConfigKeysForGame: (game: SupportedGameId) => Array<keyof SuigarConfig>;
|
|
6
|
+
declare const inspectResolvedConfig: (input?: SuigarConfigInput) => ConfigInspection;
|
|
7
|
+
declare const resolvePythPriceInfoId: (coinType: string, configInput?: SuigarConfigInput) => string;
|
|
8
|
+
declare const resolveGamePackageId: (game: SupportedGameId, configInput?: SuigarConfigInput) => string | null;
|
|
9
|
+
declare const resolveGameSettingsId: (game: CasinoBetGameId | "pvp-coinflip", configInput?: SuigarConfigInput) => string | null;
|
|
10
|
+
declare const assertRequiredConfig: (game: SupportedGameId, configInput?: SuigarConfigInput) => SuigarConfig;
|
|
11
|
+
declare const buildProviderUrl: (network: string) => "https://fullnode.mainnet.sui.io:443" | "https://fullnode.devnet.sui.io:443" | "http://127.0.0.1:9000" | "https://fullnode.testnet.sui.io:443";
|
|
12
|
+
declare const buildGraphqlUrl: (network: string) => string;
|
|
13
|
+
declare const parseApiUrl: (value: string | undefined) => string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig };
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { buildMcpSupportCatalog, getMcpSupportForGame } from "./mcp-support.mjs";
|
|
2
|
+
import { buildConfiguredCurrencies, normalizeCoinTypeKey, resolveCurrencyMetadata } from "@suigar/currency-registry";
|
|
3
|
+
import { getActiveGames } from "@suigar/game-registry";
|
|
4
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
5
|
+
import { suigar } from "@suigar/sdk";
|
|
6
|
+
//#region src/config.ts
|
|
7
|
+
const EMPTY = "";
|
|
8
|
+
const DEFAULT_NETWORK = "testnet";
|
|
9
|
+
const DEFAULT_SUI_COIN_TYPE = "0x2::sui::SUI";
|
|
10
|
+
const SDK_CONFIG_NETWORKS = /* @__PURE__ */ new Set(["mainnet", "testnet"]);
|
|
11
|
+
const DEFAULT_GRAPHQL_URL = (network) => `https://graphql.${network}.sui.io/graphql`;
|
|
12
|
+
const DEFAULT_PROVIDER_URL = (network) => {
|
|
13
|
+
switch (network) {
|
|
14
|
+
case "mainnet": return "https://fullnode.mainnet.sui.io:443";
|
|
15
|
+
case "devnet": return "https://fullnode.devnet.sui.io:443";
|
|
16
|
+
case "localnet": return "http://127.0.0.1:9000";
|
|
17
|
+
default: return "https://fullnode.testnet.sui.io:443";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const parseApiLikeUrl = (value) => value?.trim().replace(/\/+$/, "") ?? EMPTY;
|
|
21
|
+
const trim = (value) => value?.trim() ?? EMPTY;
|
|
22
|
+
const pickFirst = (...values) => {
|
|
23
|
+
for (const value of values) if (typeof value === "string" && value.trim().length > 0) return value.trim();
|
|
24
|
+
return EMPTY;
|
|
25
|
+
};
|
|
26
|
+
const env = (...keys) => pickFirst(...keys.map((key) => process.env[key]));
|
|
27
|
+
const normalizeNetwork = (value) => {
|
|
28
|
+
const normalized = value?.trim().toLowerCase();
|
|
29
|
+
return normalized ? normalized : DEFAULT_NETWORK;
|
|
30
|
+
};
|
|
31
|
+
const resolveSdkConfig = (network) => {
|
|
32
|
+
if (!SDK_CONFIG_NETWORKS.has(network)) return null;
|
|
33
|
+
try {
|
|
34
|
+
return new SuiGrpcClient({
|
|
35
|
+
baseUrl: DEFAULT_PROVIDER_URL(network),
|
|
36
|
+
network
|
|
37
|
+
}).$extend(suigar()).suigar.getConfig();
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const resolveSharedPackageId = (input) => pickFirst(input.suigarPackageId, env("SUIGAR_PACKAGE_ID", "VITE_SUIGAR_PACKAGE_ID"));
|
|
43
|
+
const resolveSuigarConfig = (input = {}) => {
|
|
44
|
+
const mergedInput = {
|
|
45
|
+
...input.config ?? {},
|
|
46
|
+
...input
|
|
47
|
+
};
|
|
48
|
+
const network = normalizeNetwork(mergedInput.network ?? env("SUIGAR_NETWORK", "VITE_NETWORK", "NETWORK"));
|
|
49
|
+
const sdkConfig = resolveSdkConfig(network);
|
|
50
|
+
const explicitSharedPackageId = resolveSharedPackageId(mergedInput);
|
|
51
|
+
const sharedPackageId = pickFirst(explicitSharedPackageId, sdkConfig?.packageIds.core);
|
|
52
|
+
return {
|
|
53
|
+
network,
|
|
54
|
+
providerUrl: pickFirst(mergedInput.providerUrl, env("SUIGAR_PROVIDER_URL", "VITE_SUI_GRPC_URL")) || DEFAULT_PROVIDER_URL(network),
|
|
55
|
+
graphqlUrl: pickFirst(mergedInput.graphqlUrl, env("SUIGAR_GRAPHQL_URL", "VITE_SUI_GRAPHQL_URL")) || DEFAULT_GRAPHQL_URL(network),
|
|
56
|
+
siteUrl: pickFirst(mergedInput.siteUrl, env("SUIGAR_SITE_URL", "VITE_SITE_URL")) || "https://suigar.com",
|
|
57
|
+
suigarPackageId: sharedPackageId,
|
|
58
|
+
coinflipPackageId: pickFirst(mergedInput.coinflipPackageId, env("COINFLIP_PACKAGE_ID", "VITE_COINFLIP_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.coinflip),
|
|
59
|
+
pvpCoinflipPackageId: pickFirst(mergedInput.pvpCoinflipPackageId, env("PVP_COINFLIP_PACKAGE_ID", "VITE_PVP_COINFLIP_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.pvpCoinflip),
|
|
60
|
+
plinkoPackageId: pickFirst(mergedInput.plinkoPackageId, env("PLINKO_PACKAGE_ID", "VITE_PLINKO_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.plinko),
|
|
61
|
+
limboPackageId: pickFirst(mergedInput.limboPackageId, env("LIMBO_PACKAGE_ID", "VITE_LIMBO_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.limbo),
|
|
62
|
+
rangePackageId: pickFirst(mergedInput.rangePackageId, env("RANGE_PACKAGE_ID", "VITE_RANGE_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.range),
|
|
63
|
+
wheelPackageId: pickFirst(mergedInput.wheelPackageId, env("WHEEL_PACKAGE_ID", "VITE_WHEEL_PACKAGE_ID"), explicitSharedPackageId, sdkConfig?.packageIds.wheel),
|
|
64
|
+
sweethouseId: pickFirst(mergedInput.sweethouseId, env("SWEETHOUSE_ID", "VITE_SWEETHOUSE_ID"), sdkConfig?.packageIds.sweetHouse),
|
|
65
|
+
suiCoinType: pickFirst(mergedInput.suiCoinType, env("SUI_COIN_TYPE", "VITE_SUI_COIN_TYPE"), sdkConfig?.coinTypes.sui) || DEFAULT_SUI_COIN_TYPE,
|
|
66
|
+
usdcCoinType: pickFirst(mergedInput.usdcCoinType, env("USDC_COIN_TYPE", "VITE_USDC_COIN_TYPE"), sdkConfig?.coinTypes.usdc),
|
|
67
|
+
suiPythPriceInfoObjectId: pickFirst(mergedInput.suiPythPriceInfoObjectId, env("SUI_PYTH_PRICE_INFO_OBJECT_ID", "VITE_SUI_PYTH_PRICE_INFO_OBJECT_ID"), sdkConfig?.priceInfoObjectIds.sui),
|
|
68
|
+
usdcPythPriceInfoObjectId: pickFirst(mergedInput.usdcPythPriceInfoObjectId, env("USDC_PYTH_PRICE_INFO_OBJECT_ID", "VITE_USDC_PYTH_PRICE_INFO_OBJECT_ID"), sdkConfig?.priceInfoObjectIds.usdc),
|
|
69
|
+
coinflipSettingsId: pickFirst(mergedInput.coinflipSettingsId, env("COINFLIP_SETTINGS_ID", "VITE_COINFLIP_SETTINGS_ID")),
|
|
70
|
+
pvpCoinflipSettingsId: pickFirst(mergedInput.pvpCoinflipSettingsId, env("PVP_COINFLIP_SETTINGS_ID", "VITE_PVP_COINFLIP_SETTINGS_ID")),
|
|
71
|
+
plinkoSettingsId: pickFirst(mergedInput.plinkoSettingsId, env("PLINKO_SETTINGS_ID", "VITE_PLINKO_SETTINGS_ID")),
|
|
72
|
+
limboSettingsId: pickFirst(mergedInput.limboSettingsId, env("LIMBO_SETTINGS_ID", "VITE_LIMBO_SETTINGS_ID")),
|
|
73
|
+
rangeSettingsId: pickFirst(mergedInput.rangeSettingsId, env("RANGE_SETTINGS_ID", "VITE_RANGE_SETTINGS_ID")),
|
|
74
|
+
wheelSettingsId: pickFirst(mergedInput.wheelSettingsId, env("WHEEL_SETTINGS_ID", "VITE_WHEEL_SETTINGS_ID")),
|
|
75
|
+
pvpCoinflipRegistryId: pickFirst(mergedInput.pvpCoinflipRegistryId, env("PVP_COINFLIP_REGISTRY_ID", "VITE_PVP_COINFLIP_REGISTRY_ID"), sdkConfig?.registryIds.pvpCoinflip)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const REQUIRED_CONFIG_KEYS_BY_GAME = {
|
|
79
|
+
coinflip: [
|
|
80
|
+
"coinflipPackageId",
|
|
81
|
+
"sweethouseId",
|
|
82
|
+
"suiCoinType",
|
|
83
|
+
"suiPythPriceInfoObjectId"
|
|
84
|
+
],
|
|
85
|
+
limbo: [
|
|
86
|
+
"limboPackageId",
|
|
87
|
+
"sweethouseId",
|
|
88
|
+
"suiCoinType",
|
|
89
|
+
"suiPythPriceInfoObjectId"
|
|
90
|
+
],
|
|
91
|
+
plinko: [
|
|
92
|
+
"plinkoPackageId",
|
|
93
|
+
"sweethouseId",
|
|
94
|
+
"suiCoinType",
|
|
95
|
+
"suiPythPriceInfoObjectId"
|
|
96
|
+
],
|
|
97
|
+
wheel: [
|
|
98
|
+
"wheelPackageId",
|
|
99
|
+
"sweethouseId",
|
|
100
|
+
"suiCoinType",
|
|
101
|
+
"suiPythPriceInfoObjectId"
|
|
102
|
+
],
|
|
103
|
+
range: [
|
|
104
|
+
"rangePackageId",
|
|
105
|
+
"sweethouseId",
|
|
106
|
+
"suiCoinType",
|
|
107
|
+
"suiPythPriceInfoObjectId"
|
|
108
|
+
],
|
|
109
|
+
"pvp-coinflip": [
|
|
110
|
+
"pvpCoinflipPackageId",
|
|
111
|
+
"sweethouseId",
|
|
112
|
+
"suiCoinType"
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
const getRequiredConfigKeysForGame = (game) => REQUIRED_CONFIG_KEYS_BY_GAME[game];
|
|
116
|
+
const inspectResolvedConfig = (input = {}) => {
|
|
117
|
+
const config = resolveSuigarConfig(input);
|
|
118
|
+
const configuredCurrencies = buildConfiguredCurrencies({
|
|
119
|
+
suiCoinType: config.suiCoinType,
|
|
120
|
+
usdcCoinType: config.usdcCoinType
|
|
121
|
+
});
|
|
122
|
+
const missingValues = Object.entries(config).flatMap(([key, value]) => trim(value) ? [] : [key]);
|
|
123
|
+
return {
|
|
124
|
+
config,
|
|
125
|
+
configuredCurrencies,
|
|
126
|
+
availableGames: getActiveGames().map((game) => ({
|
|
127
|
+
...game,
|
|
128
|
+
mcpSupport: getMcpSupportForGame(game.id)
|
|
129
|
+
})),
|
|
130
|
+
missingValues,
|
|
131
|
+
mcp: buildMcpSupportCatalog()
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const resolvePythPriceInfoId = (coinType, configInput = {}) => {
|
|
135
|
+
const config = resolveSuigarConfig(configInput);
|
|
136
|
+
const normalizedCoinType = normalizeCoinTypeKey(coinType);
|
|
137
|
+
if (normalizedCoinType === normalizeCoinTypeKey(config.suiCoinType) && config.suiPythPriceInfoObjectId) return config.suiPythPriceInfoObjectId;
|
|
138
|
+
if ([config.usdcCoinType].filter((value) => Boolean(trim(value))).map((value) => normalizeCoinTypeKey(value)).includes(normalizedCoinType) && config.usdcPythPriceInfoObjectId) return config.usdcPythPriceInfoObjectId;
|
|
139
|
+
if (resolveCurrencyMetadata(coinType, inspectResolvedConfig(config).configuredCurrencies).symbol === "USDC" && config.usdcPythPriceInfoObjectId) return config.usdcPythPriceInfoObjectId;
|
|
140
|
+
throw new Error(`Missing Pyth price object configuration for coin type ${coinType}`);
|
|
141
|
+
};
|
|
142
|
+
const resolveGamePackageId = (game, configInput = {}) => {
|
|
143
|
+
const config = resolveSuigarConfig(configInput);
|
|
144
|
+
switch (game) {
|
|
145
|
+
case "coinflip": return config.coinflipPackageId;
|
|
146
|
+
case "limbo": return config.limboPackageId;
|
|
147
|
+
case "plinko": return config.plinkoPackageId;
|
|
148
|
+
case "wheel": return config.wheelPackageId;
|
|
149
|
+
case "range": return config.rangePackageId;
|
|
150
|
+
case "pvp-coinflip": return config.pvpCoinflipPackageId;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const resolveGameSettingsId = (game, configInput = {}) => {
|
|
154
|
+
const config = resolveSuigarConfig(configInput);
|
|
155
|
+
switch (game) {
|
|
156
|
+
case "coinflip": return config.coinflipSettingsId;
|
|
157
|
+
case "limbo": return config.limboSettingsId;
|
|
158
|
+
case "plinko": return config.plinkoSettingsId;
|
|
159
|
+
case "wheel": return config.wheelSettingsId;
|
|
160
|
+
case "range": return config.rangeSettingsId;
|
|
161
|
+
case "pvp-coinflip": return config.pvpCoinflipSettingsId;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const assertRequiredConfig = (game, configInput = {}) => {
|
|
165
|
+
const inspection = inspectResolvedConfig(configInput);
|
|
166
|
+
const missing = getRequiredConfigKeysForGame(game).filter((key) => !trim(inspection.config[key]));
|
|
167
|
+
if (missing.length > 0) throw new Error(`Missing required config for ${game}: ${missing.join(", ")}`);
|
|
168
|
+
return inspection.config;
|
|
169
|
+
};
|
|
170
|
+
const buildProviderUrl = (network) => DEFAULT_PROVIDER_URL(network);
|
|
171
|
+
const buildGraphqlUrl = (network) => DEFAULT_GRAPHQL_URL(network);
|
|
172
|
+
const parseApiUrl = parseApiLikeUrl;
|
|
173
|
+
//#endregion
|
|
174
|
+
export { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_mcp_support = require("./mcp-support.cjs");
|
|
3
|
+
const require_config = require("./config.cjs");
|
|
4
|
+
const require_metadata = require("./metadata.cjs");
|
|
5
|
+
const require_coin = require("./coin.cjs");
|
|
6
|
+
const require_client = require("./client.cjs");
|
|
7
|
+
const require_transactions = require("./transactions.cjs");
|
|
8
|
+
const require_tools = require("./tools.cjs");
|
|
9
|
+
const require_server = require("./server.cjs");
|
|
10
|
+
exports.SUPPORTED_MCP_TOOL_NAMES = require_mcp_support.SUPPORTED_MCP_TOOL_NAMES;
|
|
11
|
+
exports.assertRequiredConfig = require_config.assertRequiredConfig;
|
|
12
|
+
exports.buildCoinflipTransaction = require_transactions.buildCoinflipTransaction;
|
|
13
|
+
exports.buildCoinflipTransactionTool = require_tools.buildCoinflipTransactionTool;
|
|
14
|
+
exports.buildGraphqlUrl = require_config.buildGraphqlUrl;
|
|
15
|
+
exports.buildLimboTransaction = require_transactions.buildLimboTransaction;
|
|
16
|
+
exports.buildLimboTransactionTool = require_tools.buildLimboTransactionTool;
|
|
17
|
+
exports.buildMcpSupportCatalog = require_mcp_support.buildMcpSupportCatalog;
|
|
18
|
+
exports.buildPlinkoTransaction = require_transactions.buildPlinkoTransaction;
|
|
19
|
+
exports.buildPlinkoTransactionTool = require_tools.buildPlinkoTransactionTool;
|
|
20
|
+
exports.buildProviderUrl = require_config.buildProviderUrl;
|
|
21
|
+
exports.buildPvpCoinflipCancelTransaction = require_transactions.buildPvpCoinflipCancelTransaction;
|
|
22
|
+
exports.buildPvpCoinflipCancelTransactionTool = require_tools.buildPvpCoinflipCancelTransactionTool;
|
|
23
|
+
exports.buildPvpCoinflipCreateTransaction = require_transactions.buildPvpCoinflipCreateTransaction;
|
|
24
|
+
exports.buildPvpCoinflipCreateTransactionTool = require_tools.buildPvpCoinflipCreateTransactionTool;
|
|
25
|
+
exports.buildPvpCoinflipJoinTransaction = require_transactions.buildPvpCoinflipJoinTransaction;
|
|
26
|
+
exports.buildPvpCoinflipJoinTransactionTool = require_tools.buildPvpCoinflipJoinTransactionTool;
|
|
27
|
+
exports.buildRangeTransaction = require_transactions.buildRangeTransaction;
|
|
28
|
+
exports.buildRangeTransactionTool = require_tools.buildRangeTransactionTool;
|
|
29
|
+
exports.buildWheelTransaction = require_transactions.buildWheelTransaction;
|
|
30
|
+
exports.buildWheelTransactionTool = require_tools.buildWheelTransactionTool;
|
|
31
|
+
exports.createReadOnlyClientBundle = require_client.createReadOnlyClientBundle;
|
|
32
|
+
exports.createSuigarMcpServer = require_server.createSuigarMcpServer;
|
|
33
|
+
exports.dryRunTransaction = require_client.dryRunTransaction;
|
|
34
|
+
exports.getCurrencyInfo = require_metadata.getCurrencyInfo;
|
|
35
|
+
exports.getGameMetadata = require_metadata.getGameMetadata;
|
|
36
|
+
exports.getMcpSupportForGame = require_mcp_support.getMcpSupportForGame;
|
|
37
|
+
exports.getRequiredConfigKeysForGame = require_config.getRequiredConfigKeysForGame;
|
|
38
|
+
exports.inspectResolvedConfig = require_config.inspectResolvedConfig;
|
|
39
|
+
exports.listConfiguredCurrencies = require_metadata.listConfiguredCurrencies;
|
|
40
|
+
exports.listSupportedGames = require_metadata.listSupportedGames;
|
|
41
|
+
exports.parseApiUrl = require_config.parseApiUrl;
|
|
42
|
+
exports.readConfigMetadata = require_metadata.readConfigMetadata;
|
|
43
|
+
exports.readConfigTool = require_tools.readConfigTool;
|
|
44
|
+
exports.readGameMetadataTool = require_tools.readGameMetadataTool;
|
|
45
|
+
exports.resolveBetCoin = require_coin.resolveBetCoin;
|
|
46
|
+
exports.resolveGamePackageId = require_config.resolveGamePackageId;
|
|
47
|
+
exports.resolveGameSettingsId = require_config.resolveGameSettingsId;
|
|
48
|
+
exports.resolvePythPriceInfoId = require_config.resolvePythPriceInfoId;
|
|
49
|
+
exports.resolveSuigarConfig = require_config.resolveSuigarConfig;
|
|
50
|
+
exports.sanitizeForJson = require_client.sanitizeForJson;
|
|
51
|
+
exports.serializeTransactionToBase64 = require_client.serializeTransactionToBase64;
|
|
52
|
+
exports.startSuigarMcpServer = require_server.startSuigarMcpServer;
|
|
53
|
+
exports.summarizeTransaction = require_transactions.summarizeTransaction;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GameMcpSupport, McpExecutionSurface, SUPPORTED_MCP_TOOL_NAMES, SuigarMcpToolName, buildMcpSupportCatalog, getMcpSupportForGame } from "./mcp-support.cjs";
|
|
2
|
+
import { BetCoinSource, BetMetadataInput, BetMetadataInputValue, BetMetadataPrimitive, BuilderMode, CasinoBetGameId, CoinReadClient, CoinSide, ConfigInspection, ReadOnlyPlan, SharedBuildOptions, SuigarConfig, SuigarConfigInput, SuigarNetwork, SupportedGameId, TransactionSummary } from "./types.cjs";
|
|
3
|
+
import { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig } from "./config.cjs";
|
|
4
|
+
import { getCurrencyInfo, getGameMetadata, listConfiguredCurrencies, listSupportedGames, readConfigMetadata } from "./metadata.cjs";
|
|
5
|
+
import { resolveBetCoin } from "./coin.cjs";
|
|
6
|
+
import { createReadOnlyClientBundle, dryRunTransaction, sanitizeForJson, serializeTransactionToBase64 } from "./client.cjs";
|
|
7
|
+
import { buildCoinflipTransaction, buildLimboTransaction, buildPlinkoTransaction, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCreateTransaction, buildPvpCoinflipJoinTransaction, buildRangeTransaction, buildWheelTransaction, summarizeTransaction } from "./transactions.cjs";
|
|
8
|
+
import { buildCoinflipTransactionTool, buildLimboTransactionTool, buildPlinkoTransactionTool, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransactionTool, buildRangeTransactionTool, buildWheelTransactionTool, readConfigTool, readGameMetadataTool } from "./tools.cjs";
|
|
9
|
+
import { createSuigarMcpServer, startSuigarMcpServer } from "./server.cjs";
|
|
10
|
+
export { BetCoinSource, BetMetadataInput, BetMetadataInputValue, BetMetadataPrimitive, BuilderMode, CasinoBetGameId, CoinReadClient, CoinSide, ConfigInspection, GameMcpSupport, McpExecutionSurface, ReadOnlyPlan, SUPPORTED_MCP_TOOL_NAMES, SharedBuildOptions, SuigarConfig, SuigarConfigInput, SuigarMcpToolName, SuigarNetwork, SupportedGameId, TransactionSummary, assertRequiredConfig, buildCoinflipTransaction, buildCoinflipTransactionTool, buildGraphqlUrl, buildLimboTransaction, buildLimboTransactionTool, buildMcpSupportCatalog, buildPlinkoTransaction, buildPlinkoTransactionTool, buildProviderUrl, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransaction, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransaction, buildPvpCoinflipJoinTransactionTool, buildRangeTransaction, buildRangeTransactionTool, buildWheelTransaction, buildWheelTransactionTool, createReadOnlyClientBundle, createSuigarMcpServer, dryRunTransaction, getCurrencyInfo, getGameMetadata, getMcpSupportForGame, getRequiredConfigKeysForGame, inspectResolvedConfig, listConfiguredCurrencies, listSupportedGames, parseApiUrl, readConfigMetadata, readConfigTool, readGameMetadataTool, resolveBetCoin, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig, sanitizeForJson, serializeTransactionToBase64, startSuigarMcpServer, summarizeTransaction };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GameMcpSupport, McpExecutionSurface, SUPPORTED_MCP_TOOL_NAMES, SuigarMcpToolName, buildMcpSupportCatalog, getMcpSupportForGame } from "./mcp-support.mjs";
|
|
2
|
+
import { BetCoinSource, BetMetadataInput, BetMetadataInputValue, BetMetadataPrimitive, BuilderMode, CasinoBetGameId, CoinReadClient, CoinSide, ConfigInspection, ReadOnlyPlan, SharedBuildOptions, SuigarConfig, SuigarConfigInput, SuigarNetwork, SupportedGameId, TransactionSummary } from "./types.mjs";
|
|
3
|
+
import { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig } from "./config.mjs";
|
|
4
|
+
import { getCurrencyInfo, getGameMetadata, listConfiguredCurrencies, listSupportedGames, readConfigMetadata } from "./metadata.mjs";
|
|
5
|
+
import { resolveBetCoin } from "./coin.mjs";
|
|
6
|
+
import { createReadOnlyClientBundle, dryRunTransaction, sanitizeForJson, serializeTransactionToBase64 } from "./client.mjs";
|
|
7
|
+
import { buildCoinflipTransaction, buildLimboTransaction, buildPlinkoTransaction, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCreateTransaction, buildPvpCoinflipJoinTransaction, buildRangeTransaction, buildWheelTransaction, summarizeTransaction } from "./transactions.mjs";
|
|
8
|
+
import { buildCoinflipTransactionTool, buildLimboTransactionTool, buildPlinkoTransactionTool, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransactionTool, buildRangeTransactionTool, buildWheelTransactionTool, readConfigTool, readGameMetadataTool } from "./tools.mjs";
|
|
9
|
+
import { createSuigarMcpServer, startSuigarMcpServer } from "./server.mjs";
|
|
10
|
+
export { BetCoinSource, BetMetadataInput, BetMetadataInputValue, BetMetadataPrimitive, BuilderMode, CasinoBetGameId, CoinReadClient, CoinSide, ConfigInspection, GameMcpSupport, McpExecutionSurface, ReadOnlyPlan, SUPPORTED_MCP_TOOL_NAMES, SharedBuildOptions, SuigarConfig, SuigarConfigInput, SuigarMcpToolName, SuigarNetwork, SupportedGameId, TransactionSummary, assertRequiredConfig, buildCoinflipTransaction, buildCoinflipTransactionTool, buildGraphqlUrl, buildLimboTransaction, buildLimboTransactionTool, buildMcpSupportCatalog, buildPlinkoTransaction, buildPlinkoTransactionTool, buildProviderUrl, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransaction, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransaction, buildPvpCoinflipJoinTransactionTool, buildRangeTransaction, buildRangeTransactionTool, buildWheelTransaction, buildWheelTransactionTool, createReadOnlyClientBundle, createSuigarMcpServer, dryRunTransaction, getCurrencyInfo, getGameMetadata, getMcpSupportForGame, getRequiredConfigKeysForGame, inspectResolvedConfig, listConfiguredCurrencies, listSupportedGames, parseApiUrl, readConfigMetadata, readConfigTool, readGameMetadataTool, resolveBetCoin, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig, sanitizeForJson, serializeTransactionToBase64, startSuigarMcpServer, summarizeTransaction };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SUPPORTED_MCP_TOOL_NAMES, buildMcpSupportCatalog, getMcpSupportForGame } from "./mcp-support.mjs";
|
|
2
|
+
import { assertRequiredConfig, buildGraphqlUrl, buildProviderUrl, getRequiredConfigKeysForGame, inspectResolvedConfig, parseApiUrl, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig } from "./config.mjs";
|
|
3
|
+
import { getCurrencyInfo, getGameMetadata, listConfiguredCurrencies, listSupportedGames, readConfigMetadata } from "./metadata.mjs";
|
|
4
|
+
import { resolveBetCoin } from "./coin.mjs";
|
|
5
|
+
import { createReadOnlyClientBundle, dryRunTransaction, sanitizeForJson, serializeTransactionToBase64 } from "./client.mjs";
|
|
6
|
+
import { buildCoinflipTransaction, buildLimboTransaction, buildPlinkoTransaction, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCreateTransaction, buildPvpCoinflipJoinTransaction, buildRangeTransaction, buildWheelTransaction, summarizeTransaction } from "./transactions.mjs";
|
|
7
|
+
import { buildCoinflipTransactionTool, buildLimboTransactionTool, buildPlinkoTransactionTool, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransactionTool, buildRangeTransactionTool, buildWheelTransactionTool, readConfigTool, readGameMetadataTool } from "./tools.mjs";
|
|
8
|
+
import { createSuigarMcpServer, startSuigarMcpServer } from "./server.mjs";
|
|
9
|
+
export { SUPPORTED_MCP_TOOL_NAMES, assertRequiredConfig, buildCoinflipTransaction, buildCoinflipTransactionTool, buildGraphqlUrl, buildLimboTransaction, buildLimboTransactionTool, buildMcpSupportCatalog, buildPlinkoTransaction, buildPlinkoTransactionTool, buildProviderUrl, buildPvpCoinflipCancelTransaction, buildPvpCoinflipCancelTransactionTool, buildPvpCoinflipCreateTransaction, buildPvpCoinflipCreateTransactionTool, buildPvpCoinflipJoinTransaction, buildPvpCoinflipJoinTransactionTool, buildRangeTransaction, buildRangeTransactionTool, buildWheelTransaction, buildWheelTransactionTool, createReadOnlyClientBundle, createSuigarMcpServer, dryRunTransaction, getCurrencyInfo, getGameMetadata, getMcpSupportForGame, getRequiredConfigKeysForGame, inspectResolvedConfig, listConfiguredCurrencies, listSupportedGames, parseApiUrl, readConfigMetadata, readConfigTool, readGameMetadataTool, resolveBetCoin, resolveGamePackageId, resolveGameSettingsId, resolvePythPriceInfoId, resolveSuigarConfig, sanitizeForJson, serializeTransactionToBase64, startSuigarMcpServer, summarizeTransaction };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/mcp-support.ts
|
|
2
|
+
const SUPPORTED_MCP_TOOL_NAMES = [
|
|
3
|
+
"read_config",
|
|
4
|
+
"read_game_metadata",
|
|
5
|
+
"build_coinflip_transaction",
|
|
6
|
+
"build_limbo_transaction",
|
|
7
|
+
"build_plinko_transaction",
|
|
8
|
+
"build_wheel_transaction",
|
|
9
|
+
"build_range_transaction",
|
|
10
|
+
"build_pvp_coinflip_create_transaction",
|
|
11
|
+
"build_pvp_coinflip_join_transaction",
|
|
12
|
+
"build_pvp_coinflip_cancel_transaction"
|
|
13
|
+
];
|
|
14
|
+
const GAME_MCP_SUPPORT_BY_ID = {
|
|
15
|
+
coinflip: {
|
|
16
|
+
executionSurface: "onchain",
|
|
17
|
+
toolSupported: true,
|
|
18
|
+
primaryToolName: "build_coinflip_transaction"
|
|
19
|
+
},
|
|
20
|
+
limbo: {
|
|
21
|
+
executionSurface: "onchain",
|
|
22
|
+
toolSupported: true,
|
|
23
|
+
primaryToolName: "build_limbo_transaction"
|
|
24
|
+
},
|
|
25
|
+
plinko: {
|
|
26
|
+
executionSurface: "onchain",
|
|
27
|
+
toolSupported: true,
|
|
28
|
+
primaryToolName: "build_plinko_transaction"
|
|
29
|
+
},
|
|
30
|
+
wheel: {
|
|
31
|
+
executionSurface: "onchain",
|
|
32
|
+
toolSupported: true,
|
|
33
|
+
primaryToolName: "build_wheel_transaction"
|
|
34
|
+
},
|
|
35
|
+
range: {
|
|
36
|
+
executionSurface: "onchain",
|
|
37
|
+
toolSupported: true,
|
|
38
|
+
primaryToolName: "build_range_transaction"
|
|
39
|
+
},
|
|
40
|
+
"pvp-coinflip": {
|
|
41
|
+
executionSurface: "onchain",
|
|
42
|
+
toolSupported: true,
|
|
43
|
+
primaryToolName: "build_pvp_coinflip_create_transaction"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const getMcpSupportForGame = (gameId) => {
|
|
47
|
+
const support = GAME_MCP_SUPPORT_BY_ID[gameId];
|
|
48
|
+
if (support) return support;
|
|
49
|
+
return {
|
|
50
|
+
executionSurface: gameId === "slots" ? "backend" : "onchain",
|
|
51
|
+
toolSupported: false,
|
|
52
|
+
primaryToolName: null
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const buildMcpSupportCatalog = () => Object.freeze({
|
|
56
|
+
serverName: "suigar",
|
|
57
|
+
supportedToolNames: [...SUPPORTED_MCP_TOOL_NAMES]
|
|
58
|
+
});
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.SUPPORTED_MCP_TOOL_NAMES = SUPPORTED_MCP_TOOL_NAMES;
|
|
61
|
+
exports.buildMcpSupportCatalog = buildMcpSupportCatalog;
|
|
62
|
+
exports.getMcpSupportForGame = getMcpSupportForGame;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/mcp-support.d.ts
|
|
2
|
+
type SuigarMcpToolName = 'read_config' | 'read_game_metadata' | 'build_coinflip_transaction' | 'build_limbo_transaction' | 'build_plinko_transaction' | 'build_wheel_transaction' | 'build_range_transaction' | 'build_pvp_coinflip_create_transaction' | 'build_pvp_coinflip_join_transaction' | 'build_pvp_coinflip_cancel_transaction';
|
|
3
|
+
type McpExecutionSurface = 'onchain' | 'backend';
|
|
4
|
+
type GameMcpSupport = {
|
|
5
|
+
executionSurface: McpExecutionSurface;
|
|
6
|
+
toolSupported: boolean;
|
|
7
|
+
primaryToolName: SuigarMcpToolName | null;
|
|
8
|
+
};
|
|
9
|
+
declare const SUPPORTED_MCP_TOOL_NAMES: SuigarMcpToolName[];
|
|
10
|
+
declare const getMcpSupportForGame: (gameId: string) => GameMcpSupport;
|
|
11
|
+
declare const buildMcpSupportCatalog: () => Readonly<{
|
|
12
|
+
serverName: "suigar";
|
|
13
|
+
supportedToolNames: SuigarMcpToolName[];
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { GameMcpSupport, McpExecutionSurface, SUPPORTED_MCP_TOOL_NAMES, SuigarMcpToolName, buildMcpSupportCatalog, getMcpSupportForGame };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/mcp-support.d.ts
|
|
2
|
+
type SuigarMcpToolName = 'read_config' | 'read_game_metadata' | 'build_coinflip_transaction' | 'build_limbo_transaction' | 'build_plinko_transaction' | 'build_wheel_transaction' | 'build_range_transaction' | 'build_pvp_coinflip_create_transaction' | 'build_pvp_coinflip_join_transaction' | 'build_pvp_coinflip_cancel_transaction';
|
|
3
|
+
type McpExecutionSurface = 'onchain' | 'backend';
|
|
4
|
+
type GameMcpSupport = {
|
|
5
|
+
executionSurface: McpExecutionSurface;
|
|
6
|
+
toolSupported: boolean;
|
|
7
|
+
primaryToolName: SuigarMcpToolName | null;
|
|
8
|
+
};
|
|
9
|
+
declare const SUPPORTED_MCP_TOOL_NAMES: SuigarMcpToolName[];
|
|
10
|
+
declare const getMcpSupportForGame: (gameId: string) => GameMcpSupport;
|
|
11
|
+
declare const buildMcpSupportCatalog: () => Readonly<{
|
|
12
|
+
serverName: "suigar";
|
|
13
|
+
supportedToolNames: SuigarMcpToolName[];
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { GameMcpSupport, McpExecutionSurface, SUPPORTED_MCP_TOOL_NAMES, SuigarMcpToolName, buildMcpSupportCatalog, getMcpSupportForGame };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/mcp-support.ts
|
|
2
|
+
const SUPPORTED_MCP_TOOL_NAMES = [
|
|
3
|
+
"read_config",
|
|
4
|
+
"read_game_metadata",
|
|
5
|
+
"build_coinflip_transaction",
|
|
6
|
+
"build_limbo_transaction",
|
|
7
|
+
"build_plinko_transaction",
|
|
8
|
+
"build_wheel_transaction",
|
|
9
|
+
"build_range_transaction",
|
|
10
|
+
"build_pvp_coinflip_create_transaction",
|
|
11
|
+
"build_pvp_coinflip_join_transaction",
|
|
12
|
+
"build_pvp_coinflip_cancel_transaction"
|
|
13
|
+
];
|
|
14
|
+
const GAME_MCP_SUPPORT_BY_ID = {
|
|
15
|
+
coinflip: {
|
|
16
|
+
executionSurface: "onchain",
|
|
17
|
+
toolSupported: true,
|
|
18
|
+
primaryToolName: "build_coinflip_transaction"
|
|
19
|
+
},
|
|
20
|
+
limbo: {
|
|
21
|
+
executionSurface: "onchain",
|
|
22
|
+
toolSupported: true,
|
|
23
|
+
primaryToolName: "build_limbo_transaction"
|
|
24
|
+
},
|
|
25
|
+
plinko: {
|
|
26
|
+
executionSurface: "onchain",
|
|
27
|
+
toolSupported: true,
|
|
28
|
+
primaryToolName: "build_plinko_transaction"
|
|
29
|
+
},
|
|
30
|
+
wheel: {
|
|
31
|
+
executionSurface: "onchain",
|
|
32
|
+
toolSupported: true,
|
|
33
|
+
primaryToolName: "build_wheel_transaction"
|
|
34
|
+
},
|
|
35
|
+
range: {
|
|
36
|
+
executionSurface: "onchain",
|
|
37
|
+
toolSupported: true,
|
|
38
|
+
primaryToolName: "build_range_transaction"
|
|
39
|
+
},
|
|
40
|
+
"pvp-coinflip": {
|
|
41
|
+
executionSurface: "onchain",
|
|
42
|
+
toolSupported: true,
|
|
43
|
+
primaryToolName: "build_pvp_coinflip_create_transaction"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const getMcpSupportForGame = (gameId) => {
|
|
47
|
+
const support = GAME_MCP_SUPPORT_BY_ID[gameId];
|
|
48
|
+
if (support) return support;
|
|
49
|
+
return {
|
|
50
|
+
executionSurface: gameId === "slots" ? "backend" : "onchain",
|
|
51
|
+
toolSupported: false,
|
|
52
|
+
primaryToolName: null
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const buildMcpSupportCatalog = () => Object.freeze({
|
|
56
|
+
serverName: "suigar",
|
|
57
|
+
supportedToolNames: [...SUPPORTED_MCP_TOOL_NAMES]
|
|
58
|
+
});
|
|
59
|
+
//#endregion
|
|
60
|
+
export { SUPPORTED_MCP_TOOL_NAMES, buildMcpSupportCatalog, getMcpSupportForGame };
|