Reputation: 1
I'm encountering a TypeError in my Hardhat test script that involves the isAddress function from the @nomicfoundation/hardhat-chai-matchers library. The error seems to be causing issues with my test suite. Below is the relevant code snippet: here my code.
const { expect, assert } = require("chai");
const { ethers } = require("hardhat");
const {
addressFactory,
addressRouter,
addressFrom,
addressTo,
} = require("../utils/AddressList");
const { erc20ABI, factoryABI, routerABI } = require("../utils/AbiList");
describe("read and write blockchain", () => {
let provider,
contractFactory,
contractRouter,
contractToken,
decimals,
amountIn,
amountOut;
before(async () => {
provider = new ethers.providers.JsonRpcProvider(
""
);
contractFactory = new ethers.Contract(addressFactory, factoryABI, provider);
contractRouter = new ethers.Contract(addressRouter, routerABI, provider);
contractToken = new ethers.Contract(addressFrom, erc20ABI, provider);
});
it("connects to the provider, factory, token, and router", () => {
assert(provider._isProvider);
expect(contractFactory.address).to.equal(
"0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f"
);
expect(contractRouter.address).to.equal(
"0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
);
expect(contractToken.address).to.equal(
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
);
});
});
I'm trying to perform [read and write blockchain] in my Hardhat tests, and the tests are failing due to the following error: I tried downgrade the ethers version to 5.6.1 and didn't fix.
Here what I get.
read and write blockchain
1) connects to the provider, factory, token, and router
0 passing (73ms)
1 failing
1) read and write blockchain
connects to the provider, factory, token, and router:
TypeError: (0 , ethers_1.isAddress) is not a function
at tryGetAddressSync (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/addressable.ts:29:16)
at Proxy.<anonymous> (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/addressable.ts:53:20)
at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
at Proxy.<anonymous> (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/bigNumber.ts:193:14)
at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22)
at Proxy.<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20)
at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
at Context.<anonymous> (test/SendSwapTx.js:34:40)
Upvotes: 0
Views: 442
Reputation: 1926
This happens when versions of ethers
collide - I think you might be using version 5.X
in your code yet the version of hardhat-chai-matchers
you're using depends on 6.X
.
If that's the case, look for an older version of hardhat-chai-matchers
or update your version to 6
Upvotes: 1