mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove dead code from eth-store
This commit is contained in:
parent
c9585f166f
commit
977405fc7d
@ -18,10 +18,6 @@ class EthereumStore extends ObservableStore {
|
|||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
super({
|
super({
|
||||||
accounts: {},
|
accounts: {},
|
||||||
transactions: {},
|
|
||||||
currentBlockNumber: '0',
|
|
||||||
currentBlockHash: '',
|
|
||||||
currentBlockGasLimit: '',
|
|
||||||
})
|
})
|
||||||
this._provider = opts.provider
|
this._provider = opts.provider
|
||||||
this._query = new EthQuery(this._provider)
|
this._query = new EthQuery(this._provider)
|
||||||
@ -50,21 +46,6 @@ class EthereumStore extends ObservableStore {
|
|||||||
this.updateState({ accounts })
|
this.updateState({ accounts })
|
||||||
}
|
}
|
||||||
|
|
||||||
addTransaction (txHash) {
|
|
||||||
const transactions = this.getState().transactions
|
|
||||||
transactions[txHash] = {}
|
|
||||||
this.updateState({ transactions })
|
|
||||||
if (!this._currentBlockNumber) return
|
|
||||||
this._updateTransaction(this._currentBlockNumber, txHash, noop)
|
|
||||||
}
|
|
||||||
|
|
||||||
removeTransaction (txHash) {
|
|
||||||
const transactions = this.getState().transactions
|
|
||||||
delete transactions[txHash]
|
|
||||||
this.updateState({ transactions })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// private
|
// private
|
||||||
//
|
//
|
||||||
@ -72,12 +53,9 @@ class EthereumStore extends ObservableStore {
|
|||||||
_updateForBlock (block) {
|
_updateForBlock (block) {
|
||||||
const blockNumber = '0x' + block.number.toString('hex')
|
const blockNumber = '0x' + block.number.toString('hex')
|
||||||
this._currentBlockNumber = blockNumber
|
this._currentBlockNumber = blockNumber
|
||||||
this.updateState({ currentBlockNumber: parseInt(blockNumber) })
|
|
||||||
this.updateState({ currentBlockHash: `0x${block.hash.toString('hex')}`})
|
|
||||||
this.updateState({ currentBlockGasLimit: `0x${block.gasLimit.toString('hex')}` })
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
this._updateAccounts.bind(this),
|
this._updateAccounts.bind(this),
|
||||||
this._updateTransactions.bind(this, blockNumber),
|
|
||||||
], (err) => {
|
], (err) => {
|
||||||
if (err) return console.error(err)
|
if (err) return console.error(err)
|
||||||
this.emit('block', this.getState())
|
this.emit('block', this.getState())
|
||||||
@ -104,26 +82,6 @@ class EthereumStore extends ObservableStore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateTransactions (block, cb = noop) {
|
|
||||||
const transactions = this.getState().transactions
|
|
||||||
const txHashes = Object.keys(transactions)
|
|
||||||
async.each(txHashes, this._updateTransaction.bind(this, block), cb)
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateTransaction (block, txHash, cb = noop) {
|
|
||||||
// would use the block here to determine how many confirmations the tx has
|
|
||||||
const transactions = this.getState().transactions
|
|
||||||
this._query.getTransaction(txHash, (err, result) => {
|
|
||||||
if (err) return cb(err)
|
|
||||||
// only populate if the entry is still present
|
|
||||||
if (transactions[txHash]) {
|
|
||||||
transactions[txHash] = result
|
|
||||||
this.updateState({ transactions })
|
|
||||||
}
|
|
||||||
cb(null, result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
_getAccount (address, cb = noop) {
|
_getAccount (address, cb = noop) {
|
||||||
const query = this._query
|
const query = this._query
|
||||||
async.parallel({
|
async.parallel({
|
||||||
|
Loading…
Reference in New Issue
Block a user