get token when using import

pull/5370/head
filip mertens 4 years ago
parent 22bb7c365b
commit 1ff990f541
  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) 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(['mainPanel', 'menuicons', 'tabs'])
await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await appManager.activatePlugin(['home']) 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 queryParams = new QueryParams()
const params = queryParams.get() 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. 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 protocol = typeof window !== 'undefined' && window.location.protocol
const token = await this.call('settings', 'getGithubAccessToken') const token = await this.call('settings', 'getGithubAccessToken')
this.urlResolver = new RemixURLResolver(token, protocol) this.urlResolver.setGistToken(token, protocol)
} }
isRelativeImport (url) { isRelativeImport (url) {
@ -71,6 +71,7 @@ export class CompilerImports extends Plugin {
let resolved let resolved
try { try {
await this.setToken()
resolved = await this.urlResolver.resolve(url) resolved = await this.urlResolver.resolve(url)
const { content, cleanUrl, type } = resolved const { content, cleanUrl, type } = resolved
self.previouslyHandled[url] = { self.previouslyHandled[url] = {

@ -30,6 +30,10 @@ export class RemixURLResolver {
constructor (gistToken?: string, protocol = 'http:') { constructor (gistToken?: string, protocol = 'http:') {
this.previouslyHandled = {} this.previouslyHandled = {}
this.setGistToken(gistToken, protocol)
}
async setGistToken (gistToken?: string, protocol = 'http:') {
this.gistAccessToken = gistToken || '' this.gistAccessToken = gistToken || ''
this.protocol = protocol this.protocol = protocol
} }

Loading…
Cancel
Save