Skip to content

Use hardhat-ethers for importing factories in integration tests #2016

@smartcontracts

Description

@smartcontracts

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:

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. ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions