14.05.2026 rip
This commit is contained in:
@@ -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'
|
export type Chain = 'ETH' | 'BSC' | 'BTC' | 'TRX' | 'SOL'
|
||||||
|
|
||||||
@@ -23,13 +26,28 @@ export interface PriceEntry {
|
|||||||
|
|
||||||
export const CHAINS: Chain[] = ['ETH', 'BSC', 'BTC', 'TRX', 'SOL']
|
export const CHAINS: Chain[] = ['ETH', 'BSC', 'BTC', 'TRX', 'SOL']
|
||||||
|
|
||||||
|
async function walletGet<T>(path: string): Promise<T> {
|
||||||
|
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<WalletBalanceData> {
|
export async function getWalletBalance(chain: Chain): Promise<WalletBalanceData> {
|
||||||
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
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPrices(symbols: string[]): Promise<Record<string, PriceEntry>> {
|
export async function getPrices(symbols: string[]): Promise<Record<string, PriceEntry>> {
|
||||||
const res = await api.get<{ success: boolean; data: Record<string, PriceEntry> }>(
|
const res = await walletGet<{ success: boolean; data: Record<string, PriceEntry> }>(
|
||||||
`/api/prices?symbols=${symbols.join(',')}`
|
`/api/prices?symbols=${symbols.join(',')}`
|
||||||
)
|
)
|
||||||
return res.data
|
return res.data
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export function TokenTable() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={`${styles.wrap} ${isLoading ? styles.loading : ''}`}>
|
<div className={`${styles.wrap} ${isLoading ? styles.loading : ''}`}>
|
||||||
{/* Desktop table */}
|
|
||||||
<table className={styles.table}>
|
<table className={styles.table}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user