The following function:
async function getPendingTransactions(address){
var pendingBlock = await web3.eth.getBlock('pending');
var i = 0;
var pendingTransactions = await pendingBlock.transactions.filter(async function(txHash) {
var tx = await web3.eth.getTransaction(txHash);
console.log(tx);
if(tx != null) {
return tx.from==address && tx.to == CONTRACT_ADDRESS;
}
});
console.log(pendingTransactions);
return pendingTransactions;
}
The filter does not work and all transactions are displayed (console.log), and the filter loops seems to be processed afterwards. I guess it is a async/await problem. How can I keep the the filter synchronous?