Thank you for your response @thecil.
My plugin code only include abi and address info. I think you are referring to my cloud function. I do not have a timeout for each iteration.
Plugin Code:
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "bytes",
"name": "id",
"type": "bytes"
},
{
"indexed": false,
"internalType": "uint256",
"name": "edition",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "staker",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timeLocked",
"type": "uint256"
}
],
"name": "NFTEditionClaimed",
"type": "event"
}
Set to trigger on address:
0xedd53227174f9975bE294A5C910FB3392682514b
and topic:
0x5b51407a14c08c7233925370f8828c947e2b631ea1e78e7ae61cb35bbccc6c55
Cloud Function to be triggered after plugin has saved transaction. Will only execute logic if transaction confirmation is labelled as ‘True’.
Moralis.Cloud.afterSave("bscNFTEditionsClaimed", async (request) => {
if (request.object.get("confirmed") == true) {
const NewPool = Moralis.Object.extend("AllNFTEditionsClaimed");
const newPool = new NewPool();
newPool.set("network", 97);
newPool.set("block_hash", request.object.get("block_hash"));
newPool.set("block_timestamp", request.object.get("block_timestamp"));
newPool.set("transaction_hash", request.object.get("transaction_hash"));
newPool.set("staker", request.object.get("staker"));
newPool.set("timeLocked", request.object.get("timeLocked"));
newPool.set("address", request.object.get("address"));
newPool.set("uid", request.object.get("uid"));
newPool.set("edition", request.object.get("edition"));
newPool.set("block_number", request.object.get("block_number"));
newPool.set("createdAt", request.object.get("createdAt"));
newPool.save();
const ExistingPool = Moralis.Object.extend("AllNFTPools");
const query = new Moralis.Query(ExistingPool);
query.equalTo("uid", request.object.get("uid"));
query.equalTo("address", request.object.get("address"));
const pool = await query.first();
const newRemaining = (parseInt(pool.get("remaining")) - 1).toString();
pool.set("remaining", newRemaining);
pool.save();
}
});
Should I include a timeout in the cloud function?
It seems the error is happening with the plugin since the transaction confirmation is never set to ‘true’. If I manually set the transaction confirmations to true, the cloud function performs as expected.