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 3f8024aae3 publish libs without peerDependencies in package.json 2 years ago
..
src Update axios version and bump url-resolver version 2 years ago
tests # This is a combination of 50 commits. 2 years ago
.eslintrc Use old eslint config 3 years ago
.gitignore moved libs into libs dir 4 years ago
.npmignore moved libs into libs dir 4 years ago
README.md Merge branch 'master' into master 3 years ago
package.json publish libs without peerDependencies in package.json 2 years ago
project.json update project.json 2 years ago
tsconfig.json Setup tsconfig.base.json 3 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

npm version npm npm GitHub contributions welcome

@remix-project/remix-url-resolver is a tool to handle import from different sources and resolve the content. It is used in Remix IDE to handle imports from GitHub, Swarm, IPFS and other URLs.

Installation

@remix-project/remix-url-resolver is an NPM package and can be installed using NPM as:

yarn add @remix-project/remix-url-resolver

How to use

@remix-project/remix-url-resolver exports:


export declare class RemixURLResolver {
    private previouslyHandled;
    gistAccessToken: string;
    constructor(gistToken?: string);
    /**
    * Handle an import statement based on github
    * @param root The root of the github import statement
    * @param filePath path of the file in github
    */
    handleGithubCall(root: string, filePath: string): Promise<HandlerResponse>;
    /**
    * Handle an import statement based on http
    * @param url The url of the import statement
    * @param cleanUrl
    */
    handleHttp(url: string, cleanUrl: string): Promise<HandlerResponse>;
    /**
    * Handle an import statement based on https
    * @param url The url of the import statement
    * @param cleanUrl
    */
    handleHttps(url: string, cleanUrl: string): Promise<HandlerResponse>;
    handleSwarm(url: string, cleanUrl: string): Promise<HandlerResponse>;
    /**
    * Handle an import statement based on IPFS
    * @param url The url of the IPFS import statement
    */
    handleIPFS(url: string): Promise<HandlerResponse>;
    getHandlers(): Handler[];
    resolve(filePath: string, customHandlers?: Handler[]): Promise<Imported>;
}

Usage

resolve(url, customHandlers) 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

Contribute

Please feel free to open an issue or a pull request.

In case you want to add some code, do have a look to our contribution guidelnes here. Reach us on Gitter in case of any queries.

License

MIT © 2018-21 Remix Team