suggested changes and more ethereumjs-vm related update

pull/7/head
aniket-engg 5 years ago committed by Aniket
parent e052df4aa2
commit 399b878aa7
  1. 2
      remix-lib/src/code/opcodes.js
  2. 9
      remix-lib/src/execution/txListener.js
  3. 8
      remix-lib/src/helpers/txResultHelper.js
  4. 7
      remix-simulator/src/methods/txProcess.js

@ -2,7 +2,7 @@
var codes = { var codes = {
// 0x0 range - arithmetic ops // 0x0 range - arithmetic ops
// name, baseCost, off stack, on stack, dynamic, async // name, baseCost, off stack, on stack, dynamic, async
// @todo can be improved while refactoring // @todo can be improved on basis of this: https://github.com/ethereumjs/ethereumjs-vm/blob/master/lib/evm/opcodes.ts
0x00: ['STOP', 0, 0, 0, false], 0x00: ['STOP', 0, 0, 0, false],
0x01: ['ADD', 3, 2, 1, false], 0x01: ['ADD', 3, 2, 1, false],

@ -40,14 +40,13 @@ class TxListener {
// in web3 mode && listen remix txs only // in web3 mode && listen remix txs only
if (!this._isListening) return // we don't listen if (!this._isListening) return // we don't listen
if (this._loopId && executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network if (this._loopId && executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network
var call = { var call = {
from: from, from: from,
to: to, to: to,
input: data, input: data,
hash: txResult.transactionHash ? txResult.transactionHash : 'call' + (from || '') + to + data, hash: txResult.transactionHash ? txResult.transactionHash : 'call' + (from || '') + to + data,
isCall: true, isCall: true,
returnValue: executionContext.isVM() ? txResult.result.vm.return : ethJSUtil.toBuffer(txResult.result), returnValue: executionContext.isVM() ? txResult.result.execResult.returnValue : ethJSUtil.toBuffer(txResult.result),
envMode: executionContext.getProvider() envMode: executionContext.getProvider()
} }
@ -80,9 +79,9 @@ class TxListener {
function addExecutionCosts (txResult, tx) { function addExecutionCosts (txResult, tx) {
if (txResult && txResult.result) { if (txResult && txResult.result) {
if (txResult.result.vm) { if (txResult.result.execResult) {
tx.returnValue = txResult.result.vm.return tx.returnValue = txResult.result.execResult.returnValue
if (txResult.result.vm.gasUsed) tx.executionCost = txResult.result.vm.gasUsed.toString(10) if (txResult.result.execResult.gasUsed) tx.executionCost = txResult.result.execResult.gasUsed.toString(10)
} }
if (txResult.result.gasUsed) tx.transactionCost = txResult.result.gasUsed.toString(10) if (txResult.result.gasUsed) tx.transactionCost = txResult.result.gasUsed.toString(10)
} }

@ -21,14 +21,14 @@ function convertToPrefixedHex (input) {
*/ */
function resultToRemixTx (txResult) { function resultToRemixTx (txResult) {
const { result, transactionHash } = txResult const { result, transactionHash } = txResult
const { status, vm, gasUsed, createdAddress, contractAddress } = result const { status, execResult, gasUsed, createdAddress, contractAddress } = result
let returnValue, errorMessage let returnValue, errorMessage
if (isHexString(result)) { if (isHexString(result)) {
returnValue = result returnValue = result
} else if (vm !== undefined) { } else if (execResult !== undefined) {
returnValue = vm.return returnValue = execResult.return
errorMessage = vm.exceptionError errorMessage = execResult.exceptionError
} }
return { return {

@ -8,11 +8,8 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks,
if (err) { if (err) {
return callback(err) return callback(err)
} }
const returnValue = result.result.execResult.returnValue.toString('hex')
let toReturn = '0x' + result.result.execResult.returnValue.toString('hex') const toReturn = `0x${returnValue || '0'}`
if (toReturn === '0x') {
toReturn = '0x0'
}
return callback(null, toReturn) return callback(null, toReturn)
} }

Loading…
Cancel
Save