Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return bytes_1.arrayify((value + Zeros).substring(0, 66));
}
return value;
}
match = type.match(regexArray);
if (match && Array.isArray(value)) {
var baseType_1 = match[1];
var count = parseInt(match[2] || String(value.length));
if (count != value.length) {
throw new Error("invalid value for " + type);
}
var result_1 = [];
value.forEach(function (value) {
result_1.push(_pack(baseType_1, value, true));
});
return bytes_1.concat(result_1);
}
throw new Error("unknown type - " + type);
}
// @TODO: Array Enum
return arrayify((value + Zeros).substring(0, 66));
}
return value;
}
match = type.match(regexArray);
if (match && Array.isArray(value)) {
const baseType = match[1];
const count = parseInt(match[2] || String(value.length));
if (count != value.length) {
throw new Error("invalid value for " + type);
}
const result = [];
value.forEach(function (value) {
result.push(_pack(baseType, value, true));
});
return concat(result);
}
throw new Error("unknown type - " + type);
}
// @TODO: Array Enum
Writer.prototype._getValue = function (value) {
var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value));
if (bytes.length > this.wordSize) {
logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, {
length: this.wordSize,
offset: bytes.length
});
}
if (bytes.length % this.wordSize) {
bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]);
}
return bytes;
};
// BigNumberish items; padded on the left to wordSize
function pack(types, values) {
if (types.length != values.length) {
throw new Error("type/value count mismatch");
}
var tight = [];
types.forEach(function (type, index) {
tight.push(_pack(type, values[index]));
});
return bytes_1.hexlify(bytes_1.concat(tight));
}
exports.pack = pack;
}
if (arrayify(value).byteLength !== size) { throw new Error("invalid value for " + type); }
if (isArray) { return arrayify((value + Zeros).substring(0, 66)); }
return value;
}
match = type.match(regexArray);
if (match && Array.isArray(value)) {
const baseType = match[1];
const count = parseInt(match[2] || String(value.length));
if (count != value.length) { throw new Error("invalid value for " + type); }
const result: Array = [];
value.forEach(function(value) {
result.push(_pack(baseType, value, true));
});
return concat(result);
}
throw new Error("unknown type - " + type);
}