diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 86c90ffc1e..da8dc3b694 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -48,6 +48,7 @@ export interface ICompilerApi { emit?: (key: string, ...payload: any) => void setSolJsonBinData: (binData: iSolJsonBinData) => void + solJsonBinData: iSolJsonBinData } export interface iSolJsonBinDataBuild { diff --git a/libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts b/libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts index 9c420b50bf..68e62915c5 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/api/compiler-api.ts @@ -16,6 +16,7 @@ export const CompilerApiMixin = (Base) => class extends Base { compileErrors: any compileTabLogic: CompileTabLogic configurationSettings: ConfigurationSettings + solJsonBinData: iSolJsonBinData onCurrentFileChanged: (fileName: string) => void // onResetResults: () => void @@ -281,7 +282,11 @@ export const CompilerApiMixin = (Base) => class extends Base { this.on('fileManager', 'fileClosed', this.data.eventHandlers.onFileClosed) this.on('compilerloader', 'jsonBinDataLoaded', (urls: iSolJsonBinData) => { - this.setSolJsonBinData(urls) + try{ + this.setSolJsonBinData(urls) + }catch(e){ + } + this.solJsonBinData = urls }) this.call('compilerloader', 'getJsonBinData') diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 5bc23ad9a7..2251fa1247 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -140,7 +140,10 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { } api.setSolJsonBinData = (data: iSolJsonBinData) => { + setSolJsonBinData(data) + } + const setSolJsonBinData = (data: iSolJsonBinData) => { const builtin: iSolJsonBinDataBuild = { path: 'builtin', @@ -245,6 +248,12 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { ) + useEffect(() => { + if(!state.solJsonBinData && api.solJsonBinData){ + setSolJsonBinData(api.solJsonBinData) + } + },[]) + return ( <>