Skip to content

Commit

Permalink
Merge pull request #329 from web3p/feature/integrate-async-react-php
Browse files Browse the repository at this point in the history
feature: integrate async react php
  • Loading branch information
sc0Vu authored Sep 1, 2023
2 parents cede0cc + 116659e commit 31101fe
Show file tree
Hide file tree
Showing 29 changed files with 564 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Build and test web3.php with ${{ matrix.php-version }}
strategy:
matrix:
php-version: ["7.3", "7.4", "8.0"]
php-version: ["7.3", "7.4", "8.0", "8.1", "8.2"]

runs-on: ubuntu-latest

Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
"PHP": "^7.2|^8.0",
"kornrunner/keccak": "~1.0",
"phpseclib/phpseclib": "~2.0.30",
"ext-mbstring": "*"
"ext-mbstring": "*",
"react/http": "^1.6.0",
"react/async": "^4.0.0|^3.1.0",
"react/promise": "^2.9.0",
"react/event-loop": "^1.2",
"react/socket": "^1.13"
},
"require-dev": {
"phpunit/phpunit": "~8.0|~9.0"
Expand Down
2 changes: 1 addition & 1 deletion docker/ganache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:9.11.1-alpine
FROM node:12.11.1-alpine

MAINTAINER Peter Lai <[email protected]>

Expand Down
4 changes: 2 additions & 2 deletions docker/php/Dockerfile-71 → docker/php/Dockerfile-81
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-alpine
FROM php:8.1-alpine

MAINTAINER Peter Lai <[email protected]>

Expand All @@ -20,4 +20,4 @@ RUN php composer-setup.php && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');"

WORKDIR /app
WORKDIR /app
23 changes: 23 additions & 0 deletions docker/php/Dockerfile-82
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.2-alpine

MAINTAINER Peter Lai <[email protected]>

COPY composer-setup.php composer-setup.php
# COPY php.ini-production $PHP_INI_DIR/php.ini

RUN apk update && \
apk add git

# Install gmp
Run apk add gmp-dev && \
docker-php-ext-install gmp

# Install nodejs
# Run apk add --update nodejs nodejs-npm

# Install composer
RUN php composer-setup.php && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');"

WORKDIR /app
16 changes: 8 additions & 8 deletions src/Contract.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public function abi($abi)
* Deploy a contruct with params.
*
* @param mixed
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function new()
{
Expand Down Expand Up @@ -469,7 +469,7 @@ public function new()
}
$transaction['data'] = '0x' . $this->bytecode . Utils::stripZero($data);

$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
return $this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
if ($err !== null) {
return call_user_func($callback, $err, null);
}
Expand All @@ -483,7 +483,7 @@ public function new()
* Send function method.
*
* @param mixed
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function send()
{
Expand Down Expand Up @@ -564,7 +564,7 @@ public function send()
$transaction['to'] = $this->toAddress;
$transaction['data'] = $functionSignature . Utils::stripZero($data);

$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
return $this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
if ($err !== null) {
return call_user_func($callback, $err, null);
}
Expand All @@ -578,7 +578,7 @@ public function send()
* Call function method.
*
* @param mixed
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function call()
{
Expand Down Expand Up @@ -658,7 +658,7 @@ public function call()
$transaction['to'] = $this->toAddress;
$transaction['data'] = $functionSignature . Utils::stripZero($data);

$this->eth->call($transaction, $defaultBlock, function ($err, $transaction) use ($callback, $function){
return $this->eth->call($transaction, $defaultBlock, function ($err, $transaction) use ($callback, $function){
if ($err !== null) {
return call_user_func($callback, $err, null);
}
Expand All @@ -674,7 +674,7 @@ public function call()
* Estimate function gas.
*
* @param mixed
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function estimateGas()
{
Expand Down Expand Up @@ -778,7 +778,7 @@ public function estimateGas()
$transaction['data'] = $functionSignature . Utils::stripZero($data);
}

$this->eth->estimateGas($transaction, function ($err, $gas) use ($callback) {
return $this->eth->estimateGas($transaction, function ($err, $gas) use ($callback) {
if ($err !== null) {
return call_user_func($callback, $err, null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Eth.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct($provider)
*
* @param string $name
* @param array $arguments
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function __call($name, $arguments)
{
Expand Down Expand Up @@ -102,7 +102,7 @@ public function __call($name, $arguments)
if ($methodObject->validate($arguments)) {
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
$methodObject->arguments = $inputs;
$this->provider->send($methodObject, $callback);
return $this->provider->send($methodObject, $callback);
}
}
}
Expand Down
64 changes: 0 additions & 64 deletions src/Methods/Eth/CompileLLL.php

This file was deleted.

64 changes: 0 additions & 64 deletions src/Methods/Eth/CompileSerpent.php

This file was deleted.

64 changes: 0 additions & 64 deletions src/Methods/Eth/CompileSolidity.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Net.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct($provider)
*
* @param string $name
* @param array $arguments
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function __call($name, $arguments)
{
Expand Down Expand Up @@ -102,7 +102,7 @@ public function __call($name, $arguments)
if ($methodObject->validate($arguments)) {
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
$methodObject->arguments = $inputs;
$this->provider->send($methodObject, $callback);
return $this->provider->send($methodObject, $callback);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct($provider)
*
* @param string $name
* @param array $arguments
* @return void
* @return void|\React\Promise\PromiseInterface
*/
public function __call($name, $arguments)
{
Expand Down Expand Up @@ -102,7 +102,7 @@ public function __call($name, $arguments)
if ($methodObject->validate($arguments)) {
$inputs = $methodObject->transform($arguments, $methodObject->inputFormatters);
$methodObject->arguments = $inputs;
$this->provider->send($methodObject, $callback);
return $this->provider->send($methodObject, $callback);
}
}
}
Expand Down
Loading

0 comments on commit 31101fe

Please sign in to comment.