I Have a racing problem when using moralis subscription functionality for listening transaction on blockchain.
whenever i send a money to my friend’s address, the subscription will run twice simultaneously after the transaction was confirmed, though it correctly only run once to give me update that the transaction hasn’t confirmed yet. this case also reproduce able when my friend sending fund to my wallet address.
i have checked if maybe my address is registered more than once on the moralis dashboard but its not
here’s my piece of code, will run listener for each network of [ethereum, binance, and polygon] and this issue is found on binance network.
const subscribeToMoralisDB = async (
dbName: string,
callback: BlockchainTransactionCallback,
) => {
const bscQuery = new Moralis.Query(dbName);
const bscSubscription = await bscQuery
.subscribe()
.catch((error) => console.log(error));
bscSubscription &&
bscSubscription.on("update", (data) => {
if (data.attributes.confirmed) {
callback(data.attributes as BlockchainTransaction);
}
});
};