@microcosmmoney/auth-react 1.0.4 → 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-bids.d.ts +4 -0
- package/dist/hooks/use-auction-bids.js +12 -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-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-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-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 +2 -9
- 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-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 +2 -1
- 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-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-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-user-level.d.ts +2 -8
- package/dist/hooks/use-user-stats.d.ts +2 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +83 -1
- package/package.json +2 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMiningFlow = useMiningFlow;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useMiningFlow() {
|
|
8
|
+
const { client } = (0, provider_1.useAuth)();
|
|
9
|
+
const [state, setState] = (0, react_1.useState)({
|
|
10
|
+
step: 'idle',
|
|
11
|
+
requestData: null,
|
|
12
|
+
confirmData: null,
|
|
13
|
+
txSignature: null,
|
|
14
|
+
error: null,
|
|
15
|
+
});
|
|
16
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
17
|
+
setState({ step: 'idle', requestData: null, confirmData: null, txSignature: null, error: null });
|
|
18
|
+
}, []);
|
|
19
|
+
const startMining = (0, react_1.useCallback)(async (params) => {
|
|
20
|
+
const api = client.getApiClient();
|
|
21
|
+
setState(s => ({ ...s, step: 'requesting', error: null }));
|
|
22
|
+
try {
|
|
23
|
+
const req = await api.post('/mcc/mining/request', params);
|
|
24
|
+
setState(s => ({ ...s, step: 'confirming', requestData: req.data }));
|
|
25
|
+
return req.data;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
setState(s => ({ ...s, step: 'error', error: e.message }));
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}, [client]);
|
|
32
|
+
const confirmMining = (0, react_1.useCallback)(async (requestId, txSignature) => {
|
|
33
|
+
const api = client.getApiClient();
|
|
34
|
+
setState(s => ({ ...s, step: 'signing' }));
|
|
35
|
+
try {
|
|
36
|
+
const res = await api.post('/mcc/mining/confirm', { request_id: requestId, tx_signature: txSignature });
|
|
37
|
+
setState(s => ({ ...s, step: 'completed', confirmData: res.data, txSignature }));
|
|
38
|
+
return res.data;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
setState(s => ({ ...s, step: 'error', error: e.message }));
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
}, [client]);
|
|
45
|
+
return { ...state, startMining, confirmMining, reset };
|
|
46
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { MiningHistoryItem, PaginatedResult } from '@microcosmmoney/auth-core';
|
|
1
2
|
export declare function useMiningHistory(params?: {
|
|
2
3
|
limit?: number;
|
|
3
4
|
offset?: number;
|
|
4
5
|
}): {
|
|
5
|
-
data:
|
|
6
|
+
data: PaginatedResult<MiningHistoryItem> | null;
|
|
6
7
|
loading: boolean;
|
|
7
8
|
error: Error | null;
|
|
8
9
|
refresh: () => Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { MiningRecord, PaginatedResult } from '@microcosmmoney/auth-core';
|
|
1
2
|
export declare function useMiningRecords(options?: {
|
|
2
3
|
limit?: number;
|
|
3
4
|
refetchInterval?: number;
|
|
4
|
-
}): import("./use-api-query").UseApiQueryResult<
|
|
5
|
+
}): import("./use-api-query").UseApiQueryResult<PaginatedResult<MiningRecord>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TokenPortfolio } from '@microcosmmoney/auth-core';
|
|
2
|
+
interface WalletBalance {
|
|
3
|
+
wallet_address: string;
|
|
4
|
+
is_primary: boolean;
|
|
5
|
+
portfolio: TokenPortfolio;
|
|
6
|
+
}
|
|
7
|
+
export declare function useMultiWalletBalance(options?: {
|
|
8
|
+
refetchInterval?: number;
|
|
9
|
+
}): {
|
|
10
|
+
data: WalletBalance[] | null;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
refresh: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMultiWalletBalance = useMultiWalletBalance;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useMultiWalletBalance(options) {
|
|
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) {
|
|
15
|
+
setData(null);
|
|
16
|
+
setLoading(false);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const api = client.getApiClient();
|
|
20
|
+
try {
|
|
21
|
+
setLoading(true);
|
|
22
|
+
const walletsRes = await api.get('/wallets');
|
|
23
|
+
const wallets = walletsRes.data?.wallets || [];
|
|
24
|
+
const balances = await Promise.all(wallets.map(async (w) => {
|
|
25
|
+
const balRes = await api.get(`/wallets/${w.wallet_address}/tokens`).catch(() => ({ data: {} }));
|
|
26
|
+
return { wallet_address: w.wallet_address, is_primary: w.is_primary, portfolio: balRes.data };
|
|
27
|
+
}));
|
|
28
|
+
if (mountedRef.current) {
|
|
29
|
+
setData(balances);
|
|
30
|
+
setError(null);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (mountedRef.current)
|
|
35
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
if (mountedRef.current)
|
|
39
|
+
setLoading(false);
|
|
40
|
+
}
|
|
41
|
+
}, [client, isAuthenticated]);
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
mountedRef.current = true;
|
|
44
|
+
fetchData();
|
|
45
|
+
const interval = options?.refetchInterval ?? 120000;
|
|
46
|
+
if (interval > 0) {
|
|
47
|
+
const timer = setInterval(fetchData, interval);
|
|
48
|
+
return () => { mountedRef.current = false; clearInterval(timer); };
|
|
49
|
+
}
|
|
50
|
+
return () => { mountedRef.current = false; };
|
|
51
|
+
}, [fetchData, options?.refetchInterval]);
|
|
52
|
+
return { data, loading, error, refresh: fetchData };
|
|
53
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNotificationAction = useNotificationAction;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useNotificationAction() {
|
|
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 markRead = (0, react_1.useCallback)(async (notificationId) => {
|
|
13
|
+
const api = client.getApiClient();
|
|
14
|
+
try {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
return await api.post(`/notifications/${notificationId}/read`, {});
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
21
|
+
if (mountedRef.current)
|
|
22
|
+
setError(e);
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
if (mountedRef.current)
|
|
27
|
+
setLoading(false);
|
|
28
|
+
}
|
|
29
|
+
}, [client]);
|
|
30
|
+
const markAllRead = (0, react_1.useCallback)(async () => {
|
|
31
|
+
const api = client.getApiClient();
|
|
32
|
+
try {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
setError(null);
|
|
35
|
+
return await api.post('/notifications/read-all', {});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
39
|
+
if (mountedRef.current)
|
|
40
|
+
setError(e);
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (mountedRef.current)
|
|
45
|
+
setLoading(false);
|
|
46
|
+
}
|
|
47
|
+
}, [client]);
|
|
48
|
+
return { markRead, markAllRead, loading, error };
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Notification {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
read: boolean;
|
|
7
|
+
created_at: string;
|
|
8
|
+
data?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useNotifications(options?: {
|
|
11
|
+
refetchInterval?: number;
|
|
12
|
+
unreadOnly?: boolean;
|
|
13
|
+
}): import("./use-api-query").UseApiQueryResult<Notification[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNotifications = useNotifications;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useNotifications(options) {
|
|
7
|
+
const params = new URLSearchParams();
|
|
8
|
+
if (options?.unreadOnly)
|
|
9
|
+
params.set('unread', 'true');
|
|
10
|
+
const qs = params.toString();
|
|
11
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
12
|
+
path: `/notifications${qs ? `?${qs}` : ''}`,
|
|
13
|
+
refetchInterval: options?.refetchInterval ?? 30000,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -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,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
|
+
}
|