NethermindEth/zksync-remix-plugin

Refactor the compilation UX to distinguish between "single file compilation" and "project compilation"

Closed this issue · 4 comments

Refactor the Compile feature to follow the requirements mentioned below:

  • Have 2 buttons: "Compile <>" and "Compile project"

  • The "Compile <>" button:

    • should become enabled when a valid .sol file is selected anywhere in the workspace.
    • when enabled, the button's label should include the file name (eg. "Compile Storage.sol")
    • when pressed,
      • the whole workspace is to be uploaded to backend
      • Hardhat single file compilation (hardhat compile ./Storage.sol) shall be executed
      • results will be returned back to UI

    Note: this feature requires backend API change: we add an optional parameter to specify the location of the single file selected for compilation (call it target_path), which if specified implies the "single file compilation' Hardhat call. Eg. if a file in root is selected, pass ./, if a file in deps folder is selected, pass ./deps)

  • The "Compile project" button:

    • should become enabled when the workspace selected is a valid Hardhat project (ie. follows Hardhat folder convention)
    • when pressed:
      • if the folder structure follows Hardhat convention the whole workspace shall be uploaded into the compilation API
    • Hardhat compilation will be triggered on the contracts (hardhat compile command)
    • Results will be fetched back to UI
      • Resulting contracts will be listed in Deploy panel and can be selected for deployment
      • If we have multiple contracts wit the same name, those "duplicating" names will be
        • labelled with additional info (ContractName (<file_name>)) in the item
        • (Priority 2) ...and tooltip showing full path (<path>/<file_name>)
    • A warning (colour coded) appears in console: "
    Note: only files in /contracts/* folder structure are included in project compilation
    Any smart contracts defined in following files will not be available for deployment:
      - file1.sol
      - file2.sol
      - file3.sol
      - ...

#127 Addresses all the listed items in the issue description except:

If we have multiple contracts wit the same name, those "duplicating" names will be
labelled with additional info (ContractName (<file_name>)) in the item
(Priority 2) ...and tooltip showing full path (<path>/<file_name>)

Upon closer examination of the codebase, it appears this feature should be implemented as a separate issue. It requires careful state modifications that are closely tied to the deploy contract functionality. For the sake of avoiding unintended side effects, it's recommended to handle this as a distinct task.

Looking forward to this update. Seems a lot of people are still having friction with the warning.

We have added updates on our side as well.

Fixed as part of 0.4.2 release.

Now there are two Compile options in the plugin:

  1. Compile Project: Follows hardhat directory structure and compiles all contracts present in contracts directory.
  2. Single file compilation: Select a solidity file from workspace and compile it by clicking Compile <file-name> button.

Very helpful!