Whenever I add an address to sync using the server interface, that address gets populated twice into the collection.
Only cloud function on the server is this
Moralis.settings.setAPIRateLimit({
anonymous:3500, authenticated:3500, windowMs:60000
})
Moralis.Cloud.afterSave("WatchedEthAddress", async (request) => {
const logger = Moralis.Cloud.getLogger();
const address = request.object.get("address");
logger.info("afterSave triggered for address " + address);
const options = { chain: "eth", address: address};
const {balance} = await Moralis.Web3API.account.getNativeBalance(options);
const ethBalance = Moralis.Cloud.units({
method: "fromWei",
value: balance
});
logger.info("afterSave balance response " + ethBalance);
request.object.set("eth_balance", ethBalance);
await request.object.save(null,{useMasterKey:true});
});