diff --git a/src/Eth.php b/src/Eth.php index 57c14a2..a26b000 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -12,6 +12,7 @@ use Web3\Validators\QuantityValidator; use Web3\Validators\BlockHashValidator; use Web3\Validators\HexValidator; use Web3\Validators\TransactionValidator; +use Web3\Validators\BooleanValidator; class Eth { @@ -161,6 +162,15 @@ class Eth 'validators' => TransactionValidator::class ] ] + ], + 'eth_getBlockByHash' => [ + 'params' => [ + [ + 'validators' => BlockHashValidator::class + ], [ + 'validators' => BooleanValidator::class + ] + ] ] ]; diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index 0509e0d..423b866 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -531,6 +531,31 @@ class EthTest extends TestCase }); } + /** + * testGetBlockByHash + * + * @return void + */ + public function testGetBlockByHash() + { + $eth = $this->web3->eth; + + $eth->getBlockByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', false, function ($err, $block) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($block->result)) { + $this->assertTrue(is_string($block->result)); + } else { + if (isset($block->error)) { + $this->fail($block->error->message); + } else { + $this->assertTrue(true); + } + } + }); + } + /** * testUnallowedMethod *