@microcosmmoney/auth-react 1.0.2 → 1.0.4

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.
Files changed (75) hide show
  1. package/dist/hooks/use-auction-bid.d.ts +5 -0
  2. package/dist/hooks/use-auction-bid.js +34 -0
  3. package/dist/hooks/use-auction-cancel.d.ts +5 -0
  4. package/dist/hooks/use-auction-cancel.js +34 -0
  5. package/dist/hooks/use-auction-detail.d.ts +3 -0
  6. package/dist/hooks/use-auction-detail.js +12 -0
  7. package/dist/hooks/use-auction-history.d.ts +9 -0
  8. package/dist/hooks/use-auction-history.js +41 -0
  9. package/dist/hooks/use-buyback-action.d.ts +6 -0
  10. package/dist/hooks/use-buyback-action.js +34 -0
  11. package/dist/hooks/use-buyback-history.d.ts +6 -0
  12. package/dist/hooks/use-buyback-history.js +14 -0
  13. package/dist/hooks/use-buyback-quote.d.ts +7 -0
  14. package/dist/hooks/use-buyback-quote.js +44 -0
  15. package/dist/hooks/use-cycle-history.d.ts +13 -0
  16. package/dist/hooks/use-cycle-history.js +41 -0
  17. package/dist/hooks/use-mcc-history.d.ts +18 -0
  18. package/dist/hooks/use-mcc-history.js +50 -0
  19. package/dist/hooks/use-mcc-locks.d.ts +4 -0
  20. package/dist/hooks/use-mcc-locks.js +12 -0
  21. package/dist/hooks/use-mcd-rewards.d.ts +8 -0
  22. package/dist/hooks/use-mcd-rewards.js +19 -0
  23. package/dist/hooks/use-mcd-transactions.d.ts +7 -0
  24. package/dist/hooks/use-mcd-transactions.js +17 -0
  25. package/dist/hooks/use-mining-action.d.ts +20 -0
  26. package/dist/hooks/use-mining-action.js +55 -0
  27. package/dist/hooks/use-mining-config.d.ts +7 -0
  28. package/dist/hooks/use-mining-config.js +38 -0
  29. package/dist/hooks/use-mining-distribution.d.ts +6 -0
  30. package/dist/hooks/use-mining-distribution.js +14 -0
  31. package/dist/hooks/use-mining-history.d.ts +9 -0
  32. package/dist/hooks/use-mining-history.js +46 -0
  33. package/dist/hooks/use-mining-ratio.d.ts +4 -0
  34. package/dist/hooks/use-mining-ratio.js +11 -0
  35. package/dist/hooks/use-my-bids.d.ts +4 -0
  36. package/dist/hooks/use-my-bids.js +12 -0
  37. package/dist/hooks/use-proposal-detail.d.ts +4 -0
  38. package/dist/hooks/use-proposal-detail.js +13 -0
  39. package/dist/hooks/use-proposals.d.ts +7 -0
  40. package/dist/hooks/use-proposals.js +17 -0
  41. package/dist/hooks/use-public-mining.d.ts +12 -0
  42. package/dist/hooks/use-public-mining.js +54 -0
  43. package/dist/hooks/use-reincarnation-config.d.ts +7 -0
  44. package/dist/hooks/use-reincarnation-config.js +38 -0
  45. package/dist/hooks/use-territories.d.ts +8 -0
  46. package/dist/hooks/use-territories.js +19 -0
  47. package/dist/hooks/use-territory-detail.d.ts +4 -0
  48. package/dist/hooks/use-territory-detail.js +13 -0
  49. package/dist/hooks/use-territory-income.d.ts +6 -0
  50. package/dist/hooks/use-territory-income.js +43 -0
  51. package/dist/hooks/use-territory-kpi.d.ts +6 -0
  52. package/dist/hooks/use-territory-kpi.js +43 -0
  53. package/dist/hooks/use-territory-members.d.ts +6 -0
  54. package/dist/hooks/use-territory-members.js +15 -0
  55. package/dist/hooks/use-territory-ranking.d.ts +9 -0
  56. package/dist/hooks/use-territory-ranking.js +46 -0
  57. package/dist/hooks/use-territory-stats.d.ts +4 -0
  58. package/dist/hooks/use-territory-stats.js +13 -0
  59. package/dist/hooks/use-territory-summary.d.ts +4 -0
  60. package/dist/hooks/use-territory-summary.js +12 -0
  61. package/dist/hooks/use-territory-update.d.ts +12 -0
  62. package/dist/hooks/use-territory-update.js +56 -0
  63. package/dist/hooks/use-token-portfolio.d.ts +4 -0
  64. package/dist/hooks/use-token-portfolio.js +12 -0
  65. package/dist/hooks/use-user-stats.d.ts +3 -0
  66. package/dist/hooks/use-user-stats.js +11 -0
  67. package/dist/hooks/use-vote-action.d.ts +14 -0
  68. package/dist/hooks/use-vote-action.js +58 -0
  69. package/dist/hooks/use-vote-power.d.ts +4 -0
  70. package/dist/hooks/use-vote-power.js +12 -0
  71. package/dist/hooks/use-wallets.d.ts +4 -0
  72. package/dist/hooks/use-wallets.js +12 -0
  73. package/dist/index.d.ts +37 -1
  74. package/dist/index.js +74 -1
  75. package/package.json +2 -2
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMiningHistory = useMiningHistory;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useMiningHistory(params) {
8
+ const { client, isAuthenticated } = (0, provider_1.useAuth)();
9
+ const [data, setData] = (0, react_1.useState)(null);
10
+ const [loading, setLoading] = (0, react_1.useState)(true);
11
+ const [error, setError] = (0, react_1.useState)(null);
12
+ const mountedRef = (0, react_1.useRef)(true);
13
+ const p = params || {};
14
+ const limit = p.limit || 20;
15
+ const offset = p.offset || 0;
16
+ const fetchData = (0, react_1.useCallback)(async () => {
17
+ if (!isAuthenticated) {
18
+ setData(null);
19
+ setLoading(false);
20
+ return;
21
+ }
22
+ const api = client.getApiClient();
23
+ try {
24
+ setLoading(true);
25
+ const res = await api.get(`/mining/history?limit=${limit}&offset=${offset}`);
26
+ if (mountedRef.current) {
27
+ setData(res.data);
28
+ setError(null);
29
+ }
30
+ }
31
+ catch (err) {
32
+ if (mountedRef.current)
33
+ setError(err instanceof Error ? err : new Error(String(err)));
34
+ }
35
+ finally {
36
+ if (mountedRef.current)
37
+ setLoading(false);
38
+ }
39
+ }, [client, isAuthenticated, limit, offset]);
40
+ (0, react_1.useEffect)(() => {
41
+ mountedRef.current = true;
42
+ fetchData();
43
+ return () => { mountedRef.current = false; };
44
+ }, [fetchData]);
45
+ return { data, loading, error, refresh: fetchData };
46
+ }
@@ -0,0 +1,4 @@
1
+ import type { MiningRatio } from '@microcosmmoney/auth-core';
2
+ export declare function useMiningRatio(options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<MiningRatio>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMiningRatio = useMiningRatio;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useMiningRatio(options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: '/mining/ratio',
9
+ refetchInterval: options?.refetchInterval ?? 300000,
10
+ });
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { AuctionBid } from '@microcosmmoney/auth-core';
2
+ export declare function useMyBids(options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<AuctionBid[]>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMyBids = useMyBids;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useMyBids(options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: '/auction-solana/my-bids',
9
+ requireAuth: true,
10
+ refetchInterval: options?.refetchInterval ?? 0,
11
+ });
12
+ }
@@ -0,0 +1,4 @@
1
+ import type { ProposalDetail } from '@microcosmmoney/auth-core';
2
+ export declare function useProposalDetail(id?: string, options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<ProposalDetail>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useProposalDetail = useProposalDetail;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useProposalDetail(id, options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: `/voting/proposals/${id}`,
9
+ requireAuth: true,
10
+ skip: !id,
11
+ refetchInterval: options?.refetchInterval ?? 0,
12
+ });
13
+ }
@@ -0,0 +1,7 @@
1
+ import type { Proposal } from '@microcosmmoney/auth-core';
2
+ export declare function useProposals(options?: {
3
+ status?: string;
4
+ page?: number;
5
+ pageSize?: number;
6
+ refetchInterval?: number;
7
+ }): import("./use-api-query").UseApiQueryResult<Proposal[]>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useProposals = useProposals;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useProposals(options) {
7
+ const page = options?.page ?? 1;
8
+ const pageSize = options?.pageSize ?? 20;
9
+ let qs = `?page=${page}&page_size=${pageSize}`;
10
+ if (options?.status)
11
+ qs += `&status=${options.status}`;
12
+ return (0, use_api_query_1.useApiQuery)({
13
+ path: `/voting/proposals${qs}`,
14
+ requireAuth: true,
15
+ refetchInterval: options?.refetchInterval ?? 0,
16
+ });
17
+ }
@@ -0,0 +1,12 @@
1
+ interface PublicMiningRequestParams {
2
+ wallet_address: string;
3
+ mcc_amount: number;
4
+ stablecoin?: string;
5
+ }
6
+ export declare function usePublicMining(): {
7
+ createRequest: (params: PublicMiningRequestParams) => Promise<any>;
8
+ verify: (requestId: string, txSignature: string) => Promise<any>;
9
+ loading: boolean;
10
+ error: Error | null;
11
+ };
12
+ export {};
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePublicMining = usePublicMining;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function usePublicMining() {
8
+ const { client } = (0, provider_1.useAuth)();
9
+ const [loading, setLoading] = (0, react_1.useState)(false);
10
+ const [error, setError] = (0, react_1.useState)(null);
11
+ const mountedRef = (0, react_1.useRef)(true);
12
+ const createRequest = (0, react_1.useCallback)(async (params) => {
13
+ const api = client.getApiClient();
14
+ try {
15
+ setLoading(true);
16
+ setError(null);
17
+ const res = await api.post('/mining/public/request', params);
18
+ return res.data;
19
+ }
20
+ catch (err) {
21
+ const e = err instanceof Error ? err : new Error(String(err));
22
+ if (mountedRef.current)
23
+ setError(e);
24
+ throw e;
25
+ }
26
+ finally {
27
+ if (mountedRef.current)
28
+ setLoading(false);
29
+ }
30
+ }, [client]);
31
+ const verify = (0, react_1.useCallback)(async (requestId, txSignature) => {
32
+ const api = client.getApiClient();
33
+ try {
34
+ setLoading(true);
35
+ setError(null);
36
+ const res = await api.post('/mining/public/verify', {
37
+ request_id: requestId,
38
+ tx_signature: txSignature,
39
+ });
40
+ return res.data;
41
+ }
42
+ catch (err) {
43
+ const e = err instanceof Error ? err : new Error(String(err));
44
+ if (mountedRef.current)
45
+ setError(e);
46
+ throw e;
47
+ }
48
+ finally {
49
+ if (mountedRef.current)
50
+ setLoading(false);
51
+ }
52
+ }, [client]);
53
+ return { createRequest, verify, loading, error };
54
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReincarnationConfig } from '@microcosmmoney/auth-core';
2
+ export declare function useReincarnationConfig(): {
3
+ data: ReincarnationConfig | null;
4
+ loading: boolean;
5
+ error: Error | null;
6
+ refresh: () => Promise<void>;
7
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useReincarnationConfig = useReincarnationConfig;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useReincarnationConfig() {
8
+ const { client } = (0, provider_1.useAuth)();
9
+ const [data, setData] = (0, react_1.useState)(null);
10
+ const [loading, setLoading] = (0, react_1.useState)(true);
11
+ const [error, setError] = (0, react_1.useState)(null);
12
+ const mountedRef = (0, react_1.useRef)(true);
13
+ const fetchData = (0, react_1.useCallback)(async () => {
14
+ const api = client.getApiClient();
15
+ try {
16
+ setLoading(true);
17
+ const res = await api.get('/reincarnation/config');
18
+ if (mountedRef.current) {
19
+ setData(res.data);
20
+ setError(null);
21
+ }
22
+ }
23
+ catch (err) {
24
+ if (mountedRef.current)
25
+ setError(err instanceof Error ? err : new Error(String(err)));
26
+ }
27
+ finally {
28
+ if (mountedRef.current)
29
+ setLoading(false);
30
+ }
31
+ }, [client]);
32
+ (0, react_1.useEffect)(() => {
33
+ mountedRef.current = true;
34
+ fetchData();
35
+ return () => { mountedRef.current = false; };
36
+ }, [fetchData]);
37
+ return { data, loading, error, refresh: fetchData };
38
+ }
@@ -0,0 +1,8 @@
1
+ import type { Territory } from '@microcosmmoney/auth-core';
2
+ export declare function useTerritories(options?: {
3
+ unitType?: string;
4
+ parentId?: string;
5
+ page?: number;
6
+ pageSize?: number;
7
+ refetchInterval?: number;
8
+ }): import("./use-api-query").UseApiQueryResult<Territory[]>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritories = useTerritories;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTerritories(options) {
7
+ const page = options?.page ?? 1;
8
+ const pageSize = options?.pageSize ?? 20;
9
+ let qs = `?page=${page}&page_size=${pageSize}`;
10
+ if (options?.unitType)
11
+ qs += `&unit_type=${options.unitType}`;
12
+ if (options?.parentId)
13
+ qs += `&parent_id=${options.parentId}`;
14
+ return (0, use_api_query_1.useApiQuery)({
15
+ path: `/territories${qs}`,
16
+ requireAuth: true,
17
+ refetchInterval: options?.refetchInterval ?? 0,
18
+ });
19
+ }
@@ -0,0 +1,4 @@
1
+ import type { Territory } from '@microcosmmoney/auth-core';
2
+ export declare function useTerritoryDetail(id?: string, options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<Territory>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryDetail = useTerritoryDetail;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTerritoryDetail(id, options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: `/territories/${id}`,
9
+ requireAuth: true,
10
+ skip: !id,
11
+ refetchInterval: options?.refetchInterval ?? 0,
12
+ });
13
+ }
@@ -0,0 +1,6 @@
1
+ export declare function useTerritoryIncome(territoryId?: string, period?: string): {
2
+ data: any;
3
+ loading: boolean;
4
+ error: Error | null;
5
+ refresh: () => Promise<void>;
6
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryIncome = useTerritoryIncome;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useTerritoryIncome(territoryId, period = '30d') {
8
+ const { client, isAuthenticated } = (0, provider_1.useAuth)();
9
+ const [data, setData] = (0, react_1.useState)(null);
10
+ const [loading, setLoading] = (0, react_1.useState)(true);
11
+ const [error, setError] = (0, react_1.useState)(null);
12
+ const mountedRef = (0, react_1.useRef)(true);
13
+ const fetchData = (0, react_1.useCallback)(async () => {
14
+ if (!isAuthenticated || !territoryId) {
15
+ setData(null);
16
+ setLoading(false);
17
+ return;
18
+ }
19
+ const api = client.getApiClient();
20
+ try {
21
+ setLoading(true);
22
+ const res = await api.get(`/territories/${territoryId}/income-chart?period=${period}`);
23
+ if (mountedRef.current) {
24
+ setData(res.data);
25
+ setError(null);
26
+ }
27
+ }
28
+ catch (err) {
29
+ if (mountedRef.current)
30
+ setError(err instanceof Error ? err : new Error(String(err)));
31
+ }
32
+ finally {
33
+ if (mountedRef.current)
34
+ setLoading(false);
35
+ }
36
+ }, [client, isAuthenticated, territoryId, period]);
37
+ (0, react_1.useEffect)(() => {
38
+ mountedRef.current = true;
39
+ fetchData();
40
+ return () => { mountedRef.current = false; };
41
+ }, [fetchData]);
42
+ return { data, loading, error, refresh: fetchData };
43
+ }
@@ -0,0 +1,6 @@
1
+ export declare function useTerritoryKPI(territoryId?: string): {
2
+ data: any;
3
+ loading: boolean;
4
+ error: Error | null;
5
+ refresh: () => Promise<void>;
6
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryKPI = useTerritoryKPI;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useTerritoryKPI(territoryId) {
8
+ const { client, isAuthenticated } = (0, provider_1.useAuth)();
9
+ const [data, setData] = (0, react_1.useState)(null);
10
+ const [loading, setLoading] = (0, react_1.useState)(true);
11
+ const [error, setError] = (0, react_1.useState)(null);
12
+ const mountedRef = (0, react_1.useRef)(true);
13
+ const fetchData = (0, react_1.useCallback)(async () => {
14
+ if (!isAuthenticated || !territoryId) {
15
+ setData(null);
16
+ setLoading(false);
17
+ return;
18
+ }
19
+ const api = client.getApiClient();
20
+ try {
21
+ setLoading(true);
22
+ const res = await api.get(`/territories/${territoryId}/kpi-history`);
23
+ if (mountedRef.current) {
24
+ setData(res.data);
25
+ setError(null);
26
+ }
27
+ }
28
+ catch (err) {
29
+ if (mountedRef.current)
30
+ setError(err instanceof Error ? err : new Error(String(err)));
31
+ }
32
+ finally {
33
+ if (mountedRef.current)
34
+ setLoading(false);
35
+ }
36
+ }, [client, isAuthenticated, territoryId]);
37
+ (0, react_1.useEffect)(() => {
38
+ mountedRef.current = true;
39
+ fetchData();
40
+ return () => { mountedRef.current = false; };
41
+ }, [fetchData]);
42
+ return { data, loading, error, refresh: fetchData };
43
+ }
@@ -0,0 +1,6 @@
1
+ import type { TerritoryMember } from '@microcosmmoney/auth-core';
2
+ export declare function useTerritoryMembers(id?: string, options?: {
3
+ page?: number;
4
+ pageSize?: number;
5
+ refetchInterval?: number;
6
+ }): import("./use-api-query").UseApiQueryResult<TerritoryMember[]>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryMembers = useTerritoryMembers;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTerritoryMembers(id, options) {
7
+ const page = options?.page ?? 1;
8
+ const pageSize = options?.pageSize ?? 20;
9
+ return (0, use_api_query_1.useApiQuery)({
10
+ path: `/territories/${id}/members?page=${page}&page_size=${pageSize}`,
11
+ requireAuth: true,
12
+ skip: !id,
13
+ refetchInterval: options?.refetchInterval ?? 0,
14
+ });
15
+ }
@@ -0,0 +1,9 @@
1
+ export declare function useTerritoryRanking(territoryId?: string, params?: {
2
+ page?: number;
3
+ page_size?: number;
4
+ }): {
5
+ data: any;
6
+ loading: boolean;
7
+ error: Error | null;
8
+ refresh: () => Promise<void>;
9
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryRanking = useTerritoryRanking;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useTerritoryRanking(territoryId, params) {
8
+ const { client, isAuthenticated } = (0, provider_1.useAuth)();
9
+ const [data, setData] = (0, react_1.useState)(null);
10
+ const [loading, setLoading] = (0, react_1.useState)(true);
11
+ const [error, setError] = (0, react_1.useState)(null);
12
+ const mountedRef = (0, react_1.useRef)(true);
13
+ const p = params || {};
14
+ const page = p.page || 1;
15
+ const pageSize = p.page_size || 20;
16
+ const fetchData = (0, react_1.useCallback)(async () => {
17
+ if (!isAuthenticated || !territoryId) {
18
+ setData(null);
19
+ setLoading(false);
20
+ return;
21
+ }
22
+ const api = client.getApiClient();
23
+ try {
24
+ setLoading(true);
25
+ const res = await api.get(`/territories/${territoryId}/member-ranking?page=${page}&page_size=${pageSize}`);
26
+ if (mountedRef.current) {
27
+ setData(res.data);
28
+ setError(null);
29
+ }
30
+ }
31
+ catch (err) {
32
+ if (mountedRef.current)
33
+ setError(err instanceof Error ? err : new Error(String(err)));
34
+ }
35
+ finally {
36
+ if (mountedRef.current)
37
+ setLoading(false);
38
+ }
39
+ }, [client, isAuthenticated, territoryId, page, pageSize]);
40
+ (0, react_1.useEffect)(() => {
41
+ mountedRef.current = true;
42
+ fetchData();
43
+ return () => { mountedRef.current = false; };
44
+ }, [fetchData]);
45
+ return { data, loading, error, refresh: fetchData };
46
+ }
@@ -0,0 +1,4 @@
1
+ import type { TerritoryStats } from '@microcosmmoney/auth-core';
2
+ export declare function useTerritoryStats(id?: string, options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<TerritoryStats>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryStats = useTerritoryStats;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTerritoryStats(id, options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: `/territories/${id}/stats`,
9
+ requireAuth: true,
10
+ skip: !id,
11
+ refetchInterval: options?.refetchInterval ?? 0,
12
+ });
13
+ }
@@ -0,0 +1,4 @@
1
+ import type { TerritorySummary } from '@microcosmmoney/auth-core';
2
+ export declare function useTerritorySummary(options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<TerritorySummary>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritorySummary = useTerritorySummary;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTerritorySummary(options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: '/territories/summary',
9
+ requireAuth: true,
10
+ refetchInterval: options?.refetchInterval ?? 0,
11
+ });
12
+ }
@@ -0,0 +1,12 @@
1
+ interface TerritoryUpdateData {
2
+ unit_name?: string;
3
+ description?: string;
4
+ image_url?: string;
5
+ }
6
+ export declare function useTerritoryUpdate(): {
7
+ update: (territoryId: string, data: TerritoryUpdateData) => Promise<any>;
8
+ updateName: (territoryId: string, name: string, force?: boolean) => Promise<any>;
9
+ loading: boolean;
10
+ error: Error | null;
11
+ };
12
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTerritoryUpdate = useTerritoryUpdate;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useTerritoryUpdate() {
8
+ const { client, isAuthenticated } = (0, provider_1.useAuth)();
9
+ const [loading, setLoading] = (0, react_1.useState)(false);
10
+ const [error, setError] = (0, react_1.useState)(null);
11
+ const mountedRef = (0, react_1.useRef)(true);
12
+ const update = (0, react_1.useCallback)(async (territoryId, data) => {
13
+ if (!isAuthenticated)
14
+ throw new Error('Authentication required');
15
+ const api = client.getApiClient();
16
+ try {
17
+ setLoading(true);
18
+ setError(null);
19
+ const res = await api.put(`/territories/${territoryId}`, data);
20
+ return res.data;
21
+ }
22
+ catch (err) {
23
+ const e = err instanceof Error ? err : new Error(String(err));
24
+ if (mountedRef.current)
25
+ setError(e);
26
+ throw e;
27
+ }
28
+ finally {
29
+ if (mountedRef.current)
30
+ setLoading(false);
31
+ }
32
+ }, [client, isAuthenticated]);
33
+ const updateName = (0, react_1.useCallback)(async (territoryId, name, force = false) => {
34
+ if (!isAuthenticated)
35
+ throw new Error('Authentication required');
36
+ const api = client.getApiClient();
37
+ try {
38
+ setLoading(true);
39
+ setError(null);
40
+ const qs = force ? '?force=true' : '';
41
+ const res = await api.put(`/territories/${territoryId}/name${qs}`, { name });
42
+ return res.data;
43
+ }
44
+ catch (err) {
45
+ const e = err instanceof Error ? err : new Error(String(err));
46
+ if (mountedRef.current)
47
+ setError(e);
48
+ throw e;
49
+ }
50
+ finally {
51
+ if (mountedRef.current)
52
+ setLoading(false);
53
+ }
54
+ }, [client, isAuthenticated]);
55
+ return { update, updateName, loading, error };
56
+ }
@@ -0,0 +1,4 @@
1
+ import type { TokenPortfolio } from '@microcosmmoney/auth-core';
2
+ export declare function useTokenPortfolio(address?: string, options?: {
3
+ refetchInterval?: number;
4
+ }): import("./use-api-query").UseApiQueryResult<TokenPortfolio>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTokenPortfolio = useTokenPortfolio;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useTokenPortfolio(address, options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: `/wallets/${address}/tokens`,
9
+ skip: !address,
10
+ refetchInterval: options?.refetchInterval ?? 0,
11
+ });
12
+ }
@@ -0,0 +1,3 @@
1
+ export declare function useUserStats(options?: {
2
+ refetchInterval?: number;
3
+ }): import("./use-api-query").UseApiQueryResult<any>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useUserStats = useUserStats;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useUserStats(options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: '/dashboard/stats/users',
9
+ refetchInterval: options?.refetchInterval ?? 300000,
10
+ });
11
+ }
@@ -0,0 +1,14 @@
1
+ interface CreateProposalParams {
2
+ title: string;
3
+ description: string;
4
+ proposal_type?: string;
5
+ voting_hours?: number;
6
+ options: string[];
7
+ }
8
+ export declare function useVoteAction(): {
9
+ createProposal: (params: CreateProposalParams) => Promise<any>;
10
+ castVote: (proposalId: string, optionIndex: number, voteCount?: number) => Promise<any>;
11
+ loading: boolean;
12
+ error: Error | null;
13
+ };
14
+ export {};