[英]Promise.all is not resolving promises
我正在使用 Hardhat 部署 Solidity 合约,为此我编写了这个部署脚本:
const { ethers } = require("hardhat");
async function main() {
const erc20Tokens = ["Solana", "USDC", "Doge"];
const initialSupply = ethers.utils.parseUnits("100", "ether");
async function deploy(token) {
const Token = await ethers.getContractFactory(token);
console.log(`deploying ERC20 ${token} contract...`);
const deployedToken = await Token.deploy(initialSupply);
await deployedToken.deployed();
return deployedToken.address;
// console.log(`deployed ERC20 ${token} at: `, deployedToken.address);
}
const resolveAllPromises = erc20Tokens.map(async (e) => deploy(e));
Promise.all(resolveAllPromises).then(e=>console.log("resolved",e)).catch(err=>console.log("err"))
}
main()
.then(() => process.exit(0))
.catch((err) => {
console.log("error: ", err);
process.exit(1);
});
即使部署 function 中的 console.log 没有执行,我也没有从deployedToken.address
function 中获取 deployToken.address 的返回值。 这里有什么问题? 谁能帮帮我
return Promise.all
。 你打破了你的 promise 链。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.