better org of types

pull/1342/head
yann300 3 years ago committed by davidzagi93@gmail.com
parent cded3a493a
commit 9df935f2a4
  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 { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin'
import { ViewPlugin } from '@remixproject/engine-web'
import { ICompilerApi } from '@remix-project/remix-lib-ts'
import * as packageJson from '../../../../../package.json'
const EventEmitter = require('events')
@ -32,7 +33,7 @@ const profile = {
// - events: ['compilationFinished'],
// - methods: ['getCompilationResult']
class CompileTab extends CompilerApiMixin(ViewPlugin) {
class CompileTab extends CompilerApiMixin(ViewPlugin) { // implements ICompilerApi
constructor () {
super(profile)
this.initCompilerApi()

@ -1,6 +1,7 @@
import { PluginClient } from "@remixproject/plugin";
import { createClient } from "@remixproject/plugin-webview";
import { CompilerApiMixin } from './compiler-api'
import { ICompilerApi } from '@remix-project/remix-lib-ts'
const profile = {
name: 'solidity',
@ -23,7 +24,7 @@ export interface ConfigurationSettings {
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
currentFile: string
contractMap: {

@ -18,36 +18,29 @@ import * as typeConversion from './execution/typeConversion'
import { TxRunnerVM } from './execution/txRunnerVM'
import { TxRunnerWeb3 } from './execution/txRunnerWeb3'
import * as txResultHelper from './helpers/txResultHelper'
export { ICompilerApi, ConfigurationSettings} from './types/ICompilerApi'
export = modules()
function modules () {
return {
EventManager: EventManager,
helpers: {
ui: uiHelper,
compiler: compilerHelper,
txResultHelper
},
vm: {
Web3Providers: Web3Providers,
DummyProvider: DummyProvider,
Web3VMProvider: Web3VmProvider
},
Storage: Storage,
util: util,
execution: {
EventsDecoder: EventsDecoder,
txExecution: txExecution,
txHelper: txHelper,
txFormat: txFormat,
txListener: TxListener,
TxRunner: TxRunner,
TxRunnerWeb3: TxRunnerWeb3,
TxRunnerVM: TxRunnerVM,
typeConversion: typeConversion,
LogsManager,
forkAt
}
}
const helpers = {
ui: uiHelper,
compiler: compilerHelper,
txResultHelper
}
const vm = {
Web3Providers: Web3Providers,
DummyProvider: DummyProvider,
Web3VMProvider: Web3VmProvider
}
const execution = {
EventsDecoder: EventsDecoder,
txExecution: txExecution,
txHelper: txHelper,
txFormat: txFormat,
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 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 { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity'
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 interface SolidityCompilerProps {
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 {
api: any,
compileTabLogic: any,
@ -55,12 +22,4 @@ export interface ContractSelectionProps {
} | Record<string, any>,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
contractsDetails: Record<string, any>
}
export interface ConfigurationSettings {
version: string,
evmVersion: string,
language: string,
optimize: boolean,
runs: string
}
}
Loading…
Cancel
Save