Files
koins/apps/desktop/src/bun/lib/alchemy/get-token-metadata.ts
T
TZGyn 9e76bd54ce split data access into API-only (alchemy/viem) and DB-first wrappers (tokens/transactions)
alchemy/get-token-metadata: stripped DB logic, now pure API call
viem/get-transaction-details: stripped DB logic, now pure viem call
tokens/get-metadata: new DB-first wrapper for token metadata
transactions/get-details: new DB-first wrapper for tx details
transactions/get-history: stores individual Alchemy transfers in tx_history
  table with blockNum, from, to columns for searchable ordering
2026-05-18 03:03:34 +08:00

26 lines
502 B
TypeScript

import { post } from './call'
import { getChainID, getURL } from './network'
export const getTokenMetadata = async (
key: string,
chainid: string,
tokenAddress: string,
) => {
const chainId = getChainID(chainid)
if (!chainId) return
const url = getURL({ chainId, key })
return await post<{
name: string | null
symbol: string | null
decimals: number | null
logo: string | null
}>(url, {
jsonrpc: '2.0',
id: 0,
method: 'alchemy_getTokenMetadata',
params: [tokenAddress],
})
}