shh_getFilterChanges
This commit is contained in:
parent
0395562470
commit
27277d2424
64
src/Methods/Shh/GetFilterChanges.php
Normal file
64
src/Methods/Shh/GetFilterChanges.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?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\QuantityValidator;
|
||||
use Web3\Formatters\QuantityFormatter;
|
||||
|
||||
class GetFilterChanges extends EthMethod
|
||||
{
|
||||
/**
|
||||
* validators
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validators = [
|
||||
QuantityValidator::class
|
||||
];
|
||||
|
||||
/**
|
||||
* inputFormatters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $inputFormatters = [
|
||||
QuantityFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private $allowedMethods = [
|
||||
'shh_version', 'shh_newIdentity', 'shh_hasIdentity', 'shh_post', 'shh_newFilter', 'shh_uninstallFilter'
|
||||
'shh_version', 'shh_newIdentity', 'shh_hasIdentity', 'shh_post', 'shh_newFilter', 'shh_uninstallFilter', 'shh_getFilterChanges'
|
||||
// doesn't exist: 'shh_newGroup', 'shh_addToGroup'
|
||||
];
|
||||
|
||||
|
@ -293,6 +293,80 @@ class ShhApiTest extends TestCase
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* testGetFilterChanges
|
||||
* Comment because ganache-cli only implement shh_version.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// public function testGetFilterChanges()
|
||||
// {
|
||||
// $shh = $this->shh;
|
||||
// $fromIdentity = '';
|
||||
// $toIdentity = '';
|
||||
// $filter = '';
|
||||
|
||||
// // 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->newIdentity(function ($err, $identity) use (&$fromIdentity) {
|
||||
// if ($err !== null) {
|
||||
// return $this->fail($err->getMessage());
|
||||
// }
|
||||
// $fromIdentity = $identity;
|
||||
|
||||
// $this->assertEquals(mb_strlen($identity), 132);
|
||||
// });
|
||||
|
||||
// $shh->newFilter([
|
||||
// 'to' => $toIdentity,
|
||||
// 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
|
||||
// ], function ($err, $filterId) use (&$filter) {
|
||||
// if ($err !== null) {
|
||||
// return $this->fail($err->getMessage());
|
||||
// }
|
||||
// $filter = $filterId;
|
||||
|
||||
// $this->assertTrue(is_string($filterId));
|
||||
// });
|
||||
|
||||
// $shh->getFilterChanges($filter, function ($err, $changes) {
|
||||
// if ($err !== null) {
|
||||
// return $this->fail($err->getMessage());
|
||||
// }
|
||||
// $this->assertTrue(is_array($changes));
|
||||
// });
|
||||
|
||||
// // try to post, but didn't get changes
|
||||
// $shh->post([
|
||||
// 'from' => $fromIdentity,
|
||||
// 'to' => $toIdentity,
|
||||
// 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
|
||||
// 'payload' => "0x7b2274797065223a226d6",
|
||||
// 'priority' => "0x64",
|
||||
// 'ttl' => "0x64",
|
||||
// ], function ($err, $isSent) {
|
||||
// if ($err !== null) {
|
||||
// return $this->fail($err->getMessage());
|
||||
// }
|
||||
// $this->assertTrue($isSent);
|
||||
// });
|
||||
|
||||
// $shh->getFilterChanges($filter, function ($err, $changes) {
|
||||
// if ($err !== null) {
|
||||
// return $this->fail($err->getMessage());
|
||||
// }
|
||||
// $this->assertTrue(is_array($changes));
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* testWrongParam
|
||||
* We transform data and throw invalid argument exception
|
||||
|
Loading…
Reference in New Issue
Block a user