make linter happy; remove getBlock call for now

pull/7/head
Iuri Matias 6 years ago
parent d20d81dd2b
commit 6b765f9556
  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) {
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'
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) => {
if (err) {
return cb('Account not found')
return cb(err)
}
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 privateKey = this.accountsKeys[address]
let account = web3.eth.accounts.privateKeyToAccount(privateKey)
let account = Web3.eth.accounts.privateKeyToAccount(privateKey)
let data = account.sign(message)

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

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

Loading…
Cancel
Save