eth_getBlockTransactionCountByNumber
This commit is contained in:
parent
d14b6c7ee1
commit
6a95cdef15
10
src/Eth.php
10
src/Eth.php
@ -79,6 +79,16 @@ class Eth
|
||||
]
|
||||
]
|
||||
],
|
||||
'eth_getBlockTransactionCountByNumber' => [
|
||||
'params' => [
|
||||
[
|
||||
'default' => 'latest',
|
||||
'validators' => [
|
||||
TagValidator::class, QuantityValidator::class,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user