ssh_newFilter
This commit is contained in:
parent
85a5a20570
commit
b39c22decd
61
src/Methods/Shh/NewFilter.php
Normal file
61
src/Methods/Shh/NewFilter.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of web3.php package.
|
||||||
|
*
|
||||||
|
* (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
|
||||||
|
*
|
||||||
|
* @author Peter Lai <alk03073135@gmail.com>
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Web3\Methods\Shh;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\ShhFilterValidator;
|
||||||
|
|
||||||
|
class NewFilter extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
ShhFilterValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $outputFormatters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defaultValues
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultValues = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function __construct($method='', $arguments=[])
|
||||||
|
// {
|
||||||
|
// parent::__construct($method, $arguments);
|
||||||
|
// }
|
||||||
|
}
|
@ -38,7 +38,7 @@ class Shh
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $allowedMethods = [
|
private $allowedMethods = [
|
||||||
'shh_version', 'shh_newIdentity', 'shh_hasIdentity', 'shh_post'
|
'shh_version', 'shh_newIdentity', 'shh_hasIdentity', 'shh_post', 'shh_newFilter'
|
||||||
// doesn't exist: 'shh_newGroup', 'shh_addToGroup'
|
// doesn't exist: 'shh_newGroup', 'shh_addToGroup'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -199,6 +199,58 @@ class ShhApiTest extends TestCase
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testNewFilter
|
||||||
|
* Comment because ganache-cli only implement shh_version.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function testNewFilter()
|
||||||
|
// {
|
||||||
|
// $shh = $this->shh;
|
||||||
|
// $toIdentity = '';
|
||||||
|
|
||||||
|
// // create fromIdentity and toIdentity to prevent unknown identity error
|
||||||
|
// $shh->newIdentity(function ($err, $identity) use (&$toIdentity) {
|
||||||
|
// if ($err !== null) {
|
||||||
|
// return $this->fail($err->getMessage());
|
||||||
|
// }
|
||||||
|
// $toIdentity = $identity;
|
||||||
|
|
||||||
|
// $this->assertEquals(mb_strlen($identity), 132);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $shh->newFilter([
|
||||||
|
// 'to' => $toIdentity,
|
||||||
|
// 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
|
||||||
|
// ], function ($err, $filterId) {
|
||||||
|
// if ($err !== null) {
|
||||||
|
// return $this->fail($err->getMessage());
|
||||||
|
// }
|
||||||
|
// $this->assertTrue(is_string($filterId));
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $shh->newFilter([
|
||||||
|
// 'to' => $toIdentity,
|
||||||
|
// 'topics' => [null, "0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
|
||||||
|
// ], function ($err, $filterId) {
|
||||||
|
// if ($err !== null) {
|
||||||
|
// return $this->fail($err->getMessage());
|
||||||
|
// }
|
||||||
|
// $this->assertTrue(is_string($filterId));
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $shh->newFilter([
|
||||||
|
// 'to' => $toIdentity,
|
||||||
|
// 'topics' => ["0x776869737065722d636861742d636c69656e74", ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"]],
|
||||||
|
// ], function ($err, $filterId) {
|
||||||
|
// if ($err !== null) {
|
||||||
|
// return $this->fail($err->getMessage());
|
||||||
|
// }
|
||||||
|
// $this->assertTrue(is_string($filterId));
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testWrongParam
|
* testWrongParam
|
||||||
* We transform data and throw invalid argument exception
|
* We transform data and throw invalid argument exception
|
||||||
|
Loading…
Reference in New Issue
Block a user