diff --git a/src/Eth.php b/src/Eth.php index 44e237b..898156e 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -6,6 +6,8 @@ use Web3\Providers\Provider; use Web3\Providers\HttpProvider; use Web3\RequestManagers\RequestManager; use Web3\RequestManagers\HttpRequestManager; +use Web3\Validators\AddressValidator; +use Web3\Validators\TagValidator; class Eth { @@ -30,6 +32,12 @@ class Eth 'eth_gasPrice' => [], 'eth_accounts' => [], 'eth_blockNumber' => [], + 'eth_getBalance' => [ + 'params'=> [ + AddressValidator::class, + TagValidator::class + ] + ], ]; /** diff --git a/src/Validators/AddressValidator.php b/src/Validators/AddressValidator.php new file mode 100644 index 0000000..22ec3e5 --- /dev/null +++ b/src/Validators/AddressValidator.php @@ -0,0 +1,22 @@ += 1); + } +} \ No newline at end of file diff --git a/src/Validators/TagValidator.php b/src/Validators/TagValidator.php new file mode 100644 index 0000000..62850d5 --- /dev/null +++ b/src/Validators/TagValidator.php @@ -0,0 +1,24 @@ +web3->eth; + + $eth->getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 'latest', function ($err, $balance) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($balance->result)) { + $this->assertTrue(is_string($balance->result)); + } else { + $this->fail($balance->error->message); + } + }); + } + /** * testUnallowedMethod *