Itās not all that pretty
I have other cloud functions that also return the same error.
// ************************************************************
// *** GET HOME MESSAGES ***
// ************************************************************
Moralis.Cloud.define("getHomeMessages", async (request) => {
const BTDMDABI =
[
{
"inputs": [],
"name": "totalFees",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
]
const results = [];
const web3 = Moralis.web3ByChain(CHAIN_ID); // BSC
const contract = new web3.eth.Contract(BTDMDABI, BITDIAMOND_TOKEN_ADDRESS);
var distro = await (contract.methods.totalFees().call())/(10**8);
const totalDistro = (distro.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
var troveBalance = await (contract.methods.balanceOf(TROVE_WALLET_ADDRESS).call())/(10**8);
const totalTroveBalance = (troveBalance.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
var bountyBalance = await (web3.eth.getBalance(BOUNTY_TOKEN_ADDRESS))/(10**18);
const totalBountyBalance = (bountyBalance.toFixed(4)).toString();
var wordsBalance = await (contract.methods.balanceOf(WORD_WALLET_ADDRESS).call())/(10**8);
const totalWordsBalance = (wordsBalance.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");;
const queryAllTime = new Moralis.Query("BscNFTOwners");
queryAllTime.equalTo("token_address", TREASURE_TOKEN_ADDRESS.toLowerCase());
const queryResultsAllTime = await queryAllTime.count() + 5;
const totalTreasureNFTs = (queryResultsAllTime.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
BTDMDPrice = await Moralis.Cloud.run("getPrice")
var weekdayString=new Array(7);
weekdayString[1]="Monday";
weekdayString[2]="Tuesday";
weekdayString[3]="Wednesday";
weekdayString[4]="Thursday";
weekdayString[5]="Friday";
weekdayString[6]="Saturday";
weekdayString[0]="Sunday";
var monthString=new Array(12);
monthString[0]="January";
monthString[1]="February";
monthString[2]="March";
monthString[3]="April";
monthString[4]="May";
monthString[5]="June";
monthString[6]="July";
monthString[7]="August";
monthString[8]="September";
monthString[9]="October";
monthString[10]="November";
monthString[11]="December";
var rightNow = new Date();
var day = weekdayString[rightNow.getUTCDay()]
var date = rightNow.getUTCDate();
var month = monthString[rightNow.getUTCMonth()];
var year = rightNow.getUTCFullYear();
var hours = rightNow.getUTCHours();
var minutes = rightNow.getUTCMinutes();
var seconds = rightNow.getUTCSeconds();
if (minutes < 10)
{
minuteString = "0" + minutes;
}
else
{
minuteString = "" + minutes;
}
if (seconds < 10)
{
secondString = "0" + seconds;
}
else
{
secondString = "" + seconds;
}
results.push({
"HEADER": "Platform Stats",
"LINE": "on " + day + " " + date + " " + month + " " + year + " @ " + hours + ":" + minuteString + ":" + secondString + " UTC",
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": totalDistro,
"LINE": "BTDMD Distributed to Holders using our passive yield mechanism",
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": "1 BTDMD = ",
"LINE": BTDMDPrice,
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": totalTreasureNFTs,
"LINE": "Treasure NFTs minted",
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": totalTroveBalance,
"LINE": "BTDMD to be won in the Trove!",
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": totalBountyBalance,
"LINE": "BNB in the Bounty Prize Pool!!",
});
results.push({
"HEADER": "",
"LINE": "",
});
results.push({
"HEADER": totalWordsBalance,
"LINE": "BTDMD to be won in Words of Power game!!!",
});
return results;
});