From 60e52909ff64902bd83e41cdf1fe078b1d934d3f Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Thu, 14 Dec 2017 19:22:08 +0800 Subject: [PATCH] eth_compileSolidity --- src/Eth.php | 10 +++++++++- test/unit/EthTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Eth.php b/src/Eth.php index b1d2287..357a918 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -13,6 +13,7 @@ use Web3\Validators\BlockHashValidator; use Web3\Validators\HexValidator; use Web3\Validators\TransactionValidator; use Web3\Validators\BooleanValidator; +use Web3\Validators\StringValidator; class Eth { @@ -237,7 +238,14 @@ class Eth ] ] ], - 'eth_getCompilers' => [] + 'eth_getCompilers' => [], + 'eth_compileSolidity' => [ + 'params' => [ + [ + 'validators' => StringValidator::class + ] + ] + ] ]; /** diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index 8646078..73caab4 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -759,6 +759,31 @@ class EthTest extends TestCase }); } + /** + * testCompileSolidity + * + * @return void + */ + public function testCompileSolidity() + { + $eth = $this->eth; + + $eth->compileSolidity('contract test { function multiply(uint a) returns(uint d) { return a * 7; } }', function ($err, $compiled) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($compiled->result)) { + $this->assertTrue(is_string($compiled->result)); + } else { + // if (isset($compilers->error)) { + $this->assertTrue(true); + // } else { + // $this->assertTrue(true); + // } + } + }); + } + /** * testUnallowedMethod *