diff --git a/src/Methods/Eth/Accounts.php b/src/Methods/Eth/Accounts.php new file mode 100644 index 0000000..62b349b --- /dev/null +++ b/src/Methods/Eth/Accounts.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class Accounts extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/BlockNumber.php b/src/Methods/Eth/BlockNumber.php new file mode 100644 index 0000000..da0db24 --- /dev/null +++ b/src/Methods/Eth/BlockNumber.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class BlockNumber extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Call.php b/src/Methods/Eth/Call.php new file mode 100644 index 0000000..3ec10b1 --- /dev/null +++ b/src/Methods/Eth/Call.php @@ -0,0 +1,57 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\TransactionFormatter; +use Web3\Formatters\OptionalQuantityFormatter; + +class Call extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + TransactionFormatter::class, OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 1 => 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Coinbase.php b/src/Methods/Eth/Coinbase.php new file mode 100644 index 0000000..4ae5512 --- /dev/null +++ b/src/Methods/Eth/Coinbase.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class Coinbase extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/EstimateGas.php b/src/Methods/Eth/EstimateGas.php new file mode 100644 index 0000000..a11f80e --- /dev/null +++ b/src/Methods/Eth/EstimateGas.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\TransactionFormatter; + +class EstimateGas extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + TransactionFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GasPrice.php b/src/Methods/Eth/GasPrice.php new file mode 100644 index 0000000..430877e --- /dev/null +++ b/src/Methods/Eth/GasPrice.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class GasPrice extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetBalance.php b/src/Methods/Eth/GetBalance.php new file mode 100644 index 0000000..ba4053a --- /dev/null +++ b/src/Methods/Eth/GetBalance.php @@ -0,0 +1,57 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\AddressFormatter; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetBalance extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + AddressFormatter::class, OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 1 => 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetBlockByHash.php b/src/Methods/Eth/GetBlockByHash.php new file mode 100644 index 0000000..1eb9708 --- /dev/null +++ b/src/Methods/Eth/GetBlockByHash.php @@ -0,0 +1,55 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; +use Web3\Formatters\BooleanFormatter; + +class GetBlockByHash extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::class, BooleanFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetBlockByNumber.php b/src/Methods/Eth/GetBlockByNumber.php new file mode 100644 index 0000000..51cdc2d --- /dev/null +++ b/src/Methods/Eth/GetBlockByNumber.php @@ -0,0 +1,55 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\OptionalQuantityFormatter; +use Web3\Formatters\BooleanFormatter; + +class GetBlockByNumber extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + OptionalQuantityFormatter::class, BooleanFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetBlockTransactionCountByHash.php b/src/Methods/Eth/GetBlockTransactionCountByHash.php new file mode 100644 index 0000000..b504bbb --- /dev/null +++ b/src/Methods/Eth/GetBlockTransactionCountByHash.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; + +class GetBlockTransactionCountByHash extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetBlockTransactionCountByNumber.php b/src/Methods/Eth/GetBlockTransactionCountByNumber.php new file mode 100644 index 0000000..b09312e --- /dev/null +++ b/src/Methods/Eth/GetBlockTransactionCountByNumber.php @@ -0,0 +1,56 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetBlockTransactionCountByNumber extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetCode.php b/src/Methods/Eth/GetCode.php new file mode 100644 index 0000000..425163c --- /dev/null +++ b/src/Methods/Eth/GetCode.php @@ -0,0 +1,57 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\AddressFormatter; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetCode extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + AddressFormatter::class, OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 1 => 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetStorageAt.php b/src/Methods/Eth/GetStorageAt.php new file mode 100644 index 0000000..752f7bb --- /dev/null +++ b/src/Methods/Eth/GetStorageAt.php @@ -0,0 +1,58 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\AddressFormatter; +use Web3\Formatters\QuantityFormatter; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetStorageAt extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + AddressFormatter::class, QuantityFormatter::class, OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 2 => 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetTransactionByBlockHashAndIndex.php b/src/Methods/Eth/GetTransactionByBlockHashAndIndex.php new file mode 100644 index 0000000..5d67117 --- /dev/null +++ b/src/Methods/Eth/GetTransactionByBlockHashAndIndex.php @@ -0,0 +1,55 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; +use Web3\Formatters\QuantityFormatter; + +class GetTransactionByBlockHashAndIndex extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::class, 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php b/src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php new file mode 100644 index 0000000..f348948 --- /dev/null +++ b/src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php @@ -0,0 +1,55 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\OptionalQuantityFormatter; +use Web3\Formatters\QuantityFormatter; + +class GetTransactionByBlockNumberAndIndex extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + OptionalQuantityFormatter::class, 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetTransactionByHash.php b/src/Methods/Eth/GetTransactionByHash.php new file mode 100644 index 0000000..7413d31 --- /dev/null +++ b/src/Methods/Eth/GetTransactionByHash.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; + +class GetTransactionByHash extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetTransactionCount.php b/src/Methods/Eth/GetTransactionCount.php new file mode 100644 index 0000000..233d9e0 --- /dev/null +++ b/src/Methods/Eth/GetTransactionCount.php @@ -0,0 +1,57 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\AddressFormatter; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetTransactionCount extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + AddressFormatter::class, OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 1 => 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetUncleCountByBlockHash.php b/src/Methods/Eth/GetUncleCountByBlockHash.php new file mode 100644 index 0000000..6cbde85 --- /dev/null +++ b/src/Methods/Eth/GetUncleCountByBlockHash.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; + +class GetUncleCountByBlockHash extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/GetUncleCountByBlockNumber.php b/src/Methods/Eth/GetUncleCountByBlockNumber.php new file mode 100644 index 0000000..177610f --- /dev/null +++ b/src/Methods/Eth/GetUncleCountByBlockNumber.php @@ -0,0 +1,56 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\OptionalQuantityFormatter; + +class GetUncleCountByBlockNumber extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + OptionalQuantityFormatter::class + ]; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = [ + 'latest' + ]; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Hashrate.php b/src/Methods/Eth/Hashrate.php new file mode 100644 index 0000000..3d49685 --- /dev/null +++ b/src/Methods/Eth/Hashrate.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class Hashrate extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Mining.php b/src/Methods/Eth/Mining.php new file mode 100644 index 0000000..c7688e5 --- /dev/null +++ b/src/Methods/Eth/Mining.php @@ -0,0 +1,51 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class Mining extends EthMethod +{ + /** + * 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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/ProtocolVersion.php b/src/Methods/Eth/ProtocolVersion.php index 4d937f0..d95c624 100644 --- a/src/Methods/Eth/ProtocolVersion.php +++ b/src/Methods/Eth/ProtocolVersion.php @@ -12,11 +12,10 @@ namespace Web3\Methods\Eth; use InvalidArgumentException; -use Web3\Methods\IMethod; -use Web3\Methods\JSONRPC; +use Web3\Methods\EthMethod; use Web3\Formatters\BigNumberFormatter; -class ProtocolVersion extends JSONRPC implements IMethod +class ProtocolVersion extends EthMethod { /** * inputFormatters @@ -34,6 +33,13 @@ class ProtocolVersion extends JSONRPC implements IMethod BigNumberFormatter::class ]; + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = []; + /** * construct * @@ -45,47 +51,4 @@ class ProtocolVersion extends JSONRPC implements IMethod // { // 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; - } } \ No newline at end of file diff --git a/src/Methods/Eth/SendRawTransaction.php b/src/Methods/Eth/SendRawTransaction.php new file mode 100644 index 0000000..9fcb742 --- /dev/null +++ b/src/Methods/Eth/SendRawTransaction.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\HexFormatter; + +class SendRawTransaction extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + HexFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/SendTransaction.php b/src/Methods/Eth/SendTransaction.php new file mode 100644 index 0000000..4bbb576 --- /dev/null +++ b/src/Methods/Eth/SendTransaction.php @@ -0,0 +1,54 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\TransactionFormatter; + +class SendTransaction extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + TransactionFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Sign.php b/src/Methods/Eth/Sign.php new file mode 100644 index 0000000..dcc3c07 --- /dev/null +++ b/src/Methods/Eth/Sign.php @@ -0,0 +1,55 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Eth; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Formatters\AddressFormatter; +use Web3\Formatters\HexFormatter; + +class Sign extends EthMethod +{ + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = [ + AddressFormatter::class, HexFormatter::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); + // } +} \ No newline at end of file diff --git a/src/Methods/Eth/Syncing.php b/src/Methods/Eth/Syncing.php index 6192c4d..0628394 100644 --- a/src/Methods/Eth/Syncing.php +++ b/src/Methods/Eth/Syncing.php @@ -12,10 +12,9 @@ namespace Web3\Methods\Eth; use InvalidArgumentException; -use Web3\Methods\IMethod; -use Web3\Methods\JSONRPC; +use Web3\Methods\EthMethod; -class Syncing extends JSONRPC implements IMethod +class Syncing extends EthMethod { /** * inputFormatters @@ -31,6 +30,13 @@ class Syncing extends JSONRPC implements IMethod */ protected $outputFormatters = []; + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = []; + /** * construct * @@ -42,47 +48,4 @@ class Syncing extends JSONRPC implements IMethod // { // 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; - } } \ No newline at end of file