CallValidator.
This commit is contained in:
parent
af974a6bb4
commit
0f59ac9223
@ -25,6 +25,7 @@ use Web3\Validators\BooleanValidator;
|
|||||||
use Web3\Validators\StringValidator;
|
use Web3\Validators\StringValidator;
|
||||||
use Web3\Validators\FilterValidator;
|
use Web3\Validators\FilterValidator;
|
||||||
use Web3\Validators\NonceValidator;
|
use Web3\Validators\NonceValidator;
|
||||||
|
use Web3\Validators\CallValidator;
|
||||||
|
|
||||||
class Eth
|
class Eth
|
||||||
{
|
{
|
||||||
@ -159,7 +160,7 @@ class Eth
|
|||||||
'eth_call' => [
|
'eth_call' => [
|
||||||
'params' => [
|
'params' => [
|
||||||
[
|
[
|
||||||
'validators' => TransactionValidator::class
|
'validators' => CallValidator::class
|
||||||
], [
|
], [
|
||||||
'default' => 'latest',
|
'default' => 'latest',
|
||||||
'validators' => [
|
'validators' => [
|
||||||
|
55
src/Validators/CallValidator.php
Normal file
55
src/Validators/CallValidator.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?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\Validators;
|
||||||
|
|
||||||
|
use Web3\Validators\IValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
|
use Web3\Validators\TagValidator;
|
||||||
|
use Web3\Validators\HexValidator;
|
||||||
|
|
||||||
|
class CallValidator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* validate
|
||||||
|
*
|
||||||
|
* @param array $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function validate($value)
|
||||||
|
{
|
||||||
|
if (!is_array($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['from']) && AddressValidator::validate($value['from']) === false && $value['from'] !== '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['to']) && AddressValidator::validate($value['to']) === false && $value['to'] !== '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['gas']) && QuantityValidator::validate($value['gas']) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['gasPrice']) && QuantityValidator::validate($value['gasPrice']) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['value']) && QuantityValidator::validate($value['value']) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['data']) && HexValidator::validate($value['data']) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isset($value['nonce']) && QuantityValidator::validate($value['nonce']) === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -472,7 +472,7 @@ class EthApiTest extends TestCase
|
|||||||
$eth = $this->eth;
|
$eth = $this->eth;
|
||||||
|
|
||||||
$eth->call([
|
$eth->call([
|
||||||
'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
// 'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
||||||
'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
||||||
'gas' => "0x76c0",
|
'gas' => "0x76c0",
|
||||||
'gasPrice' => "0x9184e72a000",
|
'gasPrice' => "0x9184e72a000",
|
||||||
|
Loading…
Reference in New Issue
Block a user