-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
59 changed files
with
3,069 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
{ | ||
"tabWidth": 2, | ||
"printWidth": 500, | ||
"bracketSpacing": false, | ||
"useTabs": false, | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"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/**"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file is used by: | ||
# 1. autoprefixer to adjust CSS to support the below specified browsers | ||
# 2. babel preset-env to adjust included polyfills | ||
# | ||
# For additional information regarding the format and rule options, please see: | ||
# https://github.com/browserslist/browserslist#queries | ||
# | ||
# If you need to support different browsers in production, you may tweak the list below. | ||
|
||
last 1 Chrome version | ||
last 1 Firefox version | ||
last 2 Edge major versions | ||
last 2 Safari major version | ||
last 2 iOS major versions | ||
Firefox ESR | ||
not IE 9-11 # For IE 9-11 support, remove 'not'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../../.eslintrc.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"extends": [ | ||
"plugin:@nrwl/nx/react", | ||
"../../.eslintrc.json" | ||
], | ||
"ignorePatterns": [ | ||
"!**/*" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"name": "contract-verification", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "apps/contract-verification/src", | ||
"projectType": "application", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/webpack:webpack", | ||
"outputs": ["{options.outputPath}"], | ||
"defaultConfiguration": "development", | ||
"options": { | ||
"compiler": "babel", | ||
"outputPath": "dist/apps/contract-verification", | ||
"index": "apps/contract-verification/src/index.html", | ||
"baseHref": "./", | ||
"main": "apps/contract-verification/src/main.tsx", | ||
"polyfills": "apps/contract-verification/src/polyfills.ts", | ||
"tsConfig": "apps/contract-verification/tsconfig.app.json", | ||
"assets": [ | ||
"apps/contract-verification/src/favicon.ico", | ||
"apps/contract-verification/src/assets", | ||
"apps/contract-verification/src/profile.json" | ||
], | ||
"styles": ["apps/contract-verification/src/styles.css"], | ||
"scripts": [], | ||
"webpackConfig": "apps/contract-verification/webpack.config.js" | ||
}, | ||
"configurations": { | ||
"development": { | ||
}, | ||
"production": { | ||
"fileReplacements": [ | ||
{ | ||
"replace": "apps/contract-verification/src/environments/environment.ts", | ||
"with": "apps/contract-verification/src/environments/environment.prod.ts" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nrwl/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["apps/contract-verification/**/*.ts"], | ||
"eslintConfig": "apps/contract-verification/.eslintrc" | ||
} | ||
}, | ||
"serve": { | ||
"executor": "@nrwl/webpack:dev-server", | ||
"defaultConfiguration": "development", | ||
"options": { | ||
"buildTarget": "contract-verification:build", | ||
"hmr": true, | ||
"baseHref": "/" | ||
}, | ||
"configurations": { | ||
"development": { | ||
"buildTarget": "contract-verification:build:development", | ||
"port": 5003 | ||
}, | ||
"production": { | ||
"buildTarget": "contract-verification:build:production" | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
html, body, #root { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
.fa-arrow-up-right-from-square::before { content: "\f08e"; } | ||
.fa-xmark::before { content: "\f00d"; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import type { ThemeType, Chain, SubmittedContracts, ContractVerificationSettings } from './types' | ||
import { CompilerAbstract } from '@remix-project/remix-solidity' | ||
import { ContractVerificationPluginClient } from './ContractVerificationPluginClient' | ||
import { ContractDropdownSelection } from './components/ContractDropdown' | ||
|
||
// Define the type for the context | ||
type AppContextType = { | ||
themeType: ThemeType | ||
setThemeType: (themeType: ThemeType) => void | ||
clientInstance: ContractVerificationPluginClient | ||
settings: ContractVerificationSettings | ||
setSettings: React.Dispatch<React.SetStateAction<ContractVerificationSettings>> | ||
chains: Chain[] | ||
compilationOutput: { [key: string]: CompilerAbstract } | undefined | ||
submittedContracts: SubmittedContracts | ||
setSubmittedContracts: React.Dispatch<React.SetStateAction<SubmittedContracts>> | ||
} | ||
|
||
// Provide a default value with the appropriate types | ||
const defaultContextValue: AppContextType = { | ||
themeType: 'dark', | ||
setThemeType: (themeType: ThemeType) => {}, | ||
clientInstance: {} as ContractVerificationPluginClient, | ||
settings: { chains: {} }, | ||
setSettings: () => {}, | ||
chains: [], | ||
compilationOutput: undefined, | ||
submittedContracts: {}, | ||
setSubmittedContracts: (submittedContracts: SubmittedContracts) => {}, | ||
} | ||
|
||
// Create the context with the type | ||
export const AppContext = React.createContext<AppContextType>(defaultContextValue) |
14 changes: 14 additions & 0 deletions
14
apps/contract-verification/src/app/ContractVerificationPluginClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { PluginClient } from '@remixproject/plugin' | ||
import { createClient } from '@remixproject/plugin-webview' | ||
import EventManager from 'events' | ||
|
||
export class ContractVerificationPluginClient extends PluginClient { | ||
public internalEvents: EventManager | ||
|
||
constructor() { | ||
super() | ||
this.internalEvents = new EventManager() | ||
createClient(this) | ||
this.onload() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CompilerAbstract } from '@remix-project/remix-solidity' | ||
import type { LookupResponse, SubmittedContract, VerificationResponse } from '../types' | ||
|
||
// Optional function definitions | ||
export interface AbstractVerifier { | ||
verifyProxy(submittedContract: SubmittedContract): Promise<VerificationResponse> | ||
checkVerificationStatus?(receiptId: string): Promise<VerificationResponse> | ||
checkProxyVerificationStatus?(receiptId: string): Promise<VerificationResponse> | ||
} | ||
|
||
export abstract class AbstractVerifier { | ||
constructor(public apiUrl: string, public explorerUrl: string) {} | ||
|
||
abstract verify(submittedContract: SubmittedContract, compilerAbstract: CompilerAbstract): Promise<VerificationResponse> | ||
abstract lookup(contractAddress: string, chainId: string): Promise<LookupResponse> | ||
} |
50 changes: 50 additions & 0 deletions
50
apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { SourceFile } from '../types' | ||
import { EtherscanVerifier } from './EtherscanVerifier' | ||
|
||
// Etherscan and Blockscout return different objects from the getsourcecode method | ||
interface BlockscoutSource { | ||
AdditionalSources: Array<{ SourceCode: string; Filename: string }> | ||
ConstructorArguments: string | ||
OptimizationRuns: number | ||
IsProxy: string | ||
SourceCode: string | ||
ABI: string | ||
ContractName: string | ||
CompilerVersion: string | ||
OptimizationUsed: string | ||
Runs: string | ||
EVMVersion: string | ||
FileName: string | ||
Address: string | ||
} | ||
|
||
export class BlockscoutVerifier extends EtherscanVerifier { | ||
LOOKUP_STORE_DIR = 'blockscout-verified' | ||
|
||
constructor(apiUrl: string) { | ||
// apiUrl and explorerUrl are the same for Blockscout | ||
super(apiUrl, apiUrl, undefined) | ||
} | ||
|
||
getContractCodeUrl(address: string): string { | ||
const url = new URL(this.explorerUrl + `/address/${address}`) | ||
url.searchParams.append('tab', 'contract') | ||
return url.href | ||
} | ||
|
||
processReceivedFiles(source: unknown, contractAddress: string, chainId: string): { sourceFiles: SourceFile[]; targetFilePath?: string } { | ||
const blockscoutSource = source as BlockscoutSource | ||
|
||
const result: SourceFile[] = [] | ||
const filePrefix = `/${this.LOOKUP_STORE_DIR}/${chainId}/${contractAddress}` | ||
|
||
const targetFilePath = `${filePrefix}/${blockscoutSource.FileName}` | ||
result.push({ content: blockscoutSource.SourceCode, path: targetFilePath }) | ||
|
||
for (const additional of blockscoutSource.AdditionalSources ?? []) { | ||
result.push({ content: additional.SourceCode, path: `${filePrefix}/${additional.Filename}` }) | ||
} | ||
|
||
return { sourceFiles: result, targetFilePath } | ||
} | ||
} |
Oops, something went wrong.