better org of types

pull/1584/head
yann300 3 years ago
parent 5a22644c4f
commit 49c62946c9
  1. 3
      apps/remix-ide/src/app/tabs/compile-tab.js
  2. 3
      apps/solidity-compiler/src/app/compiler.ts
  3. 55
      libs/remix-lib/src/index.ts
  4. 41
      libs/remix-lib/src/types/ICompilerApi.ts
  5. 3
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  6. 45
      libs/remix-ui/solidity-compiler/src/lib/types/index.ts

@ -4,6 +4,7 @@ import ReactDOM from 'react-dom'
import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line import { SolidityCompiler, CompileTab as CompileTabLogic, parseContracts } from '@remix-ui/solidity-compiler' // eslint-disable-line
import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin'
import { ViewPlugin } from '@remixproject/engine-web' import { ViewPlugin } from '@remixproject/engine-web'
import { ICompilerApi } from '@remix-project/remix-lib-ts'
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
const EventEmitter = require('events') const EventEmitter = require('events')
@ -32,7 +33,7 @@ const profile = {
// - events: ['compilationFinished'], // - events: ['compilationFinished'],
// - methods: ['getCompilationResult'] // - methods: ['getCompilationResult']
class CompileTab extends CompilerApiMixin(ViewPlugin) { class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi
constructor () { constructor () {
super(profile) super(profile)
this.initCompilerApi() this.initCompilerApi()

@ -1,6 +1,7 @@
import { PluginClient } from "@remixproject/plugin"; import { PluginClient } from "@remixproject/plugin";
import { createClient } from "@remixproject/plugin-webview"; import { createClient } from "@remixproject/plugin-webview";
import { CompilerApiMixin } from './compiler-api' import { CompilerApiMixin } from './compiler-api'
import { ICompilerApi } from '@remix-project/remix-lib-ts'
const profile = { const profile = {
name: 'solidity', name: 'solidity',
@ -23,7 +24,7 @@ export interface ConfigurationSettings {
runs: string runs: string
} }
export class CompilerClientApi extends CompilerApiMixin(PluginClient) { export class CompilerClientApi extends CompilerApiMixin(PluginClient) implements ICompilerApi {
// interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi // interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi
currentFile: string currentFile: string
contractMap: { contractMap: {

@ -18,36 +18,29 @@ import * as typeConversion from './execution/typeConversion'
import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerVM } from './execution/txRunnerVM'
import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import { TxRunnerWeb3 } from './execution/txRunnerWeb3'
import * as txResultHelper from './helpers/txResultHelper' import * as txResultHelper from './helpers/txResultHelper'
export { ICompilerApi, ConfigurationSettings} from './types/ICompilerApi'
export = modules() const helpers = {
ui: uiHelper,
function modules () { compiler: compilerHelper,
return { txResultHelper
EventManager: EventManager, }
helpers: { const vm = {
ui: uiHelper, Web3Providers: Web3Providers,
compiler: compilerHelper, DummyProvider: DummyProvider,
txResultHelper Web3VMProvider: Web3VmProvider
}, }
vm: { const execution = {
Web3Providers: Web3Providers, EventsDecoder: EventsDecoder,
DummyProvider: DummyProvider, txExecution: txExecution,
Web3VMProvider: Web3VmProvider txHelper: txHelper,
}, txFormat: txFormat,
Storage: Storage, txListener: TxListener,
util: util, TxRunner: TxRunner,
execution: { TxRunnerWeb3: TxRunnerWeb3,
EventsDecoder: EventsDecoder, TxRunnerVM: TxRunnerVM,
txExecution: txExecution, typeConversion: typeConversion,
txHelper: txHelper, LogsManager,
txFormat: txFormat, forkAt
txListener: TxListener,
TxRunner: TxRunner,
TxRunnerWeb3: TxRunnerWeb3,
TxRunnerVM: TxRunnerVM,
typeConversion: typeConversion,
LogsManager,
forkAt
}
}
} }
export { EventManager, helpers, vm, Storage, util, execution }

@ -0,0 +1,41 @@
export interface ICompilerApi {
currentFile: string
contractMap: {
file: string
} | Record<string, any>
compileErrors: any
compileTabLogic: any
contractsDetails: Record<string, any>
configurationSettings: ConfigurationSettings
setHardHatCompilation: (value: boolean) => void
getParameters: () => any
setParameters: (params) => void
getConfiguration: (value: string) => string
setConfiguration: (name: string, value: string) => void
getFileManagerMode: () => string
setCompilerConfig: (settings: any) => void
getCompilationResult: () => any
onCurrentFileChanged: (fileName: string) => void
onResetResults: () => void,
onSetWorkspace: (workspace: any) => void
onNoFileSelected: () => void
onCompilationFinished: (contractsDetails: any, contractMap: any) => void
onSessionSwitched: () => void
onContentChanged: () => void
fileExists: (file: string) => Promise<boolean>
writeFile: (file: string, content: string) => Promise<void>
readFile: (file: string) => Promise<string>
open: (file: string) => void
}
export interface ConfigurationSettings {
version: string,
evmVersion: string,
language: string,
optimize: boolean,
runs: string
}

@ -1,6 +1,7 @@
import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line
import semver from 'semver' import semver from 'semver'
import { CompilerContainerProps, ConfigurationSettings } from './types' import { CompilerContainerProps } from './types'
import { ConfigurationSettings } from '@remix-project/remix-lib-ts'
import * as helper from '../../../../../apps/remix-ide/src/lib/helper' import * as helper from '../../../../../apps/remix-ide/src/lib/helper'
import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity'
import { compilerReducer, compilerInitialState } from './reducers/compiler' import { compilerReducer, compilerInitialState } from './reducers/compiler'

@ -1,43 +1,10 @@
import { ICompilerApi, ConfigurationSettings } from '@remix-project/remix-lib-ts'
export type onCurrentFileChanged = (fileName: string) => void export type onCurrentFileChanged = (fileName: string) => void
export interface SolidityCompilerProps { export interface SolidityCompilerProps {
plugin: ICompilerApi plugin: ICompilerApi
} }
export interface ICompilerApi {
currentFile: string
contractMap: {
file: string
} | Record<string, any>
compileErrors: any
compileTabLogic: any
contractsDetails: Record<string, any>
configurationSettings: ConfigurationSettings
setHardHatCompilation: (value: boolean) => void
getParameters: () => any
setParameters: (params) => void
getConfiguration: (value: string) => string
setConfiguration: (name: string, value: string) => void
getFileManagerMode: () => string
setCompilerConfig: (settings: any) => void
getCompilationResult: () => any
onCurrentFileChanged: (fileName: string) => void
onResetResults: () => void,
onSetWorkspace: (isLocalhost: boolean) => void
onNoFileSelected: () => void
onCompilationFinished: (contractsDetails: any, contractMap: any) => void
onSessionSwitched: () => void
onContentChanged: () => void
fileExists: (file: string) => Promise<boolean>
writeFile: (file: string, content: string) => Promise<void>
readFile: (file: string) => Promise<string>
open: (file: string) => void
}
export interface CompilerContainerProps { export interface CompilerContainerProps {
api: any, api: any,
compileTabLogic: any, compileTabLogic: any,
@ -55,12 +22,4 @@ export interface ContractSelectionProps {
} | Record<string, any>, } | Record<string, any>,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
contractsDetails: Record<string, any> contractsDetails: Record<string, any>
} }
export interface ConfigurationSettings {
version: string,
evmVersion: string,
language: string,
optimize: boolean,
runs: string
}
Loading…
Cancel
Save