Commit ac09e459 authored by gxkai's avatar gxkai

chore: ts

parent 22133140
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 type { CompilationResult } from '@remix-project/remix-solidity-ts'
......@@ -9,7 +9,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
initDebuggerApi () {
this.debugHash = null
const self = this
this.web3Provider = {
sendAsync (payload, callback) {
......@@ -94,7 +94,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
let web3
let network
try {
network = await this.call('network', 'detectNetwork')
network = await this.call('network', 'detectNetwork')
} catch (e) {
web3 = this.web3()
}
......@@ -110,7 +110,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
if (!hash) return
const web3 = await this.getDebugWeb3()
const currentReceipt = await web3.eth.getTransactionReceipt(hash)
const debug = new Debugger({
const debug = new remixDebug.TransactionDebugger({
web3,
offsetToLineColumnConverter: this.offsetToLineColumnConverter,
compilationResult: async (address) => {
......@@ -137,7 +137,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
onActivation () {
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', '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) })
}
......@@ -171,6 +171,6 @@ export class CompilerAbstract implements CompilationOutput { // this is a subset
return sourcesArray[0]
}
return null
}
}
}
......@@ -167,7 +167,7 @@ class ContractDropdownUI {
<!-- <div class="${css.button} ${css.atAddressSect}">-->
<!-- ${this.atAddress} -->
<!-- ${this.atAddressButtonInput} -->
</div>
<!--</div>-->
</div>
</div>
`
......
module.exports = {
"presets": ["@babel/preset-react", "@babel/preset-typescript"],
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
\ No newline at end of file
presets: ['@babel/preset-react', '@babel/preset-typescript'],
plugins: ['@babel/plugin-transform-modules-commonjs', '@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@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'
import { Plugin } from '@remixproject/engine'
import { sourceMappingDecoder } from '@remix-project/remix-debug'
import remixDebug from '@remix-project/remix-debug'
const profile = {
name: 'offsetToLineColumnConverter',
......@@ -16,7 +16,7 @@ export class OffsetToLineColumnConverter extends Plugin {
constructor () {
super(profile)
this.lineBreakPositionsByContent = {}
this.sourceMappingDecoder = sourceMappingDecoder
this.sourceMappingDecoder = remixDebug.sourceMappingDecoder
}
/**
......
import Web3 from 'web3'
import { Debugger } from '../debugger/debugger.js'
import { Debugger } from '../debugger/debugger'
import { EventEmitter } from 'events'
export class CmdLine {
......
......@@ -18,7 +18,7 @@ import * as traceHelper from './trace/traceHelper'
})
this.debugger.setBreakpointManager(breakPointManager)
*/
export = {
export default {
init,
traceHelper,
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;
......
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;
......
......@@ -4,6 +4,8 @@ import path from 'path'
import Log from './logger'
import { Compiler as RemixCompiler } from '@remix-project/remix-solidity'
import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types'
import { testsAccountSol } from '../sol/tests_accounts.sol'
import { testsSol } from '../sol/tests.sol'
const logger = new Log()
const log = logger.logger
......@@ -13,7 +15,7 @@ function regexIndexOf (inputString: string, regex: RegExp, startpos = 0) {
}
function writeTestAccountsContract (accounts: string[]) {
const testAccountContract = require('../sol/tests_accounts.sol')
const testAccountContract = testsAccountSol
let body = `address[${accounts.length}] memory accounts;`
if (!accounts.length) body += ';'
else {
......@@ -88,8 +90,8 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts
let compiler: any
const accounts: string[] = opts.accounts || []
const sources: SrcIfc = {
'tests.sol': { content: require('../sol/tests.sol') },
'remix_tests.sol': { content: require('../sol/tests.sol') },
'tests.sol': { content: testsSol },
'remix_tests.sol': { content: testsSol },
'remix_accounts.sol': { content: writeTestAccountsContract(accounts) }
}
const filepath: string = (isDirectory ? filename : path.dirname(filename))
......@@ -176,8 +178,8 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile
const filepath = opts.testFilePath || ''
// Iterate over sources keys. Inject test libraries. Inject test library import statements.
if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) {
sources['tests.sol'] = { content: require('../sol/tests.sol.js') }
sources['remix_tests.sol'] = { content: require('../sol/tests.sol.js') }
sources['tests.sol'] = { content: testsSol }
sources['remix_tests.sol'] = { content: testsSol }
sources['remix_accounts.sol'] = { content: writeTestAccountsContract(accounts) }
}
const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
......
......@@ -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 { UnitTestRunner } from './runTestSources'
export { runTest } from './testRunner'
export * from './types'
export const assertLibCode = require('../sol/tests.sol')
export const assertLibCode = testsSol
......@@ -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
import StepManager from './step-manager/step-manager' // 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 { 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 { Toaster } from '@remix-ui/toaster' // eslint-disable-line
/* eslint-disable-next-line */
......@@ -214,7 +214,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
console.log(e.message)
}
const debuggerInstance = new Debugger({
const debuggerInstance = new remixDebug.TransactionDebugger({
web3,
offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter,
compilationResult: async (address) => {
......
......@@ -94,7 +94,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements
}
// eslint-disable-next-line no-use-before-define
export = LocalPlugin
export default LocalPlugin
declare class LocalPlugin {
/**
* Open a modal to create a local plugin
......
This diff is collapsed.
......@@ -14,31 +14,32 @@
"lib": ["es2017", "es2019", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@remix-project/remix-analyzer": [
"dist/libs/remix-analyzer/src/index.js"
"libs/remix-analyzer/src/index.ts"
],
"@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-lib": ["dist/libs/remix-lib/src/index.js"],
"@remix-project/remix-debug": ["libs/remix-debug/src/index.ts"],
"@remix-project/remix-lib": ["libs/remix-lib/src/index.ts"],
"@remix-project/remix-simulator": [
"dist/libs/remix-simulator/src/index.js"
"libs/remix-simulator/src/index.ts"
],
"@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": [
"dist/libs/remix-url-resolver/src/index.js"
"libs/remix-url-resolver/src/index.ts"
],
"@remixproject/debugger-plugin": ["apps/debugger/src/index.ts"],
"@remixproject/solidity-compiler-plugin": [
"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/debugger-ui": ["libs/remix-ui/debugger-ui/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