Web3 use EthMethod

This commit is contained in:
sc0Vu 2018-01-11 17:58:05 +08:00
parent 05a1a638cf
commit ce217225a9
2 changed files with 18 additions and 92 deletions

View File

@ -12,10 +12,9 @@
namespace Web3\Methods\Web3; namespace Web3\Methods\Web3;
use InvalidArgumentException; use InvalidArgumentException;
use Web3\Methods\IMethod; use Web3\Methods\EthMethod;
use Web3\Methods\JSONRPC;
class ClientVersion extends JSONRPC implements IMethod class ClientVersion extends EthMethod
{ {
/** /**
* inputFormatters * inputFormatters
@ -31,6 +30,13 @@ class ClientVersion extends JSONRPC implements IMethod
*/ */
protected $outputFormatters = []; protected $outputFormatters = [];
/**
* defaultValues
*
* @var array
*/
protected $defaultValues = [];
/** /**
* construct * construct
* *
@ -42,47 +48,4 @@ class ClientVersion extends JSONRPC implements IMethod
// { // {
// parent::__construct($method, $arguments); // parent::__construct($method, $arguments);
// } // }
/**
* getInputFormatters
*
* @return array
*/
public function getInputFormatters()
{
return $this->inputFormatters;
}
/**
* getOutputFormatters
*
* @return array
*/
public function getOutputFormatters()
{
return $this->outputFormatters;
}
/**
* transform
*
* @param array $params
* @param array $rules
* @return array
*/
public function transform($params, $rules)
{
if (!is_array($params)) {
throw new InvalidArgumentException('Please use array params when call transform.');
}
if (!is_array($rules)) {
throw new InvalidArgumentException('Please use array rules when call transform.');
}
foreach ($params as $key => $param) {
if (isset($rules[$key])) {
$params[$key] = call_user_func([$rules[$key], 'format'], $param);
}
}
return $params;
}
} }

View File

@ -12,11 +12,10 @@
namespace Web3\Methods\Web3; namespace Web3\Methods\Web3;
use InvalidArgumentException; use InvalidArgumentException;
use Web3\Methods\IMethod; use Web3\Methods\EthMethod;
use Web3\Methods\JSONRPC;
use Web3\Formatters\HexFormatter; use Web3\Formatters\HexFormatter;
class Sha3 extends JSONRPC implements IMethod class Sha3 extends EthMethod
{ {
/** /**
* inputFormatters * inputFormatters
@ -34,6 +33,13 @@ class Sha3 extends JSONRPC implements IMethod
*/ */
protected $outputFormatters = []; protected $outputFormatters = [];
/**
* defaultValues
*
* @var array
*/
protected $defaultValues = [];
/** /**
* construct * construct
* *
@ -45,47 +51,4 @@ class Sha3 extends JSONRPC implements IMethod
// { // {
// parent::__construct($method, $arguments); // parent::__construct($method, $arguments);
// } // }
/**
* getInputFormatters
*
* @return array
*/
public function getInputFormatters()
{
return $this->inputFormatters;
}
/**
* getOutputFormatters
*
* @return array
*/
public function getOutputFormatters()
{
return $this->outputFormatters;
}
/**
* transform
*
* @param array $params
* @param array $rules
* @return array
*/
public function transform($params, $rules)
{
if (!is_array($params)) {
throw new InvalidArgumentException('Please use array params when call transform.');
}
if (!is_array($rules)) {
throw new InvalidArgumentException('Please use array rules when call transform.');
}
foreach ($params as $key => $param) {
if (isset($rules[$key])) {
$params[$key] = call_user_func([$rules[$key], 'format'], $param);
}
}
return $params;
}
} }