remove undeed info

pull/426/head
yann300 4 years ago
parent c07f9ec5ac
commit 651264fa54
  1. 7
      apps/remix-ide/src/app/panels/terminal.js
  2. 156
      apps/remix-ide/src/lib/cmdInterpreterAPI.js
  3. 13
      apps/remix-ide/src/lib/commands.js

@ -447,7 +447,7 @@ class Terminal extends Plugin {
<div><div> - Welcome to Remix ${packageJson.version} - </div><br>
<div>You can use this terminal for: </div>
<ul class=${css2.ul}>
<li>Checking transactions details and start debugging.</li>
<li>Check transactions details and start debugging.</li>
<li>Running JavaScript scripts. The following libraries are accessible:
<ul class=${css2.ul}>
<li><a target="_blank" href="https://web3js.readthedocs.io/en/1.0/">web3 version 1.0.0</a></li>
@ -456,9 +456,10 @@ class Terminal extends Plugin {
<li>remix (run remix.help() for more info)</li>
</ul>
</li>
<li>Executing common command to interact with the Remix interface (see list of commands above). Note that these commands can also be included and run from a JavaScript script.</li>
<li>Use exports/.register(key, obj)/.remove(key)/.clear() to register and reuse object across script executions.</li>
</ul>
<i> - Directly input a script in the command line interface </i>
<i> - Select a Javascript file in the file explorer and run \`remix.execute()\` </i>
<i> - Right click on a JavaScript file in the file explorer and click \`Run Script\` </i>
</div>
`

@ -31,112 +31,14 @@ class CmdInterpreterAPI {
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api
}
self.commandHelp = {
'remix.call(message: {name, key, payload})': 'Call a registered plugins',
'remix.getFile(path)': 'Returns the content of the file located at the given path',
'remix.setFile(path, content)': 'set the content of the file located at the given path',
'remix.debug(hash)': 'Start debugging a transaction.',
'remix.loadgist(id)': 'Load a gist in the file explorer.',
'remix.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm, ipfs or raw http',
'remix.setproviderurl(url)': 'Change the current provider to Web3 provider and set the url endpoint.',
'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.',
'remix.exeCurrent()': 'Run the script currently displayed in the editor',
'remix.help()': 'Display this help message',
'remix.debugHelp()': 'Display help message for debugging'
}
}
call (message) {
return this._components.terminal.externalApi.request(message)
}
log () { arguments[0] != null ? this._components.terminal.commands.html(arguments[0]) : this._components.terminal.commands.html(arguments[1]) }
highlight (rawLocation) {
var self = this
if (!rawLocation) {
self._components.sourceHighlighter.currentSourceLocation(null)
return
}
var lineColumnPos = self._deps.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file,
self._deps.compilersArtefacts['__last'].getSourceCode().sources,
self._deps.compilersArtefacts['__last'].getAsts())
self._components.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation)
}
debug (hash, cb) {
var self = this
delete self.d
self.blockchain.web3().eth.getTransaction(hash, (error, tx) => {
if (error) return cb(error)
var debugSession = new RemixDebug({
compilationResult: () => {
return self._deps.compilersArtefacts['__last'].getData()
}
})
debugSession.addProvider('web3', self.blockchain.web3())
debugSession.switchProvider('web3')
debugSession.debug(tx)
self.d = debugSession
this._components.terminal.commands.log('A new debugging session is available at remix.d')
if (cb) cb(null, debugSession)
// helpers
self.d.highlight = (address, vmtraceIndex) => {
if (!address) return self.highlight()
self.d.sourceLocationFromVMTraceIndex(address, vmtraceIndex, (error, rawLocation) => {
if (!error && rawLocation) {
self.highlight(rawLocation)
}
})
}
self.d.stateAt = (vmTraceIndex) => {
self.d.extractStateAt(vmTraceIndex, (error, state) => {
if (error) return self.log(error)
self.d.decodeStateAt(vmTraceIndex, state, (error, state) => {
if (error) return this._components.terminal.commands.html(error)
var treeView = new TreeView({
json: true,
formatSelf: solidityTypeFormatter.formatSelf,
extractData: solidityTypeFormatter.extractData
})
self.log('State at ' + vmTraceIndex)
self._components.terminal.commands.html(treeView.render(state, true))
})
})
}
self.d.localsAt = (contractAddress, vmTraceIndex) => {
debugSession.sourceLocationFromVMTraceIndex(contractAddress, vmTraceIndex, (error, location) => {
if (error) return self.log(error)
debugSession.decodeLocalsAt(23, location, (error, locals) => {
if (error) return this._components.terminal.commands.html(error)
var treeView = new TreeView({
json: true,
formatSelf: solidityTypeFormatter.formatSelf,
extractData: solidityTypeFormatter.extractData
})
self.log('Locals at ' + vmTraceIndex)
self._components.terminal.commands.html(treeView.render(locals, true))
})
})
}
self.d.goTo = (row) => {
if (self._deps.editor.current()) {
var breakPoint = new remixDebug.BreakpointManager(self.d, (sourceLocation) => {
return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file,
self._deps.compilersArtefacts['__last'].getSourceCode().sources,
self._deps.compilersArtefacts['__last'].getAsts())
})
breakPoint.event.register('breakpointHit', (sourceLocation, currentStep) => {
self.log(null, 'step index ' + currentStep)
self.highlight(sourceLocation)
self.d.stateAt(currentStep)
self.d.traceManager.getCurrentCalledAddressAt(currentStep, (error, address) => {
if (error) return self.log(address)
self.d.localsAt(address, currentStep)
})
})
breakPoint.event.register('NoBreakpointHit', () => { self.log('line ' + row + ' is not part of the current execution') })
breakPoint.add({fileName: self._deps.editor.current(), row: row - 1})
breakPoint.jumpNextBreakpoint(0, true)
}
}
})
}
loadgist (id, cb) {
const self = this
self._components.gistHandler.loadFromGist({gist: id}, this._deps.fileManager)
@ -179,36 +81,9 @@ class CmdInterpreterAPI {
}
})
}
setproviderurl (url, cb) {
this.blockchain.setProviderFromEndpoint(url, 'web3', (error) => {
if (error) toolTip(error)
if (cb) cb()
})
}
exeCurrent (cb) {
return this.execute(undefined, cb)
}
getFile (path, cb) {
var provider = this._deps.fileManager.fileProviderOf(path)
if (provider) {
provider.get(path, cb)
} else {
cb('file not found')
}
}
setFile (path, content, cb) {
cb = cb || function () {}
var provider = this._deps.fileManager.fileProviderOf(path)
if (provider) {
provider.set(path, content, (error) => {
if (error) return cb(error)
this._deps.fileManager.syncEditor(path)
cb()
})
} else {
cb('file not found')
}
}
execute (file, cb) {
const self = this
@ -257,37 +132,6 @@ class CmdInterpreterAPI {
if (cb) cb()
return ''
}
debugHelp (cb) {
const self = this
var help = yo`<div>Here are some examples of scripts that can be run (using remix.exeCurrent() or directly from the console)</div>`
help.appendChild(yo`<br>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>remix.debug('0x3c247ac268afb9a9c183feb9d4e83df51efbc8a2f4624c740789b788dac43029', function (error, debugSession) {
remix.log = function () { arguments[0] != null ? console.log(arguments[0]) : console.log(arguments[1]) }
remix.d.traceManager.getLength(remix.log)
remix.storageView = remix.d.storageViewAt(97, '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a')
console.log('storage at 97 :')
remix.storageView.storageRange(remix.log)
})<br/></div>`)
help.appendChild(yo`<div>remix.log = function () { arguments[0] != null ? console.log(arguments[0]) : console.log(arguments[1]) }
remix.d.extractStateAt(2, function (error, state) {
remix.d.decodeStateAt(97, state, remix.log)
})<br/></div>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>remix.highlight(contractAddress, vmTraceIndex)</div>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>remix.goTo(row) (this log the index in the vm trace, state and local variables)</div>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>remix.stateAt(vmTraceIndex)</div>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>remix.localsAt(vmTraceIndex)</div>`)
help.appendChild(yo`<br>`)
help.appendChild(yo`<div>Please see <a href="https://www.npmjs.com/package/remix-debug" target="_blank">https://www.npmjs.com/package/remix-debug</a> for more informations</div>`)
self._components.terminal.commands.html(help)
if (cb) cb()
return ''
}
}
module.exports = CmdInterpreterAPI

