@evefrontier/dapp-kit 0.1.7 → 0.1.9

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/graphql/client.ts CHANGED
@@ -38,6 +38,9 @@ import {
38
38
  GET_OBJECT_WITH_JSON,
39
39
  GET_SINGLETON_CONFIG_OBJECT_BY_TYPE,
40
40
  } from "./queries";
41
+ import { createLogger } from "../utils/logger";
42
+
43
+ const log = createLogger();
41
44
 
42
45
  /**
43
46
  * Execute a GraphQL query against the Sui blockchain endpoint.
@@ -491,7 +494,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
491
494
  const result = await getObjectAndCharacterOwner(assemblyId);
492
495
 
493
496
  if (!result.data?.object?.asMoveObject) {
494
- console.warn("[DappKit] getAssemblyWithOwner: Assembly not found");
497
+ log.warn("[DappKit] getAssemblyWithOwner: Assembly not found");
495
498
  return {
496
499
  moveObject: null,
497
500
  assemblyOwner: null,
@@ -513,7 +516,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
513
516
  ?.asObject?.asMoveObject;
514
517
 
515
518
  if (!characterMoveObject?.contents?.json) {
516
- console.warn("[DappKit] getAssemblyWithOwner: Character not found");
519
+ log.warn("[DappKit] getAssemblyWithOwner: Character not found");
517
520
  return {
518
521
  moveObject: result.data?.object?.asMoveObject,
519
522
  assemblyOwner: null,
@@ -525,7 +528,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
525
528
  const characterJson = characterMoveObject?.contents.json;
526
529
  characterInfo = parseCharacterFromJson(characterJson);
527
530
  if (!characterInfo) {
528
- console.warn(
531
+ log.warn(
529
532
  "[DappKit] getAssemblyWithOwner: Could not extract character JSON from owner chain",
530
533
  );
531
534
  }
@@ -534,7 +537,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
534
537
  moveObject.contents.energySource?.asAddress?.asObject?.asMoveObject;
535
538
 
536
539
  if (!energySourceMoveObject?.contents?.json) {
537
- console.warn("[DappKit] getAssemblyWithOwner: Energy source not found");
540
+ log.warn("[DappKit] getAssemblyWithOwner: Energy source not found");
538
541
  }
539
542
 
540
543
  const destinationGateMoveObject =
@@ -546,7 +549,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
546
549
  ?.json as unknown as RawSuiObjectData | null;
547
550
 
548
551
  if (!energySourceJson) {
549
- console.warn(
552
+ log.warn(
550
553
  "[DappKit] getAssemblyWithOwner: Energy source not found. Object might be a network node.",
551
554
  );
552
555
  }
@@ -564,7 +567,7 @@ export async function getAssemblyWithOwner(assemblyId: string): Promise<{
564
567
  destinationGate: destinationGateJson ?? null,
565
568
  };
566
569
  } catch (error) {
567
- console.error("[DappKit] getAssemblyWithOwner error:", error);
570
+ log.error("[DappKit] getAssemblyWithOwner error:", error);
568
571
  return {
569
572
  moveObject: null,
570
573
  assemblyOwner: null,
@@ -16,7 +16,7 @@ import { SmartObjectContextType } from "../types";
16
16
  * - `character` - The owner character information (or null)
17
17
  * - `loading` - Boolean indicating if data is being fetched
18
18
  * - `error` - Error message string (or null)
19
- * - `refetch` - Function to manually refresh assembly data
19
+ * - `refetch` - Function to manually refresh assembly data with retries
20
20
  * @throws {Error} If used outside of `EveFrontierProvider`
21
21
  *
22
22
  * @example Basic usage
@@ -18,6 +18,9 @@ import {
18
18
  SponsoredTransactionArgs,
19
19
  } from "../wallet";
20
20
  import { Assemblies, QueryParams, SponsoredTransactionActions } from "../types";
21
+ import { createLogger, TenantId } from "../utils";
22
+
23
+ const log = createLogger();
21
24
 
22
25
  /** Wallet-like shape from dApp Kit (UiWallet or connection store). */
