1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix linting warnings

This commit is contained in:
Thomas Huang 2017-04-26 21:05:45 -07:00
parent afbe6f5e5f
commit 6bdb4c8728
41 changed files with 124 additions and 135 deletions

View File

@ -43,8 +43,8 @@ asyncQ.waterfall([
function loadStateFromPersistence () {
// migrations
let migrator = new Migrator({ migrations })
let initialState = migrator.generateInitialState(firstTimeState)
const migrator = new Migrator({ migrations })
const initialState = migrator.generateInitialState(firstTimeState)
return asyncQ.waterfall([
// read from disk
() => Promise.resolve(diskStore.getState() || initialState),
@ -61,7 +61,6 @@ function loadStateFromPersistence() {
}
function setupController (initState) {
//
// MetaMask Controller
//
@ -86,7 +85,7 @@ function setupController (initState) {
)
function versionifyData (state) {
let versionedData = diskStore.getState()
const versionedData = diskStore.getState()
versionedData.data = state
return versionedData
}
@ -138,7 +137,6 @@ function setupController (initState) {
}
return Promise.resolve()
}
//

View File

@ -39,11 +39,11 @@ class AddressBookController {
// pushed object is an object of two fields. Current behavior does not set an
// upper limit to the number of addresses.
_addToAddressBook (address, name) {
let addressBook = this._getAddressBook()
let identities = this._getIdentities()
const addressBook = this._getAddressBook()
const identities = this._getIdentities()
let addressBookIndex = addressBook.findIndex((element) => { return element.address.toLowerCase() === address.toLowerCase() || element.name === name })
let identitiesIndex = Object.keys(identities).findIndex((element) => { return element.toLowerCase() === address.toLowerCase() })
const addressBookIndex = addressBook.findIndex((element) => { return element.address.toLowerCase() === address.toLowerCase() || element.name === name })
const identitiesIndex = Object.keys(identities).findIndex((element) => { return element.toLowerCase() === address.toLowerCase() })
// trigger this condition if we own this address--no need to overwrite.
if (identitiesIndex !== -1) {
return Promise.resolve(addressBook)

View File

@ -51,9 +51,11 @@ class CurrencyController {
this.setConversionRate(Number(parsedResponse.ticker.price))
this.setConversionDate(Number(parsedResponse.timestamp))
}).catch((err) => {
if (err) {
console.warn('MetaMask - Failed to query currency conversion.')
this.setConversionRate(0)
this.setConversionDate('N/A')
}
})
}

View File

@ -36,8 +36,8 @@ class PreferencesController {
}
addToFrequentRpcList (_url) {
let rpcList = this.getFrequentRpcList()
let index = rpcList.findIndex((element) => { return element === _url })
const rpcList = this.getFrequentRpcList()
const index = rpcList.findIndex((element) => { return element === _url })
if (index !== -1) {
rpcList.splice(index, 1)
}
@ -53,13 +53,9 @@ class PreferencesController {
getFrequentRpcList () {
return this.store.getState().frequentRpcList
}
//
// PRIVATE METHODS
//
}
module.exports = PreferencesController

View File

@ -187,7 +187,7 @@ class KeyringController extends EventEmitter {
.then((accounts) => {
switch (type) {
case 'Simple Key Pair':
let isNotIncluded = !accounts.find((key) => key === newAccount[0] || key === ethUtil.stripHexPrefix(newAccount[0]))
const isNotIncluded = !accounts.find((key) => key === newAccount[0] || key === ethUtil.stripHexPrefix(newAccount[0]))
return (isNotIncluded) ? Promise.resolve(newAccount) : Promise.reject(new Error('The account you\'re are trying to import is a duplicate'))
default:
return Promise.resolve(newAccount)

View File

@ -85,7 +85,7 @@ MetamaskInpageProvider.prototype.send = function (payload) {
break
case 'net_version':
let networkVersion = self.publicConfigStore.getState().networkVersion
const networkVersion = self.publicConfigStore.getState().networkVersion
result = networkVersion
break

View File

@ -3,16 +3,16 @@ const asyncQ = require('async-q')
class Migrator {
constructor (opts = {}) {
let migrations = opts.migrations || []
const migrations = opts.migrations || []
this.migrations = migrations.sort((a, b) => a.version - b.version)
let lastMigration = this.migrations.slice(-1)[0]
const lastMigration = this.migrations.slice(-1)[0]
// use specified defaultVersion or highest migration version
this.defaultVersion = opts.defaultVersion || (lastMigration && lastMigration.version) || 0
}
// run all pending migrations on meta in place
migrateData (versionedData = this.generateInitialState()) {
let remaining = this.migrations.filter(migrationIsPending)
const remaining = this.migrations.filter(migrationIsPending)
return (
asyncQ.eachSeries(remaining, (migration) => this.runMigration(versionedData, migration))

View File

@ -75,8 +75,8 @@ module.exports = class txProviderUtils {
}
fillInTxParams (txParams, cb) {
let fromAddress = txParams.from
let reqs = {}
const fromAddress = txParams.from
const reqs = {}
if (isUndef(txParams.gas)) reqs.gas = (cb) => this.query.estimateGas(txParams, cb)
if (isUndef(txParams.gasPrice)) reqs.gasPrice = (cb) => this.query.gasPrice(cb)

View File

@ -32,7 +32,7 @@ module.exports = class MetamaskController extends EventEmitter {
constructor (opts) {
super()
this.opts = opts
let initState = opts.initState || {}
const initState = opts.initState || {}
// platform-specific api
this.platform = opts.platform
@ -161,8 +161,7 @@ module.exports = class MetamaskController extends EventEmitter {
//
initializeProvider () {
let provider = MetaMaskProvider({
const provider = MetaMaskProvider({
static: {
eth_syncing: false,
web3_clientVersion: `MetaMask/v${version}`,
@ -170,8 +169,8 @@ module.exports = class MetamaskController extends EventEmitter {
rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt
getAccounts: (cb) => {
let selectedAddress = this.preferencesController.getSelectedAddress()
let result = selectedAddress ? [selectedAddress] : []
const selectedAddress = this.preferencesController.getSelectedAddress()
const result = selectedAddress ? [selectedAddress] : []
cb(null, result)
},
// tx signing
@ -441,7 +440,7 @@ module.exports = class MetamaskController extends EventEmitter {
}
newUnsignedMessage (msgParams, cb) {
let msgId = this.messageManager.addUnapprovedMessage(msgParams)
const msgId = this.messageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.messageManager.once(`${msgId}:finished`, (data) => {
@ -461,7 +460,7 @@ module.exports = class MetamaskController extends EventEmitter {
return cb(new Error('MetaMask Message Signature: from field is required.'))
}
let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.personalMessageManager.once(`${msgId}:finished`, (data) => {
@ -512,7 +511,7 @@ module.exports = class MetamaskController extends EventEmitter {
// Prefixed Style Message Signing Methods:
approvePersonalMessage (msgParams, cb) {
let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
this.personalMessageManager.once(`${msgId}:finished`, (data) => {

View File

@ -7,7 +7,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
if (versionedData.data.config.provider.type === 'etherscan') {

View File

@ -8,7 +8,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
if (versionedData.data.config.provider.rpcTarget === oldTestRpc) {

View File

@ -6,7 +6,7 @@ module.exports = {
version,
migrate: function (versionedData) {
let safeVersionedData = clone(versionedData)
const safeVersionedData = clone(versionedData)
safeVersionedData.meta.version = version
try {
if (safeVersionedData.data.config.provider.type !== 'rpc') return Promise.resolve(safeVersionedData)

View File

@ -14,7 +14,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -13,7 +13,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -13,7 +13,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -13,7 +13,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -13,7 +13,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -13,7 +13,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -12,7 +12,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -12,7 +12,7 @@ module.exports = {
version,
migrate: function (originalVersionedData) {
let versionedData = clone(originalVersionedData)
const versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data

View File

@ -20,10 +20,10 @@ module.exports = {
migrate: function (versionedData) {
versionedData.meta.version = version
let store = new ObservableStore(versionedData.data)
let configManager = new ConfigManager({ store })
let idStoreMigrator = new IdentityStoreMigrator({ configManager })
let keyringController = new KeyringController({
const store = new ObservableStore(versionedData.data)
const configManager = new ConfigManager({ store })
const idStoreMigrator = new IdentityStoreMigrator({ configManager })
const keyringController = new KeyringController({
configManager: configManager,
})
@ -46,6 +46,5 @@ module.exports = {
return Promise.resolve(versionedData)
})
})
},
}

View File

@ -16,7 +16,6 @@ function initializePopup ({ container, connectionStream }, cb) {
(cb) => connectToAccountManager(connectionStream, cb),
(accountManager, cb) => launchMetamaskUi({ container, accountManager }, cb),
], cb)
}
function connectToAccountManager (connectionStream, cb) {

View File

@ -47,8 +47,8 @@ module.exports = class TransactionManager extends EventEmitter {
// Returns the tx list
getTxList () {
let network = this.getNetwork()
let fullTxList = this.getFullTxList()
const network = this.getNetwork()
const fullTxList = this.getFullTxList()
return fullTxList.filter(txMeta => txMeta.metamaskNetworkId === network)
}
@ -64,10 +64,10 @@ module.exports = class TransactionManager extends EventEmitter {
// Adds a tx to the txlist
addTx (txMeta) {
let txCount = this.getTxCount()
let network = this.getNetwork()
let fullTxList = this.getFullTxList()
let txHistoryLimit = this.txHistoryLimit
const txCount = this.getTxCount()
const network = this.getNetwork()
const fullTxList = this.getFullTxList()
const txHistoryLimit = this.txHistoryLimit
// checks if the length of the tx history is
// longer then desired persistence limit
@ -197,7 +197,7 @@ module.exports = class TransactionManager extends EventEmitter {
}
fillInTxParams (txId, cb) {
let txMeta = this.getTx(txId)
const txMeta = this.getTx(txId)
this.txProviderUtils.fillInTxParams(txMeta.txParams, (err) => {
if (err) return cb(err)
this.updateTx(txMeta)
@ -242,7 +242,7 @@ module.exports = class TransactionManager extends EventEmitter {
// receives a txHash records the tx as signed
setTxHash (txId, txHash) {
// Add the tx hash to the persisted meta-tx object
let txMeta = this.getTx(txId)
const txMeta = this.getTx(txId)
txMeta.hash = txHash
this.updateTx(txMeta)
}
@ -315,7 +315,7 @@ module.exports = class TransactionManager extends EventEmitter {
}
setTxStatusFailed (txId, reason) {
let txMeta = this.getTx(txId)
const txMeta = this.getTx(txId)
txMeta.err = reason
this.updateTx(txMeta)
this._setTxStatus(txId, 'failed')
@ -338,7 +338,7 @@ module.exports = class TransactionManager extends EventEmitter {
var txHash = txMeta.hash
var txId = txMeta.id
if (!txHash) {
let errReason = {
const errReason = {
errCode: 'No hash was provided',
message: 'We had an error while submitting this transaction, please try again.',
}

View File

@ -552,5 +552,4 @@ App.prototype.renderCommonRpc = function (rpcList, provider) {
})
}
})
}

View File

@ -24,7 +24,7 @@ EnsInput.prototype.render = function () {
list: 'addresses',
onChange: () => {
const network = this.props.network
let resolverAddress = networkResolvers[network]
const resolverAddress = networkResolvers[network]
if (!resolverAddress) return
const recipient = document.querySelector('input[name="address"]').value
@ -52,7 +52,7 @@ EnsInput.prototype.render = function () {
[
// Corresponds to the addresses owned.
Object.keys(props.identities).map((key) => {
let identity = props.identities[key]
const identity = props.identities[key]
return h('option', {
value: identity.address,
label: identity.name,
@ -72,7 +72,7 @@ EnsInput.prototype.render = function () {
EnsInput.prototype.componentDidMount = function () {
const network = this.props.network
let resolverAddress = networkResolvers[network]
const resolverAddress = networkResolvers[network]
if (resolverAddress) {
const provider = web3.currentProvider

View File

@ -115,8 +115,9 @@ Notice.prototype.render = function () {
Notice.prototype.componentDidMount = function () {
var node = findDOMNode(this)
linker.setupListener(node)
if (document.getElementsByClassName('notice-box')[0].clientHeight < 310) { this.setState({disclaimerDisabled: false}) }
if (document.getElementsByClassName('notice-box')[0].clientHeight < 310) {
this.setState({disclaimerDisabled: false})
}
}
Notice.prototype.componentWillUnmount = function () {

View File

@ -134,7 +134,6 @@ function failIfFailed (transaction) {
return h('span.error', ' (Rejected)')
}
if (transaction.err) {
return h(Tooltip, {
title: transaction.err.message,
position: 'bottom',
@ -142,5 +141,4 @@ function failIfFailed (transaction) {
h('span.error', ' (Failed)'),
])
}
}

View File

@ -125,14 +125,12 @@ function currentTxView (opts) {
if (txParams) {
log.debug('txParams detected, rendering pending tx')
return h(PendingTx, opts)
} else if (msgParams) {
log.debug('msgParams detected, rendering pending msg')
if (type === 'eth_sign') {
log.debug('rendering eth_sign message')
return h(PendingMsg, opts)
} else if (type === 'personal_sign') {
log.debug('rendering personal_sign message')
return h(PendingPersonalMsg, opts)