1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix error when fetchParams is null (#9757)

If the swaps state is cleared in between the initial quote fetch and
the subsequent poll fetch, a `TypeError` will be thrown due to
`fetchParams` being set to `null`.

This is of no functional consequence, as `fetchParams` _should_ be
`null` in this case, and and no further action should be taken.

The optional chaining operator is now used to ensure the call no longer
throws.
This commit is contained in:
Mark Stacey 2020-10-29 15:52:04 -02:30 committed by GitHub
parent 14161e37da
commit 4086f7b4d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,7 @@ export default class SwapsController {
pollForNewQuotes () {
this.pollingTimeout = setTimeout(() => {
const { swapsState } = this.store.getState()
this.fetchAndSetQuotes(swapsState.fetchParams, swapsState.fetchParams.metaData, true)
this.fetchAndSetQuotes(swapsState.fetchParams, swapsState.fetchParams?.metaData, true)
}, QUOTE_POLLING_INTERVAL)
}