Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async getRequestFromId(
requestId: string,
): Promise {
const resultGetTx = await this.transactionManager.getTransactionsByChannelId(requestId);
const actions = resultGetTx.result.transactions
// filter the actions ignored by the previous layers
.filter(action => action !== null);
let ignoredTransactions: any[] = [];
// array of transaction without duplicates to avoid replay attack
const actionsConfirmedWithoutDuplicates = Utils.uniqueByProperty(
actions
.map((t: any) => {
try {
return { action: JSON.parse(t.transaction.data), timestamp: t.timestamp };
} catch (e) {
// We ignore the transaction.data that cannot be parsed
ignoredTransactions.push({
reason: 'JSON parsing error',
transaction: t,
});
return;
}
})
.filter((elem: any) => elem !== undefined),
'action',
);
async channelId => {
let ignoredTransactions: any[] = [];
const actionsConfirmedWithoutDuplicates = Utils.uniqueByProperty(
transactionsByChannel[channelId]
// filter the actions ignored by the previous layers
.filter(action => action !== null)
.map((t: any) => {
try {
return { action: JSON.parse(t.transaction.data), timestamp: t.timestamp };
} catch (e) {
// We ignore the transaction.data that cannot be parsed
ignoredTransactions.push({
reason: 'JSON parsing error',
transaction: t,
});
return;
}
})
.filter((elem: any) => elem !== undefined),