0

I will try to clarify my questions with visual aid.

My Usual Import

The picure above is how I usually import contracts. For example, I import Both C and B contracts to A, even though B already imports C too.

Recently however, I figured out that a diffrent approach would resault with the same functionality (Picture below)

Works the same

It seems that because B had already imported C, it now containts its functionality. Thus I dont have to import both B and C to A, just the B contract will do (Picture below)

New approach

My question is this: What is the right approach, and what are benefits/downsides to each (if there are any). The picures here are simplifications. But in my real project I have dozen contracts, of which many import the other ones. So there is a lot of "import duplications" therefor this seemed like a prudent question to ask.

1

1 Answer 1

0

Since solidity 0.8.x you can do

import { contractA } from "contract/path/1";
import { contractB } from "contract/path/2";

This will prevent the shadow import of contractB if it is also used in contracA

1
  • This code should be in which contract?
    – Sky
    Jan 12, 2022 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.