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
26 lines
502 B
TypeScript
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],
|
|
})
|
|
}
|