From b7f4408b3de6353a5de1e26331121acb7fd95345 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 7 Dec 2023 13:54:04 +0100 Subject: [PATCH] bin urls --- .../plugins/electron/compilerLoaderPlugin.ts | 5 +++- .../src/plugins/compilerLoader.ts | 27 ++++++++++++++++++- libs/remix-lib/src/index.ts | 2 +- libs/remix-lib/src/types/ICompilerApi.ts | 14 ++++++++++ .../src/lib/api/compiler-api.ts | 8 +++++- .../src/lib/solidity-compiler.tsx | 18 ++++++++++++- .../solidity-compiler/src/lib/types/index.ts | 5 +++- 7 files changed, 73 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/electron/compilerLoaderPlugin.ts b/apps/remix-ide/src/app/plugins/electron/compilerLoaderPlugin.ts index 1a788100eb..3623e5b7e6 100644 --- a/apps/remix-ide/src/app/plugins/electron/compilerLoaderPlugin.ts +++ b/apps/remix-ide/src/app/plugins/electron/compilerLoaderPlugin.ts @@ -24,7 +24,6 @@ export class compilerLoaderPluginDesktop extends ElectronPlugin { constructor() { super(profile) this.methods = [] - } onActivation(): void { @@ -40,6 +39,10 @@ export class compilerLoaderPluginDesktop extends ElectronPlugin { console.log('compilerList', compilerList) this.emit('compilersDownloaded', compilerList) }) + + this.on('compilerloader', 'setSolJsonBinData', (url) => { + console.log('setSolJsonBinData', url) + }) } diff --git a/apps/remixdesktop/src/plugins/compilerLoader.ts b/apps/remixdesktop/src/plugins/compilerLoader.ts index a6a2bddfad..a8c991c8ab 100644 --- a/apps/remixdesktop/src/plugins/compilerLoader.ts +++ b/apps/remixdesktop/src/plugins/compilerLoader.ts @@ -45,11 +45,36 @@ const clientProfile: Profile = { methods: ['getPort', 'downloadCompiler', 'listCompilers', 'getBaseUrls', 'getLists'], } +export interface iSolJsonBinDataBuild { + path: string, + version: string, + build: string, + longVersion: string, +} +export interface iSolJsonBinData { + baseURLWasm: string, + baseURLBin: string, + wasmList: iSolJsonBinDataBuild[], + binList: iSolJsonBinDataBuild[] +} + class CompilerLoaderPluginClient extends ElectronBasePluginClient { constructor(webContentsId: number, profile: Profile) { super(webContentsId, profile) } + async onActivation(): Promise { + const lists = await this.getLists() + console.log('onActivation', (server.address() as any)) + const baseURLS: iSolJsonBinData = { + baseURLWasm: 'http://localhost:' + (server.address() as any).port + '/compilers', + baseURLBin: 'http://localhost:' + (server.address() as any).port + '/compilers', + wasmList: lists.wasmData, + binList: lists.binData + } + this.emit('setSolJsonBinData', baseURLS) + } + async getPort(): Promise { return (server.address() as any).port } @@ -153,7 +178,7 @@ const getLists = async()=>{ } return { - binData, wasmData + binData: binData.builds as any[], wasmData: wasmData.builds as any[] } } \ No newline at end of file diff --git a/libs/remix-lib/src/index.ts b/libs/remix-lib/src/index.ts index e92b00cab8..a2ff565543 100644 --- a/libs/remix-lib/src/index.ts +++ b/libs/remix-lib/src/index.ts @@ -17,7 +17,7 @@ import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import * as txResultHelper from './helpers/txResultHelper' export { ConsoleLogs } from './helpers/hhconsoleSigs' -export { ICompilerApi, ConfigurationSettings } from './types/ICompilerApi' +export { ICompilerApi, ConfigurationSettings, iSolJsonBinData, iSolJsonBinDataBuild } from './types/ICompilerApi' export { QueryParams } from './query-params' export { VMexecutionResult } from './execution/txRunnerVM' export { Registry } from './registry' diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 014fa3966e..8ba32a1c96 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -48,6 +48,20 @@ export interface ICompilerApi { emit?: (key: string, ...payload: any) => void compilersDownloaded: (list: string[]) => void + setSolJsonBinData: (binData: iSolJsonBinData) => void +} + +export interface iSolJsonBinDataBuild { + path: string, + version: string, + build: string, + longVersion: string, +} +export interface iSolJsonBinData { + baseURLWasm: string, + baseURLBin: string, + wasmList: iSolJsonBinDataBuild[], + binList: iSolJsonBinDataBuild[] } export type terminalLog = { 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 e5094000fa..0645b81aa6 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 @@ -1,7 +1,7 @@ import React from 'react'; import { compile, helper } from '@remix-project/remix-solidity' import { CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line -import type { ConfigurationSettings } from '@remix-project/remix-lib' +import type { ConfigurationSettings, iSolJsonBinData } from '@remix-project/remix-lib' export const CompilerApiMixin = (Base) => class extends Base { currentFile: string @@ -29,6 +29,7 @@ export const CompilerApiMixin = (Base) => class extends Base { statusChanged: (data: { key: string, title?: string, type?: string }) => void compilersDownloaded: (list: string[]) => void + setSolJsonBinData: (urls: iSolJsonBinData) => void initCompilerApi () { this.configurationSettings = null @@ -293,6 +294,11 @@ export const CompilerApiMixin = (Base) => class extends Base { this.compilersDownloaded(list) }) + this.on('compilerloader', 'setSolJsonBinData', (urls: iSolJsonBinData) => { + console.log('basuURLS', urls) + this.setSolJsonBinData(urls) + }) + this.data.eventHandlers.onCompilationFinished = async (success, data, source, input, version) => { this.compileErrors = data if (success) { 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 dda76e1192..ee51424108 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -5,8 +5,10 @@ import {ContractSelection} from './contract-selection' // eslint-disable-line import {Toaster} from '@remix-ui/toaster' // eslint-disable-line import {ModalDialog} from '@remix-ui/modal-dialog' // eslint-disable-line import {Renderer} from '@remix-ui/renderer' // eslint-disable-line +import {baseURLBin, baseURLWasm} from '@remix-project/remix-solidity' import './css/style.css' +import { iSolJsonBinData } from '@remix-project/remix-lib' export const SolidityCompiler = (props: SolidityCompilerProps) => { const { @@ -36,7 +38,13 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { cancelFn: () => {}, handleHide: null }, - compilersDownloaded: [] + compilersDownloaded: [], + solJsonBinData: { + baseURLBin, + baseURLWasm, + binList: [], + wasmList: [] + } }) const [currentVersion, setCurrentVersion] = useState('') const [hideWarnings, setHideWarnings] = useState(false) @@ -142,6 +150,13 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { }) } + api.setSolJsonBinData = (urls: iSolJsonBinData) => { + setState((prevState) => { + return {...prevState, baseURLS: urls} + }) + } + + const setConfigFilePath = (path: string) => { setState((prevState) => { return {...prevState, configFilePath: path} @@ -230,6 +245,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { configFilePath={state.configFilePath} setConfigFilePath={setConfigFilePath} compilersDownloaded={state.compilersDownloaded} + solJsonBinData={state.solJsonBinData} /> {contractsFile[currentFile] && contractsFile[currentFile].contractsDetails && ( diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index f95d0116a4..6024b8d22e 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -1,4 +1,4 @@ -import { ICompilerApi, ConfigurationSettings } from '@remix-project/remix-lib' +import { ICompilerApi, ConfigurationSettings, iSolJsonBinData } from '@remix-project/remix-lib' import { CompileTabLogic } from '../logic/compileTabLogic' export type onCurrentFileChanged = (fileName: string) => void @@ -22,7 +22,10 @@ export interface CompilerContainerProps { configFilePath: string, setConfigFilePath: (path: string) => void, compilersDownloaded: string[] + solJsonBinData: iSolJsonBinData } + + export interface ContractSelectionProps { api: ICompilerApi, compiledFileName: string,