Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/remix-ide-e2e/src/tests/solidityImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ module.exports = {
.verifyContracts(['test15', 'ERC20'], { wait: 30000 })
},

'Test NPM Import (prefixed by `npm:` and remappings.txt), it should import from two different solidity version #group3': function (browser: NightwatchBrowser) {
browser
.setSolidityCompilerVersion('soljson-v0.8.30+commit.73712a01.js')
.waitForElementPresent({
selector: `//*[@data-id='compilerloaded' and @data-version='soljson-v0.8.30+commit.73712a01.js']`,
locateStrategy: 'xpath',
timeout: 120000
})
.clickLaunchIcon('filePanel')
.click('li[data-id="treeViewLitreeViewItemREADME.txt"')
.addFile('remappings.txt', sources[10]['remappings.txt'])
.addFile('Untitled11.sol', sources[10]['Untitled11.sol'])
.clickLaunchIcon('solidity')
.click('[data-id="compilerContainerCompileBtn"]')
.clickLaunchIcon('filePanel')
.verifyContracts(['Address', 'Strings'], { wait: 30000 })
},

'Test NPM Import (the version is specified in package.json) #group4': function (browser: NightwatchBrowser) {
browser
// clone https://github.com/yann300/remix-reward
Expand Down Expand Up @@ -208,5 +226,15 @@ const sources = [
"@module_remapping": "npm:@openzeppelin/contracts@^4.9.0"
}
}` }
},
{
'Untitled11.sol': { content: `import "@openzeppelin/contracts@5.0.2/utils/Strings.sol";
import "@openzeppelin/contracts@4.7.3/utils/Address.sol";` },
'remappings.txt': { content: `@openzeppelin/contracts@4.7.3/=npm:@openzeppelin/contracts@4.7.3/
@openzeppelin/contracts@4.8.3/=npm:@openzeppelin/contracts@4.8.3/
@openzeppelin/contracts@4.9.6/=npm:@openzeppelin/contracts@4.9.6/
@openzeppelin/contracts@5.0.2/=npm:@openzeppelin/contracts@5.0.2/
@openzeppelin/contracts@5.1.0/=npm:@openzeppelin/contracts@5.1.0/
` }
}
]
9 changes: 9 additions & 0 deletions libs/remix-url-resolver/src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ export class RemixURLResolver {
},
handle: (match) => this.handleV4PeriphGithub(match[0])
},
{
type: 'npm',
match: (url) => {
if (url && url.startsWith('npm:')) {
return [url.replace('npm:', '')]
}
},
handle: (match) => this.handleNpmImport(match[0])
},
{
type: 'npm',
match: (url) => { return /^[^/][^\n"?:*<>|]*$/g.exec(url) }, // match a typical relative path
Expand Down