aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas <thomas.b.huang@gmail.com>2018-06-19 03:37:01 +0800
committerThomas <thomas.b.huang@gmail.com>2018-06-19 03:37:01 +0800
commitea0dcdd3124ec65d3145f0ac7790a6172603d88c (patch)
treeb071efe391d00f40805bb36a5c0f137eca14b8b7 /app
parentef31eeccb244592aa17dd677e854e106c9bb5848 (diff)
parentd910c35e90d0d725e86b7743538b6c6c429f26f0 (diff)
downloadtangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar.gz
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar.bz2
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar.lz
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar.xz
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.tar.zst
tangerine-wallet-browser-ea0dcdd3124ec65d3145f0ac7790a6172603d88c.zip
Merge branch 'develop' into v4.8.0
Diffstat (limited to 'app')
-rw-r--r--app/_locales/en/messages.json6
-rw-r--r--app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js2
-rw-r--r--app/scripts/controllers/transactions/lib/recipient-blacklist-config.json14
-rw-r--r--app/scripts/controllers/transactions/lib/recipient-blacklist.js17
-rw-r--r--app/scripts/inpage.js6
-rw-r--r--app/scripts/lib/auto-reload.js61
-rw-r--r--app/scripts/notice-controller.js9
7 files changed, 97 insertions, 18 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index 457c3c3b1..2579da87d 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -146,6 +146,9 @@
"copy": {
"message": "Copy"
},
+ "copyContractAddress": {
+ "message": "Copy Contract Address"
+ },
"copyToClipboard": {
"message": "Copy to clipboard"
},
@@ -955,6 +958,9 @@
"viewAccount": {
"message": "View Account"
},
+ "viewOnEtherscan": {
+ "message": "View on Etherscan"
+ },
"visitWebSite": {
"message": "Visit our web site"
},
diff --git a/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js b/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
index 84c6df1f0..e4df2367e 100644
--- a/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
+++ b/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
@@ -1,4 +1,4 @@
-const Config = require('./recipient-blacklist-config.json')
+const Config = require('./recipient-blacklist.js')
/** @module*/
module.exports = {
diff --git a/app/scripts/controllers/transactions/lib/recipient-blacklist-config.json b/app/scripts/controllers/transactions/lib/recipient-blacklist-config.json
deleted file mode 100644
index b348eb72e..000000000
--- a/app/scripts/controllers/transactions/lib/recipient-blacklist-config.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "blacklist": [
- "0x627306090abab3a6e1400e9345bc60c78a8bef57",
- "0xf17f52151ebef6c7334fad080c5704d77216b732",
- "0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef",
- "0x821aea9a577a9b44299b9c15c88cf3087f3b5544",
- "0x0d1d4e623d10f9fba5db95830f7d3839406c6af2",
- "0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e",
- "0x2191ef87e392377ec08e7c08eb105ef5448eced5",
- "0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5",
- "0x6330a553fc93768f612722bb8c2ec78ac90b3bbc",
- "0x5aeda56215b167893e80b4fe645ba6d5bab767de"
- ]
-}
diff --git a/app/scripts/controllers/transactions/lib/recipient-blacklist.js b/app/scripts/controllers/transactions/lib/recipient-blacklist.js
new file mode 100644
index 000000000..08e1a2ccd
--- /dev/null
+++ b/app/scripts/controllers/transactions/lib/recipient-blacklist.js
@@ -0,0 +1,17 @@
+module.exports = {
+ 'blacklist': [
+ // IDEX phisher
+ '0x9bcb0A9d99d815Bb87ee3191b1399b1Bcc46dc77',
+ // Ganache default seed phrases
+ '0x627306090abab3a6e1400e9345bc60c78a8bef57',
+ '0xf17f52151ebef6c7334fad080c5704d77216b732',
+ '0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef',
+ '0x821aea9a577a9b44299b9c15c88cf3087f3b5544',
+ '0x0d1d4e623d10f9fba5db95830f7d3839406c6af2',
+ '0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e',
+ '0x2191ef87e392377ec08e7c08eb105ef5448eced5',
+ '0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5',
+ '0x6330a553fc93768f612722bb8c2ec78ac90b3bbc',
+ '0x5aeda56215b167893e80b4fe645ba6d5bab767de',
+ ],
+}
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 070f5d247..7dd7fda02 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -3,6 +3,7 @@ cleanContextForImports()
require('web3/dist/web3.min.js')
const log = require('loglevel')
const LocalMessageDuplexStream = require('post-message-stream')
+const setupDappAutoReload = require('./lib/auto-reload.js')
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
restoreContextAfterImports()
@@ -38,7 +39,11 @@ web3.setProvider = function () {
}
log.debug('MetaMask - injected web3')
+setupDappAutoReload(web3, inpageProvider.publicConfigStore)
+
// export global web3, with usage-detection and deprecation warning
+
+/* TODO: Uncomment this area once auto-reload.js has been deprecated:
let hasBeenWarned = false
global.web3 = new Proxy(web3, {
get: (_web3, key) => {
@@ -55,6 +60,7 @@ global.web3 = new Proxy(web3, {
_web3[key] = value
},
})
+*/
// set web3 defaultAccount
inpageProvider.publicConfigStore.subscribe(function (state) {
diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js
new file mode 100644
index 000000000..cce31c3d2
--- /dev/null
+++ b/app/scripts/lib/auto-reload.js
@@ -0,0 +1,61 @@
+module.exports = setupDappAutoReload
+
+function setupDappAutoReload (web3, observable) {
+ // export web3 as a global, checking for usage
+ let hasBeenWarned = false
+ let reloadInProgress = false
+ let lastTimeUsed
+ let lastSeenNetwork
+
+ global.web3 = new Proxy(web3, {
+ get: (_web3, key) => {
+ // show warning once on web3 access
+ if (!hasBeenWarned && key !== 'currentProvider') {
+ console.warn('MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider \nhttps://github.com/MetaMask/faq/blob/master/detecting_metamask.md#web3-deprecation')
+ hasBeenWarned = true
+ }
+ // get the time of use
+ lastTimeUsed = Date.now()
+ // return value normally
+ return _web3[key]
+ },
+ set: (_web3, key, value) => {
+ // set value normally
+ _web3[key] = value
+ },
+ })
+
+ observable.subscribe(function (state) {
+ // if reload in progress, no need to check reload logic
+ if (reloadInProgress) return
+
+ const currentNetwork = state.networkVersion
+
+ // set the initial network
+ if (!lastSeenNetwork) {
+ lastSeenNetwork = currentNetwork
+ return
+ }
+
+ // skip reload logic if web3 not used
+ if (!lastTimeUsed) return
+
+ // if network did not change, exit
+ if (currentNetwork === lastSeenNetwork) return
+
+ // initiate page reload
+ reloadInProgress = true
+ const timeSinceUse = Date.now() - lastTimeUsed
+ // if web3 was recently used then delay the reloading of the page
+ if (timeSinceUse > 500) {
+ triggerReset()
+ } else {
+ setTimeout(triggerReset, 500)
+ }
+ })
+}
+
+// reload the page
+function triggerReset () {
+ global.location.reload()
+}
diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js
index e202043cf..2def4371e 100644
--- a/app/scripts/notice-controller.js
+++ b/app/scripts/notice-controller.js
@@ -13,12 +13,15 @@ module.exports = class NoticeController extends EventEmitter {
this.firstVersion = opts.firstVersion
this.version = opts.version
const initState = extend({
- noticesList: this._filterNotices(hardCodedNotices),
+ noticesList: [],
}, opts.initState)
this.store = new ObservableStore(initState)
+ // setup memStore
this.memStore = new ObservableStore({})
this.store.subscribe(() => this._updateMemstore())
this._updateMemstore()
+ // pull in latest notices
+ this.updateNoticesList()
}
getNoticesList () {
@@ -84,8 +87,8 @@ module.exports = class NoticeController extends EventEmitter {
}
async _retrieveNoticeData () {
- // Placeholder for the API.
- return []
+ // Placeholder for remote notice API.
+ return hardCodedNotices
}
_updateMemstore () {