better org of types

pull/5370/head
yann300 3 years ago
parent 1aff58dbfb
commit 25fc94e2d2
  1. 3
      apps/remix-ide/src/app/tabs/compile-tab.js
  2. 3
      apps/solidity-compiler/src/app/compiler.ts
  3. 21
      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. 43
      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,25 +18,19 @@ 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 = {
function modules () {
return {
EventManager: EventManager,
helpers: {
ui: uiHelper, ui: uiHelper,
compiler: compilerHelper, compiler: compilerHelper,
txResultHelper txResultHelper
}, }
vm: { const vm = {
Web3Providers: Web3Providers, Web3Providers: Web3Providers,
DummyProvider: DummyProvider, DummyProvider: DummyProvider,
Web3VMProvider: Web3VmProvider Web3VMProvider: Web3VmProvider
}, }
Storage: Storage, const execution = {
util: util,
execution: {
EventsDecoder: EventsDecoder, EventsDecoder: EventsDecoder,
txExecution: txExecution, txExecution: txExecution,
txHelper: txHelper, txHelper: txHelper,
@ -49,5 +43,4 @@ function modules () {
LogsManager, LogsManager,
forkAt 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,
@ -56,11 +23,3 @@ export interface ContractSelectionProps {
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