diff --git a/libs/remix-lib/src/execution/execution-context.ts b/libs/remix-lib/src/execution/execution-context.ts index ba067e7035..7644081040 100644 --- a/libs/remix-lib/src/execution/execution-context.ts +++ b/libs/remix-lib/src/execution/execution-context.ts @@ -343,5 +343,5 @@ export class ExecutionContext { if (transactionDetailsLinks[network]) { return transactionDetailsLinks[network] + hash } - } + } } diff --git a/libs/remix-lib/src/execution/txRunnerVM.ts b/libs/remix-lib/src/execution/txRunnerVM.ts index 3b221f8b75..bc7e1403a7 100644 --- a/libs/remix-lib/src/execution/txRunnerVM.ts +++ b/libs/remix-lib/src/execution/txRunnerVM.ts @@ -27,7 +27,7 @@ export class TxRunnerVM { this.blockNumber = 0 this.runAsync = true this.blockNumber = 0 // The VM is running in Homestead mode, which started at this block. - this.runAsync = false // We have to run like this cause the VM Event Manager does not support running multiple txs at the same time. + this.runAsync = false // We have to run like this cause the VM Event Manager does not support running multiple txs at the same time. this.pendingTxs = {} this.vmaccounts = vmaccounts this.queusTxs = [] @@ -110,11 +110,10 @@ export class TxRunnerVM { result: result, transactionHash: bufferToHex(Buffer.from(tx.hash())), block, - tx, + tx }) }).catch(function (err) { callback(err) }) - } + } } - diff --git a/libs/remix-lib/src/execution/txRunnerWeb3.ts b/libs/remix-lib/src/execution/txRunnerWeb3.ts index f735b3401c..4554c396e8 100644 --- a/libs/remix-lib/src/execution/txRunnerWeb3.ts +++ b/libs/remix-lib/src/execution/txRunnerWeb3.ts @@ -65,8 +65,8 @@ export class TxRunnerWeb3 { data = '0x' + data } - return this.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, args.timestamp, confirmationCb, gasEstimationForceSend, promptCb, callback) - } + return this.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, args.timestamp, confirmationCb, gasEstimationForceSend, promptCb, callback) + } runInNode (from, to, data, value, gasLimit, useCall, timestamp, confirmCb, gasEstimationForceSend, promptCb, callback) { const tx = { from: from, to: to, data: data, value: value } @@ -76,16 +76,16 @@ export class TxRunnerWeb3 { tx['gas'] = gasLimit tx['timestamp'] = timestamp return this.getWeb3().eth.call(tx, function (error, result: any) { - if (error) return callback(error) + if (error) return callback(error) callback(null, { - result: result + result: result }) }) } this.getWeb3().eth.estimateGas(tx, (err, gasEstimation) => { if (err && err.message.indexOf('Invalid JSON RPC response') !== -1) { // // @todo(#378) this should be removed when https://github.com/WalletConnect/walletconnect-monorepo/issues/334 is fixed - new Error('Gas estimation failed because of an unknown internal error. This may indicated that the transaction will fail.') + callback(new Error('Gas estimation failed because of an unknown internal error. This may indicated that the transaction will fail.')) } gasEstimationForceSend(err, () => { // callback is called whenever no error diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.ts b/libs/remix-lib/src/web3Provider/web3VmProvider.ts index 361c2b7161..59b0e7e909 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.ts +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.ts @@ -74,7 +74,7 @@ export class Web3VmProvider { this.utils = Web3.utils || [] this.txsMapBlock = {} this.blocks = {} - this.latestBlockNumber + this.latestBlockNumber = 0 } setVM (vm) { diff --git a/libs/remix-simulator/src/methods/transactions.ts b/libs/remix-simulator/src/methods/transactions.ts index 04ef986403..969eb0ff6f 100644 --- a/libs/remix-simulator/src/methods/transactions.ts +++ b/libs/remix-simulator/src/methods/transactions.ts @@ -7,7 +7,6 @@ export class Transactions { accounts tags - constructor (vmContext) { this.vmContext = vmContext this.tags = {} @@ -44,7 +43,7 @@ export class Transactions { const hash = '0x' + result.tx.hash().toString('hex') this.vmContext.trackTx(hash, result.block) this.vmContext.trackExecResult(hash, result.result.execResult) - return cb (null, result.transactionHash) + return cb(null, result.transactionHash) } cb(error) }) @@ -110,7 +109,7 @@ export class Transactions { } payload.params[0].value = undefined - + const tag = payload.params[0].timestamp // e2e reference processTx(this.vmContext, this.accounts, payload, true, (error, result) => { @@ -122,7 +121,7 @@ export class Transactions { this.tags[tag] = result.transactionHash // calls are not supposed to return a transaction hash. we do this for keeping track of it and allowing debugging calls. const returnValue = `0x${result.result.execResult.returnValue.toString('hex') || '0'}` - return cb (null, returnValue) + return cb(null, returnValue) } cb(error) }) diff --git a/libs/remix-simulator/src/methods/txProcess.ts b/libs/remix-simulator/src/methods/txProcess.ts index 821206eae8..d51bbf9c73 100644 --- a/libs/remix-simulator/src/methods/txProcess.ts +++ b/libs/remix-simulator/src/methods/txProcess.ts @@ -3,12 +3,11 @@ const TxExecution = execution.txExecution const TxRunnerVM = execution.TxRunnerVM const TxRunner = execution.TxRunner - function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { const finalCallback = function (err, result) { if (err) { return callback(err) - } + } return callback(null, result) } diff --git a/libs/remix-simulator/src/provider.ts b/libs/remix-simulator/src/provider.ts index 5046660d7f..276b66ca15 100644 --- a/libs/remix-simulator/src/provider.ts +++ b/libs/remix-simulator/src/provider.ts @@ -26,7 +26,7 @@ export class Provider { this.host = host this.connected = true this.vmContext = new VMContext() - + this.Accounts = new Accounts(this.vmContext) this.Transactions = new Transactions(this.vmContext) @@ -102,7 +102,7 @@ export function extend (web3) { call: 'eth_getExecutionResultFromSimulator', inputFormatter: [null], params: 1 - })) + })) } if (!(web3.eth && web3.eth.getHashFromTagBySimulator)) { @@ -111,9 +111,9 @@ export function extend (web3) { call: 'eth_getHashFromTagBySimulator', inputFormatter: [null], params: 1 - })) + })) } - + if (methods.length > 0) { web3.extend({ property: 'eth', @@ -122,4 +122,3 @@ export function extend (web3) { }) } } - diff --git a/libs/remix-simulator/src/vm-context.ts b/libs/remix-simulator/src/vm-context.ts index 481f5f4057..e59eb68cdd 100644 --- a/libs/remix-simulator/src/vm-context.ts +++ b/libs/remix-simulator/src/vm-context.ts @@ -75,8 +75,8 @@ export class VMContext { web3vm logsManager exeResults - - constructor () { + + constructor () { this.blockGasLimitDefault = 4300000 this.blockGasLimit = this.blockGasLimitDefault this.currentFork = 'muirGlacier' @@ -94,7 +94,6 @@ export class VMContext { this.txs = {} this.exeResults = {} this.logsManager = new execution.LogsManager() - } createVm (hardfork) { @@ -124,20 +123,20 @@ export class VMContext { return this.vms[this.currentFork].vm } - addBlock (block) { - let blockNumber = '0x' + block.header.number.toString('hex') - if (blockNumber === '0x') { - blockNumber = '0x0' - } - - this.blocks['0x' + block.hash().toString('hex')] = block - this.blocks[blockNumber] = block - this.latestBlockNumber = blockNumber + addBlock (block) { + let blockNumber = '0x' + block.header.number.toString('hex') + if (blockNumber === '0x') { + blockNumber = '0x0' + } + + this.blocks['0x' + block.hash().toString('hex')] = block + this.blocks[blockNumber] = block + this.latestBlockNumber = blockNumber - this.logsManager.checkBlock(blockNumber, block, this.web3vm) - } + this.logsManager.checkBlock(blockNumber, block, this.web3vm) + } - trackTx (tx, block) { + trackTx (tx, block) { this.txs[tx] = block }