diff --git a/app/components/VerificationForm.tsx b/app/components/VerificationForm.tsx index 9d4cdf0..6338c97 100644 --- a/app/components/VerificationForm.tsx +++ b/app/components/VerificationForm.tsx @@ -28,9 +28,10 @@ import { IoSettings } from "react-icons/io5"; interface VerificationFormProps { preselectedChainId?: string; preselectedAddress?: string; + hideImport?: boolean; } -export default function VerificationForm({ preselectedChainId, preselectedAddress }: VerificationFormProps) { +export default function VerificationForm({ preselectedChainId, preselectedAddress, hideImport }: VerificationFormProps) { const { serverUrl } = useServerConfig(); const { chains } = useChains(); const { solidityVersions, vyperVersions } = useCompilerVersions(); @@ -330,17 +331,18 @@ export default function VerificationForm({ preselectedChainId, preselectedAddres preselectedAddress={preselectedAddress} /> - + {!hideImport && ( + )} @@ -369,8 +371,8 @@ export default function VerificationForm({ preselectedChainId, preselectedAddres selectedMethod === "metadata-json" ? handleMetadataFileChange : selectedMethod === "build-info" - ? handleBuildInfoFileChange - : handleFilesChange + ? handleBuildInfoFileChange + : handleFilesChange } uploadedFiles={ selectedMethod === "metadata-json" ? (metadataFile ? [metadataFile] : []) : uploadedFiles @@ -383,7 +385,7 @@ export default function VerificationForm({ preselectedChainId, preselectedAddres {}} + onValidationChange={() => { }} /> {/* Render an additional file upload for the sources when the method is metadata-json. We can treat the sources' file upload as a multiple-files case. */} @@ -446,11 +448,10 @@ export default function VerificationForm({ preselectedChainId, preselectedAddres {isSubmitting && ( @@ -482,7 +483,7 @@ export default function VerificationForm({ preselectedChainId, preselectedAddres {/* Settings Modal */} - setShowSettingsModal(false)} /> + setShowSettingsModal(false)} hideImportSettings={hideImport} /> > ); } \ No newline at end of file diff --git a/app/components/verification/Settings.tsx b/app/components/verification/Settings.tsx index 352cd56..e55fde7 100644 --- a/app/components/verification/Settings.tsx +++ b/app/components/verification/Settings.tsx @@ -9,9 +9,10 @@ import { getEtherscanApiKey, setEtherscanApiKey, removeEtherscanApiKey } from ". interface SettingsProps { isOpen: boolean; onClose: () => void; + hideImportSettings?: boolean; } -export default function Settings({ isOpen, onClose }: SettingsProps) { +export default function Settings({ isOpen, onClose, hideImportSettings }: SettingsProps) { const { serverUrl, setServerUrl, getDefaultServerUrls, customServerUrls, setCustomServerUrls } = useServerConfig(); const [editingCustomUrl, setEditingCustomUrl] = useState(null); const [newCustomUrl, setNewCustomUrl] = useState(""); @@ -293,9 +294,8 @@ export default function Settings({ isOpen, onClose }: SettingsProps) { type="text" value={newCustomUrl} onChange={handleInputChange} - className={`flex-1 px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-cerulean-blue-500 focus:border-cerulean-blue-500 ${ - urlError ? "border-red-300 bg-red-50" : "border-gray-300" - }`} + className={`flex-1 px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-cerulean-blue-500 focus:border-cerulean-blue-500 ${urlError ? "border-red-300 bg-red-50" : "border-gray-300" + }`} placeholder="Enter custom server URL" onKeyDown={handleKeyDown} /> @@ -314,117 +314,118 @@ export default function Settings({ isOpen, onClose }: SettingsProps) { - - API Keys - - - - - - Etherscan API Key (v2) - - - Saved in the browser and not sent to Sourcify servers. - - - - {isEditingApiKey ? ( - - - - setShowEtherscanApiKey(!showEtherscanApiKey)} - className="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-500 hover:text-gray-700" - > - {showEtherscanApiKey ? ( - - ) : ( - - )} - - - - - - Save - - - - Cancel - - - - ) : ( - - - - {etherscanApiKey ? ( - showEtherscanApiKey ? ( - etherscanApiKey + {!hideImportSettings && ( + + API Keys + + + + + + Etherscan API Key (v2) + + + Saved in the browser and not sent to Sourcify servers. + + + + {isEditingApiKey ? ( + + + + setShowEtherscanApiKey(!showEtherscanApiKey)} + className="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-500 hover:text-gray-700" + > + {showEtherscanApiKey ? ( + ) : ( - maskApiKey(etherscanApiKey) - ) - ) : ( - No API key set - )} - - setShowEtherscanApiKey(!showEtherscanApiKey)} - className="p-2 text-gray-600 hover:text-gray-800 hover:bg-gray-50 rounded" - disabled={!etherscanApiKey} - > - {showEtherscanApiKey ? ( - - ) : ( - - )} - - - - - - Edit - - {etherscanApiKey && ( + + )} + + + + + + Save + - Remove + Cancel - )} + - - )} - {etherscanApiKeyError && {etherscanApiKeyError}} + ) : ( + + + + {etherscanApiKey ? ( + showEtherscanApiKey ? ( + etherscanApiKey + ) : ( + maskApiKey(etherscanApiKey) + ) + ) : ( + No API key set + )} + + setShowEtherscanApiKey(!showEtherscanApiKey)} + className="p-2 text-gray-600 hover:text-gray-800 hover:bg-gray-50 rounded" + disabled={!etherscanApiKey} + > + {showEtherscanApiKey ? ( + + ) : ( + + )} + + + + + + Edit + + {etherscanApiKey && ( + + + Remove + + )} + + + )} + {etherscanApiKeyError && {etherscanApiKeyError}} + - + )} diff --git a/app/routes/widget.tsx b/app/routes/widget.tsx index 978c9e7..39c89a4 100644 --- a/app/routes/widget.tsx +++ b/app/routes/widget.tsx @@ -49,7 +49,7 @@ export default function Widget() { - +
- Saved in the browser and not sent to Sourcify servers. -
+ Saved in the browser and not sent to Sourcify servers. +
{etherscanApiKeyError}