diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-11-12 02:26:12 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-11-12 02:26:12 +0800 |
commit | 23263bec7d5100accd61f7648fd9355fc95e2bb7 (patch) | |
tree | 3c24f23655b5e1aad7102b603412d6fae70d5e43 /app/scripts/lib | |
parent | c664b8f11e32eaa7f8f1b46d4be938f2ebb74d35 (diff) | |
download | tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.gz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.bz2 tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.lz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.xz tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.tar.zst tangerine-wallet-browser-23263bec7d5100accd61f7648fd9355fc95e2bb7.zip |
Linting to the max.
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/auto-reload.js | 5 | ||||
-rw-r--r-- | app/scripts/lib/config-manager.js | 3 | ||||
-rw-r--r-- | app/scripts/lib/encryptor.js | 10 | ||||
-rw-r--r-- | app/scripts/lib/idStore-migrator.js | 6 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 8 | ||||
-rw-r--r-- | app/scripts/lib/inpage-provider.js | 8 | ||||
-rw-r--r-- | app/scripts/lib/is-popup-or-notification.js | 2 | ||||
-rw-r--r-- | app/scripts/lib/notifications.js | 12 |
8 files changed, 24 insertions, 30 deletions
diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js index 3c90905db..1302df35f 100644 --- a/app/scripts/lib/auto-reload.js +++ b/app/scripts/lib/auto-reload.js @@ -18,17 +18,16 @@ function setupDappAutoReload (web3) { return handleResetRequest - function handleResetRequest() { + function handleResetRequest () { resetWasRequested = true // ignore if web3 was not used if (!pageIsUsingWeb3) return // reload after short timeout setTimeout(triggerReset, 500) } - } // reload the page function triggerReset () { global.location.reload() -}
\ No newline at end of file +} diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index f50d95c12..0c5daa8e6 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -290,7 +290,7 @@ ConfigManager.prototype.getSalt = function () { return ('salt' in data) && data.salt } -ConfigManager.prototype.setSalt = function(salt) { +ConfigManager.prototype.setSalt = function (salt) { var data = this.getData() data.salt = salt this.setData(data) @@ -358,7 +358,6 @@ ConfigManager.prototype.updateConversionRate = function () { this.setConversionPrice(0) this.setConversionDate('N/A') }) - } ConfigManager.prototype.setConversionPrice = function (price) { diff --git a/app/scripts/lib/encryptor.js b/app/scripts/lib/encryptor.js index fe83b86dd..acfb418a1 100644 --- a/app/scripts/lib/encryptor.js +++ b/app/scripts/lib/encryptor.js @@ -42,7 +42,7 @@ function encryptWithKey (key, dataObj) { return global.crypto.subtle.encrypt({ name: 'AES-GCM', iv: vector, - }, key, dataBuffer).then(function(buf){ + }, key, dataBuffer).then(function (buf) { var buffer = new Uint8Array(buf) var vectorStr = encodeBufferToBase64(vector) var vaultStr = encodeBufferToBase64(buffer) @@ -63,13 +63,13 @@ function decryptWithKey (key, text) { const encryptedData = decodeBase64ToBuffer(parts[0]) const vector = decodeBase64ToBuffer(parts[1]) return crypto.subtle.decrypt({name: 'AES-GCM', iv: vector}, key, encryptedData) - .then(function(result){ + .then(function (result) { const decryptedData = new Uint8Array(result) const decryptedStr = convertArrayBufferViewtoString(decryptedData) const decryptedObj = JSON.parse(decryptedStr) return decryptedObj }) - .catch(function(reason) { + .catch(function (reason) { throw new Error('Incorrect password') }) } @@ -95,7 +95,7 @@ function convertArrayBufferViewtoString (buffer) { function keyFromPassword (password) { var passBuffer = convertStringToArrayBufferView(password) return global.crypto.subtle.digest('SHA-256', passBuffer) - .then(function (passHash){ + .then(function (passHash) { return global.crypto.subtle.importKey('raw', passHash, {name: 'AES-GCM'}, false, ['encrypt', 'decrypt']) }) } @@ -135,7 +135,7 @@ function encodeBufferToBase64 (buf) { function decodeBase64ToBuffer (base64) { var buf = new Uint8Array(atob(base64).split('') - .map(function(c) { + .map(function (c) { return c.charCodeAt(0) })) return buf diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js index 2d1826641..818364720 100644 --- a/app/scripts/lib/idStore-migrator.js +++ b/app/scripts/lib/idStore-migrator.js @@ -11,7 +11,7 @@ module.exports = class IdentityStoreMigrator { } } - oldSeedForPassword( password ) { + oldSeedForPassword (password) { const hasOldVault = this.hasOldVault() const configManager = this.configManager @@ -35,7 +35,7 @@ module.exports = class IdentityStoreMigrator { }) } - serializeVault() { + serializeVault () { const mnemonic = this.idStore._idmgmt.getSeed() const n = this.idStore._getAddresses().length @@ -45,7 +45,7 @@ module.exports = class IdentityStoreMigrator { } } - hasOldVault() { + hasOldVault () { const wallet = this.configManager.getWallet() return wallet } diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 390c8a8ab..2a46b1b5d 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -243,7 +243,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone ], didComplete) // perform static analyis on the target contract code - function analyzeForDelegateCall(cb){ + function analyzeForDelegateCall (cb) { if (txParams.to) { query.getCode(txParams.to, (err, result) => { if (err) return cb(err) @@ -256,16 +256,16 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone } } - function estimateGas(cb){ + function estimateGas (cb) { var estimationParams = extend(txParams) // 1 billion gas for estimation var gasLimit = '0x3b9aca00' estimationParams.gas = gasLimit - query.estimateGas(estimationParams, function(err, result){ + query.estimateGas(estimationParams, function (err, result) { if (err) return cb(err) if (result === estimationParams.gas) { txData.simulationFails = true - query.getBlockByNumber('latest', true, function(err, block){ + query.getBlockByNumber('latest', true, function (err, block) { if (err) return cb(err) txData.estimatedGas = block.gasLimit txData.txParams.gas = block.gasLimit diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index 052a8f5fe..6795f2bd4 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -39,7 +39,7 @@ function MetamaskInpageProvider (connectionStream) { self.idMap = {} // handle sendAsync requests via asyncProvider - self.sendAsync = function(payload, cb){ + self.sendAsync = function (payload, cb) { // rewrite request ids var request = eachJsonMessage(payload, (message) => { var newId = createRandomId() @@ -48,7 +48,7 @@ function MetamaskInpageProvider (connectionStream) { return message }) // forward to asyncProvider - asyncProvider.sendAsync(request, function(err, res){ + asyncProvider.sendAsync(request, function (err, res) { if (err) return cb(err) // transform messages to original ids eachJsonMessage(res, (message) => { @@ -119,7 +119,7 @@ function remoteStoreWithLocalStorageCache (storageKey) { return store } -function createRandomId(){ +function createRandomId () { const extraDigits = 3 // 13 time digits const datePart = new Date().getTime() * Math.pow(10, extraDigits) @@ -129,7 +129,7 @@ function createRandomId(){ return datePart + extraPart } -function eachJsonMessage(payload, transformFn){ +function eachJsonMessage (payload, transformFn) { if (Array.isArray(payload)) { return payload.map(transformFn) } else { diff --git a/app/scripts/lib/is-popup-or-notification.js b/app/scripts/lib/is-popup-or-notification.js index 5c38ac823..693fa8751 100644 --- a/app/scripts/lib/is-popup-or-notification.js +++ b/app/scripts/lib/is-popup-or-notification.js @@ -1,4 +1,4 @@ -module.exports = function isPopupOrNotification() { +module.exports = function isPopupOrNotification () { const url = window.location.href if (url.match(/popup.html$/)) { return 'popup' diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js index cd7535232..3db1ac6b5 100644 --- a/app/scripts/lib/notifications.js +++ b/app/scripts/lib/notifications.js @@ -15,12 +15,9 @@ function show () { if (err) throw err if (popup) { - // bring focus to existing popup extension.windows.update(popup.id, { focused: true }) - } else { - // create new popup extension.windows.create({ url: 'notification.html', @@ -29,12 +26,11 @@ function show () { width, height, }) - } }) } -function getWindows(cb) { +function getWindows (cb) { // Ignore in test environment if (!extension.windows) { return cb() @@ -45,14 +41,14 @@ function getWindows(cb) { }) } -function getPopup(cb) { +function getPopup (cb) { getWindows((err, windows) => { if (err) throw err cb(null, getPopupIn(windows)) }) } -function getPopupIn(windows) { +function getPopupIn (windows) { return windows ? windows.find((win) => { return (win && win.type === 'popup' && win.height === height && @@ -60,7 +56,7 @@ function getPopupIn(windows) { }) : null } -function closePopup() { +function closePopup () { getPopup((err, popup) => { if (err) throw err if (!popup) return |