diff --git a/remix-simulator/README.md b/remix-simulator/README.md index e312f5b3f3..3e81dc02d2 100644 --- a/remix-simulator/README.md +++ b/remix-simulator/README.md @@ -14,7 +14,7 @@ Implemented: * [X] eth_hashrate * [~] eth_gasPrice * [~] eth_accounts -* [_] eth_blockNumber +* [X] eth_blockNumber * [_] eth_getBalance * [_] eth_getStorageAt * [_] eth_getTransactionCount diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js index 796b92e9de..3abb818801 100644 --- a/remix-simulator/src/methods/blocks.js +++ b/remix-simulator/src/methods/blocks.js @@ -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