commit
f2bfb2f4e3
@ -27,7 +27,7 @@ use Web3\Contracts\Types\Str;
|
|||||||
use Web3\Contracts\Types\Uinteger;
|
use Web3\Contracts\Types\Uinteger;
|
||||||
use Web3\Validators\AddressValidator;
|
use Web3\Validators\AddressValidator;
|
||||||
use Web3\Validators\HexValidator;
|
use Web3\Validators\HexValidator;
|
||||||
use Web3\Formatters\Address as AddressFormatter;
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
|
||||||
class Contract
|
class Contract
|
||||||
{
|
{
|
||||||
|
355
src/Eth.php
355
src/Eth.php
@ -41,301 +41,15 @@ class Eth
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $methods = [
|
private $methods = [];
|
||||||
'eth_protocolVersion' => [],
|
|
||||||
'eth_syncing' => [],
|
/**
|
||||||
'eth_coinbase' => [],
|
* allowedMethods
|
||||||
'eth_mining' => [],
|
*
|
||||||
'eth_hashrate' => [],
|
* @var array
|
||||||
'eth_gasPrice' => [],
|
*/
|
||||||
'eth_accounts' => [],
|
private $allowedMethods = [
|
||||||
'eth_blockNumber' => [],
|
'eth_protocolVersion', 'eth_syncing', 'eth_coinbase', 'eth_mining', 'eth_hashrate', 'eth_gasPrice', 'eth_accounts', 'eth_blockNumber', 'eth_getBalance', 'eth_getStorageAt', 'eth_getTransactionCount', 'eth_getBlockTransactionCountByHash', 'eth_getBlockTransactionCountByNumber', 'eth_getUncleCountByBlockHash', 'eth_getUncleCountByBlockNumber', 'eth_getUncleByBlockHashAndIndex', 'eth_getUncleByBlockNumberAndIndex', 'eth_getCode', 'eth_sign', 'eth_sendTransaction', 'eth_sendRawTransaction', 'eth_call', 'eth_estimateGas', 'eth_getBlockByHash', 'eth_getBlockByNumber', 'eth_getTransactionByHash', 'eth_getTransactionByBlockHashAndIndex', 'eth_getTransactionByBlockNumberAndIndex', 'eth_getTransactionReceipt', 'eth_getCompilers', 'eth_compileSolidity', 'eth_compileLLL', 'eth_compileSerpent', 'eth_getWork', 'eth_newFilter', 'eth_newBlockFilter', 'eth_newPendingTransactionFilter', 'eth_uninstallFilter', 'eth_getFilterChanges', 'eth_getFilterLogs', 'eth_getLogs', 'eth_submitWork', 'eth_submitHashrate'
|
||||||
'eth_getBalance' => [
|
|
||||||
'params'=> [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class,
|
|
||||||
], [
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getStorageAt' => [
|
|
||||||
'params'=> [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class,
|
|
||||||
], [
|
|
||||||
'validators' => QuantityValidator::class,
|
|
||||||
], [
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getTransactionCount' => [
|
|
||||||
'params'=> [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class,
|
|
||||||
], [
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getBlockTransactionCountByHash' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getBlockTransactionCountByNumber' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getUncleCountByBlockHash' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getUncleCountByBlockNumber' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getCode' => [
|
|
||||||
'params'=> [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class,
|
|
||||||
], [
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
TagValidator::class, QuantityValidator::class,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_sign' => [
|
|
||||||
'params'=> [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class,
|
|
||||||
], [
|
|
||||||
'validators' => HexValidator::class
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_sendTransaction' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => TransactionValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_sendRawTransaction' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => HexValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_call' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => CallValidator::class
|
|
||||||
], [
|
|
||||||
'default' => 'latest',
|
|
||||||
'validators' => [
|
|
||||||
QuantityValidator::class, TagValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_estimateGas' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => TransactionValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getBlockByHash' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => BooleanValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getBlockByNumber' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => [
|
|
||||||
QuantityValidator::class, TagValidator::class
|
|
||||||
]
|
|
||||||
], [
|
|
||||||
'validators' => BooleanValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getTransactionByHash' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getTransactionByBlockHashAndIndex' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getTransactionByBlockNumberAndIndex' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => [
|
|
||||||
QuantityValidator::class, TagValidator::class
|
|
||||||
]
|
|
||||||
], [
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getTransactionReceipt' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getUncleByBlockHashAndIndex' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getUncleByBlockNumberAndIndex' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => [
|
|
||||||
QuantityValidator::class, TagValidator::class
|
|
||||||
]
|
|
||||||
], [
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getCompilers' => [],
|
|
||||||
'eth_compileSolidity' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => StringValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_compileLLL' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => StringValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_compileSerpent' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => StringValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_newFilter' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => FilterValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_newBlockFilter' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_newPendingTransactionFilter' => [],
|
|
||||||
'eth_uninstallFilter' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getFilterChanges' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getFilterLogs' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getLogs' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => FilterValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_getWork' => [],
|
|
||||||
'eth_submitWork' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => NonceValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'eth_submitHashrate' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => BlockHashValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -376,11 +90,9 @@ class Eth
|
|||||||
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
||||||
$method = strtolower($class[1]) . '_' . $name;
|
$method = strtolower($class[1]) . '_' . $name;
|
||||||
|
|
||||||
if (!array_key_exists($method, $this->methods)) {
|
if (!in_array($method, $this->allowedMethods)) {
|
||||||
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
||||||
}
|
}
|
||||||
$allowedMethod = $this->methods[$method];
|
|
||||||
|
|
||||||
if ($this->provider->isBatch) {
|
if ($this->provider->isBatch) {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
} else {
|
} else {
|
||||||
@ -390,43 +102,18 @@ class Eth
|
|||||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($allowedMethod['params']) && is_array($allowedMethod['params'])) {
|
if (!array_key_exists($method, $this->methods)) {
|
||||||
// validate params
|
// new the method
|
||||||
foreach ($allowedMethod['params'] as $key => $param) {
|
$methodClass = sprintf("\Web3\Methods\%s\%s", ucfirst($class[1]), ucfirst($name));
|
||||||
if (isset($param['validators'])) {
|
$methodObject = new $methodClass($method, $arguments);
|
||||||
if (is_array($param['validators'])) {
|
$this->methods[$method] = $methodObject;
|
||||||
$isError = true;
|
} else {
|
||||||
|
$methodObject = $this->methods[$method];
|
||||||
foreach ($param['validators'] as $rule) {
|
|
||||||
if (isset($arguments[$key])) {
|
|
||||||
if (call_user_func([$rule, 'validate'], $arguments[$key]) === true) {
|
|
||||||
$isError = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isset($param['default'])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
$isError = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isError === true) {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!isset($arguments[$key]) || call_user_func([$param['validators'], 'validate'], $arguments[$key]) === false) {
|
|
||||||
if (isset($param['default']) && !isset($arguments[$key])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->provider->send($method, $arguments, $callback);
|
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||||
|
$methodObject->arguments = $inputs;
|
||||||
|
|
||||||
|
$this->provider->send($methodObject, $callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use Web3\Utils;
|
|||||||
use Web3\Formatters\IFormatter;
|
use Web3\Formatters\IFormatter;
|
||||||
use Web3\Formatters\Integer as IntegerFormatter;
|
use Web3\Formatters\Integer as IntegerFormatter;
|
||||||
|
|
||||||
class Address implements IFormatter
|
class AddressFormatter implements IFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* format
|
* format
|
33
src/Formatters/BigNumberFormatter.php
Normal file
33
src/Formatters/BigNumberFormatter.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
|
||||||
|
class BigNumberFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
$value = Utils::toString($value);
|
||||||
|
$bn = Utils::toBn($value);
|
||||||
|
|
||||||
|
return $bn;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ use InvalidArgumentException;
|
|||||||
use Web3\Utils;
|
use Web3\Utils;
|
||||||
use Web3\Formatters\IFormatter;
|
use Web3\Formatters\IFormatter;
|
||||||
|
|
||||||
class Boolean implements IFormatter
|
class BooleanFormatter implements IFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* format
|
* format
|
40
src/Formatters/HexFormatter.php
Normal file
40
src/Formatters/HexFormatter.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
|
||||||
|
class HexFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
$value = Utils::toString($value);
|
||||||
|
$value = mb_strtolower($value);
|
||||||
|
|
||||||
|
if (Utils::isZeroPrefixed($value)) {
|
||||||
|
return $value;
|
||||||
|
} elseif (Utils::isHex($value)) {
|
||||||
|
$value = '0x' . $value;
|
||||||
|
} else {
|
||||||
|
$value = Utils::toHex($value, true);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
37
src/Formatters/OptionalQuantityFormatter.php
Normal file
37
src/Formatters/OptionalQuantityFormatter.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
|
||||||
|
class OptionalQuantityFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
if (TagValidator::validate($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
$value = Utils::toString($value);
|
||||||
|
$bn = Utils::toBn($value);
|
||||||
|
|
||||||
|
return '0x' . $bn->toHex(true);
|
||||||
|
}
|
||||||
|
}
|
33
src/Formatters/QuantityFormatter.php
Normal file
33
src/Formatters/QuantityFormatter.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
|
||||||
|
class QuantityFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
$value = Utils::toString($value);
|
||||||
|
$bn = Utils::toBn($value);
|
||||||
|
|
||||||
|
return '0x' . $bn->toHex(true);
|
||||||
|
}
|
||||||
|
}
|
30
src/Formatters/StringFormatter.php
Normal file
30
src/Formatters/StringFormatter.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
|
||||||
|
class StringFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
return Utils::toString($value);
|
||||||
|
}
|
||||||
|
}
|
47
src/Formatters/TransactionFormatter.php
Normal file
47
src/Formatters/TransactionFormatter.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?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\Formatters;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Utils;
|
||||||
|
use Web3\Formatters\IFormatter;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class TransactionFormatter implements IFormatter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* format
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function format($value)
|
||||||
|
{
|
||||||
|
if (isset($value['gas'])) {
|
||||||
|
$value['gas'] = QuantityFormatter::format($value['gas']);
|
||||||
|
}
|
||||||
|
if (isset($value['gasPrice'])) {
|
||||||
|
$value['gasPrice'] = QuantityFormatter::format($value['gasPrice']);
|
||||||
|
}
|
||||||
|
if (isset($value['value'])) {
|
||||||
|
$value['value'] = QuantityFormatter::format($value['value']);
|
||||||
|
}
|
||||||
|
if (isset($value['data'])) {
|
||||||
|
$value['data'] = HexFormatter::format($value['data']);
|
||||||
|
}
|
||||||
|
if (isset($value['nonce'])) {
|
||||||
|
$value['nonce'] = QuantityFormatter::format($value['nonce']);
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
58
src/Methods/Eth/Accounts.php
Normal file
58
src/Methods/Eth/Accounts.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Accounts extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/BlockNumber.php
Normal file
58
src/Methods/Eth/BlockNumber.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class BlockNumber extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
71
src/Methods/Eth/Call.php
Normal file
71
src/Methods/Eth/Call.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\CallValidator;
|
||||||
|
use Web3\Formatters\TransactionFormatter;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class Call extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
CallValidator::class, [
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/Coinbase.php
Normal file
58
src/Methods/Eth/Coinbase.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Coinbase extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/CompileLLL.php
Normal file
64
src/Methods/Eth/CompileLLL.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
|
class CompileLLL extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
StringFormatter::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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/CompileSerpent.php
Normal file
64
src/Methods/Eth/CompileSerpent.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
|
class CompileSerpent extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
StringFormatter::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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/CompileSolidity.php
Normal file
64
src/Methods/Eth/CompileSolidity.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
|
class CompileSolidity extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
StringFormatter::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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/EstimateGas.php
Normal file
64
src/Methods/Eth/EstimateGas.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TransactionValidator;
|
||||||
|
use Web3\Formatters\TransactionFormatter;
|
||||||
|
|
||||||
|
class EstimateGas extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
TransactionValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/GasPrice.php
Normal file
58
src/Methods/Eth/GasPrice.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class GasPrice extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
71
src/Methods/Eth/GetBalance.php
Normal file
71
src/Methods/Eth/GetBalance.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetBalance extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, [
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/GetBlockByHash.php
Normal file
66
src/Methods/Eth/GetBlockByHash.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Validators\BooleanValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
use Web3\Formatters\BooleanFormatter;
|
||||||
|
|
||||||
|
class GetBlockByHash extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class, BooleanValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/GetBlockByNumber.php
Normal file
66
src/Methods/Eth/GetBlockByNumber.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\BooleanValidator;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
use Web3\Formatters\BooleanFormatter;
|
||||||
|
|
||||||
|
class GetBlockByNumber extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
QuantityValidator::class, BooleanValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetBlockTransactionCountByHash.php
Normal file
64
src/Methods/Eth/GetBlockTransactionCountByHash.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class GetBlockTransactionCountByHash extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/GetBlockTransactionCountByNumber.php
Normal file
66
src/Methods/Eth/GetBlockTransactionCountByNumber.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetBlockTransactionCountByNumber extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
71
src/Methods/Eth/GetCode.php
Normal file
71
src/Methods/Eth/GetCode.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetCode extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, [
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/GetCompilers.php
Normal file
58
src/Methods/Eth/GetCompilers.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class GetCompilers extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetFilterChanges.php
Normal file
64
src/Methods/Eth/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\Eth;
|
||||||
|
|
||||||
|
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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetFilterLogs.php
Normal file
64
src/Methods/Eth/GetFilterLogs.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class GetFilterLogs 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);
|
||||||
|
// }
|
||||||
|
}
|
61
src/Methods/Eth/GetLogs.php
Normal file
61
src/Methods/Eth/GetLogs.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\FilterValidator;
|
||||||
|
|
||||||
|
class GetLogs extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
FilterValidator::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);
|
||||||
|
// }
|
||||||
|
}
|
72
src/Methods/Eth/GetStorageAt.php
Normal file
72
src/Methods/Eth/GetStorageAt.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetStorageAt extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, QuantityValidator::class, [
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/GetTransactionByBlockHashAndIndex.php
Normal file
66
src/Methods/Eth/GetTransactionByBlockHashAndIndex.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class GetTransactionByBlockHashAndIndex extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class, QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
68
src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php
Normal file
68
src/Methods/Eth/GetTransactionByBlockNumberAndIndex.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class GetTransactionByBlockNumberAndIndex extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
[
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
], QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetTransactionByHash.php
Normal file
64
src/Methods/Eth/GetTransactionByHash.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class GetTransactionByHash extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
71
src/Methods/Eth/GetTransactionCount.php
Normal file
71
src/Methods/Eth/GetTransactionCount.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetTransactionCount extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, [
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetTransactionReceipt.php
Normal file
64
src/Methods/Eth/GetTransactionReceipt.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class GetTransactionReceipt extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/GetUncleByBlockHashAndIndex.php
Normal file
66
src/Methods/Eth/GetUncleByBlockHashAndIndex.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class GetUncleByBlockHashAndIndex extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class, QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
68
src/Methods/Eth/GetUncleByBlockNumberAndIndex.php
Normal file
68
src/Methods/Eth/GetUncleByBlockNumberAndIndex.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class GetUncleByBlockNumberAndIndex extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
[
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
], QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/GetUncleCountByBlockHash.php
Normal file
64
src/Methods/Eth/GetUncleCountByBlockHash.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class GetUncleCountByBlockHash extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
69
src/Methods/Eth/GetUncleCountByBlockNumber.php
Normal file
69
src/Methods/Eth/GetUncleCountByBlockNumber.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\OptionalQuantityFormatter;
|
||||||
|
|
||||||
|
class GetUncleCountByBlockNumber extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
[
|
||||||
|
TagValidator::class, QuantityValidator::class
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/GetWork.php
Normal file
58
src/Methods/Eth/GetWork.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class GetWork extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/Hashrate.php
Normal file
58
src/Methods/Eth/Hashrate.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Hashrate extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/Mining.php
Normal file
58
src/Methods/Eth/Mining.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Mining extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/NewBlockFilter.php
Normal file
64
src/Methods/Eth/NewBlockFilter.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class NewBlockFilter 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);
|
||||||
|
// }
|
||||||
|
}
|
61
src/Methods/Eth/NewFilter.php
Normal file
61
src/Methods/Eth/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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\FilterValidator;
|
||||||
|
|
||||||
|
class NewFilter extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
FilterValidator::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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/NewPendingTransactionFilter.php
Normal file
58
src/Methods/Eth/NewPendingTransactionFilter.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class NewPendingTransactionFilter extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
61
src/Methods/Eth/ProtocolVersion.php
Normal file
61
src/Methods/Eth/ProtocolVersion.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Formatters\BigNumberFormatter;
|
||||||
|
|
||||||
|
class ProtocolVersion extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $outputFormatters = [
|
||||||
|
BigNumberFormatter::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defaultValues
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultValues = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function __construct($method='', $arguments=[])
|
||||||
|
// {
|
||||||
|
// parent::__construct($method, $arguments);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/SendRawTransaction.php
Normal file
64
src/Methods/Eth/SendRawTransaction.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\HexValidator;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class SendRawTransaction extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
HexValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/SendTransaction.php
Normal file
64
src/Methods/Eth/SendTransaction.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TransactionValidator;
|
||||||
|
use Web3\Formatters\TransactionFormatter;
|
||||||
|
|
||||||
|
class SendTransaction extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
TransactionValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Eth/Sign.php
Normal file
66
src/Methods/Eth/Sign.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Validators\HexValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
|
||||||
|
class Sign extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, HexValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
61
src/Methods/Eth/SubmitHashrate.php
Normal file
61
src/Methods/Eth/SubmitHashrate.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
|
||||||
|
class SubmitHashrate extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
BlockHashValidator::class, BlockHashValidator::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);
|
||||||
|
// }
|
||||||
|
}
|
65
src/Methods/Eth/SubmitWork.php
Normal file
65
src/Methods/Eth/SubmitWork.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\NonceValidator;
|
||||||
|
use Web3\Validators\BlockHashValidator;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class SubmitWork extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
NonceValidator::class, BlockHashValidator::class, BlockHashValidator::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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Eth/Syncing.php
Normal file
58
src/Methods/Eth/Syncing.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Syncing extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Eth/UninstallFilter.php
Normal file
64
src/Methods/Eth/UninstallFilter.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\Eth;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class UninstallFilter 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);
|
||||||
|
// }
|
||||||
|
}
|
170
src/Methods/EthMethod.php
Normal file
170
src/Methods/EthMethod.php
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
use Web3\Methods\IMethod;
|
||||||
|
use Web3\Methods\JSONRPC;
|
||||||
|
|
||||||
|
class EthMethod extends JSONRPC implements IMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getInputFormatters
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getInputFormatters()
|
||||||
|
{
|
||||||
|
return $this->inputFormatters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getOutputFormatters
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getOutputFormatters()
|
||||||
|
{
|
||||||
|
return $this->outputFormatters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validate
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function validate($params)
|
||||||
|
{
|
||||||
|
if (!is_array($params)) {
|
||||||
|
throw new InvalidArgumentException('Please use array params when call validate.');
|
||||||
|
}
|
||||||
|
$rules = $this->validators;
|
||||||
|
|
||||||
|
if (count($params) < count($rules)) {
|
||||||
|
if (!isset($this->defaultValues) || empty($this->defaultValues)) {
|
||||||
|
throw new InvalidArgumentException('The params are less than validators.');
|
||||||
|
}
|
||||||
|
$defaultValues = $this->defaultValues;
|
||||||
|
|
||||||
|
foreach ($defaultValues as $key => $value) {
|
||||||
|
if (!isset($params[$key])) {
|
||||||
|
$params[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} elseif (count($params) > count($rules)) {
|
||||||
|
throw new InvalidArgumentException('The params are more than validators.');
|
||||||
|
}
|
||||||
|
foreach ($rules as $key => $rule) {
|
||||||
|
if (isset($params[$key])) {
|
||||||
|
if (is_array($rule)) {
|
||||||
|
$isError = true;
|
||||||
|
|
||||||
|
foreach ($rule as $r) {
|
||||||
|
if (call_user_func([$rule, 'validate'], $params[$key]) === true) {
|
||||||
|
$isError = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($isError) {
|
||||||
|
throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
|
||||||
|
throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.');
|
||||||
|
}
|
||||||
|
if (count($params) < count($rules)) {
|
||||||
|
if (!isset($this->defaultValues) || empty($this->defaultValues)) {
|
||||||
|
throw new \InvalidArgumentException('The params are less than inputFormatters.');
|
||||||
|
}
|
||||||
|
$defaultValues = $this->defaultValues;
|
||||||
|
|
||||||
|
foreach ($defaultValues as $key => $value) {
|
||||||
|
if (!isset($params[$key])) {
|
||||||
|
$params[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($params as $key => $param) {
|
||||||
|
if (isset($rules[$key])) {
|
||||||
|
$params[$key] = call_user_func([$rules[$key], 'format'], $param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
|
}
|
24
src/Methods/IMethod.php
Normal file
24
src/Methods/IMethod.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
interface IMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* transform
|
||||||
|
*
|
||||||
|
* @param array &$data
|
||||||
|
* @param array $rules
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform($data, $rules);
|
||||||
|
}
|
29
src/Methods/IRPC.php
Normal file
29
src/Methods/IRPC.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
interface IRPC
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* __toString
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toPayload
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toPayload();
|
||||||
|
}
|
212
src/Methods/JSONRPC.php
Normal file
212
src/Methods/JSONRPC.php
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\IRPC;
|
||||||
|
|
||||||
|
class JSONRPC implements IRPC
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $id = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rpcVersion
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $rpcVersion = '2.0';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $method = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* arguments
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $arguments = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($method, $arguments)
|
||||||
|
{
|
||||||
|
$this->method = $method;
|
||||||
|
$this->arguments = $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __get($name)
|
||||||
|
{
|
||||||
|
$method = 'get' . ucfirst($name);
|
||||||
|
|
||||||
|
if (method_exists($this, $method)) {
|
||||||
|
return call_user_func_array([$this, $method], []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function __set($name, $value)
|
||||||
|
{
|
||||||
|
$method = 'set' . ucfirst($name);
|
||||||
|
|
||||||
|
if (method_exists($this, $method)) {
|
||||||
|
return call_user_func_array([$this, $method], [$value]);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __toString
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
$payload = $this->toPayload();
|
||||||
|
|
||||||
|
return json_encode($payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setId
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
if (!is_int($id)) {
|
||||||
|
throw new InvalidArgumentException('Id must be integer.');
|
||||||
|
}
|
||||||
|
$this->id = $id;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getId
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getRpcVersion
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRpcVersion()
|
||||||
|
{
|
||||||
|
return $this->rpcVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getMethod
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMethod()
|
||||||
|
{
|
||||||
|
return $this->method;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setArguments
|
||||||
|
*
|
||||||
|
* @param array $arguments
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function setArguments($arguments)
|
||||||
|
{
|
||||||
|
if (!is_array($arguments)) {
|
||||||
|
throw new InvalidArgumentException('Please use array when call setArguments.');
|
||||||
|
}
|
||||||
|
$this->arguments = $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getArguments
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getArguments()
|
||||||
|
{
|
||||||
|
return $this->arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toPayload
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toPayload()
|
||||||
|
{
|
||||||
|
if (empty($this->method) || !is_string($this->method)) {
|
||||||
|
throw new InvalidArgumentException('Please check the method set properly.');
|
||||||
|
}
|
||||||
|
if (empty($this->id)) {
|
||||||
|
$id = rand();
|
||||||
|
} else {
|
||||||
|
$id = $this->id;
|
||||||
|
}
|
||||||
|
$rpc = [
|
||||||
|
'id' => $id,
|
||||||
|
'jsonrpc' => $this->rpcVersion,
|
||||||
|
'method' => $this->method
|
||||||
|
];
|
||||||
|
|
||||||
|
if (count($this->arguments) > 0) {
|
||||||
|
$rpc['params'] = $this->arguments;
|
||||||
|
}
|
||||||
|
return $rpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toPayloadString
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toPayloadString()
|
||||||
|
{
|
||||||
|
$payload = $this->toPayload();
|
||||||
|
|
||||||
|
return json_encode($payload);
|
||||||
|
}
|
||||||
|
}
|
58
src/Methods/Net/Listening.php
Normal file
58
src/Methods/Net/Listening.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Net;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Listening extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
61
src/Methods/Net/PeerCount.php
Normal file
61
src/Methods/Net/PeerCount.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\Net;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Formatters\BigNumberFormatter;
|
||||||
|
|
||||||
|
class PeerCount extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $outputFormatters = [
|
||||||
|
BigNumberFormatter::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defaultValues
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultValues = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function __construct($method='', $arguments=[])
|
||||||
|
// {
|
||||||
|
// parent::__construct($method, $arguments);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Net/Version.php
Normal file
58
src/Methods/Net/Version.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Net;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class Version extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Personal/ListAccounts.php
Normal file
58
src/Methods/Personal/ListAccounts.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Personal;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class ListAccounts extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Personal/NewAccount.php
Normal file
64
src/Methods/Personal/NewAccount.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\Personal;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
|
class NewAccount extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
StringFormatter::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);
|
||||||
|
// }
|
||||||
|
}
|
66
src/Methods/Personal/SendTransaction.php
Normal file
66
src/Methods/Personal/SendTransaction.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?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\Personal;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TransactionValidator;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Formatters\TransactionFormatter;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
|
class SendTransaction extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
TransactionValidator::class, StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
TransactionFormatter::class, StringFormatter::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);
|
||||||
|
// }
|
||||||
|
}
|
70
src/Methods/Personal/UnlockAccount.php
Normal file
70
src/Methods/Personal/UnlockAccount.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?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\Personal;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Formatters\StringFormatter;
|
||||||
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
|
class UnlockAccount extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, StringValidator::class, QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* inputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $inputFormatters = [
|
||||||
|
AddressFormatter::class, StringFormatter::class, QuantityFormatter::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outputFormatters
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $outputFormatters = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* defaultValues
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultValues = [
|
||||||
|
2 => 300
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* construct
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function __construct($method='', $arguments=[])
|
||||||
|
// {
|
||||||
|
// parent::__construct($method, $arguments);
|
||||||
|
// }
|
||||||
|
}
|
58
src/Methods/Web3/ClientVersion.php
Normal file
58
src/Methods/Web3/ClientVersion.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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\Web3;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
|
||||||
|
class ClientVersion extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
64
src/Methods/Web3/Sha3.php
Normal file
64
src/Methods/Web3/Sha3.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\Web3;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Formatters\HexFormatter;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
|
||||||
|
class Sha3 extends EthMethod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
// }
|
||||||
|
}
|
65
src/Net.php
65
src/Net.php
@ -30,10 +30,15 @@ class Net
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $methods = [
|
private $methods = [];
|
||||||
'net_version' => [],
|
|
||||||
'net_peerCount' => [],
|
/**
|
||||||
'net_listening' => [],
|
* allowedMethods
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $allowedMethods = [
|
||||||
|
'net_version', 'net_peerCount', 'net_listening'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,11 +79,9 @@ class Net
|
|||||||
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
||||||
$method = strtolower($class[1]) . '_' . $name;
|
$method = strtolower($class[1]) . '_' . $name;
|
||||||
|
|
||||||
if (!array_key_exists($method, $this->methods)) {
|
if (!in_array($method, $this->allowedMethods)) {
|
||||||
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
||||||
}
|
}
|
||||||
$allowedMethod = $this->methods[$method];
|
|
||||||
|
|
||||||
if ($this->provider->isBatch) {
|
if ($this->provider->isBatch) {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
} else {
|
} else {
|
||||||
@ -88,43 +91,19 @@ class Net
|
|||||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($allowedMethod['params']) && is_array($allowedMethod['params'])) {
|
if (!array_key_exists($method, $this->methods)) {
|
||||||
// validate params
|
// new the method
|
||||||
foreach ($allowedMethod['params'] as $key => $param) {
|
$methodClass = sprintf("\Web3\Methods\%s\%s", ucfirst($class[1]), ucfirst($name));
|
||||||
if (isset($param['validators'])) {
|
$methodObject = new $methodClass($method, $arguments);
|
||||||
if (is_array($param['validators'])) {
|
$this->methods[$method] = $methodObject;
|
||||||
$isError = true;
|
} else {
|
||||||
|
$methodObject = $this->methods[$method];
|
||||||
foreach ($param['validators'] as $rule) {
|
}
|
||||||
if (isset($arguments[$key])) {
|
if ($methodObject->validate($arguments)) {
|
||||||
if (call_user_func([$rule, 'validate'], $arguments[$key]) === true) {
|
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||||
$isError = false;
|
$methodObject->arguments = $inputs;
|
||||||
break;
|
$this->provider->send($methodObject, $callback);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isset($param['default'])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
$isError = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isError === true) {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!isset($arguments[$key]) || call_user_func([$param['validators'], 'validate'], $arguments[$key]) === false) {
|
|
||||||
if (isset($param['default']) && !isset($arguments[$key])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->provider->send($method, $arguments, $callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,36 +34,15 @@ class Personal
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $methods = [
|
private $methods = [];
|
||||||
'personal_listAccounts' => [],
|
|
||||||
'personal_newAccount' => [
|
/**
|
||||||
'params' => [
|
* allowedMethods
|
||||||
[
|
*
|
||||||
'validators' => StringValidator::class
|
* @var array
|
||||||
]
|
*/
|
||||||
]
|
private $allowedMethods = [
|
||||||
],
|
'personal_listAccounts', 'personal_newAccount', 'personal_unlockAccount', 'personal_sendTransaction'
|
||||||
'personal_unlockAccount' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => AddressValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => StringValidator::class
|
|
||||||
], [
|
|
||||||
'default' => 300,
|
|
||||||
'validators' => QuantityValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'personal_sendTransaction' => [
|
|
||||||
'params' => [
|
|
||||||
[
|
|
||||||
'validators' => TransactionValidator::class
|
|
||||||
], [
|
|
||||||
'validators' => StringValidator::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,11 +83,9 @@ class Personal
|
|||||||
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
||||||
$method = strtolower($class[1]) . '_' . $name;
|
$method = strtolower($class[1]) . '_' . $name;
|
||||||
|
|
||||||
if (!array_key_exists($method, $this->methods)) {
|
if (!in_array($method, $this->allowedMethods)) {
|
||||||
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
||||||
}
|
}
|
||||||
$allowedMethod = $this->methods[$method];
|
|
||||||
|
|
||||||
if ($this->provider->isBatch) {
|
if ($this->provider->isBatch) {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
} else {
|
} else {
|
||||||
@ -118,43 +95,19 @@ class Personal
|
|||||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($allowedMethod['params']) && is_array($allowedMethod['params'])) {
|
if (!array_key_exists($method, $this->methods)) {
|
||||||
// validate params
|
// new the method
|
||||||
foreach ($allowedMethod['params'] as $key => $param) {
|
$methodClass = sprintf("\Web3\Methods\%s\%s", ucfirst($class[1]), ucfirst($name));
|
||||||
if (isset($param['validators'])) {
|
$methodObject = new $methodClass($method, $arguments);
|
||||||
if (is_array($param['validators'])) {
|
$this->methods[$method] = $methodObject;
|
||||||
$isError = true;
|
} else {
|
||||||
|
$methodObject = $this->methods[$method];
|
||||||
foreach ($param['validators'] as $rule) {
|
}
|
||||||
if (isset($arguments[$key])) {
|
if ($methodObject->validate($arguments)) {
|
||||||
if (call_user_func([$rule, 'validate'], $arguments[$key]) === true) {
|
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||||
$isError = false;
|
$methodObject->arguments = $inputs;
|
||||||
break;
|
$this->provider->send($methodObject, $callback);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isset($param['default'])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
$isError = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isError === true) {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!isset($arguments[$key]) || call_user_func([$param['validators'], 'validate'], $arguments[$key]) === false) {
|
|
||||||
if (isset($param['default']) && !isset($arguments[$key])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->provider->send($method, $arguments, $callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,13 @@ use Web3\RequestManagers\RequestManager;
|
|||||||
|
|
||||||
class HttpProvider extends Provider implements IProvider
|
class HttpProvider extends Provider implements IProvider
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* methods
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $methods = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construct
|
* construct
|
||||||
*
|
*
|
||||||
@ -31,19 +38,31 @@ class HttpProvider extends Provider implements IProvider
|
|||||||
/**
|
/**
|
||||||
* send
|
* send
|
||||||
*
|
*
|
||||||
* @param string $method
|
* @param \Web3\Methods\Method $method
|
||||||
* @param array $arguments
|
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function send($method, $arguments, $callback)
|
public function send($method, $callback)
|
||||||
{
|
{
|
||||||
$rpc = $this->createRpc($method, $arguments);
|
$payload = $method->toPayloadString();
|
||||||
|
|
||||||
if (!$this->isBatch) {
|
if (!$this->isBatch) {
|
||||||
$this->requestManager->sendPayload(json_encode($rpc), $callback);
|
$proxy = function ($err, $res) use ($method, $callback) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return call_user_func($callback, $err, null);
|
||||||
|
}
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$res = $method->transform([$res], $method->outputFormatters);
|
||||||
|
return call_user_func($callback, null, $res[0]);
|
||||||
|
}
|
||||||
|
$res = $method->transform($res, $method->outputFormatters);
|
||||||
|
|
||||||
|
return call_user_func($callback, null, $res);
|
||||||
|
};
|
||||||
|
$this->requestManager->sendPayload($payload, $proxy);
|
||||||
} else {
|
} else {
|
||||||
$this->batch[] = json_encode($rpc);
|
$this->methods[] = $method;
|
||||||
|
$this->batch[] = $payload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,30 +90,26 @@ class HttpProvider extends Provider implements IProvider
|
|||||||
if (!$this->isBatch) {
|
if (!$this->isBatch) {
|
||||||
throw new \RuntimeException('Please batch json rpc first.');
|
throw new \RuntimeException('Please batch json rpc first.');
|
||||||
}
|
}
|
||||||
$this->requestManager->sendPayload('[' . implode(',', $this->batch) . ']', $callback);
|
$methods = $this->methods;
|
||||||
|
$proxy = function ($err, $res) use ($methods, $callback) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return call_user_func($callback, $err, null);
|
||||||
|
}
|
||||||
|
foreach ($methods as $key => $method) {
|
||||||
|
if (isset($res[$key])) {
|
||||||
|
if (!is_array($res[$key])) {
|
||||||
|
$transformed = $method->transform([$res[$key]], $method->outputFormatters);
|
||||||
|
$res[$key] = $transformed[0];
|
||||||
|
} else {
|
||||||
|
$transformed = $method->transform($res[$key], $method->outputFormatters);
|
||||||
|
$res[$key] = $transformed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return call_user_func($callback, null, $res);
|
||||||
|
};
|
||||||
|
$this->requestManager->sendPayload('[' . implode(',', $this->batch) . ']', $proxy);
|
||||||
|
$this->methods[] = [];
|
||||||
$this->batch = [];
|
$this->batch = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* createRpc
|
|
||||||
*
|
|
||||||
* @param string $rpc
|
|
||||||
* @param array $arguments
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function createRpc($rpc, $arguments)
|
|
||||||
{
|
|
||||||
$this->id += 1;
|
|
||||||
|
|
||||||
$rpc = [
|
|
||||||
'id' => $this->id,
|
|
||||||
'jsonrpc' => $this->rpcVersion,
|
|
||||||
'method' => $rpc
|
|
||||||
];
|
|
||||||
|
|
||||||
if (count($arguments) > 0) {
|
|
||||||
$rpc['params'] = $arguments;
|
|
||||||
}
|
|
||||||
return $rpc;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -16,12 +16,11 @@ interface IProvider
|
|||||||
/**
|
/**
|
||||||
* send
|
* send
|
||||||
*
|
*
|
||||||
* @param string $method
|
* @param \Web3\Methods\Method $method
|
||||||
* @param array $arguments
|
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function send($method, $arguments, $callback);
|
public function send($method, $callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batch
|
* batch
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Web3;
|
namespace Web3;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use kornrunner\Keccak;
|
use kornrunner\Keccak;
|
||||||
@ -214,6 +215,22 @@ class Utils
|
|||||||
return '0x' . $hash;
|
return '0x' . $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toString
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function toString($value)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$value = (string) $value;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RuntimeException('Cannot transform value to string!');
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toWei
|
* toWei
|
||||||
* Change number from unit to wei.
|
* Change number from unit to wei.
|
||||||
|
70
src/Web3.php
70
src/Web3.php
@ -63,15 +63,15 @@ class Web3
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $methods = [
|
private $methods = [];
|
||||||
'web3_clientVersion' => [],
|
|
||||||
'web3_sha3' => [
|
/**
|
||||||
'params' => [
|
* allowedMethods
|
||||||
[
|
*
|
||||||
'validators' => HexValidator::class
|
* @var array
|
||||||
]
|
*/
|
||||||
]
|
private $allowedMethods = [
|
||||||
]
|
'web3_clientVersion', 'web3_sha3'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,11 +112,9 @@ class Web3
|
|||||||
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
if (preg_match('/^[a-zA-Z0-9]+$/', $name) === 1) {
|
||||||
$method = strtolower($class[1]) . '_' . $name;
|
$method = strtolower($class[1]) . '_' . $name;
|
||||||
|
|
||||||
if (!array_key_exists($method, $this->methods)) {
|
if (!in_array($method, $this->allowedMethods)) {
|
||||||
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
throw new \RuntimeException('Unallowed rpc method: ' . $method);
|
||||||
}
|
}
|
||||||
$allowedMethod = $this->methods[$method];
|
|
||||||
|
|
||||||
if ($this->provider->isBatch) {
|
if ($this->provider->isBatch) {
|
||||||
$callback = null;
|
$callback = null;
|
||||||
} else {
|
} else {
|
||||||
@ -126,43 +124,19 @@ class Web3
|
|||||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($allowedMethod['params']) && is_array($allowedMethod['params'])) {
|
if (!array_key_exists($method, $this->methods)) {
|
||||||
// validate params
|
// new the method
|
||||||
foreach ($allowedMethod['params'] as $key => $param) {
|
$methodClass = sprintf("\Web3\Methods\%s\%s", ucfirst($class[1]), ucfirst($name));
|
||||||
if (isset($param['validators'])) {
|
$methodObject = new $methodClass($method, $arguments);
|
||||||
if (is_array($param['validators'])) {
|
$this->methods[$method] = $methodObject;
|
||||||
$isError = true;
|
} else {
|
||||||
|
$methodObject = $this->methods[$method];
|
||||||
foreach ($param['validators'] as $rule) {
|
}
|
||||||
if (isset($arguments[$key])) {
|
if ($methodObject->validate($arguments)) {
|
||||||
if (call_user_func([$rule, 'validate'], $arguments[$key]) === true) {
|
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||||
$isError = false;
|
$methodObject->arguments = $inputs;
|
||||||
break;
|
$this->provider->send($methodObject, $callback);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isset($param['default'])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
$isError = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isError === true) {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!isset($arguments[$key]) || call_user_func([$param['validators'], 'validate'], $arguments[$key]) === false) {
|
|
||||||
if (isset($param['default']) && !isset($arguments[$key])) {
|
|
||||||
$arguments[$key] = $param['default'];
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException('Wrong type of ' . $name . ' method argument ' . $key . '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->provider->send($method, $arguments, $callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
namespace Test\Unit;
|
namespace Test\Unit;
|
||||||
|
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
use Web3\Formatters\Address;
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
|
||||||
class AddressFormatterTest extends TestCase
|
class AddressFormatterTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* formatter
|
* formatter
|
||||||
*
|
*
|
||||||
* @var \Web3\Formatters\Address
|
* @var \Web3\Formatters\AddressFormatter
|
||||||
*/
|
*/
|
||||||
protected $formatter;
|
protected $formatter;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class AddressFormatterTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->formatter = new Address;
|
$this->formatter = new AddressFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Test\Unit;
|
namespace Test\Unit;
|
||||||
|
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
use Web3\Formatters\Boolean;
|
use Web3\Formatters\BooleanFormatter;
|
||||||
|
|
||||||
class BooleanFormatterTest extends TestCase
|
class BooleanFormatterTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ class BooleanFormatterTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->formatter = new Boolean;
|
$this->formatter = new BooleanFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ namespace Test\Unit;
|
|||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
use phpseclib\Math\BigInteger as BigNumber;
|
||||||
|
|
||||||
class EthApiTest extends TestCase
|
class EthApiTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -39,7 +40,7 @@ class EthApiTest extends TestCase
|
|||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
return $this->fail($err->getMessage());
|
return $this->fail($err->getMessage());
|
||||||
}
|
}
|
||||||
$this->assertTrue(is_string($version));
|
$this->assertTrue($version instanceof BigNumber);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace Test\Unit;
|
|||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
use phpseclib\Math\BigInteger as BigNumber;
|
||||||
|
|
||||||
class EthBatchTest extends TestCase
|
class EthBatchTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ class EthBatchTest extends TestCase
|
|||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
return $this->fail('Got error!');
|
return $this->fail('Got error!');
|
||||||
}
|
}
|
||||||
$this->assertTrue(is_string($data[0]));
|
$this->assertTrue($data[0] instanceof BigNumber);
|
||||||
$this->assertTrue($data[1] !== null);
|
$this->assertTrue($data[1] !== null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace Test\Unit;
|
|||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
use phpseclib\Math\BigInteger as BigNumber;
|
||||||
|
|
||||||
class NetApiTest extends TestCase
|
class NetApiTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -56,7 +57,7 @@ class NetApiTest extends TestCase
|
|||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
return $this->fail($err->getMessage());
|
return $this->fail($err->getMessage());
|
||||||
}
|
}
|
||||||
$this->assertTrue(is_string($count));
|
$this->assertTrue($count instanceof BigNumber);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace Test\Unit;
|
|||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
use phpseclib\Math\BigInteger as BigNumber;
|
||||||
|
|
||||||
class NetBatchTest extends TestCase
|
class NetBatchTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -38,6 +39,7 @@ class NetBatchTest extends TestCase
|
|||||||
$net->batch(true);
|
$net->batch(true);
|
||||||
$net->version();
|
$net->version();
|
||||||
$net->listening();
|
$net->listening();
|
||||||
|
$net->peerCount();
|
||||||
|
|
||||||
$net->provider->execute(function ($err, $data) {
|
$net->provider->execute(function ($err, $data) {
|
||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
@ -45,6 +47,7 @@ class NetBatchTest extends TestCase
|
|||||||
}
|
}
|
||||||
$this->assertTrue(is_string($data[0]));
|
$this->assertTrue(is_string($data[0]));
|
||||||
$this->assertTrue(is_bool($data[1]));
|
$this->assertTrue(is_bool($data[1]));
|
||||||
|
$this->assertTrue($data[2] instanceof BigNumber);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -135,7 +135,7 @@ class PersonalApiTest extends TestCase
|
|||||||
|
|
||||||
$personal = $this->personal;
|
$personal = $this->personal;
|
||||||
|
|
||||||
$personal->newAccount(123456, function ($err, $account) {
|
$personal->newAccount($personal, function ($err, $account) {
|
||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
return $this->fail($err->getMessage());
|
return $this->fail($err->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -47,4 +47,28 @@ class PersonalBatchTest extends TestCase
|
|||||||
$this->assertTrue(is_string($data[1]));
|
$this->assertTrue(is_string($data[1]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testWrongParam
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongParam()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$personal = $this->personal;
|
||||||
|
|
||||||
|
$personal->batch(true);
|
||||||
|
$personal->listAccounts();
|
||||||
|
$personal->newAccount($personal);
|
||||||
|
|
||||||
|
$personal->provider->execute(function ($err, $data) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertTrue(is_string($data[0]));
|
||||||
|
$this->assertEquals($data[1], $this->testHash);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -65,6 +65,13 @@ class Web3ApiTest extends TestCase
|
|||||||
}
|
}
|
||||||
$this->assertEquals($hash, $this->testHash);
|
$this->assertEquals($hash, $this->testHash);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$web3->sha3('hello world', function ($err, $hash) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals($hash, $this->testHash);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,6 +95,8 @@ class Web3ApiTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* testWrongParam
|
* testWrongParam
|
||||||
|
* We transform data and throw invalid argument exception
|
||||||
|
* instead of runtime exception.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -97,7 +106,7 @@ class Web3ApiTest extends TestCase
|
|||||||
|
|
||||||
$web3 = $this->web3;
|
$web3 = $this->web3;
|
||||||
|
|
||||||
$web3->sha3('hello world', function ($err, $hash) {
|
$web3->sha3($web3, function ($err, $hash) {
|
||||||
if ($err !== null) {
|
if ($err !== null) {
|
||||||
return $this->fail($err->getMessage());
|
return $this->fail($err->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,28 @@ class Web3BatchTest extends TestCase
|
|||||||
$this->assertEquals($data[1], $this->testHash);
|
$this->assertEquals($data[1], $this->testHash);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testWrongParam
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongParam()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$web3 = $this->web3;
|
||||||
|
|
||||||
|
$web3->batch(true);
|
||||||
|
$web3->clientVersion();
|
||||||
|
$web3->sha3($web3);
|
||||||
|
|
||||||
|
$web3->provider->execute(function ($err, $data) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail('Got error!');
|
||||||
|
}
|
||||||
|
$this->assertTrue(is_string($data[0]));
|
||||||
|
$this->assertEquals($data[1], $this->testHash);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user