mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
migration 7 - break off TransactionManager substate
This commit is contained in:
parent
bcb86f38cb
commit
99fa9ab13a
@ -68,11 +68,9 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
// tx mgmt
|
// tx mgmt
|
||||||
this.txManager = new TxManager({
|
this.txManager = new TxManager({
|
||||||
txList: this.configManager.getTxList(),
|
initState: initState.TxManager,
|
||||||
txHistoryLimit: 40,
|
txHistoryLimit: 40,
|
||||||
setTxList: this.configManager.setTxList.bind(this.configManager),
|
|
||||||
getSelectedAddress: this.preferencesController.getSelectedAddress.bind(this.preferencesController),
|
getSelectedAddress: this.preferencesController.getSelectedAddress.bind(this.preferencesController),
|
||||||
getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager),
|
|
||||||
getNetwork: this.getStateNetwork.bind(this),
|
getNetwork: this.getStateNetwork.bind(this),
|
||||||
signTransaction: this.keyringController.signTransaction.bind(this.keyringController),
|
signTransaction: this.keyringController.signTransaction.bind(this.keyringController),
|
||||||
provider: this.provider,
|
provider: this.provider,
|
||||||
@ -107,11 +105,14 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
this.preferencesController.store.subscribe((state) => {
|
this.preferencesController.store.subscribe((state) => {
|
||||||
this.store.updateState({ PreferencesController: state })
|
this.store.updateState({ PreferencesController: state })
|
||||||
})
|
})
|
||||||
|
this.txManager.store.subscribe((state) => {
|
||||||
|
this.store.updateState({ TransactionManager: state })
|
||||||
|
})
|
||||||
|
|
||||||
// manual mem state subscriptions
|
// manual mem state subscriptions
|
||||||
this.ethStore.on('update', this.sendUpdate.bind(this))
|
this.ethStore.on('update', this.sendUpdate.bind(this))
|
||||||
this.keyringController.memStore.subscribe(this.sendUpdate.bind(this))
|
this.keyringController.memStore.subscribe(this.sendUpdate.bind(this))
|
||||||
this.txManager.on('update', this.sendUpdate.bind(this))
|
this.txManager.memStore.subscribe(this.sendUpdate.bind(this))
|
||||||
this.messageManager.memStore.subscribe(this.sendUpdate.bind(this))
|
this.messageManager.memStore.subscribe(this.sendUpdate.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
},
|
},
|
||||||
this.state,
|
this.state,
|
||||||
this.ethStore.getState(),
|
this.ethStore.getState(),
|
||||||
this.txManager.getState(),
|
this.txManager.memStore.getState(),
|
||||||
this.messageManager.memStore.getState(),
|
this.messageManager.memStore.getState(),
|
||||||
this.keyringController.memStore.getState(),
|
this.keyringController.memStore.getState(),
|
||||||
this.preferencesController.store.getState(),
|
this.preferencesController.store.getState(),
|
||||||
@ -245,11 +246,13 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
|
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
|
||||||
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
|
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
|
||||||
|
|
||||||
// signing methods
|
// txManager
|
||||||
approveTransaction: txManager.approveTransaction.bind(txManager),
|
approveTransaction: txManager.approveTransaction.bind(txManager),
|
||||||
cancelTransaction: txManager.cancelTransaction.bind(txManager),
|
cancelTransaction: txManager.cancelTransaction.bind(txManager),
|
||||||
signMessage: this.signMessage.bind(this),
|
|
||||||
cancelMessage: messageManager.rejectMsg.bind(messageManager),
|
// messageManager
|
||||||
|
signMessage: this.signMessage.bind(this),
|
||||||
|
cancelMessage: messageManager.rejectMsg.bind(messageManager),
|
||||||
|
|
||||||
// notices
|
// notices
|
||||||
checkNotices: noticeController.updateNoticesList.bind(noticeController),
|
checkNotices: noticeController.updateNoticesList.bind(noticeController),
|
||||||
@ -586,7 +589,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
|
|
||||||
setGasMultiplier (gasMultiplier, cb) {
|
setGasMultiplier (gasMultiplier, cb) {
|
||||||
try {
|
try {
|
||||||
this.configManager.setGasMultiplier(gasMultiplier)
|
this.txManager.setGasMultiplier(gasMultiplier)
|
||||||
cb()
|
cb()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
cb(err)
|
cb(err)
|
||||||
|
38
app/scripts/migrations/007.js
Normal file
38
app/scripts/migrations/007.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
const version = 7
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This migration breaks out the TransactionManager substate
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
const extend = require('xtend')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
version,
|
||||||
|
|
||||||
|
migrate: function (versionedData) {
|
||||||
|
versionedData.meta.version = version
|
||||||
|
try {
|
||||||
|
const state = versionedData.data
|
||||||
|
const newState = transformState(state)
|
||||||
|
versionedData.data = newState
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`MetaMask Migration #${version}` + err.stack)
|
||||||
|
}
|
||||||
|
return Promise.resolve(versionedData)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function transformState (state) {
|
||||||
|
const newState = extend(state, {
|
||||||
|
TransactionManager: {
|
||||||
|
transactions: state.transactions || [],
|
||||||
|
gasMultiplier: state.gasMultiplier || 1,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
delete newState.transactions
|
||||||
|
delete newState.gasMultiplier
|
||||||
|
|
||||||
|
return newState
|
||||||
|
}
|
@ -17,4 +17,5 @@ module.exports = [
|
|||||||
require('./004'),
|
require('./004'),
|
||||||
require('./005'),
|
require('./005'),
|
||||||
require('./006'),
|
require('./006'),
|
||||||
|
require('./007'),
|
||||||
]
|
]
|
||||||
|
@ -2,6 +2,7 @@ const EventEmitter = require('events')
|
|||||||
const async = require('async')
|
const async = require('async')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const Semaphore = require('semaphore')
|
const Semaphore = require('semaphore')
|
||||||
|
const ObservableStore = require('obs-store')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const BN = require('ethereumjs-util').BN
|
const BN = require('ethereumjs-util').BN
|
||||||
const TxProviderUtil = require('./lib/tx-utils')
|
const TxProviderUtil = require('./lib/tx-utils')
|
||||||
@ -10,33 +11,46 @@ const createId = require('./lib/random-id')
|
|||||||
module.exports = class TransactionManager extends EventEmitter {
|
module.exports = class TransactionManager extends EventEmitter {
|
||||||
constructor (opts) {
|
constructor (opts) {
|
||||||
super()
|
super()
|
||||||
this.txList = opts.txList || []
|
this.store = new ObservableStore(extend({
|
||||||
this._setTxList = opts.setTxList
|
txList: [],
|
||||||
|
gasMultiplier: 1,
|
||||||
|
}, opts.initState))
|
||||||
|
this.memStore = new ObservableStore({})
|
||||||
|
// this.networkStore = opts.networkStore || new ObservableStore({})
|
||||||
|
this.getNetwork = opts.getNetwork
|
||||||
|
|
||||||
this.txHistoryLimit = opts.txHistoryLimit
|
this.txHistoryLimit = opts.txHistoryLimit
|
||||||
this.getSelectedAddress = opts.getSelectedAddress
|
this.getSelectedAddress = opts.getSelectedAddress
|
||||||
this.provider = opts.provider
|
this.provider = opts.provider
|
||||||
this.blockTracker = opts.blockTracker
|
this.blockTracker = opts.blockTracker
|
||||||
this.txProviderUtils = new TxProviderUtil(this.provider)
|
this.txProviderUtils = new TxProviderUtil(this.provider)
|
||||||
this.blockTracker.on('block', this.checkForTxInBlock.bind(this))
|
this.blockTracker.on('block', this.checkForTxInBlock.bind(this))
|
||||||
this.getGasMultiplier = opts.getGasMultiplier
|
|
||||||
this.getNetwork = opts.getNetwork
|
|
||||||
this.signEthTx = opts.signTransaction
|
this.signEthTx = opts.signTransaction
|
||||||
this.nonceLock = Semaphore(1)
|
this.nonceLock = Semaphore(1)
|
||||||
|
|
||||||
|
// memstore is computed from diskStore
|
||||||
|
this._updateMemstore()
|
||||||
|
this.store.subscribe(() => this._updateMemstore() )
|
||||||
|
// this.networkStore.subscribe(() => this._updateMemstore() )
|
||||||
}
|
}
|
||||||
|
|
||||||
getState () {
|
getState () {
|
||||||
var selectedAddress = this.getSelectedAddress()
|
return this.memStore.getState()
|
||||||
return {
|
|
||||||
transactions: this.getTxList(),
|
|
||||||
unapprovedTxs: this.getUnapprovedTxList(),
|
|
||||||
selectedAddressTxList: this.getFilteredTxList({metamaskNetworkId: this.getNetwork(), from: selectedAddress}),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the tx list
|
// Returns the tx list
|
||||||
getTxList () {
|
getTxList () {
|
||||||
let network = this.getNetwork()
|
let network = this.getNetwork()
|
||||||
return this.txList.filter(txMeta => txMeta.metamaskNetworkId === network)
|
let fullTxList = this.store.getState().txList
|
||||||
|
return fullTxList.filter(txMeta => txMeta.metamaskNetworkId === network)
|
||||||
|
}
|
||||||
|
|
||||||
|
getGasMultiplier () {
|
||||||
|
return this.store.getState().gasMultiplier
|
||||||
|
}
|
||||||
|
|
||||||
|
setGasMultiplier (gasMultiplier) {
|
||||||
|
return this.store.updateState({ gasMultiplier })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a tx to the txlist
|
// Adds a tx to the txlist
|
||||||
@ -108,7 +122,7 @@ module.exports = class TransactionManager extends EventEmitter {
|
|||||||
id: txId,
|
id: txId,
|
||||||
time: time,
|
time: time,
|
||||||
status: 'unapproved',
|
status: 'unapproved',
|
||||||
gasMultiplier: this.getGasMultiplier() || 1,
|
gasMultiplier: this.getGasMultiplier(),
|
||||||
metamaskNetworkId: this.getNetwork(),
|
metamaskNetworkId: this.getNetwork(),
|
||||||
txParams: txParams,
|
txParams: txParams,
|
||||||
}
|
}
|
||||||
@ -239,7 +253,7 @@ module.exports = class TransactionManager extends EventEmitter {
|
|||||||
|
|
||||||
getTxsByMetaData (key, value, txList = this.getTxList()) {
|
getTxsByMetaData (key, value, txList = this.getTxList()) {
|
||||||
return txList.filter((txMeta) => {
|
return txList.filter((txMeta) => {
|
||||||
if (key in txMeta.txParams) {
|
if (txMeta.txParams[key]) {
|
||||||
return txMeta.txParams[key] === value
|
return txMeta.txParams[key] === value
|
||||||
} else {
|
} else {
|
||||||
return txMeta[key] === value
|
return txMeta[key] === value
|
||||||
@ -352,8 +366,16 @@ module.exports = class TransactionManager extends EventEmitter {
|
|||||||
// Saves the new/updated txList.
|
// Saves the new/updated txList.
|
||||||
// Function is intended only for internal use
|
// Function is intended only for internal use
|
||||||
_saveTxList (txList) {
|
_saveTxList (txList) {
|
||||||
this.txList = txList
|
this.store.updateState({ txList })
|
||||||
this._setTxList(txList)
|
}
|
||||||
|
|
||||||
|
_updateMemstore () {
|
||||||
|
const unapprovedTxs = this.getUnapprovedTxList()
|
||||||
|
const selectedAddressTxList = this.getFilteredTxList({
|
||||||
|
from: this.getSelectedAddress(),
|
||||||
|
metamaskNetworkId: this.getNetwork(),
|
||||||
|
})
|
||||||
|
this.memStore.updateState({ unapprovedTxs, selectedAddressTxList })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<script src="bundle.js"></script>
|
<script src="bundle.js"></script>
|
||||||
<script src="/testem.js"></script>
|
<script src="/testem.js"></script>
|
||||||
|
|
||||||
<iframe src="/development/test.html" height="500px" width="360px">
|
<iframe src="/development/test.html" height="800px" width="500px">
|
||||||
<p>Your browser does not support iframes</p>
|
<p>Your browser does not support iframes</p>
|
||||||
</iframe>
|
</iframe>
|
||||||
</body>
|
</body>
|
||||||
|
@ -3,19 +3,18 @@ const extend = require('xtend')
|
|||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const STORAGE_KEY = 'metamask-persistance-key'
|
const STORAGE_KEY = 'metamask-persistance-key'
|
||||||
const TransactionManager = require('../../app/scripts/transaction-manager')
|
const TransactionManager = require('../../app/scripts/transaction-manager')
|
||||||
|
const noop = () => true
|
||||||
|
|
||||||
describe('Transaction Manager', function() {
|
describe('Transaction Manager', function() {
|
||||||
let txManager
|
let txManager
|
||||||
|
|
||||||
const onTxDoneCb = () => true
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
txManager = new TransactionManager ({
|
txManager = new TransactionManager ({
|
||||||
txList: [],
|
|
||||||
setTxList: () => {},
|
|
||||||
provider: "testnet",
|
provider: "testnet",
|
||||||
txHistoryLimit: 10,
|
txHistoryLimit: 10,
|
||||||
blockTracker: new EventEmitter(),
|
blockTracker: new EventEmitter(),
|
||||||
getNetwork: function(){ return 'unit test' }
|
getNetwork: function(){ return 'unit test' },
|
||||||
|
getSelectedAddress: function(){ return '0xabcd' },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#_saveTxList', function() {
|
describe('#_saveTxList', function() {
|
||||||
it('saves the submitted data to the tx list', function() {
|
it('saves the submitted data to the tx list', function() {
|
||||||
var target = [{ foo: 'bar', metamaskNetworkId: 'unit test' }]
|
var target = [{ foo: 'bar', metamaskNetworkId: 'unit test', txParams: {} }]
|
||||||
txManager._saveTxList(target)
|
txManager._saveTxList(target)
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.equal(result[0].foo, 'bar')
|
assert.equal(result[0].foo, 'bar')
|
||||||
@ -62,8 +61,8 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#addTx', function() {
|
describe('#addTx', function() {
|
||||||
it('adds a tx returned in getTxList', function() {
|
it('adds a tx returned in getTxList', function() {
|
||||||
var tx = { id: 1, status: 'confirmed', metamaskNetworkId: 'unit test' }
|
var tx = { id: 1, status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx, onTxDoneCb)
|
txManager.addTx(tx, noop)
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
@ -73,8 +72,8 @@ describe('Transaction Manager', function() {
|
|||||||
it('cuts off early txs beyond a limit', function() {
|
it('cuts off early txs beyond a limit', function() {
|
||||||
const limit = txManager.txHistoryLimit
|
const limit = txManager.txHistoryLimit
|
||||||
for (let i = 0; i < limit + 1; i++) {
|
for (let i = 0; i < limit + 1; i++) {
|
||||||
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: 'unit test' }
|
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx, onTxDoneCb)
|
txManager.addTx(tx, noop)
|
||||||
}
|
}
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
||||||
@ -84,8 +83,8 @@ describe('Transaction Manager', function() {
|
|||||||
it('cuts off early txs beyond a limit whether or not it is confirmed or rejected', function() {
|
it('cuts off early txs beyond a limit whether or not it is confirmed or rejected', function() {
|
||||||
const limit = txManager.txHistoryLimit
|
const limit = txManager.txHistoryLimit
|
||||||
for (let i = 0; i < limit + 1; i++) {
|
for (let i = 0; i < limit + 1; i++) {
|
||||||
let tx = { id: i, time: new Date(), status: 'rejected', metamaskNetworkId: 'unit test' }
|
let tx = { id: i, time: new Date(), status: 'rejected', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx, onTxDoneCb)
|
txManager.addTx(tx, noop)
|
||||||
}
|
}
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
||||||
@ -93,12 +92,12 @@ describe('Transaction Manager', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('cuts off early txs beyond a limit but does not cut unapproved txs', function() {
|
it('cuts off early txs beyond a limit but does not cut unapproved txs', function() {
|
||||||
var unconfirmedTx = { id: 0, time: new Date(), status: 'unapproved', metamaskNetworkId: 'unit test' }
|
var unconfirmedTx = { id: 0, time: new Date(), status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(unconfirmedTx, onTxDoneCb)
|
txManager.addTx(unconfirmedTx, noop)
|
||||||
const limit = txManager.txHistoryLimit
|
const limit = txManager.txHistoryLimit
|
||||||
for (let i = 1; i < limit + 1; i++) {
|
for (let i = 1; i < limit + 1; i++) {
|
||||||
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: 'unit test' }
|
let tx = { id: i, time: new Date(), status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx, onTxDoneCb)
|
txManager.addTx(tx, noop)
|
||||||
}
|
}
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
assert.equal(result.length, limit, `limit of ${limit} txs enforced`)
|
||||||
@ -110,8 +109,8 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#setTxStatusSigned', function() {
|
describe('#setTxStatusSigned', function() {
|
||||||
it('sets the tx status to signed', function() {
|
it('sets the tx status to signed', function() {
|
||||||
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
|
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx, onTxDoneCb)
|
txManager.addTx(tx, noop)
|
||||||
txManager.setTxStatusSigned(1)
|
txManager.setTxStatusSigned(1)
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
@ -121,20 +120,20 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
it('should emit a signed event to signal the exciton of callback', (done) => {
|
it('should emit a signed event to signal the exciton of callback', (done) => {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
|
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
let onTxDoneCb = function () {
|
let noop = function () {
|
||||||
assert(true, 'event listener has been triggered and onTxDoneCb executed')
|
assert(true, 'event listener has been triggered and noop executed')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
txManager.addTx(tx)
|
txManager.addTx(tx)
|
||||||
txManager.on('1:signed', onTxDoneCb)
|
txManager.on('1:signed', noop)
|
||||||
txManager.setTxStatusSigned(1)
|
txManager.setTxStatusSigned(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#setTxStatusRejected', function() {
|
describe('#setTxStatusRejected', function() {
|
||||||
it('sets the tx status to rejected', function() {
|
it('sets the tx status to rejected', function() {
|
||||||
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
|
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx)
|
txManager.addTx(tx)
|
||||||
txManager.setTxStatusRejected(1)
|
txManager.setTxStatusRejected(1)
|
||||||
var result = txManager.getTxList()
|
var result = txManager.getTxList()
|
||||||
@ -145,13 +144,13 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
it('should emit a rejected event to signal the exciton of callback', (done) => {
|
it('should emit a rejected event to signal the exciton of callback', (done) => {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test' }
|
var tx = { id: 1, status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }
|
||||||
txManager.addTx(tx)
|
txManager.addTx(tx)
|
||||||
let onTxDoneCb = function (err, txId) {
|
let noop = function (err, txId) {
|
||||||
assert(true, 'event listener has been triggered and onTxDoneCb executed')
|
assert(true, 'event listener has been triggered and noop executed')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
txManager.on('1:rejected', onTxDoneCb)
|
txManager.on('1:rejected', noop)
|
||||||
txManager.setTxStatusRejected(1)
|
txManager.setTxStatusRejected(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -159,9 +158,9 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#updateTx', function() {
|
describe('#updateTx', function() {
|
||||||
it('replaces the tx with the same id', function() {
|
it('replaces the tx with the same id', function() {
|
||||||
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
txManager.updateTx({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test' })
|
txManager.updateTx({ id: '1', status: 'blah', hash: 'foo', metamaskNetworkId: 'unit test', txParams: {} })
|
||||||
var result = txManager.getTx('1')
|
var result = txManager.getTx('1')
|
||||||
assert.equal(result.hash, 'foo')
|
assert.equal(result.hash, 'foo')
|
||||||
})
|
})
|
||||||
@ -169,8 +168,8 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#getUnapprovedTxList', function() {
|
describe('#getUnapprovedTxList', function() {
|
||||||
it('returns unapproved txs in a hash', function() {
|
it('returns unapproved txs in a hash', function() {
|
||||||
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
let result = txManager.getUnapprovedTxList()
|
let result = txManager.getUnapprovedTxList()
|
||||||
assert.equal(typeof result, 'object')
|
assert.equal(typeof result, 'object')
|
||||||
assert.equal(result['1'].status, 'unapproved')
|
assert.equal(result['1'].status, 'unapproved')
|
||||||
@ -180,8 +179,8 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#getTx', function() {
|
describe('#getTx', function() {
|
||||||
it('returns a tx with the requested id', function() {
|
it('returns a tx with the requested id', function() {
|
||||||
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '1', status: 'unapproved', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test' }, onTxDoneCb)
|
txManager.addTx({ id: '2', status: 'confirmed', metamaskNetworkId: 'unit test', txParams: {} }, noop)
|
||||||
assert.equal(txManager.getTx('1').status, 'unapproved')
|
assert.equal(txManager.getTx('1').status, 'unapproved')
|
||||||
assert.equal(txManager.getTx('2').status, 'confirmed')
|
assert.equal(txManager.getTx('2').status, 'confirmed')
|
||||||
})
|
})
|
||||||
@ -189,26 +188,33 @@ describe('Transaction Manager', function() {
|
|||||||
|
|
||||||
describe('#getFilteredTxList', function() {
|
describe('#getFilteredTxList', function() {
|
||||||
it('returns a tx with the requested data', function() {
|
it('returns a tx with the requested data', function() {
|
||||||
var foop = 0
|
let txMetas = [
|
||||||
var zoop = 0
|
{ id: 0, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: 'unit test' },
|
||||||
for (let i = 0; i < 10; ++i ){
|
{ id: 1, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: 'unit test' },
|
||||||
let everyOther = i % 2
|
{ id: 2, status: 'unapproved', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: 'unit test' },
|
||||||
txManager.addTx({ id: i,
|
{ id: 3, status: 'unapproved', txParams: { from: '0xbb', to: '0xaa' }, metamaskNetworkId: 'unit test' },
|
||||||
status: everyOther ? 'unapproved' : 'confirmed',
|
{ id: 4, status: 'unapproved', txParams: { from: '0xbb', to: '0xaa' }, metamaskNetworkId: 'unit test' },
|
||||||
metamaskNetworkId: 'unit test',
|
{ id: 5, status: 'confirmed', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: 'unit test' },
|
||||||
txParams: {
|
{ id: 6, status: 'confirmed', txParams: { from: '0xaa', to: '0xbb' }, metamaskNetworkId: 'unit test' },
|
||||||
from: everyOther ? 'foop' : 'zoop',
|
{ id: 7, status: 'confirmed', txParams: { from: '0xbb', to: '0xaa' }, metamaskNetworkId: 'unit test' },
|
||||||
to: everyOther ? 'zoop' : 'foop',
|
{ id: 8, status: 'confirmed', txParams: { from: '0xbb', to: '0xaa' }, metamaskNetworkId: 'unit test' },
|
||||||
}
|
{ id: 9, status: 'confirmed', txParams: { from: '0xbb', to: '0xaa' }, metamaskNetworkId: 'unit test' },
|
||||||
}, onTxDoneCb)
|
]
|
||||||
everyOther ? ++foop : ++zoop
|
txMetas.forEach((txMeta) => txManager.addTx(txMeta, noop))
|
||||||
}
|
let filterParams
|
||||||
assert.equal(txManager.getFilteredTxList({status: 'confirmed', from: 'zoop'}).length, zoop)
|
|
||||||
assert.equal(txManager.getFilteredTxList({status: 'confirmed', to: 'foop'}).length, zoop)
|
filterParams = { status: 'unapproved', from: '0xaa' }
|
||||||
assert.equal(txManager.getFilteredTxList({status: 'confirmed', from: 'foop'}).length, 0)
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 3, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
assert.equal(txManager.getFilteredTxList({status: 'confirmed'}).length, zoop)
|
filterParams = { status: 'unapproved', to: '0xaa' }
|
||||||
assert.equal(txManager.getFilteredTxList({from: 'foop'}).length, foop)
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 2, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
assert.equal(txManager.getFilteredTxList({from: 'zoop'}).length, zoop)
|
filterParams = { status: 'confirmed', from: '0xbb' }
|
||||||
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 3, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
|
filterParams = { status: 'confirmed' }
|
||||||
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
|
filterParams = { from: '0xaa' }
|
||||||
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
|
filterParams = { to: '0xaa' }
|
||||||
|
assert.equal(txManager.getFilteredTxList(filterParams).length, 5, `getFilteredTxList - ${JSON.stringify(filterParams)}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ function tryUnlockMetamask (password) {
|
|||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
dispatch(actions.unlockInProgress())
|
dispatch(actions.unlockInProgress())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.submitPassword`)
|
||||||
background.submitPassword(password, (err) => {
|
background.submitPassword(password, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -207,6 +208,7 @@ function transitionBackward () {
|
|||||||
function confirmSeedWords () {
|
function confirmSeedWords () {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.clearSeedWordCache`)
|
||||||
background.clearSeedWordCache((err, account) => {
|
background.clearSeedWordCache((err, account) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -222,6 +224,7 @@ function confirmSeedWords () {
|
|||||||
function createNewVaultAndRestore (password, seed) {
|
function createNewVaultAndRestore (password, seed) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.createNewVaultAndRestore`)
|
||||||
background.createNewVaultAndRestore(password, seed, (err) => {
|
background.createNewVaultAndRestore(password, seed, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
@ -233,10 +236,12 @@ function createNewVaultAndRestore (password, seed) {
|
|||||||
function createNewVaultAndKeychain (password) {
|
function createNewVaultAndKeychain (password) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.createNewVaultAndKeychain`)
|
||||||
background.createNewVaultAndKeychain(password, (err) => {
|
background.createNewVaultAndKeychain(password, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
}
|
}
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.placeSeedWords`)
|
||||||
background.placeSeedWords((err) => {
|
background.placeSeedWords((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
@ -257,8 +262,10 @@ function revealSeedConfirmation () {
|
|||||||
function requestRevealSeed (password) {
|
function requestRevealSeed (password) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.submitPassword`)
|
||||||
background.submitPassword(password, (err) => {
|
background.submitPassword(password, (err) => {
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.placeSeedWords`)
|
||||||
background.placeSeedWords((err) => {
|
background.placeSeedWords((err) => {
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
@ -270,6 +277,7 @@ function requestRevealSeed (password) {
|
|||||||
function addNewKeyring (type, opts) {
|
function addNewKeyring (type, opts) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.addNewKeyring`)
|
||||||
background.addNewKeyring(type, opts, (err) => {
|
background.addNewKeyring(type, opts, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
@ -281,9 +289,11 @@ function addNewKeyring (type, opts) {
|
|||||||
function importNewAccount (strategy, args) {
|
function importNewAccount (strategy, args) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication('This may take a while, be patient.'))
|
dispatch(actions.showLoadingIndication('This may take a while, be patient.'))
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.importAccountWithStrategy`)
|
||||||
background.importAccountWithStrategy(strategy, args, (err) => {
|
background.importAccountWithStrategy(strategy, args, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.getState`)
|
||||||
background.getState((err, newState) => {
|
background.getState((err, newState) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
@ -305,6 +315,7 @@ function navigateToNewAccountScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addNewAccount () {
|
function addNewAccount () {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.addNewAccount`)
|
||||||
return callBackgroundThenUpdate(background.addNewAccount)
|
return callBackgroundThenUpdate(background.addNewAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,6 +328,7 @@ function showInfoPage () {
|
|||||||
function setCurrentFiat (fiat) {
|
function setCurrentFiat (fiat) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(this.showLoadingIndication())
|
dispatch(this.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setCurrentFiat`)
|
||||||
background.setCurrentFiat(fiat, (data, err) => {
|
background.setCurrentFiat(fiat, (data, err) => {
|
||||||
dispatch(this.hideLoadingIndication())
|
dispatch(this.hideLoadingIndication())
|
||||||
dispatch({
|
dispatch({
|
||||||
@ -335,6 +347,7 @@ function signMsg (msgData) {
|
|||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.signMessage`)
|
||||||
background.signMessage(msgData, (err) => {
|
background.signMessage(msgData, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
|
||||||
@ -346,6 +359,7 @@ function signMsg (msgData) {
|
|||||||
|
|
||||||
function signTx (txData) {
|
function signTx (txData) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setGasMultiplier`)
|
||||||
background.setGasMultiplier(txData.gasMultiplier, (err) => {
|
background.setGasMultiplier(txData.gasMultiplier, (err) => {
|
||||||
if (err) return dispatch(actions.displayWarning(err.message))
|
if (err) return dispatch(actions.displayWarning(err.message))
|
||||||
web3.eth.sendTransaction(txData, (err, data) => {
|
web3.eth.sendTransaction(txData, (err, data) => {
|
||||||
@ -361,6 +375,7 @@ function signTx (txData) {
|
|||||||
|
|
||||||
function sendTx (txData) {
|
function sendTx (txData) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.approveTransaction`)
|
||||||
background.approveTransaction(txData.id, (err) => {
|
background.approveTransaction(txData.id, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
alert(err.message)
|
alert(err.message)
|
||||||
@ -387,11 +402,13 @@ function txError (err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancelMsg (msgData) {
|
function cancelMsg (msgData) {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.cancelMessage`)
|
||||||
background.cancelMessage(msgData.id)
|
background.cancelMessage(msgData.id)
|
||||||
return actions.completedTx(msgData.id)
|
return actions.completedTx(msgData.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelTx (txData) {
|
function cancelTx (txData) {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.cancelTransaction`)
|
||||||
background.cancelTransaction(txData.id)
|
background.cancelTransaction(txData.id)
|
||||||
return actions.completedTx(txData.id)
|
return actions.completedTx(txData.id)
|
||||||
}
|
}
|
||||||
@ -433,6 +450,7 @@ function showImportPage () {
|
|||||||
function agreeToDisclaimer () {
|
function agreeToDisclaimer () {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(this.showLoadingIndication())
|
dispatch(this.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.agreeToDisclaimer`)
|
||||||
background.agreeToDisclaimer((err) => {
|
background.agreeToDisclaimer((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
@ -503,12 +521,14 @@ function updateMetamaskState (newState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lockMetamask () {
|
function lockMetamask () {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setLocked`)
|
||||||
return callBackgroundThenUpdate(background.setLocked)
|
return callBackgroundThenUpdate(background.setLocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAccountDetail (address) {
|
function showAccountDetail (address) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setSelectedAddress`)
|
||||||
background.setSelectedAddress(address, (err) => {
|
background.setSelectedAddress(address, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -581,6 +601,7 @@ function goBackToInitView () {
|
|||||||
function markNoticeRead (notice) {
|
function markNoticeRead (notice) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(this.showLoadingIndication())
|
dispatch(this.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.markNoticeRead`)
|
||||||
background.markNoticeRead(notice, (err, notice) => {
|
background.markNoticeRead(notice, (err, notice) => {
|
||||||
dispatch(this.hideLoadingIndication())
|
dispatch(this.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -612,6 +633,7 @@ function clearNotices () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function markAccountsFound() {
|
function markAccountsFound() {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.markAccountsFound`)
|
||||||
return callBackgroundThenUpdate(background.markAccountsFound)
|
return callBackgroundThenUpdate(background.markAccountsFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,6 +642,7 @@ function markAccountsFound() {
|
|||||||
//
|
//
|
||||||
|
|
||||||
function setRpcTarget (newRpc) {
|
function setRpcTarget (newRpc) {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`)
|
||||||
background.setRpcTarget(newRpc)
|
background.setRpcTarget(newRpc)
|
||||||
return {
|
return {
|
||||||
type: actions.SET_RPC_TARGET,
|
type: actions.SET_RPC_TARGET,
|
||||||
@ -628,6 +651,7 @@ function setRpcTarget (newRpc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setProviderType (type) {
|
function setProviderType (type) {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.setProviderType`)
|
||||||
background.setProviderType(type)
|
background.setProviderType(type)
|
||||||
return {
|
return {
|
||||||
type: actions.SET_PROVIDER_TYPE,
|
type: actions.SET_PROVIDER_TYPE,
|
||||||
@ -636,6 +660,7 @@ function setProviderType (type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useEtherscanProvider () {
|
function useEtherscanProvider () {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.useEtherscanProvider`)
|
||||||
background.useEtherscanProvider()
|
background.useEtherscanProvider()
|
||||||
return {
|
return {
|
||||||
type: actions.USE_ETHERSCAN_PROVIDER,
|
type: actions.USE_ETHERSCAN_PROVIDER,
|
||||||
@ -692,6 +717,7 @@ function exportAccount (address) {
|
|||||||
return function (dispatch) {
|
return function (dispatch) {
|
||||||
dispatch(self.showLoadingIndication())
|
dispatch(self.showLoadingIndication())
|
||||||
|
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.exportAccount`)
|
||||||
background.exportAccount(address, function (err, result) {
|
background.exportAccount(address, function (err, result) {
|
||||||
dispatch(self.hideLoadingIndication())
|
dispatch(self.hideLoadingIndication())
|
||||||
|
|
||||||
@ -715,6 +741,7 @@ function showPrivateKey (key) {
|
|||||||
function saveAccountLabel (account, label) {
|
function saveAccountLabel (account, label) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.saveAccountLabel`)
|
||||||
background.saveAccountLabel(account, label, (err) => {
|
background.saveAccountLabel(account, label, (err) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -736,6 +763,7 @@ function showSendPage () {
|
|||||||
|
|
||||||
function buyEth (address, amount) {
|
function buyEth (address, amount) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.buyEth`)
|
||||||
background.buyEth(address, amount)
|
background.buyEth(address, amount)
|
||||||
dispatch({
|
dispatch({
|
||||||
type: actions.BUY_ETH,
|
type: actions.BUY_ETH,
|
||||||
@ -814,6 +842,7 @@ function coinShiftRquest (data, marketData) {
|
|||||||
if (response.error) return dispatch(actions.displayWarning(response.error))
|
if (response.error) return dispatch(actions.displayWarning(response.error))
|
||||||
var message = `
|
var message = `
|
||||||
Deposit your ${response.depositType} to the address bellow:`
|
Deposit your ${response.depositType} to the address bellow:`
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.createShapeShiftTx`)
|
||||||
background.createShapeShiftTx(response.deposit, response.depositType)
|
background.createShapeShiftTx(response.deposit, response.depositType)
|
||||||
dispatch(actions.showQrView(response.deposit, [message].concat(marketData)))
|
dispatch(actions.showQrView(response.deposit, [message].concat(marketData)))
|
||||||
})
|
})
|
||||||
@ -893,6 +922,7 @@ function callBackgroundThenUpdate (method, ...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function forceUpdateMetamaskState(dispatch){
|
function forceUpdateMetamaskState(dispatch){
|
||||||
|
if (global.METAMASK_DEBUG) console.log(`background.getState`)
|
||||||
background.getState((err, newState) => {
|
background.getState((err, newState) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
|
Loading…
Reference in New Issue
Block a user