Hola buenos días, tengo un problema con este código... No puedo declarar un async dentro de una Promesa, entonces me gustaría saber la mejor forma de solucionar esto y ejecutar estas promesas con .PromiseAll() más abajo.
const massiveSender = async (client, tokenId, data) => {
const promises = data.map(async (tx) => {
return new Promise(async (resolve, reject) => {
try {
let tokenTransferTx = await new TransferTransaction().addNftTransfer(
tokenId,
tx.SerialNumber,
tx.SenderAccount,
tx.ReceiverAccount
);
const tokenTransferTxSubmit = await tokenTransferTx.execute(client);
const tokenTransferTxReceipt = await tokenTransferTxSubmit.getReceipt(
client
);
console.log(
"Sended NFT to" +
tx.ReceiverAccount +
" STATUS: " +
tokenTransferTxReceipt.status +
"\n"
);
resolve();
} catch (error) {
console.log(error);
reject();
}
});
});
Promise.all(promises)
.then(() => {
console.log("All NFTs were sent successfully");
})
.catch((error) => {
console.log("Some NFTs were not sent successfully: ", error);
});
};