Hi guys, I have a question.
Based on this documentation https://docs.moralis.io/streams-api/evm#supported-chains for Arbitrum I will receive a stream request from Moralis with confirmed = true
when will be 100 block confirmations.
Sometimes it can takes up to even 10 minutes (it happened to me).
In that case for Arbitrum I would like to build a custom block confirmation.
Do you have an idea how to make it properly?
I tried something like:
import { Types as StreamsTypes } from '@moralisweb3/streams';
import { JsonRpcProvider } from 'ethers';
import { uniqBy } from 'lodash';
const checkTxConfirmation = async (input: StreamsTypes.IWebhook, jsonRpcUrl: string): Promise<boolean> => {
if (!input.confirmed) {
const provider = new JsonRpcProvider(jsonRpcUrl);
const results = await Promise.all(
uniqBy(input.logs || [], 'transactionHash').map(async (log: any) => {
const tx = await provider.getTransaction(log.transactionHash);
const receipt = await tx?.wait(10);
return receipt?.status === 1;
}),
);
return !results.find((confirmation) => !confirmation);
}
return input.confirmed;
}
But I’m not sure whether is a good direction.
Can you advice?