@microcosmmoney/auth-react 1.5.1 → 2.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.
Files changed (55) hide show
  1. package/dist/hooks/use-api-query.js +17 -8
  2. package/dist/hooks/use-auction-bid.js +3 -6
  3. package/dist/hooks/use-auction-cancel.js +3 -6
  4. package/dist/hooks/use-auction-end.js +3 -4
  5. package/dist/hooks/use-auction-history.js +3 -4
  6. package/dist/hooks/use-auction-refund.js +3 -4
  7. package/dist/hooks/use-buyback-action.js +3 -6
  8. package/dist/hooks/use-buyback-flow.js +4 -6
  9. package/dist/hooks/use-buyback-quote.js +3 -4
  10. package/dist/hooks/use-create-auction.js +3 -4
  11. package/dist/hooks/use-cycle-history.js +3 -4
  12. package/dist/hooks/use-dashboard-summary.js +3 -4
  13. package/dist/hooks/use-fragment-action.js +3 -6
  14. package/dist/hooks/use-lending-action.d.ts +2 -1
  15. package/dist/hooks/use-lending-action.js +5 -7
  16. package/dist/hooks/use-lending-loans.d.ts +7 -2
  17. package/dist/hooks/use-lending-loans.js +5 -9
  18. package/dist/hooks/use-lending-oracle.d.ts +3 -0
  19. package/dist/hooks/use-lending-oracle.js +11 -0
  20. package/dist/hooks/use-lending-position.d.ts +7 -2
  21. package/dist/hooks/use-lending-position.js +5 -8
  22. package/dist/hooks/use-mcc-history.js +6 -5
  23. package/dist/hooks/use-mcc.js +6 -5
  24. package/dist/hooks/use-mcd.js +6 -5
  25. package/dist/hooks/use-mining-action.js +4 -10
  26. package/dist/hooks/use-mining-config.js +3 -4
  27. package/dist/hooks/use-mining-flow.js +4 -6
  28. package/dist/hooks/use-mining-history.js +6 -5
  29. package/dist/hooks/use-multi-wallet-balance.js +6 -5
  30. package/dist/hooks/use-notification-action.js +4 -6
  31. package/dist/hooks/use-profile.js +20 -21
  32. package/dist/hooks/use-proposal-settle.js +3 -4
  33. package/dist/hooks/use-public-mining.js +4 -6
  34. package/dist/hooks/use-reincarnation-config.js +3 -4
  35. package/dist/hooks/use-station-join.js +3 -4
  36. package/dist/hooks/use-station-leave.js +3 -4
  37. package/dist/hooks/use-tech-tree-action.js +4 -6
  38. package/dist/hooks/use-territory-distribution-plan.js +3 -4
  39. package/dist/hooks/use-territory-image.js +3 -4
  40. package/dist/hooks/use-territory-income.js +6 -5
  41. package/dist/hooks/use-territory-join.js +3 -4
  42. package/dist/hooks/use-territory-kpi.js +6 -5
  43. package/dist/hooks/use-territory-leave.js +3 -4
  44. package/dist/hooks/use-territory-nft-action.js +4 -6
  45. package/dist/hooks/use-territory-nft-mint.js +3 -4
  46. package/dist/hooks/use-territory-ranking.js +6 -5
  47. package/dist/hooks/use-territory-update.js +4 -10
  48. package/dist/hooks/use-vote-action.js +4 -10
  49. package/dist/index.d.ts +5 -2
  50. package/dist/index.js +10 -3
  51. package/dist/microcosm-context.d.ts +18 -0
  52. package/dist/microcosm-context.js +70 -0
  53. package/dist/provider.d.ts +1 -0
  54. package/dist/provider.js +7 -2
  55. package/package.json +2 -2
