support importRawKey
This commit is contained in:
parent
3faad71b99
commit
354f76317a
65
src/Methods/Personal/ImportRawKey.php
Normal file
65
src/Methods/Personal/ImportRawKey.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\Personal;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\PrivateValidator;
|
||||
use Web3\Validators\StringValidator;
|
||||
use Web3\Formatters\StringFormatter;
|
||||
|
||||
class ImportRawKey extends EthMethod
|
||||
{
|
||||
/**
|
||||
* validators
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validators = [
|
||||
PrivateValidator::class, StringValidator::class
|
||||
];
|
||||
|
||||
/**
|
||||
* inputFormatters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $inputFormatters = [
|
||||
PrivateValidator::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);
|
||||
// }
|
||||
}
|
@ -38,7 +38,7 @@ class Personal
|
||||
* @var array
|
||||
*/
|
||||
private $allowedMethods = [
|
||||
'personal_listAccounts', 'personal_newAccount', 'personal_unlockAccount', 'personal_lockAccount', 'personal_sendTransaction'
|
||||
'personal_listAccounts', 'personal_newAccount', 'personal_unlockAccount', 'personal_lockAccount', 'personal_sendTransaction', 'personal_importRawKey'
|
||||
];
|
||||
|
||||
/**
|
||||
|
31
src/Validators/PrivateValidator.php
Normal file
31
src/Validators/PrivateValidator.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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;
|
||||
|
||||
class PrivateValidator
|
||||
{
|
||||
/**
|
||||
* validate
|
||||
*
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function validate($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
return (preg_match('/^[a-fA-F0-9]{64}$/', $value) >= 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user