aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-09-07 06:29:36 +0800
committerDan Finlay <dan@danfinlay.com>2016-09-07 06:29:36 +0800
commit58a8f02294eb1079d92cdf1e6d05a74a224029c3 (patch)
treefb723445e877bc316b060edcbe76284edf05f889 /app/scripts
parentb2ebb6032d3f99eb0e9eb90364a0cd95c7775bde (diff)
parent095a40e33d40bc02ef6a6b7379eb6c90e0b4c3d8 (diff)
downloadtangerine-wallet-browser-58a8f02294eb1079d92cdf1e6d05a74a224029c3.tar.gz
tangerine-wallet-browser-58a8f02294eb1079d92cdf1e6d05a74a224029c3.tar.zst
tangerine-wallet-browser-58a8f02294eb1079d92cdf1e6d05a74a224029c3.zip
Merge branch 'master' into ModularFiatBalance
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/lib/inpage-provider.js5
-rw-r--r--app/scripts/lib/notifications.js42
-rw-r--r--app/scripts/metamask-controller.js10
3 files changed, 37 insertions, 20 deletions
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index 3b7d76c7d..4f9fa1a7d 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -80,7 +80,8 @@ MetamaskInpageProvider.prototype.send = function (payload) {
// throw not-supported Error
default:
- var message = 'The MetaMask Web3 object does not support synchronous methods. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#all-async---think-of-metamask-as-a-light-client for details.'
+ var message = 'The MetaMask Web3 object does not support synchronous methods like ' + payload.method +
+ '. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#all-async---think-of-metamask-as-a-light-client for details.'
throw new Error(message)
}
@@ -131,4 +132,4 @@ function eachJsonMessage(payload, transformFn){
} else {
return transformFn(payload)
}
-} \ No newline at end of file
+}
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index df4fe73dd..4e3f7558c 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -9,20 +9,26 @@ module.exports = notifications
window.METAMASK_NOTIFIER = notifications
function show () {
- getWindows((windows) => {
+ getPopup((err, popup) => {
+ if (err) throw err
- if (windows.length > 0) {
- const win = windows[0]
- return extension.windows.update(win.id, { focused: true })
- }
+ if (popup) {
+
+ // bring focus to existing popup
+ extension.windows.update(popup.id, { focused: true })
+
+ } else {
- extension.windows.create({
- url: 'notification.html',
- type: 'popup',
- focused: true,
- width: 360,
- height: 500,
- })
+ // create new popup
+ extension.windows.create({
+ url: 'notification.html',
+ type: 'popup',
+ focused: true,
+ width: 360,
+ height: 500,
+ })
+
+ }
})
}
@@ -38,19 +44,19 @@ function getWindows(cb) {
}
function getPopup(cb) {
- getWindows((windows) => {
- cb(getPopupIn(windows))
+ getWindows((err, windows) => {
+ if (err) throw err
+ cb(null, getPopupIn(windows))
})
}
function getPopupIn(windows) {
- return windows ? windows.find((win) => {
- return win.type === 'popup'
- }) : null
+ return windows ? windows.find((win) => win.type === 'popup') : null
}
function closePopup() {
- getPopup((popup) => {
+ getPopup((err, popup) => {
+ if (err) throw err
if (!popup) return
extension.windows.remove(popup.id, console.error)
})
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index e94db2dfd..83827ec76 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -199,6 +199,9 @@ module.exports = class MetamaskController {
const idStore = this.idStore
var state = idStore.getState()
+ let err = this.enforceTxValidations(txParams)
+ if (err) return onTxDoneCb(err)
+
// It's locked
if (!state.isUnlocked) {
@@ -216,6 +219,13 @@ module.exports = class MetamaskController {
}
}
+ enforceTxValidations (txParams) {
+ if (txParams.value.indexOf('-') === 0) {
+ const msg = `Invalid transaction value of ${txParams.value} not a positive number.`
+ return new Error(msg)
+ }
+ }
+
newUnsignedMessage (msgParams, cb) {
var state = this.idStore.getState()
if (!state.isUnlocked) {