Skip to content

Commit

Permalink
cleanup: remove some unused types
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Sep 16, 2024
1 parent f5b30e4 commit e2bdc36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 50 deletions.
19 changes: 10 additions & 9 deletions src/hooks/useTokenData.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -26,14 +25,16 @@ const useTokenData = (chain: Chain, address: string, onFinish?: () => void) => {
)
}, [tokensFromApi, address])

const swrResponse = useSWRImmutable<Token>(
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
Expand Down
10 changes: 9 additions & 1 deletion src/hooks/useTokens.ts
Original file line number Diff line number Diff line change
@@ -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<Chain, string[]> = {
ETHEREUM: ["https://tokens.coingecko.com/uniswap/all.json"],
BSC: ["https://tokens.coingecko.com/binance-smart-chain/all.json"],
Expand Down
43 changes: 3 additions & 40 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
FarcasterProfile,
Guild as GuildFromTypesPackage,
Logic,
Schemas,
SocialLinks,
Expand All @@ -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 }
Expand All @@ -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
Expand Down Expand Up @@ -146,11 +125,6 @@ type User = {
farcasterProfiles: FarcasterProfile[]
}

type BaseUser = {
id: number
createdAt: Date
}

type GuildBase = {
id: number
name: string
Expand Down Expand Up @@ -181,7 +155,7 @@ type SimpleGuild = {
onboardingComplete: boolean
memberCount: number
guildPin?: GuildPinConfig
theme: Theme
theme: GuildFromTypesPackage["theme"]
}

type GuildAdmin = {
Expand Down Expand Up @@ -595,7 +569,7 @@ type Guild = {
contacts?: GuildContact[]
createdAt: string
admins: GuildAdmin[]
theme: Theme
theme: GuildFromTypesPackage["theme"]
guildPlatforms: GuildPlatform[]
roles: Role[]
groups: Group[]
Expand Down Expand Up @@ -675,13 +649,6 @@ enum ValidationMethod {
FUEL = 4,
}

type RequestMintLinksForm = {
event_id: number
requested_codes: number
secret_code: string
redeem_type: string
}

type Without<First, Second> = {
[P in Exclude<keyof First, keyof Second>]?: never
}
Expand Down Expand Up @@ -744,9 +711,7 @@ export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>

export { ValidationMethod }
export type {
BaseUser,
ClientStateRequirementCreateResponse,
CoingeckoToken,
DetailedPinLeaderboardUserData as DetailedUserLeaderboardData,
DiscordError,
GitPoap,
Expand All @@ -765,7 +730,6 @@ export type {
PlatformGuildData,
PlatformName,
Poap,
RequestMintLinksForm,
Requirement,
RequirementCreateResponseOutput,
RequirementCreationPayloadWithTempID,
Expand All @@ -779,7 +743,6 @@ export type {
SimpleRole,
SocialLinkKey,
SocialLinks,
Token,
Trait,
User,
UserAddress,
Expand Down

0 comments on commit e2bdc36

Please sign in to comment.