@@ -3,21 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useApiQuery = useApiQuery;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useApiQuery(options) {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
+ const { getAccessToken } = (0, microcosm_context_1.useMicrocosmContext)();
9
10
  const [data, setData] = (0, react_1.useState)(null);
10
11
  const [loading, setLoading] = (0, react_1.useState)(true);
11
12
  const [error, setError] = (0, react_1.useState)(null);
12
13
  const mountedRef = (0, react_1.useRef)(true);
13
- const shouldSkip = options.skip || (options.requireAuth && !isAuthenticated);
14
+ const skipRef = (0, react_1.useRef)(options.skip);
15
+ skipRef.current = options.skip;
14
16
  const fetchData = (0, react_1.useCallback)(async () => {
15
- if (shouldSkip) {
17
+ if (skipRef.current) {
16
18
  setData(null);
17
19
  setLoading(false);
18
20
  return;
19
21
  }
20
- const api = client.getApiClient();
22
+ if (options.requireAuth) {
23
+ const token = await getAccessToken();
24
+ if (!token) {
25
+ setData(null);
26
+ setLoading(false);
27
+ return;
28
+ }
29
+ }
21
30
  try {
22
31
  setLoading(true);
23
32
  const res = await api.get(options.path);
@@ -35,16 +44,16 @@ function useApiQuery(options) {
35
44
  if (mountedRef.current)
36
45
  setLoading(false);
37
46
  }
38
- }, [client, options.path, shouldSkip]);
47
+ }, [api, options.path, options.requireAuth, getAccessToken]);
39
48
  (0, react_1.useEffect)(() => {
40
49
  mountedRef.current = true;
41
50
  fetchData();
42
51
  const interval = options.refetchInterval;
43
- if (interval && interval > 0 && !shouldSkip) {
52
+ if (interval && interval > 0 && !options.skip) {
44
53
  const timer = setInterval(fetchData, interval);
45
54
  return () => { mountedRef.current = false; clearInterval(timer); };
46
55
  }
47
56
  return () => { mountedRef.current = false; };
48
- }, [fetchData, options.refetchInterval, shouldSkip]);
57
+ }, [fetchData, options.refetchInterval, options.skip]);
49
58
  return { data, loading, error, refresh: fetchData };
50
59
  }
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuctionBid = useAuctionBid;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useAuctionBid() {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
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
13
  try {
17
14
  setLoading(true);
18
15
  setError(null);
@@ -29,6 +26,6 @@ function useAuctionBid() {
29
26
  if (mountedRef.current)
30
27
  setLoading(false);
31
28
  }
32
- }, [client, isAuthenticated]);
29
+ }, [api]);
33
30
  return { placeBid, loading, error };
34
31
  }
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuctionCancel = useAuctionCancel;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useAuctionCancel() {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const prepareCancelBid = (0, react_1.useCallback)(async (auctionId) => {
13
- if (!isAuthenticated)
14
- throw new Error('Authentication required');
15
- const api = client.getApiClient();
16
13
  try {
17
14
  setLoading(true);
18
15
  setError(null);
@@ -29,6 +26,6 @@ function useAuctionCancel() {
29
26
  if (mountedRef.current)
30
27
  setLoading(false);
31
28
  }
32
- }, [client, isAuthenticated]);
29
+ }, [api]);
33
30
  return { prepareCancelBid, loading, error };
34
31
  }
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuctionEnd = useAuctionEnd;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useAuctionEnd() {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const endAuction = (0, react_1.useCallback)(async (auctionId) => {
13
- const api = client.getApiClient();
14
13
  try {
15
14
  setLoading(true);
16
15
  setError(null);
@@ -27,6 +26,6 @@ function useAuctionEnd() {
27
26
  if (mountedRef.current)
28
27
  setLoading(false);
29
28
  }
30
- }, [client]);
29
+ }, [api]);
31
30
  return { endAuction, loading, error };
