get token when using import

pull/1324/head
filip mertens 3 years ago
parent c685252858
commit 340d78000d
  1. 4
      apps/remix-ide/src/app.js
  2. 5
      libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts
  3. 4
      libs/remix-url-resolver/src/resolve.ts

@ -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
}

Loading…
Cancel
Save