Commit 340d7800 authored by filip mertens's avatar filip mertens

get token when using import

parent c6852528
......@@ -460,11 +460,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
console.log('couldn\'t register iframe plugins', e.message)
}
await appManager.activatePlugin(['settings', 'contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await appManager.activatePlugin(['theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
await appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await appManager.activatePlugin(['home'])
await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'fetchAndCompile'])
await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport'])
const queryParams = new QueryParams()
const params = queryParams.get()
......
......@@ -22,10 +22,10 @@ export class CompilerImports extends Plugin {
this.previouslyHandled = {} // cache import so we don't make the request at each compilation.
}
async onActivation () {
async setToken () {
const protocol = typeof window !== 'undefined' && window.location.protocol
const token = await this.call('settings', 'getGithubAccessToken')
this.urlResolver = new RemixURLResolver(token, protocol)
this.urlResolver.setGistToken(token, protocol)
}
isRelativeImport (url) {
......@@ -71,6 +71,7 @@ export class CompilerImports extends Plugin {
let resolved
try {
await this.setToken()
resolved = await this.urlResolver.resolve(url)
const { content, cleanUrl, type } = resolved
self.previouslyHandled[url] = {
......
......@@ -30,6 +30,10 @@ export class RemixURLResolver {
constructor (gistToken?: string, protocol = 'http:') {
this.previouslyHandled = {}
this.setGistToken(gistToken, protocol)
}
async setGistToken (gistToken?: string, protocol = 'http:') {
this.gistAccessToken = gistToken || ''
this.protocol = protocol
}
......
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