Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"guzzlehttp/guzzle": "^6.3|^7.0",
"PHP": "^7.2|^8.0",
"kornrunner/keccak": "~1.0",
"phpseclib/phpseclib": "~2.0.30",
"phpseclib/phpseclib": "^3.0.36",
"ext-mbstring": "*",
"react/http": "^1.6.0",
"react/async": "^4.0.0|^3.1.0",
Expand Down
52 changes: 26 additions & 26 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/**
* This file is part of web3.php package.
*
*
* (c) Kuan-Cheng,Lai <[email protected]>
*
*
* @author Peter Lai <[email protected]>
* @license MIT
*/
Expand All @@ -15,21 +15,21 @@
use InvalidArgumentException;
use stdClass;
use kornrunner\Keccak;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class Utils
{
/**
* SHA3_NULL_HASH
*
*
* @const string
*/
const SHA3_NULL_HASH = 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';

/**
* UNITS
* from ethjs-unit
*
*
* @const array
*/
const UNITS = [
Expand Down Expand Up @@ -65,7 +65,7 @@ class Utils
/**
* NEGATIVE1
* Cannot work, see: http://php.net/manual/en/language.constants.syntax.php
*
*
* @const
*/
// const NEGATIVE1 = new BigNumber(-1);
Expand All @@ -80,7 +80,7 @@ class Utils
/**
* toHex
* Encoding string or integer or numeric string(is not zero prefixed) or big number to hex.
*
*
* @param string|int|BigNumber $value
* @param bool $isPrefix
* @return string
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function toHex($value, $isPrefix=false)

/**
* hexToBin
*
*
* @param string
* @return string
*/
Expand All @@ -130,7 +130,7 @@ public static function hexToBin($value)

/**
* isZeroPrefixed
*
*
* @param string
* @return bool
*/
Expand All @@ -144,7 +144,7 @@ public static function isZeroPrefixed($value)

/**
* stripZero
*
*
* @param string $value
* @return string
*/
Expand All @@ -159,7 +159,7 @@ public static function stripZero($value)

/**
* isNegative
*
*
* @param string
* @return bool
*/
Expand All @@ -173,7 +173,7 @@ public static function isNegative($value)

/**
* isAddress
*
*
* @param string $value
* @return bool true if the address is lowercase or in checksum format otherwise false
*/
Expand Down Expand Up @@ -243,7 +243,7 @@ public static function toChecksumAddress($value)

/**
* isHex
*
*
* @param string $value
* @return bool
*/
Expand All @@ -255,7 +255,7 @@ public static function isHex($value)
/**
* sha3
* keccak256
*
*
* @param string $value
* @return string
*/
Expand All @@ -277,7 +277,7 @@ public static function sha3($value)

/**
* toString
*
*
* @param mixed $value
* @return string
*/
Expand All @@ -292,9 +292,9 @@ public static function toString($value)
* toWei
* Change number from unit to wei.
* For example:
* $wei = Utils::toWei('1', 'kwei');
* $wei = Utils::toWei('1', 'kwei');
* $wei->toString(); // 1000
*
*
* @param BigNumber|string $number
* @param string $unit
* @return \phpseclib\Math\BigInteger
Expand Down Expand Up @@ -358,9 +358,9 @@ public static function toWei($number, $unit)
* toEther
* Change number from unit to ether.
* For example:
* list($bnq, $bnr) = Utils::toEther('1', 'kether');
* list($bnq, $bnr) = Utils::toEther('1', 'kether');
* $bnq->toString(); // 1000
*
*
* @param BigNumber|string|int $number
* @param string $unit
* @return array
Expand All @@ -380,9 +380,9 @@ public static function toEther($number, $unit)
* fromWei
* Change number from wei to unit.
* For example:
* list($bnq, $bnr) = Utils::fromWei('1000', 'kwei');
* list($bnq, $bnr) = Utils::fromWei('1000', 'kwei');
* $bnq->toString(); // 1
*
*
* @param BigNumber|string|int $number
* @param string $unit
* @return \phpseclib\Math\BigInteger
Expand All @@ -404,7 +404,7 @@ public static function fromWei($number, $unit)

/**
* jsonMethodToString
*
*
* @param stdClass|array $json
* @return string
*/
Expand Down Expand Up @@ -450,7 +450,7 @@ public static function jsonMethodToString($json)

/**
* jsonToArray
*
*
* @param stdClass|array $json
* @return array
*/
Expand Down Expand Up @@ -486,7 +486,7 @@ public static function jsonToArray($json)
/**
* toBn
* Change number or number string to bignumber.
*
*
* @param BigNumber|string|int $number
* @return array|\phpseclib\Math\BigInteger
*/
Expand Down Expand Up @@ -552,7 +552,7 @@ public static function toBn($number)

/**
* hexToNumber
*
*
* @param string $hexNumber
* @return int
*/
Expand All @@ -563,4 +563,4 @@ public static function hexToNumber($hexNumber)
}
return intval(self::toBn($hexNumber)->toString());
}
}
}
12 changes: 6 additions & 6 deletions test/unit/BigNumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
namespace Test\Unit;

