Skip to content

Add Solidity Wizard API function to get versioned remappings #695

@ericglau

Description

@ericglau

Overview

In the programmatic API, the print function creates a contract with imports that are not versioned. For the reasons described in #692 (comment), these should remain unversioned, but callers such as Remix should add remappings to pin dependencies to specific versions.


Enhancement Request

Provide function(s) in the API that when given specific contract options, returns remappings that map unversioned import prefixes to versioned import prefixes.

For example, the interface may look something like:

getVersionedRemappings: (opts?: Options) => string[];

When opts.upgradeable is falsy, this should return a string array with one element, e.g.:

[
  "@openzeppelin/contracts/=@openzeppelin/[email protected]/"
]

When opts.upgradeable is truthy, this should return a string array with two elements (for both non-upgradeable and upgradeable libraries), e.g.:

[
  "@openzeppelin/contracts/=@openzeppelin/[email protected]/",
  "@openzeppelin/contracts-upgradeable/=@openzeppelin/[email protected]/"
]

Callers such as Remix should append these elements as lines in remappings.txt. End users can update the versions in that file if they want their code to use newer versions of OpenZeppelin Contracts, when new versions are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions