Fix decode bytes
* Return non zero bytes. Decode bytes1 data: 0x6300000000000000000000000000000000000000000000000000000000000000 Will return 0x63
This commit is contained in:
parent
ecafb1c5ec
commit
d5c21afec0
@ -36,7 +36,7 @@ class Bytes extends SolidityType implements IType
|
||||
*/
|
||||
public function isType($name)
|
||||
{
|
||||
return (preg_match('/^bytes([0-9]{1,})?(\[([0-9]*)\])*/', $name) === 1);
|
||||
return (preg_match('/^bytes([0-9]{1,})(\[([0-9]*)\])*$/', $name) === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +90,11 @@ class Bytes extends SolidityType implements IType
|
||||
if (empty($checkZero)) {
|
||||
return '0';
|
||||
}
|
||||
if (preg_match('/^bytes([0-9]*)/', $name, $match) === 1) {
|
||||
$size = intval($match[1]);
|
||||
$length = 2 * $size;
|
||||
$value = mb_substr($value, 0, $length);
|
||||
}
|
||||
return '0x' . $value;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user