Skip to content

Commit

Permalink
refactor: use viem isAddressEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Feb 19, 2025
1 parent 97bbaf5 commit 998587f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/communities/communityUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nftContracts } from '@/lib/contracts'
import { ReactNode } from 'react'

interface CommunityItem {
export interface CommunityItem {
leftImageSrc: string
title: string
subtitle: string
Expand Down
2 changes: 1 addition & 1 deletion src/app/providers/NFT/BoosterContext.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from '@tanstack/react-query'
import { render, renderHook, screen, waitFor } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, Mock, vi } from 'vitest'
import { afterEach, describe, expect, it, vi, beforeEach } from 'vitest'
import { useAccount } from 'wagmi'
import { BoosterProvider, useFetchBoostData, useNFTBoosterContext } from './BoosterContext'

Expand Down
7 changes: 5 additions & 2 deletions src/app/providers/NFT/BoosterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AVERAGE_BLOCKTIME, NFT_BOOSTER_DATA_URL } from '@/lib/constants'
import { useQuery } from '@tanstack/react-query'
import axios from 'axios'
import { createContext, ReactNode, useContext, useMemo } from 'react'
import { Address } from 'viem'
import { Address, isAddressEqual } from 'viem'
import { useAccount } from 'wagmi'

interface HolderRewards {
Expand Down Expand Up @@ -52,7 +52,10 @@ export const BoosterProvider = ({ children }: BoosterContextProviderProps) => {
return { boostData, isLoading, error, hasActiveCampaign }
}

const currentBoost = boostData?.holders[address]
const [, currentBoost] =
Object.entries(boostData?.holders ?? {}).find(
([key]) => key.toLocaleLowerCase() === address.toLocaleLowerCase(),
) ?? []
const isBoosted =
currentBoost &&
(currentBoost.boostedRBTCRewards > 0 ||
Expand Down
8 changes: 4 additions & 4 deletions src/app/shared/components/NFTBoosterCard/NFTBoosterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const NFTBoosterCard: FC<NFTBoosterCardProps> = ({ nftThumbPath, boostVal
>
<g filter="url(#filter0_f_773_18628)">
<path
fill-rule="evenodd"
clip-rule="evenodd"
fillRule="evenodd"
clipRule="evenodd"
d="M17.7212 18.0696H259.721V74.0696H17.7212V18.0696ZM21.7212 22.0696V70.0696H255.721V22.0696H21.7212Z"
fill="url(#paint0_linear_773_18628)"
/>
Expand All @@ -34,9 +34,9 @@ export const NFTBoosterCard: FC<NFTBoosterCardProps> = ({ nftThumbPath, boostVal
width="276.2"
height="90.2"
filterUnits="userSpaceOnUse"
color-interpolation-filters="sRGB"
colorInterpolationFilters="sRGB"
>
<feFlood flood-opacity="0" result="BackgroundImageFix" />
<feFlood floodOpacity="0" result="BackgroundImageFix" />
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
<feGaussianBlur stdDeviation="8.55" result="effect1_foregroundBlur_773_18628" />
</filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useNFTBoosterContext } from '@/app/providers/NFT/BoosterContext'
import { NFTBoosterCard } from '@/app/shared/components'
import { FC } from 'react'
import { communitiesMapByContract } from '../../../communities/communityUtils'
import { communitiesMapByContract } from '@/app/communities/communityUtils'

export const SelfContainedNFTBoosterCard: FC = () => {
const { hasActiveCampaign, currentBoost, boostData } = useNFTBoosterContext()
const { title } = communitiesMapByContract[boostData?.nftContractAddress ?? ''] ?? {}
const { title } = boostData?.nftContractAddress
? communitiesMapByContract[boostData.nftContractAddress.toLowerCase()]
: {}

return (
hasActiveCampaign &&
Expand Down

0 comments on commit 998587f

Please sign in to comment.