How do I chain two contract updates together?
This following code works for individually updating each of them, but I have to approve the first update in Metamask, then wait for it to finish before the other update asks to be confirmed in Metamask :
await vaultcontract.methods.update7Day([update7day]).send({from: account}).then(function(receipt){
document.getElementById("7dayupdated").innerText = "updated";
});
await vaultcontract.methods.update30Day([update30day]).send({from: account}).then(function(receipt){
document.getElementById("30dayupdated").innerText = "updated";
});
How can I do both with one transaction?
Promise.all([
vaultcontract.methods.update7Day([update7day]).send({from: account}),
vaultcontract.methods.update30Day([update30day]).send({from: account})
]).then( _ => {
// variable name is _ (underscore) because you don't use it
document.getElementById("7dayupdated").innerText = "updated";
document.getElementById("30dayupdated").innerText = "updated";
});