Skip to content

Commit 1877c07

Browse files
committed
Merge branch 'master' of github.com:MetaMask/metamask-extension into BreakOutKeyringController
2 parents 443b1a8 + 6ca519e commit 1877c07

File tree

12 files changed

+663
-56
lines changed

12 files changed

+663
-56
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Current Master
44

5+
- Fix bug that could mis-render token balances when very small. (Not actually included in 3.9.9)
6+
7+
## 3.10.3 2017-9-21
8+
59
- Fix bug where metamask-dapp connections are lost on rpc error
610
- Fix bug that would sometimes display transactions as failed that could be successfully mined.
711

app/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "MetaMask",
33
"short_name": "Metamask",
4-
"version": "3.10.2",
4+
"version": "3.10.3",
55
"manifest_version": 2,
66
"author": "https://metamask.io",
77
"description": "Ethereum Browser Extension",

app/scripts/controllers/balance.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ const BN = require('ethereumjs-util').BN
55
class BalanceController {
66

77
constructor (opts = {}) {
8-
const { address, accountTracker, txController } = opts
8+
const { address, accountTracker, txController, blockTracker } = opts
99
this.address = address
1010
this.accountTracker = accountTracker
1111
this.txController = txController
12+
this.blockTracker = blockTracker
1213

1314
const initState = {
1415
ethBalance: undefined,
1516
}
1617
this.store = new ObservableStore(initState)
1718

1819
this.balanceCalc = new PendingBalanceCalculator({
19-
getBalance: () => Promise.resolve(this._getBalance()),
20+
getBalance: () => this._getBalance(),
2021
getPendingTransactions: this._getPendingTransactions.bind(this),
2122
})
2223

23-
this.registerUpdates()
24+
this._registerUpdates()
2425
}
2526

2627
async updateBalance () {
@@ -30,29 +31,29 @@ class BalanceController {
3031
})
3132
}
3233

33-
registerUpdates () {
34+
_registerUpdates () {
3435
const update = this.updateBalance.bind(this)
3536
this.txController.on('submitted', update)
3637
this.txController.on('confirmed', update)
3738
this.txController.on('failed', update)
38-
this.txController.blockTracker.on('block', update)
39+
this.accountTracker.store.subscribe(update)
40+
this.blockTracker.on('block', update)
3941
}
4042

41-
_getBalance () {
42-
const store = this.accountTracker.getState()
43-
const balances = store.accounts
44-
const entry = balances[this.address]
43+
async _getBalance () {
44+
const { accounts } = this.accountTracker.store.getState()
45+
const entry = accounts[this.address]
4546
const balance = entry.balance
4647
return balance ? new BN(balance.substring(2), 16) : undefined
4748
}
4849

49-
_getPendingTransactions () {
50+
async _getPendingTransactions () {
5051
const pending = this.txController.getFilteredTxList({
5152
from: this.address,
5253
status: 'submitted',
5354
err: undefined,
5455
})
55-
return Promise.resolve(pending)
56+
return pending
5657
}
5758

5859
}

app/scripts/controllers/computed-balances.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ const BalanceController = require('./balance')
55
class ComputedbalancesController {
66

77
constructor (opts = {}) {
8-
const { accountTracker, txController } = opts
8+
const { accountTracker, txController, blockTracker } = opts
99
this.accountTracker = accountTracker
1010
this.txController = txController
11+
this.blockTracker = blockTracker
1112

1213
const initState = extend({
1314
computedBalances: {},
@@ -19,15 +20,15 @@ class ComputedbalancesController {
1920
}
2021

2122
updateAllBalances () {
22-
for (let address in this.balances) {
23+
for (let address in this.accountTracker.store.getState().accounts) {
2324
this.balances[address].updateBalance()
2425
}
2526
}
2627

2728
_initBalanceUpdating () {
28-
const store = this.accountTracker.getState()
29+
const store = this.accountTracker.store.getState()
2930
this.addAnyAccountsFromStore(store)
30-
this.accountTracker.subscribe(this.addAnyAccountsFromStore.bind(this))
31+
this.accountTracker.store.subscribe(this.addAnyAccountsFromStore.bind(this))
3132
}
3233

3334
addAnyAccountsFromStore(store) {
@@ -50,6 +51,7 @@ class ComputedbalancesController {
5051
address,
5152
accountTracker: this.accountTracker,
5253
txController: this.txController,
54+
blockTracker: this.blockTracker,
5355
})
5456
updater.store.subscribe((accountBalance) => {
5557
let newState = this.store.getState()

0 commit comments

Comments
 (0)