Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

refactor: simplify CreatorCoin component's address validation logic and streamline form default values

yoginth.com 1766199b 0d3702cc

verified
Changed files
+3 -20
apps
web
src
components
Settings
+3 -20
apps/web/src/components/Settings/Pro/CreatorCoin.tsx
··· 85 85 ); 86 86 87 87 const form = useZodForm({ 88 - defaultValues: { 89 - creatorCoinAddress: savedCreatorCoinAddress 90 - }, 88 + defaultValues: { creatorCoinAddress: savedCreatorCoinAddress }, 91 89 schema: ValidationSchema 92 90 }); 93 91 ··· 95 93 const isValidAddress = Regex.evmAddress.test(creatorCoinAddress || ""); 96 94 97 95 useEffect(() => { 98 - if (!creatorCoinAddress) return; 99 - const match = creatorCoinAddress.match(/0x[\da-fA-F]{40}/); 100 - if (match?.[0] && match[0] !== creatorCoinAddress) { 101 - form.setValue("creatorCoinAddress", match[0], { 102 - shouldDirty: true, 103 - shouldTouch: true, 104 - shouldValidate: true 105 - }); 106 - } 107 - }, [creatorCoinAddress, form]); 96 + form.setValue("creatorCoinAddress", savedCreatorCoinAddress); 97 + }, [savedCreatorCoinAddress, form]); 108 98 109 99 const { data: coin, isFetching: isFetchingCoin } = useQuery< 110 100 GetCoinResponse["zora20Token"] | null ··· 162 152 ); 163 153 164 154 return await setAccountMetadata({ 165 - onCompleted: async () => { 166 - form.setValue("creatorCoinAddress", "", { 167 - shouldDirty: true, 168 - shouldTouch: true, 169 - shouldValidate: true 170 - }); 171 - }, 172 155 variables: { request: { metadataUri } } 173 156 }); 174 157 };