@ -6,16 +6,11 @@ const allPrograms = [
]
const allCommands = [
{'remix.debug(hash)': 'Start debugging a transaction.'},
{'remix.debugHelp()': 'Display help message for debugging'},
{'remix.execute(filepath)': 'Run the script specified by file path. If filepath is empty, script currently displayed in the editor is executed.'},
{'remix.exeCurrent()': 'Run the script currently displayed in the editor.'},
{'remix.getFile(path)': 'Returns the content of the file located at the given path'},
{'remix.help()': 'Display this help message.'},
{'remix.loadgist(id)': 'Load a gist in the file explorer.'},
{'remix.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm or ipfs.'},
{'remix.setFile(path, content)': 'set the content of the file located at the given path'},
{'remix.setproviderurl(url)': 'Change the current provider to Web3 provider and set the url endpoint.'},
{'swarmgw.get(url, cb)': 'Download files from Swarm via https://swarm-gateways.net/'},
{'swarmgw.put(content, cb)': 'Upload files to Swarm via https://swarm-gateways.net/'},
@ -30,8 +25,7 @@ const allCommands = [
{'ethers.utils.RLP': 'This encoding method is used internally for several aspects of Ethereum, such as encoding transactions and determining contract addresses.'},
{'ethers.Wallet': 'A wallet manages a private/public key pair which is used to cryptographically sign transactions and prove ownership on the Ethereum network.'},
{'ethers.version': 'Contains the version of the ethers container object.'},
{'web3.bzz': 'Bzz module for interacting with the swarm network.'},
{'web3.eth': 'Eth module for interacting with the Ethereum network.'},
{'web3.eth.accounts': 'The web3.eth.accounts contains functions to generate Ethereum accounts and sign transactions and data.'},
{'web3.eth.abi': 'The web3.eth.abi functions let you de- and encode parameters to ABI (Application Binary Interface) for function calls to the EVM (Ethereum Virtual Machine).'},
@ -50,6 +44,11 @@ const allCommands = [
{'web3.eth.clearSubscriptions();': 'Resets subscriptions.'},
{'web3.eth.Contract(jsonInterface[, address][, options])': 'The web3.eth.Contract object makes it easy to interact with smart contracts on the ethereum blockchain.'},
{'web3.eth.accounts.create([entropy]);': 'The web3.eth.accounts contains functions to generate Ethereum accounts and sign transactions and data.'}
{'web3.eth.getAccounts();': 'Retrieve the list of accounts'},
{'web3.eth.accounts.privateKeyToAccount(privateKey [, ignoreLength ]);': 'Get the account from the private key'},
{'web3.eth.accounts.signTransaction(tx, privateKey [, callback]);': 'Sign Transaction'},
{'web3.eth.accounts.recoverTransaction(rawTransaction);': 'Sign Transaction'},
{'web3.eth.accounts.hashMessage(message);': 'Hash message'},
]
module.exports = {

Loading…
Cancel
Save