Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract verification plugin #5221

Merged
merged 100 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9989c6b
Add nvmrc
kuzdogan May 29, 2024
e15427b
Init contract-verification plugin and add it inside plugins
kuzdogan Jun 5, 2024
f9e90e7
Clean legacy Etherscan code
kuzdogan Jun 12, 2024
10770e8
Add ThemeType
kuzdogan Jun 12, 2024
97ac7f5
Add pluginClient to fix unstyled Plugin
kuzdogan Jun 12, 2024
c769c8b
Add Verify form items. Fetch and format chains form chainid.network/c…
kuzdogan Jun 13, 2024
89d0656
Searchable Dropdown on chains, setSelectedChain, add fuse.js
kuzdogan Jun 13, 2024
7505c40
Basic select compiled contract name
kuzdogan Jun 13, 2024
f8b3b02
Turn on strict Typescript in the contract-verification-plugin
kuzdogan Jun 13, 2024
baa5c01
Fix types for contract-verification-plugin
kuzdogan Jun 13, 2024
a148432
Turn off temp. strict. Dropdown to ContractDropdown. Style ContractDr…
kuzdogan Jun 13, 2024
9da31b7
Add getAllCompilerAbstracts method to `compiler-artefacts.ts`
kuzdogan Jun 14, 2024
12702c5
Don't create two separate new CompilerAbstracts
kuzdogan Jun 14, 2024
f4a3fa5
Fetch compilation outputs from `compilerArtefacts` module
kuzdogan Jun 14, 2024
93d4af3
Add SourcifyVerifier and submit a verification. Proper e2e chain and …
kuzdogan Jun 14, 2024
0299f53
Add compilationSaved event
kuzdogan Jun 17, 2024
9363f74
Fetch all compilations on load and subscribe to compilations
kuzdogan Jun 17, 2024
f5de0e5
Rename HomeView to VerifyView
kuzdogan Jun 17, 2024
5bd1628
Add AbstractVerifier and enable/disable verifiers
kuzdogan Jun 17, 2024
c11023e
Add EtherscanVerifier and extend from AbstractVerifier
kuzdogan Jun 17, 2024
b32e44a
Send contracts for verification for each verifier
kuzdogan Jun 18, 2024
0dcf7f7
Fix missing upper level triggerFilePath in contract selections
kuzdogan Jun 20, 2024
37502d1
Handle simple contructor args
kuzdogan Jun 20, 2024
4dbe763
Rename EtherscanVerifier.tsx to .ts
kuzdogan Jun 20, 2024
5f014e6
Move abiEncodedConstrArgs state to VerifyView and pass along the Ethe…
kuzdogan Jun 20, 2024
a870235
Fix no selectedContractFileAndName on load
kuzdogan Jun 20, 2024
c992394
Basic receipt styling
kuzdogan Jun 21, 2024
f5848c9
Modify .prettierrc and prettify `contract-verification-plugin` folder
kuzdogan Jun 21, 2024
8325675
Adapt Layout
manuelwedler Jun 28, 2024
216e272
Make receipts view prettier
manuelwedler Jul 1, 2024
6de47ef
Add proxy contracts to receipts view
manuelwedler Jul 2, 2024
f19e582
Make navigation menu prettier
manuelwedler Jul 2, 2024
b1ce849
Add Lookup view
manuelwedler Jul 2, 2024
1678fd3
Decouple SubmittedContract from verifier logic to make it easy to sto…
manuelwedler Jul 4, 2024
549eaf1
Use objects as ContractDropdown values
manuelwedler Jul 4, 2024
b7e24f2
Rename plugin where it was not done yet
manuelwedler Jul 5, 2024
869c868
Improve SourcifyVerifier
manuelwedler Jul 5, 2024
758097a
Improve EtherscanVerifier
manuelwedler Jul 5, 2024
13ab2ba
Add checkVerificationStatus to Etherscan Verifier
manuelwedler Jul 5, 2024
58ed05e
Add lookup function to SourcifyVerifier
manuelwedler Jul 16, 2024
bc33630
Add lookup function to EtherscanVerifier
manuelwedler Jul 16, 2024
3d75021
Add lookupUrls to lookup function results
manuelwedler Jul 17, 2024
a457b76
Add BlockscoutVerifier
manuelwedler Jul 17, 2024
c1f28f1
Add visual SettingsView
manuelwedler Jul 17, 2024
caf1e58
Add variables for storing settings and submittedContracts in LocalSto…
manuelwedler Jul 18, 2024
1a10b7b
Add logic for SettingsView
manuelwedler Jul 18, 2024
99dbe93
Fix mergeChainSettingsWithDefaults function
manuelwedler Jul 19, 2024
b365060
Reset ConfigInput when initialValue changes
manuelwedler Jul 19, 2024
37a48d0
Fix URL construction
manuelwedler Jul 19, 2024
2a6d6a1
Add logic for LookupView
manuelwedler Jul 19, 2024
ba2a3f5
Make VerifyView functional with modified Verifier classes
manuelwedler Jul 22, 2024
58a799c
Remove unused code
manuelwedler Jul 24, 2024
d3aca88
Fix Etherscan API verification
manuelwedler Jul 24, 2024
92af87d
Make chain descriptors of SearchableChainDropdown consistent and impr…
manuelwedler Jul 24, 2024
2701720
Move default api urls to a json structure
manuelwedler Jul 24, 2024
ec6fb71
Add defaults for Etherscan
manuelwedler Jul 24, 2024
c0873b4
Show message on ReceiptsView if no contracts were submitted
manuelwedler Jul 25, 2024
48dd94e
Correctly encode and decode constructor arguments
manuelwedler Jul 29, 2024
a063188
Improve labels of ConstructorArguments component
manuelwedler Jul 29, 2024
033737e
Fix Etherscan API calls
manuelwedler Jul 30, 2024
d075b8e
Add proxy inputs to VerifyView
manuelwedler Jul 30, 2024
a0db3ef
Add proxy methods to EtherscanVerifier
manuelwedler Jul 30, 2024
2f85c32
Add proxy verification call to VerifyView
manuelwedler Jul 30, 2024
c5ebdd9
Check proxy receipt status frequently
manuelwedler Jul 30, 2024
150d775
Adapt AccordionReceipt to proxy receipts
manuelwedler Jul 30, 2024
c25bb0e
Improve error handling of verification
manuelwedler Jul 30, 2024
d831933
Fetch source files from Sourcify lookup
manuelwedler Jul 31, 2024
24f5f45
Add open in remix button to LookupView
manuelwedler Aug 1, 2024
afdde56
Get source code with Blockscout lookup
manuelwedler Aug 1, 2024
ce64b7e
Get source code with Etherscan lookup
manuelwedler Aug 1, 2024
a99808f
Remove console.logs
manuelwedler Aug 2, 2024
355b56c
Add lookup links to AccordionReceipt
manuelwedler Aug 2, 2024
edef5f1
Remove outdated todos
manuelwedler Aug 2, 2024
7a28b1d
Remove Ropsten, Rinkeby, Goerli from default chains on chain selector
manuelwedler Aug 8, 2024
ecf8300
Add default API URLs for Blockscout
manuelwedler Aug 8, 2024
4c9db60
Navigate to settings when clicking 'Enable?' on disabled verifier
manuelwedler Aug 8, 2024
6abf31e
Reset lookup results when chain or contract changes
manuelwedler Aug 8, 2024
7694141
Persist form data when switching tabs
manuelwedler Aug 8, 2024
df0e341
Check valid chains for Sourcify and disable Sourcify if not supported
manuelwedler Aug 12, 2024
2e939a9
Await implementation verification before proxy verification API call
manuelwedler Sep 6, 2024
9205bf7
Make settings view prettier
manuelwedler Sep 11, 2024
21c9037
Disable submit button when no verifier is enabled
manuelwedler Sep 17, 2024
cf4a8ec
Make receipts view prettier
manuelwedler Sep 18, 2024
d6ab227
Fix proxy verification check on Etherscan for non existing delegateca…
manuelwedler Sep 18, 2024
c14616d
Reset form after submitting for verification
manuelwedler Sep 18, 2024
1e72561
Make NavMenu fixed on top
manuelwedler Sep 18, 2024
c748609
Make ContractDropdown prettier
manuelwedler Sep 18, 2024
813bbac
Improve coloring of NavMenu and move to one line
manuelwedler Sep 18, 2024
a057147
Adapt coloring of checkboxes
manuelwedler Sep 18, 2024
96facf3
Use colored background for SearchableChainDropdown
manuelwedler Sep 18, 2024
803f445
Fix NavMenu coloring
manuelwedler Sep 18, 2024
21ba015
Fix NavMenu for smaller screens
manuelwedler Sep 19, 2024
e02c5bc
Fix tooltip in ReceiptsView to not get cut in iframe
manuelwedler Sep 24, 2024
1c0ef62
Update profile.json
manuelwedler Sep 24, 2024
a50ed79
Fix title in index.html
manuelwedler Sep 25, 2024
1d76fe5
Fix linting
manuelwedler Sep 25, 2024
d318e47
Make contract-verification a native plugin
manuelwedler Oct 1, 2024
6303c7e
Add verification_activated event
manuelwedler Oct 1, 2024
e79d089
Adapt padding of NavMenu
manuelwedler Oct 1, 2024
dacce46
Fix SearchableChainDropdown error when no chain is selected
manuelwedler Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
4 changes: 1 addition & 3 deletions .prettierrc.json
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
}
5 changes: 5 additions & 0 deletions apps/contract-verification/.babelrc
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/**"]
}
16 changes: 16 additions & 0 deletions apps/contract-verification/.browserslistrc
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'.
3 changes: 3 additions & 0 deletions apps/contract-verification/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc.json"
}
34 changes: 34 additions & 0 deletions apps/contract-verification/.eslintrc.json
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": {}
}
]
}
69 changes: 69 additions & 0 deletions apps/contract-verification/project.json
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": []
}
10 changes: 10 additions & 0 deletions apps/contract-verification/src/app/App.css
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"; }
34 changes: 34 additions & 0 deletions apps/contract-verification/src/app/AppContext.tsx
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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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()
}

onActivation(): void {
this.internalEvents.emit('verification_activated')
}
}
16 changes: 16 additions & 0 deletions apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts
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 apps/contract-verification/src/app/Verifiers/BlockscoutVerifier.ts
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 }
}
}
Loading