I am trying to create a field “value” in the _AddressSyncStatus collection for each entry after it has been synced using the plugin. The afterSave gets triggered according to the log, but the “value” column including the web3 value doesnt get saved.
Am I doing something wrong? The logs dont output any error.
Moralis.Cloud.afterSave("_AddressSyncStatus", async request => {
logger.info("afterSave _AddressSyncStatus called");
const addressObj = request.object;
const ethBalance = await Moralis.Web3API.account.getNativeBalance({
address: addressObj.get("address")
});
addressObj.set("value", ethBalance);
addressObj.save();
});
2022-03-20T15:54:25.878Z - Ran cloud function coreservices_getConfig for user undefined with:
Input: {}
Result: {"status":200,"data":{"success":true,"result":{"providers":[{"chain":"Eth","name":"Mainnet","network":"mainnet","exchange":"eth","chainId":"0x1","lookups":["eth","mainnet","0x1"],"token":{"name":"Ether","symbol":"ETH"},"httpProviderUrl":"eth/mainnet","maxRecordsPerCategory":50,"userSync":true}],"addressSyncs":[{"chainId":"0x1","address":"0xf977814e90da44bfa03b6295a0616a897441acec","syncHistorical":false,"key":"0xf977814e90da44bfa03b6295a0616a897441acec_1"},{"chainId":"0x1","address":"0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f","syncHistorical":false,"key":"0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f_1"},{"chainId":"0x1","address":"0x42e0ab4619c7be98f7c9cd7b57ba02362ad79459","syncHistorical":true,"key":"0x42e0ab4619c7be98f7c9cd7b57ba02362ad79459_1"},{"chainId":"0x1","address":"0xd10c833f4305E1053a64Bc738c550381f48104Ca","syncHistorical":false,"key":"0xd10c833f4305e1053a64bc738c550381f48104ca_1"},{"chainId":"0x1","address":"0x7edd7d8bb062c9883400e498cb7538a008281468","syncHistorical":true... (truncated)
2022-03-20T15:54:25.365Z - Ran cloud function coreservices_getWeb3ApiToken for user undefined with:
Input: {}
Result: {"status":200,"data":{"success":true,"result":"O148899.1647791665327.0x34e08231a42f6e544ac563de6333c1da2462b59e6e096897ba79d04617705a29"}}
2022-03-20T15:54:25.294Z - afterSave _AddressSyncStatus called