-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Use hardhat-ethers for importing factories in integration tests #2016
Description
Is your feature request related to a problem? Please describe.
Some files in the integration tests still use an older method of importing contract artifacts directly instead of going through hardhat-ethers. For example, basic-l1-l2-communication.spec.ts includes the following import:
| import simpleStorageJson from '../artifacts/contracts/SimpleStorage.sol/SimpleStorage.json' |
This file then creates a contract factory using the JSON object imported from this file:
optimism/integration-tests/test/basic-l1-l2-communication.spec.ts
Lines 25 to 29 in e634bf2
| Factory__L1SimpleStorage = new ContractFactory( | |
| simpleStorageJson.abi, | |
| simpleStorageJson.bytecode, | |
| env.l1Wallet | |
| ) |
This is not clean.
Describe the solution you'd like
It's cleaner to replace this with the functionality already provided by the hardhat-ethers plugin. Simply import ethers from hardhat:
import { ethers } from 'hardhat'Then import the factory from ethers:
const SimpleStorageFactory = await ethers.getContractFactory('SimpleStorage')Doing this allows us to remove the long (and brittle) JSON imports. Please check other .spec.ts files within integration-tests/test to see if there are other places where this can also be fixed. ❤️