compiler for hardhat

pull/4964/head
bunsenstraat 5 months ago
parent ebbdf6b5ea
commit 1c04cc41f5
  1. 6
      apps/remix-ide/src/app/tabs/compile-tab.js
  2. 4
      apps/solidity-compiler/src/app/compiler.ts
  3. 1
      libs/remix-lib/src/types/ICompilerApi.ts
  4. 9
      libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts
  5. 13
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx

@ -9,7 +9,7 @@ import { QueryParams } from '@remix-project/remix-lib'
import * as packageJson from '../../../../../package.json'
import { compilerConfigChangedToastMsg, compileToastMsg } from '@remix-ui/helper'
import { isNative } from '../../remixAppManager'
import { Registry } from '@remix-project/remix-lib'
const profile = {
name: 'solidity',
displayName: 'Solidity compiler',
@ -90,6 +90,10 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerA
return this.fileManager.mode
}
isDesktop () {
return Registry.getInstance().get('platform').api.isDesktop()
}
/**
* set the compiler configuration
* This function is used by remix-plugin compiler API.

@ -55,4 +55,8 @@ export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements
getFileManagerMode () {
return 'browser'
}
isDesktop() {
return false
}
}

@ -18,6 +18,7 @@ export interface ICompilerApi {
setAppParameter: (name: string, value: string | boolean) => void
getFileManagerMode: () => string
isDesktop: () => boolean
setCompilerConfig: (settings: any) => void
getCompilationResult: () => any

@ -129,26 +129,27 @@ export class CompileTabLogic {
}
async isHardhatProject () {
if (this.api.getFileManagerMode() === 'localhost') {
if (this.api.getFileManagerMode() === ('localhost') || this.api.isDesktop()) {
console.log('checking hardhat project')
return await this.api.fileExists('hardhat.config.js') || await this.api.fileExists('hardhat.config.ts')
} else return false
}
async isTruffleProject () {
if (this.api.getFileManagerMode() === 'localhost') {
if (this.api.getFileManagerMode() === ('localhost') || this.api.isDesktop()) {
return await this.api.fileExists('truffle-config.js')
} else return false
}
async isFoundryProject () {
if (this.api.getFileManagerMode() === 'localhost') {
if (this.api.getFileManagerMode() === ('localhost') || this.api.isDesktop()) {
return await this.api.fileExists('foundry.toml')
} else return false
}
runCompiler (externalCompType) {
try {
if (this.api.getFileManagerMode() === 'localhost') {
if (this.api.getFileManagerMode() === 'localhost' || this.api.isDesktop()) {
if (externalCompType === 'hardhat') {
const { currentVersion, optimize, runs } = this.compiler.state
if (currentVersion) {

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' // eslint-disable-line
import React, { useContext, useEffect, useState } from 'react' // eslint-disable-line
import { CompileErrors, ContractsFile, SolidityCompilerProps } from './types'
import { CompilerContainer } from './compiler-container' // eslint-disable-line
import { ContractSelection } from './contract-selection' // eslint-disable-line
@ -9,6 +9,7 @@ import { baseURLBin, baseURLWasm, pathToURL } from '@remix-project/remix-solidit
import * as packageJson from '../../../../../package.json'
import './css/style.css'
import { iSolJsonBinData, iSolJsonBinDataBuild } from '@remix-project/remix-lib'
import { appPlatformTypes, platformContext } from '@remix-ui/app'
export const SolidityCompiler = (props: SolidityCompilerProps) => {
const {
@ -47,6 +48,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
const [compileErrors, setCompileErrors] = useState<Record<string, CompileErrors>>({ [currentFile]: api.compileErrors })
const [badgeStatus, setBadgeStatus] = useState<Record<string, { key: string; title?: string; type?: string }>>({})
const [contractsFile, setContractsFile] = useState<ContractsFile>({})
const platform = useContext(platformContext)
useEffect(() => {
; (async () => {
@ -77,9 +79,12 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
}
api.onSetWorkspace = async (isLocalhost: boolean, workspaceName: string) => {
const isHardhat = isLocalhost && (await compileTabLogic.isHardhatProject())
const isTruffle = isLocalhost && (await compileTabLogic.isTruffleProject())
const isFoundry = isLocalhost && (await compileTabLogic.isFoundryProject())
const isDesktop = platform === appPlatformTypes.desktop
console.log('onSetWorkspace', workspaceName, isLocalhost, isDesktop, workspaceName)
const isHardhat = (isLocalhost || isDesktop) && (await compileTabLogic.isHardhatProject())
const isTruffle = (isLocalhost || isDesktop) && (await compileTabLogic.isTruffleProject())
const isFoundry = (isLocalhost || isDesktop) && (await compileTabLogic.isFoundryProject())
console.log(isFoundry, isHardhat, isTruffle)
setState((prevState) => {
return {
...prevState,

Loading…
Cancel
Save