Compare commits

...

34 Commits

Author SHA1 Message Date
Peter Lai
cede0cc410
Merge pull request #264 from srdante/patch-1
Fix Test Caching
2022-03-06 20:41:49 -08:00
Dante
1d2581e78e
Update php.yml 2022-03-07 00:34:50 -03:00
Peter Lai
2eafffbbe5
Merge pull request #257 from cryptounifier/php-80-test-passing
Support PHP 8.0
2022-03-06 19:26:51 -08:00
Dante
cc7d01e7eb
Add Dockerfile-80 2022-02-26 03:44:06 -03:00
srdante
1d47285b8b Fix preg match & testings 2022-02-26 03:15:44 -03:00
srdante
7c46919e7d Bump composer dependencies 2022-02-26 02:48:12 -03:00
srdante
91f4d2c40b Set setUp() return type 2022-02-26 02:43:32 -03:00
Dante
2ae840f538
Update TestCase.php 2022-02-26 02:40:01 -03:00
Dante
217851c62d
Update php.yml 2022-02-26 02:33:59 -03:00
Dante
7eb8a46366
Update php.yml 2022-02-26 02:28:17 -03:00
Dante
dabb7262b5
Update composer.json 2022-02-26 02:27:56 -03:00
sc0Vu
bd40f1946a
Update package to web3p/web3.php 2022-01-15 00:26:41 +08:00
Peter Lai
fb94ea92c5
Merge pull request #205 from harensarma/patch-2
Removed space from versions of guzzlehttp
2021-08-14 20:28:10 -07:00
harensarma
199cb1d175
Removed space from versions of guzzlehttp
Removed space from versions of guzzlehttp, else second version was not working in laravel
2021-04-18 21:07:09 +05:30
Peter Lai
1b093c8ad4
Merge pull request #198 from web3p/github-ci
Add github ci
2021-02-25 15:24:56 +08:00
sc0Vu
a96e8865a8 Update README.md 2021-02-25 15:23:05 +08:00
Peter Lai
d1582e3a7c Add github ci 2021-02-25 15:22:49 +08:00
sc0vu
9ed1b0d2dd
Add contribution in README.md 2021-02-22 13:14:08 +08:00
Peter Lai
17472b55fd
Merge pull request #191 from serderovsh/patch-1
Update composer.json
2020-11-14 17:15:11 +00:00
Peter Lai
8ba41a37b7
Merge branch 'master' into patch-1 2020-11-14 17:14:48 +00:00
Peter Lai
c0c57219d7
Merge pull request #195 from web3p/minor-update
Minor update
2020-11-14 17:12:21 +00:00
sc0vu
d4f747606f
Update codecov/README.md 2020-11-14 23:33:04 +08:00
sc0vu
292b579337
Test for php ~7.4 2020-11-14 22:31:10 +08:00
sc0vu
dc66eb1064
Update guzzlehttp to 7 2020-11-14 22:28:58 +08:00
Shamsudin
4e0548a3ea
Update composer.json 2020-10-13 07:45:01 +03:00
Peter Lai
d69ce96a64
Merge pull request #158 from sc0Vu/fix-150
Add toChecksumAddress in Utils.php
2019-10-03 22:41:19 +08:00
sc0vu
d0289506dc
Add toChecksumAddress in Utils.php
See #150 (https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md)
2019-10-03 00:01:35 +08:00
Peter Lai
0659ec04dc
Merge pull request #157 from sc0Vu/add-defaultblock
Add defaultblock in Contract.call
2019-10-02 10:42:08 +08:00
sc0vu
0e303787ba
Add defaultblock in contract call 2019-10-02 10:26:41 +08:00
Peter Lai
fff321de37
Merge pull request #156 from sc0Vu/add-dockerfile
Add dockerfile
2019-09-08 23:41:37 +08:00
sc0vu
5e284d0037
Update .travis.yml 2019-09-08 23:12:58 +08:00
sc0vu
3943f00b38
Update php dockerfiles
Change:
* Add Dockerfile-73
* Install gmp library automatically
2019-09-08 23:11:27 +08:00
Peter Lai
8a34582d23
Merge pull request #154 from tomcyr/master
Fix call Eth NewBlockFilter
2019-07-30 11:48:05 +08:00
Tomasz Cyrankowski
d67367a2f2 Eth NewBlockFilter method hasn't any arguments so it shouldn't have any validators 2019-07-25 10:52:57 +02:00
65 changed files with 367 additions and 137 deletions

