@microcosmmoney/auth-react 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-auction-bid.d.ts +5 -0
- package/dist/hooks/use-auction-bid.js +34 -0
- package/dist/hooks/use-auction-bids.d.ts +4 -0
- package/dist/hooks/use-auction-bids.js +12 -0
- package/dist/hooks/use-auction-cancel.d.ts +5 -0
- package/dist/hooks/use-auction-cancel.js +34 -0
- package/dist/hooks/use-auction-config.d.ts +3 -0
- package/dist/hooks/use-auction-config.js +11 -0
- package/dist/hooks/use-auction-detail.d.ts +2 -1
- package/dist/hooks/use-auction-end.d.ts +5 -0
- package/dist/hooks/use-auction-end.js +32 -0
- package/dist/hooks/use-auction-history.d.ts +9 -0
- package/dist/hooks/use-auction-history.js +41 -0
- package/dist/hooks/use-auction-refund.d.ts +5 -0
- package/dist/hooks/use-auction-refund.js +32 -0
- package/dist/hooks/use-auctions.d.ts +10 -2
- package/dist/hooks/use-auctions.js +14 -1
- package/dist/hooks/use-buyback-action.d.ts +6 -0
- package/dist/hooks/use-buyback-action.js +34 -0
- package/dist/hooks/use-buyback-flow.d.ts +22 -0
- package/dist/hooks/use-buyback-flow.js +46 -0
- package/dist/hooks/use-create-auction.d.ts +6 -0
- package/dist/hooks/use-create-auction.js +32 -0
- package/dist/hooks/use-cycle-history.d.ts +13 -0
- package/dist/hooks/use-cycle-history.js +41 -0
- package/dist/hooks/use-dashboard-mining-history.d.ts +3 -0
- package/dist/hooks/use-dashboard-mining-history.js +11 -0
- package/dist/hooks/use-dashboard-summary.d.ts +4 -14
- package/dist/hooks/use-dashboard-territory-stats.d.ts +3 -0
- package/dist/hooks/use-dashboard-territory-stats.js +11 -0
- package/dist/hooks/use-dashboard-user-stats.d.ts +4 -0
- package/dist/hooks/use-dashboard-user-stats.js +11 -0
- package/dist/hooks/use-fragment-config.d.ts +3 -0
- package/dist/hooks/use-fragment-config.js +11 -0
- package/dist/hooks/use-fragment-vault-detail.d.ts +3 -0
- package/dist/hooks/use-fragment-vault-detail.js +12 -0
- package/dist/hooks/use-fragment-vaults.d.ts +3 -0
- package/dist/hooks/use-fragment-vaults.js +11 -0
- package/dist/hooks/use-lending-pool.d.ts +3 -0
- package/dist/hooks/use-lending-pool.js +11 -0
- package/dist/hooks/use-lending-position.d.ts +3 -0
- package/dist/hooks/use-lending-position.js +13 -0
- package/dist/hooks/use-lending-stats.d.ts +3 -0
- package/dist/hooks/use-lending-stats.js +11 -0
- package/dist/hooks/use-manager-income.d.ts +9 -0
- package/dist/hooks/use-manager-income.js +11 -0
- package/dist/hooks/use-market-data.d.ts +4 -0
- package/dist/hooks/use-market-data.js +11 -0
- package/dist/hooks/use-mcc-history.d.ts +11 -0
- package/dist/hooks/use-mcc-history.js +50 -0
- package/dist/hooks/use-mcc-holders.d.ts +3 -0
- package/dist/hooks/use-mcc-holders.js +11 -0
- package/dist/hooks/use-mcc-mining-history.d.ts +3 -0
- package/dist/hooks/use-mcc-mining-history.js +11 -0
- package/dist/hooks/use-mcc-stats.d.ts +2 -1
- package/dist/hooks/use-mcd.js +1 -1
- package/dist/hooks/use-mining-action.d.ts +20 -0
- package/dist/hooks/use-mining-action.js +55 -0
- package/dist/hooks/use-mining-config.d.ts +7 -0
- package/dist/hooks/use-mining-config.js +38 -0
- package/dist/hooks/use-mining-distribution.d.ts +2 -2
- package/dist/hooks/use-mining-flow.d.ts +22 -0
- package/dist/hooks/use-mining-flow.js +46 -0
- package/dist/hooks/use-mining-history.d.ts +10 -0
- package/dist/hooks/use-mining-history.js +46 -0
- package/dist/hooks/use-mining-records.d.ts +2 -1
- package/dist/hooks/use-mining-stats.d.ts +2 -1
- package/dist/hooks/use-multi-wallet-balance.d.ts +15 -0
- package/dist/hooks/use-multi-wallet-balance.js +53 -0
- package/dist/hooks/use-notification-action.d.ts +10 -0
- package/dist/hooks/use-notification-action.js +49 -0
- package/dist/hooks/use-notifications.d.ts +13 -0
- package/dist/hooks/use-notifications.js +15 -0
- package/dist/hooks/use-organization-summary.d.ts +12 -0
- package/dist/hooks/use-organization-summary.js +12 -0
- package/dist/hooks/use-organization-tree.d.ts +4 -0
- package/dist/hooks/use-organization-tree.js +13 -0
- package/dist/hooks/use-organizations.d.ts +2 -1
- package/dist/hooks/use-platform-stats.d.ts +3 -0
- package/dist/hooks/use-platform-stats.js +11 -0
- package/dist/hooks/use-price-history.d.ts +2 -1
- package/dist/hooks/use-proposal-settle.d.ts +5 -0
- package/dist/hooks/use-proposal-settle.js +32 -0
- package/dist/hooks/use-public-mining.d.ts +12 -0
- package/dist/hooks/use-public-mining.js +54 -0
- package/dist/hooks/use-reincarnation-config.d.ts +7 -0
- package/dist/hooks/use-reincarnation-config.js +38 -0
- package/dist/hooks/use-solana-wallet.d.ts +16 -0
- package/dist/hooks/use-solana-wallet.js +56 -0
- package/dist/hooks/use-station-join.d.ts +5 -0
- package/dist/hooks/use-station-join.js +32 -0
- package/dist/hooks/use-station-leave.d.ts +5 -0
- package/dist/hooks/use-station-leave.js +32 -0
- package/dist/hooks/use-station-queue.d.ts +3 -0
- package/dist/hooks/use-station-queue.js +12 -0
- package/dist/hooks/use-team-custody.d.ts +18 -0
- package/dist/hooks/use-team-custody.js +11 -0
- package/dist/hooks/use-tech-tree-action.d.ts +6 -0
- package/dist/hooks/use-tech-tree-action.js +51 -0
- package/dist/hooks/use-tech-tree-bonus.d.ts +4 -0
- package/dist/hooks/use-tech-tree-bonus.js +12 -0
- package/dist/hooks/use-tech-tree-config.d.ts +4 -0
- package/dist/hooks/use-tech-tree-config.js +11 -0
- package/dist/hooks/use-tech-tree.d.ts +2 -1
- package/dist/hooks/use-territory-detailed-stats.d.ts +9 -0
- package/dist/hooks/use-territory-detailed-stats.js +12 -0
- package/dist/hooks/use-territory-distribution-plan.d.ts +16 -0
- package/dist/hooks/use-territory-distribution-plan.js +41 -0
- package/dist/hooks/use-territory-income.d.ts +6 -0
- package/dist/hooks/use-territory-income.js +43 -0
- package/dist/hooks/use-territory-kpi.d.ts +6 -0
- package/dist/hooks/use-territory-kpi.js +43 -0
- package/dist/hooks/use-territory-name-status.d.ts +10 -0
- package/dist/hooks/use-territory-name-status.js +13 -0
- package/dist/hooks/use-territory-nft-action.d.ts +15 -0
- package/dist/hooks/use-territory-nft-action.js +51 -0
- package/dist/hooks/use-territory-nft-collection.d.ts +3 -0
- package/dist/hooks/use-territory-nft-collection.js +11 -0
- package/dist/hooks/use-territory-nft-mint.d.ts +12 -0
- package/dist/hooks/use-territory-nft-mint.js +32 -0
- package/dist/hooks/use-territory-ranking.d.ts +9 -0
- package/dist/hooks/use-territory-ranking.js +46 -0
- package/dist/hooks/use-territory-update.d.ts +12 -0
- package/dist/hooks/use-territory-update.js +56 -0
- package/dist/hooks/use-user-level.d.ts +2 -8
- package/dist/hooks/use-user-stats.d.ts +2 -1
- package/dist/hooks/use-vote-action.d.ts +14 -0
- package/dist/hooks/use-vote-action.js +58 -0
- package/dist/index.d.ts +59 -1
- package/dist/index.js +116 -1
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface OrganizationSummary {
|
|
2
|
+
total_stations: number;
|
|
3
|
+
total_matrices: number;
|
|
4
|
+
total_sectors: number;
|
|
5
|
+
total_systems: number;
|
|
6
|
+
total_members: number;
|
|
7
|
+
total_vault_mcd: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function useOrganizationSummary(options?: {
|
|
10
|
+
refetchInterval?: number;
|
|
11
|
+
}): import("./use-api-query").UseApiQueryResult<OrganizationSummary>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOrganizationSummary = useOrganizationSummary;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useOrganizationSummary(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/organizations/summary',
|
|
9
|
+
requireAuth: true,
|
|
10
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOrganizationTree = useOrganizationTree;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useOrganizationTree(rootId, options) {
|
|
7
|
+
const path = rootId ? `/organizations/tree?root_id=${rootId}` : '/organizations/tree';
|
|
8
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
9
|
+
path,
|
|
10
|
+
requireAuth: true,
|
|
11
|
+
refetchInterval: options?.refetchInterval ?? 120000,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePlatformStats = usePlatformStats;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function usePlatformStats(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/dashboard/platform',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { PriceHistoryPoint } from '@microcosmmoney/auth-core';
|
|
1
2
|
type TimeRange = '1D' | '7D' | '30D';
|
|
2
3
|
export declare function usePriceHistory(range?: TimeRange, options?: {
|
|
3
4
|
refetchInterval?: number;
|
|
4
|
-
}): import("./use-api-query").UseApiQueryResult<
|
|
5
|
+
}): import("./use-api-query").UseApiQueryResult<PriceHistoryPoint[]>;
|
|
5
6
|
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useProposalSettle = useProposalSettle;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useProposalSettle() {
|
|
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 settle = (0, react_1.useCallback)(async (proposalId) => {
|
|
13
|
+
const api = client.getApiClient();
|
|
14
|
+
try {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
const res = await api.post(`/proposals/${proposalId}/settle`, {});
|
|
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
|
+
return { settle, loading, error };
|
|
32
|
+
}
|
|
@@ -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,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,16 @@
|
|
|
1
|
+
export interface SolanaWalletState {
|
|
2
|
+
connected: boolean;
|
|
3
|
+
publicKey: string | null;
|
|
4
|
+
connecting: boolean;
|
|
5
|
+
error: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function useSolanaWallet(): {
|
|
8
|
+
connect: () => Promise<any>;
|
|
9
|
+
disconnect: () => Promise<void>;
|
|
10
|
+
signTransaction: (transaction: any) => Promise<any>;
|
|
11
|
+
signAllTransactions: (transactions: any[]) => Promise<any>;
|
|
12
|
+
connected: boolean;
|
|
13
|
+
publicKey: string | null;
|
|
14
|
+
connecting: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSolanaWallet = useSolanaWallet;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useSolanaWallet() {
|
|
7
|
+
const [state, setState] = (0, react_1.useState)({
|
|
8
|
+
connected: false,
|
|
9
|
+
publicKey: null,
|
|
10
|
+
connecting: false,
|
|
11
|
+
error: null,
|
|
12
|
+
});
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const sol = window.solana;
|
|
15
|
+
if (sol?.isPhantom && sol.isConnected && sol.publicKey) {
|
|
16
|
+
setState({ connected: true, publicKey: sol.publicKey.toString(), connecting: false, error: null });
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
const connect = (0, react_1.useCallback)(async () => {
|
|
20
|
+
const sol = window.solana;
|
|
21
|
+
if (!sol?.isPhantom) {
|
|
22
|
+
setState(s => ({ ...s, error: 'Phantom wallet not found' }));
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
setState(s => ({ ...s, connecting: true, error: null }));
|
|
26
|
+
try {
|
|
27
|
+
const resp = await sol.connect();
|
|
28
|
+
const pk = resp.publicKey.toString();
|
|
29
|
+
setState({ connected: true, publicKey: pk, connecting: false, error: null });
|
|
30
|
+
return pk;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
setState(s => ({ ...s, connecting: false, error: e.message }));
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
const disconnect = (0, react_1.useCallback)(async () => {
|
|
38
|
+
const sol = window.solana;
|
|
39
|
+
if (sol)
|
|
40
|
+
await sol.disconnect();
|
|
41
|
+
setState({ connected: false, publicKey: null, connecting: false, error: null });
|
|
42
|
+
}, []);
|
|
43
|
+
const signTransaction = (0, react_1.useCallback)(async (transaction) => {
|
|
44
|
+
const sol = window.solana;
|
|
45
|
+
if (!sol)
|
|
46
|
+
throw new Error('Wallet not available');
|
|
47
|
+
return sol.signTransaction(transaction);
|
|
48
|
+
}, []);
|
|
49
|
+
const signAllTransactions = (0, react_1.useCallback)(async (transactions) => {
|
|
50
|
+
const sol = window.solana;
|
|
51
|
+
if (!sol)
|
|
52
|
+
throw new Error('Wallet not available');
|
|
53
|
+
return sol.signAllTransactions(transactions);
|
|
54
|
+
}, []);
|
|
55
|
+
return { ...state, connect, disconnect, signTransaction, signAllTransactions };
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStationJoin = useStationJoin;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useStationJoin() {
|
|
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 joinStation = (0, react_1.useCallback)(async (stationId) => {
|
|
13
|
+
const api = client.getApiClient();
|
|
14
|
+
try {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
const res = await api.post(`/territories/${stationId}/join`, {});
|
|
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
|
+
return { joinStation, loading, error };
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStationLeave = useStationLeave;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useStationLeave() {
|
|
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 leaveStation = (0, react_1.useCallback)(async (stationId) => {
|
|
13
|
+
const api = client.getApiClient();
|
|
14
|
+
try {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
const res = await api.post(`/territories/${stationId}/leave`, {});
|
|
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
|
+
return { leaveStation, loading, error };
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStationQueue = useStationQueue;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useStationQueue(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/territories/queue',
|
|
9
|
+
requireAuth: true,
|
|
10
|
+
refetchInterval: options?.refetchInterval ?? 60000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface CustodyWallet {
|
|
2
|
+
wallet_address: string;
|
|
3
|
+
role: string;
|
|
4
|
+
territory_id?: string;
|
|
5
|
+
sol_balance: number;
|
|
6
|
+
mcc_balance: number;
|
|
7
|
+
mcd_balance: number;
|
|
8
|
+
usdt_balance: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TeamCustodyData {
|
|
11
|
+
wallets: CustodyWallet[];
|
|
12
|
+
total_mcc: number;
|
|
13
|
+
total_mcd: number;
|
|
14
|
+
total_usdt: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function useTeamCustody(options?: {
|
|
17
|
+
refetchInterval?: number;
|
|
18
|
+
}): import("./use-api-query").UseApiQueryResult<TeamCustodyData>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTeamCustody = useTeamCustody;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useTeamCustody(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/territories/team/custody',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTechTreeAction = useTechTreeAction;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useTechTreeAction() {
|
|
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 unlock = (0, react_1.useCallback)(async (nodeId) => {
|
|
13
|
+
const api = client.getApiClient();
|
|
14
|
+
try {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
const res = await api.post('/tech-tree/unlock', { node_id: nodeId });
|
|
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 upgrade = (0, react_1.useCallback)(async (nodeId) => {
|
|
32
|
+
const api = client.getApiClient();
|
|
33
|
+
try {
|
|
34
|
+
setLoading(true);
|
|
35
|
+
setError(null);
|
|
36
|
+
const res = await api.post('/tech-tree/upgrade', { node_id: nodeId });
|
|
37
|
+
return res.data;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
41
|
+
if (mountedRef.current)
|
|
42
|
+
setError(e);
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
if (mountedRef.current)
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
}, [client]);
|
|
50
|
+
return { unlock, upgrade, loading, error };
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTechTreeBonus = useTechTreeBonus;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useTechTreeBonus(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/tech-tree/bonus',
|
|
9
|
+
requireAuth: true,
|
|
10
|
+
refetchInterval: options?.refetchInterval ?? 120000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTechTreeConfig = useTechTreeConfig;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useTechTreeConfig(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/tech-tree/config',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TerritoryStats, TerritoryKPI, TechTreeBonus } from '@microcosmmoney/auth-core';
|
|
2
|
+
export interface TerritoryDetailedStats {
|
|
3
|
+
stats: TerritoryStats;
|
|
4
|
+
kpi?: TerritoryKPI;
|
|
5
|
+
tech_bonus?: TechTreeBonus;
|
|
6
|
+
}
|
|
7
|
+
export declare function useTerritoryDetailedStats(territoryId: string, options?: {
|
|
8
|
+
refetchInterval?: number;
|
|
9
|
+
}): import("./use-api-query").UseApiQueryResult<TerritoryDetailedStats>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTerritoryDetailedStats = useTerritoryDetailedStats;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useTerritoryDetailedStats(territoryId, options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: `/territories/${territoryId}/detailed-stats`,
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 60000,
|
|
10
|
+
skip: !territoryId,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface DistributionPlan {
|
|
2
|
+
territory_id: string;
|
|
3
|
+
distribution_type: string;
|
|
4
|
+
parameters: Record<string, any>;
|
|
5
|
+
updated_at: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useTerritoryDistributionPlan(territoryId?: string): {
|
|
8
|
+
updatePlan: (plan: Partial<DistributionPlan>) => Promise<DistributionPlan | undefined>;
|
|
9
|
+
updating: boolean;
|
|
10
|
+
updateError: Error | null;
|
|
11
|
+
data: DistributionPlan | null;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
refresh: () => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTerritoryDistributionPlan = useTerritoryDistributionPlan;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
const use_api_query_1 = require("./use-api-query");
|
|
8
|
+
function useTerritoryDistributionPlan(territoryId) {
|
|
9
|
+
const { client } = (0, provider_1.useAuth)();
|
|
10
|
+
const [updating, setUpdating] = (0, react_1.useState)(false);
|
|
11
|
+
const [updateError, setUpdateError] = (0, react_1.useState)(null);
|
|
12
|
+
const mountedRef = (0, react_1.useRef)(true);
|
|
13
|
+
const query = (0, use_api_query_1.useApiQuery)({
|
|
14
|
+
path: `/territories/${territoryId}/distribution-plan`,
|
|
15
|
+
skip: !territoryId,
|
|
16
|
+
requireAuth: true,
|
|
17
|
+
});
|
|
18
|
+
const updatePlan = (0, react_1.useCallback)(async (plan) => {
|
|
19
|
+
if (!territoryId)
|
|
20
|
+
return;
|
|
21
|
+
const api = client.getApiClient();
|
|
22
|
+
try {
|
|
23
|
+
setUpdating(true);
|
|
24
|
+
setUpdateError(null);
|
|
25
|
+
const res = await api.put(`/territories/${territoryId}/distribution-plan`, plan);
|
|
26
|
+
query.refresh();
|
|
27
|
+
return res.data;
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
31
|
+
if (mountedRef.current)
|
|
32
|
+
setUpdateError(e);
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
if (mountedRef.current)
|
|
37
|
+
setUpdating(false);
|
|
38
|
+
}
|
|
39
|
+
}, [client, territoryId, query]);
|
|
40
|
+
return { ...query, updatePlan, updating, updateError };
|
|
41
|
+
}
|