From 27c6efddfd3fdc663e79705469901b867530c69e Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 19 Feb 2018 11:33:25 +0100 Subject: [PATCH 1/3] fix import external --- src/app.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/app.js b/src/app.js index 600d56a447..2bc7cea06b 100644 --- a/src/app.js +++ b/src/app.js @@ -217,6 +217,21 @@ This instance of Remix you are visiting WILL NOT BE UPDATED.\n Please make a backup of your contracts and start using http://remix.ethereum.org`) } + function importExternal (url, cb) { + handleImports.import(url, + (loadingMsg) => { + $('#output').append($('
').append($('
').text(loadingMsg)))
+      },
+      (error, content, cleanUrl, type, url) => {
+        if (!error) {
+          filesProviders[type].addReadOnly(cleanUrl, content, url)
+          cb(null, content)
+        } else {
+          cb(error)
+        }
+      })
+  }
+
   // ----------------- Compiler -----------------
   var compiler = new Compiler((url, cb) => {
     var provider = fileManager.fileProviderOf(url)
@@ -226,22 +241,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
         if (exist) {
           return provider.get(url, cb)
         } else {
-          return cb('Unable to import "' + url + '": File not found')
+          importExternal(url, cb)
         }
       })
     } else {
-      handleImports.import(url,
-      (loadingMsg) => {
-        $('#output').append($('
').append($('
').text(loadingMsg)))
-      },
-      (error, content, cleanUrl, type, url) => {
-        if (!error) {
-          filesProviders[type].addReadOnly(cleanUrl, content, url)
-          cb(null, content)
-        } else {
-          cb(error)
-        }
-      })
+      importExternal(url, cb)
     }
   })
   var offsetToLineColumnConverter = new OffsetToLineColumnConverter(compiler.event)

From 8af128557f906371a53faf4360dbcd064043414c Mon Sep 17 00:00:00 2001
From: yann300 
Date: Tue, 20 Feb 2018 18:53:34 +0100
Subject: [PATCH 2/3] replace jquery by tooltip

---
 src/app.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/app.js b/src/app.js
index 2bc7cea06b..e844b3c332 100644
--- a/src/app.js
+++ b/src/app.js
@@ -220,7 +220,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
   function importExternal (url, cb) {
     handleImports.import(url,
       (loadingMsg) => {
-        $('#output').append($('
').append($('
').text(loadingMsg)))
+        toolTip(loadingMsg)
       },
       (error, content, cleanUrl, type, url) => {
         if (!error) {

From e72185730991bdf73f9190baf8544c932aa71d06 Mon Sep 17 00:00:00 2001
From: yann300 
Date: Tue, 20 Feb 2018 18:54:22 +0100
Subject: [PATCH 3/3] cache previously added import

---
 src/app/compiler/compiler-imports.js | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/app/compiler/compiler-imports.js b/src/app/compiler/compiler-imports.js
index 9730f9b046..3a09141907 100644
--- a/src/app/compiler/compiler-imports.js
+++ b/src/app/compiler/compiler-imports.js
@@ -4,6 +4,7 @@ var swarmgw = require('swarmgw')
 var request = require('request')
 
 module.exports = {
+  previouslyHandled: {}, // cache import so we don't make the request at each compilation.
   handleGithubCall: function (root, path, cb) {
     return request.get(
       {
@@ -61,6 +62,11 @@ module.exports = {
   },
 
   import: function (url, loadingCb, cb) {
+    var self = this
+    var imported = this.previouslyHandled[url]
+    if (imported) {
+      return cb(null, imported.content, imported.cleanUrl, imported.type, url)
+    }
     var handlers = this.handlers()
 
     var found = false
@@ -79,7 +85,11 @@ module.exports = {
             cb('Unable to import "' + cleanUrl + '": ' + err)
             return
           }
-
+          self.previouslyHandled[url] = {
+            content: content,
+            cleanUrl: cleanUrl,
+            type: handler.type
+          }
           cb(null, content, cleanUrl, handler.type, url)
         })
       }