1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

fix faulty null checks

This commit is contained in:
Erik Marks 2020-02-12 08:17:13 -08:00
parent 1ae0933897
commit 0103bf8b29
No known key found for this signature in database
GPG Key ID: 11955E59BBB17134
2 changed files with 3 additions and 2 deletions

View File

@ -325,6 +325,7 @@ export default class PermissionsLogController {
getRequestedMethods (request) {
if (
!request.params ||
!request.params[0] ||
typeof request.params[0] !== 'object' ||
Array.isArray(request.params[0])
) {
@ -392,7 +393,7 @@ function getLastIndexOfObjectArray (array, key, value) {
for (let i = array.length - 1; i >= 0; i--) {
if (typeof array[i] !== 'object') {
if (!array[i] || typeof array[i] !== 'object') {
throw new Error(`Encountered non-Object element at index ${i}`)
}

View File

@ -57,7 +57,7 @@ describe('Transaction Controller', function () {
const exposedState = txController.getState()
assert('unapprovedTxs' in exposedState, 'state should have the key unapprovedTxs')
assert('selectedAddressTxList' in exposedState, 'state should have the key selectedAddressTxList')
assert(typeof exposedState.unapprovedTxs === 'object', 'should be an object')
assert(exposedState && typeof exposedState.unapprovedTxs === 'object', 'should be an object')
assert(Array.isArray(exposedState.selectedAddressTxList), 'should be an array')
})
})