Fix bytes and dynamic bytes format

This commit is contained in:
sc0Vu 2019-02-11 00:10:14 +08:00
parent b0615caf03
commit d35ecef5f7
No known key found for this signature in database
GPG Key ID: A53323E7065B1FA7
2 changed files with 9 additions and 7 deletions

View File

@ -63,9 +63,10 @@ class Bytes extends SolidityType implements IType
}
$value = Utils::stripZero($value);
// if (mb_strlen($value) % 2 !== 0) {
if (mb_strlen($value) % 2 !== 0) {
$value = "0" . $value;
// throw new InvalidArgumentException('The value to inputFormat has invalid length. Value: ' . $value);
// }
}
if (mb_strlen($value) > 64) {
throw new InvalidArgumentException('The value to inputFormat is too long.');

View File

@ -63,9 +63,10 @@ class DynamicBytes extends SolidityType implements IType
}
$value = Utils::stripZero($value);
// if (mb_strlen($value) % 2 !== 0) {
if (mb_strlen($value) % 2 !== 0) {
$value = "0" . $value;
// throw new InvalidArgumentException('The value to inputFormat has invalid length.');
// }
}
$bn = Utils::toBn(floor(mb_strlen($value) / 2));
$bnHex = $bn->toHex(true);
$padded = mb_substr($bnHex, 0, 1);