32
31
  }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuctionHistory = useAuctionHistory;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useAuctionHistory(params) {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [data, setData] = (0, react_1.useState)(null);
10
10
  const [loading, setLoading] = (0, react_1.useState)(true);
11
11
  const [error, setError] = (0, react_1.useState)(null);
@@ -14,7 +14,6 @@ function useAuctionHistory(params) {
14
14
  const page = p.page || 1;
15
15
  const pageSize = p.page_size || 20;
16
16
  const fetchData = (0, react_1.useCallback)(async () => {
17
- const api = client.getApiClient();
18
17
  try {
19
18
  setLoading(true);
20
19
  const res = await api.get(`/auction-solana/history?page=${page}&page_size=${pageSize}`);
@@ -31,7 +30,7 @@ function useAuctionHistory(params) {
31
30
  if (mountedRef.current)
32
31
  setLoading(false);
33
32
  }
34
- }, [client, page, pageSize]);
33
+ }, [api, page, pageSize]);
35
34
  (0, react_1.useEffect)(() => {
36
35
  mountedRef.current = true;
37
36
  fetchData();
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuctionRefund = useAuctionRefund;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useAuctionRefund() {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const prepareRefund = (0, react_1.useCallback)(async (auctionId) => {
13
- const api = client.getApiClient();
14
13
  try {
15
14
  setLoading(true);
16
15
  setError(null);
@@ -27,6 +26,6 @@ function useAuctionRefund() {
27
26
  if (mountedRef.current)
28
27
  setLoading(false);
29
28
  }
30
- }, [client]);
29
+ }, [api]);
31
30
  return { prepareRefund, loading, error };
32
31
  }
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useBuybackAction = useBuybackAction;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useBuybackAction() {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const record = (0, react_1.useCallback)(async (params) => {
13
- if (!isAuthenticated)
14
- throw new Error('Authentication required');
15
- const api = client.getApiClient();
16
13
  try {
17
14
  setLoading(true);
18
15
  setError(null);
@@ -29,6 +26,6 @@ function useBuybackAction() {
29
26
  if (mountedRef.current)
30
27
  setLoading(false);
31
28
  }
32
- }, [client, isAuthenticated]);
29
+ }, [api]);
33
30
  return { record, loading, error };
34
31
  }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useBuybackFlow = useBuybackFlow;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useBuybackFlow() {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [state, setState] = (0, react_1.useState)({
10
10
  step: 'idle',
11
11
  quote: null,
@@ -17,7 +17,6 @@ function useBuybackFlow() {
17
17
  setState({ step: 'idle', quote: null, result: null, txSignature: null, error: null });
18
18
  }, []);
19
19
  const getQuote = (0, react_1.useCallback)(async (params) => {
20
- const api = client.getApiClient();
21
20
  setState(s => ({ ...s, step: 'quoting', error: null }));
22
21
  try {
23
22
  const q = await api.post('/mcc/buyback/quote', params);
@@ -28,9 +27,8 @@ function useBuybackFlow() {
28
27
  setState(s => ({ ...s, step: 'error', error: e.message }));
29
28
  throw e;
30
29
  }
31
- }, [client]);
30
+ }, [api]);
32
31
  const executeBuyback = (0, react_1.useCallback)(async (quoteId, txSignature) => {
33
- const api = client.getApiClient();
34
32
  setState(s => ({ ...s, step: 'signing' }));
35
33
  try {
36
34
  const res = await api.post('/mcc/buyback/execute', { quote_id: quoteId, tx_signature: txSignature });
@@ -41,6 +39,6 @@ function useBuybackFlow() {
41
39
  setState(s => ({ ...s, step: 'error', error: e.message }));
42
40
  throw e;
43
41
  }
44
- }, [client]);
42
+ }, [api]);
45
43
  return { ...state, getQuote, executeBuyback, reset };
46
44
  }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useBuybackQuote = useBuybackQuote;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useBuybackQuote(mccAmount) {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [data, setData] = (0, react_1.useState)(null);
10
10
  const [loading, setLoading] = (0, react_1.useState)(false);
11
11
  const [error, setError] = (0, react_1.useState)(null);
@@ -16,7 +16,6 @@ function useBuybackQuote(mccAmount) {
16
16
  setLoading(false);
17
17
  return;
18
18
  }
19
- const api = client.getApiClient();
20
19
  try {
21
20
  setLoading(true);
22
21
  const res = await api.post('/reincarnation/quote', { mcc_amount: mccAmount });
@@ -34,7 +33,7 @@ function useBuybackQuote(mccAmount) {
34
33
  if (mountedRef.current)
35
34
  setLoading(false);
36
35
  }
37
- }, [client, mccAmount]);
36
+ }, [api, mccAmount]);
38
37
  (0, react_1.useEffect)(() => {
39
38
  mountedRef.current = true;
40
39
  fetchQuote();
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCreateAuction = useCreateAuction;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useCreateAuction() {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const createAuction = (0, react_1.useCallback)(async (input) => {
13
- const api = client.getApiClient();
14
13
  try {
15
14
  setLoading(true);
16
15
  setError(null);
@@ -27,6 +26,6 @@ function useCreateAuction() {
27
26
  if (mountedRef.current)
28
27
  setLoading(false);
29
28
  }
30
- }, [client]);
29
+ }, [api]);
31
30
  return { createAuction, loading, error };
32
31
  }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCycleHistory = useCycleHistory;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useCycleHistory(params) {
8
- const { client } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [data, setData] = (0, react_1.useState)(null);
10
10
  const [loading, setLoading] = (0, react_1.useState)(true);
11
11
  const [error, setError] = (0, react_1.useState)(null);
@@ -14,7 +14,6 @@ function useCycleHistory(params) {
14
14
  const page = p.page || 1;
15
15
  const pageSize = p.page_size || 20;
16
16
  const fetchData = (0, react_1.useCallback)(async () => {
17
- const api = client.getApiClient();
18
17
  try {
19
18
  setLoading(true);
20
19
  const res = await api.get(`/reincarnation/cycle-history?page=${page}&page_size=${pageSize}`);
@@ -31,7 +30,7 @@ function useCycleHistory(params) {
31
30
  if (mountedRef.current)
32
31
  setLoading(false);
33
32
  }
34
- }, [client, page, pageSize]);
33
+ }, [api, page, pageSize]);
35
34
  (0, react_1.useEffect)(() => {
36
35
  mountedRef.current = true;
37
36
  fetchData();
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDashboardSummary = useDashboardSummary;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useDashboardSummary(wallet, options) {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [data, setData] = (0, react_1.useState)(null);
10
10
  const [loading, setLoading] = (0, react_1.useState)(true);
11
11
  const [error, setError] = (0, react_1.useState)(null);
12
12
  const mountedRef = (0, react_1.useRef)(true);
13
13
  const fetchData = (0, react_1.useCallback)(async () => {
14
- const api = client.getApiClient();
15
14
  try {
16
15
  setLoading(true);
17
16
  const promises = [
@@ -38,7 +37,7 @@ function useDashboardSummary(wallet, options) {
38
37
  if (mountedRef.current)
39
38
  setLoading(false);
40
39
  }
41
- }, [client, wallet]);
40
+ }, [api, wallet]);
42
41
  (0, react_1.useEffect)(() => {
43
42
  mountedRef.current = true;
44
43
  fetchData();
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFragmentAction = useFragmentAction;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useFragmentAction() {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const exec = (0, react_1.useCallback)(async (path, params) => {
13
- if (!isAuthenticated)
14
- throw new Error('Authentication required');
15
- const api = client.getApiClient();
16
13
  try {
17
14
  setLoading(true);
18
15
  setError(null);
@@ -29,7 +26,7 @@ function useFragmentAction() {
29
26
  if (mountedRef.current)
30
27
  setLoading(false);
31
28
  }
32
- }, [client, isAuthenticated]);
29
+ }, [api]);
33
30
  const buy = (0, react_1.useCallback)((params) => exec('/fragment/buy/prepare', params), [exec]);
34
31
  const fragmentize = (0, react_1.useCallback)((params) => exec('/fragment/fragmentize/prepare', params), [exec]);
35
32
  const redeem = (0, react_1.useCallback)((params) => exec('/fragment/redeem/prepare', params), [exec]);
@@ -1,9 +1,10 @@
1
- import type { LendingDepositInput, LendingWithdrawInput, LendingBorrowInput, LendingRepayInput, LendingLiquidateInput } from '@microcosmmoney/auth-core';
1
+ import type { LendingDepositInput, LendingWithdrawInput, LendingBorrowInput, LendingRepayInput, LendingExtendInput, LendingLiquidateInput } from '@microcosmmoney/auth-core';
2
2
  export declare function useLendingAction(): {
3
3
  deposit: (params: LendingDepositInput) => Promise<any>;
4
4
  withdraw: (params: LendingWithdrawInput) => Promise<any>;
5
5
  borrow: (params: LendingBorrowInput) => Promise<any>;
6
6
  repay: (params: LendingRepayInput) => Promise<any>;
7
+ extend: (params: LendingExtendInput) => Promise<any>;
7
8
  liquidate: (params: LendingLiquidateInput) => Promise<any>;
8
9
  loading: boolean;
9
10
  error: Error | null;
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLendingAction = useLendingAction;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useLendingAction() {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
9
  const [loading, setLoading] = (0, react_1.useState)(false);
10
10
  const [error, setError] = (0, react_1.useState)(null);
11
11
  const mountedRef = (0, react_1.useRef)(true);
12
12
  const exec = (0, react_1.useCallback)(async (path, params) => {
13
- if (!isAuthenticated)
14
- throw new Error('Authentication required');
15
- const api = client.getApiClient();
16
13
  try {
17
14
  setLoading(true);
18
15
  setError(null);
@@ -29,11 +26,12 @@ function useLendingAction() {
29
26
  if (mountedRef.current)
30
27
  setLoading(false);
31
28
  }
32
- }, [client, isAuthenticated]);
29
+ }, [api]);
33
30
  const deposit = (0, react_1.useCallback)((params) => exec('/lending/deposit/prepare', params), [exec]);
34
31
  const withdraw = (0, react_1.useCallback)((params) => exec('/lending/withdraw/prepare', params), [exec]);
35
32
  const borrow = (0, react_1.useCallback)((params) => exec('/lending/borrow/prepare', params), [exec]);
36
33
  const repay = (0, react_1.useCallback)((params) => exec('/lending/repay/prepare', params), [exec]);
34
+ const extend = (0, react_1.useCallback)((params) => exec('/lending/extend/prepare', params), [exec]);
37
35
  const liquidate = (0, react_1.useCallback)((params) => exec('/lending/liquidate/prepare', params), [exec]);
38
- return { deposit, withdraw, borrow, repay, liquidate, loading, error };
36
+ return { deposit, withdraw, borrow, repay, extend, liquidate, loading, error };
39
37
  }
@@ -1,3 +1,8 @@
1
- export declare function useLendingLoans(wallet?: string, options?: {
1
+ export declare function useLendingLoans(_wallet?: string, _options?: {
2
2
  refetchInterval?: number;
3
- }): import("./use-api-query").UseApiQueryResult<any[]>;
3
+ }): {
4
+ data: any[];
5
+ loading: boolean;
6
+ error: Error;
7
+ refresh: () => void;
8
+ };
@@ -2,13 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLendingLoans = useLendingLoans;
4
4
  // AI-generated · AI-managed · AI-maintained
5
- const use_api_query_1 = require("./use-api-query");
6
- function useLendingLoans(wallet, options) {
7
- return (0, use_api_query_1.useApiQuery)({
8
- path: `/lending/loans/${wallet}`,
9
- requireAuth: false,
10
- skip: !wallet,
11
- refetchInterval: options?.refetchInterval ?? 0,
12
- select: (d) => Array.isArray(d) ? d : d?.loans ?? [],
13
- });
5
+ // DEPRECATED: Removed in v2.1.0 — loans are now identified by nft_mint.
6
+ // Use GET /v1/lending/loan/{wallet}/{nft_mint} directly.
7
+ function useLendingLoans(_wallet, _options) {
8
+ console.warn('[Microcosm SDK] useLendingLoans() is deprecated and removed in v2.1.0. Query individual loans via nft_mint.');
9
+ return { data: [], loading: false, error: new Error('useLendingLoans removed in v2.1.0'), refresh: () => { } };
14
10
  }
@@ -0,0 +1,3 @@
1
+ export declare function useLendingOracle(options?: {
2
+ refetchInterval?: number;
3
+ }): import("./use-api-query").UseApiQueryResult<any>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLendingOracle = useLendingOracle;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ const use_api_query_1 = require("./use-api-query");
6
+ function useLendingOracle(options) {
7
+ return (0, use_api_query_1.useApiQuery)({
8
+ path: '/lending/oracle',
9
+ refetchInterval: options?.refetchInterval ?? 300000,
10
+ });
11
+ }
@@ -1,3 +1,8 @@
1
- export declare function useLendingPosition(wallet?: string, options?: {
1
+ export declare function useLendingPosition(_wallet?: string, _options?: {
2
2
  refetchInterval?: number;
3
- }): import("./use-api-query").UseApiQueryResult<any>;
3
+ }): {
4
+ data: null;
5
+ loading: boolean;
6
+ error: Error;
7
+ refresh: () => void;
8
+ };
@@ -2,12 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLendingPosition = useLendingPosition;
4
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
- });
5
+ // DEPRECATED: Removed in v2.1.0 — native contract has no UserPosition concept.
6
+ // Use useLendingLPBalance() for deposit tracking, loan lookup via nft_mint.
7
+ function useLendingPosition(_wallet, _options) {
8
+ console.warn('[Microcosm SDK] useLendingPosition() is deprecated and removed in v2.1.0. Use useLendingLPBalance() instead.');
9
+ return { data: null, loading: false, error: new Error('useLendingPosition removed in v2.1.0'), refresh: () => { } };
13
10
  }
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMCCHistory = useMCCHistory;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useMCCHistory(params) {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
+ const { getAccessToken } = (0, microcosm_context_1.useMicrocosmContext)();
9
10
  const [data, setData] = (0, react_1.useState)(null);
10
11
  const [loading, setLoading] = (0, react_1.useState)(true);
11
12
  const [error, setError] = (0, react_1.useState)(null);
@@ -15,12 +16,12 @@ function useMCCHistory(params) {
15
16
  const pageSize = p.page_size || 20;
16
17
  const txType = p.tx_type;
17
18
  const fetchData = (0, react_1.useCallback)(async () => {
18
- if (!isAuthenticated) {
19
+ const _token = await getAccessToken();
20
+ if (!_token) {
19
21
  setData(null);
20
22
  setLoading(false);
21
23
  return;
22
24
  }
23
- const api = client.getApiClient();
24
25
  try {
25
26
  setLoading(true);
26
27
  let qs = `?page=${page}&page_size=${pageSize}`;
@@ -40,7 +41,7 @@ function useMCCHistory(params) {
40
41
  if (mountedRef.current)
41
42
  setLoading(false);
42
43
  }
43
- }, [client, isAuthenticated, page, pageSize, txType]);
44
+ }, [api, getAccessToken, page, pageSize, txType]);
44
45
  (0, react_1.useEffect)(() => {
45
46
  mountedRef.current = true;
46
47
  fetchData();
@@ -3,21 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMCC = useMCC;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useMCC(refreshInterval) {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
+ const { getAccessToken } = (0, microcosm_context_1.useMicrocosmContext)();
9
10
  const [balance, setBalance] = (0, react_1.useState)(null);
10
11
  const [price, setPrice] = (0, react_1.useState)(null);
11
12
  const [loading, setLoading] = (0, react_1.useState)(true);
12
13
  const [error, setError] = (0, react_1.useState)(null);
13
14
  const fetchData = (0, react_1.useCallback)(async () => {
14
- const api = client.getApiClient();
15
15
  try {
16
16
  setLoading(true);
17
17
  const pricePromise = api.get('/mcc/price')
18
18
  .then(res => setPrice(res.data))
19
19
  .catch(() => { });
20
- if (isAuthenticated) {
20
+ const token = await getAccessToken();
21
+ if (token) {
21
22
  const balancePromise = api.get('/mcc/balance')
22
23
  .then(res => setBalance(res.data))
23
24
  .catch(() => { });
@@ -35,7 +36,7 @@ function useMCC(refreshInterval) {
35
36
  finally {
36
37
  setLoading(false);
37
38
  }
38
- }, [client, isAuthenticated]);
39
+ }, [api, getAccessToken]);
39
40
  (0, react_1.useEffect)(() => {
40
41
  fetchData();
41
42
  if (refreshInterval && refreshInterval > 0) {
@@ -3,21 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMCD = useMCD;
4
4
  // AI-generated · AI-managed · AI-maintained
5
5
  const react_1 = require("react");
6
- const provider_1 = require("../provider");
6
+ const microcosm_context_1 = require("../microcosm-context");
7
7
  function useMCD(refreshInterval) {
8
- const { client, isAuthenticated } = (0, provider_1.useAuth)();
8
+ const api = (0, microcosm_context_1.useMicrocosmApi)();
9
+ const { getAccessToken } = (0, microcosm_context_1.useMicrocosmContext)();
9
10
  const [balance, setBalance] = (0, react_1.useState)(null);
10
11
  const [loading, setLoading] = (0, react_1.useState)(true);
11
12
  const [error, setError] = (0, react_1.useState)(null);
12
13
  const fetchBalance = (0, react_1.useCallback)(async () => {
13
- if (!isAuthenticated) {
14
+ const _token = await getAccessToken();
15
+ if (!_token) {
14
16
  setBalance(null);
15
17
  setLoading(false);
16
18
  return;
17
19
  }
18
20
  try {
19
21
  setLoading(true);
20
- const api = client.getApiClient();
21
22
  const data = await api.get('/mcd/balance');
22
23
  setBalance(data.data || null);
23
24
  setError(null);
@@ -28,7 +29,7 @@ function useMCD(refreshInterval) {
28
29
  finally {
29
30
  setLoading(false);
30
31
  }
31
- }, [client, isAuthenticated]);
32
+ }, [api, getAccessToken]);
32
33
  (0, react_1.useEffect)(() => {
33
34
  fetchBalance();
34
35
  if (refreshInterval && refreshInterval > 0) {