Skip to content

Fix the imports from OpenZeppelin in the sample code so Remix can compile #454

Closed

Description

@hcheng826

Hi Ethernaut contributors,

Thanks for the great project! I've learned a lot from it! One experience I have is that for some levels, the Solidity code showing in the level instruction cannot directly compile, since it's importing the OpenZeppelin code from a relative path.

Some examples: Fallout imports SafeMath, Dex imports ERC20, PuzzleWallet imports UpgradableProxy, etc. The user needs to find the correct version of the package to import, in order to make it compile on Remix.

I can open a PR and try to fix the path and make it compile for Factory and Remix. Let me know if you want me to work on this. Thanks!

Activity

  1. moved this from 📋 Backlog to No status in Ethernaut Developmenton Dec 13, 2022
  2. moved this from 📋 To Do to Backlog in Ethernaut Developmenton Dec 13, 2022
  3. xaler5 commented on Dec 20, 2022

    @xaler5
    Collaborator

    Hey thanks for raising this up. Happy to review any PR you might create out of it, how do you think to solve this ?
    @hcheng826

  4. hcheng826 commented on Dec 21, 2022

    @hcheng826
    Author

    Thanks for the reply!

    My thought is to replace the relative path to the actual npm package path.

    Example for the import in Fallout below (link)

    import 'openzeppelin-contracts-06/math/SafeMath.sol';
    

    maybe change it to the below according to the remapping in package.json (link)

    import 'npm:@openzeppelin/contracts@3.4.2/math/SafeMath.sol';
    

    Try if I can leverage the functionality on Remix for importing from npm registry: https://remix-ide.readthedocs.io/en/latest/import.html#import-from-npm

    Does it sound like a plan?

  5. xaler5 commented on Dec 25, 2022

    @xaler5
    Collaborator

    It sounds good but probably it would be better to have a "Try it on Remix" button or similar like the Solidity docs ?
    https://twitter.com/solidity_lang/status/1456233507538227207

  6. moved this from Backlog to 📋 To Do in Ethernaut Developmenton Jan 12, 2023
  7. CAPSLOCKDAVE commented on Jan 12, 2023

    @CAPSLOCKDAVE

    The replacement code from @hcheng826:
    import 'npm:@openzeppelin/contracts@3.4.2/math/SafeMath.sol';
    still failed to compile.
    I found success without the 'npm:' like so:
    import '@openzeppelin/contracts@3.4.2/math/SafeMath.sol';

  8. locked and limited conversation to collaborators on Jan 16, 2023
  9. converted this issue into a discussion #562 on Jan 16, 2023
  10. moved this from 📋 To Do to ✅ Done in Ethernaut Developmenton Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions