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"
7
1
import {
8
2
AvatarBase as Avatar ,
9
3
AvatarFallback ,
10
4
AvatarImage ,
11
5
} from "@/components/ui/avatar"
12
- import { Button } from "@/components/ui/buttons/Button"
6
+ import { ButtonLink } from "@/components/ui/buttons/Button"
13
7
import {
14
8
Card ,
15
9
CardContent ,
@@ -22,100 +16,77 @@ import { BaseLink } from "@/components/ui/Link"
22
16
import { cn } from "@/lib/utils/cn"
23
17
24
18
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
32
19
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"
41
25
42
26
interface CurrentTorchHolderCardProps {
43
- holderLookup ?: Record < string , unknown >
27
+ currentHolder : TorchHolderMetadata
44
28
className ?: string
45
29
}
46
30
47
- const CurrentTorchHolderCard = async ( {
48
- holderLookup ,
31
+ const CurrentTorchHolderCard = ( {
32
+ currentHolder ,
49
33
className,
50
34
} : 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
-
73
35
return (
74
36
< Card
75
37
className = { cn ( "w-full overflow-hidden rounded-3xl shadow-xl" , className ) }
76
38
>
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" >
79
41
{ /* 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"
82
45
src = "/videos/torch.mp4"
46
+ aria-label = "Torch video"
83
47
autoPlay
84
48
loop
85
49
muted
86
- /> */ }
87
-
88
- < Image src = { TorchImage } alt = "Torch" width = { 170 } height = { 170 } />
50
+ poster = "/images/10-year-anniversary/torch-cover.png"
51
+ />
89
52
</ 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 >
93
64
</ CardHeader >
94
65
{ /* Bottom section: torchbearer info */ }
95
66
< CardContent className = "p-6" >
96
67
{ currentHolder ? (
97
68
< div className = "flex items-start gap-4" >
98
- < Avatar className = "h-19 w-19" >
69
+ < Avatar className = "h-19 w-19 !shadow-none " >
99
70
< 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 } ` }
102
73
/>
103
74
< AvatarFallback >
104
- { holderData ? .name || formatAddress ( currentHolder ) }
75
+ { currentHolder . name || formatAddress ( currentHolder . address ) }
105
76
</ AvatarFallback >
106
77
</ Avatar >
107
78
108
79
< div className = "flex flex-col" >
109
80
{ /* Name */ }
110
81
< div className = "text-lg font-bold leading-none" >
111
- { holderData ? .name || formatAddress ( currentHolder ) }
82
+ { currentHolder . name || formatAddress ( currentHolder . address ) }
112
83
</ div >
113
84
{ /* Description */ }
114
- < div > { holderData ?. description || "Current torchbearer" } </ div >
85
+ < div > { currentHolder . role || "Current torchbearer" } </ div >
115
86
{ /* Verify onchain link */ }
116
87
< BaseLink
117
88
className = "mt-2 text-xs"
118
- href = { `https://sepolia.etherscan.io/address/${ currentHolder } ` }
89
+ href = { `https://sepolia.etherscan.io/address/${ currentHolder . address } ` }
119
90
>
120
91
View on Etherscan
121
92
</ BaseLink >
@@ -126,7 +97,9 @@ const CurrentTorchHolderCard = async ({
126
97
) }
127
98
</ CardContent >
128
99
< 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 >
130
103
</ CardFooter >
131
104
</ Card >
132
105
)
0 commit comments