ef28667d13
* feat: add token and nft injection * feat: basic tests * fix: get jest configured properly * fix: change timeout * fix: uninstall port ready * fix: readd port ready * fix: local tests work * Update yarn.lock * add lint disable for setup files * fix: update dependencies * fix: basic test suite for nfts/tokens * feat: collection data * fix: make tests more comprehensive * fix: change matches to contains * fix: tests for twitter alt image tag * fix: image gen * fix: add patch-package * fix: update yarn install * feat: basic image gen for nfts and collections * fix: remove vibrant attempt * use watermark asset * dynamically grab color * modularize code and prototype for token preview * refactor code * finalize css * fix color grabber * update tests * fix up css * refactor code a bit more * remove console logs * tests * update tests * update images based on design feedback * network logos * update lint * slight refactoring * more refactoring * fix packages * Update yarn.lock * remove dynamically generated image stuff * cleanup return values * Create README.md * Revert "Create README.md" This reverts commit 7a91c98d384995fba914c9bf9a2fb3072793621f. * First round of feedback * comments * feedback round 2 * final feedback * final final feedback * nest twitter:image:alt in image check * better title handling --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
34 lines
818 B
TypeScript
34 lines
818 B
TypeScript
import { TokenDocument } from '../../src/graphql/data/__generated__/types-and-hooks'
|
|
import client from '../client'
|
|
|
|
function formatTitleName(symbol: string, name: string) {
|
|
if (symbol) {
|
|
return 'Get ' + symbol + ' on Uniswap'
|
|
}
|
|
if (name) {
|
|
return 'Get ' + name + ' on Uniswap'
|
|
}
|
|
return 'View Token on Uniswap'
|
|
}
|
|
|
|
export default async function getToken(networkName: string, tokenAddress: string, url: string) {
|
|
const { data } = await client.query({
|
|
query: TokenDocument,
|
|
variables: {
|
|
chain: networkName,
|
|
address: tokenAddress,
|
|
},
|
|
})
|
|
const asset = data?.token
|
|
if (!asset) {
|
|
return undefined
|
|
}
|
|
const title = formatTitleName(asset.symbol, asset.name)
|
|
const formattedAsset = {
|
|
title,
|
|
image: asset.project?.logoUrl,
|
|
url,
|
|
}
|
|
return formattedAsset
|
|
}
|