Skip to content

Commit

Permalink
Subject metadata cleanup (#13090)
Browse files Browse the repository at this point in the history
This PR fixes some subject metadata-related issues that were missed in #13026.
  • Loading branch information
rekmarks authored Dec 13, 2021
1 parent 69e27c8 commit c03b6dd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .storybook/initial-states/approval-screens/token-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export const currentNetworkTxListSample = {

export const subjectMetadata = {
"https://metamask.github.io": {
"origin": "https://metamask.github.io",
"name": "E2E Test Dapp",
"icon": "https://metamask.github.io/test-dapp/metamask-fox.svg",
"lastUpdated": 1620723443380,
"host": "metamask.github.io"
"iconUrl": "https://metamask.github.io/test-dapp/metamask-fox.svg",
"subjectType": "website"
}
}
12 changes: 6 additions & 6 deletions .storybook/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,15 +1175,15 @@ const state = {
subjectMetadata: {
'https://metamask.github.io': {
name: 'E2E Test Dapp',
icon: 'https://metamask.github.io/test-dapp/metamask-fox.svg',
lastUpdated: 1620723443380,
host: 'metamask.github.io',
origin: 'https://metamask.github.io',
iconUrl: 'https://metamask.github.io/test-dapp/metamask-fox.svg',
subjectType: 'website',
},
'https://app.uniswap.org': {
name: 'Uniswap',
icon: './UNI.png',
lastUpdated: 1620723443380,
host: 'app.uniswap.org',
origin: 'https://app.uniswap.org',
iconUrl: './UNI.png',
subjectType: 'website',
},
},
threeBoxSyncingAllowed: false,
Expand Down
1 change: 1 addition & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2634,6 +2634,7 @@ export default class MetamaskController extends EventEmitter {
subjectType = SUBJECT_TYPES.EXTENSION;
this.subjectMetadataController.addSubjectMetadata(origin, {
extensionId: sender.id,
subjectType: SUBJECT_TYPES.EXTENSION,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import PermissionsConnectPermissionList from '../../permissions-connect-permissi
export default class PermissionPageContainerContent extends PureComponent {
static propTypes = {
subjectMetadata: PropTypes.shape({
extensionId: PropTypes.string,
iconUrl: PropTypes.string,
name: PropTypes.string.isRequired,
origin: PropTypes.string.isRequired,
subjectType: PropTypes.string.isRequired,
extensionId: PropTypes.string,
iconUrl: PropTypes.string,
}),
selectedPermissions: PropTypes.object.isRequired,
selectedIdentities: PropTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export default class PermissionPageContainer extends Component {
request: PropTypes.object,
requestMetadata: PropTypes.object,
targetSubjectMetadata: PropTypes.shape({
extensionId: PropTypes.string,
icon: PropTypes.string,
name: PropTypes.string.isRequired,
origin: PropTypes.string.isRequired,
subjectType: PropTypes.string.isRequired,
extensionId: PropTypes.string,
iconUrl: PropTypes.string,
}),
};

Expand Down
2 changes: 1 addition & 1 deletion ui/hooks/useOriginMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function useOriginMetadata(origin) {
if (!origin) {
return null;
}
const url = new URL(origin);

const url = new URL(origin);
const minimumOriginMetadata = {
host: url.host,
hostname: url.hostname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ const mapStateToProps = (state, ownProps) => {
} else {
const targetUrl = new URL(origin);
targetSubjectMetadata = {
host: targetUrl.host,
name: targetUrl.hostname,
origin,
iconUrl: null,
extensionId: null,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PermissionsRedirect.propTypes = {
subjectMetadata: PropTypes.shape({
extensionId: PropTypes.string,
iconUrl: PropTypes.string,
subjectType: PropTypes.string,
name: PropTypes.string.isRequired,
origin: PropTypes.string.isRequired,
}),
Expand Down

0 comments on commit c03b6dd

Please sign in to comment.