diff --git a/src/Eth.php b/src/Eth.php index 898156e..071b202 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -8,6 +8,7 @@ use Web3\RequestManagers\RequestManager; use Web3\RequestManagers\HttpRequestManager; use Web3\Validators\AddressValidator; use Web3\Validators\TagValidator; +use Web3\Validators\QuantityValidator; class Eth { @@ -38,6 +39,13 @@ class Eth TagValidator::class ] ], + 'eth_getStorageAt' => [ + 'params'=> [ + AddressValidator::class, + QuantityValidator::class, + TagValidator::class + ] + ], ]; /** diff --git a/src/Validators/QuantityValidator.php b/src/Validators/QuantityValidator.php new file mode 100644 index 0000000..27a127e --- /dev/null +++ b/src/Validators/QuantityValidator.php @@ -0,0 +1,20 @@ += 1); + } +} \ No newline at end of file diff --git a/src/Validators/TagValidator.php b/src/Validators/TagValidator.php index 62850d5..17fcf1a 100644 --- a/src/Validators/TagValidator.php +++ b/src/Validators/TagValidator.php @@ -18,7 +18,7 @@ class TagValidator 'latest', 'earliest', 'pending' ]; - // maybe change in_int future - return (is_int($value) || in_array($value, $tags)); + // maybe change in_int and preg_match future + return (is_int($value) || preg_match('/^0x[a-fA-f0-9]+/', $value) >= 1 || in_array($value, $tags)); } } \ No newline at end of file diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index 7d5e44e..c2354f7 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -220,6 +220,27 @@ class EthTest extends TestCase }); } + /** + * testGetStorageAt + * + * @return void + */ + public function testGetStorageAt() + { + $eth = $this->web3->eth; + + $eth->getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x0', 'latest', function ($err, $storage) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($storage->result)) { + $this->assertTrue(is_string($storage->result)); + } else { + $this->fail($storage->error->message); + } + }); + } + /** * testUnallowedMethod *