diff --git a/src/hooks/useTokenData.ts b/src/hooks/useTokenData.ts index a3d3d82190..b8d3dc1089 100644 --- a/src/hooks/useTokenData.ts +++ b/src/hooks/useTokenData.ts @@ -1,6 +1,5 @@ import { useMemo } from "react" import useSWRImmutable from "swr/immutable" -import { Token } from "types" import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" import useTokens from "./useTokens" @@ -26,14 +25,16 @@ const useTokenData = (chain: Chain, address: string, onFinish?: () => void) => { ) }, [tokensFromApi, address]) - const swrResponse = useSWRImmutable( - shouldFetch ? `/v2/util/chains/${chain}/contracts/${address}/symbol` : null, - { - errorRetryInterval: 100, - shouldRetryOnError: address?.toLowerCase() !== ENS_ADDRESS, - ...(onFinish ? { onSuccess: onFinish, onError: onFinish } : {}), - } - ) + const swrResponse = useSWRImmutable<{ + address: `0x${string}` + name: string + symbol: string + decimals: number + }>(shouldFetch ? `/v2/util/chains/${chain}/contracts/${address}/symbol` : null, { + errorRetryInterval: 100, + shouldRetryOnError: address?.toLowerCase() !== ENS_ADDRESS, + ...(onFinish ? { onSuccess: onFinish, onError: onFinish } : {}), + }) /** * Doing this instead of using initialData to make sure it fetches when shouldFetch diff --git a/src/hooks/useTokens.ts b/src/hooks/useTokens.ts index e0c4c6f637..033e6b5aac 100644 --- a/src/hooks/useTokens.ts +++ b/src/hooks/useTokens.ts @@ -1,9 +1,17 @@ import useSWRImmutable from "swr/immutable" -import { CoingeckoToken } from "types" import fetcher from "utils/fetcher" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { CHAIN_CONFIG, Chain, Chains } from "wagmiConfig/chains" +type CoingeckoToken = { + chainId: number + address: string + name: string + symbol: string + decimals: number + logoURI: string +} + export const TokenApiURLs: Record = { ETHEREUM: ["https://tokens.coingecko.com/uniswap/all.json"], BSC: ["https://tokens.coingecko.com/binance-smart-chain/all.json"], diff --git a/src/types.ts b/src/types.ts index 3cd3446bb8..dab8b6a7bc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,6 @@ import { FarcasterProfile, + Guild as GuildFromTypesPackage, Logic, Schemas, SocialLinks, @@ -14,13 +15,6 @@ import { z } from "zod" export const FUEL_ADDRESS_REGEX = /^0x[a-f0-9]{64}$/i -type Token = { - address: `0x${string}` - name: string - symbol: string - decimals: number -} - type DiscordError = { error: string; errorDescription: string } type WalletError = { code: number; message: string } @@ -29,21 +23,6 @@ type Rest = { [x: string]: any } -type Theme = { - color?: string - backgroundImage?: string - backgroundCss?: string -} - -type CoingeckoToken = { - chainId: number - address: string - name: string - symbol: string - decimals: number - logoURI: string -} - type Poap = { id: number fancy_id: string @@ -146,11 +125,6 @@ type User = { farcasterProfiles: FarcasterProfile[] } -type BaseUser = { - id: number - createdAt: Date -} - type GuildBase = { id: number name: string @@ -181,7 +155,7 @@ type SimpleGuild = { onboardingComplete: boolean memberCount: number guildPin?: GuildPinConfig - theme: Theme + theme: GuildFromTypesPackage["theme"] } type GuildAdmin = { @@ -595,7 +569,7 @@ type Guild = { contacts?: GuildContact[] createdAt: string admins: GuildAdmin[] - theme: Theme + theme: GuildFromTypesPackage["theme"] guildPlatforms: GuildPlatform[] roles: Role[] groups: Group[] @@ -675,13 +649,6 @@ enum ValidationMethod { FUEL = 4, } -type RequestMintLinksForm = { - event_id: number - requested_codes: number - secret_code: string - redeem_type: string -} - type Without = { [P in Exclude]?: never } @@ -744,9 +711,7 @@ export type RequiredFields = T & Required> export { ValidationMethod } export type { - BaseUser, ClientStateRequirementCreateResponse, - CoingeckoToken, DetailedPinLeaderboardUserData as DetailedUserLeaderboardData, DiscordError, GitPoap, @@ -765,7 +730,6 @@ export type { PlatformGuildData, PlatformName, Poap, - RequestMintLinksForm, Requirement, RequirementCreateResponseOutput, RequirementCreationPayloadWithTempID, @@ -779,7 +743,6 @@ export type { SimpleRole, SocialLinkKey, SocialLinks, - Token, Trait, User, UserAddress,