22
33import { FormFieldSetup } from "@/components/blocks/FormFieldSetup" ;
44import { Button } from "@/components/ui/button" ;
5- import {
6- Select ,
7- SelectContent ,
8- SelectItem ,
9- SelectTrigger ,
10- SelectValue ,
11- } from "@/components/ui/select" ;
5+ import { Input } from "@/components/ui/input" ;
126import { Separator } from "@/components/ui/separator" ;
137import { cn } from "@/lib/utils" ;
148import { zodResolver } from "@hookform/resolvers/zod" ;
@@ -19,8 +13,7 @@ import * as z from "zod";
1913import { Fieldset } from "components/contract-components/contract-deploy-form/common" ;
2014import { SolidityInput } from "contract-ui/components/solidity-inputs" ;
2115import { Form } from "@/components/ui/form" ;
22- import { useAllChainsData } from "hooks/chains/allChains" ;
23- import type { StoredChain } from "stores/chainStores" ;
16+ import { NetworkSelectorButton } from "components/selects/NetworkSelectorButton" ;
2417
2518// Form schema
2619const contractDetailsSchema = z . object ( {
@@ -66,9 +59,6 @@ export default function ImportAssetPage() {
6659 const [ contractDetails , setContractDetails ] =
6760 useState < ContractDetailsValues > ( ) ;
6861
69- // Get chain data
70- const { allChains } = useAllChainsData ( ) ;
71-
7262 // Form
7363 const contractDetailsForm = useForm < ContractDetailsValues > ( {
7464 resolver : zodResolver ( contractDetailsSchema ) ,
@@ -154,34 +144,13 @@ export default function ImportAssetPage() {
154144 errorMessage = {
155145 contractDetailsForm . formState . errors . network ?. message
156146 }
157- helperText = "Select the blockchain where the contract is deployed"
158147 >
159- < Select
160- defaultValue = { contractDetailsForm . watch ( "network" ) }
161- onValueChange = { ( value ) =>
162- contractDetailsForm . setValue ( "network" , value )
163- }
164- >
165- < SelectTrigger id = "network" >
166- < SelectValue placeholder = "Select network" />
167- </ SelectTrigger >
168- < SelectContent className = "max-h-[300px]" >
169- { allChains . map ( ( chain : StoredChain ) => (
170- < SelectItem key = { chain . chainId } value = { chain . name } >
171- < div className = "flex items-center gap-2" >
172- { chain . icon ?. url && (
173- < img
174- src = { chain . icon . url }
175- alt = { chain . name }
176- className = "w-4 h-4 rounded-full"
177- />
178- ) }
179- { chain . name }
180- </ div >
181- </ SelectItem >
182- ) ) }
183- </ SelectContent >
184- </ Select >
148+ < NetworkSelectorButton
149+ className = "bg-background"
150+ onSwitchChain = { ( chain ) => {
151+ contractDetailsForm . setValue ( "network" , chain . name ) ;
152+ } }
153+ />
185154 </ FormFieldSetup >
186155 </ div >
187156
0 commit comments