mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove usages of xtend from the background scripts (#7796)
This commit is contained in:
parent
ac01c5c89a
commit
25fe4adaa7
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
import { getRandomArrayItem } from '../lib/util'
|
import { getRandomArrayItem } from '../lib/util'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,7 +20,7 @@ class ABTestController {
|
|||||||
*/
|
*/
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const { initState } = opts
|
const { initState } = opts
|
||||||
this.store = new ObservableStore(extend({
|
this.store = new ObservableStore(Object.assign({
|
||||||
abTests: {
|
abTests: {
|
||||||
fullScreenVsPopup: this._getRandomizedTestGroupName('fullScreenVsPopup'),
|
fullScreenVsPopup: this._getRandomizedTestGroupName('fullScreenVsPopup'),
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
class AppStateController {
|
class AppStateController {
|
||||||
/**
|
/**
|
||||||
@ -11,7 +10,7 @@ class AppStateController {
|
|||||||
const { preferences } = preferencesStore.getState()
|
const { preferences } = preferencesStore.getState()
|
||||||
|
|
||||||
this.onInactiveTimeout = onInactiveTimeout || (() => {})
|
this.onInactiveTimeout = onInactiveTimeout || (() => {})
|
||||||
this.store = new ObservableStore(extend({
|
this.store = new ObservableStore(Object.assign({
|
||||||
timeoutMinutes: 0,
|
timeoutMinutes: 0,
|
||||||
mkrMigrationReminderTimestamp: null,
|
mkrMigrationReminderTimestamp: null,
|
||||||
}, initState))
|
}, initState))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} CachedBalancesOptions
|
* @typedef {Object} CachedBalancesOptions
|
||||||
@ -24,7 +23,7 @@ class CachedBalancesController {
|
|||||||
this.accountTracker = accountTracker
|
this.accountTracker = accountTracker
|
||||||
this.getNetwork = getNetwork
|
this.getNetwork = getNetwork
|
||||||
|
|
||||||
const initState = extend({
|
const initState = Object.assign({
|
||||||
cachedBalances: {},
|
cachedBalances: {},
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
|
|
||||||
// every ten minutes
|
// every ten minutes
|
||||||
@ -8,7 +7,7 @@ const POLLING_INTERVAL = 10 * 60 * 1000
|
|||||||
class InfuraController {
|
class InfuraController {
|
||||||
|
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const initState = extend({
|
const initState = Object.assign({
|
||||||
infuraNetworkStatus: {},
|
infuraNetworkStatus: {},
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +26,7 @@ class OnboardingController {
|
|||||||
const initialTransientState = {
|
const initialTransientState = {
|
||||||
onboardingTabs: {},
|
onboardingTabs: {},
|
||||||
}
|
}
|
||||||
const initState = extend(
|
const initState = Object.assign(
|
||||||
{
|
{
|
||||||
seedPhraseBackedUp: true,
|
seedPhraseBackedUp: true,
|
||||||
},
|
},
|
||||||
|
@ -2,8 +2,6 @@ import ObservableStore from 'obs-store'
|
|||||||
import { addInternalMethodPrefix } from './permissions'
|
import { addInternalMethodPrefix } from './permissions'
|
||||||
import { normalize as normalizeAddress } from 'eth-sig-util'
|
import { normalize as normalizeAddress } from 'eth-sig-util'
|
||||||
import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
|
import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
|
|
||||||
class PreferencesController {
|
class PreferencesController {
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ class PreferencesController {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const initState = extend({
|
const initState = Object.assign({
|
||||||
frequentRpcListDetail: [],
|
frequentRpcListDetail: [],
|
||||||
currentAccountTab: 'history',
|
currentAccountTab: 'history',
|
||||||
accountTokens: {},
|
accountTokens: {},
|
||||||
@ -489,7 +487,7 @@ class PreferencesController {
|
|||||||
})
|
})
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
const rpcDetail = rpcList[index]
|
const rpcDetail = rpcList[index]
|
||||||
const updatedRpc = extend(rpcDetail, newRpcDetails)
|
const updatedRpc = { ...rpcDetail, ...newRpcDetails }
|
||||||
rpcList[index] = updatedRpc
|
rpcList[index] = updatedRpc
|
||||||
this.store.updateState({ frequentRpcListDetail: rpcList })
|
this.store.updateState({ frequentRpcListDetail: rpcList })
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import extend from 'xtend'
|
|
||||||
import EthQuery from 'eth-query'
|
import EthQuery from 'eth-query'
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
import pify from 'pify'
|
import pify from 'pify'
|
||||||
@ -33,7 +32,7 @@ class RecentBlocksController {
|
|||||||
this.ethQuery = new EthQuery(provider)
|
this.ethQuery = new EthQuery(provider)
|
||||||
this.historyLength = opts.historyLength || 40
|
this.historyLength = opts.historyLength || 40
|
||||||
|
|
||||||
const initState = extend({
|
const initState = Object.assign({
|
||||||
recentBlocks: [],
|
recentBlocks: [],
|
||||||
}, opts.initState)
|
}, opts.initState)
|
||||||
this.store = new ObservableStore(initState)
|
this.store = new ObservableStore(initState)
|
||||||
@ -121,11 +120,12 @@ class RecentBlocksController {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
mapTransactionsToPrices (newBlock) {
|
mapTransactionsToPrices (newBlock) {
|
||||||
const block = extend(newBlock, {
|
const block = {
|
||||||
|
...newBlock,
|
||||||
gasPrices: newBlock.transactions.map((tx) => {
|
gasPrices: newBlock.transactions.map((tx) => {
|
||||||
return tx.gasPrice
|
return tx.gasPrice
|
||||||
}),
|
}),
|
||||||
})
|
}
|
||||||
delete block.transactions
|
delete block.transactions
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import extend from 'xtend'
|
|
||||||
import EventEmitter from 'safe-event-emitter'
|
import EventEmitter from 'safe-event-emitter'
|
||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
@ -32,7 +31,7 @@ class TransactionStateManager extends EventEmitter {
|
|||||||
super()
|
super()
|
||||||
|
|
||||||
this.store = new ObservableStore(
|
this.store = new ObservableStore(
|
||||||
extend({
|
Object.assign({
|
||||||
transactions: [],
|
transactions: [],
|
||||||
}, initState))
|
}, initState))
|
||||||
this.txHistoryLimit = txHistoryLimit
|
this.txHistoryLimit = txHistoryLimit
|
||||||
@ -48,7 +47,7 @@ class TransactionStateManager extends EventEmitter {
|
|||||||
if (netId === 'loading') {
|
if (netId === 'loading') {
|
||||||
throw new Error('MetaMask is having trouble connecting to the network')
|
throw new Error('MetaMask is having trouble connecting to the network')
|
||||||
}
|
}
|
||||||
return extend({
|
return Object.assign({
|
||||||
id: createId(),
|
id: createId(),
|
||||||
time: (new Date()).getTime(),
|
time: (new Date()).getTime(),
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
@ -222,7 +221,7 @@ class TransactionStateManager extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
updateTxParams (txId, txParams) {
|
updateTxParams (txId, txParams) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
txMeta.txParams = extend(txMeta.txParams, txParams)
|
txMeta.txParams = { ...txMeta.txParams, ...txParams }
|
||||||
this.updateTx(txMeta, `txStateManager#updateTxParams`)
|
this.updateTx(txMeta, `txStateManager#updateTxParams`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ This migration moves state from the flat state trie into KeyringController subst
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
import clone from 'clone'
|
import clone from 'clone'
|
||||||
|
|
||||||
|
|
||||||
@ -30,13 +28,14 @@ export default {
|
|||||||
|
|
||||||
function selectSubstateForKeyringController (state) {
|
function selectSubstateForKeyringController (state) {
|
||||||
const config = state.config
|
const config = state.config
|
||||||
const newState = extend(state, {
|
const newState = {
|
||||||
|
...state,
|
||||||
KeyringController: {
|
KeyringController: {
|
||||||
vault: state.vault,
|
vault: state.vault,
|
||||||
selectedAccount: config.selectedAccount,
|
selectedAccount: config.selectedAccount,
|
||||||
walletNicknames: state.walletNicknames,
|
walletNicknames: state.walletNicknames,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
delete newState.vault
|
delete newState.vault
|
||||||
delete newState.walletNicknames
|
delete newState.walletNicknames
|
||||||
delete newState.config.selectedAccount
|
delete newState.config.selectedAccount
|
||||||
|
@ -6,8 +6,6 @@ This migration moves KeyringController.selectedAddress to PreferencesController.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
import clone from 'clone'
|
import clone from 'clone'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -31,11 +29,12 @@ function migrateState (state) {
|
|||||||
const keyringSubstate = state.KeyringController
|
const keyringSubstate = state.KeyringController
|
||||||
|
|
||||||
// add new state
|
// add new state
|
||||||
const newState = extend(state, {
|
const newState = {
|
||||||
|
...state,
|
||||||
PreferencesController: {
|
PreferencesController: {
|
||||||
selectedAddress: keyringSubstate.selectedAccount,
|
selectedAddress: keyringSubstate.selectedAccount,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
// rm old state
|
// rm old state
|
||||||
delete newState.KeyringController.selectedAccount
|
delete newState.KeyringController.selectedAccount
|
||||||
|
@ -6,8 +6,6 @@ This migration breaks out the TransactionManager substate
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
import clone from 'clone'
|
import clone from 'clone'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -28,12 +26,13 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformState (state) {
|
function transformState (state) {
|
||||||
const newState = extend(state, {
|
const newState = {
|
||||||
|
...state,
|
||||||
TransactionManager: {
|
TransactionManager: {
|
||||||
transactions: state.transactions || [],
|
transactions: state.transactions || [],
|
||||||
gasMultiplier: state.gasMultiplier || 1,
|
gasMultiplier: state.gasMultiplier || 1,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
delete newState.transactions
|
delete newState.transactions
|
||||||
delete newState.gasMultiplier
|
delete newState.gasMultiplier
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ This migration breaks out the NoticeController substate
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extend from 'xtend'
|
|
||||||
|
|
||||||
import clone from 'clone'
|
import clone from 'clone'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -28,11 +26,12 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function transformState (state) {
|
function transformState (state) {
|
||||||
const newState = extend(state, {
|
const newState = {
|
||||||
|
...state,
|
||||||
NoticeController: {
|
NoticeController: {
|
||||||
noticesList: state.noticesList || [],
|
noticesList: state.noticesList || [],
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
delete newState.noticesList
|
delete newState.noticesList
|
||||||
|
|
||||||
return newState
|
return newState
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import extend from 'xtend'
|
|
||||||
import { BN } from 'ethereumjs-util'
|
import { BN } from 'ethereumjs-util'
|
||||||
|
|
||||||
const template = {
|
const template = {
|
||||||
@ -23,7 +22,7 @@ class TxGenerator {
|
|||||||
let nonce = fromNonce || this.txs.length
|
let nonce = fromNonce || this.txs.length
|
||||||
const txs = []
|
const txs = []
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
txs.push(extend(template, {
|
txs.push(Object.assign({}, template, {
|
||||||
txParams: {
|
txParams: {
|
||||||
nonce: hexify(nonce++),
|
nonce: hexify(nonce++),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user