Commit a6aa9f80 authored by 0mkar's avatar 0mkar

Merge branch 'remix-resolve' of github.com:ethereum/remix into remix-resolve

parents 88a8988a 141bef40
import axios from 'axios' import axios, { AxiosResponse } from 'axios'
import { Api, ModuleProfile, API } from 'remix-plugin' import { Api, ModuleProfile, API } from 'remix-plugin'
...@@ -42,24 +42,40 @@ export class RemixResolveApi implements API<RemixResolve> { ...@@ -42,24 +42,40 @@ export class RemixResolveApi implements API<RemixResolve> {
* @params root The root of the github import statement * @params root The root of the github import statement
* @params filePath path of the file in github * @params filePath path of the file in github
*/ */
handleGithubCall(root: string, filePath: string) { async handleGithubCall(root: string, filePath: string) {
return try {
let req: string = 'https://api.github.com/repos/' + root + '/contents/' + filePath
const response: AxiosResponse = await axios.get(req)
return Buffer.from(response.data.content, 'base64').toString()
} catch(e) {
throw e
}
} }
/** /**
* Handle an import statement based on http * Handle an import statement based on http
* @params url The url of the import statement * @params url The url of the import statement
* @params cleanURL * @params cleanURL
*/ */
handleHttp(url: string, cleanURL: string) { async handleHttp(url: string, _: string) {
return try {
const response: AxiosResponse = await axios.get(url)
return response.data
} catch(e) {
throw e
}
} }
/** /**
* Handle an import statement based on https * Handle an import statement based on https
* @params url The url of the import statement * @params url The url of the import statement
* @params cleanURL * @params cleanURL
*/ */
handleHttps(url: string, cleanURL: string) { async handleHttps(url: string, _: string) {
return try {
const response: AxiosResponse = await axios.get(url)
return response.data
} catch(e) {
throw e
}
} }
handleSwarm(url: string, cleanURL: string) { handleSwarm(url: string, cleanURL: string) {
return return
...@@ -75,15 +91,12 @@ export class RemixResolveApi implements API<RemixResolve> { ...@@ -75,15 +91,12 @@ export class RemixResolveApi implements API<RemixResolve> {
const req = 'https://gateway.ipfs.io/' + url const req = 'https://gateway.ipfs.io/' + url
// If you don't find greeter.sol on ipfs gateway use local // If you don't find greeter.sol on ipfs gateway use local
// const req = 'http://localhost:8080/' + url // const req = 'http://localhost:8080/' + url
const response = await axios.get(req) const response: AxiosResponse = await axios.get(req)
return response.data return response.data
} catch (e) { } catch (e) {
throw e throw e
} }
} }
handleLocal(root: string, filePath: string) {
return
}
getHandlers(): Handler[] { getHandlers(): Handler[] {
return [ return [
{ {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment