Skip to content

Commit b34e7e9

Browse files
committed
torch nft
1 parent 9b4d788 commit b34e7e9

File tree

13 files changed

+1082
-1518
lines changed

13 files changed

+1082
-1518
lines changed

app/[locale]/10years/_components/CurrentTorchHolderCard.tsx

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import blockies from "ethereum-blockies-base64"
2-
import type { Address } from "viem"
3-
import { sepolia } from "viem/chains"
4-
import { createConfig, getPublicClient, http } from "@wagmi/core"
5-
6-
import { Image } from "@/components/Image"
71
import {
82
AvatarBase as Avatar,
93
AvatarFallback,
104
AvatarImage,
115
} from "@/components/ui/avatar"
12-
import { Button } from "@/components/ui/buttons/Button"
6+
import { ButtonLink } from "@/components/ui/buttons/Button"
137
import {
148
Card,
159
CardContent,
@@ -22,100 +16,77 @@ import { BaseLink } from "@/components/ui/Link"
2216
import { cn } from "@/lib/utils/cn"
2317

2418
import Curved10YearsText from "./10y.svg"
25-
import Torch from "./Torch.json"
26-
27-
import type { TorchHolder } from "@/lib/api/fetchTorchHolders"
28-
import TorchImage from "@/public/images/10-year-anniversary/torch.png"
29-
30-
const TORCH_CONTRACT_ADDRESS = Torch.address as Address
31-
const TORCH_ABI = Torch.abi
3219

33-
export const config = createConfig({
34-
chains: [sepolia],
35-
transports: {
36-
[sepolia.id]: http(
37-
`https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
38-
),
39-
},
40-
})
20+
import {
21+
formatAddress,
22+
getBlockieImage,
23+
type TorchHolderMetadata,
24+
} from "@/lib/torch"
4125

4226
interface CurrentTorchHolderCardProps {
43-
holderLookup?: Record<string, unknown>
27+
currentHolder: TorchHolderMetadata
4428
className?: string
4529
}
4630

47-
const CurrentTorchHolderCard = async ({
48-
holderLookup,
31+
const CurrentTorchHolderCard = ({
32+
currentHolder,
4933
className,
5034
}: CurrentTorchHolderCardProps) => {
51-
const publicClient = getPublicClient(config)
52-
53-
// Read current holder from contract
54-
const currentHolder = (await publicClient.readContract({
55-
address: TORCH_CONTRACT_ADDRESS,
56-
abi: TORCH_ABI,
57-
functionName: "currentHolder",
58-
})) as Address
59-
60-
const formatAddress = (address: Address) => {
61-
return `${address.slice(0, 6)}...${address.slice(-4)}`
62-
}
63-
64-
const getBlockieImage = (address: Address) => {
65-
return blockies(address)
66-
}
67-
68-
let holderData: TorchHolder | null = null
69-
if (currentHolder && holderLookup) {
70-
holderData = holderLookup[currentHolder.toLowerCase()] as TorchHolder
71-
}
72-
7335
return (
7436
<Card
7537
className={cn("w-full overflow-hidden rounded-3xl shadow-xl", className)}
7638
>
77-
<CardHeader className="p-0">
78-
<CardTitle className="relative flex flex-col items-center justify-center bg-[#18193A] p-0 pb-6">
39+
<CardHeader className="bg-[#18193A]">
40+
<div className="relative">
7941
{/* Torch/flame video */}
80-
<div className="mt-24 flex items-center justify-center">
81-
{/* <video
42+
<div className="flex items-center justify-center pt-12">
43+
<video
44+
className="h-[170px] w-[170px] object-cover"
8245
src="/videos/torch.mp4"
46+
aria-label="Torch video"
8347
autoPlay
8448
loop
8549
muted
86-
/> */}
87-
88-
<Image src={TorchImage} alt="Torch" width={170} height={170} />
50+
poster="/images/10-year-anniversary/torch-cover.png"
51+
/>
8952
</div>
90-
{/* Curved text */}
91-
<Curved10YearsText className="absolute left-1/2 top-6 -translate-x-1/2" />
92-
</CardTitle>
53+
54+
<CardTitle className="p-0">
55+
{/* Curved text */}
56+
<Curved10YearsText
57+
viewBox="0 0 356 186"
58+
className="absolute left-1/2 top-0 h-min w-full max-w-[600px] -translate-x-1/2"
59+
width="100%"
60+
height="auto"
61+
/>
62+
</CardTitle>
63+
</div>
9364
</CardHeader>
9465
{/* Bottom section: torchbearer info */}
9566
<CardContent className="p-6">
9667
{currentHolder ? (
9768
<div className="flex items-start gap-4">
98-
<Avatar className="h-19 w-19">
69+
<Avatar className="h-19 w-19 !shadow-none">
9970
<AvatarImage
100-
src={holderData?.imageUrl || getBlockieImage(currentHolder)}
101-
alt={`Avatar for ${holderData?.name || currentHolder}`}
71+
src={getBlockieImage(currentHolder.address)}
72+
alt={`Avatar for ${currentHolder.name || currentHolder.address}`}
10273
/>
10374
<AvatarFallback>
104-
{holderData?.name || formatAddress(currentHolder)}
75+
{currentHolder.name || formatAddress(currentHolder.address)}
10576
</AvatarFallback>
10677
</Avatar>
10778

10879
<div className="flex flex-col">
10980
{/* Name */}
11081
<div className="text-lg font-bold leading-none">
111-
{holderData?.name || formatAddress(currentHolder)}
82+
{currentHolder.name || formatAddress(currentHolder.address)}
11283
</div>
11384
{/* Description */}
114-
<div>{holderData?.description || "Current torchbearer"}</div>
85+
<div>{currentHolder.role || "Current torchbearer"}</div>
11586
{/* Verify onchain link */}
11687
<BaseLink
11788
className="mt-2 text-xs"
118-
href={`https://sepolia.etherscan.io/address/${currentHolder}`}
89+
href={`https://sepolia.etherscan.io/address/${currentHolder.address}`}
11990
>
12091
View on Etherscan
12192
</BaseLink>
@@ -126,7 +97,9 @@ const CurrentTorchHolderCard = async ({
12697
)}
12798
</CardContent>
12899
<CardFooter className="justify-center pt-4">
129-
<Button variant="outline">See all torchbearers</Button>
100+
<ButtonLink href="#torch-history" variant="outline">
101+
See all torchbearers
102+
</ButtonLink>
130103
</CardFooter>
131104
</Card>
132105
)

0 commit comments

Comments
 (0)