mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix TokenRatesController
(#8780)
The `TokenRatesController` was accidentally broken in #8744, when the logic for starting and stopping polling was moved from the `isActive` property to start/stop functions. A reference to the now-obsolete `isActive` property was accidentally left behind, resulting in no exchange rate updates.
This commit is contained in:
parent
0b86283c10
commit
1f8a7a72c9
@ -27,9 +27,6 @@ export default class TokenRatesController {
|
|||||||
* Updates exchange rates for all tokens
|
* Updates exchange rates for all tokens
|
||||||
*/
|
*/
|
||||||
async updateExchangeRates () {
|
async updateExchangeRates () {
|
||||||
if (!this.isActive) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const contractExchangeRates = {}
|
const contractExchangeRates = {}
|
||||||
const nativeCurrency = this.currency ? this.currency.state.nativeCurrency.toLowerCase() : 'eth'
|
const nativeCurrency = this.currency ? this.currency.state.nativeCurrency.toLowerCase() : 'eth'
|
||||||
const pairs = this._tokens.map((token) => token.address).join(',')
|
const pairs = this._tokens.map((token) => token.address).join(',')
|
||||||
|
@ -6,18 +6,20 @@ import ObservableStore from 'obs-store'
|
|||||||
describe('TokenRatesController', function () {
|
describe('TokenRatesController', function () {
|
||||||
it('should listen for preferences store updates', function () {
|
it('should listen for preferences store updates', function () {
|
||||||
const preferences = new ObservableStore({ tokens: [] })
|
const preferences = new ObservableStore({ tokens: [] })
|
||||||
const controller = new TokenRatesController({ preferences })
|
|
||||||
preferences.putState({ tokens: ['foo'] })
|
preferences.putState({ tokens: ['foo'] })
|
||||||
|
const controller = new TokenRatesController({ preferences })
|
||||||
assert.deepEqual(controller._tokens, ['foo'])
|
assert.deepEqual(controller._tokens, ['foo'])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should poll on correct interval', async function () {
|
it('should poll on correct interval', async function () {
|
||||||
const stub = sinon.stub(global, 'setInterval')
|
const stub = sinon.stub(global, 'setInterval')
|
||||||
const rateController = new TokenRatesController() // eslint-disable-line no-new
|
const preferences = new ObservableStore({ tokens: [] })
|
||||||
rateController.start(1337)
|
preferences.putState({ tokens: ['foo'] })
|
||||||
|
const controller = new TokenRatesController({ preferences })
|
||||||
|
controller.start(1337)
|
||||||
|
|
||||||
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
assert.strictEqual(stub.getCall(0).args[1], 1337)
|
||||||
stub.restore()
|
stub.restore()
|
||||||
rateController.stop()
|
controller.stop()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user