remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
remix-project/libs/remix-url-resolver
aniket-engg 83e54b77b1 solc dependency updated to 0.7.4 4 years ago
..
src moved libs into libs dir 4 years ago
tests Fix e2e tests 4 years ago
.eslintrc lint working for remix-url-resolver 4 years ago
.gitignore moved libs into libs dir 4 years ago
.npmignore moved libs into libs dir 4 years ago
README.md moved libs into libs dir 4 years ago
package.json solc dependency updated to 0.7.4 4 years ago
tsconfig.json Merge branch 'master' of https://github.com/ethereum/remix-project 4 years ago
tsconfig.lib.json lint working for remix-url-resolver 4 years ago
tslint.json moved libs into libs dir 4 years ago

README.md

Remix URL resolver engine

resolve(url, urlHandler)

Returns json object with exact same path as import statement.

Output

{
	content: 'pragma solidity ^0.5.0;\nimport "./mortal.sol";\n\ncontract Greeter is Mortal {\n    /* Define variable greeting of the type string */\n    string greeting;\n\n    /* This runs when the contract is executed */\n    constructor(string memory _greeting) public {\n        greeting = _greeting;\n    }\n\n    /* Main function */\n    function greet() public view returns (string memory) {\n        return greeting;\n    }\n}\n',
	cleanURL: '../greeter.sol',
	type: 'local'
}

Usage

resolve(url, urlHandler) function should be called from within handleImportCb function of solc.compile(input, handleImportCb).

import { RemixURLResolver } from 'remix-url-resolver'

const urlResolver = new RemixURLResolver()
const fileName: string = '../greeter.sol'
urlResolver.resolve(fileName, urlHandler)
	.then((sources: object) => {
		console.log(sources)
	})
	.catch((e: Error) => {
		throw e
	})

References