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

Display the address icon for the contract requesting spending cap instead of the dapp/url icon (#17858)

This commit is contained in:
Vladimir Saric 2023-02-23 15:54:04 +01:00 committed by GitHub
parent 32b9237df3
commit 4c598b330e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 68 deletions

View File

@ -2,7 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { getAccountLink } from '@metamask/etherscan-link'; import { getAccountLink } from '@metamask/etherscan-link';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import classnames from 'classnames';
import Box from '../../../ui/box'; import Box from '../../../ui/box';
import Button from '../../../ui/button/button.component'; import Button from '../../../ui/button/button.component';
import Tooltip from '../../../ui/tooltip/tooltip'; import Tooltip from '../../../ui/tooltip/tooltip';
@ -23,7 +22,6 @@ import {
AlignItems, AlignItems,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard'; import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
import UrlIcon from '../../../ui/url-icon/url-icon';
import { getAddressBookEntry } from '../../../../selectors'; import { getAddressBookEntry } from '../../../../selectors';
import { TokenStandard } from '../../../../../shared/constants/transaction'; import { TokenStandard } from '../../../../../shared/constants/transaction';
import NftCollectionImage from '../../../ui/nft-collection-image/nft-collection-image'; import NftCollectionImage from '../../../ui/nft-collection-image/nft-collection-image';
@ -36,8 +34,6 @@ export default function ContractDetailsModal({
toAddress, toAddress,
chainId, chainId,
rpcPrefs, rpcPrefs,
origin,
siteImage,
tokenId, tokenId,
assetName, assetName,
assetStandard, assetStandard,
@ -207,30 +203,11 @@ export default function ContractDetailsModal({
borderColor={BorderColor.borderDefault} borderColor={BorderColor.borderDefault}
className="contract-details-modal__content__contract" className="contract-details-modal__content__contract"
> >
{nft ? (
<Identicon <Identicon
className="contract-details-modal__content__contract__identicon" className="contract-details-modal__content__contract__identicon"
diameter={24} diameter={24}
address={toAddress} address={toAddress}
/> />
) : (
<UrlIcon
className={classnames({
'contract-details-modal__content__contract__identicon-for-unknown-contact':
addressBookEntry?.data?.name === undefined,
'contract-details-modal__content__contract__identicon':
addressBookEntry?.data?.name !== undefined,
})}
fallbackClassName={classnames({
'contract-details-modal__content__contract__identicon-for-unknown-contact':
addressBookEntry?.data?.name === undefined,
'contract-details-modal__content__contract__identicon':
addressBookEntry?.data?.name !== undefined,
})}
name={origin}
url={siteImage}
/>
)}
<Box data-testid="recipient"> <Box data-testid="recipient">
<Typography <Typography
fontWeight={FONT_WEIGHT.BOLD} fontWeight={FONT_WEIGHT.BOLD}
@ -341,14 +318,6 @@ ContractDetailsModal.propTypes = {
* RPC prefs of the current network * RPC prefs of the current network
*/ */
rpcPrefs: PropTypes.object, rpcPrefs: PropTypes.object,
/**
* Dapp URL
*/
origin: PropTypes.string,
/**
* Dapp image
*/
siteImage: PropTypes.string,
/** /**
* The token id of the NFT * The token id of the NFT
*/ */

View File

@ -33,16 +33,6 @@ export default {
type: 'object', type: 'object',
}, },
}, },
origin: {
control: {
type: 'text',
},
},
siteImage: {
control: {
type: 'text',
},
},
}, },
args: { args: {
tokenName: 'DAI', tokenName: 'DAI',
@ -50,8 +40,6 @@ export default {
toAddress: '0x9bc5baf874d2da8d216ae9f137804184ee5afef4', toAddress: '0x9bc5baf874d2da8d216ae9f137804184ee5afef4',
chainId: '0x3', chainId: '0x3',
rpcPrefs: {}, rpcPrefs: {},
origin: 'https://metamask.github.io',
siteImage: 'https://metamask.github.io/test-dapp/metamask-fox.svg',
}, },
}; };

View File

@ -11,10 +11,6 @@
box-shadow: none; box-shadow: none;
background: none; background: none;
} }
&__identicon-for-unknown-contact {
margin: 16px;
}
} }
} }
} }

