@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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLendingPool = useLendingPool;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useLendingPool(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/lending/pool',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 120000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLendingPosition = useLendingPosition;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useLendingPosition(wallet, options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: `/lending/position/${wallet}`,
|
|
9
|
+
skip: !wallet,
|
|
10
|
+
requireAuth: true,
|
|
11
|
+
refetchInterval: options?.refetchInterval ?? 60000,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLendingStats = useLendingStats;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useLendingStats(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/lending/stats',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TerritoryIncome } from '@microcosmmoney/auth-core';
|
|
2
|
+
export interface ManagerIncomeData {
|
|
3
|
+
total_income: number;
|
|
4
|
+
pending_income: number;
|
|
5
|
+
records: TerritoryIncome[];
|
|
6
|
+
}
|
|
7
|
+
export declare function useManagerIncome(options?: {
|
|
8
|
+
refetchInterval?: number;
|
|
9
|
+
}): import("./use-api-query").UseApiQueryResult<ManagerIncomeData>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useManagerIncome = useManagerIncome;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useManagerIncome(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/territories/manager/income',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMarketData = useMarketData;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMarketData(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/dashboard/market',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 120000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MCCHistoryRecord, PaginatedResult } from '@microcosmmoney/auth-core';
|
|
2
|
+
export declare function useMCCHistory(params?: {
|
|
3
|
+
tx_type?: string;
|
|
4
|
+
page?: number;
|
|
5
|
+
page_size?: number;
|
|
6
|
+
}): {
|
|
7
|
+
data: PaginatedResult<MCCHistoryRecord> | null;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
refresh: () => Promise<void>;
|
|
11
|
+
};
|
|
@@ -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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCCHolders = useMCCHolders;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMCCHolders(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/reincarnation/holders',
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCCMiningHistory = useMCCMiningHistory;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMCCMiningHistory(days = 30, options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: `/reincarnation/mining-history?days=${days}`,
|
|
9
|
+
refetchInterval: options?.refetchInterval ?? 300000,
|
|
10
|
+
});
|
|
11
|
+
}
|
package/dist/hooks/use-mcd.js
CHANGED
|
@@ -19,7 +19,7 @@ function useMCD(refreshInterval) {
|
|
|
19
19
|
setLoading(true);
|
|
20
20
|
const api = client.getApiClient();
|
|
21
21
|
const data = await api.get('/mcd/balance');
|
|
22
|
-
setBalance(data.data
|
|
22
|
+
setBalance(data.data || null);
|
|
23
23
|
setError(null);
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
@@ -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,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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MiningDistribution } from '@microcosmmoney/auth-core';
|
|
1
|
+
import type { MiningDistribution, PaginatedResult } from '@microcosmmoney/auth-core';
|
|
2
2
|
export declare function useMiningDistribution(options?: {
|
|
3
3
|
page?: number;
|
|
4
4
|
pageSize?: number;
|
|
5
5
|
refetchInterval?: number;
|
|
6
|
-
}): import("./use-api-query").UseApiQueryResult<MiningDistribution
|
|
6
|
+
}): import("./use-api-query").UseApiQueryResult<PaginatedResult<MiningDistribution>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type MiningFlowStep = 'idle' | 'requesting' | 'confirming' | 'signing' | 'completed' | 'error';
|
|
2
|
+
export interface MiningFlowState {
|
|
3
|
+
step: MiningFlowStep;
|
|
4
|
+
requestData: any | null;
|
|
5
|
+
confirmData: any | null;
|
|
6
|
+
txSignature: string | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function useMiningFlow(): {
|
|
10
|
+
startMining: (params: {
|
|
11
|
+
amount: number;
|
|
12
|
+
wallet_address: string;
|
|
13
|
+
stablecoin?: "USDT" | "USDC";
|
|
14
|
+
}) => Promise<any>;
|
|
15
|
+
confirmMining: (requestId: string, txSignature: string) => Promise<any>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
step: MiningFlowStep;
|
|
18
|
+
requestData: any | null;
|
|
19
|
+
confirmData: any | null;
|
|
20
|
+
txSignature: string | null;
|
|
21
|
+
error: string | null;
|
|
22
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MiningHistoryItem, PaginatedResult } from '@microcosmmoney/auth-core';
|
|
2
|
+
export declare function useMiningHistory(params?: {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
}): {
|
|
6
|
+
data: PaginatedResult<MiningHistoryItem> | null;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
refresh: () => Promise<void>;
|
|
10
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|