Personal apis.
This commit is contained in:
parent
34647e7fdf
commit
cf5288774c
@ -16,6 +16,13 @@ use Web3\Methods\EthMethod;
|
||||
|
||||
class ListAccounts extends EthMethod
|
||||
{
|
||||
/**
|
||||
* validators
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validators = [];
|
||||
|
||||
/**
|
||||
* inputFormatters
|
||||
*
|
||||
|
@ -13,10 +13,20 @@ 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
|
||||
*
|
||||
|
@ -13,11 +13,22 @@ 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
|
||||
*
|
||||
|
@ -13,12 +13,24 @@ 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
|
||||
*
|
||||
|
@ -103,12 +103,13 @@ class Personal
|
||||
} else {
|
||||
$methodObject = $this->methods[$method];
|
||||
}
|
||||
if ($methodObject->validate($arguments)) {
|
||||
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||
$methodObject->arguments = $inputs;
|
||||
|
||||
$this->provider->send($methodObject, $callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get
|
||||
|
@ -47,4 +47,28 @@ class PersonalBatchTest extends TestCase
|
||||
$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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user