add eth_blockNumber

pull/7/head
Iuri Matias 6 years ago
parent e136ed3086
commit 2d4c54012b
  1. 2
      remix-simulator/README.md
  2. 16
      remix-simulator/src/methods/blocks.js

@ -14,7 +14,7 @@ Implemented:
* [X] eth_hashrate
* [~] eth_gasPrice
* [~] eth_accounts
* [_] eth_blockNumber
* [X] eth_blockNumber
* [_] eth_getBalance
* [_] eth_getStorageAt
* [_] eth_getTransactionCount

@ -1,12 +1,16 @@
var Web3 = require("web3")
var Blocks = function (options) {
this.coinbase = options.coinbase || "0x0000000000000000000000000000000000000000"
this.blockNumber = 0
}
Blocks.prototype.methods = function () {
return {
eth_getBlockByNumber: this.eth_getBlockByNumber.bind(this),
eth_gasPrice: this.eth_gasPrice.bind(this)
eth_gasPrice: this.eth_gasPrice.bind(this),
eth_coinbase: this.coinbase.bind(this),
eth_blockNumber: this.blockNumber.bind(this)
}
}
@ -21,7 +25,7 @@ Blocks.prototype.eth_getBlockByNumber = function (payload, cb) {
'miner': this.coinbase,
'mixHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'nonce': '0x0000000000000042',
'number': '0x0',
'number': Web3.utils.tohex(this.blockNumber),
'parentHash': '0x0000000000000000000000000000000000000000000000000000000000000000',
'receiptsRoot': '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
'sha3Uncles': '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
@ -40,4 +44,12 @@ Blocks.prototype.eth_gasPrice = function (payload, cb) {
cb(null, 1)
}
Blocks.prototype.eth_coinbase = function (payload, cb) {
cb(null, this.coinbase)
}
Blocks.prototype.eth_blockNumber = function (payload, cb) {
cb(null, this.blockNumber)
}
module.exports = Blocks

Loading…
Cancel
Save