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 PermissionPageContainer from './permission-page-container.component'
import {
getTargetDomainMetadata,
getMetaMaskIdentities,
} from '../../../selectors'
import { getMetaMaskIdentities } from '../../../selectors'
const mapStateToProps = (state, ownProps) => {
const { request, cachedOrigin, selectedIdentities } = ownProps
const targetDomainMetadata = getTargetDomainMetadata(state, request, cachedOrigin)
const { selectedIdentities } = ownProps
const allIdentities = getMetaMaskIdentities(state)
const allIdentitiesSelected = Object.keys(selectedIdentities).length === Object.keys(allIdentities).length && selectedIdentities.length > 1
return {
targetDomainMetadata,
allIdentitiesSelected,
}
}

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

@ -6,7 +6,7 @@ import {
getNativeCurrency,
getAccountsWithLabels,
getLastConnectedInfo,
getTargetDomainMetadata,
getDomainMetadata,
getSelectedAddress,
} from '../../selectors'
@ -42,6 +42,15 @@ const mapStateToProps = (state, ownProps) => {
const { origin } = metadata
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 lastConnectedInfo = getLastConnectedInfo(state) || {}
@ -63,8 +72,6 @@ const mapStateToProps = (state, ownProps) => {
throw new Error('Incorrect path for permissions-connect component')
}
const targetDomainMetadata = getTargetDomainMetadata(state, permissionsRequest, origin)
return {
permissionsRequest,
permissionsRequestId,

@ -287,18 +287,6 @@ export function getDomainMetadata (state) {
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) => {
return {
network: getCurrentNetworkId(state),

Loading…
Cancel
Save