Throw errors when trying to RLP encode integers.
This commit is contained in:
parent
3e44aac8f1
commit
9ea16e5172
@ -97,7 +97,7 @@ export function arrayify(value: BytesLike | Hexable | number, options?: DataOpti
|
||||
const result = [];
|
||||
while (value) {
|
||||
result.unshift(value & 0xff);
|
||||
value /= 256;
|
||||
value = parseInt(String(value / 256));
|
||||
}
|
||||
if (result.length === 0) { result.push(0); }
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
//See: https://github.com/ethereum/wiki/wiki/RLP
|
||||
|
||||
|
||||
import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes";
|
||||
import { arrayify, BytesLike, hexlify, isBytesLike } from "@ethersproject/bytes";
|
||||
|
||||
function arrayifyInteger(value: number): Array<number> {
|
||||
const result = [];
|
||||
@ -41,6 +40,10 @@ function _encode(object: Array<any> | string): Array<number> {
|
||||
|
||||
}
|
||||
|
||||
if (!isBytesLike(object)) {
|
||||
throw new Error("RLP object must be BytesLike");
|
||||
}
|
||||
|
||||
const data: Array<number> = Array.prototype.slice.call(arrayify(object));
|
||||
|
||||
if (data.length === 1 && data[0] <= 0x7f) {
|
||||
|
Loading…
Reference in New Issue
Block a user