Fix permissions domain metadata retrieval (#8821)

* delete targetDomainMetadata selector

* fix permissions connect target domain metadata handling
feature/default_network_editable
Erik Marks 5 years ago committed by GitHub
commit b0187d3247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      ui/app/components/app/permission-page-container/permission-page-container.container.js
  2. 3
      ui/app/pages/permissions-connect/permissions-connect.component.js
  3. 13
      ui/app/pages/permissions-connect/permissions-connect.container.js
  4. 12
      ui/app/selectors/selectors.js

@ -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,
} }
} }

@ -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}
/> />
)} )}
/> />

@ -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,

@ -287,18 +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
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),

Loading…
Cancel
Save