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