aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-11-12 02:26:12 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-11-12 02:26:12 +0800
commit23263bec7d5100accd61f7648fd9355fc95e2bb7 (patch)
tree3c24f23655b5e1aad7102b603412d6fae70d5e43 /app
parentc664b8f11e32eaa7f8f1b46d4be938f2ebb74d35 (diff)
downloadtangerine-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')
-rw-r--r--app/scripts/contentscript.js14
-rw-r--r--app/scripts/inpage.js2
-rw-r--r--app/scripts/keyring-controller.js74
-rw-r--r--app/scripts/keyrings/hd.js27
-rw-r--r--app/scripts/keyrings/simple.js19
-rw-r--r--app/scripts/lib/auto-reload.js5
-rw-r--r--app/scripts/lib/config-manager.js3
-rw-r--r--app/scripts/lib/encryptor.js10
-rw-r--r--app/scripts/lib/idStore-migrator.js6
-rw-r--r--app/scripts/lib/idStore.js8
-rw-r--r--app/scripts/lib/inpage-provider.js8
-rw-r--r--app/scripts/lib/is-popup-or-notification.js2
-rw-r--r--app/scripts/lib/notifications.js12
-rw-r--r--app/scripts/metamask-controller.js23
-rw-r--r--app/scripts/popup-core.js4
-rw-r--r--app/scripts/popup.js2
16 files changed, 93 insertions, 126 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index e2a968ac9..ab64dc9fa 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -6,7 +6,7 @@ const extension = require('./lib/extension')
const fs = require('fs')
const path = require('path')
-const inpageText = fs.readFileSync(path.join(__dirname + '/inpage.js')).toString()
+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
@@ -20,9 +20,8 @@ if (shouldInjectWeb3()) {
setupStreams()
}
-function setupInjection(){
+function setupInjection () {
try {
-
// inject in-page script
var scriptTag = document.createElement('script')
scriptTag.src = extension.extension.getURL('scripts/inpage.js')
@@ -31,14 +30,12 @@ function setupInjection(){
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(){
-
+function setupStreams () {
// setup communication to page and plugin
var pageStream = new LocalMessageDuplexStream({
name: 'contentscript',
@@ -65,14 +62,13 @@ function setupStreams(){
mx.ignoreStream('provider')
mx.ignoreStream('publicConfig')
mx.ignoreStream('reload')
-
}
-function shouldInjectWeb3(){
+function shouldInjectWeb3 () {
return isAllowedSuffix(window.location.href)
}
-function isAllowedSuffix(testCase) {
+function isAllowedSuffix (testCase) {
var prohibitedTypes = ['xml', 'pdf']
var currentUrl = window.location.href
var currentRegex
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 85dd70b4d..9d6fc96de 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -43,7 +43,7 @@ reloadStream.once('data', triggerReload)
var pingChannel = inpageProvider.multiStream.createStream('pingpong')
var pingStream = new PingStream({ objectMode: true })
// wait for first successful reponse
-metamaskStream.once('_data', function(){
+metamaskStream.once('_data', function () {
pingStream.pipe(pingChannel).pipe(pingStream)
})
endOfStream(pingStream, triggerReload)
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 5d9dd51a4..b74d6cbfc 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -46,7 +46,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- getState() {
+ getState () {
const configManager = this.configManager
const address = configManager.getSelectedAccount()
const wallet = configManager.getWallet() // old style vault
@@ -72,18 +72,18 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- setStore(ethStore) {
+ setStore (ethStore) {
this.ethStore = ethStore
}
- createNewVaultAndKeychain(password, entropy, cb) {
+ createNewVaultAndKeychain (password, entropy, cb) {
this.createNewVault(password, entropy, (err) => {
if (err) return cb(err)
this.createFirstKeyTree(password, cb)
})
}
- createNewVaultAndRestore(password, seed, cb) {
+ createNewVaultAndRestore (password, seed, cb) {
if (typeof password !== 'string') {
return cb('Password must be text.')
}
@@ -114,7 +114,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- migrateAndGetKey(password) {
+ migrateAndGetKey (password) {
let key
const shouldMigrate = !!this.configManager.getWallet() && !this.configManager.getVault()
@@ -134,7 +134,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- createNewVault(password, entropy, cb) {
+ createNewVault (password, entropy, cb) {
const configManager = this.configManager
const salt = this.encryptor.generateSalt()
configManager.setSalt(salt)
@@ -151,7 +151,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- createFirstKeyTree(password, cb) {
+ createFirstKeyTree (password, cb) {
this.clearKeyrings()
this.addNewKeyring('HD Key Tree', {n: 1}, (err) => {
const firstKeyring = this.keyrings[0]
@@ -179,7 +179,7 @@ module.exports = class KeyringController extends EventEmitter {
this.configManager.setSeedWords(seedWords)
}
- submitPassword(password, cb) {
+ submitPassword (password, cb) {
this.migrateAndGetKey(password)
.then((key) => {
return this.unlockKeyrings(key)
@@ -196,7 +196,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- loadKey(password) {
+ loadKey (password) {
const salt = this.configManager.getSalt() || this.encryptor.generateSalt()
return this.encryptor.keyFromPassword(password + salt)
.then((key) => {
@@ -206,7 +206,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- addNewKeyring(type, opts, cb) {
+ addNewKeyring (type, opts, cb) {
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring(opts)
const accounts = keyring.getAccounts()
@@ -222,7 +222,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- addNewAccount(keyRingNum = 0, cb) {
+ addNewAccount (keyRingNum = 0, cb) {
const ring = this.keyrings[keyRingNum]
const accounts = ring.addAccounts(1)
this.setupAccounts(accounts)
@@ -235,7 +235,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- setupAccounts(accounts) {
+ setupAccounts (accounts) {
var arr = accounts || this.getAccounts()
arr.forEach((account) => {
this.loadBalanceAndNickname(account)
@@ -244,13 +244,13 @@ module.exports = class KeyringController extends EventEmitter {
// Takes an account address and an iterator representing
// the current number of named accounts.
- loadBalanceAndNickname(account) {
+ loadBalanceAndNickname (account) {
const address = normalize(account)
this.ethStore.addAccount(address)
this.createNickname(address)
}
- createNickname(address) {
+ createNickname (address) {
const hexAddress = normalize(address)
var i = Object.keys(this.identities).length
const oldNickname = this.configManager.nicknameForWallet(address)
@@ -274,7 +274,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- persistAllKeyrings() {
+ persistAllKeyrings () {
const serialized = this.keyrings.map((k) => {
return {
type: k.type,
@@ -289,7 +289,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- unlockKeyrings(key) {
+ unlockKeyrings (key) {
const encryptedVault = this.configManager.getVault()
return this.encryptor.decryptWithKey(key, encryptedVault)
.then((vault) => {
@@ -298,7 +298,7 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- restoreKeyring(serialized) {
+ restoreKeyring (serialized) {
const { type, data } = serialized
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring()
@@ -311,7 +311,7 @@ module.exports = class KeyringController extends EventEmitter {
return keyring
}
- getKeyringClassForType(type) {
+ getKeyringClassForType (type) {
const Keyring = this.keyringTypes.reduce((res, kr) => {
if (kr.type() === type) {
return kr
@@ -322,7 +322,7 @@ module.exports = class KeyringController extends EventEmitter {
return Keyring
}
- getAccounts() {
+ getAccounts () {
const keyrings = this.keyrings || []
return keyrings.map(kr => kr.getAccounts())
.reduce((res, arr) => {
@@ -330,13 +330,13 @@ module.exports = class KeyringController extends EventEmitter {
}, [])
}
- setSelectedAddress(address, cb) {
+ setSelectedAddress (address, cb) {
var addr = normalize(address)
this.configManager.setSelectedAccount(addr)
cb(null, addr)
}
- addUnconfirmedTransaction(txParams, onTxDoneCb, cb) {
+ addUnconfirmedTransaction (txParams, onTxDoneCb, cb) {
var self = this
const configManager = this.configManager
@@ -369,7 +369,7 @@ module.exports = class KeyringController extends EventEmitter {
], didComplete)
// perform static analyis on the target contract code
- function analyzeForDelegateCall(cb){
+ function analyzeForDelegateCall (cb) {
if (txParams.to) {
query.getCode(txParams.to, function (err, result) {
if (err) return cb(err)
@@ -388,8 +388,8 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- function estimateGas(cb){
- query.estimateGas(txParams, function(err, result){
+ function estimateGas (cb) {
+ query.estimateGas(txParams, function (err, result) {
if (err) return cb(err)
txData.estimatedGas = self.addGasBuffer(result)
cb()
@@ -406,7 +406,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- addUnconfirmedMessage(msgParams, cb) {
+ addUnconfirmedMessage (msgParams, cb) {
// create txData obj with parameters and meta data
var time = (new Date()).getTime()
var msgId = createId()
@@ -428,7 +428,7 @@ module.exports = class KeyringController extends EventEmitter {
return msgId
}
- approveTransaction(txId, cb) {
+ approveTransaction (txId, cb) {
const configManager = this.configManager
var approvalCb = this._unconfTxCbs[txId] || noop
@@ -441,7 +441,7 @@ module.exports = class KeyringController extends EventEmitter {
this.emit('update')
}
- cancelTransaction(txId, cb) {
+ cancelTransaction (txId, cb) {
const configManager = this.configManager
var approvalCb = this._unconfTxCbs[txId] || noop
@@ -456,7 +456,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- signTransaction(txParams, cb) {
+ signTransaction (txParams, cb) {
try {
const address = normalize(txParams.from)
const keyring = this.getKeyringForAccount(address)
@@ -492,7 +492,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- signMessage(msgParams, cb) {
+ signMessage (msgParams, cb) {
try {
const keyring = this.getKeyringForAccount(msgParams.from)
const address = normalize(msgParams.from)
@@ -503,7 +503,7 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- getKeyringForAccount(address) {
+ getKeyringForAccount (address) {
const hexed = normalize(address)
return this.keyrings.find((ring) => {
return ring.getAccounts()
@@ -512,19 +512,19 @@ module.exports = class KeyringController extends EventEmitter {
})
}
- cancelMessage(msgId, cb) {
+ cancelMessage (msgId, cb) {
if (cb && typeof cb === 'function') {
cb()
}
}
- setLocked(cb) {
+ setLocked (cb) {
this.key = null
this.keyrings = []
cb()
}
- exportAccount(address, cb) {
+ exportAccount (address, cb) {
try {
const keyring = this.getKeyringForAccount(address)
const privateKey = keyring.exportAccount(normalize(address))
@@ -534,19 +534,19 @@ module.exports = class KeyringController extends EventEmitter {
}
}
- addGasBuffer(gas) {
+ addGasBuffer (gas) {
const gasBuffer = new BN('100000', 10)
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
const correct = bnGas.add(gasBuffer)
return ethUtil.addHexPrefix(correct.toString(16))
}
- clearSeedWordCache(cb) {
+ clearSeedWordCache (cb) {
this.configManager.setSeedWords(null)
cb(null, this.configManager.getSelectedAccount())
}
- clearKeyrings() {
+ clearKeyrings () {
let accounts
try {
accounts = Object.keys(this.ethStore._currentState.accounts)
@@ -564,7 +564,7 @@ module.exports = class KeyringController extends EventEmitter {
}
-function normalize(address) {
+function normalize (address) {
if (!address) return
return ethUtil.addHexPrefix(address.toLowerCase())
}
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index 4bfc56c15..6df78555d 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.js
@@ -9,17 +9,17 @@ const hdPathString = `m/44'/60'/0'/0`
module.exports = class HdKeyring extends EventEmitter {
- static type() {
+ static type () {
return type
}
- constructor(opts = {}) {
+ constructor (opts = {}) {
super()
this.type = type
this.deserialize(opts)
}
- deserialize(opts = {}) {
+ deserialize (opts = {}) {
this.opts = opts || {}
this.wallets = []
this.mnemonic = null
@@ -34,26 +34,26 @@ module.exports = class HdKeyring extends EventEmitter {
}
}
- initFromMnemonic(mnemonic) {
+ initFromMnemonic (mnemonic) {
this.mnemonic = mnemonic
const seed = bip39.mnemonicToSeed(mnemonic)
this.hdWallet = hdkey.fromMasterSeed(seed)
this.root = this.hdWallet.derivePath(hdPathString)
}
- serialize() {
+ serialize () {
return {
mnemonic: this.mnemonic,
n: this.wallets.length,
}
}
- exportAccount(address) {
+ exportAccount (address) {
const wallet = this.getWalletForAccount(address)
return wallet.getPrivateKey().toString('hex')
}
- addAccounts(n = 1) {
+ addAccounts (n = 1) {
if (!this.root) {
this.initFromMnemonic(bip39.generateMnemonic())
}
@@ -69,12 +69,12 @@ module.exports = class HdKeyring extends EventEmitter {
return newWallets.map(w => w.getAddress().toString('hex'))
}
- getAccounts() {
+ getAccounts () {
return this.wallets.map(w => w.getAddress().toString('hex'))
}
// tx is an instance of the ethereumjs-transaction class.
- signTransaction(address, tx) {
+ signTransaction (address, tx) {
const wallet = this.getWalletForAccount(address)
var privKey = wallet.getPrivateKey()
tx.sign(privKey)
@@ -82,7 +82,7 @@ module.exports = class HdKeyring extends EventEmitter {
}
// For eth_sign, we need to sign transactions:
- signMessage(withAccount, data) {
+ signMessage (withAccount, data) {
const wallet = this.getWalletForAccount(withAccount)
const message = ethUtil.removeHexPrefix(data)
var privKey = wallet.getPrivateKey()
@@ -91,17 +91,14 @@ module.exports = class HdKeyring extends EventEmitter {
return rawMsgSig
}
- getWalletForAccount(account) {
+ getWalletForAccount (account) {
return this.wallets.find((w) => {
const address = w.getAddress().toString('hex')
return ((address === account) || (normalize(address) === account))
})
}
-
-
-
}
-function normalize(address) {
+function normalize (address) {
return ethUtil.addHexPrefix(address.toLowerCase())
}
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index 9e832f274..ee743bc03 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -6,22 +6,22 @@ const sigUtil = require('../lib/sig-util')
module.exports = class SimpleKeyring extends EventEmitter {
- static type() {
+ static type () {
return type
}
- constructor(opts) {
+ constructor (opts) {
super()
this.type = type
this.opts = opts || {}
this.wallets = []
}
- serialize() {
+ serialize () {
return this.wallets.map(w => w.getPrivateKey().toString('hex'))
}
- deserialize(wallets = []) {
+ deserialize (wallets = []) {
this.wallets = wallets.map((w) => {
var b = new Buffer(w, 'hex')
const wallet = Wallet.fromPrivateKey(b)
@@ -29,7 +29,7 @@ module.exports = class SimpleKeyring extends EventEmitter {
})
}
- addAccounts(n = 1) {
+ addAccounts (n = 1) {
var newWallets = []
for (var i = 0; i < n; i++) {
newWallets.push(Wallet.generate())
@@ -38,12 +38,12 @@ module.exports = class SimpleKeyring extends EventEmitter {
return newWallets.map(w => w.getAddress().toString('hex'))
}
- getAccounts() {
+ getAccounts () {
return this.wallets.map(w => w.getAddress().toString('hex'))
}
// tx is an instance of the ethereumjs-transaction class.
- signTransaction(address, tx) {
+ signTransaction (address, tx) {
const wallet = this.getWalletForAccount(address)
var privKey = wallet.getPrivateKey()
tx.sign(privKey)
@@ -51,7 +51,7 @@ module.exports = class SimpleKeyring extends EventEmitter {
}
// For eth_sign, we need to sign transactions:
- signMessage(withAccount, data) {
+ signMessage (withAccount, data) {
const wallet = this.getWalletForAccount(withAccount)
const message = ethUtil.removeHexPrefix(data)
var privKey = wallet.getPrivateKey()
@@ -60,9 +60,8 @@ module.exports = class SimpleKeyring extends EventEmitter {
return rawMsgSig
}
- getWalletForAccount(account) {
+ getWalletForAccount (account) {
return this.wallets.find(w => w.getAddress().toString('hex') === account)
}
}
-
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
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 07d365283..83220b7b2 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -87,23 +87,6 @@ module.exports = class MetamaskController {
}
onRpcRequest (stream, originDomain, request) {
-
- /* Commented out for Parity compliance
- * Parity does not permit additional keys, like `origin`,
- * and Infura is not currently filtering this key out.
- var payloads = Array.isArray(request) ? request : [request]
- payloads.forEach(function (payload) {
- // Append origin to rpc payload
- payload.origin = originDomain
- // Append origin to signature request
- if (payload.method === 'eth_sendTransaction') {
- payload.params[0].origin = originDomain
- } else if (payload.method === 'eth_sign') {
- payload.params.push({ origin: originDomain })
- }
- })
- */
-
// handle rpc request
this.provider.sendAsync(request, function onPayloadHandled (err, response) {
logger(err, request, response)
@@ -217,7 +200,7 @@ module.exports = class MetamaskController {
newUnsignedTransaction (txParams, onTxDoneCb) {
const keyringController = this.keyringController
- let err = this.enforceTxValidations(txParams)
+ const err = this.enforceTxValidations(txParams)
if (err) return onTxDoneCb(err)
keyringController.addUnconfirmedTransaction(txParams, onTxDoneCb, (err, txData) => {
if (err) return onTxDoneCb(err)
@@ -291,7 +274,6 @@ module.exports = class MetamaskController {
} catch (e) {
console.error('Error in checking TOS change.')
}
-
}
agreeToDisclaimer (cb) {
@@ -373,7 +355,7 @@ module.exports = class MetamaskController {
this.configManager.createShapeShiftTx(depositAddress, depositType)
}
- getNetwork(err) {
+ getNetwork (err) {
if (err) {
this.state.network = 'loading'
this.sendUpdate()
@@ -405,4 +387,3 @@ module.exports = class MetamaskController {
return this.state.network
}
}
-
diff --git a/app/scripts/popup-core.js b/app/scripts/popup-core.js
index 94413a1c4..0c97a5d19 100644
--- a/app/scripts/popup-core.js
+++ b/app/scripts/popup-core.js
@@ -9,7 +9,7 @@ const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
module.exports = initializePopup
-function initializePopup(connectionStream){
+function initializePopup (connectionStream) {
// setup app
connectToAccountManager(connectionStream, setupApp)
}
@@ -32,7 +32,7 @@ function setupWeb3Connection (connectionStream) {
}
function setupControllerConnection (connectionStream, cb) {
- // this is a really sneaky way of adding EventEmitter api
+ // this is a really sneaky way of adding EventEmitter api
// to a bi-directional dnode instance
var eventEmitter = new EventEmitter()
var accountManagerDnode = Dnode({
diff --git a/app/scripts/popup.js b/app/scripts/popup.js
index e6f149f96..62db68c10 100644
--- a/app/scripts/popup.js
+++ b/app/scripts/popup.js
@@ -18,7 +18,7 @@ var portStream = new PortStream(pluginPort)
startPopup(portStream)
-function closePopupIfOpen(name) {
+function closePopupIfOpen (name) {
if (name !== 'notification') {
notification.closePopup()
}