Skip to content

Commit 048d8d1

Browse files
committed
Merge branch 'compilerstate' into yellowlines
2 parents 8d814e7 + 863f395 commit 048d8d1

File tree

9 files changed

+183
-232
lines changed

9 files changed

+183
-232
lines changed

apps/contract-verification/src/app/Verifiers/AbstractVerifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type { LookupResponse, SubmittedContract, VerificationResponse } from '..
44
// Optional function definitions
55
export interface AbstractVerifier {
66
verifyProxy?(submittedContract: SubmittedContract): Promise<VerificationResponse>
7-
checkVerificationStatus?(receiptId: string): Promise<VerificationResponse>
8-
checkProxyVerificationStatus?(receiptId: string): Promise<VerificationResponse>
7+
checkVerificationStatus?(receiptId: string, chainId: string): Promise<VerificationResponse>
8+
checkProxyVerificationStatus?(receiptId: string, chainId: string): Promise<VerificationResponse>
99
}
1010

1111
export abstract class AbstractVerifier {

apps/contract-verification/src/app/Verifiers/EtherscanVerifier.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class EtherscanVerifier extends AbstractVerifier {
4747
// TODO: Handle version Vyper contracts. This relies on Solidity metadata.
4848
const metadata = JSON.parse(compilerAbstract.data.contracts[submittedContract.filePath][submittedContract.contractName].metadata)
4949
const formData = new FormData()
50-
formData.append('chainId', submittedContract.chainId)
5150
formData.append('codeformat', 'solidity-standard-json-input')
5251
formData.append('sourceCode', compilerAbstract.input.toString())
5352
formData.append('contractaddress', submittedContract.address)
@@ -56,6 +55,7 @@ export class EtherscanVerifier extends AbstractVerifier {
5655
formData.append('constructorArguements', submittedContract.abiEncodedConstructorArgs?.replace('0x', '') ?? '')
5756

5857
const url = new URL(this.apiUrl + '/api')
58+
url.searchParams.append('chainid', submittedContract.chainId)
5959
url.searchParams.append('module', 'contract')
6060
url.searchParams.append('action', 'verifysourcecode')
6161
if (this.apiKey) {
@@ -98,6 +98,7 @@ export class EtherscanVerifier extends AbstractVerifier {
9898
formData.append('expectedimplementation', submittedContract.address)
9999

100100
const url = new URL(this.apiUrl + '/api')
101+
url.searchParams.append('chainid', submittedContract.chainId)
101102
url.searchParams.append('module', 'contract')
102103
url.searchParams.append('action', 'verifyproxycontract')
103104
if (this.apiKey) {
@@ -129,8 +130,9 @@ export class EtherscanVerifier extends AbstractVerifier {
129130
return { status: 'pending', receiptId: verificationResponse.result }
130131
}
131132

132-
async checkVerificationStatus(receiptId: string): Promise<VerificationResponse> {
133+
async checkVerificationStatus(receiptId: string, chainId: string): Promise<VerificationResponse> {
133134
const url = new URL(this.apiUrl + '/api')
135+
url.searchParams.append('chainid', chainId)
134136
url.searchParams.append('module', 'contract')
135137
url.searchParams.append('action', 'checkverifystatus')
136138
url.searchParams.append('guid', receiptId)
@@ -173,8 +175,9 @@ export class EtherscanVerifier extends AbstractVerifier {
173175
return { status: 'unknown', receiptId }
174176
}
175177

176-
async checkProxyVerificationStatus(receiptId: string): Promise<VerificationResponse> {
178+
async checkProxyVerificationStatus(receiptId: string, chainId: string): Promise<VerificationResponse> {
177179
const url = new URL(this.apiUrl + '/api')
180+
url.searchParams.append('chainid', chainId)
178181
url.searchParams.append('module', 'contract')
179182
url.searchParams.append('action', 'checkproxyverification')
180183
url.searchParams.append('guid', receiptId)
@@ -216,6 +219,7 @@ export class EtherscanVerifier extends AbstractVerifier {
216219

217220
async lookup(contractAddress: string, chainId: string): Promise<LookupResponse> {
218221
const url = new URL(this.apiUrl + '/api')
222+
url.searchParams.append('chainid', chainId)
219223
url.searchParams.append('module', 'contract')
220224
url.searchParams.append('action', 'getsourcecode')
221225
url.searchParams.append('address', contractAddress)

apps/contract-verification/src/app/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ const App = () => {
123123
try {
124124
let response: VerificationResponse
125125
if (receipt.isProxyReceipt) {
126-
response = await verifier.checkProxyVerificationStatus(receiptId)
126+
response = await verifier.checkProxyVerificationStatus(receiptId, contract.chainId)
127127
} else {
128-
response = await verifier.checkVerificationStatus(receiptId)
128+
response = await verifier.checkVerificationStatus(receiptId, contract.chainId)
129129
}
130130
const { status, message, lookupUrl } = response
131131
receipt.status = status

apps/contract-verification/src/app/utils/default-apis.json

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,144 +4,110 @@
44
"explorerUrl": "https://repo.sourcify.dev"
55
},
66
"Etherscan": {
7+
"apiUrl": "https://api.etherscan.io/v2",
78
"1": {
8-
"apiUrl": "https://api.etherscan.io",
99
"explorerUrl": "https://etherscan.io"
1010
},
1111
"56": {
12-
"apiUrl": "https://api.bscscan.com",
1312
"explorerUrl": "https://bscscan.com"
1413
},
1514
"137": {
16-
"apiUrl": "https://api.polygonscan.com",
1715
"explorerUrl": "https://polygonscan.com"
1816
},
1917
"250": {
20-
"apiUrl": "https://api.ftmscan.com",
2118
"explorerUrl": "https://ftmscan.com"
2219
},
2320
"42161": {
24-
"apiUrl": "https://api.arbiscan.io",
2521
"explorerUrl": "https://arbiscan.io"
2622
},
2723
"43114": {
28-
"apiUrl": "https://api.snowtrace.io",
2924
"explorerUrl": "https://snowtrace.io"
3025
},
3126
"1285": {
32-
"apiUrl": "https://api-moonriver.moonscan.io",
3327
"explorerUrl": "https://moonscan.io"
3428
},
3529
"1284": {
36-
"apiUrl": "https://api-moonbeam.moonscan.io",
3730
"explorerUrl": "https://moonscan.io"
3831
},
3932
"25": {
40-
"apiUrl": "https://api.cronoscan.com",
4133
"explorerUrl": "https://cronoscan.com"
4234
},
4335
"199": {
44-
"apiUrl": "https://api.bttcscan.com",
4536
"explorerUrl": "https://bttcscan.com"
4637
},
4738
"10": {
48-
"apiUrl": "https://api-optimistic.etherscan.io",
4939
"explorerUrl": "https://optimistic.etherscan.io"
5040
},
5141
"42220": {
52-
"apiUrl": "https://api.celoscan.io",
5342
"explorerUrl": "https://celoscan.io"
5443
},
5544
"288": {
56-
"apiUrl": "https://api.bobascan.com",
5745
"explorerUrl": "https://bobascan.com"
5846
},
5947
"100": {
60-
"apiUrl": "https://api.gnosisscan.io",
6148
"explorerUrl": "https://gnosisscan.io"
6249
},
6350
"1101": {
64-
"apiUrl": "https://api-zkevm.polygonscan.com",
6551
"explorerUrl": "https://zkevm.polygonscan.com"
6652
},
6753
"59144": {
68-
"apiUrl": "https://api.lineascan.build",
6954
"explorerUrl": "https://lineascan.build"
7055
},
7156
"8453": {
72-
"apiUrl": "https://api.basescan.org",
7357
"explorerUrl": "https://basescan.org"
7458
},
7559
"534352": {
76-
"apiUrl": "https://api.scrollscan.com",
7760
"explorerUrl": "https://scrollscan.com"
7861
},
7962
"17000": {
80-
"apiUrl": "https://api-holesky.etherscan.io",
8163
"explorerUrl": "https://holesky.etherscan.io"
8264
},
8365
"11155111": {
84-
"apiUrl": "https://api-sepolia.etherscan.io",
8566
"explorerUrl": "https://sepolia.etherscan.io"
8667
},
8768
"97": {
88-
"apiUrl": "https://api-testnet.bscscan.com",
8969
"explorerUrl": "https://bscscan.com"
9070
},
9171
"80001": {
92-
"apiUrl": "https://api-testnet.polygonscan.com",
9372
"explorerUrl": "https://polygonscan.com"
9473
},
9574
"4002": {
96-
"apiUrl": "https://api-testnet.ftmscan.com",
9775
"explorerUrl": "https://ftmscan.com"
9876
},
9977
"421611": {
100-
"apiUrl": "https://api-testnet.arbiscan.io",
10178
"explorerUrl": "https://arbiscan.io"
10279
},
10380
"42170": {
104-
"apiUrl": "https://api-nova.arbiscan.io",
10581
"explorerUrl": "https://nova.arbiscan.io"
10682
},
10783
"43113": {
108-
"apiUrl": "https://api-testnet.snowtrace.io",
10984
"explorerUrl": "https://snowtrace.io"
11085
},
11186
"1287": {
112-
"apiUrl": "https://api-moonbase.moonscan.io",
11387
"explorerUrl": "https://moonscan.io"
11488
},
11589
"338": {
116-
"apiUrl": "https://api-testnet.cronoscan.com",
11790
"explorerUrl": "https://cronoscan.com"
11891
},
11992
"1028": {
120-
"apiUrl": "https://api-testnet.bttcscan.com",
12193
"explorerUrl": "https://bttcscan.com"
12294
},
12395
"44787": {
124-
"apiUrl": "https://api-alfajores.celoscan.io",
12596
"explorerUrl": "https://alfajores.celoscan.io"
12697
},
12798
"2888": {
128-
"apiUrl": "https://api-testnet.bobascan.com",
12999
"explorerUrl": "https://bobascan.com"
130100
},
131101
"84532": {
132-
"apiUrl": "https://api-sepolia.basescan.org",
133102
"explorerUrl": "https://sepolia.basescan.org"
134103
},
135104
"1442": {
136-
"apiUrl": "https://api-testnet-zkevm.polygonscan.com",
137105
"explorerUrl": "https://zkevm.polygonscan.com"
138106
},
139107
"59140": {
140-
"apiUrl": "https://api-testnet.lineascan.build",
141108
"explorerUrl": "https://lineascan.build"
142109
},
143110
"534351": {
144-
"apiUrl": "https://api-sepolia.scrollscan.com",
145111
"explorerUrl": "https://sepolia.scrollscan.com"
146112
}
147113
},

apps/contract-verification/src/app/utils/default-settings.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ export function mergeChainSettingsWithDefaults(chainId: string, userSettings: Co
1313
let defaultsForVerifier: VerifierSettings
1414
if (verifierId === 'Sourcify') {
1515
defaultsForVerifier = DEFAULT_APIS['Sourcify']
16+
} else if (verifierId === 'Etherscan') {
17+
const apiUrl = DEFAULT_APIS['Etherscan'].apiUrl
18+
const explorerUrl = DEFAULT_APIS['Etherscan'][chainId]?.explorerUrl
19+
defaultsForVerifier = { apiUrl, explorerUrl }
1620
} else if (verifierId === 'Routescan') {
1721
const routescanDefaults = DEFAULT_APIS['Routescan']
1822

1923
if (!routescanDefaults[chainId]) {
2024
defaultsForVerifier = {}
21-
2225
} else {
2326
const explorerUrl = routescanDefaults[chainId]?.type === 'mainnet' ? routescanDefaults.mainnetExplorerUrl : routescanDefaults.testnetExplorerUrl
2427
const apiUrl = routescanDefaults.apiUrl.replace('${CHAIN_TYPE}', routescanDefaults[chainId]?.type).replace('${CHAIN_ID}', chainId)

libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const CompilerApiMixin = (Base) => class extends Base {
152152
* @param {object} settings {evmVersion, optimize, runs, version, language}
153153
*/
154154
async compileWithParameters (compilationTargets: Source, settings: CompilerInputOptions) {
155-
const compilerState = this.getCompilerState()
155+
const compilerState = await this.getCompilerState()
156156
const version = settings.version || compilerState.currentVersion
157157
const settingsCompile: CompilerInput = JSON.parse(compilerInputFactory(null, settings))
158158
const res = await compile(
@@ -165,8 +165,8 @@ export const CompilerApiMixin = (Base) => class extends Base {
165165
}
166166

167167
// This function is used for passing the compiler configuration to 'remix-tests'
168-
getCurrentCompilerConfig () {
169-
const compilerState = this.getCompilerState()
168+
async getCurrentCompilerConfig () {
169+
const compilerState = await this.getCompilerState()
170170
const compilerDetails: any = {
171171
currentVersion: compilerState.currentVersion,
172172
evmVersion: compilerState.evmVersion,

libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class CompileTabLogic {
5656
if (this.language != null) {
5757
this.compiler.set('language', this.language)
5858
}
59+
5960
}
6061

6162
setOptimize (newOptimizeValue: boolean) {
@@ -64,9 +65,11 @@ export class CompileTabLogic {
6465
this.compiler.set('optimize', this.optimize)
6566
}
6667

67-
setUseFileConfiguration (useFileConfiguration: boolean) {
68+
async setUseFileConfiguration (useFileConfiguration: boolean) {
6869
this.useFileConfiguration = useFileConfiguration
70+
console.log('setUseFileConfiguration', useFileConfiguration)
6971
this.compiler.set('useFileConfiguration', useFileConfiguration)
72+
await this.setCompilerConfigContent()
7073
}
7174

7275
setConfigFilePath (path) {
@@ -89,8 +92,10 @@ export class CompileTabLogic {
8992
this.compiler.set('evmVersion', this.evmVersion)
9093
}
9194

92-
getCompilerState () {
93-
console.log('getCompilerState', this.compiler.state)
95+
async getCompilerState () {
96+
await this.setCompilerMappings()
97+
await this.setCompilerConfigContent()
98+
console.log('getCompilerState', this.compiler)
9499
return this.compiler.state
95100
}
96101

@@ -104,6 +109,23 @@ export class CompileTabLogic {
104109
this.compiler.set('language', lang)
105110
}
106111

112+
async setCompilerMappings () {
113+
if (await this.api.fileExists('remappings.txt')) {
114+
this.api.readFile('remappings.txt').then(remappings => {
115+
this.compiler.set('remappings', remappings.split('\n').filter(Boolean))
116+
})
117+
} else this.compiler.set('remappings', [])
118+
}
119+
120+
async setCompilerConfigContent () {
121+
if (this.configFilePath && this.useFileConfiguration) {
122+
this.api.readFile(this.configFilePath).then(content => {
123+
this.compiler.set('configFileContent', content)
124+
})
125+
}
126+
}
127+
128+
107129
/**
108130
* Compile a specific file of the file manager
109131
* @param {string} target the path to the file to compile
@@ -115,16 +137,8 @@ export class CompileTabLogic {
115137
const sources = { [target]: { content } }
116138
this.event.emit('removeAnnotations')
117139
this.event.emit('startingCompilation')
118-
if (await this.api.fileExists('remappings.txt')) {
119-
this.api.readFile('remappings.txt').then(remappings => {
120-
this.compiler.set('remappings', remappings.split('\n').filter(Boolean))
121-
})
122-
} else this.compiler.set('remappings', [])
123-
if (this.configFilePath) {
124-
this.api.readFile(this.configFilePath).then( contentConfig => {
125-
this.compiler.set('configFileContent', contentConfig)
126-
})
127-
}
140+
await this.setCompilerMappings()
141+
await this.setCompilerConfigContent()
128142
// setTimeout fix the animation on chrome... (animation triggered by 'staringCompilation')
129143
setTimeout(() => { this.compiler.compile(sources, target); resolve(true) }, 100)
130144
}).catch((error) => {

libs/remix-ui/solidity-compiler/src/lib/reducers/compiler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const compilerInitialState = {
1414
}
1515

1616
export const compilerReducer = (state = compilerInitialState, action: Action) => {
17+
console.log('compilerReducer', action)
1718
switch (action.type) {
1819
case 'SET_COMPILER_MODE': {
1920
return {

0 commit comments

Comments
 (0)