aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--ui/app/actions.js2
-rw-r--r--ui/app/app.js2
-rw-r--r--ui/app/components/coinbase-form.js8
-rw-r--r--ui/app/components/copyButton.js4
-rw-r--r--ui/app/components/drop-menu-item.js6
-rw-r--r--ui/app/components/network.js2
-rw-r--r--ui/app/components/pending-tx.js36
-rw-r--r--ui/app/components/shapeshift-form.js4
-rw-r--r--ui/app/components/shift-list-item.js1
-rw-r--r--ui/app/components/tooltip.js2
-rw-r--r--ui/app/components/transaction-list-item.js2
-rw-r--r--ui/app/reducers.js2
-rw-r--r--ui/app/reducers/app.js1
-rw-r--r--ui/lib/account-link.js2
-rw-r--r--ui/lib/contract-namer.js9
-rw-r--r--ui/lib/icon-factory.js4
32 files changed, 129 insertions, 177 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()
}
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 0d2e7f521..7021c69db 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -145,7 +145,7 @@ var actions = {
module.exports = actions
var background = null
-function _setBackgroundConnection(backgroundConnection) {
+function _setBackgroundConnection (backgroundConnection) {
background = backgroundConnection
}
diff --git a/ui/app/app.js b/ui/app/app.js
index a2532c153..abe609eca 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -98,7 +98,6 @@ App.prototype.render = function () {
}
App.prototype.renderAppBar = function () {
-
if (window.METAMASK_UI_TYPE === 'notification') {
return null
}
@@ -367,7 +366,6 @@ App.prototype.renderPrimary = function () {
// show initialize screen
if (!props.isInitialized || props.forgottenPassword) {
-
// show current view
switch (props.currentView.name) {
diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js
index 3c5708bf8..693eb2ea8 100644
--- a/ui/app/components/coinbase-form.js
+++ b/ui/app/components/coinbase-form.js
@@ -7,7 +7,7 @@ const actions = require('../actions')
const isValidAddress = require('../util').isValidAddress
module.exports = connect(mapStateToProps)(CoinbaseForm)
-function mapStateToProps(state) {
+function mapStateToProps (state) {
return {
selectedAccount: state.selectedAccount,
warning: state.appState.warning,
@@ -16,7 +16,7 @@ function mapStateToProps(state) {
inherits(CoinbaseForm, Component)
-function CoinbaseForm() {
+function CoinbaseForm () {
Component.call(this)
}
@@ -124,7 +124,6 @@ CoinbaseForm.prototype.toCoinbase = function () {
}
CoinbaseForm.prototype.renderLoading = function () {
-
return h('img', {
style: {
width: '27px',
@@ -134,9 +133,8 @@ CoinbaseForm.prototype.renderLoading = function () {
})
}
-function isValidAmountforCoinBase(amount) {
+function isValidAmountforCoinBase (amount) {
amount = parseFloat(amount)
-
if (amount) {
if (amount <= 5 && amount > 0) {
return {
diff --git a/ui/app/components/copyButton.js b/ui/app/components/copyButton.js
index a01603585..a25d0719c 100644
--- a/ui/app/components/copyButton.js
+++ b/ui/app/components/copyButton.js
@@ -50,12 +50,10 @@ CopyButton.prototype.render = function () {
])
}
-CopyButton.prototype.debounceRestore = function() {
-
+CopyButton.prototype.debounceRestore = function () {
this.setState({ copied: true })
clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
this.setState({ copied: false })
}, 850)
-
}
diff --git a/ui/app/components/drop-menu-item.js b/ui/app/components/drop-menu-item.js
index 8088680c0..5c06101df 100644
--- a/ui/app/components/drop-menu-item.js
+++ b/ui/app/components/drop-menu-item.js
@@ -32,9 +32,9 @@ DropMenuItem.prototype.render = function () {
}
DropMenuItem.prototype.activeNetworkRender = function () {
- let activeNetwork = this.props.activeNetworkRender
- let { provider } = this.props
- let providerType = provider ? provider.type : null
+ const activeNetwork = this.props.activeNetworkRender
+ const { provider } = this.props
+ const providerType = provider ? provider.type : null
if (activeNetwork === undefined) return
switch (this.props.label) {
diff --git a/ui/app/components/network.js b/ui/app/components/network.js
index ff5aefd41..8e67dd741 100644
--- a/ui/app/components/network.js
+++ b/ui/app/components/network.js
@@ -22,7 +22,6 @@ Network.prototype.render = function () {
let iconName, hoverText
if (networkNumber === 'loading') {
-
return h('img.network-indicator', {
title: 'Attempting to connect to blockchain.',
onClick: (event) => this.props.onClick(event),
@@ -32,7 +31,6 @@ Network.prototype.render = function () {
},
src: 'images/loading.svg',
})
-
} else if (providerName === 'mainnet') {
hoverText = 'Main Ethereum Network'
iconName = 'ethereum-network'
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 96f968929..1fc2f47d0 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -30,22 +30,22 @@ PendingTx.prototype.render = function () {
}
`),
- txData.simulationFails ?
- h('.error', {
- style: {
- marginLeft: 50,
- fontSize: '0.9em',
- },
- }, 'Transaction Error. Exception thrown in contract code.')
+ txData.simulationFails
+ ? h('.error', {
+ style: {
+ marginLeft: 50,
+ fontSize: '0.9em',
+ },
+ }, 'Transaction Error. Exception thrown in contract code.')
: null,
- state.insufficientBalance ?
- h('span.error', {
- style: {
- marginLeft: 50,
- fontSize: '0.9em',
- },
- }, 'Insufficient balance for transaction')
+ state.insufficientBalance
+ ? h('span.error', {
+ style: {
+ marginLeft: 50,
+ fontSize: '0.9em',
+ },
+ }, 'Insufficient balance for transaction')
: null,
// send + cancel
@@ -57,10 +57,10 @@ PendingTx.prototype.render = function () {
},
}, [
- state.insufficientBalance ?
- h('button.btn-green', {
- onClick: state.buyEth,
- }, 'Buy Ether')
+ state.insufficientBalance
+ ? h('button.btn-green', {
+ onClick: state.buyEth,
+ }, 'Buy Ether')
: null,
h('button.confirm', {
diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js
index 1da549288..383d5b623 100644
--- a/ui/app/components/shapeshift-form.js
+++ b/ui/app/components/shapeshift-form.js
@@ -8,7 +8,7 @@ const Qr = require('./qr-code')
const isValidAddress = require('../util').isValidAddress
module.exports = connect(mapStateToProps)(ShapeshiftForm)
-function mapStateToProps(state) {
+function mapStateToProps (state) {
return {
selectedAccount: state.selectedAccount,
warning: state.appState.warning,
@@ -25,7 +25,6 @@ function ShapeshiftForm () {
}
ShapeshiftForm.prototype.render = function () {
-
return h(ReactCSSTransitionGroup, {
className: 'css-transition-group',
transitionName: 'main',
@@ -34,7 +33,6 @@ ShapeshiftForm.prototype.render = function () {
}, [
this.props.qrRequested ? h(Qr, {key: 'qr'}) : this.renderMain(),
])
-
}
ShapeshiftForm.prototype.renderMain = function () {
diff --git a/ui/app/components/shift-list-item.js b/ui/app/components/shift-list-item.js
index 38c19eb28..e0243e247 100644
--- a/ui/app/components/shift-list-item.js
+++ b/ui/app/components/shift-list-item.js
@@ -26,7 +26,6 @@ function ShiftListItem () {
}
ShiftListItem.prototype.render = function () {
-
return (
h('.transaction-list-item.flex-row', {
style: {
diff --git a/ui/app/components/tooltip.js b/ui/app/components/tooltip.js
index 757ad0cd6..edbc074bb 100644
--- a/ui/app/components/tooltip.js
+++ b/ui/app/components/tooltip.js
@@ -11,7 +11,6 @@ function Tooltip () {
}
Tooltip.prototype.render = function () {
-
const props = this.props
const { position, title, children } = props
@@ -20,5 +19,4 @@ Tooltip.prototype.render = function () {
title,
fixed: false,
}, children)
-
}
diff --git a/ui/app/components/transaction-list-item.js b/ui/app/components/transaction-list-item.js
index 491e90c7c..d1306549e 100644
--- a/ui/app/components/transaction-list-item.js
+++ b/ui/app/components/transaction-list-item.js
@@ -63,7 +63,7 @@ TransactionListItem.prototype.render = function () {
style: {
fontSize: '27px',
},
- }) : h( '.pop-hover', {
+ }) : h('.pop-hover', {
onClick: (event) => {
event.stopPropagation()
if (!isTx || isPending) return
diff --git a/ui/app/reducers.js b/ui/app/reducers.js
index a691cf614..4d10e2b39 100644
--- a/ui/app/reducers.js
+++ b/ui/app/reducers.js
@@ -41,7 +41,7 @@ function rootReducer (state, action) {
return state
}
-window.logState = function() {
+window.logState = function () {
var stateString = JSON.stringify(window.METAMASK_CACHED_LOG_STATE, null, 2)
console.log(stateString)
}
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 49507eb30..ca450fd89 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -278,7 +278,6 @@ function reduceApp (state, action) {
warning: null,
})
} else {
-
notification.closePopup()
return extend(appState, {
diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js
index eb958e22d..479bf23d2 100644
--- a/ui/lib/account-link.js
+++ b/ui/lib/account-link.js
@@ -1,4 +1,4 @@
-module.exports = function(address, network) {
+module.exports = function (address, network) {
const net = parseInt(network)
let link
diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js
index c99d44de6..a94c62b62 100644
--- a/ui/lib/contract-namer.js
+++ b/ui/lib/contract-namer.js
@@ -8,23 +8,22 @@
// Nickname keys must be stored in lower case.
const nicknames = {}
-module.exports = function(addr, identities = {}) {
-
+module.exports = function (addr, identities = {}) {
const address = addr.toLowerCase()
const ids = hashFromIdentities(identities)
return addrFromHash(address, ids) || addrFromHash(address, nicknames)
}
-function hashFromIdentities(identities) {
+function hashFromIdentities (identities) {
const result = {}
- for (let key in identities) {
+ for (const key in identities) {
result[key] = identities[key].name
}
return result
}
-function addrFromHash(addr, hash) {
+function addrFromHash (addr, hash) {
const address = addr.toLowerCase()
return hash[address] || null
}
diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js
index a30041114..82cc839d6 100644
--- a/ui/lib/icon-factory.js
+++ b/ui/lib/icon-factory.js
@@ -55,6 +55,6 @@ function jsNumberForAddress (address) {
return seed
}
-function toDataUri(identiconSrc){
+function toDataUri (identiconSrc) {
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(identiconSrc)
-} \ No newline at end of file
+}