diff --git a/src/features/wallet/api/walletApi.ts b/src/features/wallet/api/walletApi.ts index 74ec8a0..39a54d0 100644 --- a/src/features/wallet/api/walletApi.ts +++ b/src/features/wallet/api/walletApi.ts @@ -1,4 +1,7 @@ -import { api } from '@shared/api/base' +import { getCsrfToken } from '@shared/api/csrf' +import { tokenStore } from '@shared/api/tokenStore' + +const WALLET_API_URL = 'https://app.cryptowallet.elcsa.ru' export type Chain = 'ETH' | 'BSC' | 'BTC' | 'TRX' | 'SOL' @@ -23,13 +26,28 @@ export interface PriceEntry { export const CHAINS: Chain[] = ['ETH', 'BSC', 'BTC', 'TRX', 'SOL'] +async function walletGet(path: string): Promise { + const csrf = await getCsrfToken() + + const res = await fetch(`${WALLET_API_URL}${path}`, { + credentials: 'include', + headers: { + 'X-CSRF-Token': csrf, + }, + }) + + const data = await res.json() + if (!res.ok) throw data + return data as T +} + export async function getWalletBalance(chain: Chain): Promise { - const res = await api.get<{ success: boolean; data: WalletBalanceData }>(`/api/wallets/${chain}/balance`) + const res = await walletGet<{ success: boolean; data: WalletBalanceData }>(`/api/wallets/${chain}/balance`) return res.data } export async function getPrices(symbols: string[]): Promise> { - const res = await api.get<{ success: boolean; data: Record }>( + const res = await walletGet<{ success: boolean; data: Record }>( `/api/prices?symbols=${symbols.join(',')}` ) return res.data diff --git a/src/widgets/token-table/ui/TokenTable.tsx b/src/widgets/token-table/ui/TokenTable.tsx index 8bde73d..72beb88 100644 --- a/src/widgets/token-table/ui/TokenTable.tsx +++ b/src/widgets/token-table/ui/TokenTable.tsx @@ -19,7 +19,6 @@ export function TokenTable() { return ( <>
- {/* Desktop table */}