Personal apis.
This commit is contained in:
parent
34647e7fdf
commit
cf5288774c
@ -16,6 +16,13 @@ use Web3\Methods\EthMethod;
|
|||||||
|
|
||||||
class ListAccounts extends EthMethod
|
class ListAccounts extends EthMethod
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inputFormatters
|
* inputFormatters
|
||||||
*
|
*
|
||||||
|
@ -13,10 +13,20 @@ namespace Web3\Methods\Personal;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Web3\Methods\EthMethod;
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
use Web3\Formatters\StringFormatter;
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
class NewAccount extends EthMethod
|
class NewAccount extends EthMethod
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inputFormatters
|
* inputFormatters
|
||||||
*
|
*
|
||||||
|
@ -13,11 +13,22 @@ namespace Web3\Methods\Personal;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Web3\Methods\EthMethod;
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\TransactionValidator;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
use Web3\Formatters\TransactionFormatter;
|
use Web3\Formatters\TransactionFormatter;
|
||||||
use Web3\Formatters\StringFormatter;
|
use Web3\Formatters\StringFormatter;
|
||||||
|
|
||||||
class SendTransaction extends EthMethod
|
class SendTransaction extends EthMethod
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
TransactionValidator::class, StringValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inputFormatters
|
* inputFormatters
|
||||||
*
|
*
|
||||||
|
@ -13,12 +13,24 @@ namespace Web3\Methods\Personal;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Web3\Methods\EthMethod;
|
use Web3\Methods\EthMethod;
|
||||||
|
use Web3\Validators\AddressValidator;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
use Web3\Validators\QuantityValidator;
|
||||||
use Web3\Formatters\AddressFormatter;
|
use Web3\Formatters\AddressFormatter;
|
||||||
use Web3\Formatters\StringFormatter;
|
use Web3\Formatters\StringFormatter;
|
||||||
use Web3\Formatters\QuantityFormatter;
|
use Web3\Formatters\QuantityFormatter;
|
||||||
|
|
||||||
class UnlockAccount extends EthMethod
|
class UnlockAccount extends EthMethod
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* validators
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $validators = [
|
||||||
|
AddressValidator::class, StringValidator::class, QuantityValidator::class
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inputFormatters
|
* inputFormatters
|
||||||
*
|
*
|
||||||
|
@ -103,10 +103,11 @@ class Personal
|
|||||||
} else {
|
} else {
|
||||||
$methodObject = $this->methods[$method];
|
$methodObject = $this->methods[$method];
|
||||||
}
|
}
|
||||||
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
if ($methodObject->validate($arguments)) {
|
||||||
$methodObject->arguments = $inputs;
|
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
|
||||||
|
$methodObject->arguments = $inputs;
|
||||||
$this->provider->send($methodObject, $callback);
|
$this->provider->send($methodObject, $callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,4 +47,28 @@ class PersonalBatchTest extends TestCase
|
|||||||
$this->assertTrue(is_string($data[1]));
|
$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