From 61c0e01c8327ac80f1e19f3e5150656f2a897acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20Uzdo=C4=9Fan?= Date: Fri, 21 Jun 2024 16:57:20 +0300 Subject: [PATCH] Modify .prettierrc and prettify `contract-verification-plugin` folder --- .prettierrc.json | 4 +-- apps/contract-verification/.babelrc | 10 ++---- apps/contract-verification/.eslintrc | 4 +-- apps/contract-verification/src/app/App.css | 2 +- .../src/app/AppContext.tsx | 10 +++--- .../app/ContractVerificationPluginClient.ts | 4 +-- .../src/app/Receipts/EtherscanReceipt.tsx | 8 ++--- .../src/app/Receipts/SourcifyReceipt.tsx | 10 +++--- .../src/app/Receipts/props.ts | 4 +-- .../src/app/Verifiers/AbstractVerifier.ts | 6 ++-- .../src/app/Verifiers/EtherscanVerifier.ts | 8 ++--- .../src/app/Verifiers/SourcifyVerifier.ts | 10 +++--- apps/contract-verification/src/app/app.tsx | 26 +++++++------- .../src/app/components/AccordionReceipt.tsx | 4 +-- .../app/components/ConstructorArguments.tsx | 12 +++---- .../src/app/components/ContractDropdown.tsx | 10 +++--- .../src/app/components/NavMenu.tsx | 6 ++-- .../src/app/components/SearchableDropdown.tsx | 12 +++---- .../src/app/components/index.tsx | 6 ++-- .../src/app/hooks/useLocalStorage.tsx | 2 +- .../src/app/layouts/Default.tsx | 6 ++-- .../src/app/layouts/index.ts | 2 +- apps/contract-verification/src/app/routes.tsx | 8 ++--- .../src/app/types/ThemeType.ts | 2 +- .../src/app/types/VerificationTypes.ts | 8 ++--- .../src/app/views/ReceiptsView.tsx | 6 ++-- .../src/app/views/VerifyView.tsx | 34 +++++++++---------- .../src/app/views/index.ts | 2 +- .../src/environments/environment.prod.ts | 4 +-- .../src/environments/environment.ts | 4 +-- apps/contract-verification/src/index.html | 3 +- apps/contract-verification/src/main.tsx | 10 ++---- apps/contract-verification/src/polyfills.ts | 4 +-- apps/contract-verification/webpack.config.js | 22 ++++++------ 34 files changed, 131 insertions(+), 142 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 07681f5b0a..967e2ecc37 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,9 +1,7 @@ { "tabWidth": 2, "printWidth": 500, - "bracketSpacing": false, "useTabs": false, "semi": false, - "singleQuote": true, - "bracketSpacing": false + "singleQuote": true } diff --git a/apps/contract-verification/.babelrc b/apps/contract-verification/.babelrc index e37036ce66..6df3e5be52 100644 --- a/apps/contract-verification/.babelrc +++ b/apps/contract-verification/.babelrc @@ -1,9 +1,5 @@ { - "presets": ["@babel/preset-env", ["@babel/preset-react", - {"runtime": "automatic"} - ]], + "presets": ["@babel/preset-env", ["@babel/preset-react", { "runtime": "automatic" }]], "plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime", "@babel/plugin-proposal-nullish-coalescing-operator"], - "ignore": [ - "**/node_modules/**" - ] -} \ No newline at end of file + "ignore": ["**/node_modules/**"] +} diff --git a/apps/contract-verification/.eslintrc b/apps/contract-verification/.eslintrc index 2d85f9fa66..be97c53fbb 100644 --- a/apps/contract-verification/.eslintrc +++ b/apps/contract-verification/.eslintrc @@ -1,3 +1,3 @@ { - "extends": "../../.eslintrc.json", -} \ No newline at end of file + "extends": "../../.eslintrc.json" +} diff --git a/apps/contract-verification/src/app/App.css b/apps/contract-verification/src/app/App.css index 74a89ee342..6b8ef2820e 100644 --- a/apps/contract-verification/src/app/App.css +++ b/apps/contract-verification/src/app/App.css @@ -4,4 +4,4 @@ body { #root { padding: 8px 14px; -} \ No newline at end of file +} diff --git a/apps/contract-verification/src/app/AppContext.tsx b/apps/contract-verification/src/app/AppContext.tsx index 2de02cb07e..eacd43f056 100644 --- a/apps/contract-verification/src/app/AppContext.tsx +++ b/apps/contract-verification/src/app/AppContext.tsx @@ -1,15 +1,15 @@ import React from 'react' -import {ThemeType} from './types' -import {Chain, SubmittedContracts} from './types/VerificationTypes' -import {CompilerAbstract} from '@remix-project/remix-solidity' -import {AbstractVerifier} from './Verifiers/AbstractVerifier' +import { ThemeType } from './types' +import { Chain, SubmittedContracts } from './types/VerificationTypes' +import { CompilerAbstract } from '@remix-project/remix-solidity' +import { AbstractVerifier } from './Verifiers/AbstractVerifier' // Define the type for the context type AppContextType = { themeType: ThemeType setThemeType: (themeType: ThemeType) => void chains: Chain[] - compilationOutput: {[key: string]: CompilerAbstract} | undefined + compilationOutput: { [key: string]: CompilerAbstract } | undefined selectedContractFileAndName: string | undefined setSelectedContractFileAndName: React.Dispatch> targetFileName: string | undefined diff --git a/apps/contract-verification/src/app/ContractVerificationPluginClient.ts b/apps/contract-verification/src/app/ContractVerificationPluginClient.ts index a72b7b764e..47e45c8cbc 100644 --- a/apps/contract-verification/src/app/ContractVerificationPluginClient.ts +++ b/apps/contract-verification/src/app/ContractVerificationPluginClient.ts @@ -1,5 +1,5 @@ -import {PluginClient} from '@remixproject/plugin' -import {createClient} from '@remixproject/plugin-webview' +import { PluginClient } from '@remixproject/plugin' +import { createClient } from '@remixproject/plugin-webview' import EventManager from 'events' export class ContractVerificationPluginClient extends PluginClient { diff --git a/apps/contract-verification/src/app/Receipts/EtherscanReceipt.tsx b/apps/contract-verification/src/app/Receipts/EtherscanReceipt.tsx index 613d99a991..34ce9eb1f4 100644 --- a/apps/contract-verification/src/app/Receipts/EtherscanReceipt.tsx +++ b/apps/contract-verification/src/app/Receipts/EtherscanReceipt.tsx @@ -1,8 +1,8 @@ -import React, {useState, useEffect} from 'react' -import {EtherscanVerifier} from '../Verifiers/EtherscanVerifier' -import {ReceiptProps} from './props' +import React, { useState, useEffect } from 'react' +import { EtherscanVerifier } from '../Verifiers/EtherscanVerifier' +import { ReceiptProps } from './props' -export const EtherscanReceipt: React.FC = ({verifyPromise, address, chainId, verifier}) => { +export const EtherscanReceipt: React.FC = ({ verifyPromise, address, chainId, verifier }) => { const [status, setStatus] = useState(null) const [submissionDate] = useState(new Date()) diff --git a/apps/contract-verification/src/app/Receipts/SourcifyReceipt.tsx b/apps/contract-verification/src/app/Receipts/SourcifyReceipt.tsx index 5d757a7a4b..066544c099 100644 --- a/apps/contract-verification/src/app/Receipts/SourcifyReceipt.tsx +++ b/apps/contract-verification/src/app/Receipts/SourcifyReceipt.tsx @@ -1,10 +1,10 @@ -import React, {useState, useEffect} from 'react' -import {SourcifyVerifier} from '../Verifiers/SourcifyVerifier' -import {SourcifyVerificationStatus} from '../types/VerificationTypes' -import {ReceiptProps} from './props' +import React, { useState, useEffect } from 'react' +import { SourcifyVerifier } from '../Verifiers/SourcifyVerifier' +import { SourcifyVerificationStatus } from '../types/VerificationTypes' +import { ReceiptProps } from './props' // A receipt is something to be rendered -export const SourcifyReceipt: React.FC = ({verifyPromise, address, chainId, verifier}) => { +export const SourcifyReceipt: React.FC = ({ verifyPromise, address, chainId, verifier }) => { const [status, setStatus] = useState(null) const [submissionDate] = useState(new Date()) // This will be set once and not change diff --git a/apps/contract-verification/src/app/Receipts/props.ts b/apps/contract-verification/src/app/Receipts/props.ts index 00c0119b8d..e1f4b1e60f 100644 --- a/apps/contract-verification/src/app/Receipts/props.ts +++ b/apps/contract-verification/src/app/Receipts/props.ts @@ -1,5 +1,5 @@ -import {EtherscanVerifier} from '../Verifiers/EtherscanVerifier' -import {SourcifyVerifier} from '../Verifiers/SourcifyVerifier' +import { EtherscanVerifier } from '../Verifiers/EtherscanVerifier' +import { SourcifyVerifier } from '../Verifiers/SourcifyVerifier' export interface ReceiptProps { verifyPromise: Promise diff --git a/apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts b/apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts index ce6cc643a8..651eec6a3a 100644 --- a/apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts @@ -1,6 +1,6 @@ -import {CompilerAbstract} from '@remix-project/remix-solidity' -import {SourcifyReceipt} from '../Receipts/SourcifyReceipt' -import {EtherscanReceipt} from '../Receipts/EtherscanReceipt' +import { CompilerAbstract } from '@remix-project/remix-solidity' +import { SourcifyReceipt } from '../Receipts/SourcifyReceipt' +import { EtherscanReceipt } from '../Receipts/EtherscanReceipt' export abstract class AbstractVerifier { name: string diff --git a/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts b/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts index 465948e3a9..f839010110 100644 --- a/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts @@ -1,7 +1,7 @@ -import {CompilerAbstract} from '@remix-project/remix-solidity' -import {AbstractVerifier} from './AbstractVerifier' -import {EtherscanReceipt} from '../Receipts/EtherscanReceipt' -import {EtherscanRequest, EtherscanResponse} from '../types/VerificationTypes' +import { CompilerAbstract } from '@remix-project/remix-solidity' +import { AbstractVerifier } from './AbstractVerifier' +import { EtherscanReceipt } from '../Receipts/EtherscanReceipt' +import { EtherscanRequest, EtherscanResponse } from '../types/VerificationTypes' export class EtherscanVerifier extends AbstractVerifier { apiKey: string diff --git a/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts b/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts index 7e3865f198..a26c3ffb7d 100644 --- a/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts +++ b/apps/contract-verification/src/app/Verifiers/SourcifyVerifier.ts @@ -1,7 +1,7 @@ -import {CompilerAbstract, SourcesCode} from '@remix-project/remix-solidity' -import {AbstractVerifier} from './AbstractVerifier' -import {SourcifyReceipt} from '../Receipts/SourcifyReceipt' -import {SourcifyVerificationError, SourcifyVerificationResponse} from '../types/VerificationTypes' +import { CompilerAbstract, SourcesCode } from '@remix-project/remix-solidity' +import { AbstractVerifier } from './AbstractVerifier' +import { SourcifyReceipt } from '../Receipts/SourcifyReceipt' +import { SourcifyVerificationError, SourcifyVerificationResponse } from '../types/VerificationTypes' export class SourcifyVerifier extends AbstractVerifier { constructor(apiUrl: string, name: string = 'Sourcify') { @@ -21,7 +21,7 @@ export class SourcifyVerifier extends AbstractVerifier { // from { "filename.sol": {content: "contract MyContract { ... }"} } // to { "filename.sol": "contract MyContract { ... }" } - const formattedSources = Object.entries(sources).reduce((acc, [fileName, {content}]) => { + const formattedSources = Object.entries(sources).reduce((acc, [fileName, { content }]) => { acc[fileName] = content return acc }, {}) diff --git a/apps/contract-verification/src/app/app.tsx b/apps/contract-verification/src/app/app.tsx index 50394ecf5d..ff81b1be56 100644 --- a/apps/contract-verification/src/app/app.tsx +++ b/apps/contract-verification/src/app/app.tsx @@ -1,17 +1,17 @@ -import React, {useState, useEffect, useRef} from 'react' +import React, { useState, useEffect, useRef } from 'react' -import {ContractVerificationPluginClient} from './ContractVerificationPluginClient' +import { ContractVerificationPluginClient } from './ContractVerificationPluginClient' -import {AppContext} from './AppContext' +import { AppContext } from './AppContext' import DisplayRoutes from './routes' -import {ThemeType} from './types' +import { ThemeType } from './types' import './App.css' -import {Chain, SubmittedContracts} from './types/VerificationTypes' -import {CompilerAbstract} from '@remix-project/remix-solidity' -import {SourcifyVerifier} from './Verifiers/SourcifyVerifier' -import {EtherscanVerifier} from './Verifiers/EtherscanVerifier' -import {AbstractVerifier} from './Verifiers/AbstractVerifier' +import { Chain, SubmittedContracts } from './types/VerificationTypes' +import { CompilerAbstract } from '@remix-project/remix-solidity' +import { SourcifyVerifier } from './Verifiers/SourcifyVerifier' +import { EtherscanVerifier } from './Verifiers/EtherscanVerifier' +import { AbstractVerifier } from './Verifiers/AbstractVerifier' const plugin = new ContractVerificationPluginClient() @@ -20,7 +20,7 @@ const App = () => { // TODO: Types for chains const [chains, setChains] = useState([]) // State to hold the chains data const [targetFileName, setTargetFileName] = useState('') - const [compilationOutput, setCompilationOutput] = useState<{[key: string]: CompilerAbstract} | undefined>() + const [compilationOutput, setCompilationOutput] = useState<{ [key: string]: CompilerAbstract } | undefined>() // Contract file and name in format contracts/Storage.sol:contracts/Owner.sol:Owner // TODO: What happens if contract or filepath contains ":"" ? const [selectedContractFileAndName, setSelectedContractFileAndName] = useState() @@ -46,10 +46,10 @@ const App = () => { }) // Subscribe to compilations - plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstract: {[key: string]: CompilerAbstract}) => { + plugin.on('compilerArtefacts' as any, 'compilationSaved', (compilerAbstract: { [key: string]: CompilerAbstract }) => { console.log('compilerArtefacts.compilationSaved') console.log(compilerAbstract) - setCompilationOutput((prev) => ({...(prev || {}), ...compilerAbstract})) + setCompilationOutput((prev) => ({ ...(prev || {}), ...compilerAbstract })) }) // TODO: Is there a way to get all compilations from the `build-info` files without having to compile again? @@ -67,7 +67,7 @@ const App = () => { }, []) return ( - + ) diff --git a/apps/contract-verification/src/app/components/AccordionReceipt.tsx b/apps/contract-verification/src/app/components/AccordionReceipt.tsx index 9ec05c8a99..c6631d37b3 100644 --- a/apps/contract-verification/src/app/components/AccordionReceipt.tsx +++ b/apps/contract-verification/src/app/components/AccordionReceipt.tsx @@ -1,12 +1,12 @@ import React from 'react' -import {SubmittedContract} from '../types/VerificationTypes' +import { SubmittedContract } from '../types/VerificationTypes' interface AccordionReceiptProps { contract: SubmittedContract index: number } -export const AccordionReceipt: React.FC = ({contract, index}) => { +export const AccordionReceipt: React.FC = ({ contract, index }) => { const [expanded, setExpanded] = React.useState(false) const toggleAccordion = () => { diff --git a/apps/contract-verification/src/app/components/ConstructorArguments.tsx b/apps/contract-verification/src/app/components/ConstructorArguments.tsx index 94bcc829f7..22f257e217 100644 --- a/apps/contract-verification/src/app/components/ConstructorArguments.tsx +++ b/apps/contract-verification/src/app/components/ConstructorArguments.tsx @@ -1,7 +1,7 @@ -import React, {useEffect} from 'react' -import {ethers} from 'ethers' +import React, { useEffect } from 'react' +import { ethers } from 'ethers' -import {AppContext} from '../AppContext' +import { AppContext } from '../AppContext' const abiCoder = new ethers.utils.AbiCoder() @@ -10,8 +10,8 @@ interface ConstructorArgumentsProps { setAbiEncodedConstructorArgs: React.Dispatch> } -export const ConstructorArguments: React.FC = ({abiEncodedConstructorArgs, setAbiEncodedConstructorArgs}) => { - const {selectedContractFileAndName, compilationOutput} = React.useContext(AppContext) +export const ConstructorArguments: React.FC = ({ abiEncodedConstructorArgs, setAbiEncodedConstructorArgs }) => { + const { selectedContractFileAndName, compilationOutput } = React.useContext(AppContext) const [constructorArgsValues, setConstructorArgsValues] = React.useState([]) const [abiEncodingError, setAbiEncodingError] = React.useState('') const [toggleRawInput, setToggleRawInput] = React.useState(false) @@ -101,7 +101,7 @@ export const ConstructorArguments: React.FC = ({abiEn -