23
26
  type ResolvableWallet = {
@@ -126,6 +129,31 @@ function resolveAssemblyId(
126
129
  throw new AssemblyIdRequiredError();
127
130
  }
128
131
 
132
+ // ============================================================================
133
+ // Retry helpers (502 Bad Gateway)
134
+ // ============================================================================
135
+
136
+ const DEFAULT_MAX_RETRIES = 2;
137
+ const DEFAULT_RETRY_DELAY_MS = 1500;
138
+
139
+ function delay(ms: number): Promise<void> {
140
+ return new Promise((resolve) => setTimeout(resolve, ms));
141
+ }
142
+
143
+ /**
144
+ * Returns true if the error indicates a 502 (or similar transient server error)
145
+ * where retrying the same payload is safe.
146
+ */
147
+ function isRetryableSponsorError(error: unknown): boolean {
148
+ if (error instanceof Error) {
149
+ const msg = error.message.toLowerCase();
150
+ if (msg.includes("502") || msg.includes("bad gateway")) return true;
151
+ }
152
+ const withResponse = error as { response?: { status?: number } };
153
+ if (withResponse?.response?.status === 502) return true;
154
+ return false;
155
+ }
156
+
129
157
  // ============================================================================
130
158
  // Hook Types
131
159
  // ============================================================================
@@ -176,6 +204,9 @@ export type UseSponsoredTransactionMutationOptions = Omit<
176
204
  * tokens for gas. The wallet must support the `evefrontier:sponsoredTransaction` feature
177
205
  * (currently only EVE Vault).
178
206
  *
207
+ * Transient server errors (e.g. 502 Bad Gateway) are retried automatically with the same
208
+ * payload a limited number of times with a delay between attempts.
209
+ *
179
210
  * The hook automatically uses the currently connected wallet and account (unless overridden)
180
211
  * and handles wallet feature detection and validation.
181
212
  *
@@ -183,7 +214,7 @@ export type UseSponsoredTransactionMutationOptions = Omit<
183
214
  * - `txAction` (required) – The sponsored action to run (e.g. BRING_ONLINE, BRING_OFFLINE).
184
215
  * - `chain` (required) – Sui chain id, e.g. `"sui:testnet"` or `"sui:mainnet"`.
185
216
  * - `assembly` (required) – Full assembly object (`AssemblyType<Assemblies>`). Must include `type` and `item_id` (number). If `item_id` is missing or invalid, the hook falls back to the URL query param `itemId` (parsed as a non-negative integer). Fails with {@link AssemblyIdRequiredError} if neither source provides a valid id.
186
- * - `tenant` (optional) – Tenant ID. When omitted, the hook resolves it from the URL query param (e.g. `tenant`) with fallback to `"testevenet"`. Pass explicitly to override.
217
+ * - `tenant` (optional) – Tenant ID. When omitted, the hook resolves it from the URL query param (e.g. `tenant`) with fallback to `TenantId.UTOPIA`. Pass explicitly to override.
187
218
  * - `account` (optional) – Signer address. If omitted, the currently connected wallet account is used.
188
219
  *
189
220
  * **Output** (on success, in `data` or resolved from `mutateAsync`):
@@ -366,7 +397,7 @@ export function useSponsoredTransaction({
366
397
  );
367
398
  }
368
399
 
369
- const tenant = (args.tenant ?? queryTenant ?? "testevenet").trim();
400
+ const tenant = (args.tenant ?? queryTenant ?? TenantId.UTOPIA).trim();
370
401
  if (!tenant) {
371
402
  throw new Error(
372
403
  "Tenant could not be resolved; pass tenant or set the tenant query param",
@@ -390,9 +421,21 @@ export function useSponsoredTransaction({
390
421
  tenant,
391
422
  };
392
423
 
393
- console.log("Sponsored Transaction Payload:", payload);
424
+ log.info("Sponsored Transaction Payload:", payload);
394
425
 
395
- return await signSponsoredTransaction(payload);
426
+ let lastError: unknown;
427
+ const maxAttempts = DEFAULT_MAX_RETRIES + 1;
428
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
429
+ try {
430
+ return await signSponsoredTransaction(payload);
431
+ } catch (e) {
432
+ lastError = e;
433
+ const canRetry = attempt < maxAttempts && isRetryableSponsorError(e);
434
+ if (!canRetry) throw e;
435
+ await delay(DEFAULT_RETRY_DELAY_MS);
436
+ }
437
+ }
438
+ throw lastError;
396
439
  },
397
440
  ...mutationOptions,
398
441
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evefrontier/dapp-kit",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "React SDK for EVE Frontier dApps on Sui",
5
5
  "main": "index.ts",
6
6
  "author": "",
@@ -26,22 +26,23 @@
26
26
  "./config": "./config/index.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@mysten/dapp-kit-core": "^1.0.4",
30
- "@mysten/dapp-kit-react": "^1.0.2",
31
- "@mysten/sui": "^2.4.0",
32
- "@mysten/wallet-standard": "^0.19.9",
33
- "@tanstack/react-query": "^5.90.16",
29
+ "@mysten/dapp-kit-core": "^1.2.2",
30
+ "@mysten/dapp-kit-react": "^2.0.1",
31
+ "@mysten/sui": "^2.14.1",
32
+ "@mysten/wallet-standard": "^0.20.1",
33
+ "@tanstack/react-query": "^5.96.2",
34
34
  "react": "^19.2.4"
35
35
  },
36
36
  "devDependencies": {
37
+ "@vitest/ui": "^4.1.3",
37
38
  "@types/react": "^19.2.14",
38
- "@vitejs/plugin-react-swc": "3.4.0",
39
- "typedoc": "^0.28.17",
40
- "typedoc-plugin-markdown": "^4.4.0",
41
- "typescript": "^5.5.3",
42
- "vite": "^5.4.6",
43
- "vite-plugin-svgr": "^3.3.0",
44
- "vitest": "^4.0.14"
39
+ "@vitejs/plugin-react-swc": "^4.3.0",
40
+ "typedoc": "^0.28.18",
41
+ "typedoc-plugin-markdown": "^4.11.0",
42
+ "typescript": "^6.0.2",
43
+ "vite": "^8.0.5",
44
+ "vite-plugin-svgr": "^5.2.0",
45
+ "vitest": "^4.1.3"
45
46
  },
46
47
  "scripts": {
47
48
  "build": "tsc --noEmit",
@@ -9,6 +9,7 @@ export const NotificationContext = createContext<NotificationContextType>({
9
9
  notification: {
10
10
  message: "",
11
11
  txHash: "",
12
+ onSuccess: () => {},
12
13
  severity: Severity.Success,
13
14
  handleClose: () => {},
14
15
  isOpen: false,
@@ -26,23 +27,33 @@ const NotificationProvider = ({ children }: { children: ReactNode }) => {
26
27
  const [message, setMessage] = useState<string>("");
27
28
  const [severity, setSeverity] = useState<Severity>(Severity.Info);
28
29
  const [txHash, setTxHash] = useState<string>("");
30
+ const [onSuccess, setOnSuccess] = useState<NotificationState["onSuccess"]>(
31
+ () => () => {},
32
+ );
29
33
 
30
34
  const handleClose = useCallback(() => {
31
35
  setIsOpen(false);
32
- }, []);
36
+ if (severity === Severity.Success) {
37
+ onSuccess();
38
+ }
39
+ setOnSuccess(() => () => {});
40
+ }, [onSuccess, severity]);
33
41
 
34
42
  const notify = useCallback(
35
43
  ({
36
44
  type,
37
45
  message,
38
46
  txHash,
47
+ onSuccess,
39
48
  }: {
40
49
  type: Severity;
41
50
  message?: string;
42
51
  txHash?: string;
52
+ onSuccess?: () => void;
43
53
  }) => {
44
54
  setSeverity(type);
45
55
  setIsOpen(true);
56
+ setOnSuccess(() => onSuccess ?? (() => {}));
46
57
 
47
58
  // If success with txHash, show success message with transaction hash
48
59
  if (type === Severity.Success && txHash) {
@@ -81,6 +92,7 @@ const NotificationProvider = ({ children }: { children: ReactNode }) => {
81
92
  const notification: NotificationState = {
82
93
  message,
83
94
  txHash,
95
+ onSuccess,
84
96
  severity,
85
97
  handleClose,
86
98
  isOpen,
@@ -17,6 +17,7 @@ import {
17
17
  import { DEFAULT_TENANT, POLLING_INTERVAL } from "../utils/constants";
18
18
  import { getAssemblyWithOwner, MoveObjectData } from "../graphql";
19
19
  import {
20
+ createLogger,
20
21
  getObjectId,
21
22
  transformToAssembly,
22
23
  transformToCharacter,
@@ -25,6 +26,8 @@ import { getDatahubGameInfo } from "../utils/datahub";
25
26
  import { useConnection } from "../hooks/useConnection";
26
27
  import { SmartObjectContextType } from "../types";
27
28
 
29
+ const log = createLogger();
30
+
28
31
  /** Input for fetching object data: either itemId + tenant (derive object ID) or a Sui object ID directly.
29
32
  * @category Types
30
33
  */
@@ -66,7 +69,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
66
69
  const [loading, setLoading] = useState<boolean>(true);
67
70
  const [error, setError] = useState<string | null>(null);
68
71
 
69
- const pollingRef = useRef<NodeJS.Timeout | null>(null);
72
+ const pollingRef = useRef<ReturnType<typeof setTimeout> | null>(null);
70
73
  const lastDataHashRef = useRef<string | null>(null);
71
74
 
72
75
  const { isConnected } = useConnection();
@@ -91,7 +94,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
91
94
  const objectId = hasItemId
92
95
  ? await getObjectId(input.itemId, input.selectedTenant)
93
96
  : input.objectId;
94
- console.log(
97
+ log.info(
95
98
  "[DappKit] SmartObjectProvider: Fetching object:",
96
99
  hasItemId
97
100
  ? { itemId: input.itemId, selectedTenant: input.selectedTenant }
@@ -107,7 +110,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
107
110
  } = await getAssemblyWithOwner(objectId);
108
111
 
109
112
  if (!moveObject) {
110
- console.warn(
113
+ log.warn(
111
114
  "[DappKit] SmartObjectProvider: Object not found or not a Move object",
112
115
  );
113
116
  setAssembly(null);
@@ -125,7 +128,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
125
128
 
126
129
  // Only update state if the data changed (optimization for polling)
127
130
  if (isInitialFetch || lastDataHashRef.current !== dataHash) {
128
- console.log("[DappKit] SmartObjectProvider: Object data updated");
131
+ log.info("[DappKit] SmartObjectProvider: Object data updated");
129
132
  lastDataHashRef.current = dataHash;
130
133
 
131
134
  // Extract typeId from the raw JSON to fetch datahub info
@@ -139,7 +142,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
139
142
  try {
140
143
  datahubInfo = await getDatahubGameInfo(parseInt(typeId, 10));
141
144
  } catch (err) {
142
- console.warn(
145
+ log.warn(
143
146
  "[DappKit] SmartObjectProvider: Failed to fetch datahub info:",
144
147
  err,
145
148
  );
@@ -169,7 +172,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
169
172
  }
170
173
  setError(null);
171
174
  } catch (err: unknown) {
172
- console.error("[DappKit] SmartObjectProvider: Query error:", err);
175
+ log.error("[DappKit] SmartObjectProvider: Query error:", err);
173
176
  setError(err instanceof Error ? err.message : "Failed to fetch object");
174
177
  } finally {
175
178
  if (isInitialFetch) {
@@ -183,7 +186,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
183
186
  // Initialize the object ID (env or query params) and tenant (query params).
184
187
  // Tenant comes from URL ?tenant= with fallback DEFAULT_TENANT.
185
188
  useEffect(() => {
186
- console.log("[DappKit] SmartObjectProvider: Checking for item ID");
189
+ log.info("[DappKit] SmartObjectProvider: Checking for item ID");
187
190
 
188
191
  const queryParams = new URLSearchParams(window.location.search);
189
192
  const queryTenant =
@@ -193,7 +196,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
193
196
  const envObjectId = import.meta.env.VITE_OBJECT_ID;
194
197
 
195
198
  if (envObjectId) {
196
- console.log(
199
+ log.info(
197
200
  "[DappKit] SmartObjectProvider: Using Sui object ID from env:",
198
201
  envObjectId,
199
202
  );
@@ -211,7 +214,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
211
214
  setSelectedTenant(queryTenant);
212
215
  setIsObjectIdDirect(false);
213
216
  } else {
214
- console.error("[DappKit] SmartObjectProvider: No object ID provided");
217
+ log.error("[DappKit] SmartObjectProvider: No object ID provided");
215
218
  setLoading(false);
216
219
  }
217
220
  }, []);
@@ -235,7 +238,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
235
238
  fetchObjectData(input, false);
236
239
  }, POLLING_INTERVAL);
237
240
 
238
- console.log(
241
+ log.info(
239
242
  "[DappKit] SmartObjectProvider: Started polling for object:",
240
243
  selectedObjectId,
241
244
  );
@@ -244,7 +247,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
244
247
  if (pollingRef.current) {
245
248
  clearInterval(pollingRef.current);
246
249
  pollingRef.current = null;
247
- console.log("[DappKit] SmartObjectProvider: Stopped polling");
250
+ log.info("[DappKit] SmartObjectProvider: Stopped polling");
248
251
  }
249
252
  lastDataHashRef.current = null;
250
253
  };
@@ -264,6 +267,16 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
264
267
  await fetchObjectData(input, true);
265
268
  }, [selectedObjectId, selectedTenant, isObjectIdDirect, fetchObjectData]);
266
269
 
270
+ // Refetch with retries after a mutation (e.g. metadata save)
271
+ // so the indexer can catch up.
272
+ const handleRefetchWithRetries = useCallback(async () => {
273
+ await handleRefetch();
274
+ await new Promise<void>((resolve) => {
275
+ setTimeout(resolve, 1500);
276
+ });
277
+ await handleRefetch();
278
+ }, [handleRefetch]);
279
+
267
280
  return (
268
281
  <SmartObjectContext.Provider
269
282
  value={{
@@ -272,7 +285,7 @@ const SmartObjectProvider = ({ children }: { children: ReactNode }) => {
272
285
  assemblyOwner,
273
286
  loading,
274
287
  error,
275
- refetch: handleRefetch,
288
+ refetch: handleRefetchWithRetries,
276
289
  }}
277
290
  >
278
291
  {children}
@@ -4,9 +4,11 @@ import {
4
4
  useWallets,
5
5
  useDAppKit,
6
6
  } from "@mysten/dapp-kit-react";
7
- import { STORAGE_KEYS } from "../utils";
7
+ import { createLogger, STORAGE_KEYS } from "../utils";
8
8
  import { SupportedWallets, VaultContextType } from "../types";
9
9
 
10
+ const log = createLogger();
11
+
10
12
  /** @category Providers */
11
13
  export const VaultContext = createContext<VaultContextType>({
12
14
  currentAccount: null,
@@ -47,23 +49,23 @@ const VaultProvider = ({ children }: { children: ReactNode }) => {
47
49
  const walletToConnect = eveVaultWallet || wallets[0];
48
50
 
49
51
  if (!walletToConnect) {
50
- console.warn("No wallet available to connect");
52
+ log.warn("No wallet available to connect");
51
53
  return;
52
54
  }
53
55
 
54
56
  try {
55
57
  connectWallet({ wallet: walletToConnect });
56
- console.log("[DappKit] Connected to wallet:", walletToConnect.name);
58
+ log.info("[DappKit] Connected to wallet:", walletToConnect.name);
57
59
  localStorage.setItem(STORAGE_KEYS.CONNECTED, "true");
58
60
  } catch (error) {
59
- console.error("[DappKit] Failed to connect wallet:", error);
61
+ log.error("[DappKit] Failed to connect wallet:", error);
60
62
  }
61
63
  };
62
64
 
63
65
  const handleDisconnect = () => {
64
66
  disconnectWallet();
65
67
  localStorage.removeItem(STORAGE_KEYS.CONNECTED);
66
- console.log("[DappKit] Wallet disconnected");
68
+ log.info("[DappKit] Wallet disconnected");
67
69
  };
68
70
 
69
71
  // Auto-reconnect if user was previously connected (only once)
package/types/contexts.ts CHANGED
@@ -37,13 +37,21 @@ export interface SmartObjectContextType {
37
37
  refetch: () => Promise<void>;
38
38
  }
39
39
 
40
+ export interface NotifySuccess {
41
+ type: Severity.Success;
42
+ txHash?: string;
43
+ message?: string;
44
+ onSuccess?: () => void;
45
+ }
46
+
47
+ export interface NotifyOther {
48
+ type: Severity.Error | Severity.Warning | Severity.Info;
49
+ message?: string;
50
+ }
51
+
40
52
  /** @category Types */
41
53
  export interface NotificationContextType {
42
- notify: (notification: {
43
- type: Severity;
44
- txHash?: string;
45
- message?: string;
46
- }) => void;
54
+ notify: (notification: NotifySuccess | NotifyOther) => void;
47
55
  notification: NotificationState;
48
56
  handleClose: () => void;
49
57
  }
@@ -52,6 +60,7 @@ export interface NotificationContextType {
52
60
  export interface NotificationState {
53
61
  message: string;
54
62
  txHash: string;
63
+ onSuccess: () => void;
55
64
  severity: Severity;
56
65
  handleClose: () => void;
57
66
  isOpen: boolean;
package/types/types.ts CHANGED
@@ -157,3 +157,42 @@ export interface DatahubGameInfo {
157
157
  /** URL to the item's icon image */
158
158
  iconUrl: string;
159
159
  }
160
+
161
+ // =========================================
162
+ // Logger Types
163
+ // =========================================
164
+
165
+ export type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
166
+
167
+ export type GlobalProcess = {
168
+ env?: Record<string, string | undefined>;
169
+ cwd?: () => string;
170
+ };
171
+
172
+ export type GlobalWithProcess = typeof globalThis & {
173
+ process?: GlobalProcess;
174
+ };
175
+
176
+ export interface StackFrame {
177
+ filePath: string;
178
+ lineNumber?: number;
179
+ columnNumber?: number;
180
+ }
181
+
182
+ export type LoggerFn = (...args: unknown[]) => void;
183
+
184
+ export interface Logger {
185
+ debug: LoggerFn;
186
+ info: LoggerFn;
187
+ warn: LoggerFn;
188
+ error: LoggerFn;
189
+ /**
190
+ * Create a scoped logger that inherits the current options.
191
+ */
192
+ child: (scope: string) => Logger;
193
+ }
194
+
195
+ export interface CreateLoggerOptions {
196
+ scope?: string;
197
+ level?: LogLevel;
198
+ }
@@ -191,7 +191,10 @@ describe("getCharacterOwnedObjects", () => {
191
191
  const result = await getCharacterOwnedObjects("0xwallet");
192
192
 
193
193
  expect(result).toBeUndefined();
194
- expect(warnSpy).toHaveBeenCalledWith(
194
+ expect(warnSpy).toHaveBeenCalledTimes(1);
195
+ const [merged] = warnSpy.mock.calls[0] as [string];
196
+ expect(merged).toMatch(/characterOwnedObjects/);
197
+ expect(merged).toContain(
195
198
  "[Dapp] No data returned from getCharacterAndOwnedObjects",
196
199
  );
197
200
  warnSpy.mockRestore();
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { resolveTenantFromSearch, resolveDatahubHost } from "../datahub";
3
- import { DATAHUB_BY_TENANT, DEFAULT_TENANT } from "../constants";
3
+ import { DATAHUB_BY_TENANT, DEFAULT_TENANT, TenantId } from "../constants";
4
4
  import { QueryParams } from "../../types";
5
5
 
6
6
  const DEFAULT_HOST = DATAHUB_BY_TENANT[DEFAULT_TENANT];
@@ -19,16 +19,18 @@ describe("resolveTenantFromSearch (tenant resolution)", () => {
19
19
  });
20
20
 
21
21
  it("trims tenant value (surrounding spaces)", () => {
22
- expect(resolveTenantFromSearch("?tenant= stillness ")).toBe("stillness");
23
- expect(resolveTenantFromSearch("?tenant=nebula ")).toBe("nebula");
22
+ expect(resolveTenantFromSearch("?tenant= stillness ")).toBe(
23
+ TenantId.STILLNESS,
24
+ );
25
+ expect(resolveTenantFromSearch("?tenant=tauceti ")).toBe(TenantId.TAUCETI);
24
26
  });
25
27
 
26
28
  it("returns trimmed known tenant from param", () => {
27
- expect(resolveTenantFromSearch(`?${QueryParams.TENANT}=nebula`)).toBe(
28
- "nebula",
29
+ expect(resolveTenantFromSearch(`?${QueryParams.TENANT}=tauceti`)).toBe(
30
+ TenantId.TAUCETI,
29
31
  );
30
32
  expect(resolveTenantFromSearch(`?${QueryParams.TENANT}=utopia`)).toBe(
31
- "utopia",
33
+ TenantId.UTOPIA,
32
34
  );
33
35
  });
34
36
  });
@@ -40,9 +42,17 @@ describe("resolveDatahubHost (host fallback)", () => {
40
42
  });
41
43
 
42
44
  it("returns known host for valid tenant keys", () => {
43
- expect(resolveDatahubHost("stillness")).toBe(DATAHUB_BY_TENANT.stillness);
44
- expect(resolveDatahubHost("nebula")).toBe(DATAHUB_BY_TENANT.nebula);
45
- expect(resolveDatahubHost("utopia")).toBe(DATAHUB_BY_TENANT.utopia);
46
- expect(resolveDatahubHost("testevenet")).toBe(DATAHUB_BY_TENANT.testevenet);
45
+ expect(resolveDatahubHost(TenantId.STILLNESS)).toBe(
46
+ DATAHUB_BY_TENANT.stillness,
47
+ );
48
+ expect(resolveDatahubHost(TenantId.TAUCETI)).toBe(
49
+ DATAHUB_BY_TENANT.tauceti,
50
+ );
51
+ expect(resolveDatahubHost(TenantId.UTOPIA)).toBe(DATAHUB_BY_TENANT.utopia);
52
+ expect(resolveDatahubHost(TenantId.TIAKI)).toBe(DATAHUB_BY_TENANT.tiaki);
53
+ expect(resolveDatahubHost(TenantId.TETRA)).toBe(DATAHUB_BY_TENANT.tetra);
54
+ expect(resolveDatahubHost(TenantId.TESSERACT)).toBe(
55
+ DATAHUB_BY_TENANT.tesseract,
56
+ );
47
57
  });
48
58
  });