Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ethers-chai-matchers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ethers-chai-matchers": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ethers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ethers": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-foundry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-foundry": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ignition-ethers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ignition-ethers": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ignition-viem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ignition-viem": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ignition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ignition": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-keystore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-keystore": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-ledger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ledger": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-mocha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-mocha": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-network-helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-network-helpers": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-node-test-reporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-node-test-reporter": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-node-test-runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-node-test-runner": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-solx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-solx": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-test-utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-test-utils": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-typechain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-typechain": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-utils": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-verify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-verify": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-viem-assertions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-viem-assertions": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat-viem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-viem": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-hardhat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Improve async handling to get better error reports
5 changes: 5 additions & 0 deletions .changeset/async-improvements-ignition-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/ignition-core": patch
---

Improve async handling to get better error reports
8 changes: 8 additions & 0 deletions .changeset/proud-clocks-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"hardhat": patch
"@nomicfoundation/hardhat-ignition": patch
"@nomicfoundation/hardhat-verify": patch
"@nomicfoundation/hardhat-errors": patch
---

Don't report HardhatErrors that aren't bugs
3 changes: 2 additions & 1 deletion packages/config/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ export function createConfig(
"no-new-wrappers": "error",
"no-only-tests/no-only-tests": "error",
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/return-await": ["error", "always"],
"no-sequences": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
Expand Down
4 changes: 0 additions & 4 deletions packages/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ You can learn how to use Hardhat by reading the [Getting Started guide](/getting
},
DUPLICATED_PLUGIN_ID: {
number: 2,
shouldBeReported: true,
messageTemplate:
'Duplicated plugin id "{id}" found. Did you install multiple versions of the same plugin?',
websiteTitle: "Duplicated plugin id",
Expand Down Expand Up @@ -1501,7 +1500,6 @@ Please use the fully qualified name of the contract to disambiguate it.`,
},
UNKNOWN_TRANSACTION_TYPE: {
number: 10110,
shouldBeReported: true,
messageTemplate: `Unknown transaction type: "{type}"`,
websiteTitle:
"Hardhat Ignition was unable to display an unknown transaction type",
Expand Down Expand Up @@ -1530,7 +1528,6 @@ Please use the fully qualified name of the contract to disambiguate it.`,
},
VISUALIZATION_TEMPLATE_DIR_NOT_FOUND: {
number: 10114,
shouldBeReported: true,
messageTemplate: `Unable to find template directory: "{templateDir}"`,
websiteTitle: "Visualization template directory not found",
websiteDescription: "Visualization template directory not found",
Expand Down Expand Up @@ -2845,7 +2842,6 @@ Please check the returned message for details.`,
CONTRACT_VERIFICATION_UNEXPECTED_RESPONSE: {
number: 80025,
messageTemplate: `The block explorer API returned an unexpected message: "{message}". Please report this issue to the Hardhat team.`,
shouldBeReported: true,
websiteTitle: "Unexpected API response during contract verification",
websiteDescription: `The block explorer API returned a message that doesn't match the expected format. This may indicate a change in the API or an issue with the request.

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-ethers-chai-matchers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./type-extensions.js";
const hardhatChaiMatchersPlugin: HardhatPlugin = {
id: "hardhat-ethers-chai-matchers",
hookHandlers: {
network: () => import("./internal/hook-handlers/network.js"),
network: async () => await import("./internal/hook-handlers/network.js"),
},
npmPackage: "@nomicfoundation/hardhat-ethers-chai-matchers",
dependencies: () => [import("@nomicfoundation/hardhat-ethers")],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async (): Promise<Partial<NetworkHooks>> => {
isInitialized = true;
}

return next(context);
return await next(context);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async function getTxFees(
txResponse: TransactionResponse,
options?: BalanceChangeOptions,
): Promise<bigint[]> {
return Promise.all(
return await Promise.all(
accounts.map(async (account) => {
if (
options?.includeFee !== true &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ export function supportChangeTokenBalance(
validateInput(this._obj, token, accounts, balanceChanges);

const balanceChangesPromise = Promise.all(
accounts.map((account) =>
getBalanceChange(ethers, subject, token, account),
accounts.map(
async (account) =>
await getBalanceChange(ethers, subject, token, account),
),
);
const addressesPromise = Promise.all(accounts.map(getAddressOf));
Expand Down
25 changes: 13 additions & 12 deletions packages/hardhat-ethers-chai-matchers/src/internal/matchers/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ async function waitForPendingTransaction(
// string, it might not be a real tx hash. Do a one-shot check to
// avoid polling forever.
if (isBytes32String(hash)) {
return provider.getTransactionReceipt(hash);
return await provider.getTransactionReceipt(hash);
}
}

return provider.waitForTransaction(hash);
return await provider.waitForTransaction(hash);
}

export function supportEmit(
Expand Down Expand Up @@ -130,7 +130,7 @@ export function supportEmit(
chaiUtils.flag(this, "contract", contract);
};

const derivedPromise = promise.then(() => {
const derivedPromise = promise.then(async () => {
// abort if the assertion chain was aborted, for example because
// a `.not` was combined with a `.withArgs`
if (chaiUtils.flag(this, ASSERTION_ABORTED) === true) {
Expand All @@ -141,15 +141,16 @@ export function supportEmit(
chaiAssert.fail("contract.runner.provider shouldn't be null");
}

return waitForPendingTransaction(tx, contract.runner.provider).then(
(receipt) => {
assertIsNotNull(
receipt,
"Transaction's receipt cannot be fetched from the network",
);
return onSuccess(receipt);
},
);
return await waitForPendingTransaction(
tx,
contract.runner.provider,
).then((receipt) => {
assertIsNotNull(
receipt,
"Transaction's receipt cannot be fetched from the network",
);
return onSuccess(receipt);
});
});

chaiUtils.flag(this, EMIT_CALLED, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function supportRevert(
}

async function waitForTransactionReceipt(ethers: HardhatEthers, hash: string) {
return ethers.provider.waitForTransaction(hash);
return await ethers.provider.waitForTransaction(hash);
}

function isTransactionResponse(x: unknown): x is { hash: string } {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ export function supportWithArgs(
const resolveArgument = (arg: any) =>
isAddressable(arg) ? arg.getAddress() : arg;

const onSuccess = (resolvedExpectedArgs: any[]) => {
const onSuccess = async (resolvedExpectedArgs: any[]) => {
if (emitCalled) {
return emitWithArgs(
return await emitWithArgs(
this,
Assertion,
chaiUtils,
resolvedExpectedArgs,
onSuccess,
);
} else {
return revertedWithCustomErrorWithArgs(
return await revertedWithCustomErrorWithArgs(
this,
Assertion,
chaiUtils,
Expand All @@ -88,7 +88,7 @@ export function supportWithArgs(
};

const promise = (this.then === undefined ? Promise.resolve() : this)
.then(() => Promise.all(expectedArgs.map(resolveArgument)))
.then(async () => await Promise.all(expectedArgs.map(resolveArgument)))
.then(onSuccess);

this.then = promise.then.bind(promise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function getAddressOf(
}

if (isAddressable(account)) {
return account.getAddress();
return await account.getAddress();
}

chaiAssert.fail(`Expected string or addressable, but got "${account}"`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ export interface BalanceChangeOptions {
includeFee?: boolean;
}

export function getAddresses(
export async function getAddresses(
accounts: Array<Addressable | string>,
): Promise<string[]> {
return Promise.all(accounts.map((account) => getAddressOf(account)));
return await Promise.all(
accounts.map(async (account) => await getAddressOf(account)),
);
}

export async function getBalances(
ethers: HardhatEthers,
accounts: Array<Addressable | string>,
blockNumber: number,
): Promise<bigint[]> {
return Promise.all(
return await Promise.all(
accounts.map(async (account) => {
const address = await getAddressOf(account);

Expand Down
Loading
Loading