aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-08-05 04:26:03 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-08-05 04:26:03 +0800
commit479abadaa7dc59dc900cb35e897e0f164e3bb345 (patch)
tree07ea368e21d9c8277828e76e975f4671270b10a4 /app/scripts
parent0ae5305822b86e43c7921c53456a4042b4bc8af6 (diff)
parent106cbc133f26606449746587d4a33a3b8fb3f727 (diff)
downloadtangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar.gz
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar.bz2
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar.lz
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar.xz
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.tar.zst
tangerine-wallet-browser-479abadaa7dc59dc900cb35e897e0f164e3bb345.zip
Merge branch 'master' into usd-conversion
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/chromereload.js1
-rw-r--r--app/scripts/config.js2
-rw-r--r--app/scripts/contentscript.js33
-rw-r--r--app/scripts/lib/config-manager.js4
-rw-r--r--app/scripts/lib/extension-instance.js25
-rw-r--r--app/scripts/metamask-controller.js1
6 files changed, 51 insertions, 15 deletions
diff --git a/app/scripts/chromereload.js b/app/scripts/chromereload.js
index cd85a8114..88333ba8a 100644
--- a/app/scripts/chromereload.js
+++ b/app/scripts/chromereload.js
@@ -30,7 +30,6 @@
// }
// };
-const extension = require('./lib/extension')
window.LiveReloadOptions = { host: 'localhost' };
(function e (t, n, r) { function s (o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require === 'function' && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); var f = new Error("Cannot find module '" + o + "'"); throw f.code = 'MODULE_NOT_FOUND', f } var l = n[o] = {exports: {}}; t[o][0].call(l.exports, function (e) { var n = t[o][1][e]; return s(n ? n : e) }, l, l.exports, e, t, n, r) } return n[o].exports } var i = typeof require === 'function' && require; for (var o = 0; o < r.length; o++)s(r[o]); return s })({1: [function (require, module, exports) {
diff --git a/app/scripts/config.js b/app/scripts/config.js
index f26e6778d..5f6ffd936 100644
--- a/app/scripts/config.js
+++ b/app/scripts/config.js
@@ -1,12 +1,14 @@
const MAINET_RPC_URL = 'https://mainnet.infura.io/'
const TESTNET_RPC_URL = 'https://morden.infura.io/'
const DEFAULT_RPC_URL = TESTNET_RPC_URL
+const CLASSIC_RPC_URL = 'https://mainnet-nf.infura.io/'
module.exports = {
network: {
default: DEFAULT_RPC_URL,
mainnet: MAINET_RPC_URL,
testnet: TESTNET_RPC_URL,
+ classic: CLASSIC_RPC_URL,
},
}
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index 0ffe93e3c..1eb04059d 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -3,19 +3,37 @@ const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
const extension = require('./lib/extension')
+const fs = require('fs')
+const path = require('path')
+const inpageText = fs.readFileSync(path.join(__dirname + '/inpage.js')).toString()
+
+// Eventually this streaming injection could be replaced with:
+// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
+//
+// But for now that is only Firefox
+// If we create a FireFox-only code path using that API,
+// MetaMask will be much faster loading and performant on Firefox.
+
if (shouldInjectWeb3()) {
setupInjection()
setupStreams()
}
function setupInjection(){
- // inject in-page script
- var scriptTag = document.createElement('script')
- scriptTag.src = extension.extension.getURL('scripts/inpage.js')
- scriptTag.onload = function () { this.parentNode.removeChild(this) }
- var container = document.head || document.documentElement
- // append as first child
- container.insertBefore(scriptTag, container.children[0])
+ try {
+
+ // inject in-page script
+ var scriptTag = document.createElement('script')
+ scriptTag.src = extension.extension.getURL('scripts/inpage.js')
+ scriptTag.textContent = inpageText
+ scriptTag.onload = function () { this.parentNode.removeChild(this) }
+ var container = document.head || document.documentElement
+ // append as first child
+ container.insertBefore(scriptTag, container.children[0])
+
+ } catch (e) {
+ console.error('Metamask injection failed.', e)
+ }
}
function setupStreams(){
@@ -44,7 +62,6 @@ function setupStreams(){
pluginStream.on('close', function () {
reloadStream.write({ method: 'reset' })
})
-
}
function shouldInjectWeb3(){
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 8d250e555..9c37a2c6f 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -5,6 +5,7 @@ const rp = require('request-promise')
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
+const CLASSIC_RPC = MetamaskConfig.network.classic
/* The config-manager is a convenience object
* wrapping a pojo-migrator.
@@ -145,6 +146,9 @@ ConfigManager.prototype.getCurrentRpcAddress = function () {
case 'testnet':
return TESTNET_RPC
+ case 'classic':
+ return CLASSIC_RPC
+
default:
return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC
}
diff --git a/app/scripts/lib/extension-instance.js b/app/scripts/lib/extension-instance.js
index eeab6c6d0..eb3b8a1e9 100644
--- a/app/scripts/lib/extension-instance.js
+++ b/app/scripts/lib/extension-instance.js
@@ -24,14 +24,27 @@ const apis = [
function Extension () {
const _this = this
- let global = window
-
- if (window.chrome) {
- global = window.chrome
- }
apis.forEach(function (api) {
- _this[api] = global[api]
+
+ _this[api] = null
+
+ try {
+ if (chrome[api]) {
+ _this[api] = chrome[api]
+ }
+ } catch (e) {}
+
+ try {
+ if (window[api]) {
+ _this[api] = window[api]
+ }
+ } catch (e) {}
+
+ try {
+ _this.api = browser.extension[api]
+ } catch (e) {}
+
})
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 613484ffb..45305ee8f 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -170,6 +170,7 @@ module.exports = class MetamaskController {
function configToPublic (state) {
return {
provider: state.provider,
+ selectedAddress: state.selectedAccount,
}
}
// dump obj into store