Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(transactionResponse => {
if (
transactionResponse.status === TransactionStatus.FAIL &&
transactionResponse.errors.length > 0
) {
const message = `Error processing signature: ${
transactionResponse.errors[0].message
}`;
library.logger.error(message, { signature });
return setImmediate(cb, new Error(message));
}
// Emit events
library.channel.publish(
'chain:multisignatures:signature:change',
transaction.id
);
library.bus.message('signature', signature, true);
return setImmediate(cb);
.then(transactionResponse => {
if (
transactionResponse.status === TransactionStatus.FAIL &&
transactionResponse.errors.length > 0
) {
const message = transactionResponse.errors[0].message;
library.logger.error(message, { signature });
return setImmediate(cb, transactionResponse.errors);
}
// Emit events
library.channel.publish(
'chain:multisignatures:signature:change',
transaction.id
);
library.bus.message('signature', signature, true);
return setImmediate(cb);
})
.catch(err => setImmediate(cb, [err]));
signature.transactionId,
);
if (!transaction) {
const message =
'Unable to process signature, corresponding transaction not found';
this.logger.error({ signature }, message);
throw [new TransactionError(message, '', '.signature')];
}
const transactionResponse = await this.blocks.processSignature(
transaction,
signature,
);
if (
transactionResponse.status === TransactionStatus.FAIL &&
transactionResponse.errors.length > 0
) {
const { message } = transactionResponse.errors[0];
this.logger.error(message, { signature });
throw transactionResponse.errors;
}
this.emit(EVENT_MULTISIGNATURE_SIGNATURE, signature);
return transactionResponse;
}
const transaction = this.getMultisignatureTransaction(
signature.transactionId
);
if (!transaction) {
const message =
'Unable to process signature, corresponding transaction not found';
this.logger.error(message, { signature });
throw [new TransactionError(message, '', '.signature')];
}
const transactionResponse = await transactionsModule.processSignature(
this.storage
)(transaction, signature);
if (
transactionResponse.status === TransactionStatus.FAIL &&
transactionResponse.errors.length > 0
) {
const message = transactionResponse.errors[0].message;
this.logger.error(message, { signature });
throw transactionResponse.errors;
}
return transactionResponse;
}
transactionsResponses: transactions.map(transaction => {
const context = typeof contexter === 'function' ? contexter() : contexter;
const allowed = !transaction.matcher || transaction.matcher(context);
return {
id: transaction.id,
status: allowed ? TransactionStatus.OK : TransactionStatus.FAIL,
errors: allowed
? []
: [
new TransactionError(
`Transaction type ${transaction.type} is currently not allowed.`,
transaction.id,
),
],
};
}),
});
const transactionsResponses = transactions.map(transaction => {
stateStore.createSnapshot();
const transactionResponse = transaction.apply(stateStore);
if (slots.getSlotNumber(transaction.timestamp) > slots.getSlotNumber()) {
transactionResponse.status = TransactionStatus.FAIL;
transactionResponse.errors.push(
new TransactionError(
'Invalid transaction timestamp. Timestamp is in the future',
transaction.id,
'.timestamp',
),
);
}
stateStore.restoreSnapshot();
return transactionResponse;
});
const transactionsResponses = transactions.map(transaction => {
stateStore.createSnapshot();
const transactionResponse = transaction.apply(stateStore);
if (slots.getSlotNumber(transaction.timestamp) > slots.getSlotNumber()) {
transactionResponse.status = TransactionStatus.FAIL;
transactionResponse.errors.push(
new TransactionError(
'Invalid transaction timestamp. Timestamp is in the future',
transaction.id,
'.timestamp',
),
);
}
stateStore.restoreSnapshot();
return transactionResponse;
});
response => response.status === TransactionStatus.FAIL,
),
transactionsResponses: transactions.map(transaction => {
const allowed =
!transaction.matcher ||
transaction.matcher(
context || ProcessTransactions._getCurrentContext()
);
return {
id: transaction.id,
status: allowed ? TransactionStatus.OK : TransactionStatus.FAIL,
errors: allowed
? []
: [
new TransactionError(
`Transaction type ${
transaction.type
} is currently not allowed.`,
transaction.id
),
],
};
}),
};
transactionsResponses: transactions.map(transaction => {
const context = typeof contexter === 'function' ? contexter() : contexter;
const allowed = !transaction.matcher || transaction.matcher(context);
return {
id: transaction.id,
status: allowed ? TransactionStatus.OK : TransactionStatus.FAIL,
errors: allowed
? []
: [
new TransactionError(
`Transaction type ${transaction.type} is currently not allowed.`,
transaction.id,
),
],
};
}),
});