Enable no-var rule for ESLint (#7590)

* eslint: Enable no-var rule
* yarn lint --fix
feature/default_network_editable
Whymarrh Whitby 5 years ago committed by GitHub
parent 86e7233bd1
commit e61745a821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintrc
  2. 4
      app/scripts/controllers/network/network.js
  3. 28
      app/scripts/edge-encryptor.js
  4. 4
      app/scripts/lib/cleanErrorStack.js
  5. 6
      app/scripts/lib/message-manager.js
  6. 6
      app/scripts/lib/personal-message-manager.js
  7. 6
      app/scripts/lib/typed-message-manager.js
  8. 12
      development/announcer.js
  9. 2
      development/mock-dev.js
  10. 4
      development/sourcemap-validator.js
  11. 32
      test/e2e/web3.spec.js
  12. 4
      test/helper.js
  13. 4
      test/lib/mock-encryptor.js
  14. 4
      test/lib/mock-simple-keychain.js
  15. 24
      test/lib/react-trigger-change.js
  16. 16
      test/unit/actions/config_test.js
  17. 18
      test/unit/actions/set_selected_account_test.js
  18. 4
      test/unit/actions/tx_test.js
  19. 14
      test/unit/actions/view_info_test.js
  20. 12
      test/unit/actions/warning_test.js
  21. 10
      test/unit/app/controllers/detect-tokens-test.js
  22. 12
      test/unit/app/controllers/preferences-controller-test.js
  23. 4
      test/unit/app/controllers/transactions/tx-utils-test.js
  24. 4
      test/unit/app/edge-encryptor-test.js
  25. 16
      test/unit/app/message-manager-test.js
  26. 28
      test/unit/app/personal-message-manager-test.js
  27. 10
      test/unit/reducers/unlock_vault_test.js
  28. 122
      test/unit/util_test.js
  29. 4
      test/web3/schema.js
  30. 2
      test/web3/web3.js
  31. 10
      ui/app/components/app/account-panel.js
  32. 4
      ui/app/components/app/menu-droppo.js
  33. 4
      ui/app/components/ui/fiat-value.js
  34. 4
      ui/app/components/ui/mascot.js
  35. 4
      ui/app/ducks/app/app.js
  36. 4
      ui/app/ducks/metamask/metamask.js
  37. 80
      ui/app/helpers/utils/util.js
  38. 8
      ui/app/pages/confirm-transaction/conf-tx.js
  39. 2
      ui/app/pages/routes/index.js
  40. 20
      ui/app/store/actions.js
  41. 2
      ui/index.js
  42. 16
      ui/lib/icon-factory.js
  43. 4
      ui/lib/persistent-form.js

@ -143,6 +143,7 @@
"no-useless-computed-key": 2, "no-useless-computed-key": 2,
"no-useless-constructor": 2, "no-useless-constructor": 2,
"no-useless-escape": 2, "no-useless-escape": 2,
"no-var": 2,
"no-whitespace-before-property": 2, "no-whitespace-before-property": 2,
"no-with": 2, "no-with": 2,
"one-var": [2, { "initialized": "never" }], "one-var": [2, { "initialized": "never" }],

@ -198,7 +198,7 @@ module.exports = class NetworkController extends EventEmitter {
}) })
this._setNetworkClient(networkClient) this._setNetworkClient(networkClient)
// setup networkConfig // setup networkConfig
var settings = { const settings = {
ticker: 'ETH', ticker: 'ETH',
} }
this.networkConfig.putState(settings) this.networkConfig.putState(settings)
@ -221,7 +221,7 @@ module.exports = class NetworkController extends EventEmitter {
nickname, nickname,
} }
// setup networkConfig // setup networkConfig
var settings = { let settings = {
network: chainId, network: chainId,
} }
settings = extend(settings, networks.networkList['rpc']) settings = extend(settings, networks.networkList['rpc'])

