diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 03ec2a1c9..c872d2d31 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -790,6 +790,9 @@ "contractRequestingAccess": { "message": "Contract requesting access" }, + "contractRequestingSignature": { + "message": "Contract requesting signature" + }, "contractRequestingSpendingCap": { "message": "Contract requesting spending cap" }, diff --git a/test/e2e/tests/signature-request.spec.js b/test/e2e/tests/signature-request.spec.js index 9fa2a08d4..bbf2f742f 100644 --- a/test/e2e/tests/signature-request.spec.js +++ b/test/e2e/tests/signature-request.spec.js @@ -53,20 +53,22 @@ describe('Sign Typed Data V4 Signature Request', function () { const content = await driver.findElements( '.signature-request-content__info', ); + const verifyContractDetailsButton = await driver.findElement( + '.signature-request-content__verify-contract-details', + ); const origin = content[0]; - const address = content[1]; const message = await driver.findElement( '.signature-request-data__node__value', ); assert.equal(await title.getText(), 'Signature request'); assert.equal(await name.getText(), 'Ether Mail'); assert.equal(await origin.getText(), 'http://127.0.0.1:8080'); - assert.equal( - await address.getText(), - `${publicAddress.slice(0, 8)}...${publicAddress.slice( - publicAddress.length - 8, - )}`, - ); + + verifyContractDetailsButton.click(); + await driver.findElement({ text: 'Contract details', tag: 'h5' }); + await driver.findElement('[data-testid="recipient"]'); + await driver.clickElement({ text: 'Got it', tag: 'button' }); + assert.equal(await message.getText(), 'Hello, Bob!'); // Approve signing typed data await driver.clickElement( @@ -137,20 +139,22 @@ describe('Sign Typed Data V3 Signature Request', function () { const content = await driver.findElements( '.signature-request-content__info', ); + const verifyContractDetailsButton = await driver.findElement( + '.signature-request-content__verify-contract-details', + ); const origin = content[0]; - const address = content[1]; const messages = await driver.findElements( '.signature-request-data__node__value', ); assert.equal(await title.getText(), 'Signature request'); assert.equal(await name.getText(), 'Ether Mail'); assert.equal(await origin.getText(), 'http://127.0.0.1:8080'); - assert.equal( - await address.getText(), - `${publicAddress.slice(0, 8)}...${publicAddress.slice( - publicAddress.length - 8, - )}`, - ); + + verifyContractDetailsButton.click(); + await driver.findElement({ text: 'Contract details', tag: 'h5' }); + await driver.findElement('[data-testid="recipient"]'); + await driver.clickElement({ text: 'Got it', tag: 'button' }); + assert.equal(await messages[4].getText(), 'Hello, Bob!'); // Approve signing typed data diff --git a/ui/components/app/modals/contract-details-modal/contract-details-modal.js b/ui/components/app/modals/contract-details-modal/contract-details-modal.js index 9095ef160..c339f1313 100644 --- a/ui/components/app/modals/contract-details-modal/contract-details-modal.js +++ b/ui/components/app/modals/contract-details-modal/contract-details-modal.js @@ -40,6 +40,7 @@ export default function ContractDetailsModal({ tokenId, assetName, assetStandard, + isContractRequestingSignature, }) { const t = useI18nContext(); const [copiedTokenAddress, handleCopyTokenAddress] = useCopyToClipboard(); @@ -80,117 +81,123 @@ export default function ContractDetailsModal({ > {t('contractDescription')} - - {nft ? t('contractNFT') : t('contractToken')} - - - {nft ? ( - - - - ) : ( - - )} - + {!isContractRequestingSignature && ( + <> - {tokenName || ellipsify(tokenAddress)} + {nft ? t('contractNFT') : t('contractToken')} - {tokenName && ( - - {ellipsify(tokenAddress)} - - )} - - - - - - - - - - - + + ) : ( + + )} + + + {tokenName || ellipsify(tokenAddress)} + + {tokenName && ( + + {ellipsify(tokenAddress)} + + )} + + + + + + + + + + + + + - - - + + )} - {nft - ? t('contractRequestingAccess') - : t('contractRequestingSpendingCap')} + {nft && t('contractRequestingAccess')} + {isContractRequestingSignature && t('contractRequestingSignature')} + {!nft && + !isContractRequestingSignature && + t('contractRequestingSpendingCap')} -
- {this.formatWallet(fromAddress)} +
+
{isLedgerWallet ? ( @@ -153,6 +184,17 @@ export default class SignatureRequest extends PureComponent { (messageIsScrollable && !this.state.hasScrolledMessage) } /> + {this.state.showContractDetails && ( + this.setState({ showContractDetails: false })} + isContractRequestingSignature + /> + )} ); } diff --git a/ui/components/app/signature-request/signature-request.container.js b/ui/components/app/signature-request/signature-request.container.js index 35a62561d..acde5dacc 100644 --- a/ui/components/app/signature-request/signature-request.container.js +++ b/ui/components/app/signature-request/signature-request.container.js @@ -2,6 +2,9 @@ import { connect } from 'react-redux'; import { accountsWithSendEtherInfoSelector, doesAddressRequireLedgerHidConnection, + getCurrentChainId, + getRpcPrefsForCurrentProvider, + getSubjectMetadata, } from '../../../selectors'; import { isAddressLedger } from '../../../ducks/metamask/metamask'; import { getAccountByAddress } from '../../../helpers/utils/util'; @@ -16,18 +19,33 @@ function mapStateToProps(state, ownProps) { const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(state, from); const isLedgerWallet = isAddressLedger(state, from); + const chainId = getCurrentChainId(state); + const rpcPrefs = getRpcPrefsForCurrentProvider(state); + const subjectMetadata = getSubjectMetadata(state); + + const { iconUrl: siteImage = '' } = + subjectMetadata[txData.msgParams.origin] || {}; return { isLedgerWallet, hardwareWalletRequiresConnection, + chainId, + rpcPrefs, + siteImage, // not forwarded to component allAccounts: accountsWithSendEtherInfoSelector(state), }; } function mergeProps(stateProps, dispatchProps, ownProps) { - const { allAccounts, isLedgerWallet, hardwareWalletRequiresConnection } = - stateProps; + const { + allAccounts, + isLedgerWallet, + hardwareWalletRequiresConnection, + chainId, + rpcPrefs, + siteImage, + } = stateProps; const { signPersonalMessage, signTypedMessage, @@ -68,6 +86,9 @@ function mergeProps(stateProps, dispatchProps, ownProps) { sign, isLedgerWallet, hardwareWalletRequiresConnection, + chainId, + rpcPrefs, + siteImage, }; }