fixing linting for etherscan

linter rules for solhint
pull/4771/head
lianahus 7 months ago
parent 313cec883e
commit 1d08797503
  1. 8
      apps/etherscan/src/app/EtherscanPluginClient.ts
  2. 6
      apps/etherscan/src/app/utils/utilities.ts
  3. 14
      apps/etherscan/src/app/utils/verify.ts
  4. 15
      apps/solhint/.eslintrc
  5. 1
      apps/solhint/src/app/SolhintPluginClient.ts

@ -1,7 +1,7 @@
import {PluginClient} from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview' import { createClient } from '@remixproject/plugin-webview'
import {verify, EtherScanReturn} from './utils/verify' import { verify, EtherScanReturn } from './utils/verify'
import {getReceiptStatus, getEtherScanApi, getNetworkName, getProxyContractReceiptStatus} from './utils' import { getReceiptStatus, getEtherScanApi, getNetworkName, getProxyContractReceiptStatus } from './utils'
import EventManager from 'events' import EventManager from 'events'
export class EtherscanPluginClient extends PluginClient { export class EtherscanPluginClient extends PluginClient {
@ -46,7 +46,7 @@ export class EtherscanPluginClient extends PluginClient {
async receiptStatus(receiptGuid: string, apiKey: string, isProxyContract: boolean) { async receiptStatus(receiptGuid: string, apiKey: string, isProxyContract: boolean) {
try { try {
const {network, networkId} = await getNetworkName(this) const { network, networkId } = await getNetworkName(this)
if (network === 'vm') { if (network === 'vm') {
throw new Error('Cannot check the receipt status in the selected network') throw new Error('Cannot check the receipt status in the selected network')
} }

@ -4,7 +4,7 @@ import { scanAPIurls } from "./networks"
type RemixClient = PluginClient type RemixClient = PluginClient
/* /*
status: 0=Error, 1=Pass status: 0=Error, 1=Pass
message: OK, NOTOK message: OK, NOTOK
result: explanation result: explanation
*/ */
@ -14,7 +14,7 @@ export type receiptStatus = {
status: string status: string
} }
export const getEtherScanApi = (networkId: any) => { export const getEtherScanApi = (networkId: any) => {
if (!(networkId in scanAPIurls)) { if (!(networkId in scanAPIurls)) {
throw new Error("no known network to verify against") throw new Error("no known network to verify against")
} }
@ -26,7 +26,7 @@ export const getNetworkName = async (client: RemixClient) => {
const network = await client.call("network", "detectNetwork") const network = await client.call("network", "detectNetwork")
if (!network) { if (!network) {
throw new Error("no known network to verify against") throw new Error("no known network to verify against")
} }
return { network: network.name!.toLowerCase(), networkId: network.id } return { network: network.name!.toLowerCase(), networkId: network.id }
} }

@ -23,7 +23,7 @@ export const verify = async (
compilationResultParam: CompilerAbstract, compilationResultParam: CompilerAbstract,
chainRef: number | string, chainRef: number | string,
isProxyContract: boolean, isProxyContract: boolean,
expectedImplAddress: string, expectedImplAddress: string,
client: PluginClient, client: PluginClient,
onVerifiedContract: (value: EtherScanReturn) => void, onVerifiedContract: (value: EtherScanReturn) => void,
setResults: (value: string) => void setResults: (value: string) => void
@ -47,7 +47,7 @@ export const verify = async (
etherscanApi = getEtherScanApi(networkChainId) etherscanApi = getEtherScanApi(networkChainId)
} }
} }
try { try {
const contractMetadata = getContractMetadata( const contractMetadata = getContractMetadata(
// cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository // cast from the remix-plugin interface to the solidity one. Should be fixed when remix-plugin move to the remix-project repository
@ -61,7 +61,7 @@ export const verify = async (
message: "Please recompile contract" message: "Please recompile contract"
} }
} }
const contractMetadataParsed = JSON.parse(contractMetadata) const contractMetadataParsed = JSON.parse(contractMetadata)
const fileName = getContractFileName( const fileName = getContractFileName(
@ -146,9 +146,9 @@ export const verify = async (
title: result, title: result,
}) })
const returnValue = { const returnValue = {
message: result, message: result,
succeed: false, succeed: false,
isProxyContract isProxyContract
} }
resetAfter10Seconds(client, setResults) resetAfter10Seconds(client, setResults)
return returnValue return returnValue
@ -184,7 +184,7 @@ export const getContractFileName = (
} }
return fileName return fileName
} }
export const getContractMetadata = ( export const getContractMetadata = (
compilationResult: CompilationResult, compilationResult: CompilationResult,
contractName: string contractName: string

@ -1,3 +1,18 @@
{ {
"extends": "../../.eslintrc.json", "extends": "../../.eslintrc.json",
"overrides": [
{
"files": [
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"warn"
]
}
}
]
} }

@ -1,6 +1,7 @@
import { PluginClient } from '@remixproject/plugin' import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview' import { createClient } from '@remixproject/plugin-webview'
import EventEmitter from 'events' import EventEmitter from 'events'
// eslint-disable @nrwl/nx/enforce-module-boundaries
import { processStr } from 'solhint' import { processStr } from 'solhint'
import { applyExtends } from 'solhint/lib/config/config-file' import { applyExtends } from 'solhint/lib/config/config-file'
import bestPractises from 'solhint/lib/rules/best-practises' import bestPractises from 'solhint/lib/rules/best-practises'

Loading…
Cancel
Save