|
|
|
@ -1,5 +1,3 @@ |
|
|
|
|
import { createSelector } from 'reselect' |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
CAVEAT_NAMES, |
|
|
|
|
} from '../../../app/scripts/controllers/permissions/enums' |
|
|
|
@ -26,9 +24,8 @@ export function getPermittedAccounts (state, origin) { |
|
|
|
|
* @param {Object} state - The current state. |
|
|
|
|
* @returns {Object} Permitted accounts by origin. |
|
|
|
|
*/ |
|
|
|
|
export const getPermittedAccountsMap = createSelector( |
|
|
|
|
allDomainsSelector, |
|
|
|
|
(domains = {}) => { |
|
|
|
|
export function getPermittedAccountsByOrigin (state) { |
|
|
|
|
const domains = allDomainsSelector(state) |
|
|
|
|
return Object.keys(domains).reduce((acc, domainKey) => { |
|
|
|
|
const accounts = getAccountsFromPermission( |
|
|
|
|
getAccountsPermissionFromDomain(domains[domainKey]) |
|
|
|
@ -38,8 +35,7 @@ export const getPermittedAccountsMap = createSelector( |
|
|
|
|
} |
|
|
|
|
return acc |
|
|
|
|
}, {}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// selector helpers
|
|
|
|
|
|
|
|
|
@ -72,7 +68,7 @@ function getAccountsCaveatFromPermission (accountsPermission = {}) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function allDomainsSelector (state) { |
|
|
|
|
return state.metamask.domains |
|
|
|
|
return state.metamask.domains || {} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function domainSelector (state, origin) { |
|
|
|
|