Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/tabs/compile-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class CompileTab extends CompilerApiMixin(ViewPlugin) { // implem

compile(fileName) {
if (!isNative(this.currentRequest.from)) this.call('notification', 'toast', compileToastMsg(this.currentRequest.from, fileName))
super.compile(fileName)
return super.compile(fileName)
}

compileFile(event) {
Expand Down
4 changes: 3 additions & 1 deletion libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ export const CompilerApiMixin = (Base) => class extends Base {
if (this.currentFile && (this.currentFile.endsWith('.sol') || this.currentFile.endsWith('.yul'))) {
if (await this.getAppParameter('hardhat-compilation')) this.compileTabLogic.runCompiler('hardhat')
else if (await this.getAppParameter('truffle-compilation')) this.compileTabLogic.runCompiler('truffle')
else this.compileTabLogic.runCompiler(undefined)
else this.compileTabLogic.runCompiler(undefined).catch((error) => {
this.call('notification', 'toast', error.message)
})
} else if (this.currentFile && this.currentFile.endsWith('.circom')) {
await this.call('circuit-compiler', 'compile', this.currentFile)
} else if (this.currentFile && this.currentFile.endsWith('.vy')) {
Expand Down
20 changes: 18 additions & 2 deletions libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,15 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
let externalCompType
if (hhCompilation) externalCompType = 'hardhat'
else if (truffleCompilation) externalCompType = 'truffle'
compileTabLogic.runCompiler(externalCompType)
compileTabLogic.runCompiler(externalCompType).catch((error) => {
tooltip(error.message)
compileIcon.current.classList.remove('remixui_bouncingIcon')
compileIcon.current.classList.remove('remixui_spinningIcon')
// @ts-ignore
props.setCompileErrors({ [currentFile]: { error: error.message } })
// @ts-ignore
props.setBadgeStatus({ [currentFile]: { key: 1, title: error.message, type: 'error' } })
})
}

const compileAndRun = () => {
Expand All @@ -448,7 +456,15 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
if (hhCompilation) externalCompType = 'hardhat'
else if (truffleCompilation) externalCompType = 'truffle'
api.runScriptAfterCompilation(currentFile)
compileTabLogic.runCompiler(externalCompType)
compileTabLogic.runCompiler(externalCompType).catch((error) => {
tooltip(error.message)
compileIcon.current.classList.remove('remixui_bouncingIcon')
compileIcon.current.classList.remove('remixui_spinningIcon')
// @ts-ignore
props.setCompileErrors({ [currentFile]: { error: error.message } })
// @ts-ignore
props.setBadgeStatus({ [currentFile]: { key: 1, title: error.message, type: 'error' } })
})
}

const _updateVersionSelector = (version, customUrl = '', setQueryParameter = true) => {
Expand Down
23 changes: 22 additions & 1 deletion libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,28 @@ export class CompileTabLogic {
const config = JSON.parse(configContent)

if (config['solidity-compiler']) {
this.compiler.set('configFileContent', config['solidity-compiler'])
if (typeof config['solidity-compiler'] === 'string') {
if (config['solidity-compiler'].endsWith('.json')) {
const configFilePath = config['solidity-compiler']
const fileExists = await this.api.fileExists(configFilePath)

if (fileExists) {
try {
const fileContent = await this.api.readFile(configFilePath)
config['solidity-compiler'] = JSON.parse(fileContent)
this.compiler.set('configFileContent', config['solidity-compiler'])
} catch (e) {
throw new Error('Configuration file specified in remix.config.json contains invalid configuration')
}
} else {
throw new Error('Configuration file specified in remix.config.json does not exist')
}
} else {
throw new Error('Configuration file specified in remix.config.json is not a valid JSON file')
}
} else {
this.compiler.set('configFileContent', config['solidity-compiler'])
}
} else {
this.compiler.set('configFileContent', JSON.parse(configFileContent))
this.api.writeFile(remixConfigPath, JSON.stringify({ ...config, 'solidity-compiler': JSON.parse(configFileContent) }, null, 2))
Expand Down
2 changes: 2 additions & 0 deletions libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
updateCurrentVersion={updateCurrentVersion}
configurationSettings={configurationSettings}
solJsonBinData={state.solJsonBinData}
setCompileErrors={setCompileErrors}
setBadgeStatus={setBadgeStatus}
/>
{/* "compileErrors[currentFile]['contracts']" field will not be there in case of compilation errors */}
{contractsFile && contractsFile[currentFile] && contractsFile[currentFile].contractsDetails
Expand Down
4 changes: 3 additions & 1 deletion libs/remix-ui/solidity-compiler/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export interface CompilerContainerProps {
compiledFileName: string,
updateCurrentVersion: any,
configurationSettings: ConfigurationSettings,
solJsonBinData: iSolJsonBinData
solJsonBinData: iSolJsonBinData,
setCompileErrors: (errors: Record<string, CompileErrors>) => void
setBadgeStatus: (badgeStatus: Record<string, { key: string; title?: string; type?: string }>) => void
}

export interface ContractSelectionProps {
Expand Down
4 changes: 3 additions & 1 deletion libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ export const TabsUI = (props: TabsUIProps) => {
if (tabsState.currentExt === 'vy') {
await props.plugin.call(compilerName, 'vyperCompileCustomAction')
} else {
await props.plugin.call(compilerName, 'compile', path)
await props.plugin.call(compilerName, 'compile', path).catch((error) => {
props.plugin.call('notification', 'toast', error.message)
})
}

} catch (e) {
Expand Down