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

Add origin to transaction confirmation (#10296)

Fixes #5611

The origin that suggests a transaction is now shown on the transaction
confirmation page. If the transaction was initiated from within
MetaMask (e.g. via the 'Send' flow or swaps), no origin is shown.

This was based upon designs that were linked in the PR #9377. This is a
temporary measure until our newer transaction confirmation designs can
be implemented.
This commit is contained in:
Mark Stacey 2021-01-28 14:29:45 -03:30 committed by GitHub
parent d8993883b7
commit c053294781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 0 deletions

View File

@ -21,6 +21,7 @@ export default class ConfirmPageContainerContent extends Component {
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
titleComponent: PropTypes.node, titleComponent: PropTypes.node,
warning: PropTypes.string, warning: PropTypes.string,
origin: PropTypes.string.isRequired,
// Footer // Footer
onCancelAll: PropTypes.func, onCancelAll: PropTypes.func,
onCancel: PropTypes.func, onCancel: PropTypes.func,
@ -79,6 +80,7 @@ export default class ConfirmPageContainerContent extends Component {
disabled, disabled,
unapprovedTxCount, unapprovedTxCount,
rejectNText, rejectNText,
origin,
} = this.props } = this.props
return ( return (
@ -97,6 +99,7 @@ export default class ConfirmPageContainerContent extends Component {
identiconAddress={identiconAddress} identiconAddress={identiconAddress}
nonce={nonce} nonce={nonce}
assetImage={assetImage} assetImage={assetImage}
origin={origin}
/> />
{this.renderContent()} {this.renderContent()}
{(errorKey || errorMessage) && ( {(errorKey || errorMessage) && (

View File

@ -14,10 +14,14 @@ const ConfirmPageContainerSummary = (props) => {
identiconAddress, identiconAddress,
nonce, nonce,
assetImage, assetImage,
origin,
} = props } = props
return ( return (
<div className={classnames('confirm-page-container-summary', className)}> <div className={classnames('confirm-page-container-summary', className)}>
{origin === 'metamask' ? null : (
<div className="confirm-page-container-summary__origin">{origin}</div>
)}
<div className="confirm-page-container-summary__action-row"> <div className="confirm-page-container-summary__action-row">
<div className="confirm-page-container-summary__action">{action}</div> <div className="confirm-page-container-summary__action">{action}</div>
{nonce && ( {nonce && (
@ -58,6 +62,7 @@ ConfirmPageContainerSummary.propTypes = {
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string, assetImage: PropTypes.string,
origin: PropTypes.string.isRequired,
} }
export default ConfirmPageContainerSummary export default ConfirmPageContainerSummary

View File

@ -4,6 +4,12 @@
height: 133px; height: 133px;
box-sizing: border-box; box-sizing: border-box;
&__origin {
@include H6;
padding-bottom: 10px;
}
&__action-row { &__action-row {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -42,6 +42,7 @@ export default class ConfirmPageContainer extends Component {
assetImage: PropTypes.string, assetImage: PropTypes.string,
warning: PropTypes.string, warning: PropTypes.string,
unapprovedTxCount: PropTypes.number, unapprovedTxCount: PropTypes.number,
origin: PropTypes.string.isRequired,
// Navigation // Navigation
totalTx: PropTypes.number, totalTx: PropTypes.number,
positionOfCurrentTx: PropTypes.number, positionOfCurrentTx: PropTypes.number,
@ -101,6 +102,7 @@ export default class ConfirmPageContainer extends Component {
requestsWaitingText, requestsWaitingText,
hideSenderToRecipient, hideSenderToRecipient,
showAccountInHeader, showAccountInHeader,
origin,
} = this.props } = this.props
const renderAssetImage = const renderAssetImage =
contentComponent || (!contentComponent && !identiconAddress) contentComponent || (!contentComponent && !identiconAddress)
@ -160,6 +162,7 @@ export default class ConfirmPageContainer extends Component {
disabled={disabled} disabled={disabled}
unapprovedTxCount={unapprovedTxCount} unapprovedTxCount={unapprovedTxCount}
rejectNText={this.context.t('rejectTxsN', [unapprovedTxCount])} rejectNText={this.context.t('rejectTxsN', [unapprovedTxCount])}
origin={origin}
/> />
)} )}
{contentComponent && ( {contentComponent && (

View File

@ -669,6 +669,7 @@ export default class ConfirmTransactionBase extends Component {
transactionCategory, transactionCategory,
hideSenderToRecipient, hideSenderToRecipient,
showAccountInHeader, showAccountInHeader,
txData,
} = this.props } = this.props
const { submitting, submitError, submitWarning } = this.state const { submitting, submitError, submitWarning } = this.state
@ -736,6 +737,7 @@ export default class ConfirmTransactionBase extends Component {
onCancel={() => this.handleCancel()} onCancel={() => this.handleCancel()}
onSubmit={() => this.handleSubmit()} onSubmit={() => this.handleSubmit()}
hideSenderToRecipient={hideSenderToRecipient} hideSenderToRecipient={hideSenderToRecipient}
origin={txData.origin}
/> />
) )
} }