Fix bytes and dynamic bytes format
This commit is contained in:
parent
b0615caf03
commit
d35ecef5f7
@ -63,9 +63,10 @@ class Bytes extends SolidityType implements IType
|
||||
}
|
||||
$value = Utils::stripZero($value);
|
||||
|
||||
// if (mb_strlen($value) % 2 !== 0) {
|
||||
// throw new InvalidArgumentException('The value to inputFormat has invalid length. Value: ' . $value);
|
||||
// }
|
||||
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.');
|
||||
|
@ -63,9 +63,10 @@ class DynamicBytes extends SolidityType implements IType
|
||||
}
|
||||
$value = Utils::stripZero($value);
|
||||
|
||||
// if (mb_strlen($value) % 2 !== 0) {
|
||||
// throw new InvalidArgumentException('The value to inputFormat has invalid length.');
|
||||
// }
|
||||
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);
|
||||
@ -98,4 +99,4 @@ class DynamicBytes extends SolidityType implements IType
|
||||
|
||||
return '0x' . mb_substr($value, 64, $length);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user