From 7282760c10a775699286183a8624f1103eacfcdd Mon Sep 17 00:00:00 2001 From: Greg Magarshak Date: Mon, 28 Nov 2022 19:31:55 -0500 Subject: [PATCH] Updated Utils and BigNumberFormatter to handle hex edge cases --- src/Contracts/Types/Uinteger.php | 2 +- src/Utils.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Contracts/Types/Uinteger.php b/src/Contracts/Types/Uinteger.php index c2099eda..b37c91da 100644 --- a/src/Contracts/Types/Uinteger.php +++ b/src/Contracts/Types/Uinteger.php @@ -73,7 +73,7 @@ public function outputFormat($value, $name) { $match = []; - if (preg_match('/^[0]+([a-f0-9]+)$/', $value, $match) === 1) { + if (preg_match('/^([a-f0-9]+)$/', $value, $match) === 1) { // due to value without 0x prefix, we will parse as decimal $value = '0x' . $match[1]; } diff --git a/src/Utils.php b/src/Utils.php index 8883c2b4..a09c427f 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -492,7 +492,7 @@ public static function toBn($number) $bn = $number; } elseif (is_int($number)) { $bn = new BigNumber($number); - } elseif (is_numeric($number)) { + } elseif (preg_match('/^(-{0,1})[0-9]*$/', $number)) { $number = (string) $number; if (self::isNegative($number)) {