1
1
<template >
2
2
<div class =" py-8 lg:py-16" >
3
3
<div class =" max-w-lg mx-auto flex flex-col gap-12" >
4
- <h1 class =" font-medium text-center text-2xl" >Lookup avatar on {{ chain.name }}</h1 >
4
+ <div class =" flex justify-center items-center gap-3" >
5
+ <h1 class =" font-medium text-center text-2xl" >Lookup avatar on</h1 >
6
+ <select class =" select" v-model =" selectedChain" >
7
+ <template v-for =" chain in chains " >
8
+ <option :value =" chain" >{{ chain.name }}</option >
9
+ </template >
10
+ </select >
11
+ </div >
5
12
<div class =" flex gap-2" >
6
13
<input class =" input" type =" text" placeholder =" Search on address.." v-model =" walletAddress" >
7
14
<button :disabled =" !isSearchValid" @click =" search" class =" px-6 h-14 flex gap-2 flex-nowrap justify-center items-center bg-blue-500/20 hover:bg-blue-500/25 disabled:bg-neutral-100 font-medium text-blue-500 disabled:text-neutral-400/75 rounded-2xl duration-300" >Go</button >
15
22
16
23
<script setup>
17
24
import {onMounted , ref } from " vue" ;
18
- import {useAccount , useConnect } from " @wagmi/vue" ;
25
+ import {useAccount , useChains , useConnect } from " @wagmi/vue" ;
19
26
import {isAddress , zeroAddress } from " viem" ;
20
27
import AvatarViewer from " ~/components/AvatarViewer.vue" ;
21
28
22
- const { connect } = useConnect ();
23
- const { chainId , chain } = useAccount ();
29
+ const { connect , isConnected } = useConnect ();
24
30
const {setAvatar , getAvatarInfo } = useAvatarService ();
25
31
const {getAvatarForAddress } = useAvatarServiceApi ();
26
32
const route = useRoute ();
27
33
const router = useRouter ();
34
+ const chains = useChains ();
28
35
29
36
const IPFS_GATEWAY = " https://ipfs.io/ipfs/" ;
30
37
@@ -33,14 +40,15 @@ const fetchedWalletAddress = ref("");
33
40
const avatarInfo = ref (null );
34
41
const avatarMetadata = ref (null );
35
42
const imageLink = ref (" " );
43
+ const selectedChain = ref (chains .value [0 ]);
36
44
37
45
onMounted (() => {
38
46
if (walletAddress .value ) {
39
47
updateAvatarInfo ();
40
48
}
41
49
});
42
50
43
- watch (chainId , () => {
51
+ watch (selectedChain , () => {
44
52
updateAvatarInfo ();
45
53
});
46
54
@@ -64,7 +72,7 @@ async function updateAvatarInfo() {
64
72
65
73
const apiRes = await getAvatarForAddress (address);
66
74
67
- const chainName = chain .value .name .toLowerCase ();
75
+ const chainName = selectedChain .value .name .toLowerCase ();
68
76
69
77
avatarInfo .value = {
70
78
avatar: {
@@ -96,4 +104,8 @@ async function updateAvatarInfo() {
96
104
.input {
97
105
@apply bg- neutral- 100 p- 4 placeholder- neutral- 300 rounded- 2xl w- full;
98
106
}
107
+
108
+ .select {
109
+ @apply bg- neutral- 100 p- 4 placeholder- neutral- 300 rounded- 2xl ;
110
+ }
99
111
< / style>
0 commit comments