@ -14,17 +14,17 @@ class EdgeEncryptor {
* @returns {Promise<string>} Promise resolving to an object with ciphertext * @returns {Promise<string>} Promise resolving to an object with ciphertext
*/ */
encrypt (password, dataObject) { encrypt (password, dataObject) {
var salt = this._generateSalt() const salt = this._generateSalt()
return this._keyFromPassword(password, salt) return this._keyFromPassword(password, salt)
.then(function (key) { .then(function (key) {
var data = JSON.stringify(dataObject) const data = JSON.stringify(dataObject)
var dataBuffer = Unibabel.utf8ToBuffer(data) const dataBuffer = Unibabel.utf8ToBuffer(data)
var vector = global.crypto.getRandomValues(new Uint8Array(16)) const vector = global.crypto.getRandomValues(new Uint8Array(16))
var resultbuffer = asmcrypto.AES_GCM.encrypt(dataBuffer, key, vector) const resultbuffer = asmcrypto.AES_GCM.encrypt(dataBuffer, key, vector)
var buffer = new Uint8Array(resultbuffer) const buffer = new Uint8Array(resultbuffer)
var vectorStr = Unibabel.bufferToBase64(vector) const vectorStr = Unibabel.bufferToBase64(vector)
var vaultStr = Unibabel.bufferToBase64(buffer) const vaultStr = Unibabel.bufferToBase64(buffer)
return JSON.stringify({ return JSON.stringify({
data: vaultStr, data: vaultStr,
iv: vectorStr, iv: vectorStr,
@ -48,7 +48,7 @@ class EdgeEncryptor {
const encryptedData = Unibabel.base64ToBuffer(payload.data) const encryptedData = Unibabel.base64ToBuffer(payload.data)
const vector = Unibabel.base64ToBuffer(payload.iv) const vector = Unibabel.base64ToBuffer(payload.iv)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var result let result
try { try {
result = asmcrypto.AES_GCM.decrypt(encryptedData, key, vector) result = asmcrypto.AES_GCM.decrypt(encryptedData, key, vector)
} catch (err) { } catch (err) {
@ -72,12 +72,12 @@ class EdgeEncryptor {
*/ */
_keyFromPassword (password, salt) { _keyFromPassword (password, salt) {
var passBuffer = Unibabel.utf8ToBuffer(password) const passBuffer = Unibabel.utf8ToBuffer(password)
var saltBuffer = Unibabel.base64ToBuffer(salt) const saltBuffer = Unibabel.base64ToBuffer(salt)
const iterations = 10000 const iterations = 10000
const length = 32 // SHA256 hash size const length = 32 // SHA256 hash size
return new Promise((resolve) => { return new Promise((resolve) => {
var key = asmcrypto.Pbkdf2HmacSha256(passBuffer, saltBuffer, iterations, length) const key = asmcrypto.Pbkdf2HmacSha256(passBuffer, saltBuffer, iterations, length)
resolve(key) resolve(key)
}) })
} }
@ -89,9 +89,9 @@ class EdgeEncryptor {
* @returns {string} Randomized base64 encoded data * @returns {string} Randomized base64 encoded data
*/ */
_generateSalt (byteCount = 32) { _generateSalt (byteCount = 32) {
var view = new Uint8Array(byteCount) const view = new Uint8Array(byteCount)
global.crypto.getRandomValues(view) global.crypto.getRandomValues(view)
var b64encoded = btoa(String.fromCharCode.apply(null, view)) const b64encoded = btoa(String.fromCharCode.apply(null, view))
return b64encoded return b64encoded
} }
} }

@ -4,10 +4,10 @@
* @returns {Error} Error with clean stack trace. * @returns {Error} Error with clean stack trace.
*/ */
function cleanErrorStack (err) { function cleanErrorStack (err) {
var name = err.name let name = err.name
name = (name === undefined) ? 'Error' : String(name) name = (name === undefined) ? 'Error' : String(name)
var msg = err.message let msg = err.message
msg = (msg === undefined) ? '' : String(msg) msg = (msg === undefined) ? '' : String(msg)
if (name === '') { if (name === '') {

@ -109,9 +109,9 @@ module.exports = class MessageManager extends EventEmitter {
} }
msgParams.data = normalizeMsgData(msgParams.data) msgParams.data = normalizeMsgData(msgParams.data)
// create txData obj with parameters and meta data // create txData obj with parameters and meta data
var time = (new Date()).getTime() const time = (new Date()).getTime()
var msgId = createId() const msgId = createId()
var msgData = { const msgData = {
id: msgId, id: msgId,
msgParams: msgParams, msgParams: msgParams,
time: time, time: time,

@ -117,9 +117,9 @@ module.exports = class PersonalMessageManager extends EventEmitter {
} }
msgParams.data = this.normalizeMsgData(msgParams.data) msgParams.data = this.normalizeMsgData(msgParams.data)
// create txData obj with parameters and meta data // create txData obj with parameters and meta data
var time = (new Date()).getTime() const time = (new Date()).getTime()
var msgId = createId() const msgId = createId()
var msgData = { const msgData = {
id: msgId, id: msgId,
msgParams: msgParams, msgParams: msgParams,
time: time, time: time,

@ -111,9 +111,9 @@ module.exports = class TypedMessageManager extends EventEmitter {
log.debug(`TypedMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`) log.debug(`TypedMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
// create txData obj with parameters and meta data // create txData obj with parameters and meta data
var time = (new Date()).getTime() const time = (new Date()).getTime()
var msgId = createId() const msgId = createId()
var msgData = { const msgData = {
id: msgId, id: msgId,
msgParams: msgParams, msgParams: msgParams,
time: time, time: time,

@ -1,11 +1,11 @@
var manifest = require('../app/manifest.json') const manifest = require('../app/manifest.json')
var version = manifest.version const version = manifest.version
var fs = require('fs') const fs = require('fs')
var path = require('path') const path = require('path')
var changelog = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md')).toString() const changelog = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md')).toString()
var log = changelog.split(version)[1].split('##')[0].trim() const log = changelog.split(version)[1].split('##')[0].trim()
const msg = `*MetaMask ${version}* now published! It should auto-update soon!\n${log}` const msg = `*MetaMask ${version}* now published! It should auto-update soon!\n${log}`

@ -94,7 +94,7 @@ function modifyBackgroundConnection (backgroundConnectionModifier) {
} }
// parse opts // parse opts
var store = configureStore(firstState) const store = configureStore(firstState)
// start app // start app
startApp() startApp()

@ -96,8 +96,8 @@ async function validateSourcemapForFile ({ buildName }) {
} }
function indicesOf (substring, string) { function indicesOf (substring, string) {
var a = [] const a = []
var i = -1 let i = -1
while ((i = string.indexOf(substring, i + 1)) >= 0) { while ((i = string.indexOf(substring, i + 1)) >= 0) {
a.push(i) a.push(i)
} }

@ -30,7 +30,7 @@ describe('Using MetaMask with an existing account', function () {
await delay(largeDelayMs) await delay(largeDelayMs)
const [results] = await findElements(driver, By.css('#results')) const [results] = await findElements(driver, By.css('#results'))
const resulttext = await results.getText() const resulttext = await results.getText()
var parsedData = JSON.parse(resulttext) const parsedData = JSON.parse(resulttext)
return (parsedData) return (parsedData)
@ -153,14 +153,14 @@ describe('Using MetaMask with an existing account', function () {
it('testing hexa methods', async () => { it('testing hexa methods', async () => {
var List = await driver.findElements(By.className('hexaNumberMethods')) const List = await driver.findElements(By.className('hexaNumberMethods'))
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
try { try {
var parsedData = await button(List[i]) const parsedData = await button(List[i])
console.log(parsedData) console.log(parsedData)
var result = parseInt(parsedData.result, 16) const result = parseInt(parsedData.result, 16)
assert.equal((typeof result === 'number'), true) assert.equal((typeof result === 'number'), true)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -174,14 +174,14 @@ describe('Using MetaMask with an existing account', function () {
it('testing booleanMethods', async () => { it('testing booleanMethods', async () => {
var List = await driver.findElements(By.className('booleanMethods')) const List = await driver.findElements(By.className('booleanMethods'))
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
try { try {
var parsedData = await button(List[i]) const parsedData = await button(List[i])
console.log(parsedData) console.log(parsedData)
var result = parsedData.result const result = parsedData.result
assert.equal(result, false) assert.equal(result, false)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -197,16 +197,16 @@ describe('Using MetaMask with an existing account', function () {
it('testing transactionMethods', async () => { it('testing transactionMethods', async () => {
var List = await driver.findElements(By.className('transactionMethods')) const List = await driver.findElements(By.className('transactionMethods'))
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
try { try {
var parsedData = await button(List[i]) const parsedData = await button(List[i])
console.log(parsedData.result.blockHash) console.log(parsedData.result.blockHash)
var result = [] const result = []
result.push(parseInt(parsedData.result.blockHash, 16)) result.push(parseInt(parsedData.result.blockHash, 16))
result.push(parseInt(parsedData.result.blockNumber, 16)) result.push(parseInt(parsedData.result.blockNumber, 16))
result.push(parseInt(parsedData.result.gas, 16)) result.push(parseInt(parsedData.result.gas, 16))
@ -239,17 +239,17 @@ describe('Using MetaMask with an existing account', function () {
it('testing blockMethods', async () => { it('testing blockMethods', async () => {
var List = await driver.findElements(By.className('blockMethods')) const List = await driver.findElements(By.className('blockMethods'))
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
try { try {
var parsedData = await button(List[i]) const parsedData = await button(List[i])
console.log(JSON.stringify(parsedData) + i) console.log(JSON.stringify(parsedData) + i)
console.log(parsedData.result.parentHash) console.log(parsedData.result.parentHash)
var result = parseInt(parsedData.result.parentHash, 16) const result = parseInt(parsedData.result.parentHash, 16)
assert.equal((typeof result === 'number'), true) assert.equal((typeof result === 'number'), true)
await delay(regularDelayMs) await delay(regularDelayMs)
@ -265,9 +265,9 @@ describe('Using MetaMask with an existing account', function () {
it('testing methods', async () => { it('testing methods', async () => {
var List = await driver.findElements(By.className('methods')) const List = await driver.findElements(By.className('methods'))
var parsedData let parsedData
var result let result
for (let i = 0; i < List.length; i++) { for (let i = 0; i < List.length; i++) {
try { try {

@ -17,7 +17,7 @@ server.listen(8545, () => {
}) })
// logging util // logging util
var log = require('loglevel') const log = require('loglevel')
log.setDefaultLevel(5) log.setDefaultLevel(5)
global.log = log global.log = log
@ -62,7 +62,7 @@ function enableFailureOnUnhandledPromiseRejection () {
throw evt.detail.reason throw evt.detail.reason
}) })
} else { } else {
var oldOHR = window.onunhandledrejection const oldOHR = window.onunhandledrejection
window.onunhandledrejection = function (evt) { window.onunhandledrejection = function (evt) {
if (typeof oldOHR === 'function') { if (typeof oldOHR === 'function') {
oldOHR.apply(this, arguments) oldOHR.apply(this, arguments)

@ -1,5 +1,5 @@
var mockHex = '0xabcdef0123456789' const mockHex = '0xabcdef0123456789'
var mockKey = Buffer.alloc(32) const mockKey = Buffer.alloc(32)
let cacheVal let cacheVal
module.exports = { module.exports = {

@ -1,4 +1,4 @@
var fakeWallet = { const fakeWallet = {
privKey: '0x123456788890abcdef', privKey: '0x123456788890abcdef',
address: '0xfedcba0987654321', address: '0xfedcba0987654321',
} }
@ -28,7 +28,7 @@ module.exports = class MockSimpleKeychain {
} }
addAccounts (n = 1) { addAccounts (n = 1) {
for (var i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
this.wallets.push(fakeWallet) this.wallets.push(fakeWallet)
} }
} }

@ -18,7 +18,7 @@
// Constants and functions are declared inside the closure. // Constants and functions are declared inside the closure.
// In this way, reactTriggerChange can be passed directly to executeScript in Selenium. // In this way, reactTriggerChange can be passed directly to executeScript in Selenium.
module.exports = function reactTriggerChange (node) { module.exports = function reactTriggerChange (node) {
var supportedInputTypes = { const supportedInputTypes = {
color: true, color: true,
date: true, date: true,
datetime: true, datetime: true,
@ -35,27 +35,27 @@ module.exports = function reactTriggerChange (node) {
url: true, url: true,
week: true, week: true,
} }
var nodeName = node.nodeName.toLowerCase() const nodeName = node.nodeName.toLowerCase()
var type = node.type const type = node.type
var event let event
var descriptor let descriptor
var initialValue let initialValue
var initialChecked let initialChecked
var initialCheckedRadio let initialCheckedRadio
// Do not try to delete non-configurable properties. // Do not try to delete non-configurable properties.
// Value and checked properties on DOM elements are non-configurable in PhantomJS. // Value and checked properties on DOM elements are non-configurable in PhantomJS.
function deletePropertySafe (elem, prop) { function deletePropertySafe (elem, prop) {
var desc = Object.getOwnPropertyDescriptor(elem, prop) const desc = Object.getOwnPropertyDescriptor(elem, prop)
if (desc && desc.configurable) { if (desc && desc.configurable) {
delete elem[prop] delete elem[prop]
} }
} }
function getCheckedRadio (radio) { function getCheckedRadio (radio) {
var name = radio.name const name = radio.name
var radios let radios
var i let i
if (name) { if (name) {
radios = document.querySelectorAll('input[type="radio"][name="' + name + '"]') radios = document.querySelectorAll('input[type="radio"][name="' + name + '"]')
for (i = 0; i < radios.length; i += 1) { for (i = 0; i < radios.length; i += 1) {

@ -1,13 +1,13 @@
// var jsdom = require('mocha-jsdom') // var jsdom = require('mocha-jsdom')
var assert = require('assert') const assert = require('assert')
var freeze = require('deep-freeze-strict') const freeze = require('deep-freeze-strict')
var path = require('path') const path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
describe('config view actions', function () { describe('config view actions', function () {
var initialState = { const initialState = {
metamask: { metamask: {
rpcTarget: 'foo', rpcTarget: 'foo',
frequentRpcList: [], frequentRpcList: [],
@ -22,7 +22,7 @@ describe('config view actions', function () {
describe('SHOW_CONFIG_PAGE', function () { describe('SHOW_CONFIG_PAGE', function () {
it('should set appState.currentView.name to config', function () { it('should set appState.currentView.name to config', function () {
var result = reducers(initialState, actions.showConfigPage()) const result = reducers(initialState, actions.showConfigPage())
assert.equal(result.appState.currentView.name, 'config') assert.equal(result.appState.currentView.name, 'config')
}) })
}) })
@ -34,7 +34,7 @@ describe('config view actions', function () {
value: 'foo', value: 'foo',
} }
var result = reducers(initialState, action) const result = reducers(initialState, action)
assert.equal(result.metamask.provider.type, 'rpc') assert.equal(result.metamask.provider.type, 'rpc')
assert.equal(result.metamask.provider.rpcTarget, 'foo') assert.equal(result.metamask.provider.rpcTarget, 'foo')
}) })

@ -1,14 +1,14 @@
// var jsdom = require('mocha-jsdom') // var jsdom = require('mocha-jsdom')
var assert = require('assert') const assert = require('assert')
var freeze = require('deep-freeze-strict') const freeze = require('deep-freeze-strict')
var path = require('path') const path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
describe('SET_SELECTED_ACCOUNT', function () { describe('SET_SELECTED_ACCOUNT', function () {
it('sets the state.appState.activeAddress property of the state to the action.value', function () { it('sets the state.appState.activeAddress property of the state to the action.value', function () {
var initialState = { const initialState = {
appState: { appState: {
activeAddress: 'foo', activeAddress: 'foo',
}, },
@ -21,14 +21,14 @@ describe('SET_SELECTED_ACCOUNT', function () {
} }
freeze(action) freeze(action)
var resultingState = reducers(initialState, action) const resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.activeAddress, action.value) assert.equal(resultingState.appState.activeAddress, action.value)
}) })
}) })
describe('SHOW_ACCOUNT_DETAIL', function () { describe('SHOW_ACCOUNT_DETAIL', function () {
it('updates metamask state', function () { it('updates metamask state', function () {
var initialState = { const initialState = {
metamask: { metamask: {
selectedAddress: 'foo', selectedAddress: 'foo',
}, },
@ -41,7 +41,7 @@ describe('SHOW_ACCOUNT_DETAIL', function () {
} }
freeze(action) freeze(action)
var resultingState = reducers(initialState, action) const resultingState = reducers(initialState, action)
assert.equal(resultingState.metamask.selectedAddress, action.value) assert.equal(resultingState.metamask.selectedAddress, action.value)
}) })
}) })

@ -1,5 +1,5 @@
var assert = require('assert') const assert = require('assert')
var path = require('path') const path = require('path')
import configureMockStore from 'redux-mock-store' import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk' import thunk from 'redux-thunk'

@ -1,14 +1,14 @@
// var jsdom = require('mocha-jsdom') // var jsdom = require('mocha-jsdom')
var assert = require('assert') const assert = require('assert')
var freeze = require('deep-freeze-strict') const freeze = require('deep-freeze-strict')
var path = require('path') const path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
describe('SHOW_INFO_PAGE', function () { describe('SHOW_INFO_PAGE', function () {
it('sets the state.appState.currentView.name property to info', function () { it('sets the state.appState.currentView.name property to info', function () {
var initialState = { const initialState = {
appState: { appState: {
activeAddress: 'foo', activeAddress: 'foo',
}, },
@ -16,7 +16,7 @@ describe('SHOW_INFO_PAGE', function () {
freeze(initialState) freeze(initialState)
const action = actions.showInfoPage() const action = actions.showInfoPage()
var resultingState = reducers(initialState, action) const resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.currentView.name, 'info') assert.equal(resultingState.appState.currentView.name, 'info')
}) })
}) })

@ -1,14 +1,14 @@
// var jsdom = require('mocha-jsdom') // var jsdom = require('mocha-jsdom')
var assert = require('assert') const assert = require('assert')
var freeze = require('deep-freeze-strict') const freeze = require('deep-freeze-strict')
var path = require('path') const path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
describe('action DISPLAY_WARNING', function () { describe('action DISPLAY_WARNING', function () {
it('sets appState.warning to provided value', function () { it('sets appState.warning to provided value', function () {
var initialState = { const initialState = {
appState: {}, appState: {},
} }
freeze(initialState) freeze(initialState)

@ -54,7 +54,7 @@ describe('DetectTokensController', () => {
controller.isOpen = true controller.isOpen = true
controller.isUnlocked = true controller.isUnlocked = true
var stub = sandbox.stub(controller, 'detectNewTokens') const stub = sandbox.stub(controller, 'detectNewTokens')
clock.tick(1) clock.tick(1)
sandbox.assert.notCalled(stub) sandbox.assert.notCalled(stub)
@ -70,7 +70,7 @@ describe('DetectTokensController', () => {
controller.isOpen = true controller.isOpen = true
controller.isUnlocked = true controller.isUnlocked = true
var stub = sandbox.stub(controller, 'detectTokenBalance') const stub = sandbox.stub(controller, 'detectTokenBalance')
.withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true) .withArgs('0x0D262e5dC4A06a0F1c90cE79C7a60C09DfC884E4').returns(true)
.withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true) .withArgs('0xBC86727E770de68B1060C91f6BB6945c73e10388').returns(true)
@ -114,7 +114,7 @@ describe('DetectTokensController', () => {
it('should trigger detect new tokens when change address', async () => { it('should trigger detect new tokens when change address', async () => {
controller.isOpen = true controller.isOpen = true
controller.isUnlocked = true controller.isUnlocked = true
var stub = sandbox.stub(controller, 'detectNewTokens') const stub = sandbox.stub(controller, 'detectNewTokens')
await preferences.setSelectedAddress('0xbc86727e770de68b1060c91f6bb6945c73e10388') await preferences.setSelectedAddress('0xbc86727e770de68b1060c91f6bb6945c73e10388')
sandbox.assert.called(stub) sandbox.assert.called(stub)
}) })
@ -122,7 +122,7 @@ describe('DetectTokensController', () => {
it('should trigger detect new tokens when submit password', async () => { it('should trigger detect new tokens when submit password', async () => {
controller.isOpen = true controller.isOpen = true
controller.selectedAddress = '0x0' controller.selectedAddress = '0x0'
var stub = sandbox.stub(controller, 'detectNewTokens') const stub = sandbox.stub(controller, 'detectNewTokens')
await controller._keyringMemStore.updateState({ isUnlocked: true }) await controller._keyringMemStore.updateState({ isUnlocked: true })
sandbox.assert.called(stub) sandbox.assert.called(stub)
}) })
@ -130,7 +130,7 @@ describe('DetectTokensController', () => {
it('should not trigger detect new tokens when not open or not unlocked', async () => { it('should not trigger detect new tokens when not open or not unlocked', async () => {
controller.isOpen = true controller.isOpen = true
controller.isUnlocked = false controller.isUnlocked = false
var stub = sandbox.stub(controller, 'detectTokenBalance') const stub = sandbox.stub(controller, 'detectTokenBalance')
clock.tick(180000) clock.tick(180000)
sandbox.assert.notCalled(stub) sandbox.assert.notCalled(stub)
controller.isOpen = false controller.isOpen = false

@ -342,7 +342,7 @@ describe('preferences controller', function () {
}) })
describe('on watchAsset', function () { describe('on watchAsset', function () {
var stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res let stubNext, stubEnd, stubHandleWatchAssetERC20, asy, req, res
const sandbox = sinon.createSandbox() const sandbox = sinon.createSandbox()
beforeEach(() => { beforeEach(() => {
@ -359,8 +359,8 @@ describe('preferences controller', function () {
it('shouldn not do anything if method not corresponds', async function () { it('shouldn not do anything if method not corresponds', async function () {
const asy = {next: () => {}, end: () => {}} const asy = {next: () => {}, end: () => {}}
var stubNext = sandbox.stub(asy, 'next') const stubNext = sandbox.stub(asy, 'next')
var stubEnd = sandbox.stub(asy, 'end').returns(0) const stubEnd = sandbox.stub(asy, 'end').returns(0)
req.method = 'metamask' req.method = 'metamask'
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end) await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
sandbox.assert.notCalled(stubEnd) sandbox.assert.notCalled(stubEnd)
@ -368,8 +368,8 @@ describe('preferences controller', function () {
}) })
it('should do something if method is supported', async function () { it('should do something if method is supported', async function () {
const asy = {next: () => {}, end: () => {}} const asy = {next: () => {}, end: () => {}}
var stubNext = sandbox.stub(asy, 'next') const stubNext = sandbox.stub(asy, 'next')
var stubEnd = sandbox.stub(asy, 'end').returns(0) const stubEnd = sandbox.stub(asy, 'end').returns(0)
req.method = 'metamask_watchAsset' req.method = 'metamask_watchAsset'
req.params.type = 'someasset' req.params.type = 'someasset'
await preferencesController.requestWatchAsset(req, res, asy.next, asy.end) await preferencesController.requestWatchAsset(req, res, asy.next, asy.end)
@ -400,7 +400,7 @@ describe('preferences controller', function () {
}) })
describe('on watchAsset of type ERC20', function () { describe('on watchAsset of type ERC20', function () {
var req let req
const sandbox = sinon.createSandbox() const sandbox = sinon.createSandbox()
beforeEach(() => { beforeEach(() => {

@ -5,7 +5,7 @@ const txUtils = require('../../../../../app/scripts/controllers/transactions/lib
describe('txUtils', function () { describe('txUtils', function () {
describe('#validateTxParams', function () { describe('#validateTxParams', function () {
it('does not throw for positive values', function () { it('does not throw for positive values', function () {
var sample = { const sample = {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d', from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
value: '0x01', value: '0x01',
} }
@ -13,7 +13,7 @@ describe('txUtils', function () {
}) })
it('returns error for negative values', function () { it('returns error for negative values', function () {
var sample = { const sample = {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d', from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
value: '-0x01', value: '-0x01',
} }

@ -2,8 +2,8 @@ const assert = require('assert')
const EdgeEncryptor = require('../../../app/scripts/edge-encryptor') const EdgeEncryptor = require('../../../app/scripts/edge-encryptor')
var password = 'passw0rd1' const password = 'passw0rd1'
var data = 'some random data' const data = 'some random data'
global.crypto = global.crypto || { global.crypto = global.crypto || {
getRandomValues: function (array) { getRandomValues: function (array) {

@ -10,7 +10,7 @@ describe('Message Manager', function () {
describe('#getMsgList', function () { describe('#getMsgList', function () {
it('when new should return empty array', function () { it('when new should return empty array', function () {
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 0) assert.equal(result.length, 0)
}) })
@ -21,9 +21,9 @@ describe('Message Manager', function () {
describe('#addMsg', function () { describe('#addMsg', function () {
it('adds a Msg returned in getMsgList', function () { it('adds a Msg returned in getMsgList', function () {
var Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].id, 1) assert.equal(result[0].id, 1)
@ -32,10 +32,10 @@ describe('Message Manager', function () {
describe('#setMsgStatusApproved', function () { describe('#setMsgStatusApproved', function () {
it('sets the Msg status to approved', function () { it('sets the Msg status to approved', function () {
var Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
messageManager.setMsgStatusApproved(1) messageManager.setMsgStatusApproved(1)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].status, 'approved') assert.equal(result[0].status, 'approved')
@ -44,10 +44,10 @@ describe('Message Manager', function () {
describe('#rejectMsg', function () { describe('#rejectMsg', function () {
it('sets the Msg status to rejected', function () { it('sets the Msg status to rejected', function () {
var Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
messageManager.rejectMsg(1) messageManager.rejectMsg(1)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].status, 'rejected') assert.equal(result[0].status, 'rejected')
@ -59,7 +59,7 @@ describe('Message Manager', function () {
messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' }) messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' })
messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' }) messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' })
messageManager._updateMsg({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test' }) messageManager._updateMsg({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test' })
var result = messageManager.getMsg('1') const result = messageManager.getMsg('1')
assert.equal(result.hash, 'foo') assert.equal(result.hash, 'foo')
}) })
}) })

@ -11,7 +11,7 @@ describe('Personal Message Manager', function () {
describe('#getMsgList', function () { describe('#getMsgList', function () {
it('when new should return empty array', function () { it('when new should return empty array', function () {
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 0) assert.equal(result.length, 0)
}) })
@ -22,9 +22,9 @@ describe('Personal Message Manager', function () {
describe('#addMsg', function () { describe('#addMsg', function () {
it('adds a Msg returned in getMsgList', function () { it('adds a Msg returned in getMsgList', function () {
var Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].id, 1) assert.equal(result[0].id, 1)
@ -33,10 +33,10 @@ describe('Personal Message Manager', function () {
describe('#setMsgStatusApproved', function () { describe('#setMsgStatusApproved', function () {
it('sets the Msg status to approved', function () { it('sets the Msg status to approved', function () {
var Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
messageManager.setMsgStatusApproved(1) messageManager.setMsgStatusApproved(1)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].status, 'approved') assert.equal(result[0].status, 'approved')
@ -45,10 +45,10 @@ describe('Personal Message Manager', function () {
describe('#rejectMsg', function () { describe('#rejectMsg', function () {
it('sets the Msg status to rejected', function () { it('sets the Msg status to rejected', function () {
var Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' } const Msg = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
messageManager.addMsg(Msg) messageManager.addMsg(Msg)
messageManager.rejectMsg(1) messageManager.rejectMsg(1)
var result = messageManager.messages const result = messageManager.messages
assert.ok(Array.isArray(result)) assert.ok(Array.isArray(result))
assert.equal(result.length, 1) assert.equal(result.length, 1)
assert.equal(result[0].status, 'rejected') assert.equal(result[0].status, 'rejected')
@ -60,7 +60,7 @@ describe('Personal Message Manager', function () {
messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' }) messageManager.addMsg({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' })
messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' }) messageManager.addMsg({ id: '2', status: 'approved', metamaskNetworkId: 'unit test' })
messageManager._updateMsg({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test' }) messageManager._updateMsg({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test' })
var result = messageManager.getMsg('1') const result = messageManager.getMsg('1')
assert.equal(result.hash, 'foo') assert.equal(result.hash, 'foo')
}) })
}) })
@ -87,20 +87,20 @@ describe('Personal Message Manager', function () {
describe('#normalizeMsgData', function () { describe('#normalizeMsgData', function () {
it('converts text to a utf8 hex string', function () { it('converts text to a utf8 hex string', function () {
var input = 'hello' const input = 'hello'
var output = messageManager.normalizeMsgData(input) const output = messageManager.normalizeMsgData(input)
assert.equal(output, '0x68656c6c6f', 'predictably hex encoded') assert.equal(output, '0x68656c6c6f', 'predictably hex encoded')
}) })
it('tolerates a hex prefix', function () { it('tolerates a hex prefix', function () {
var input = '0x12' const input = '0x12'
var output = messageManager.normalizeMsgData(input) const output = messageManager.normalizeMsgData(input)
assert.equal(output, '0x12', 'un modified') assert.equal(output, '0x12', 'un modified')
}) })
it('tolerates normal hex', function () { it('tolerates normal hex', function () {
var input = '12' const input = '12'
var output = messageManager.normalizeMsgData(input) const output = messageManager.normalizeMsgData(input)
assert.equal(output, '0x12', 'adds prefix') assert.equal(output, '0x12', 'adds prefix')
}) })
}) })

@ -1,11 +1,11 @@
// var jsdom = require('mocha-jsdom') // var jsdom = require('mocha-jsdom')
var assert = require('assert') const assert = require('assert')
// var freeze = require('deep-freeze-strict') // var freeze = require('deep-freeze-strict')
var path = require('path') const path = require('path')
var sinon = require('sinon') const sinon = require('sinon')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js')) const actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'store', 'actions.js'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js')) const reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'ducks', 'index.js'))
describe('#unlockMetamask(selectedAccount)', function () { describe('#unlockMetamask(selectedAccount)', function () {
beforeEach(function () { beforeEach(function () {

@ -1,13 +1,13 @@
var assert = require('assert') const assert = require('assert')
var sinon = require('sinon') const sinon = require('sinon')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
var path = require('path') const path = require('path')
var util = require(path.join(__dirname, '..', '..', 'ui', 'app', 'helpers', 'utils', 'util.js')) const util = require(path.join(__dirname, '..', '..', 'ui', 'app', 'helpers', 'utils', 'util.js'))
describe('util', function () { describe('util', function () {
var ethInWei = '1' let ethInWei = '1'
for (var i = 0; i < 18; i++) { for (let i = 0; i < 18; i++) {
ethInWei += '0' ethInWei += '0'
} }
@ -47,52 +47,52 @@ describe('util', function () {
describe('#addressSummary', function () { describe('#addressSummary', function () {
it('should add case-sensitive checksum', function () { it('should add case-sensitive checksum', function () {
var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825' const address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825'
var result = util.addressSummary(address) const result = util.addressSummary(address)
assert.equal(result, '0xFDEa65C8...b825') assert.equal(result, '0xFDEa65C8...b825')
}) })
it('should accept arguments for firstseg, lastseg, and keepPrefix', function () { it('should accept arguments for firstseg, lastseg, and keepPrefix', function () {
var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825' const address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825'
var result = util.addressSummary(address, 4, 4, false) const result = util.addressSummary(address, 4, 4, false)
assert.equal(result, 'FDEa...b825') assert.equal(result, 'FDEa...b825')
}) })
}) })
describe('#isValidAddress', function () { describe('#isValidAddress', function () {
it('should allow 40-char non-prefixed hex', function () { it('should allow 40-char non-prefixed hex', function () {
var address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825' const address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b825'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(result) assert.ok(result)
}) })
it('should allow 42-char non-prefixed hex', function () { it('should allow 42-char non-prefixed hex', function () {
var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825' const address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(result) assert.ok(result)
}) })
it('should not allow less non hex-prefixed', function () { it('should not allow less non hex-prefixed', function () {
var address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b85' const address = 'fdea65c8e26263f6d9a1b5de9555d2931a33b85'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(!result) assert.ok(!result)
}) })
it('should not allow less hex-prefixed', function () { it('should not allow less hex-prefixed', function () {
var address = '0xfdea65ce26263f6d9a1b5de9555d2931a33b85' const address = '0xfdea65ce26263f6d9a1b5de9555d2931a33b85'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(!result) assert.ok(!result)
}) })
it('should recognize correct capitalized checksum', function () { it('should recognize correct capitalized checksum', function () {
var address = '0xFDEa65C8e26263F6d9A1B5de9555D2931A33b825' const address = '0xFDEa65C8e26263F6d9A1B5de9555D2931A33b825'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(result) assert.ok(result)
}) })
it('should recognize incorrect capitalized checksum', function () { it('should recognize incorrect capitalized checksum', function () {
var address = '0xFDea65C8e26263F6d9A1B5de9555D2931A33b825' const address = '0xFDea65C8e26263F6d9A1B5de9555D2931A33b825'
var result = util.isValidAddress(address) const result = util.isValidAddress(address)
assert.ok(!result) assert.ok(!result)
}) })
@ -107,58 +107,58 @@ describe('util', function () {
describe('#numericBalance', function () { describe('#numericBalance', function () {
it('should return a BN 0 if given nothing', function () { it('should return a BN 0 if given nothing', function () {
var result = util.numericBalance() const result = util.numericBalance()
assert.equal(result.toString(10), 0) assert.equal(result.toString(10), 0)
}) })
it('should work with hex prefix', function () { it('should work with hex prefix', function () {
var result = util.numericBalance('0x012') const result = util.numericBalance('0x012')
assert.equal(result.toString(10), '18') assert.equal(result.toString(10), '18')
}) })
it('should work with no hex prefix', function () { it('should work with no hex prefix', function () {
var result = util.numericBalance('012') const result = util.numericBalance('012')
assert.equal(result.toString(10), '18') assert.equal(result.toString(10), '18')
}) })
}) })
describe('#formatBalance', function () { describe('#formatBalance', function () {
it('when given nothing', function () { it('when given nothing', function () {
var result = util.formatBalance() const result = util.formatBalance()
assert.equal(result, 'None', 'should return "None"') assert.equal(result, 'None', 'should return "None"')
}) })
it('should return eth as string followed by ETH', function () { it('should return eth as string followed by ETH', function () {
var input = new ethUtil.BN(ethInWei, 10).toJSON() const input = new ethUtil.BN(ethInWei, 10).toJSON()
var result = util.formatBalance(input, 4) const result = util.formatBalance(input, 4)
assert.equal(result, '1.0000 ETH') assert.equal(result, '1.0000 ETH')
}) })
it('should return eth as string followed by ETH', function () { it('should return eth as string followed by ETH', function () {
var input = new ethUtil.BN(ethInWei, 10).div(new ethUtil.BN('2', 10)).toJSON() const input = new ethUtil.BN(ethInWei, 10).div(new ethUtil.BN('2', 10)).toJSON()
var result = util.formatBalance(input, 3) const result = util.formatBalance(input, 3)
assert.equal(result, '0.500 ETH') assert.equal(result, '0.500 ETH')
}) })
it('should display specified decimal points', function () { it('should display specified decimal points', function () {
var input = '0x128dfa6a90b28000' const input = '0x128dfa6a90b28000'
var result = util.formatBalance(input, 2) const result = util.formatBalance(input, 2)
assert.equal(result, '1.33 ETH') assert.equal(result, '1.33 ETH')
}) })
it('should default to 3 decimal points', function () { it('should default to 3 decimal points', function () {
var input = '0x128dfa6a90b28000' const input = '0x128dfa6a90b28000'
var result = util.formatBalance(input) const result = util.formatBalance(input)
assert.equal(result, '1.337 ETH') assert.equal(result, '1.337 ETH')
}) })
it('should show 2 significant digits for tiny balances', function () { it('should show 2 significant digits for tiny balances', function () {
var input = '0x1230fa6a90b28' const input = '0x1230fa6a90b28'
var result = util.formatBalance(input) const result = util.formatBalance(input)
assert.equal(result, '0.00032 ETH') assert.equal(result, '0.00032 ETH')
}) })
it('should not parse the balance and return value with 2 decimal points with ETH at the end', function () { it('should not parse the balance and return value with 2 decimal points with ETH at the end', function () {
var value = '1.2456789' const value = '1.2456789'
var needsParse = false const needsParse = false
var result = util.formatBalance(value, 2, needsParse) const result = util.formatBalance(value, 2, needsParse)
assert.equal(result, '1.24 ETH') assert.equal(result, '1.24 ETH')
}) })
}) })
@ -166,7 +166,7 @@ describe('util', function () {
describe('normalizing values', function () { describe('normalizing values', function () {
describe('#normalizeToWei', function () { describe('#normalizeToWei', function () {
it('should convert an eth to the appropriate equivalent values', function () { it('should convert an eth to the appropriate equivalent values', function () {
var valueTable = { const valueTable = {
wei: '1000000000000000000', wei: '1000000000000000000',
kwei: '1000000000000000', kwei: '1000000000000000',
mwei: '1000000000000', mwei: '1000000000000',
@ -181,11 +181,11 @@ describe('util', function () {
// gether:'0.000000001', // gether:'0.000000001',
// tether:'0.000000000001', // tether:'0.000000000001',
} }
var oneEthBn = new ethUtil.BN(ethInWei, 10) const oneEthBn = new ethUtil.BN(ethInWei, 10)
for (var currency in valueTable) { for (const currency in valueTable) {
var value = new ethUtil.BN(valueTable[currency], 10) const value = new ethUtil.BN(valueTable[currency], 10)
var output = util.normalizeToWei(value, currency) const output = util.normalizeToWei(value, currency)
assert.equal(output.toString(10), valueTable.wei, `value of ${output.toString(10)} ${currency} should convert to ${oneEthBn}`) assert.equal(output.toString(10), valueTable.wei, `value of ${output.toString(10)} ${currency} should convert to ${oneEthBn}`)
} }
}) })
@ -193,66 +193,66 @@ describe('util', function () {
describe('#normalizeEthStringToWei', function () { describe('#normalizeEthStringToWei', function () {
it('should convert decimal eth to pure wei BN', function () { it('should convert decimal eth to pure wei BN', function () {
var input = '1.23456789' const input = '1.23456789'
var output = util.normalizeEthStringToWei(input) const output = util.normalizeEthStringToWei(input)
assert.equal(output.toString(10), '1234567890000000000') assert.equal(output.toString(10), '1234567890000000000')
}) })
it('should convert 1 to expected wei', function () { it('should convert 1 to expected wei', function () {
var input = '1' const input = '1'
var output = util.normalizeEthStringToWei(input) const output = util.normalizeEthStringToWei(input)
assert.equal(output.toString(10), ethInWei) assert.equal(output.toString(10), ethInWei)
}) })
it('should account for overflow numbers gracefully by dropping extra precision.', function () { it('should account for overflow numbers gracefully by dropping extra precision.', function () {
var input = '1.11111111111111111111' const input = '1.11111111111111111111'
var output = util.normalizeEthStringToWei(input) const output = util.normalizeEthStringToWei(input)
assert.equal(output.toString(10), '1111111111111111111') assert.equal(output.toString(10), '1111111111111111111')
}) })
it('should not truncate very exact wei values that do not have extra precision.', function () { it('should not truncate very exact wei values that do not have extra precision.', function () {
var input = '1.100000000000000001' const input = '1.100000000000000001'
var output = util.normalizeEthStringToWei(input) const output = util.normalizeEthStringToWei(input)
assert.equal(output.toString(10), '1100000000000000001') assert.equal(output.toString(10), '1100000000000000001')
}) })
}) })
describe('#normalizeNumberToWei', function () { describe('#normalizeNumberToWei', function () {
it('should handle a simple use case', function () { it('should handle a simple use case', function () {
var input = 0.0002 const input = 0.0002
var output = util.normalizeNumberToWei(input, 'ether') const output = util.normalizeNumberToWei(input, 'ether')
var str = output.toString(10) const str = output.toString(10)
assert.equal(str, '200000000000000') assert.equal(str, '200000000000000')
}) })
it('should convert a kwei number to the appropriate equivalent wei', function () { it('should convert a kwei number to the appropriate equivalent wei', function () {
var result = util.normalizeNumberToWei(1.111, 'kwei') const result = util.normalizeNumberToWei(1.111, 'kwei')
assert.equal(result.toString(10), '1111', 'accepts decimals') assert.equal(result.toString(10), '1111', 'accepts decimals')
}) })
it('should convert a ether number to the appropriate equivalent wei', function () { it('should convert a ether number to the appropriate equivalent wei', function () {
var result = util.normalizeNumberToWei(1.111, 'ether') const result = util.normalizeNumberToWei(1.111, 'ether')
assert.equal(result.toString(10), '1111000000000000000', 'accepts decimals') assert.equal(result.toString(10), '1111000000000000000', 'accepts decimals')
}) })
}) })
describe('#isHex', function () { describe('#isHex', function () {
it('should return true when given a hex string', function () { it('should return true when given a hex string', function () {
var result = util.isHex('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2') const result = util.isHex('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2')
assert(result) assert(result)
}) })
it('should return false when given a non-hex string', function () { it('should return false when given a non-hex string', function () {
var result = util.isHex('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714imnotreal') const result = util.isHex('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714imnotreal')
assert(!result) assert(!result)
}) })
it('should return false when given a string containing a non letter/number character', function () { it('should return false when given a string containing a non letter/number character', function () {
var result = util.isHex('c3ab8ff13720!8ad9047dd39466b3c%8974e592c2fa383d4a396071imnotreal') const result = util.isHex('c3ab8ff13720!8ad9047dd39466b3c%8974e592c2fa383d4a396071imnotreal')
assert(!result) assert(!result)
}) })
it('should return true when given a hex string with hex-prefix', function () { it('should return true when given a hex string with hex-prefix', function () {
var result = util.isHex('0xc3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2') const result = util.isHex('0xc3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2')
assert(result) assert(result)
}) })
}) })

@ -1,6 +1,6 @@
/* eslint no-unused-vars: 0 */ /* eslint no-unused-vars: 0 */
var params = { const params = {
// diffrent params used in the methods // diffrent params used in the methods
param: [], param: [],
blockHashParams: '0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35', blockHashParams: '0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35',
@ -93,7 +93,7 @@ var params = {
}, },
} }
var methods = { const methods = {
hexaNumberMethods: { hexaNumberMethods: {
// these are the methods which have output in the form of hexa decimal numbers // these are the methods which have output in the form of hexa decimal numbers
eth_blockNumber: ['eth_blockNumber', params.param, 'Q'], eth_blockNumber: ['eth_blockNumber', params.param, 'Q'],

@ -1,6 +1,6 @@
/* eslint no-undef: 0 */ /* eslint no-undef: 0 */
var json = methods const json = methods
web3.currentProvider.enable().then(() => { web3.currentProvider.enable().then(() => {

@ -13,12 +13,12 @@ function AccountPanel () {
} }
AccountPanel.prototype.render = function () { AccountPanel.prototype.render = function () {
var state = this.props const state = this.props
var identity = state.identity || {} const identity = state.identity || {}
var account = state.account || {} const account = state.account || {}
var isFauceting = state.isFauceting const isFauceting = state.isFauceting
var panelState = { const panelState = {
key: `accountPanel${identity.address}`, key: `accountPanel${identity.address}`,
identiconKey: identity.address, identiconKey: identity.address,
identiconLabel: identity.name || '', identiconLabel: identity.name || '',

@ -98,7 +98,7 @@ MenuDroppoComponent.prototype.componentDidMount = function () {
this.globalClickHandler = this.globalClickOccurred.bind(this) this.globalClickHandler = this.globalClickOccurred.bind(this)
document.body.addEventListener('click', this.globalClickHandler) document.body.addEventListener('click', this.globalClickHandler)
// eslint-disable-next-line react/no-find-dom-node // eslint-disable-next-line react/no-find-dom-node
var container = findDOMNode(this) const container = findDOMNode(this)
this.container = container this.container = container
} }
} }
@ -122,7 +122,7 @@ MenuDroppoComponent.prototype.globalClickOccurred = function (event) {
} }
function isDescendant (parent, child) { function isDescendant (parent, child) {
var node = child.parentNode let node = child.parentNode
while (node !== null) { while (node !== null) {
if (node === parent) { if (node === parent) {
return true return true

@ -19,8 +19,8 @@ FiatValue.prototype.render = function () {
if (value === 'None') { if (value === 'None') {
return value return value
} }
var fiatDisplayNumber, fiatTooltipNumber let fiatDisplayNumber, fiatTooltipNumber
var splitBalance = value.split(' ') const splitBalance = value.split(' ')
if (conversionRate !== 0) { if (conversionRate !== 0) {
fiatTooltipNumber = Number(splitBalance[0]) * conversionRate fiatTooltipNumber = Number(splitBalance[0]) * conversionRate

@ -33,8 +33,8 @@ Mascot.prototype.render = function Mascot () {
} }
Mascot.prototype.componentDidMount = function () { Mascot.prototype.componentDidMount = function () {
var targetDivId = 'metamask-mascot-container' const targetDivId = 'metamask-mascot-container'
var container = document.getElementById(targetDivId) const container = document.getElementById(targetDivId)
container.appendChild(this.logo.container) container.appendChild(this.logo.container)
} }

@ -21,14 +21,14 @@ export default function reduceApp (state, action) {
name = 'confTx' name = 'confTx'
} }
var defaultView = { const defaultView = {
name, name,
detailView: null, detailView: null,
context: selectedAddress, context: selectedAddress,
} }
// default state // default state
var appState = extend({ const appState = extend({
shouldClose: false, shouldClose: false,
menuOpen: false, menuOpen: false,
modal: { modal: {

@ -10,7 +10,7 @@ function reduceMetamask (state, action) {
let newState let newState
// clone + defaults // clone + defaults
var metamaskState = extend({ const metamaskState = extend({
isInitialized: false, isInitialized: false,
isUnlocked: false, isUnlocked: false,
isAccountMenuOpen: false, isAccountMenuOpen: false,
@ -99,7 +99,7 @@ function reduceMetamask (state, action) {
}) })
case actions.COMPLETED_TX: case actions.COMPLETED_TX:
var stringId = String(action.id) const stringId = String(action.id)
newState = extend(metamaskState, { newState = extend(metamaskState, {
unapprovedTxs: {}, unapprovedTxs: {},
unapprovedMsgs: {}, unapprovedMsgs: {},

@ -12,7 +12,7 @@ function formatDate (date, format = 'M/d/y \'at\' T') {
return DateTime.fromMillis(date).toFormat(format) return DateTime.fromMillis(date).toFormat(format)
} }
var valueTable = { const valueTable = {
wei: '1000000000000000000', wei: '1000000000000000000',
kwei: '1000000000000000', kwei: '1000000000000000',
mwei: '1000000000000', mwei: '1000000000000',
@ -25,8 +25,8 @@ var valueTable = {
gether: '0.000000001', gether: '0.000000001',
tether: '0.000000000001', tether: '0.000000000001',
} }
var bnTable = {} const bnTable = {}
for (var currency in valueTable) { for (const currency in valueTable) {
bnTable[currency] = new ethUtil.BN(valueTable[currency], 10) bnTable[currency] = new ethUtil.BN(valueTable[currency], 10)
} }
@ -97,12 +97,12 @@ function miniAddressSummary (address) {
if (!address) { if (!address) {
return '' return ''
} }
var checked = checksumAddress(address) const checked = checksumAddress(address)
return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...' return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...'
} }
function isValidAddress (address) { function isValidAddress (address) {
var prefixed = ethUtil.addHexPrefix(address) const prefixed = ethUtil.addHexPrefix(address)
if (address === '0x0000000000000000000000000000000000000000') { if (address === '0x0000000000000000000000000000000000000000') {
return false return false
} }
@ -114,7 +114,7 @@ function isValidENSAddress (address) {
} }
function isInvalidChecksumAddress (address) { function isInvalidChecksumAddress (address) {
var prefixed = ethUtil.addHexPrefix(address) const prefixed = ethUtil.addHexPrefix(address)
if (address === '0x0000000000000000000000000000000000000000') { if (address === '0x0000000000000000000000000000000000000000') {
return false return false
} }
@ -125,8 +125,8 @@ function isAllOneCase (address) {
if (!address) { if (!address) {
return true return true
} }
var lower = address.toLowerCase() const lower = address.toLowerCase()
var upper = address.toUpperCase() const upper = address.toUpperCase()
return address === lower || address === upper return address === lower || address === upper
} }
@ -135,18 +135,18 @@ function numericBalance (balance) {
if (!balance) { if (!balance) {
return new ethUtil.BN(0, 16) return new ethUtil.BN(0, 16)
} }
var stripped = ethUtil.stripHexPrefix(balance) const stripped = ethUtil.stripHexPrefix(balance)
return new ethUtil.BN(stripped, 16) return new ethUtil.BN(stripped, 16)
} }
// Takes hex, returns [beforeDecimal, afterDecimal] // Takes hex, returns [beforeDecimal, afterDecimal]
function parseBalance (balance) { function parseBalance (balance) {
var beforeDecimal, afterDecimal let afterDecimal
const wei = numericBalance(balance) const wei = numericBalance(balance)
var weiString = wei.toString() const weiString = wei.toString()
const trailingZeros = /0+$/ const trailingZeros = /0+$/
beforeDecimal = weiString.length > 18 ? weiString.slice(0, weiString.length - 18) : '0' const beforeDecimal = weiString.length > 18 ? weiString.slice(0, weiString.length - 18) : '0'
afterDecimal = ('000000000000000000' + wei).slice(-18).replace(trailingZeros, '') afterDecimal = ('000000000000000000' + wei).slice(-18).replace(trailingZeros, '')
if (afterDecimal === '') { if (afterDecimal === '') {
afterDecimal = '0' afterDecimal = '0'
@ -157,14 +157,14 @@ function parseBalance (balance) {
// Takes wei hex, returns an object with three properties. // Takes wei hex, returns an object with three properties.
// Its "formatted" property is what we generally use to render values. // Its "formatted" property is what we generally use to render values.
function formatBalance (balance, decimalsToKeep, needsParse = true, ticker = 'ETH') { function formatBalance (balance, decimalsToKeep, needsParse = true, ticker = 'ETH') {
var parsed = needsParse ? parseBalance(balance) : balance.split('.') const parsed = needsParse ? parseBalance(balance) : balance.split('.')
var beforeDecimal = parsed[0] const beforeDecimal = parsed[0]
var afterDecimal = parsed[1] let afterDecimal = parsed[1]
var formatted = 'None' let formatted = 'None'
if (decimalsToKeep === undefined) { if (decimalsToKeep === undefined) {
if (beforeDecimal === '0') { if (beforeDecimal === '0') {
if (afterDecimal !== '0') { if (afterDecimal !== '0') {
var sigFigs = afterDecimal.match(/^0*(.{2})/) // default: grabs 2 most significant digits const sigFigs = afterDecimal.match(/^0*(.{2})/) // default: grabs 2 most significant digits
if (sigFigs) { if (sigFigs) {
afterDecimal = sigFigs[0] afterDecimal = sigFigs[0]
} }
@ -182,11 +182,11 @@ function formatBalance (balance, decimalsToKeep, needsParse = true, ticker = 'ET
function generateBalanceObject (formattedBalance, decimalsToKeep = 1) { function generateBalanceObject (formattedBalance, decimalsToKeep = 1) {
var balance = formattedBalance.split(' ')[0] let balance = formattedBalance.split(' ')[0]
var label = formattedBalance.split(' ')[1] const label = formattedBalance.split(' ')[1]
var beforeDecimal = balance.split('.')[0] const beforeDecimal = balance.split('.')[0]
var afterDecimal = balance.split('.')[1] const afterDecimal = balance.split('.')[1]
var shortBalance = shortenBalance(balance, decimalsToKeep) const shortBalance = shortenBalance(balance, decimalsToKeep)
if (beforeDecimal === '0' && afterDecimal.substr(0, 5) === '00000') { if (beforeDecimal === '0' && afterDecimal.substr(0, 5) === '00000') {
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
@ -203,8 +203,8 @@ function generateBalanceObject (formattedBalance, decimalsToKeep = 1) {
} }
function shortenBalance (balance, decimalsToKeep = 1) { function shortenBalance (balance, decimalsToKeep = 1) {
var truncatedValue let truncatedValue
var convertedBalance = parseFloat(balance) const convertedBalance = parseFloat(balance)
if (convertedBalance > 1000000) { if (convertedBalance > 1000000) {
truncatedValue = (balance / 1000000).toFixed(decimalsToKeep) truncatedValue = (balance / 1000000).toFixed(decimalsToKeep)
return `${truncatedValue}m` return `${truncatedValue}m`
@ -216,7 +216,7 @@ function shortenBalance (balance, decimalsToKeep = 1) {
} else if (convertedBalance < 0.001) { } else if (convertedBalance < 0.001) {
return '<0.001' return '<0.001'
} else if (convertedBalance < 1) { } else if (convertedBalance < 1) {
var stringBalance = convertedBalance.toString() const stringBalance = convertedBalance.toString()
if (stringBalance.split('.')[1].length > 3) { if (stringBalance.split('.')[1].length > 3) {
return convertedBalance.toFixed(3) return convertedBalance.toFixed(3)
} else { } else {
@ -228,7 +228,7 @@ function shortenBalance (balance, decimalsToKeep = 1) {
} }
function dataSize (data) { function dataSize (data) {
var size = data ? ethUtil.stripHexPrefix(data).length : 0 const size = data ? ethUtil.stripHexPrefix(data).length : 0
return size + ' bytes' return size + ' bytes'
} }
@ -245,7 +245,7 @@ function normalizeEthStringToWei (str) {
const parts = str.split('.') const parts = str.split('.')
let eth = new ethUtil.BN(parts[0], 10).mul(bnTable.wei) let eth = new ethUtil.BN(parts[0], 10).mul(bnTable.wei)
if (parts[1]) { if (parts[1]) {
var decimal = parts[1] let decimal = parts[1]
while (decimal.length < 18) { while (decimal.length < 18) {
decimal += '0' decimal += '0'
} }
@ -258,24 +258,24 @@ function normalizeEthStringToWei (str) {
return eth return eth
} }
var multiple = new ethUtil.BN('10000', 10) const multiple = new ethUtil.BN('10000', 10)
function normalizeNumberToWei (n, currency) { function normalizeNumberToWei (n, currency) {
var enlarged = n * 10000 const enlarged = n * 10000
var amount = new ethUtil.BN(String(enlarged), 10) const amount = new ethUtil.BN(String(enlarged), 10)
return normalizeToWei(amount, currency).div(multiple) return normalizeToWei(amount, currency).div(multiple)
} }
function readableDate (ms) { function readableDate (ms) {
var date = new Date(ms) const date = new Date(ms)
var month = date.getMonth() const month = date.getMonth()
var day = date.getDate() const day = date.getDate()
var year = date.getFullYear() const year = date.getFullYear()
var hours = date.getHours() const hours = date.getHours()
var minutes = '0' + date.getMinutes() const minutes = '0' + date.getMinutes()
var seconds = '0' + date.getSeconds() const seconds = '0' + date.getSeconds()
var dateStr = `${month}/${day}/${year}` const dateStr = `${month}/${day}/${year}`
var time = `${hours}:${minutes.substr(-2)}:${seconds.substr(-2)}` const time = `${hours}:${minutes.substr(-2)}:${seconds.substr(-2)}`
return `${dateStr} ${time}` return `${dateStr} ${time}`
} }

@ -153,7 +153,7 @@ ConfirmTxScreen.prototype.render = function () {
conversionRate, conversionRate,
} = this.props } = this.props
var txData = this.getTxData() || {} const txData = this.getTxData() || {}
const { msgParams, type, msgParams: { version } } = txData const { msgParams, type, msgParams: { version } } = txData
log.debug('msgParams detected, rendering pending msg') log.debug('msgParams detected, rendering pending msg')
@ -186,7 +186,7 @@ ConfirmTxScreen.prototype.render = function () {
ConfirmTxScreen.prototype.signMessage = function (msgData, event) { ConfirmTxScreen.prototype.signMessage = function (msgData, event) {
log.info('conf-tx.js: signing message') log.info('conf-tx.js: signing message')
var params = msgData.msgParams const params = msgData.msgParams
params.metamaskId = msgData.id params.metamaskId = msgData.id
this.stopPropagation(event) this.stopPropagation(event)
return this.props.dispatch(actions.signMsg(params)) return this.props.dispatch(actions.signMsg(params))
@ -200,7 +200,7 @@ ConfirmTxScreen.prototype.stopPropagation = function (event) {
ConfirmTxScreen.prototype.signPersonalMessage = function (msgData, event) { ConfirmTxScreen.prototype.signPersonalMessage = function (msgData, event) {
log.info('conf-tx.js: signing personal message') log.info('conf-tx.js: signing personal message')
var params = msgData.msgParams const params = msgData.msgParams
params.metamaskId = msgData.id params.metamaskId = msgData.id
this.stopPropagation(event) this.stopPropagation(event)
return this.props.dispatch(actions.signPersonalMsg(params)) return this.props.dispatch(actions.signPersonalMsg(params))
@ -208,7 +208,7 @@ ConfirmTxScreen.prototype.signPersonalMessage = function (msgData, event) {
ConfirmTxScreen.prototype.signTypedMessage = function (msgData, event) { ConfirmTxScreen.prototype.signTypedMessage = function (msgData, event) {
log.info('conf-tx.js: signing typed message') log.info('conf-tx.js: signing typed message')
var params = msgData.msgParams const params = msgData.msgParams
params.metamaskId = msgData.id params.metamaskId = msgData.id
this.stopPropagation(event) this.stopPropagation(event)
return this.props.dispatch(actions.signTypedMsg(params)) return this.props.dispatch(actions.signTypedMsg(params))

@ -260,7 +260,7 @@ class Routes extends Component {
toggleMetamaskActive () { toggleMetamaskActive () {
if (!this.props.isUnlocked) { if (!this.props.isUnlocked) {
// currently inactive: redirect to password box // currently inactive: redirect to password box
var passwordBox = document.querySelector('input[type=password]') const passwordBox = document.querySelector('input[type=password]')
if (!passwordBox) { if (!passwordBox) {
return return
} }

@ -17,7 +17,7 @@ const { hasUnconfirmedTransactions } = require('../helpers/utils/confirm-tx.util
const gasDuck = require('../ducks/gas/gas.duck') const gasDuck = require('../ducks/gas/gas.duck')
const WebcamUtils = require('../../lib/webcam-utils') const WebcamUtils = require('../../lib/webcam-utils')
var actions = { const actions = {
_setBackgroundConnection: _setBackgroundConnection, _setBackgroundConnection: _setBackgroundConnection,
GO_HOME: 'GO_HOME', GO_HOME: 'GO_HOME',
@ -399,7 +399,7 @@ var actions = {
module.exports = actions module.exports = actions
var background = null let background = null
function _setBackgroundConnection (backgroundConnection) { function _setBackgroundConnection (backgroundConnection) {
background = backgroundConnection background = backgroundConnection
} }
@ -2171,7 +2171,7 @@ function requestExportAccount () {
} }
function exportAccount (password, address) { function exportAccount (password, address) {
var self = this const self = this
return function (dispatch) { return function (dispatch) {
dispatch(self.showLoadingIndication()) dispatch(self.showLoadingIndication())
@ -2305,7 +2305,7 @@ function pairUpdate (coin) {
} }
function shapeShiftSubview () { function shapeShiftSubview () {
var pair = 'btc_eth' const pair = 'btc_eth'
return (dispatch) => { return (dispatch) => {
dispatch(actions.showSubLoadingIndication()) dispatch(actions.showSubLoadingIndication())
shapeShiftRequest('marketinfo', {pair}, (mktResponse) => { shapeShiftRequest('marketinfo', {pair}, (mktResponse) => {
@ -2334,7 +2334,7 @@ function coinShiftRquest (data, marketData) {
if (response.error) { if (response.error) {
return dispatch(actions.displayWarning(response.error)) return dispatch(actions.displayWarning(response.error))
} }
var message = ` const message = `
Deposit your ${response.depositType} to the address below:` Deposit your ${response.depositType} to the address below:`
log.debug(`background.createShapeShiftTx`) log.debug(`background.createShapeShiftTx`)
background.createShapeShiftTx(response.deposit, response.depositType) background.createShapeShiftTx(response.deposit, response.depositType)
@ -2372,7 +2372,7 @@ function reshowQrCode (data, coin) {
return dispatch(actions.displayWarning(mktResponse.error)) return dispatch(actions.displayWarning(mktResponse.error))
} }
var message = [ const message = [
`Deposit your ${coin} to the address below:`, `Deposit your ${coin} to the address below:`,
`Deposit Limit: ${mktResponse.limit}`, `Deposit Limit: ${mktResponse.limit}`,
`Deposit Minimum:${mktResponse.minimum}`, `Deposit Minimum:${mktResponse.minimum}`,
@ -2385,10 +2385,10 @@ function reshowQrCode (data, coin) {
} }
function shapeShiftRequest (query, options = {}, cb) { function shapeShiftRequest (query, options = {}, cb) {
var queryResponse, method let queryResponse, method
options.method ? method = options.method : method = 'GET' options.method ? method = options.method : method = 'GET'
var requestListner = function () { const requestListner = function () {
try { try {
queryResponse = JSON.parse(this.responseText) queryResponse = JSON.parse(this.responseText)
if (cb) { if (cb) {
@ -2403,12 +2403,12 @@ function shapeShiftRequest (query, options = {}, cb) {
} }
} }
var shapShiftReq = new XMLHttpRequest() const shapShiftReq = new XMLHttpRequest()
shapShiftReq.addEventListener('load', requestListner) shapShiftReq.addEventListener('load', requestListner)
shapShiftReq.open(method, `https://shapeshift.io/${query}/${options.pair ? options.pair : ''}`, true) shapShiftReq.open(method, `https://shapeshift.io/${query}/${options.pair ? options.pair : ''}`, true)
if (options.method === 'POST') { if (options.method === 'POST') {
var jsonObj = JSON.stringify(options.data) const jsonObj = JSON.stringify(options.data)
shapShiftReq.setRequestHeader('Content-Type', 'application/json') shapShiftReq.setRequestHeader('Content-Type', 'application/json')
return shapShiftReq.send(jsonObj) return shapShiftReq.send(jsonObj)
} else { } else {

@ -13,7 +13,7 @@ module.exports = launchMetamaskUi
log.setLevel(global.METAMASK_DEBUG ? 'debug' : 'warn') log.setLevel(global.METAMASK_DEBUG ? 'debug' : 'warn')
function launchMetamaskUi (opts, cb) { function launchMetamaskUi (opts, cb) {
var {backgroundConnection} = opts const {backgroundConnection} = opts
actions._setBackgroundConnection(backgroundConnection) actions._setBackgroundConnection(backgroundConnection)
// check if we are unlocked first // check if we are unlocked first
backgroundConnection.getState(function (err, metamaskState) { backgroundConnection.getState(function (err, metamaskState) {

@ -1,4 +1,4 @@
var iconFactory let iconFactory
const isValidAddress = require('ethereumjs-util').isValidAddress const isValidAddress = require('ethereumjs-util').isValidAddress
const { checksumAddress } = require('../app/helpers/utils/util') const { checksumAddress } = require('../app/helpers/utils/util')
const contractMap = require('eth-contract-metadata') const contractMap = require('eth-contract-metadata')
@ -26,18 +26,18 @@ IconFactory.prototype.iconForAddress = function (address, diameter) {
// returns svg dom element // returns svg dom element
IconFactory.prototype.generateIdenticonSvg = function (address, diameter) { IconFactory.prototype.generateIdenticonSvg = function (address, diameter) {
var cacheId = `${address}:${diameter}` const cacheId = `${address}:${diameter}`
// check cache, lazily generate and populate cache // check cache, lazily generate and populate cache
var identicon = this.cache[cacheId] || (this.cache[cacheId] = this.generateNewIdenticon(address, diameter)) const identicon = this.cache[cacheId] || (this.cache[cacheId] = this.generateNewIdenticon(address, diameter))
// create a clean copy so you can modify it // create a clean copy so you can modify it
var cleanCopy = identicon.cloneNode(true) const cleanCopy = identicon.cloneNode(true)
return cleanCopy return cleanCopy
} }
// creates a new identicon // creates a new identicon
IconFactory.prototype.generateNewIdenticon = function (address, diameter) { IconFactory.prototype.generateNewIdenticon = function (address, diameter) {
var numericRepresentation = jsNumberForAddress(address) const numericRepresentation = jsNumberForAddress(address)
var identicon = this.jazzicon(diameter, numericRepresentation) const identicon = this.jazzicon(diameter, numericRepresentation)
return identicon return identicon
} }
@ -58,8 +58,8 @@ function imageElFor (address) {
} }
function jsNumberForAddress (address) { function jsNumberForAddress (address) {
var addr = address.slice(2, 10) const addr = address.slice(2, 10)
var seed = parseInt(addr, 16) const seed = parseInt(addr, 16)
return seed return seed
} }

@ -15,7 +15,7 @@ PersistentForm.prototype.componentDidMount = function () {
const fields = document.querySelectorAll('[data-persistent-formid]') const fields = document.querySelectorAll('[data-persistent-formid]')
const store = this.getPersistentStore() const store = this.getPersistentStore()
for (var i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
const field = fields[i] const field = fields[i]
const key = field.getAttribute('data-persistent-formid') const key = field.getAttribute('data-persistent-formid')
const cached = store[key] const cached = store[key]
@ -52,7 +52,7 @@ PersistentForm.prototype.persistentFieldDidUpdate = function (event) {
PersistentForm.prototype.componentWillUnmount = function () { PersistentForm.prototype.componentWillUnmount = function () {
const fields = document.querySelectorAll('[data-persistent-formid]') const fields = document.querySelectorAll('[data-persistent-formid]')
for (var i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
const field = fields[i] const field = fields[i]
field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this)) field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
} }

Loading…
Cancel
Save