@microcosmmoney/auth-react 1.0.3 → 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 (35) 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-history.d.ts +9 -0
  6. package/dist/hooks/use-auction-history.js +41 -0
  7. package/dist/hooks/use-buyback-action.d.ts +6 -0
  8. package/dist/hooks/use-buyback-action.js +34 -0
  9. package/dist/hooks/use-cycle-history.d.ts +13 -0
  10. package/dist/hooks/use-cycle-history.js +41 -0
  11. package/dist/hooks/use-mcc-history.d.ts +18 -0
  12. package/dist/hooks/use-mcc-history.js +50 -0
  13. package/dist/hooks/use-mining-action.d.ts +20 -0
  14. package/dist/hooks/use-mining-action.js +55 -0
  15. package/dist/hooks/use-mining-config.d.ts +7 -0
  16. package/dist/hooks/use-mining-config.js +38 -0
  17. package/dist/hooks/use-mining-history.d.ts +9 -0
  18. package/dist/hooks/use-mining-history.js +46 -0
  19. package/dist/hooks/use-public-mining.d.ts +12 -0
  20. package/dist/hooks/use-public-mining.js +54 -0
  21. package/dist/hooks/use-reincarnation-config.d.ts +7 -0
  22. package/dist/hooks/use-reincarnation-config.js +38 -0
  23. package/dist/hooks/use-territory-income.d.ts +6 -0
  24. package/dist/hooks/use-territory-income.js +43 -0
  25. package/dist/hooks/use-territory-kpi.d.ts +6 -0
  26. package/dist/hooks/use-territory-kpi.js +43 -0
  27. package/dist/hooks/use-territory-ranking.d.ts +9 -0
  28. package/dist/hooks/use-territory-ranking.js +46 -0
  29. package/dist/hooks/use-territory-update.d.ts +12 -0
  30. package/dist/hooks/use-territory-update.js +56 -0
  31. package/dist/hooks/use-vote-action.d.ts +14 -0
  32. package/dist/hooks/use-vote-action.js +58 -0
  33. package/dist/index.d.ts +17 -1
  34. package/dist/index.js +34 -1
  35. package/package.json +2 -2
