@dubsdotapp/expo 0.2.71 → 0.2.73
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/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +26 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +7 -3
- package/src/hooks/useCreateCustomGame.ts +2 -3
- package/src/hooks/useCreateGame.ts +2 -3
- package/src/hooks/useJoinGame.ts +2 -3
- package/src/provider.tsx +21 -7
- package/src/types.ts +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -406,6 +406,7 @@ interface UiConfig {
|
|
|
406
406
|
appName?: string;
|
|
407
407
|
appUrl?: string;
|
|
408
408
|
tagline?: string;
|
|
409
|
+
environment?: 'sandbox' | 'production';
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
interface DubsClientConfig {
|
|
@@ -482,7 +483,7 @@ declare class DubsClient {
|
|
|
482
483
|
parseErrorLocal(error: unknown): ParsedError;
|
|
483
484
|
/** Get the full local error code map */
|
|
484
485
|
getErrorCodesLocal(): Record<number, SolanaErrorCode>;
|
|
485
|
-
/** Fetch the app's UI customization config (accent color, icon, tagline) */
|
|
486
|
+
/** Fetch the app's UI customization config (accent color, icon, tagline, environment) */
|
|
486
487
|
getAppConfig(): Promise<UiConfig>;
|
|
487
488
|
}
|
|
488
489
|
|
package/dist/index.d.ts
CHANGED
|
@@ -406,6 +406,7 @@ interface UiConfig {
|
|
|
406
406
|
appName?: string;
|
|
407
407
|
appUrl?: string;
|
|
408
408
|
tagline?: string;
|
|
409
|
+
environment?: 'sandbox' | 'production';
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
interface DubsClientConfig {
|
|
@@ -482,7 +483,7 @@ declare class DubsClient {
|
|
|
482
483
|
parseErrorLocal(error: unknown): ParsedError;
|
|
483
484
|
/** Get the full local error code map */
|
|
484
485
|
getErrorCodesLocal(): Record<number, SolanaErrorCode>;
|
|
485
|
-
/** Fetch the app's UI customization config (accent color, icon, tagline) */
|
|
486
|
+
/** Fetch the app's UI customization config (accent color, icon, tagline, environment) */
|
|
486
487
|
getAppConfig(): Promise<UiConfig>;
|
|
487
488
|
}
|
|
488
489
|
|
package/dist/index.js
CHANGED
|
@@ -585,10 +585,14 @@ var DubsClient = class {
|
|
|
585
585
|
return { ...SOLANA_PROGRAM_ERRORS };
|
|
586
586
|
}
|
|
587
587
|
// ── App Config ──
|
|
588
|
-
/** Fetch the app's UI customization config (accent color, icon, tagline) */
|
|
588
|
+
/** Fetch the app's UI customization config (accent color, icon, tagline, environment) */
|
|
589
589
|
async getAppConfig() {
|
|
590
590
|
const res = await this.request("GET", "/apps/config");
|
|
591
|
-
|
|
591
|
+
const config = res.data?.uiConfig || {};
|
|
592
|
+
if (res.data?.environment) {
|
|
593
|
+
config.environment = res.data.environment;
|
|
594
|
+
}
|
|
595
|
+
return config;
|
|
592
596
|
}
|
|
593
597
|
};
|
|
594
598
|
|
|
@@ -1846,7 +1850,7 @@ function useCreateGame() {
|
|
|
1846
1850
|
console.log("[useCreateGame] Step 2 done. Signature:", signature);
|
|
1847
1851
|
setStatus("confirming");
|
|
1848
1852
|
console.log("[useCreateGame] Step 3: Confirming with backend...");
|
|
1849
|
-
await client.confirmGame({
|
|
1853
|
+
const confirmResult = await client.confirmGame({
|
|
1850
1854
|
gameId: createResult.gameId,
|
|
1851
1855
|
playerWallet: params.playerWallet,
|
|
1852
1856
|
signature,
|
|
@@ -1856,12 +1860,11 @@ function useCreateGame() {
|
|
|
1856
1860
|
gameAddress: createResult.gameAddress
|
|
1857
1861
|
});
|
|
1858
1862
|
console.log("[useCreateGame] Step 3 done.");
|
|
1859
|
-
const explorerUrl = `https://solscan.io/tx/${signature}`;
|
|
1860
1863
|
const result = {
|
|
1861
1864
|
gameId: createResult.gameId,
|
|
1862
1865
|
gameAddress: createResult.gameAddress,
|
|
1863
1866
|
signature,
|
|
1864
|
-
explorerUrl
|
|
1867
|
+
explorerUrl: confirmResult.explorerUrl
|
|
1865
1868
|
};
|
|
1866
1869
|
setData(result);
|
|
1867
1870
|
setStatus("success");
|
|
@@ -1917,14 +1920,13 @@ function useJoinGame() {
|
|
|
1917
1920
|
gameAddress: joinResult.gameAddress
|
|
1918
1921
|
};
|
|
1919
1922
|
console.log("[useJoinGame] Step 3: Confirming with backend...", confirmParams);
|
|
1920
|
-
await client.confirmGame(confirmParams);
|
|
1923
|
+
const confirmResult = await client.confirmGame(confirmParams);
|
|
1921
1924
|
console.log("[useJoinGame] Step 3 done. Backend confirmed.");
|
|
1922
|
-
const explorerUrl = `https://solscan.io/tx/${signature}`;
|
|
1923
1925
|
const result = {
|
|
1924
1926
|
gameId: params.gameId,
|
|
1925
1927
|
gameAddress: joinResult.gameAddress,
|
|
1926
1928
|
signature,
|
|
1927
|
-
explorerUrl
|
|
1929
|
+
explorerUrl: confirmResult.explorerUrl
|
|
1928
1930
|
};
|
|
1929
1931
|
setData(result);
|
|
1930
1932
|
setStatus("success");
|
|
@@ -2042,7 +2044,7 @@ function useCreateCustomGame() {
|
|
|
2042
2044
|
console.log("[useCreateCustomGame] Step 2 done. Signature:", signature);
|
|
2043
2045
|
setStatus("confirming");
|
|
2044
2046
|
console.log("[useCreateCustomGame] Step 3: Confirming with backend...");
|
|
2045
|
-
await client.confirmCustomGame({
|
|
2047
|
+
const confirmResult = await client.confirmCustomGame({
|
|
2046
2048
|
gameId: createResult.gameId,
|
|
2047
2049
|
playerWallet: params.playerWallet,
|
|
2048
2050
|
signature,
|
|
@@ -2052,12 +2054,11 @@ function useCreateCustomGame() {
|
|
|
2052
2054
|
gameAddress: createResult.gameAddress
|
|
2053
2055
|
});
|
|
2054
2056
|
console.log("[useCreateCustomGame] Step 3 done.");
|
|
2055
|
-
const explorerUrl = `https://solscan.io/tx/${signature}`;
|
|
2056
2057
|
const result = {
|
|
2057
2058
|
gameId: createResult.gameId,
|
|
2058
2059
|
gameAddress: createResult.gameAddress,
|
|
2059
2060
|
signature,
|
|
2060
|
-
explorerUrl,
|
|
2061
|
+
explorerUrl: confirmResult.explorerUrl,
|
|
2061
2062
|
buyIn: params.wagerAmount
|
|
2062
2063
|
};
|
|
2063
2064
|
setData(result);
|
|
@@ -3152,21 +3153,28 @@ function DubsProvider({
|
|
|
3152
3153
|
const config = NETWORK_CONFIG[network];
|
|
3153
3154
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
3154
3155
|
const rpcUrl = rpcUrlOverride || config.rpcUrl;
|
|
3155
|
-
const cluster = config.cluster;
|
|
3156
3156
|
const client = (0, import_react18.useMemo)(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
3157
|
-
const connection = (0, import_react18.useMemo)(() => new import_web34.Connection(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
|
|
3158
3157
|
const storage = (0, import_react18.useMemo)(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
|
|
3159
3158
|
const [uiConfig, setUiConfig] = (0, import_react18.useState)(null);
|
|
3159
|
+
const [resolvedNetwork, setResolvedNetwork] = (0, import_react18.useState)(network);
|
|
3160
3160
|
(0, import_react18.useEffect)(() => {
|
|
3161
|
-
client.getAppConfig().then((
|
|
3162
|
-
console.log("[DubsProvider] UI config loaded:", JSON.stringify(
|
|
3163
|
-
setUiConfig(
|
|
3161
|
+
client.getAppConfig().then((cfg) => {
|
|
3162
|
+
console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
|
|
3163
|
+
setUiConfig(cfg);
|
|
3164
|
+
if (cfg.environment === "sandbox" && network === "mainnet-beta" && !rpcUrlOverride) {
|
|
3165
|
+
console.log("[DubsProvider] Sandbox API key detected \u2014 auto-switching to devnet");
|
|
3166
|
+
setResolvedNetwork("devnet");
|
|
3167
|
+
}
|
|
3164
3168
|
}).catch((err) => {
|
|
3165
3169
|
console.log("[DubsProvider] UI config fetch failed, using defaults:", err?.message);
|
|
3166
3170
|
setUiConfig({});
|
|
3167
3171
|
});
|
|
3168
3172
|
}, [client]);
|
|
3169
3173
|
if (uiConfig === null) return null;
|
|
3174
|
+
const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
|
|
3175
|
+
const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
|
|
3176
|
+
const cluster = resolvedConfig.cluster;
|
|
3177
|
+
const connection = (0, import_react18.useMemo)(() => new import_web34.Connection(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
|
|
3170
3178
|
const themeOverrides = {};
|
|
3171
3179
|
if (uiConfig.accentColor) {
|
|
3172
3180
|
themeOverrides.accent = uiConfig.accentColor;
|
|
@@ -3179,7 +3187,7 @@ function DubsProvider({
|
|
|
3179
3187
|
connection,
|
|
3180
3188
|
wallet: externalWallet,
|
|
3181
3189
|
appName: uiConfig.appName || appName,
|
|
3182
|
-
network,
|
|
3190
|
+
network: resolvedNetwork,
|
|
3183
3191
|
storage,
|
|
3184
3192
|
managed,
|
|
3185
3193
|
renderLoading,
|
|
@@ -3211,7 +3219,7 @@ function DubsProvider({
|
|
|
3211
3219
|
connection,
|
|
3212
3220
|
wallet: adapter,
|
|
3213
3221
|
appName: uiConfig.appName || appName,
|
|
3214
|
-
network,
|
|
3222
|
+
network: resolvedNetwork,
|
|
3215
3223
|
storage,
|
|
3216
3224
|
renderLoading,
|
|
3217
3225
|
renderError,
|