|
|
|
@ -1,22 +1,10 @@ |
|
|
|
|
var Web3 = require('web3') |
|
|
|
|
var RemixLib = require('remix-lib') |
|
|
|
|
var executionContext = RemixLib.execution.executionContext |
|
|
|
|
var ethJSUtil = require('ethereumjs-util') |
|
|
|
|
var processTx = require('./txProcess.js') |
|
|
|
|
var BN = ethJSUtil.BN |
|
|
|
|
|
|
|
|
|
function hexConvert (ints) { |
|
|
|
|
var ret = '0x' |
|
|
|
|
for (var i = 0; i < ints.length; i++) { |
|
|
|
|
var h = ints[i] |
|
|
|
|
if (h) { |
|
|
|
|
ret += (h <= 0xf ? '0' : '') + h.toString(16) |
|
|
|
|
} else { |
|
|
|
|
ret += '00' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ret |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var Transactions = function (accounts) { |
|
|
|
|
this.accounts = accounts |
|
|
|
|
} |
|
|
|
@ -45,15 +33,15 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { |
|
|
|
|
return cb(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var txBlock = executionContext.txs[receipt.hash]; |
|
|
|
|
var txBlock = executionContext.txs[receipt.hash] |
|
|
|
|
|
|
|
|
|
var r = { |
|
|
|
|
'transactionHash': receipt.hash, |
|
|
|
|
'transactionIndex': '0x00', |
|
|
|
|
'blockHash': "0x" + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': "0x" + txBlock.header.number.toString('hex'), |
|
|
|
|
'gasUsed': web3.utils.toHex(receipt.gas), |
|
|
|
|
'cumulativeGasUsed': web3.utils.toHex(receipt.gas), |
|
|
|
|
'blockHash': '0x' + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': '0x' + txBlock.header.number.toString('hex'), |
|
|
|
|
'gasUsed': Web3.utils.toHex(receipt.gas), |
|
|
|
|
'cumulativeGasUsed': Web3.utils.toHex(receipt.gas), |
|
|
|
|
'contractAddress': receipt.contractAddress, |
|
|
|
|
'logs': receipt.logs, |
|
|
|
|
'status': receipt.status |
|
|
|
@ -72,8 +60,8 @@ Transactions.prototype.eth_getCode = function (payload, cb) { |
|
|
|
|
|
|
|
|
|
executionContext.web3().eth.getCode(address, (error, result) => { |
|
|
|
|
if (error) { |
|
|
|
|
console.dir("error getting code"); |
|
|
|
|
console.dir(error); |
|
|
|
|
console.dir('error getting code') |
|
|
|
|
console.dir(error) |
|
|
|
|
} |
|
|
|
|
cb(error, result) |
|
|
|
|
}) |
|
|
|
@ -103,23 +91,21 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) { |
|
|
|
|
return cb(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var test = executionContext.web3(); |
|
|
|
|
|
|
|
|
|
var txBlock = executionContext.txs[receipt.transactionHash]; |
|
|
|
|
var txBlock = executionContext.txs[receipt.transactionHash] |
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
|
let r = { |
|
|
|
|
'blockHash': "0x" + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': "0x" + txBlock.header.number.toString('hex'), |
|
|
|
|
'blockHash': '0x' + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': '0x' + txBlock.header.number.toString('hex'), |
|
|
|
|
'from': receipt.from, |
|
|
|
|
'gas': web3.utils.toHex(receipt.gas), |
|
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
|
"gasPrice":"0x4a817c800", // 20000000000
|
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
|
'input': receipt.input, |
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
|
"value": receipt.value |
|
|
|
|
'value': receipt.value |
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
@ -130,8 +116,8 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) { |
|
|
|
|
r.to = receipt.to |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (r.value === "0x") { |
|
|
|
|
r.value = "0x0" |
|
|
|
|
if (r.value === '0x') { |
|
|
|
|
r.value = '0x0' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cb(null, r) |
|
|
|
@ -142,7 +128,7 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload |
|
|
|
|
const txIndex = payload.params[1] |
|
|
|
|
|
|
|
|
|
var txBlock = executionContext.blocks[payload.params[0]] |
|
|
|
|
const txHash = "0x" + txBlock.transactions[web3.utils.toDecimal(txIndex)].hash().toString('hex') |
|
|
|
|
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') |
|
|
|
|
|
|
|
|
|
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { |
|
|
|
|
if (error) { |
|
|
|
@ -151,17 +137,17 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload |
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
|
let r = { |
|
|
|
|
'blockHash': "0x" + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': "0x" + txBlock.header.number.toString('hex'), |
|
|
|
|
'blockHash': '0x' + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': '0x' + txBlock.header.number.toString('hex'), |
|
|
|
|
'from': receipt.from, |
|
|
|
|
'gas': web3.utils.toHex(receipt.gas), |
|
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
|
"gasPrice": "0x4a817c800", // 20000000000
|
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
|
'input': receipt.input, |
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
|
"value": receipt.value |
|
|
|
|
'value': receipt.value |
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
@ -172,8 +158,8 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload |
|
|
|
|
r.to = receipt.to |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (r.value === "0x") { |
|
|
|
|
r.value = "0x0" |
|
|
|
|
if (r.value === '0x') { |
|
|
|
|
r.value = '0x0' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cb(null, r) |
|
|
|
@ -184,7 +170,7 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo |
|
|
|
|
const txIndex = payload.params[1] |
|
|
|
|
|
|
|
|
|
var txBlock = executionContext.blocks[payload.params[0]] |
|
|
|
|
const txHash = "0x" + txBlock.transactions[web3.utils.toDecimal(txIndex)].hash().toString('hex') |
|
|
|
|
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') |
|
|
|
|
|
|
|
|
|
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { |
|
|
|
|
if (error) { |
|
|
|
@ -193,17 +179,17 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo |
|
|
|
|
|
|
|
|
|
// TODO: params to add later
|
|
|
|
|
let r = { |
|
|
|
|
'blockHash': "0x" + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': "0x" + txBlock.header.number.toString('hex'), |
|
|
|
|
'blockHash': '0x' + txBlock.hash().toString('hex'), |
|
|
|
|
'blockNumber': '0x' + txBlock.header.number.toString('hex'), |
|
|
|
|
'from': receipt.from, |
|
|
|
|
'gas': web3.utils.toHex(receipt.gas), |
|
|
|
|
'gas': Web3.utils.toHex(receipt.gas), |
|
|
|
|
// 'gasPrice': '2000000000000', // 0x123
|
|
|
|
|
"gasPrice": "0x4a817c800", // 20000000000
|
|
|
|
|
'gasPrice': '0x4a817c800', // 20000000000
|
|
|
|
|
'hash': receipt.transactionHash, |
|
|
|
|
'input': receipt.input, |
|
|
|
|
// "nonce": 2, // 0x15
|
|
|
|
|
// "transactionIndex": 0,
|
|
|
|
|
"value": receipt.value |
|
|
|
|
'value': receipt.value |
|
|
|
|
// "value":"0xf3dbb76162000" // 4290000000000000
|
|
|
|
|
// "v": "0x25", // 37
|
|
|
|
|
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
|
|
|
|
@ -214,8 +200,8 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo |
|
|
|
|
r.to = receipt.to |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (r.value === "0x") { |
|
|
|
|
r.value = "0x0" |
|
|
|
|
if (r.value === '0x') { |
|
|
|
|
r.value = '0x0' |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cb(null, r) |
|
|
|
|