diff --git a/v-next/hardhat-chai-matchers/src/internal/changeTokenBalance.ts b/v-next/hardhat-chai-matchers/src/internal/changeTokenBalance.ts index 926ddd1161..2018502373 100644 --- a/v-next/hardhat-chai-matchers/src/internal/changeTokenBalance.ts +++ b/v-next/hardhat-chai-matchers/src/internal/changeTokenBalance.ts @@ -214,7 +214,14 @@ function checkToken(token: unknown, method: string) { method, }, ); - } else if ((token as any).interface.getFunction("balanceOf") === null) { + } else if ( + isObject(token) && + "interface" in token && + isObject(token.interface) && + "getFunction" in token.interface && + typeof token.interface.getFunction === "function" && + token.interface.getFunction("balanceOf") === null + ) { throw new HardhatError( HardhatError.ERRORS.CHAI_MATCHERS.CONTRACT_IS_NOT_AN_ERC20_TOKEN, ); diff --git a/v-next/hardhat-chai-matchers/src/internal/constants.ts b/v-next/hardhat-chai-matchers/src/internal/constants.ts index 44022c9877..481b77c834 100644 --- a/v-next/hardhat-chai-matchers/src/internal/constants.ts +++ b/v-next/hardhat-chai-matchers/src/internal/constants.ts @@ -1,5 +1,3 @@ -// TODO: check if all are used - export const ASSERTION_ABORTED = "hh-chai-matchers-assertion-aborted"; export const PREVIOUS_MATCHER_NAME = "previousMatcherName"; diff --git a/v-next/hardhat-chai-matchers/src/internal/reverted/utils.ts b/v-next/hardhat-chai-matchers/src/internal/reverted/utils.ts index b378c91b23..6a71199e97 100644 --- a/v-next/hardhat-chai-matchers/src/internal/reverted/utils.ts +++ b/v-next/hardhat-chai-matchers/src/internal/reverted/utils.ts @@ -21,6 +21,7 @@ const PANIC_CODE_PREFIX = "0x4e487b71"; */ export function getReturnDataFromError(error: any): string { if (!(error instanceof Error)) { + // eslint-disable-next-line no-restricted-syntax -- keep the original chai error structure throw new AssertionError("Expected an Error object"); }