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

delete targetDomainMetadata selector

This commit is contained in:
Erik Marks 2020-06-16 11:34:08 -07:00
parent d79bf8db2e
commit 28cf728067
4 changed files with 13 additions and 29 deletions

View File

@ -1,19 +1,14 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import PermissionPageContainer from './permission-page-container.component' import PermissionPageContainer from './permission-page-container.component'
import { import { getMetaMaskIdentities } from '../../../selectors'
getTargetDomainMetadata,
getMetaMaskIdentities,
} from '../../../selectors'
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { request, cachedOrigin, selectedIdentities } = ownProps const { selectedIdentities } = ownProps
const targetDomainMetadata = getTargetDomainMetadata(state, request, cachedOrigin)
const allIdentities = getMetaMaskIdentities(state) const allIdentities = getMetaMaskIdentities(state)
const allIdentitiesSelected = Object.keys(selectedIdentities).length === Object.keys(allIdentities).length && selectedIdentities.length > 1 const allIdentitiesSelected = Object.keys(selectedIdentities).length === Object.keys(allIdentities).length && selectedIdentities.length > 1
return { return {
targetDomainMetadata,
allIdentitiesSelected, allIdentitiesSelected,
} }
} }

View File

@ -206,7 +206,6 @@ export default class PermissionConnect extends Component {
const { const {
selectedAccountAddresses, selectedAccountAddresses,
permissionsApproved, permissionsApproved,
origin,
redirecting, redirecting,
targetDomainMetadata, targetDomainMetadata,
} = this.state } = this.state
@ -257,7 +256,7 @@ export default class PermissionConnect extends Component {
}} }}
rejectPermissionsRequest={(requestId) => this.cancelPermissionsRequest(requestId)} rejectPermissionsRequest={(requestId) => this.cancelPermissionsRequest(requestId)}
selectedIdentities={accounts.filter((account) => selectedAccountAddresses.has(account.address))} selectedIdentities={accounts.filter((account) => selectedAccountAddresses.has(account.address))}
cachedOrigin={origin} targetDomainMetadata={targetDomainMetadata}
/> />
)} )}
/> />

View File

@ -6,7 +6,7 @@ import {
getNativeCurrency, getNativeCurrency,
getAccountsWithLabels, getAccountsWithLabels,
getLastConnectedInfo, getLastConnectedInfo,
getTargetDomainMetadata, getDomainMetadata,
getSelectedAddress, getSelectedAddress,
} from '../../selectors' } from '../../selectors'
@ -42,6 +42,15 @@ const mapStateToProps = (state, ownProps) => {
const { origin } = metadata const { origin } = metadata
const nativeCurrency = getNativeCurrency(state) const nativeCurrency = getNativeCurrency(state)
const domainMetadata = getDomainMetadata(state)
const targetDomainMetadata = origin
? domainMetadata[origin] || {
origin,
name: (new URL(origin)).hostname,
icon: null,
}
: null
const accountsWithLabels = getAccountsWithLabels(state) const accountsWithLabels = getAccountsWithLabels(state)
const lastConnectedInfo = getLastConnectedInfo(state) || {} const lastConnectedInfo = getLastConnectedInfo(state) || {}
@ -63,8 +72,6 @@ const mapStateToProps = (state, ownProps) => {
throw new Error('Incorrect path for permissions-connect component') throw new Error('Incorrect path for permissions-connect component')
} }
const targetDomainMetadata = getTargetDomainMetadata(state, permissionsRequest, origin)
return { return {
permissionsRequest, permissionsRequest,
permissionsRequestId, permissionsRequestId,

View File

@ -287,23 +287,6 @@ export function getDomainMetadata (state) {
return state.metamask.domainMetadata return state.metamask.domainMetadata
} }
export function getTargetDomainMetadata (state, request, defaultOrigin) {
const domainMetadata = getDomainMetadata(state)
const { metadata: requestMetadata = {} } = request || {}
const origin = requestMetadata.origin || defaultOrigin
if (!origin) {
return null
}
const hostname = (new URL(origin).hostname)
const targetDomainMetadata = (domainMetadata[origin] || { name: hostname, icon: null })
targetDomainMetadata.origin = origin
return targetDomainMetadata
}
export const getBackgroundMetaMetricState = (state) => { export const getBackgroundMetaMetricState = (state) => {
return { return {
network: getCurrentNetworkId(state), network: getCurrentNetworkId(state),