From 1d29fd01388c3f0f9e0fa83f2634dea965d8f87c Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Thu, 14 Dec 2017 21:56:08 +0800 Subject: [PATCH] eth_newFilter --- src/Eth.php | 8 ++++++++ test/unit/EthTest.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Eth.php b/src/Eth.php index 05abcef..cf5938b 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -14,6 +14,7 @@ use Web3\Validators\HexValidator; use Web3\Validators\TransactionValidator; use Web3\Validators\BooleanValidator; use Web3\Validators\StringValidator; +use Web3\Validators\FilterValidator; class Eth { @@ -259,6 +260,13 @@ class Eth 'validators' => StringValidator::class ] ] + ], + 'eth_newFilter' => [ + 'params' => [ + [ + 'validators' => FilterValidator::class + ] + ] ] ]; diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index f6396a3..b3a9787 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -834,6 +834,37 @@ class EthTest extends TestCase }); } + /** + * testNewFilter + * + * @return void + */ + public function testNewFilter() + { + $eth = $this->eth; + + $eth->newFilter([ + 'fromBlock' => '0x1', + 'toBlock' => '0x2', + 'address' => '0x8888f1f195afa192cfee860698584c030f4c9db1', + 'topics' => ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', null, ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc']] + ], function ($err, $filter) { + if ($err !== null) { + // infura banned us to new filter + return $this->assertTrue($err->getCode() === 405); + } + if (isset($filter->result)) { + $this->assertTrue(is_string($filter->result)); + } else { + if (isset($filter->error)) { + $this->assertTrue(is_string($filter->error->message)); + } else { + $this->assertTrue(true); + } + } + }); + } + /** * testUnallowedMethod *