diff --git a/composer.json b/composer.json index 61d30dc2..c76d7758 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Utils.php b/src/Utils.php index f0fdd848..09470fb5 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -2,9 +2,9 @@ /** * This file is part of web3.php package. - * + * * (c) Kuan-Cheng,Lai - * + * * @author Peter Lai * @license MIT */ @@ -15,13 +15,13 @@ 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'; @@ -29,7 +29,7 @@ class Utils /** * UNITS * from ethjs-unit - * + * * @const array */ const UNITS = [ @@ -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); @@ -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 @@ -108,7 +108,7 @@ public static function toHex($value, $isPrefix=false) /** * hexToBin - * + * * @param string * @return string */ @@ -130,7 +130,7 @@ public static function hexToBin($value) /** * isZeroPrefixed - * + * * @param string * @return bool */ @@ -144,7 +144,7 @@ public static function isZeroPrefixed($value) /** * stripZero - * + * * @param string $value * @return string */ @@ -159,7 +159,7 @@ public static function stripZero($value) /** * isNegative - * + * * @param string * @return bool */ @@ -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 */ @@ -243,7 +243,7 @@ public static function toChecksumAddress($value) /** * isHex - * + * * @param string $value * @return bool */ @@ -255,7 +255,7 @@ public static function isHex($value) /** * sha3 * keccak256 - * + * * @param string $value * @return string */ @@ -277,7 +277,7 @@ public static function sha3($value) /** * toString - * + * * @param mixed $value * @return string */ @@ -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 @@ -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 @@ -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 @@ -404,7 +404,7 @@ public static function fromWei($number, $unit) /** * jsonMethodToString - * + * * @param stdClass|array $json * @return string */ @@ -450,7 +450,7 @@ public static function jsonMethodToString($json) /** * jsonToArray - * + * * @param stdClass|array $json * @return array */ @@ -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 */ @@ -552,7 +552,7 @@ public static function toBn($number) /** * hexToNumber - * + * * @param string $hexNumber * @return int */ @@ -563,4 +563,4 @@ public static function hexToNumber($hexNumber) } return intval(self::toBn($hexNumber)->toString()); } -} \ No newline at end of file +} diff --git a/test/unit/BigNumberFormatterTest.php b/test/unit/BigNumberFormatterTest.php index 87dc6216..48e5da3a 100644 --- a/test/unit/BigNumberFormatterTest.php +++ b/test/unit/BigNumberFormatterTest.php @@ -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 @@ -28,7 +28,7 @@ public function setUp(): void /** * testFormat - * + * * @return void */ public function testFormat() @@ -39,4 +39,4 @@ public function testFormat() $this->assertEquals($bigNumber->toString(), '1'); $this->assertTrue($bigNumber instanceof BigNumber); } -} \ No newline at end of file +} diff --git a/test/unit/ContractTest.php b/test/unit/ContractTest.php index 985a1a74..4e4243f6 100644 --- a/test/unit/ContractTest.php +++ b/test/unit/ContractTest.php @@ -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 { @@ -1631,4 +1631,4 @@ function () use ($promise2) { return $promise2; }, function () use ($promise3) { return $promise3; }, ])); } -} \ No newline at end of file +} diff --git a/test/unit/EthApiTest.php b/test/unit/EthApiTest.php index f7645809..83f987f9 100644 --- a/test/unit/EthApiTest.php +++ b/test/unit/EthApiTest.php @@ -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 { @@ -795,4 +795,4 @@ public function testWrongCallback() $eth->protocolVersion(); } -} \ No newline at end of file +} diff --git a/test/unit/EthBatchTest.php b/test/unit/EthBatchTest.php index 591f50e4..7584681e 100644 --- a/test/unit/EthBatchTest.php +++ b/test/unit/EthBatchTest.php @@ -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 { @@ -74,4 +74,4 @@ public function testBatchAsync() $this->assertTrue($promise instanceof \React\Promise\PromiseInterface); \React\Async\await($promise); } -} \ No newline at end of file +} diff --git a/test/unit/NetApiTest.php b/test/unit/NetApiTest.php index 0c96d571..db7871e9 100644 --- a/test/unit/NetApiTest.php +++ b/test/unit/NetApiTest.php @@ -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 { @@ -132,4 +132,4 @@ public function testWrongCallback() $net->version(); } -} \ No newline at end of file +} diff --git a/test/unit/NetBatchTest.php b/test/unit/NetBatchTest.php index 9fadb1f8..8ee20a2d 100644 --- a/test/unit/NetBatchTest.php +++ b/test/unit/NetBatchTest.php @@ -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 { @@ -78,4 +78,4 @@ public function testBatchAsync() $this->assertTrue($promise instanceof \React\Promise\PromiseInterface); \React\Async\await($promise); } -} \ No newline at end of file +} diff --git a/test/unit/UtilsTest.php b/test/unit/UtilsTest.php index 76244edf..cb83d4b1 100644 --- a/test/unit/UtilsTest.php +++ b/test/unit/UtilsTest.php @@ -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; @@ -652,4 +652,4 @@ public function testToBn() $this->expectException(InvalidArgumentException::class); $bn = Utils::toBn(new stdClass); } -} \ No newline at end of file +}