@microcosmmoney/auth-react 1.5.0 → 1.5.1

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.
@@ -1,8 +1,9 @@
1
- interface UseApiQueryOptions {
1
+ interface UseApiQueryOptions<T = any> {
2
2
  path: string;
3
3
  requireAuth?: boolean;
4
4
  refetchInterval?: number;
5
5
  skip?: boolean;
6
+ select?: (raw: any) => T;
6
7
  }
7
8
  export interface UseApiQueryResult<T> {
8
9
  data: T | null;
@@ -10,5 +11,5 @@ export interface UseApiQueryResult<T> {
10
11
  error: Error | null;
11
12
  refresh: () => Promise<void>;
12
13
  }
13
- export declare function useApiQuery<T = any>(options: UseApiQueryOptions): UseApiQueryResult<T>;
14
+ export declare function useApiQuery<T = any>(options: UseApiQueryOptions<T>): UseApiQueryResult<T>;
14
15
  export {};
@@ -22,7 +22,7 @@ function useApiQuery(options) {
22
22
  setLoading(true);
23
23
  const res = await api.get(options.path);
24
24
  if (mountedRef.current) {
25
- setData(res.data);
25
+ setData(options.select ? options.select(res.data) : res.data);
26
26
  setError(null);
27
27
  }
28
28
  }
@@ -10,5 +10,6 @@ function useBuybackHistory(options) {
10
10
  path: `/reincarnation/user-history?page=${page}&page_size=${pageSize}`,
11
11
  requireAuth: true,
12
12
  refetchInterval: options?.refetchInterval ?? 0,
13
+ select: (d) => Array.isArray(d) ? d : d?.records ?? [],
13
14
  });
14
15
  }
@@ -1,3 +1,3 @@
1
1
  export declare function useFragmentHoldings(wallet?: string, options?: {
2
2
  refetchInterval?: number;
3
- }): import("./use-api-query").UseApiQueryResult<any>;
3
+ }): import("./use-api-query").UseApiQueryResult<any[]>;
@@ -9,5 +9,6 @@ function useFragmentHoldings(wallet, options) {
9
9
  requireAuth: false,
10
10
  skip: !wallet,
11
11
  refetchInterval: options?.refetchInterval ?? 0,
12
+ select: (d) => Array.isArray(d) ? d : d?.holdings ?? [],
12
13
  });
13
14
  }
@@ -7,5 +7,6 @@ function useFragmentVaults(options) {
7
7
  return (0, use_api_query_1.useApiQuery)({
8
8
  path: '/fragment/vaults',
9
9
  refetchInterval: options?.refetchInterval ?? 120000,
10
+ select: (d) => Array.isArray(d) ? d : d?.vaults ?? [],
10
11
  });
11
12
  }
@@ -1,3 +1,3 @@
1
1
  export declare function useLendingLoans(wallet?: string, options?: {
2
2
  refetchInterval?: number;
3
- }): import("./use-api-query").UseApiQueryResult<any>;
3
+ }): import("./use-api-query").UseApiQueryResult<any[]>;
@@ -9,5 +9,6 @@ function useLendingLoans(wallet, options) {
9
9
  requireAuth: false,
10
10
  skip: !wallet,
11
11
  refetchInterval: options?.refetchInterval ?? 0,
12
+ select: (d) => Array.isArray(d) ? d : d?.loans ?? [],
12
13
  });
13
14
  }
@@ -8,5 +8,6 @@ function useMCCLocks(options) {
8
8
  path: '/mcc/locks',
9
9
  requireAuth: true,
10
10
  refetchInterval: options?.refetchInterval ?? 0,
11
+ select: (d) => Array.isArray(d) ? d : d?.locks ?? [],
11
12
  });
12
13
  }
@@ -15,5 +15,6 @@ function useMCDRewards(options) {
15
15
  path: `/mcd/rewards${qs}`,
16
16
  requireAuth: true,
17
17
  refetchInterval: options?.refetchInterval ?? 0,
18
+ select: (d) => Array.isArray(d) ? d : d?.records ?? [],
18
19
  });
19
20
  }
@@ -13,5 +13,6 @@ function useMCDTransactions(options) {
13
13
  path: `/mcd/transactions${qs}`,
14
14
  requireAuth: true,
15
15
  refetchInterval: options?.refetchInterval ?? 0,
16
+ select: (d) => Array.isArray(d) ? d : d?.records ?? [],
16
17
  });
17
18
  }
@@ -7,5 +7,6 @@ function usePriceHistory(range = '7D', options) {
7
7
  return (0, use_api_query_1.useApiQuery)({
8
8
  path: `/mcc/price/history?range=${range}`,
9
9
  refetchInterval: options?.refetchInterval ?? 300000,
10
+ select: (d) => Array.isArray(d) ? d : d?.records ?? [],
10
11
  });
11
12
  }
@@ -1,3 +1,3 @@
1
1
  export declare function useTerritoryNFTs(wallet?: string, options?: {
2
2
  refetchInterval?: number;
3
- }): import("./use-api-query").UseApiQueryResult<any>;
3
+ }): import("./use-api-query").UseApiQueryResult<any[]>;
@@ -8,5 +8,6 @@ function useTerritoryNFTs(wallet, options) {
8
8
  path: `/territory/nfts/${wallet}`,
9
9
  skip: !wallet,
10
10
  refetchInterval: options?.refetchInterval ?? 0,
11
+ select: (d) => Array.isArray(d) ? d : d?.nfts ?? [],
11
12
  });
12
13
  }
@@ -8,5 +8,6 @@ function useWallets(options) {
8
8
  path: '/wallets',
9
9
  requireAuth: true,
10
10
  refetchInterval: options?.refetchInterval ?? 0,
11
+ select: (d) => Array.isArray(d) ? d : d?.wallets ?? [],
11
12
  });
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microcosmmoney/auth-react",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Microcosm OAuth 2.0 React/Next.js adapter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "react-dom": ">=18.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@microcosmmoney/auth-core": "^1.5.0"
27
+ "@microcosmmoney/auth-core": "^1.5.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/react": "^18.0.0",