Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Sep 7, 2023
1 parent 473dc35 commit 013c712
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ export async function deploy<T extends ContractFactory>(
const contractName = getContractName(factory);
logger.out(`Deploying ${contractName}...`);

const contract = await factory.deploy(...(constructorArguments ?? []));
try {
const contract = await factory.deploy(...(constructorArguments ?? []));
await contract.deployed();
logger.out(`Address: ${contract.address}`);
return {
constructorArguments,
contractName,
contract: contract as Awaited<ReturnType<T["deploy"]>>,
};
} catch (error) {
logger.out(`Tx hash: ${contract.deployTransaction.hash}`);
} catch (error: any) {
if ("data" in error && "txHash" in error.data) {
logger.out(`Tx hash: ${error.data.txHash}`);
}
throw error;
}
}
Expand Down

0 comments on commit 013c712

Please sign in to comment.