View File

@ -62,10 +62,6 @@ export default class SignatureRequest extends PureComponent {
* RPC prefs of the current network * RPC prefs of the current network
*/ */
rpcPrefs: PropTypes.object, rpcPrefs: PropTypes.object,
/**
* Dapp image
*/
siteImage: PropTypes.string,
conversionRate: PropTypes.number, conversionRate: PropTypes.number,
nativeCurrency: PropTypes.string, nativeCurrency: PropTypes.string,
provider: PropTypes.object, provider: PropTypes.object,
@ -157,7 +153,6 @@ export default class SignatureRequest extends PureComponent {
hardwareWalletRequiresConnection, hardwareWalletRequiresConnection,
chainId, chainId,
rpcPrefs, rpcPrefs,
siteImage,
txData, txData,
subjectMetadata, subjectMetadata,
conversionRate, conversionRate,
@ -309,8 +304,6 @@ export default class SignatureRequest extends PureComponent {
toAddress={verifyingContract} toAddress={verifyingContract}
chainId={chainId} chainId={chainId}
rpcPrefs={rpcPrefs} rpcPrefs={rpcPrefs}
origin={origin}
siteImage={siteImage}
onClose={() => this.setState({ showContractDetails: false })} onClose={() => this.setState({ showContractDetails: false })}
isContractRequestingSignature isContractRequestingSignature
/> />

View File

@ -32,20 +32,15 @@ function mapStateToProps(state, ownProps) {
const isLedgerWallet = isAddressLedger(state, from); const isLedgerWallet = isAddressLedger(state, from);
const chainId = getCurrentChainId(state); const chainId = getCurrentChainId(state);
const rpcPrefs = getRpcPrefsForCurrentProvider(state); const rpcPrefs = getRpcPrefsForCurrentProvider(state);
const subjectMetadata = getSubjectMetadata(state);
const unconfirmedMessagesList = unconfirmedMessagesHashSelector(state); const unconfirmedMessagesList = unconfirmedMessagesHashSelector(state);
const unapprovedMessagesCount = getTotalUnapprovedMessagesCount(state); const unapprovedMessagesCount = getTotalUnapprovedMessagesCount(state);
const { iconUrl: siteImage = '' } =
subjectMetadata[txData.msgParams.origin] || {};
return { return {
provider, provider,
isLedgerWallet, isLedgerWallet,
hardwareWalletRequiresConnection, hardwareWalletRequiresConnection,
chainId, chainId,
rpcPrefs, rpcPrefs,
siteImage,
unconfirmedMessagesList, unconfirmedMessagesList,
unapprovedMessagesCount, unapprovedMessagesCount,
mostRecentOverviewPage: getMostRecentOverviewPage(state), mostRecentOverviewPage: getMostRecentOverviewPage(state),
@ -85,7 +80,6 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
hardwareWalletRequiresConnection, hardwareWalletRequiresConnection,
chainId, chainId,
rpcPrefs, rpcPrefs,
siteImage,
conversionRate, conversionRate,
nativeCurrency, nativeCurrency,
provider, provider,
@ -138,7 +132,6 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
hardwareWalletRequiresConnection, hardwareWalletRequiresConnection,
chainId, chainId,
rpcPrefs, rpcPrefs,
siteImage,
conversionRate, conversionRate,
nativeCurrency, nativeCurrency,
provider, provider,

View File

@ -518,8 +518,6 @@ export default function TokenAllowance({
toAddress={toAddress} toAddress={toAddress}
chainId={fullTxData.chainId} chainId={fullTxData.chainId}
rpcPrefs={rpcPrefs} rpcPrefs={rpcPrefs}
origin={origin}
siteImage={siteImage}
/> />
)} )}
</Box> </Box>