49
.github/workflows/php.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: PHP
on: ["push", "pull_request", "workflow_dispatch"]
jobs:
build_and_test:
name: Build and test web3.php with ${{ matrix.php-version }}
strategy:
matrix:
php-version: ["7.3", "7.4", "8.0"]
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: PHP version
run: |
php --version
- name: Install nodejs and ganache-cli
run: |
sudo apt-get update -y
sudo apt-get install -y nodejs
sudo npm install -g ganache-cli
- uses: actions/checkout@v2
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite
run: sudo scripts/test.sh

View File

@ -5,6 +5,8 @@ language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
before_install:
- nvm install 8
@ -24,4 +26,4 @@ script:
- scripts/test.sh
after_success:
- bash <(curl -s https://codecov.io/bash) -t 8436848f-9a99-4b49-be60-629d7ff9a62c
- bash <(curl -s https://codecov.io/bash) -t 76a0abaf-bbc4-4829-b5b8-474f10a6b9e9

View File

@ -1,9 +1,10 @@
# web3.php
[![Build Status](https://travis-ci.org/sc0Vu/web3.php.svg?branch=master)](https://travis-ci.org/sc0Vu/web3.php)
[![codecov](https://codecov.io/gh/sc0Vu/web3.php/branch/master/graph/badge.svg)](https://codecov.io/gh/sc0Vu/web3.php)
[![PHP](https://github.com/web3p/web3.php/actions/workflows/php.yml/badge.svg)](https://github.com/web3p/web3.php/actions/workflows/php.yml)
[![Build Status](https://travis-ci.org/web3p/web3.php.svg?branch=master)](https://travis-ci.org/web3p/web3.php)
[![codecov](https://codecov.io/gh/web3p/web3.php/branch/master/graph/badge.svg)](https://codecov.io/gh/web3p/web3.php)
[![Join the chat at https://gitter.im/web3-php/web3.php](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/web3-php/web3.php)
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sc0Vu/web3.php/blob/master/LICENSE)
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/web3p/web3.php/blob/master/LICENSE)
A php interface for interacting with the Ethereum blockchain and ecosystem.
@ -17,13 +18,13 @@ Set minimum stability to dev
Then
```
composer require sc0vu/web3.php dev-master
composer require web3p/web3.php dev-master
```
Or you can add this line in composer.json
```
"sc0vu/web3.php": "dev-master"
"web3p/web3.php": "dev-master"
```
@ -216,7 +217,7 @@ If you are using docker as development machain, you can try [ethdock](https://gi
1. Clone the repo and install packages.
```
git clone https://github.com/sc0Vu/web3.php.git && cd web3.php && composer install
git clone https://github.com/web3p/web3.php.git && cd web3.php && composer install
```
2. Run test script.
@ -228,7 +229,7 @@ vendor/bin/phpunit
1. Clone the repo and run docker container.
```
git clone https://github.com/sc0Vu/web3.php.git
git clone https://github.com/web3p/web3.php.git
```
2. Copy web3.php to web3.php/docker/app directory and start container.
@ -283,5 +284,12 @@ mv /usr/local/etc/php/conf.d/extension-config-name to/directory
Todo.
# Contribution
Thank you to all the people who already contributed to web3.php!
<a href="https://github.com/web3p/web3.php/graphs/contributors">
<img src="https://contrib.rocks/image?repo=web3p/web3.php" />
</a>
# License
MIT

View File

@ -1,5 +1,5 @@
{
"name": "sc0vu/web3.php",
"name": "web3p/web3.php",
"description": "Ethereum web3 interface.",
"type": "library",
"license": "MIT",
@ -10,14 +10,14 @@
}
],
"require": {
"guzzlehttp/guzzle": "~6.0",
"PHP": "^7.1",
"guzzlehttp/guzzle": "^6.3|^7.0",
"PHP": "^7.2|^8.0",
"kornrunner/keccak": "~1.0",
"phpseclib/phpseclib": "~2.0.11",
"phpseclib/phpseclib": "~2.0.30",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "~6.0"
"phpunit/phpunit": "~8.0|~9.0"
},
"autoload": {
"psr-4": {

View File

@ -1,4 +1,4 @@
FROM php:7.1.14-alpine
FROM php:7.1-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
@ -8,6 +8,10 @@ COPY composer-setup.php composer-setup.php
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

View File

@ -1,4 +1,4 @@
FROM php:7.2.2-alpine
FROM php:7.2-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
@ -8,6 +8,10 @@ COPY composer-setup.php composer-setup.php
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

23
docker/php/Dockerfile-73 Normal file
View File

@ -0,0 +1,23 @@
FROM php:7.3-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
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

23
docker/php/Dockerfile-74 Normal file
View File

@ -0,0 +1,23 @@
FROM php:7.4-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
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

23
docker/php/Dockerfile-80 Normal file
View File

@ -0,0 +1,23 @@
FROM php:8.0-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
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

View File

@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuite name="Web3.php unit test">
<directory suffix="Test.php">./test/unit</directory>

View File

@ -28,8 +28,10 @@ use Web3\Contracts\Types\Str;
use Web3\Contracts\Types\Uinteger;
use Web3\Validators\AddressValidator;
use Web3\Validators\HexValidator;
use Web3\Formatters\AddressFormatter;
use Web3\Validators\StringValidator;
use Web3\Validators\TagValidator;
use Web3\Validators\QuantityValidator;
use Web3\Formatters\AddressFormatter;
class Contract
{
@ -96,14 +98,22 @@ class Contract
*/
protected $ethabi;
/**
* defaultBlock
*
* @var mixed
*/
protected $defaultBlock;
/**
* construct
*
* @param string|\Web3\Providers\Provider $provider
* @param string|\stdClass|array $abi
* @param mixed $defaultBlock
* @return void
*/
public function __construct($provider, $abi)
public function __construct($provider, $abi, $defaultBlock = 'latest')
{
if (is_string($provider) && (filter_var($provider, FILTER_VALIDATE_URL) !== false)) {
// check the uri schema
@ -137,6 +147,11 @@ class Contract
}
}
}
if (TagValidator::validate($defaultBlock) || QuantityValidator::validate($defaultBlock)) {
$this->defaultBlock = $defaultBlock;
} else {
$this->$defaultBlock = 'latest';
}
$this->abi = $abiArray;
$this->eth = new Eth($this->provider);
$this->ethabi = new Ethabi([
@ -224,6 +239,32 @@ class Contract
return $this;
}
/**
* getDefaultBlock
*
* @return string
*/
public function getDefaultBlock()
{
return $this->defaultBlock;
}
/**
* setDefaultBlock
*
* @param mixed $defaultBlock
* @return $this
*/
public function setDefaultBlock($defaultBlock)
{
if (TagValidator::validate($defaultBlock) || QuantityValidator::validate($defaultBlock)) {
$this->defaultBlock = $defaultBlock;
} else {
$this->$defaultBlock = 'latest';
}
return $this;
}
/**
* getFunctions
*
@ -563,47 +604,17 @@ class Contract
throw new \InvalidArgumentException('The last param must be callback function.');
}
// check the last one in arguments is transaction object
// check the arguments
$argsLen = count($arguments);
$transaction = [];
$hasTransaction = false;
if ($argsLen > 0) {
$transaction = $arguments[$argsLen - 1];
}
if (
isset($transaction["from"]) ||
isset($transaction["to"]) ||
isset($transaction["gas"]) ||
isset($transaction["gasPrice"]) ||
isset($transaction["value"]) ||
isset($transaction["data"]) ||
isset($transaction["nonce"])
) {
$hasTransaction = true;
} else {
$transaction = [];
}
$defaultBlock = $this->defaultBlock;
$params = [];
$data = "";
$functionName = "";
foreach ($functions as $function) {
if ($hasTransaction) {
if ($argsLen - 1 !== count($function['inputs'])) {
continue;
} else {
$paramsLen = $argsLen - 1;
}
} else {
if ($argsLen !== count($function['inputs'])) {
continue;
} else {
$paramsLen = $argsLen;
}
}
try {
$params = array_splice($arguments, 0, $paramsLen);
$paramsLen = count($function['inputs']);
$params = array_slice($arguments, 0, $paramsLen);
$data = $this->ethabi->encodeParameters($function, $params);
$functionName = Utils::jsonMethodToString($function);
} catch (InvalidArgumentException $e) {
@ -614,11 +625,40 @@ class Contract
if (empty($data) || empty($functionName)) {
throw new InvalidArgumentException('Please make sure you have put all function params and callback.');
}
// remove arguments
array_splice($arguments, 0, $paramsLen);
$argsLen -= $paramsLen;
if ($argsLen > 1) {
$defaultBlock = $arguments[$argsLen - 1];
$transaction = $arguments[$argsLen - 2];
} else if ($argsLen > 0) {
if (is_array($arguments[$argsLen - 1])) {
$transaction = $arguments[$argsLen - 1];
} else {
$defaultBlock = $arguments[$argsLen - 1];
}
}
if (!TagValidator::validate($defaultBlock) && !QuantityValidator::validate($defaultBlock)) {
$defaultBlock = $this->defaultBlock;
}
if (
!is_array($transaction) &&
!isset($transaction["from"]) &&
!isset($transaction["to"]) &&
!isset($transaction["gas"]) &&
!isset($transaction["gasPrice"]) &&
!isset($transaction["value"]) &&
!isset($transaction["data"]) &&
!isset($transaction["nonce"])
) {
$transaction = [];
}
$functionSignature = $this->ethabi->encodeFunctionSignature($functionName);
$transaction['to'] = $this->toAddress;
$transaction['data'] = $functionSignature . Utils::stripZero($data);
$this->eth->call($transaction, function ($err, $transaction) use ($callback, $function){
$this->eth->call($transaction, $defaultBlock, function ($err, $transaction) use ($callback, $function){
if ($err !== null) {
return call_user_func($callback, $err, null);
}
@ -738,7 +778,7 @@ class Contract
$transaction['data'] = $functionSignature . Utils::stripZero($data);
}
$this->eth->estimateGas($transaction, function ($err, $gas) use ($callback){
$this->eth->estimateGas($transaction, function ($err, $gas) use ($callback) {
if ($err !== null) {
return call_user_func($callback, $err, null);
}

View File

@ -23,18 +23,14 @@ class NewBlockFilter extends EthMethod
*
* @var array
*/
protected $validators = [
QuantityValidator::class
];
protected $validators = [];
/**
* inputFormatters
*
* @var array
*/
protected $inputFormatters = [
QuantityFormatter::class
];
protected $inputFormatters = [];
/**
* outputFormatters

View File

@ -212,6 +212,31 @@ class Utils
return true;
}
/**
* toChecksumAddress
*
* @param string $value
* @return string
*/
public static function toChecksumAddress($value)
{
if (!is_string($value)) {
throw new InvalidArgumentException('The value to toChecksumAddress function must be string.');
}
$value = self::stripZero(strtolower($value));
$hash = self::stripZero(self::sha3($value));
$ret = '0x';
for ($i = 0; $i < 40; $i++) {
if (intval($hash[$i], 16) >= 8) {
$ret .= strtoupper($value[$i]);
} else {
$ret .= $value[$i];
}
}
return $ret;
}
/**
* isHex
*
@ -504,7 +529,7 @@ class Utils
$number = str_replace('-', '', $number, $count);
$negative1 = new BigNumber(-1);
}
if (self::isZeroPrefixed($number) || preg_match('/[a-f]+/', $number) === 1) {
if (self::isZeroPrefixed($number) || preg_match('/^[0-9a-f]+$/i', $number) === 1) {
$number = self::stripZero($number);
$bn = new BigNumber($number, 16);
} elseif (empty($number)) {

View File

@ -37,10 +37,8 @@ class TestCase extends BaseTestCase
/**
* setUp
*
* @return void
*/
public function setUp()
public function setUp(): void
{
$web3 = new Web3($this->testHost);
$this->web3 = $web3;
@ -55,8 +53,6 @@ class TestCase extends BaseTestCase
/**
* tearDown
*
* @return void
*/
public function tearDown() {}
public function tearDown(): void {}
}

View File

@ -19,7 +19,7 @@ class AddressFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new AddressFormatter;

View File

@ -47,7 +47,7 @@ class AddressTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Address;

View File

@ -19,7 +19,7 @@ class AddressValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new AddressValidator;

View File

@ -20,7 +20,7 @@ class BigNumberFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new BigNumberFormatter;

View File

@ -19,7 +19,7 @@ class BlockHashValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new BlockHashValidator;

View File

@ -20,7 +20,7 @@ class BooleanFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new BooleanFormatter;

View File

@ -47,7 +47,7 @@ class BooleanTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Boolean;

View File

@ -19,7 +19,7 @@ class BooleanValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new BooleanValidator;

View File

@ -53,7 +53,7 @@ class BytesTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Bytes;

View File

@ -19,7 +19,7 @@ class CallValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new CallValidator;

View File

@ -412,7 +412,7 @@ class ContractTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
@ -1134,7 +1134,7 @@ class ContractTest extends TestCase
$contract->at($contractAddress);
foreach ($functions as $function) {
$contract->call($function['name'], function ($err, $res) use ($function) {
$contract->call($function['name'], [], 'latest', function ($err, $res) use ($function) {
if ($err !== null) {
echo 'Error when call ' . $function['name'] . '. Message: ' . $err->getMessage() . "\n";
return;
@ -1468,13 +1468,22 @@ class ContractTest extends TestCase
// $this->assertEquals($contract->ethabi->encodeEventSignature($contract->events['Say']), $topics[0]);
$this->assertEquals('0x' . IntegerFormatter::format($testNumber), $topics[1]);
}
$contract->call('number', function ($err, $res) use ($testNumber) {
$blockNumber = Utils::toBn($transaction->blockNumber);
$contract->call('number', Utils::toHex($blockNumber, true), function ($err, $res) use ($testNumber) {
if ($err !== null) {
echo 'Error when call ' . $function['name'] . '. Message: ' . $err->getMessage() . "\n";
return;
}
$this->assertEquals((string) $testNumber, $res[0]->toString());
});
$blockNumber = $blockNumber->subtract(Utils::toBn(1));
$contract->call('number', Utils::toHex($blockNumber, true), function ($err, $res) use ($testNumber) {
if ($err !== null) {
echo 'Error when call ' . $function['name'] . '. Message: ' . $err->getMessage() . "\n";
return;
}
$this->assertEquals((string) $testNumber-1, $res[0]->toString());
});
});
});

View File

@ -53,7 +53,7 @@ class DynamicBytesTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new DynamicBytes;

View File

@ -21,7 +21,7 @@ class EthApiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
@ -439,7 +439,7 @@ class EthApiTest extends TestCase
if ($err !== null) {
return $this->assertTrue($err !== null);
}
// weired behavior, see https://github.com/sc0Vu/web3.php/issues/16
// weird behavior, see https://github.com/web3p/web3.php/issues/16
$this->assertTrue($block !== null);
});
}
@ -629,7 +629,7 @@ class EthApiTest extends TestCase
{
$eth = $this->eth;
$eth->newBlockFilter('0x01', function ($err, $filter) {
$eth->newBlockFilter(function ($err, $filter) {
if ($err !== null) {
// infura banned us to new block filter
return $this->assertTrue($err !== null);

View File

@ -20,7 +20,7 @@ class EthBatchTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -23,7 +23,7 @@ class EthTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -163,7 +163,7 @@ class EthabiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
// Error: Using $this when not in object context
@ -298,7 +298,7 @@ class EthabiTest extends TestCase
/**
* testIssue71
* test 33 bytes and 128 bytes string, see: https://github.com/sc0Vu/web3.php/issues/71
* test 33 bytes and 128 bytes string, see: https://github.com/web3p/web3.php/issues/71
* string generated from: https://www.lipsum.com/
*
* @return void

View File

@ -19,7 +19,7 @@ class FilterValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new FilterValidator;

View File

@ -19,7 +19,7 @@ class HexFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new HexFormatter;

View File

@ -19,7 +19,7 @@ class HexValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new HexValidator;

View File

@ -19,7 +19,7 @@ class IdentityValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new IdentityValidator;

View File

@ -19,7 +19,7 @@ class IntegerFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new IntegerFormatter;

View File

@ -53,7 +53,7 @@ class IntegerTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Integer;

View File

@ -21,7 +21,7 @@ class NetApiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -20,7 +20,7 @@ class NetBatchTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -23,7 +23,7 @@ class NetTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ class NonceValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new NonceValidator;

View File

@ -19,7 +19,7 @@ class NumberFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new NumberFormatter;

View File

@ -19,7 +19,7 @@ class OptionalQuantityFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new OptionalQuantityFormatter;
@ -55,6 +55,8 @@ class OptionalQuantityFormatterTest extends TestCase
$this->assertEquals('latest', $formatter->format('latest'));
$this->assertEquals('earliest', $formatter->format('earliest'));
$this->assertEquals('pending', $formatter->format('pending'));
$this->assertEquals('0x0', $formatter->format('hello'));
$this->expectExceptionMessage('toBn number must be valid hex string.');
$formatter->format('hello');
}
}

View File

@ -27,7 +27,7 @@ class PersonalApiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ class PersonalBatchTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -23,7 +23,7 @@ class PersonalTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ class PostFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new PostFormatter;

View File

@ -19,7 +19,7 @@ class PostValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new PostValidator;

View File

@ -19,7 +19,7 @@ class QuantityFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new QuantityFormatter;

View File

@ -19,7 +19,7 @@ class QuantityValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new QuantityValidator;

View File

@ -21,7 +21,7 @@ class ShhApiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ class ShhBatchTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -19,7 +19,7 @@ class ShhFilterValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new ShhFilterValidator;

View File

@ -23,7 +23,7 @@ class ShhTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -20,7 +20,7 @@ class SolidityTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->type = new SolidityType();

View File

@ -47,7 +47,7 @@ class StrTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Str;

View File

@ -19,7 +19,7 @@ class StringFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new StringFormatter;

View File

@ -19,7 +19,7 @@ class StringValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new StringValidator;

View File

@ -19,7 +19,7 @@ class TagValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new TagValidator;

View File

@ -19,7 +19,7 @@ class TransactionFormatterTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->formatter = new TransactionFormatter;

View File

@ -19,7 +19,7 @@ class TransactionValidatorTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->validator = new TransactionValidator;

View File

@ -53,7 +53,7 @@ class UintegerTypeTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->solidityType = new Uinteger;

View File

@ -55,7 +55,7 @@ class UtilsTest extends TestCase
/**
* testIssue112Json
* see: https://github.com/sc0Vu/web3.php/issues/112
* see: https://github.com/web3p/web3.php/issues/112
*
* @var string
*/
@ -137,7 +137,7 @@ class UtilsTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
}
@ -291,6 +291,33 @@ class UtilsTest extends TestCase
$isAddressChecksum = Utils::isAddressChecksum(new stdClass);
}
/**
* testToChecksumAddress
*
* @return void
*/
public function testToChecksumAddress()
{
$checksumAddressTest = [
// All caps
'0x52908400098527886E0F7030069857D2E4169EE7',
'0x8617E340B3D01FA5F11F306F4090FD50E238070D',
// All Lower
'0xde709f2102306220921060314715629080e2fb77',
'0x27b1fdb04752bbc536007a920d24acb045561c26',
// Normal
'0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed',
'0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359',
'0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB',
'0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb'
];
for ($i=0; $i<count($checksumAddressTest); $i++) {
$checksumAddress = Utils::toChecksumAddress(strtolower($checksumAddressTest[$i]));
$this->assertEquals($checksumAddressTest[$i], $checksumAddress);
}
}
/**
* testStripZero
*

View File

@ -29,7 +29,7 @@ class Web3ApiTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
}

View File

@ -28,7 +28,7 @@ class Web3BatchTest extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
}

View File

@ -37,7 +37,7 @@ class Web3Test extends TestCase
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();
}