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 = {
// 0x0 range - arithmetic ops
// 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],
0x01: ['ADD', 3, 2, 1, false],

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

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

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

Loading…
Cancel
Save