From ff2c90c196b4ba91d9574c7a644f962b2fe35059 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 13 Dec 2017 23:22:58 +0800 Subject: [PATCH] eth_sign --- src/Eth.php | 10 ++++++++++ test/unit/EthTest.php | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/Eth.php b/src/Eth.php index 621787e..29bcfad 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -10,6 +10,7 @@ use Web3\Validators\AddressValidator; use Web3\Validators\TagValidator; use Web3\Validators\QuantityValidator; use Web3\Validators\BlockHashValidator; +use Web3\Validators\HexValidator; class Eth { @@ -118,6 +119,15 @@ class Eth ], ] ], + 'eth_sign' => [ + 'params'=> [ + [ + 'validators' => AddressValidator::class, + ], [ + 'validators' => HexValidator::class + ], + ] + ], ]; /** diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index a100ef7..04d69b0 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -383,6 +383,28 @@ class EthTest extends TestCase }); } + /** + * testSign + * + * @return void + */ + public function testSign() + { + $eth = $this->web3->eth; + + $eth->sign('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0xdeadbeaf', function ($err, $sign) { + if ($err !== null) { + // infura banned us to sign message + return $this->assertTrue($err->getCode() === 405); + } + if (isset($sign->result)) { + $this->assertTrue(is_string($sign->result)); + } else { + $this->fail($sign->error->message); + } + }); + } + /** * testUnallowedMethod *