use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;
use Web3\Formatters\BigNumberFormatter;

class BigNumberFormatterTest extends TestCase
class BigNumberFormatterTest extends \PHPUnit\Framework\TestCase
{
/**
* formatter
*
*
* @var \Web3\Formatters\BigNumberFormatter
*/
protected $formatter;

/**
* setUp
*
*
* @return void
*/
public function setUp(): void
Expand All @@ -28,7 +28,7 @@ public function setUp(): void

/**
* testFormat
*
*
* @return void
*/
public function testFormat()
Expand All @@ -39,4 +39,4 @@ public function testFormat()
$this->assertEquals($bigNumber->toString(), '1');
$this->assertTrue($bigNumber instanceof BigNumber);
}
}
}
4 changes: 2 additions & 2 deletions test/unit/ContractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Web3\Utils;
use Web3\Contracts\Ethabi;
use Web3\Formatters\IntegerFormatter;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class ContractTest extends TestCase
{
Expand Down Expand Up @@ -1631,4 +1631,4 @@ function () use ($promise2) { return $promise2; },
function () use ($promise3) { return $promise3; },
]));
}
}
}
4 changes: 2 additions & 2 deletions test/unit/EthApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use RuntimeException;
use InvalidArgumentException;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class EthApiTest extends TestCase
{
Expand Down Expand Up @@ -795,4 +795,4 @@ public function testWrongCallback()

$eth->protocolVersion();
}
}
}
4 changes: 2 additions & 2 deletions test/unit/EthBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use RuntimeException;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class EthBatchTest extends TestCase
{
Expand Down Expand Up @@ -74,4 +74,4 @@ public function testBatchAsync()
$this->assertTrue($promise instanceof \React\Promise\PromiseInterface);
\React\Async\await($promise);
}
}
}
4 changes: 2 additions & 2 deletions test/unit/NetApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use RuntimeException;
use InvalidArgumentException;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class NetApiTest extends TestCase
{
Expand Down Expand Up @@ -132,4 +132,4 @@ public function testWrongCallback()

$net->version();
}
}
}
4 changes: 2 additions & 2 deletions test/unit/NetBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use RuntimeException;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;

class NetBatchTest extends TestCase
{
Expand Down Expand Up @@ -78,4 +78,4 @@ public function testBatchAsync()
$this->assertTrue($promise instanceof \React\Promise\PromiseInterface);
\React\Async\await($promise);
}
}
}
4 changes: 2 additions & 2 deletions test/unit/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use InvalidArgumentException;
use stdClass;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
use phpseclib3\Math\BigInteger as BigNumber;
use Web3\Utils;
use Web3\Contract;

Expand Down Expand Up @@ -652,4 +652,4 @@ public function testToBn()
$this->expectException(InvalidArgumentException::class);
$bn = Utils::toBn(new stdClass);
}
}
}