make linter happy; remove getBlock call for now

pull/5370/head
Iuri Matias 6 years ago
parent 3906c0c347
commit c21d5e38d9
  1. 11
      remix-simulator/src/methods/accounts.js
  2. 4
      remix-simulator/src/methods/blocks.js
  3. 34
      remix-simulator/src/methods/transactions.js

@ -15,9 +15,12 @@ var Accounts = function () {
for (let _account of this.accountsList) { for (let _account of this.accountsList) {
this.accountsKeys[_account.address.toLowerCase()] = _account.privateKey this.accountsKeys[_account.address.toLowerCase()] = _account.privateKey
this.accounts[_account.address.toLowerCase()] = { privateKey: Buffer.from(_account.privateKey.replace("0x", ""), 'hex'), nonce: 0 } this.accounts[_account.address.toLowerCase()] = { privateKey: Buffer.from(_account.privateKey.replace('0x', ''), 'hex'), nonce: 0 }
executionContext.vm().stateManager.getAccount(Buffer.from(_account.address.toLowerCase().replace("0x", ""), 'hex'), (err, account) => { executionContext.vm().stateManager.getAccount(Buffer.from(_account.address.toLowerCase().replace('0x', ''), 'hex'), (err, account) => {
if (err) {
throw new Error(err)
}
var balance = '0x56BC75E2D63100000' var balance = '0x56BC75E2D63100000'
account.balance = balance || '0xf00000000000000001' account.balance = balance || '0xf00000000000000001'
}) })
@ -42,7 +45,7 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, account) => { executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, account) => {
if (err) { if (err) {
return cb('Account not found') return cb(err)
} }
cb(null, new BN(account.balance).toString(10)) cb(null, new BN(account.balance).toString(10))
}) })
@ -53,7 +56,7 @@ Accounts.prototype.eth_sign = function (payload, cb) {
let message = payload.params[1] let message = payload.params[1]
let privateKey = this.accountsKeys[address] let privateKey = this.accountsKeys[address]
let account = web3.eth.accounts.privateKeyToAccount(privateKey) let account = Web3.eth.accounts.privateKeyToAccount(privateKey)
let data = account.sign(message) let data = account.sign(message)

@ -1,8 +1,8 @@
var Web3 = require("web3") var Web3 = require('web3')
var Blocks = function (_options) { var Blocks = function (_options) {
const options = _options || {} const options = _options || {}
this.coinbase = options.coinbase || "0x0000000000000000000000000000000000000000" this.coinbase = options.coinbase || '0x0000000000000000000000000000000000000000'
this.blockNumber = 0 this.blockNumber = 0
} }

@ -2,8 +2,9 @@ var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var processTx = require('./txProcess.js') var processTx = require('./txProcess.js')
var BN = ethJSUtil.BN
function hexConvert(ints) { function hexConvert (ints) {
var ret = '0x' var ret = '0x'
for (var i = 0; i < ints.length; i++) { for (var i = 0; i < ints.length; i++) {
var h = ints[i] var h = ints[i]
@ -37,12 +38,10 @@ Transactions.prototype.eth_sendTransaction = function (payload, cb) {
} }
Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
const self = this
executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
} }
//self.deployedContracts[receipt.contractAddress] = receipt.data
var r = { var r = {
'transactionHash': receipt.hash, 'transactionHash': receipt.hash,
@ -82,6 +81,9 @@ Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
let address = payload.params[0] let address = payload.params[0]
executionContext.vm().stateManager.getAccount(address, (err, account) => { executionContext.vm().stateManager.getAccount(address, (err, account) => {
if (err) {
return cb(err)
}
let nonce = new BN(account.nonce).toString(10) let nonce = new BN(account.nonce).toString(10)
cb(null, nonce) cb(null, nonce)
}) })
@ -95,23 +97,23 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
return cb(error) return cb(error)
} }
web3.eth.getBlock(receipt.hash).then((block) => { //executionContext.web3().eth.getBlock(receipt.hash).then((block) => {
const r = { const r = {
"hash": receipt.transactionHash, 'hash': receipt.transactionHash,
//"nonce": 2, // "nonce": 2,
"blockHash": receipt.hash, 'blockHash': receipt.hash,
"blockNumber": block.number, //'blockNumber': block.number,
//"transactionIndex": 0, // "transactionIndex": 0,
"from": receipt.from, 'from': receipt.from,
"to": receipt.to, 'to': receipt.to,
"value": receipt.value, 'value': receipt.value,
"gas": receipt.gas, 'gas': receipt.gas,
"gasPrice": '2000000000000', 'gasPrice': '2000000000000',
"input": receipt.input 'input': receipt.input
} }
cb(null, r) cb(null, r)
}) //})
}) })
} }

Loading…
Cancel
Save