diff options
Merge branch 'master' into uiFixes
Diffstat (limited to 'app')
-rw-r--r-- | app/images/ethereum-network.jpg | bin | 0 -> 10807 bytes | |||
-rw-r--r-- | app/images/morden-test-network.jpg | bin | 0 -> 10517 bytes | |||
-rw-r--r-- | app/images/no-connection.jpg | bin | 0 -> 6946 bytes | |||
-rw-r--r-- | app/images/unknown-private-network.jpg | bin | 0 -> 3962 bytes | |||
-rw-r--r-- | app/manifest.json | 2 | ||||
-rw-r--r-- | app/scripts/background.js | 21 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 27 | ||||
-rw-r--r-- | app/scripts/lib/notifications.js | 43 |
8 files changed, 65 insertions, 28 deletions
diff --git a/app/images/ethereum-network.jpg b/app/images/ethereum-network.jpg Binary files differnew file mode 100644 index 000000000..61cb000ed --- /dev/null +++ b/app/images/ethereum-network.jpg diff --git a/app/images/morden-test-network.jpg b/app/images/morden-test-network.jpg Binary files differnew file mode 100644 index 000000000..458708c78 --- /dev/null +++ b/app/images/morden-test-network.jpg diff --git a/app/images/no-connection.jpg b/app/images/no-connection.jpg Binary files differnew file mode 100644 index 000000000..a5d21242b --- /dev/null +++ b/app/images/no-connection.jpg diff --git a/app/images/unknown-private-network.jpg b/app/images/unknown-private-network.jpg Binary files differnew file mode 100644 index 000000000..b8a5a9bbf --- /dev/null +++ b/app/images/unknown-private-network.jpg diff --git a/app/manifest.json b/app/manifest.json index 5b1be504d..ce157bdf3 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "Metamask", - "version": "2.1.0", + "version": "2.2.0", "manifest_version": 2, "description": "__MSG_appDescription__", "icons": { diff --git a/app/scripts/background.js b/app/scripts/background.js index bfd1fc92b..f64209ecc 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -76,13 +76,20 @@ var providerOpts = { var provider = MetaMaskProvider(providerOpts) var web3 = new Web3(provider) idStore.web3 = web3 -idStore.getNetwork(3) +idStore.getNetwork() // log new blocks provider.on('block', function(block){ console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex')) + + // Check network when restoring connectivity: + if (idStore._currentState.network === 'loading') { + idStore.getNetwork() + } }) +provider.on('error', idStore.getNetwork.bind(idStore)) + var ethStore = new EthStore(provider) idStore.setStore(ethStore) @@ -145,7 +152,7 @@ function setupPublicConfig(stream){ } function setupProviderConnection(stream, originDomain){ - + stream.on('data', function onRpcRequest(payload){ // Append origin to rpc payload payload.origin = originDomain @@ -195,6 +202,8 @@ function setupControllerConnection(stream){ exportAccount: idStore.exportAccount.bind(idStore), revealAccount: idStore.revealAccount.bind(idStore), saveAccountLabel: idStore.saveAccountLabel.bind(idStore), + tryPassword: idStore.tryPassword.bind(idStore), + recoverSeed: idStore.recoverSeed.bind(idStore), }) stream.pipe(dnode).pipe(stream) dnode.on('remote', function(remote){ @@ -246,7 +255,7 @@ function newUnsignedTransaction(txParams, cb){ }) var txId = idStore.addUnconfirmedTransaction(txParams, cb) } else { - addUnconfirmedTx(txParams, cb) + addUnconfirmedTx(txParams, cb) } } @@ -258,7 +267,7 @@ function newUnsignedMessage(msgParams, cb){ }) var msgId = idStore.addUnconfirmedMessage(msgParams, cb) } else { - addUnconfirmedMsg(msgParams, cb) + addUnconfirmedMsg(msgParams, cb) } } @@ -290,13 +299,13 @@ function addUnconfirmedMsg(msgParams, cb){ function setRpcTarget(rpcTarget){ configManager.setRpcTarget(rpcTarget) chrome.runtime.reload() - idStore.getNetwork(3) // 3 retry attempts + idStore.getNetwork() } function setProviderType(type) { configManager.setProviderType(type) chrome.runtime.reload() - idStore.getNetwork(3) + idStore.getNetwork() } function useEtherscanProvider() { diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 4ce4fd6f2..33d842d54 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -59,6 +59,13 @@ IdentityStore.prototype.createNewVault = function(password, entropy, cb){ }) } +IdentityStore.prototype.recoverSeed = function(cb){ + configManager.setShowSeedWords(true) + if (!this._idmgmt) return cb(new Error('Unauthenticated. Please sign in.')) + var seedWords = this._idmgmt.getSeed() + cb(null, seedWords) +} + IdentityStore.prototype.recoverFromSeed = function(password, seed, cb){ this._createIdmgmt(password, seed, null, (err) => { if (err) return cb(err) @@ -130,16 +137,22 @@ IdentityStore.prototype.revealAccount = function(cb) { cb(null) } -IdentityStore.prototype.getNetwork = function(tries) { - if (tries === 0) { - this._currentState.network = 'error' - return +IdentityStore.prototype.getNetwork = function(err) { + + if (err) { + this._currentState.network = 'loading' + this._didUpdate() } + this.web3.version.getNetwork((err, network) => { if (err) { - return this.getNetwork(tries - 1, cb) + this._currentState.network = 'loading' + return this._didUpdate() } + + console.log('web3.getNetwork returned ' + network) this._currentState.network = network + this._didUpdate() }) } @@ -150,7 +163,7 @@ IdentityStore.prototype.setLocked = function(cb){ } IdentityStore.prototype.submitPassword = function(password, cb){ - this._tryPassword(password, (err) => { + this.tryPassword(password, (err) => { if (err) return cb(err) // load identities before returning... this._loadIdentities() @@ -366,7 +379,7 @@ IdentityStore.prototype._mayBeFauceting = function(i) { // keyStore managment - unlocking + deserialization // -IdentityStore.prototype._tryPassword = function(password, cb){ +IdentityStore.prototype.tryPassword = function(password, cb){ this._createIdmgmt(password, null, null, cb) } diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js index d011d778b..90edaea12 100644 --- a/app/scripts/lib/notifications.js +++ b/app/scripts/lib/notifications.js @@ -8,24 +8,35 @@ module.exports = { createMsgNotification: createMsgNotification, } -// notification button press -chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex){ - var handlers = notificationHandlers[notificationId] - if (buttonIndex === 0) { - handlers.confirm() - } else { - handlers.cancel() - } - chrome.notifications.clear(notificationId) -}) +setupListeners() + +function setupListeners(){ + + // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 + if (!chrome.notifications) return console.error('Chrome notifications API missing...') + + // notification button press + chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex){ + var handlers = notificationHandlers[notificationId] + if (buttonIndex === 0) { + handlers.confirm() + } else { + handlers.cancel() + } + chrome.notifications.clear(notificationId) + }) + + // notification teardown + chrome.notifications.onClosed.addListener(function(notificationId){ + delete notificationHandlers[notificationId] + }) -// notification teardown -chrome.notifications.onClosed.addListener(function(notificationId){ - delete notificationHandlers[notificationId] -}) +} // creation helper function createUnlockRequestNotification(opts){ + // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 + if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = 'An Ethereum app has requested a signature. Please unlock your account.' var id = createId() @@ -39,6 +50,8 @@ function createUnlockRequestNotification(opts){ } function createTxNotification(opts){ + // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 + if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = [ 'Submitted by '+opts.txParams.origin, 'to: '+uiUtils.addressSummary(opts.txParams.to), @@ -67,6 +80,8 @@ function createTxNotification(opts){ } function createMsgNotification(opts){ + // guard for chrome bug https://github.com/MetaMask/metamask-plugin/issues/236 + if (!chrome.notifications) return console.error('Chrome notifications API missing...') var message = [ 'Submitted by '+opts.msgParams.origin, 'to be signed by: '+uiUtils.addressSummary(opts.msgParams.from), |