@microcosmmoney/auth-react 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/use-auction-bid.d.ts +5 -0
- package/dist/hooks/use-auction-bid.js +34 -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-detail.d.ts +3 -0
- package/dist/hooks/use-auction-detail.js +12 -0
- package/dist/hooks/use-auction-history.d.ts +9 -0
- package/dist/hooks/use-auction-history.js +41 -0
- package/dist/hooks/use-buyback-action.d.ts +6 -0
- package/dist/hooks/use-buyback-action.js +34 -0
- package/dist/hooks/use-buyback-history.d.ts +6 -0
- package/dist/hooks/use-buyback-history.js +14 -0
- package/dist/hooks/use-buyback-quote.d.ts +7 -0
- package/dist/hooks/use-buyback-quote.js +44 -0
- package/dist/hooks/use-cycle-history.d.ts +13 -0
- package/dist/hooks/use-cycle-history.js +41 -0
- package/dist/hooks/use-mcc-history.d.ts +18 -0
- package/dist/hooks/use-mcc-history.js +50 -0
- package/dist/hooks/use-mcc-locks.d.ts +4 -0
- package/dist/hooks/use-mcc-locks.js +12 -0
- package/dist/hooks/use-mcd-rewards.d.ts +8 -0
- package/dist/hooks/use-mcd-rewards.js +19 -0
- package/dist/hooks/use-mcd-transactions.d.ts +7 -0
- package/dist/hooks/use-mcd-transactions.js +17 -0
- 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 +6 -0
- package/dist/hooks/use-mining-distribution.js +14 -0
- package/dist/hooks/use-mining-history.d.ts +9 -0
- package/dist/hooks/use-mining-history.js +46 -0
- package/dist/hooks/use-mining-ratio.d.ts +4 -0
- package/dist/hooks/use-mining-ratio.js +11 -0
- package/dist/hooks/use-my-bids.d.ts +4 -0
- package/dist/hooks/use-my-bids.js +12 -0
- package/dist/hooks/use-proposal-detail.d.ts +4 -0
- package/dist/hooks/use-proposal-detail.js +13 -0
- package/dist/hooks/use-proposals.d.ts +7 -0
- package/dist/hooks/use-proposals.js +17 -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-territories.d.ts +8 -0
- package/dist/hooks/use-territories.js +19 -0
- package/dist/hooks/use-territory-detail.d.ts +4 -0
- package/dist/hooks/use-territory-detail.js +13 -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-members.d.ts +6 -0
- package/dist/hooks/use-territory-members.js +15 -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-stats.d.ts +4 -0
- package/dist/hooks/use-territory-stats.js +13 -0
- package/dist/hooks/use-territory-summary.d.ts +4 -0
- package/dist/hooks/use-territory-summary.js +12 -0
- package/dist/hooks/use-territory-update.d.ts +12 -0
- package/dist/hooks/use-territory-update.js +56 -0
- package/dist/hooks/use-token-portfolio.d.ts +4 -0
- package/dist/hooks/use-token-portfolio.js +12 -0
- package/dist/hooks/use-user-stats.d.ts +3 -0
- package/dist/hooks/use-user-stats.js +11 -0
- package/dist/hooks/use-vote-action.d.ts +14 -0
- package/dist/hooks/use-vote-action.js +58 -0
- package/dist/hooks/use-vote-power.d.ts +4 -0
- package/dist/hooks/use-vote-power.js +12 -0
- package/dist/hooks/use-wallets.d.ts +4 -0
- package/dist/hooks/use-wallets.js +12 -0
- package/dist/index.d.ts +37 -1
- package/dist/index.js +74 -1
- package/package.json +2 -2
|
@@ -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,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,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAuctionDetail = useAuctionDetail;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useAuctionDetail(id, options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: `/auction-solana/auction/${id}`,
|
|
9
|
+
skip: id === undefined || id === null,
|
|
10
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -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,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,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBuybackHistory = useBuybackHistory;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useBuybackHistory(options) {
|
|
7
|
+
const page = options?.page ?? 1;
|
|
8
|
+
const pageSize = options?.pageSize ?? 20;
|
|
9
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
10
|
+
path: `/reincarnation/user-history?page=${page}&page_size=${pageSize}`,
|
|
11
|
+
requireAuth: true,
|
|
12
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBuybackQuote = useBuybackQuote;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const provider_1 = require("../provider");
|
|
7
|
+
function useBuybackQuote(mccAmount) {
|
|
8
|
+
const { client } = (0, provider_1.useAuth)();
|
|
9
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
10
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
11
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
12
|
+
const mountedRef = (0, react_1.useRef)(true);
|
|
13
|
+
const fetchQuote = (0, react_1.useCallback)(async () => {
|
|
14
|
+
if (!mccAmount || mccAmount <= 0) {
|
|
15
|
+
setData(null);
|
|
16
|
+
setLoading(false);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const api = client.getApiClient();
|
|
20
|
+
try {
|
|
21
|
+
setLoading(true);
|
|
22
|
+
const res = await api.post('/reincarnation/quote', { mcc_amount: mccAmount });
|
|
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
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
if (mountedRef.current)
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}
|
|
37
|
+
}, [client, mccAmount]);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
mountedRef.current = true;
|
|
40
|
+
fetchQuote();
|
|
41
|
+
return () => { mountedRef.current = false; };
|
|
42
|
+
}, [fetchQuote]);
|
|
43
|
+
return { data, loading, error, refresh: fetchQuote };
|
|
44
|
+
}
|
|
@@ -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,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCCLocks = useMCCLocks;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMCCLocks(options) {
|
|
7
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
8
|
+
path: '/mcc/locks',
|
|
9
|
+
requireAuth: true,
|
|
10
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MCDReward } from '@microcosmmoney/auth-core';
|
|
2
|
+
export declare function useMCDRewards(options?: {
|
|
3
|
+
page?: number;
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
startDate?: string;
|
|
6
|
+
endDate?: string;
|
|
7
|
+
refetchInterval?: number;
|
|
8
|
+
}): import("./use-api-query").UseApiQueryResult<MCDReward[]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCDRewards = useMCDRewards;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMCDRewards(options) {
|
|
7
|
+
const page = options?.page ?? 1;
|
|
8
|
+
const pageSize = options?.pageSize ?? 20;
|
|
9
|
+
let qs = `?page=${page}&page_size=${pageSize}`;
|
|
10
|
+
if (options?.startDate)
|
|
11
|
+
qs += `&start_date=${options.startDate}`;
|
|
12
|
+
if (options?.endDate)
|
|
13
|
+
qs += `&end_date=${options.endDate}`;
|
|
14
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
15
|
+
path: `/mcd/rewards${qs}`,
|
|
16
|
+
requireAuth: true,
|
|
17
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MCDTransaction } from '@microcosmmoney/auth-core';
|
|
2
|
+
export declare function useMCDTransactions(options?: {
|
|
3
|
+
page?: number;
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
type?: string;
|
|
6
|
+
refetchInterval?: number;
|
|
7
|
+
}): import("./use-api-query").UseApiQueryResult<MCDTransaction[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMCDTransactions = useMCDTransactions;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMCDTransactions(options) {
|
|
7
|
+
const page = options?.page ?? 1;
|
|
8
|
+
const pageSize = options?.pageSize ?? 20;
|
|
9
|
+
let qs = `?page=${page}&page_size=${pageSize}`;
|
|
10
|
+
if (options?.type)
|
|
11
|
+
qs += `&type=${options.type}`;
|
|
12
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
13
|
+
path: `/mcd/transactions${qs}`,
|
|
14
|
+
requireAuth: true,
|
|
15
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMiningDistribution = useMiningDistribution;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_api_query_1 = require("./use-api-query");
|
|
6
|
+
function useMiningDistribution(options) {
|
|
7
|
+
const page = options?.page ?? 1;
|
|
8
|
+
const pageSize = options?.pageSize ?? 20;
|
|
9
|
+
return (0, use_api_query_1.useApiQuery)({
|
|
10
|
+
path: `/mining/distribution?page=${page}&page_size=${pageSize}`,
|
|
11
|
+
requireAuth: true,
|
|
12
|
+
refetchInterval: options?.refetchInterval ?? 0,
|
|
13
|
+
});
|
|
14
|
+
}
|