@@ -0,0 +1,5 @@
1
+ export declare function useAuctionBid(): {
2
+ placeBid: (auctionId: number, bidAmount: number) => Promise<any>;
3
+ loading: boolean;
4
+ error: Error | null;
5
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuctionBid = useAuctionBid;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useAuctionBid() {
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 placeBid = (0, react_1.useCallback)(async (auctionId, bidAmount) => {
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.post(`/auction-solana/auction/${auctionId}/bid`, { bid_amount: bidAmount });
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
+ return { placeBid, loading, error };
34
+ }
@@ -0,0 +1,5 @@
1
+ export declare function useAuctionCancel(): {
2
+ prepareCancelBid: (auctionId: number) => Promise<any>;
3
+ loading: boolean;
4
+ error: Error | null;
5
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuctionCancel = useAuctionCancel;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useAuctionCancel() {
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 prepareCancelBid = (0, react_1.useCallback)(async (auctionId) => {
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.post('/auction-solana/bid/cancel/prepare', { auction_id: auctionId });
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
+ return { prepareCancelBid, loading, error };
34
+ }
@@ -0,0 +1,9 @@
1
+ export declare function useAuctionHistory(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,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAuctionHistory = useAuctionHistory;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useAuctionHistory(params) {
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 p = params || {};
14
+ const page = p.page || 1;
15
+ const pageSize = p.page_size || 20;
16
+ const fetchData = (0, react_1.useCallback)(async () => {
17
+ const api = client.getApiClient();
18
+ try {
19
+ setLoading(true);
20
+ const res = await api.get(`/auction-solana/history?page=${page}&page_size=${pageSize}`);
21
+ if (mountedRef.current) {
22
+ setData(res.data);
23
+ setError(null);
24
+ }
25
+ }
26
+ catch (err) {
27
+ if (mountedRef.current)
28
+ setError(err instanceof Error ? err : new Error(String(err)));
29
+ }
30
+ finally {
31
+ if (mountedRef.current)
32
+ setLoading(false);
33
+ }
34
+ }, [client, page, pageSize]);
35
+ (0, react_1.useEffect)(() => {
36
+ mountedRef.current = true;
37
+ fetchData();
38
+ return () => { mountedRef.current = false; };
39
+ }, [fetchData]);
40
+ return { data, loading, error, refresh: fetchData };
41
+ }
@@ -0,0 +1,6 @@
1
+ import type { BuybackRecordInput } from '@microcosmmoney/auth-core';
2
+ export declare function useBuybackAction(): {
3
+ record: (params: BuybackRecordInput) => Promise<any>;
4
+ loading: boolean;
5
+ error: Error | null;
6
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBuybackAction = useBuybackAction;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useBuybackAction() {
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 record = (0, react_1.useCallback)(async (params) => {
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.post('/reincarnation/record', params);
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
+ return { record, loading, error };
34
+ }
@@ -0,0 +1,13 @@
1
+ import type { CycleHistory } from '@microcosmmoney/auth-core';
2
+ export declare function useCycleHistory(params?: {
3
+ page?: number;
4
+ page_size?: number;
5
+ }): {
6
+ data: {
7
+ records: CycleHistory[];
8
+ total: number;
9
+ } | null;
10
+ loading: boolean;
11
+ error: Error | null;
12
+ refresh: () => Promise<void>;
13
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCycleHistory = useCycleHistory;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useCycleHistory(params) {
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 p = params || {};
14
+ const page = p.page || 1;
15
+ const pageSize = p.page_size || 20;
16
+ const fetchData = (0, react_1.useCallback)(async () => {
17
+ const api = client.getApiClient();
18
+ try {
19
+ setLoading(true);
20
+ const res = await api.get(`/reincarnation/cycle-history?page=${page}&page_size=${pageSize}`);
21
+ if (mountedRef.current) {
22
+ setData(res.data);
23
+ setError(null);
24
+ }
25
+ }
26
+ catch (err) {
27
+ if (mountedRef.current)
28
+ setError(err instanceof Error ? err : new Error(String(err)));
29
+ }
30
+ finally {
31
+ if (mountedRef.current)
32
+ setLoading(false);
33
+ }
34
+ }, [client, page, pageSize]);
35
+ (0, react_1.useEffect)(() => {
36
+ mountedRef.current = true;
37
+ fetchData();
38
+ return () => { mountedRef.current = false; };
39
+ }, [fetchData]);
40
+ return { data, loading, error, refresh: fetchData };
41
+ }
@@ -0,0 +1,18 @@
1
+ import type { MCCHistoryRecord } from '@microcosmmoney/auth-core';
2
+ interface PaginatedResult {
3
+ records: MCCHistoryRecord[];
4
+ total: number;
5
+ page: number;
6
+ page_size: number;
7
+ }
8
+ export declare function useMCCHistory(params?: {
9
+ tx_type?: string;
10
+ page?: number;
11
+ page_size?: number;
12
+ }): {
13
+ data: PaginatedResult | null;
14
+ loading: boolean;
15
+ error: Error | null;
16
+ refresh: () => Promise<void>;
17
+ };
18
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMCCHistory = useMCCHistory;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useMCCHistory(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 txType = p.tx_type;
17
+ const fetchData = (0, react_1.useCallback)(async () => {
18
+ if (!isAuthenticated) {
19
+ setData(null);
20
+ setLoading(false);
21
+ return;
22
+ }
23
+ const api = client.getApiClient();
24
+ try {
25
+ setLoading(true);
26
+ let qs = `?page=${page}&page_size=${pageSize}`;
27
+ if (txType)
28
+ qs += `&tx_type=${txType}`;
29
+ const res = await api.get(`/mcc/history${qs}`);
30
+ if (mountedRef.current) {
31
+ setData(res.data);
32
+ setError(null);
33
+ }
34
+ }
35
+ catch (err) {
36
+ if (mountedRef.current)
37
+ setError(err instanceof Error ? err : new Error(String(err)));
38
+ }
39
+ finally {
40
+ if (mountedRef.current)
41
+ setLoading(false);
42
+ }
43
+ }, [client, isAuthenticated, page, pageSize, txType]);
44
+ (0, react_1.useEffect)(() => {
45
+ mountedRef.current = true;
46
+ fetchData();
47
+ return () => { mountedRef.current = false; };
48
+ }, [fetchData]);
49
+ return { data, loading, error, refresh: fetchData };
50
+ }
@@ -0,0 +1,20 @@
1
+ import type { MiningRequestResult } from '@microcosmmoney/auth-core';
2
+ interface MiningRequestParams {
3
+ mcc_amount: number;
4
+ stablecoin?: string;
5
+ wallet_address: string;
6
+ }
7
+ interface MiningConfirmParams {
8
+ request_id: string;
9
+ tx_signature: string;
10
+ mcc_amount: number;
11
+ usdc_amount: number;
12
+ stablecoin_type?: string;
13
+ }
14
+ export declare function useMiningAction(): {
15
+ createRequest: (params: MiningRequestParams) => Promise<MiningRequestResult | null>;
16
+ confirm: (params: MiningConfirmParams) => Promise<any>;
17
+ loading: boolean;
18
+ error: Error | null;
19
+ };
20
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMiningAction = useMiningAction;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useMiningAction() {
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 createRequest = (0, react_1.useCallback)(async (params) => {
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.post('/mining/request', params);
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 confirm = (0, react_1.useCallback)(async (params) => {
34
+ if (!isAuthenticated)
35
+ throw new Error('Authentication required');
36
+ const api = client.getApiClient();
37
+ try {
38
+ setLoading(true);
39
+ setError(null);
40
+ const res = await api.post('/mining/confirm', params);
41
+ return res.data;
42
+ }
43
+ catch (err) {
44
+ const e = err instanceof Error ? err : new Error(String(err));
45
+ if (mountedRef.current)
46
+ setError(e);
47
+ throw e;
48
+ }
49
+ finally {
50
+ if (mountedRef.current)
51
+ setLoading(false);
52
+ }
53
+ }, [client, isAuthenticated]);
54
+ return { createRequest, confirm, loading, error };
55
+ }
@@ -0,0 +1,7 @@
1
+ import type { MiningConfig } from '@microcosmmoney/auth-core';
2
+ export declare function useMiningConfig(): {
3
+ data: MiningConfig | 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.useMiningConfig = useMiningConfig;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useMiningConfig() {
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('/mining/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,9 @@
1
+ export declare function useMiningHistory(params?: {
2
+ limit?: number;
3
+ offset?: 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.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,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,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,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,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,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 {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVoteAction = useVoteAction;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const react_1 = require("react");
6
+ const provider_1 = require("../provider");
7
+ function useVoteAction() {
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 createProposal = (0, react_1.useCallback)(async (params) => {
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.post('/voting/proposals', params);
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 castVote = (0, react_1.useCallback)(async (proposalId, optionIndex, voteCount) => {
34
+ if (!isAuthenticated)
35
+ throw new Error('Authentication required');
36
+ const api = client.getApiClient();
37
+ try {
38
+ setLoading(true);
39
+ setError(null);
40
+ const body = { option_index: optionIndex };
41
+ if (voteCount !== undefined)
42
+ body.vote_count = voteCount;
43
+ const res = await api.post(`/voting/proposals/${proposalId}/vote`, body);
44
+ return res.data;
45
+ }
46
+ catch (err) {
47
+ const e = err instanceof Error ? err : new Error(String(err));
48
+ if (mountedRef.current)
49
+ setError(e);
50
+ throw e;
51
+ }
52
+ finally {
53
+ if (mountedRef.current)
54
+ setLoading(false);
55
+ }
56
+ }, [client, isAuthenticated]);
57
+ return { createProposal, castVote, loading, error };
58
+ }
package/dist/index.d.ts CHANGED
@@ -39,4 +39,20 @@ export { useVotePower } from './hooks/use-vote-power';
39
39
  export { useMyBids } from './hooks/use-my-bids';
40
40
  export { useAuctionDetail } from './hooks/use-auction-detail';
41
41
  export { useUserStats } from './hooks/use-user-stats';
42
- export type { MicrocosmAuthConfig, MicrocosmAPIConfig, User, AuthState, LoginOptions, MCDBalance, MCCBalance, MCCPrice, Wallet, TokenPortfolio, MCCLock, MiningRatio, MiningDistribution, BuybackQuote, BuybackRecord, Territory, TerritorySummary, TerritoryStats, TerritoryMember, Proposal, ProposalDetail, VoteResult, VotePower, AuctionBid, MCDTransaction, MCDReward, } from '@microcosmmoney/auth-core';
42
+ export { useMiningAction } from './hooks/use-mining-action';
43
+ export { usePublicMining } from './hooks/use-public-mining';
44
+ export { useBuybackAction } from './hooks/use-buyback-action';
45
+ export { useTerritoryUpdate } from './hooks/use-territory-update';
46
+ export { useAuctionCancel } from './hooks/use-auction-cancel';
47
+ export { useAuctionBid } from './hooks/use-auction-bid';
48
+ export { useAuctionHistory } from './hooks/use-auction-history';
49
+ export { useVoteAction } from './hooks/use-vote-action';
50
+ export { useMCCHistory } from './hooks/use-mcc-history';
51
+ export { useMiningConfig } from './hooks/use-mining-config';
52
+ export { useMiningHistory } from './hooks/use-mining-history';
53
+ export { useReincarnationConfig } from './hooks/use-reincarnation-config';
54
+ export { useCycleHistory } from './hooks/use-cycle-history';
55
+ export { useTerritoryIncome } from './hooks/use-territory-income';
56
+ export { useTerritoryKPI } from './hooks/use-territory-kpi';
57
+ export { useTerritoryRanking } from './hooks/use-territory-ranking';
58
+ export type { MicrocosmAuthConfig, MicrocosmAPIConfig, User, AuthState, LoginOptions, MCDBalance, MCCBalance, MCCPrice, Wallet, TokenPortfolio, MCCLock, MiningRatio, MiningDistribution, BuybackQuote, BuybackRecord, Territory, TerritorySummary, TerritoryStats, TerritoryMember, Proposal, ProposalDetail, VoteResult, VotePower, AuctionBid, MCDTransaction, MCDReward, MiningRequest, MiningConfirmData, MiningRequestResult, MiningConfig, BuybackRecordInput, ReincarnationConfig, MCCHistoryRecord, CycleHistory, AuctionHistory, } from '@microcosmmoney/auth-core';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUserStats = exports.useAuctionDetail = exports.useMyBids = exports.useVotePower = exports.useProposalDetail = exports.useProposals = exports.useTerritoryMembers = exports.useTerritoryStats = exports.useTerritoryDetail = exports.useTerritorySummary = exports.useTerritories = exports.useBuybackHistory = exports.useBuybackQuote = exports.useMCDRewards = exports.useMCDTransactions = exports.useMiningDistribution = exports.useMiningRatio = exports.useMCCLocks = exports.useTokenPortfolio = exports.useWallets = exports.useDashboardSummary = exports.usePriceHistory = exports.useTechTree = exports.useOrganizations = exports.useAuctions = exports.useTerritoryNFTs = exports.useReincarnationPool = exports.useUserLevel = exports.useMiningRecords = exports.useMiningStats = exports.useMCDStats = exports.useMCCStats = exports.useMCCPrice = exports.useApiQuery = exports.useProfile = exports.useMCC = exports.useMCD = exports.RequireRole = exports.withAuth = exports.AuthCallback = exports.useAuth = exports.MicrocosmAuthProvider = void 0;
3
+ exports.useVoteAction = exports.useAuctionHistory = exports.useAuctionBid = exports.useAuctionCancel = exports.useTerritoryUpdate = exports.useBuybackAction = exports.usePublicMining = exports.useMiningAction = exports.useUserStats = exports.useAuctionDetail = exports.useMyBids = exports.useVotePower = exports.useProposalDetail = exports.useProposals = exports.useTerritoryMembers = exports.useTerritoryStats = exports.useTerritoryDetail = exports.useTerritorySummary = exports.useTerritories = exports.useBuybackHistory = exports.useBuybackQuote = exports.useMCDRewards = exports.useMCDTransactions = exports.useMiningDistribution = exports.useMiningRatio = exports.useMCCLocks = exports.useTokenPortfolio = exports.useWallets = exports.useDashboardSummary = exports.usePriceHistory = exports.useTechTree = exports.useOrganizations = exports.useAuctions = exports.useTerritoryNFTs = exports.useReincarnationPool = exports.useUserLevel = exports.useMiningRecords = exports.useMiningStats = exports.useMCDStats = exports.useMCCStats = exports.useMCCPrice = exports.useApiQuery = exports.useProfile = exports.useMCC = exports.useMCD = exports.RequireRole = exports.withAuth = exports.AuthCallback = exports.useAuth = exports.MicrocosmAuthProvider = void 0;
4
+ exports.useTerritoryRanking = exports.useTerritoryKPI = exports.useTerritoryIncome = exports.useCycleHistory = exports.useReincarnationConfig = exports.useMiningHistory = exports.useMiningConfig = exports.useMCCHistory = void 0;
4
5
  // AI-generated · AI-managed · AI-maintained
5
6
  var provider_1 = require("./provider");
6
7
  Object.defineProperty(exports, "MicrocosmAuthProvider", { enumerable: true, get: function () { return provider_1.MicrocosmAuthProvider; } });
@@ -85,3 +86,35 @@ var use_auction_detail_1 = require("./hooks/use-auction-detail");
85
86
  Object.defineProperty(exports, "useAuctionDetail", { enumerable: true, get: function () { return use_auction_detail_1.useAuctionDetail; } });
86
87
  var use_user_stats_1 = require("./hooks/use-user-stats");
87
88
  Object.defineProperty(exports, "useUserStats", { enumerable: true, get: function () { return use_user_stats_1.useUserStats; } });
89
+ var use_mining_action_1 = require("./hooks/use-mining-action");
90
+ Object.defineProperty(exports, "useMiningAction", { enumerable: true, get: function () { return use_mining_action_1.useMiningAction; } });
91
+ var use_public_mining_1 = require("./hooks/use-public-mining");
92
+ Object.defineProperty(exports, "usePublicMining", { enumerable: true, get: function () { return use_public_mining_1.usePublicMining; } });
93
+ var use_buyback_action_1 = require("./hooks/use-buyback-action");
94
+ Object.defineProperty(exports, "useBuybackAction", { enumerable: true, get: function () { return use_buyback_action_1.useBuybackAction; } });
95
+ var use_territory_update_1 = require("./hooks/use-territory-update");
96
+ Object.defineProperty(exports, "useTerritoryUpdate", { enumerable: true, get: function () { return use_territory_update_1.useTerritoryUpdate; } });
97
+ var use_auction_cancel_1 = require("./hooks/use-auction-cancel");
98
+ Object.defineProperty(exports, "useAuctionCancel", { enumerable: true, get: function () { return use_auction_cancel_1.useAuctionCancel; } });
99
+ var use_auction_bid_1 = require("./hooks/use-auction-bid");
100
+ Object.defineProperty(exports, "useAuctionBid", { enumerable: true, get: function () { return use_auction_bid_1.useAuctionBid; } });
101
+ var use_auction_history_1 = require("./hooks/use-auction-history");
102
+ Object.defineProperty(exports, "useAuctionHistory", { enumerable: true, get: function () { return use_auction_history_1.useAuctionHistory; } });
103
+ var use_vote_action_1 = require("./hooks/use-vote-action");
104
+ Object.defineProperty(exports, "useVoteAction", { enumerable: true, get: function () { return use_vote_action_1.useVoteAction; } });
105
+ var use_mcc_history_1 = require("./hooks/use-mcc-history");
106
+ Object.defineProperty(exports, "useMCCHistory", { enumerable: true, get: function () { return use_mcc_history_1.useMCCHistory; } });
107
+ var use_mining_config_1 = require("./hooks/use-mining-config");
108
+ Object.defineProperty(exports, "useMiningConfig", { enumerable: true, get: function () { return use_mining_config_1.useMiningConfig; } });
109
+ var use_mining_history_1 = require("./hooks/use-mining-history");
110
+ Object.defineProperty(exports, "useMiningHistory", { enumerable: true, get: function () { return use_mining_history_1.useMiningHistory; } });
111
+ var use_reincarnation_config_1 = require("./hooks/use-reincarnation-config");
112
+ Object.defineProperty(exports, "useReincarnationConfig", { enumerable: true, get: function () { return use_reincarnation_config_1.useReincarnationConfig; } });
113
+ var use_cycle_history_1 = require("./hooks/use-cycle-history");
114
+ Object.defineProperty(exports, "useCycleHistory", { enumerable: true, get: function () { return use_cycle_history_1.useCycleHistory; } });
115
+ var use_territory_income_1 = require("./hooks/use-territory-income");
116
+ Object.defineProperty(exports, "useTerritoryIncome", { enumerable: true, get: function () { return use_territory_income_1.useTerritoryIncome; } });
117
+ var use_territory_kpi_1 = require("./hooks/use-territory-kpi");
118
+ Object.defineProperty(exports, "useTerritoryKPI", { enumerable: true, get: function () { return use_territory_kpi_1.useTerritoryKPI; } });
119
+ var use_territory_ranking_1 = require("./hooks/use-territory-ranking");
120
+ Object.defineProperty(exports, "useTerritoryRanking", { enumerable: true, get: function () { return use_territory_ranking_1.useTerritoryRanking; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microcosmmoney/auth-react",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
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.0.2"
27
+ "@microcosmmoney/auth-core": "^1.0.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/react": "^18.0.0",