Commit ac09e459 authored by gxkai's avatar gxkai

chore: ts

parent 22133140
import Web3 from 'web3' import Web3 from 'web3'
import remixDebug, { TransactionDebugger as Debugger } from '@remix-project/remix-debug' import remixDebug from '@remix-project/remix-debug'
import { CompilationOutput, Sources } from '@remix-ui/debugger-ui' import { CompilationOutput, Sources } from '@remix-ui/debugger-ui'
import type { CompilationResult } from '@remix-project/remix-solidity-ts' import type { CompilationResult } from '@remix-project/remix-solidity-ts'
...@@ -9,7 +9,7 @@ export const DebuggerApiMixin = (Base) => class extends Base { ...@@ -9,7 +9,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
initDebuggerApi () { initDebuggerApi () {
this.debugHash = null this.debugHash = null
const self = this const self = this
this.web3Provider = { this.web3Provider = {
sendAsync (payload, callback) { sendAsync (payload, callback) {
...@@ -94,7 +94,7 @@ export const DebuggerApiMixin = (Base) => class extends Base { ...@@ -94,7 +94,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
let web3 let web3
let network let network
try { try {
network = await this.call('network', 'detectNetwork') network = await this.call('network', 'detectNetwork')
} catch (e) { } catch (e) {
web3 = this.web3() web3 = this.web3()
} }
...@@ -110,7 +110,7 @@ export const DebuggerApiMixin = (Base) => class extends Base { ...@@ -110,7 +110,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
if (!hash) return if (!hash) return
const web3 = await this.getDebugWeb3() const web3 = await this.getDebugWeb3()
const currentReceipt = await web3.eth.getTransactionReceipt(hash) const currentReceipt = await web3.eth.getTransactionReceipt(hash)
const debug = new Debugger({ const debug = new remixDebug.TransactionDebugger({
web3, web3,
offsetToLineColumnConverter: this.offsetToLineColumnConverter, offsetToLineColumnConverter: this.offsetToLineColumnConverter,
compilationResult: async (address) => { compilationResult: async (address) => {
...@@ -137,7 +137,7 @@ export const DebuggerApiMixin = (Base) => class extends Base { ...@@ -137,7 +137,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
onActivation () { onActivation () {
this.on('editor', 'breakpointCleared', (fileName, row) => { if (this.onBreakpointClearedListener) this.onBreakpointClearedListener(fileName, row) }) this.on('editor', 'breakpointCleared', (fileName, row) => { if (this.onBreakpointClearedListener) this.onBreakpointClearedListener(fileName, row) })
this.on('editor', 'breakpointAdded', (fileName, row) => { if (this.onBreakpointAddedListener) this.onBreakpointAddedListener(fileName, row) }) this.on('editor', 'breakpointAdded', (fileName, row) => { if (this.onBreakpointAddedListener) this.onBreakpointAddedListener(fileName, row) })
this.on('editor', 'contentChanged', () => { if (this.onEditorContentChangedListener) this.onEditorContentChangedListener() }) this.on('editor', 'contentChanged', () => { if (this.onEditorContentChangedListener) this.onEditorContentChangedListener() })
this.on('network', 'providerChanged', (provider) => { if (this.onEnvChangedListener) this.onEnvChangedListener(provider) }) this.on('network', 'providerChanged', (provider) => { if (this.onEnvChangedListener) this.onEnvChangedListener(provider) })
} }
...@@ -171,6 +171,6 @@ export class CompilerAbstract implements CompilationOutput { // this is a subset ...@@ -171,6 +171,6 @@ export class CompilerAbstract implements CompilationOutput { // this is a subset
return sourcesArray[0] return sourcesArray[0]
} }
return null return null
} }
} }
...@@ -167,7 +167,7 @@ class ContractDropdownUI { ...@@ -167,7 +167,7 @@ class ContractDropdownUI {
<!-- <div class="${css.button} ${css.atAddressSect}">--> <!-- <div class="${css.button} ${css.atAddressSect}">-->
<!-- ${this.atAddress} --> <!-- ${this.atAddress} -->
<!-- ${this.atAddressButtonInput} --> <!-- ${this.atAddressButtonInput} -->
</div> <!--</div>-->
</div> </div>
</div> </div>
` `
......
module.exports = { module.exports = {
"presets": ["@babel/preset-react", "@babel/preset-typescript"], presets: ['@babel/preset-react', '@babel/preset-typescript'],
"plugins": ["@babel/plugin-transform-modules-commonjs"] plugins: ['@babel/plugin-transform-modules-commonjs', '@babel/plugin-proposal-nullish-coalescing-operator',
} '@babel/plugin-proposal-optional-chaining',
\ No newline at end of file '@babel/plugin-proposal-numeric-separator',
[
'@babel/plugin-proposal-decorators',
{
legacy: true
}
],
[
'@babel/plugin-proposal-class-properties',
{
legacy: true
}
],
[
'@babel/plugin-transform-runtime'
]
],
babelrcRoots: [
'*'
]
}
'use strict' 'use strict'
import { Plugin } from '@remixproject/engine' import { Plugin } from '@remixproject/engine'
import { sourceMappingDecoder } from '@remix-project/remix-debug' import remixDebug from '@remix-project/remix-debug'
const profile = { const profile = {
name: 'offsetToLineColumnConverter', name: 'offsetToLineColumnConverter',
...@@ -16,7 +16,7 @@ export class OffsetToLineColumnConverter extends Plugin { ...@@ -16,7 +16,7 @@ export class OffsetToLineColumnConverter extends Plugin {
constructor () { constructor () {
super(profile) super(profile)
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.sourceMappingDecoder = sourceMappingDecoder this.sourceMappingDecoder = remixDebug.sourceMappingDecoder
} }
/** /**
......
import Web3 from 'web3' import Web3 from 'web3'
import { Debugger } from '../debugger/debugger.js' import { Debugger } from '../debugger/debugger'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
export class CmdLine { export class CmdLine {
......
...@@ -18,7 +18,7 @@ import * as traceHelper from './trace/traceHelper' ...@@ -18,7 +18,7 @@ import * as traceHelper from './trace/traceHelper'
}) })
this.debugger.setBreakpointManager(breakPointManager) this.debugger.setBreakpointManager(breakPointManager)
*/ */
export = { export default {
init, init,
traceHelper, traceHelper,
sourceMappingDecoder, sourceMappingDecoder,
......
module.exports = `// SPDX-License-Identifier: GPL-3.0 export const testsSol = `// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0; pragma solidity >=0.4.22 <0.9.0;
......
module.exports = `// SPDX-License-Identifier: GPL-3.0 export const testsAccountSol = `// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0; pragma solidity >=0.4.22 <0.9.0;
......
...@@ -4,6 +4,8 @@ import path from 'path' ...@@ -4,6 +4,8 @@ import path from 'path'
import Log from './logger' import Log from './logger'
import { Compiler as RemixCompiler } from '@remix-project/remix-solidity' import { Compiler as RemixCompiler } from '@remix-project/remix-solidity'
import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types' import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types'
import { testsAccountSol } from '../sol/tests_accounts.sol'
import { testsSol } from '../sol/tests.sol'
const logger = new Log() const logger = new Log()
const log = logger.logger const log = logger.logger
...@@ -13,7 +15,7 @@ function regexIndexOf (inputString: string, regex: RegExp, startpos = 0) { ...@@ -13,7 +15,7 @@ function regexIndexOf (inputString: string, regex: RegExp, startpos = 0) {
} }
function writeTestAccountsContract (accounts: string[]) { function writeTestAccountsContract (accounts: string[]) {
const testAccountContract = require('../sol/tests_accounts.sol') const testAccountContract = testsAccountSol
let body = `address[${accounts.length}] memory accounts;` let body = `address[${accounts.length}] memory accounts;`
if (!accounts.length) body += ';' if (!accounts.length) body += ';'
else { else {
...@@ -88,8 +90,8 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts ...@@ -88,8 +90,8 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts
let compiler: any let compiler: any
const accounts: string[] = opts.accounts || [] const accounts: string[] = opts.accounts || []
const sources: SrcIfc = { const sources: SrcIfc = {
'tests.sol': { content: require('../sol/tests.sol') }, 'tests.sol': { content: testsSol },
'remix_tests.sol': { content: require('../sol/tests.sol') }, 'remix_tests.sol': { content: testsSol },
'remix_accounts.sol': { content: writeTestAccountsContract(accounts) } 'remix_accounts.sol': { content: writeTestAccountsContract(accounts) }
} }
const filepath: string = (isDirectory ? filename : path.dirname(filename)) const filepath: string = (isDirectory ? filename : path.dirname(filename))
...@@ -176,8 +178,8 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile ...@@ -176,8 +178,8 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile
const filepath = opts.testFilePath || '' const filepath = opts.testFilePath || ''
// Iterate over sources keys. Inject test libraries. Inject test library import statements. // Iterate over sources keys. Inject test libraries. Inject test library import statements.
if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) { if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) {
sources['tests.sol'] = { content: require('../sol/tests.sol.js') } sources['tests.sol'] = { content: testsSol }
sources['remix_tests.sol'] = { content: require('../sol/tests.sol.js') } sources['remix_tests.sol'] = { content: testsSol }
sources['remix_accounts.sol'] = { content: writeTestAccountsContract(accounts) } sources['remix_accounts.sol'] = { content: writeTestAccountsContract(accounts) }
} }
const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
......
...@@ -17,4 +17,4 @@ fs.walkSync = function (start: string, callback) { ...@@ -17,4 +17,4 @@ fs.walkSync = function (start: string, callback) {
}) })
} }
export = fs export default fs
import { testsSol } from '../sol/tests.sol'
export { runTestFiles } from './runTestFiles' export { runTestFiles } from './runTestFiles'
export { UnitTestRunner } from './runTestSources' export { UnitTestRunner } from './runTestSources'
export { runTest } from './testRunner' export { runTest } from './testRunner'
export * from './types' export * from './types'
export const assertLibCode = require('../sol/tests.sol') export const assertLibCode = testsSol
...@@ -55,4 +55,4 @@ class Log { ...@@ -55,4 +55,4 @@ class Log {
} }
} }
export = Log export default Log
...@@ -3,7 +3,7 @@ import TxBrowser from './tx-browser/tx-browser' // eslint-disable-line ...@@ -3,7 +3,7 @@ import TxBrowser from './tx-browser/tx-browser' // eslint-disable-line
import StepManager from './step-manager/step-manager' // eslint-disable-line import StepManager from './step-manager/step-manager' // eslint-disable-line
import VmDebugger from './vm-debugger/vm-debugger' // eslint-disable-line import VmDebugger from './vm-debugger/vm-debugger' // eslint-disable-line
import VmDebuggerHead from './vm-debugger/vm-debugger-head' // eslint-disable-line import VmDebuggerHead from './vm-debugger/vm-debugger-head' // eslint-disable-line
import { TransactionDebugger as Debugger } from '@remix-project/remix-debug' // eslint-disable-line import remixDebug from '@remix-project/remix-debug' // eslint-disable-line
import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
/* eslint-disable-next-line */ /* eslint-disable-next-line */
...@@ -214,7 +214,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { ...@@ -214,7 +214,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
console.log(e.message) console.log(e.message)
} }
const debuggerInstance = new Debugger({ const debuggerInstance = new remixDebug.TransactionDebugger({
web3, web3,
offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter, offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter,
compilationResult: async (address) => { compilationResult: async (address) => {
......
...@@ -94,7 +94,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements ...@@ -94,7 +94,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements
} }
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
export = LocalPlugin export default LocalPlugin
declare class LocalPlugin { declare class LocalPlugin {
/** /**
* Open a modal to create a local plugin * Open a modal to create a local plugin
......
This diff is collapsed.
...@@ -14,31 +14,32 @@ ...@@ -14,31 +14,32 @@
"lib": ["es2017", "es2019", "dom"], "lib": ["es2017", "es2019", "dom"],
"skipLibCheck": true, "skipLibCheck": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@remix-project/remix-analyzer": [ "@remix-project/remix-analyzer": [
"dist/libs/remix-analyzer/src/index.js" "libs/remix-analyzer/src/index.ts"
], ],
"@remix-project/remix-astwalker": [ "@remix-project/remix-astwalker": [
"dist/libs/remix-astwalker/src/index.js" "libs/remix-astwalker/src/index.ts"
], ],
"@remix-project/remix-debug": ["dist/libs/remix-debug/src/index.js"], "@remix-project/remix-debug": ["libs/remix-debug/src/index.ts"],
"@remix-project/remix-lib": ["dist/libs/remix-lib/src/index.js"], "@remix-project/remix-lib": ["libs/remix-lib/src/index.ts"],
"@remix-project/remix-simulator": [ "@remix-project/remix-simulator": [
"dist/libs/remix-simulator/src/index.js" "libs/remix-simulator/src/index.ts"
], ],
"@remix-project/remix-solidity": [ "@remix-project/remix-solidity": [
"dist/libs/remix-solidity/src/index.js" "libs/remix-solidity/src/index.ts"
], ],
"@remix-project/remix-tests": ["dist/libs/remix-tests/src/index.js"], "@remix-project/remix-tests": ["libs/remix-tests/src/index.ts"],
"@remix-project/remix-url-resolver": [ "@remix-project/remix-url-resolver": [
"dist/libs/remix-url-resolver/src/index.js" "libs/remix-url-resolver/src/index.ts"
], ],
"@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"], "@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"],
"@remixproject/solidity-compiler-plugin": [ "@remixproject/solidity-compiler-plugin": [
"apps/solidity-compiler/src/index.ts" "apps/solidity-compiler/src/index.ts"
], ],
"@remix-project/remixd": ["dist/libs/remixd/index.js"], "@remix-project/remixd": ["libs/remixd/index.ts"],
"@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"], "@remix-ui/tree-view": ["libs/remix-ui/tree-view/src/index.ts"],
"@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"], "@remix-ui/debugger-ui": ["libs/remix-ui/debugger-ui/src/index.ts"],
"@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"], "@remix-ui/utils": ["libs/remix-ui/utils/src/index.ts"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment