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);
|
||||
// }
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
/**
|
||||
* This file is part of web3.php package.
|
||||
*
|
||||
*
|
||||
* (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
|
||||
*
|
||||
*
|
||||
* @author Peter Lai <alk03073135@gmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
@ -27,18 +27,18 @@ class Personal
|
||||
|
||||
/**
|
||||
* methods
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $methods = [];
|
||||
|
||||
/**
|
||||
* allowedMethods
|
||||
*
|
||||
*
|
||||
* @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'
|
||||
];
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* call
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return void
|
||||
@ -109,7 +109,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* get
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
@ -125,7 +125,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* set
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
@ -142,7 +142,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* getProvider
|
||||
*
|
||||
*
|
||||
* @return \Web3\Providers\Provider
|
||||
*/
|
||||
public function getProvider()
|
||||
@ -152,7 +152,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* setProvider
|
||||
*
|
||||
*
|
||||
* @param \Web3\Providers\Provider $provider
|
||||
* @return bool
|
||||
*/
|
||||
@ -167,7 +167,7 @@ class Personal
|
||||
|
||||
/**
|
||||
* batch
|
||||
*
|
||||
*
|
||||
* @param bool $status
|
||||
* @return void
|
||||
*/
|
||||
|
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