Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function serialize(transaction, signature) {
checkProperties(transaction, allowedTransactionKeys);
const raw = [];
transactionFields.forEach(function (fieldInfo) {
let value = transaction[fieldInfo.name] || ([]);
const options = {};
if (fieldInfo.numeric) {
options.hexPad = "left";
}
value = arrayify(hexlify(value, options));
// Fixed-width field
if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) {
logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
}
// Variable-width (with a maximum)
if (fieldInfo.maxLength) {
value = stripZeros(value);
if (value.length > fieldInfo.maxLength) {
JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) {
// Check only allowed properties are given
var allowed = properties_1.shallowCopy(allowedTransactionKeys);
if (allowExtra) {
for (var key in allowExtra) {
if (allowExtra[key]) {
allowed[key] = true;
}
}
}
properties_1.checkProperties(transaction, allowed);
var result = {};
// Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros.
["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) {
if (transaction[key] == null) {
return;
}
var value = bytes_1.hexValue(transaction[key]);
if (key === "gasLimit") {
key = "gas";
}
result[key] = value;
});
["from", "to", "data"].forEach(function (key) {
if (transaction[key] == null) {
return;
}
static hexlifyTransaction(transaction, allowExtra) {
// Check only allowed properties are given
const allowed = shallowCopy(allowedTransactionKeys);
if (allowExtra) {
for (let key in allowExtra) {
if (allowExtra[key]) {
allowed[key] = true;
}
}
}
checkProperties(transaction, allowed);
const result = {};
// Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros.
["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) {
if (transaction[key] == null) {
return;
}
const value = hexValue(transaction[key]);
if (key === "gasLimit") {
key = "gas";
}
result[key] = value;
});
["from", "to", "data"].forEach(function (key) {
if (transaction[key] == null) {
return;
}
function serialize(transaction, signature) {
properties_1.checkProperties(transaction, allowedTransactionKeys);
var raw = [];
transactionFields.forEach(function (fieldInfo) {
var value = transaction[fieldInfo.name] || ([]);
var options = {};
if (fieldInfo.numeric) {
options.hexPad = "left";
}
value = bytes_1.arrayify(bytes_1.hexlify(value, options));
// Fixed-width field
if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) {
logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value);
}
// Variable-width (with a maximum)
if (fieldInfo.maxLength) {
value = bytes_1.stripZeros(value);
if (value.length > fieldInfo.maxLength) {