diff --git a/src/Eth.php b/src/Eth.php index 93e2a5b..be4cadf 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -79,6 +79,16 @@ class Eth ] ] ], + 'eth_getBlockTransactionCountByNumber' => [ + 'params' => [ + [ + 'default' => 'latest', + 'validators' => [ + TagValidator::class, QuantityValidator::class, + ] + ] + ] + ], ]; /** diff --git a/src/Validators/QuantityValidator.php b/src/Validators/QuantityValidator.php index 27a127e..672b738 100644 --- a/src/Validators/QuantityValidator.php +++ b/src/Validators/QuantityValidator.php @@ -15,6 +15,6 @@ class QuantityValidator public static function validate($value) { // maybe change in_int and preg_match future - return (is_int($value) || preg_match('/^0x[a-fA-f0-9]+/', $value) >= 1); + return (is_int($value) || preg_match('/^0x[a-fA-f0-9]+$/', $value) >= 1); } } \ No newline at end of file diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index 9700cb5..332fcea 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -287,6 +287,32 @@ class EthTest extends TestCase }); } + /** + * testGetBlockTransactionCountByNumber + * + * @return void + */ + public function testGetBlockTransactionCountByNumber() + { + $eth = $this->web3->eth; + + $eth->getBlockTransactionCountByNumber('0x0', function ($err, $transactionCount) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($transactionCount->result)) { + var_dump($transactionCount->result); + $this->assertTrue(is_string($transactionCount->result)); + } else { + if (isset($transactionCount->error)) { + $this->fail($transactionCount->error->message); + } else { + $this->assertTrue(true); + } + } + }); + } + /** * testUnallowedMethod *