add utils package + move get tokens to lib folder

This commit is contained in:
2026-05-11 23:16:26 +08:00
parent d2c2a46e54
commit f47491ad86
18 changed files with 482 additions and 54 deletions
@@ -0,0 +1,30 @@
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,
})
const result = 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],
})
return result
}