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

Remove unused transaction base props (#10295)

These props were never given. They have been removed to simplify the
component.
This commit is contained in:
Mark Stacey 2021-01-28 13:47:26 -03:30 committed by GitHub
parent 419897cba6
commit ecff9dfcb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 198 deletions

View File

@ -17,9 +17,7 @@ export default class ConfirmPageContainerContent extends Component {
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string, assetImage: PropTypes.string,
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
subtitleComponent: PropTypes.node, subtitleComponent: PropTypes.node,
summaryComponent: PropTypes.node,
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,
@ -65,13 +63,11 @@ export default class ConfirmPageContainerContent extends Component {
errorMessage, errorMessage,
title, title,
titleComponent, titleComponent,
subtitle,
subtitleComponent, subtitleComponent,
hideSubtitle, hideSubtitle,
identiconAddress, identiconAddress,
nonce, nonce,
assetImage, assetImage,
summaryComponent,
detailsComponent, detailsComponent,
dataComponent, dataComponent,
warning, warning,
@ -88,23 +84,20 @@ export default class ConfirmPageContainerContent extends Component {
return ( return (
<div className="confirm-page-container-content"> <div className="confirm-page-container-content">
{warning && <ConfirmPageContainerWarning warning={warning} />} {warning && <ConfirmPageContainerWarning warning={warning} />}
{summaryComponent || ( <ConfirmPageContainerSummary
<ConfirmPageContainerSummary className={classnames({
className={classnames({ 'confirm-page-container-summary--border':
'confirm-page-container-summary--border': !detailsComponent || !dataComponent,
!detailsComponent || !dataComponent, })}
})} action={action}
action={action} title={title}
title={title} titleComponent={titleComponent}
titleComponent={titleComponent} subtitleComponent={subtitleComponent}
subtitle={subtitle} hideSubtitle={hideSubtitle}
subtitleComponent={subtitleComponent} identiconAddress={identiconAddress}
hideSubtitle={hideSubtitle} nonce={nonce}
identiconAddress={identiconAddress} assetImage={assetImage}
nonce={nonce} />
assetImage={assetImage}
/>
)}
{this.renderContent()} {this.renderContent()}
{(errorKey || errorMessage) && ( {(errorKey || errorMessage) && (
<div className="confirm-page-container-content__error-container"> <div className="confirm-page-container-content__error-container">

View File

@ -8,7 +8,6 @@ const ConfirmPageContainerSummary = (props) => {
action, action,
title, title,
titleComponent, titleComponent,
subtitle,
subtitleComponent, subtitleComponent,
hideSubtitle, hideSubtitle,
className, className,
@ -42,7 +41,7 @@ const ConfirmPageContainerSummary = (props) => {
</div> </div>
{hideSubtitle || ( {hideSubtitle || (
<div className="confirm-page-container-summary__subtitle"> <div className="confirm-page-container-summary__subtitle">
{subtitleComponent || subtitle} {subtitleComponent}
</div> </div>
)} )}
</div> </div>
@ -53,7 +52,6 @@ ConfirmPageContainerSummary.propTypes = {
action: PropTypes.string, action: PropTypes.string,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
titleComponent: PropTypes.node, titleComponent: PropTypes.node,
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
subtitleComponent: PropTypes.node, subtitleComponent: PropTypes.node,
hideSubtitle: PropTypes.bool, hideSubtitle: PropTypes.bool,
className: PropTypes.string, className: PropTypes.string,

View File

@ -19,7 +19,6 @@ export default class ConfirmPageContainer extends Component {
hideSubtitle: PropTypes.bool, hideSubtitle: PropTypes.bool,
onEdit: PropTypes.func, onEdit: PropTypes.func,
showEdit: PropTypes.bool, showEdit: PropTypes.bool,
subtitle: PropTypes.string,
subtitleComponent: PropTypes.node, subtitleComponent: PropTypes.node,
title: PropTypes.string, title: PropTypes.string,
titleComponent: PropTypes.node, titleComponent: PropTypes.node,
@ -41,7 +40,6 @@ export default class ConfirmPageContainer extends Component {
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
nonce: PropTypes.string, nonce: PropTypes.string,
assetImage: PropTypes.string, assetImage: PropTypes.string,
summaryComponent: PropTypes.node,
warning: PropTypes.string, warning: PropTypes.string,
unapprovedTxCount: PropTypes.number, unapprovedTxCount: PropTypes.number,
// Navigation // Navigation
@ -79,10 +77,8 @@ export default class ConfirmPageContainer extends Component {
action, action,
title, title,
titleComponent, titleComponent,
subtitle,
subtitleComponent, subtitleComponent,
hideSubtitle, hideSubtitle,
summaryComponent,
detailsComponent, detailsComponent,
dataComponent, dataComponent,
onCancelAll, onCancelAll,
@ -146,10 +142,8 @@ export default class ConfirmPageContainer extends Component {
action={action} action={action}
title={title} title={title}
titleComponent={titleComponent} titleComponent={titleComponent}
subtitle={subtitle}
subtitleComponent={subtitleComponent} subtitleComponent={subtitleComponent}
hideSubtitle={hideSubtitle} hideSubtitle={hideSubtitle}
summaryComponent={summaryComponent}
detailsComponent={detailsComponent} detailsComponent={detailsComponent}
dataComponent={dataComponent} dataComponent={dataComponent}
errorMessage={errorMessage} errorMessage={errorMessage}

View File

@ -70,31 +70,19 @@ export default class ConfirmTransactionBase extends Component {
actionKey: PropTypes.string, actionKey: PropTypes.string,
contentComponent: PropTypes.node, contentComponent: PropTypes.node,
dataComponent: PropTypes.node, dataComponent: PropTypes.node,
detailsComponent: PropTypes.node,
errorKey: PropTypes.string,
errorMessage: PropTypes.string,
primaryTotalTextOverride: PropTypes.oneOfType([ primaryTotalTextOverride: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.node, PropTypes.node,
]), ]),
secondaryTotalTextOverride: PropTypes.string, secondaryTotalTextOverride: PropTypes.string,
hideData: PropTypes.bool, hideData: PropTypes.bool,
hideDetails: PropTypes.bool,
hideSubtitle: PropTypes.bool, hideSubtitle: PropTypes.bool,
identiconAddress: PropTypes.string, identiconAddress: PropTypes.string,
onCancel: PropTypes.func,
onEdit: PropTypes.func, onEdit: PropTypes.func,
onEditGas: PropTypes.func,
onSubmit: PropTypes.func,
setMetaMetricsSendCount: PropTypes.func, setMetaMetricsSendCount: PropTypes.func,
metaMetricsSendCount: PropTypes.number, metaMetricsSendCount: PropTypes.number,
subtitle: PropTypes.string,
subtitleComponent: PropTypes.node, subtitleComponent: PropTypes.node,
summaryComponent: PropTypes.node,
title: PropTypes.string, title: PropTypes.string,
titleComponent: PropTypes.node,
valid: PropTypes.bool,
warning: PropTypes.string,
advancedInlineGasShown: PropTypes.bool, advancedInlineGasShown: PropTypes.bool,
insufficientBalance: PropTypes.bool, insufficientBalance: PropTypes.bool,
hideFiatConversion: PropTypes.bool, hideFiatConversion: PropTypes.bool,
@ -212,7 +200,6 @@ export default class ConfirmTransactionBase extends Component {
handleEditGas() { handleEditGas() {
const { const {
onEditGas,
showCustomizeGasModal, showCustomizeGasModal,
actionKey, actionKey,
txData: { origin }, txData: { origin },
@ -235,21 +222,15 @@ export default class ConfirmTransactionBase extends Component {
}, },
}) })
if (onEditGas) { showCustomizeGasModal()
onEditGas()
} else {
showCustomizeGasModal()
}
} }
renderDetails() { renderDetails() {
const { const {
detailsComponent,
primaryTotalTextOverride, primaryTotalTextOverride,
secondaryTotalTextOverride, secondaryTotalTextOverride,
hexTransactionFee, hexTransactionFee,
hexTransactionTotal, hexTransactionTotal,
hideDetails,
useNonceField, useNonceField,
customNonceValue, customNonceValue,
updateCustomNonce, updateCustomNonce,
@ -263,100 +244,90 @@ export default class ConfirmTransactionBase extends Component {
isMainnet, isMainnet,
} = this.props } = this.props
if (hideDetails) {
return null
}
const notMainnetOrTest = !(isMainnet || process.env.IN_TEST) const notMainnetOrTest = !(isMainnet || process.env.IN_TEST)
return ( return (
detailsComponent || ( <div className="confirm-page-container-content__details">
<div className="confirm-page-container-content__details"> <div className="confirm-page-container-content__gas-fee">
<div className="confirm-page-container-content__gas-fee"> <ConfirmDetailRow
<ConfirmDetailRow label="Gas Fee"
label="Gas Fee" value={hexTransactionFee}
value={hexTransactionFee} headerText={notMainnetOrTest ? '' : 'Edit'}
headerText={notMainnetOrTest ? '' : 'Edit'} headerTextClassName={
headerTextClassName={ notMainnetOrTest ? '' : 'confirm-detail-row__header-text--edit'
notMainnetOrTest ? '' : 'confirm-detail-row__header-text--edit'
}
onHeaderClick={
notMainnetOrTest ? null : () => this.handleEditGas()
}
secondaryText={
hideFiatConversion
? this.context.t('noConversionRateAvailable')
: ''
}
/>
{advancedInlineGasShown || notMainnetOrTest ? (
<AdvancedGasInputs
updateCustomGasPrice={(newGasPrice) =>
updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })
}
updateCustomGasLimit={(newGasLimit) =>
updateGasAndCalculate({ ...customGas, gasLimit: newGasLimit })
}
customGasPrice={customGas.gasPrice}
customGasLimit={customGas.gasLimit}
insufficientBalance={insufficientBalance}
customPriceIsSafe
isSpeedUp={false}
/>
) : null}
</div>
<div
className={
useNonceField ? 'confirm-page-container-content__gas-fee' : null
} }
> onHeaderClick={notMainnetOrTest ? null : () => this.handleEditGas()}
<ConfirmDetailRow secondaryText={
label="Total" hideFiatConversion
value={hexTransactionTotal} ? this.context.t('noConversionRateAvailable')
primaryText={primaryTotalTextOverride} : ''
secondaryText={ }
hideFiatConversion />
? this.context.t('noConversionRateAvailable') {advancedInlineGasShown || notMainnetOrTest ? (
: secondaryTotalTextOverride <AdvancedGasInputs
updateCustomGasPrice={(newGasPrice) =>
updateGasAndCalculate({ ...customGas, gasPrice: newGasPrice })
} }
headerText="Amount + Gas Fee" updateCustomGasLimit={(newGasLimit) =>
headerTextClassName="confirm-detail-row__header-text--total" updateGasAndCalculate({ ...customGas, gasLimit: newGasLimit })
primaryValueTextColor="#2f9ae0" }
customGasPrice={customGas.gasPrice}
customGasLimit={customGas.gasLimit}
insufficientBalance={insufficientBalance}
customPriceIsSafe
isSpeedUp={false}
/> />
</div>
{useNonceField ? (
<div>
<div className="confirm-detail-row">
<div className="confirm-detail-row__label">
{this.context.t('nonceFieldHeading')}
</div>
<div className="custom-nonce-input">
<TextField
type="number"
min="0"
placeholder={
typeof nextNonce === 'number'
? nextNonce.toString()
: null
}
onChange={({ target: { value } }) => {
if (!value.length || Number(value) < 0) {
updateCustomNonce('')
} else {
updateCustomNonce(String(Math.floor(value)))
}
getNextNonce()
}}
fullWidth
margin="dense"
value={customNonceValue || ''}
/>
</div>
</div>
</div>
) : null} ) : null}
</div> </div>
) <div
className={
useNonceField ? 'confirm-page-container-content__gas-fee' : null
}
>
<ConfirmDetailRow
label="Total"
value={hexTransactionTotal}
primaryText={primaryTotalTextOverride}
secondaryText={
hideFiatConversion
? this.context.t('noConversionRateAvailable')
: secondaryTotalTextOverride
}
headerText="Amount + Gas Fee"
headerTextClassName="confirm-detail-row__header-text--total"
primaryValueTextColor="#2f9ae0"
/>
</div>
{useNonceField ? (
<div>
<div className="confirm-detail-row">
<div className="confirm-detail-row__label">
{this.context.t('nonceFieldHeading')}
</div>
<div className="custom-nonce-input">
<TextField
type="number"
min="0"
placeholder={
typeof nextNonce === 'number' ? nextNonce.toString() : null
}
onChange={({ target: { value } }) => {
if (!value.length || Number(value) < 0) {
updateCustomNonce('')
} else {
updateCustomNonce(String(Math.floor(value)))
}
getNextNonce()
}}
fullWidth
margin="dense"
value={customNonceValue || ''}
/>
</div>
</div>
</div>
) : null}
</div>
) )
} }
@ -455,7 +426,6 @@ export default class ConfirmTransactionBase extends Component {
handleCancel() { handleCancel() {
const { metricsEvent } = this.context const { metricsEvent } = this.context
const { const {
onCancel,
txData, txData,
cancelTransaction, cancelTransaction,
history, history,
@ -484,14 +454,10 @@ export default class ConfirmTransactionBase extends Component {
}, },
}) })
updateCustomNonce('') updateCustomNonce('')
if (onCancel) { cancelTransaction(txData).then(() => {
onCancel(txData) clearConfirmTransaction()
} else { history.push(mostRecentOverviewPage)
cancelTransaction(txData).then(() => { })
clearConfirmTransaction()
history.push(mostRecentOverviewPage)
})
}
} }
handleSubmit() { handleSubmit() {
@ -502,7 +468,6 @@ export default class ConfirmTransactionBase extends Component {
clearConfirmTransaction, clearConfirmTransaction,
txData, txData,
history, history,
onSubmit,
actionKey, actionKey,
mostRecentOverviewPage, mostRecentOverviewPage,
metaMetricsSendCount = 0, metaMetricsSendCount = 0,
@ -540,42 +505,33 @@ export default class ConfirmTransactionBase extends Component {
}) })
setMetaMetricsSendCount(metaMetricsSendCount + 1).then(() => { setMetaMetricsSendCount(metaMetricsSendCount + 1).then(() => {
if (onSubmit) { sendTransaction(txData)
Promise.resolve(onSubmit(txData)).then(() => { .then(() => {
clearConfirmTransaction()
this.setState(
{
submitting: false,
},
() => {
history.push(mostRecentOverviewPage)
updateCustomNonce('')
},
)
})
.catch((error) => {
this.setState({ this.setState({
submitting: false, submitting: false,
submitError: error.message,
}) })
updateCustomNonce('') updateCustomNonce('')
}) })
} else {
sendTransaction(txData)
.then(() => {
clearConfirmTransaction()
this.setState(
{
submitting: false,
},
() => {
history.push(mostRecentOverviewPage)
updateCustomNonce('')
},
)
})
.catch((error) => {
this.setState({
submitting: false,
submitError: error.message,
})
updateCustomNonce('')
})
}
}) })
}, },
) )
} }
renderTitleComponent() { renderTitleComponent() {
const { title, titleComponent, hexTransactionAmount } = this.props const { title, hexTransactionAmount } = this.props
// Title string passed in by props takes priority // Title string passed in by props takes priority
if (title) { if (title) {
@ -583,25 +539,18 @@ export default class ConfirmTransactionBase extends Component {
} }
return ( return (
titleComponent || ( <UserPreferencedCurrencyDisplay
<UserPreferencedCurrencyDisplay value={hexTransactionAmount}
value={hexTransactionAmount} type={PRIMARY}
type={PRIMARY} showEthLogo
showEthLogo ethLogoHeight="26"
ethLogoHeight="26" hideLabel
hideLabel />
/>
)
) )
} }
renderSubtitleComponent() { renderSubtitleComponent() {
const { subtitle, subtitleComponent, hexTransactionAmount } = this.props const { subtitleComponent, hexTransactionAmount } = this.props
// Subtitle string passed in by props takes priority
if (subtitle) {
return null
}
return ( return (
subtitleComponent || ( subtitleComponent || (
@ -708,20 +657,14 @@ export default class ConfirmTransactionBase extends Component {
toEns, toEns,
toNickname, toNickname,
methodData, methodData,
valid: propsValid = true,
errorMessage,
errorKey: propsErrorKey,
title, title,
subtitle,
hideSubtitle, hideSubtitle,
identiconAddress, identiconAddress,
summaryComponent,
contentComponent, contentComponent,
onEdit, onEdit,
nonce, nonce,
customNonceValue, customNonceValue,
assetImage, assetImage,
warning,
unapprovedTxCount, unapprovedTxCount,
transactionCategory, transactionCategory,
hideSenderToRecipient, hideSenderToRecipient,
@ -765,10 +708,8 @@ export default class ConfirmTransactionBase extends Component {
action={functionType} action={functionType}
title={title} title={title}
titleComponent={this.renderTitleComponent()} titleComponent={this.renderTitleComponent()}
subtitle={subtitle}
subtitleComponent={this.renderSubtitleComponent()} subtitleComponent={this.renderSubtitleComponent()}
hideSubtitle={hideSubtitle} hideSubtitle={hideSubtitle}
summaryComponent={summaryComponent}
detailsComponent={this.renderDetails()} detailsComponent={this.renderDetails()}
dataComponent={this.renderData(functionType)} dataComponent={this.renderData(functionType)}
contentComponent={contentComponent} contentComponent={contentComponent}
@ -776,9 +717,9 @@ export default class ConfirmTransactionBase extends Component {
unapprovedTxCount={unapprovedTxCount} unapprovedTxCount={unapprovedTxCount}
assetImage={assetImage} assetImage={assetImage}
identiconAddress={identiconAddress} identiconAddress={identiconAddress}
errorMessage={errorMessage || submitError} errorMessage={submitError}
errorKey={propsErrorKey || errorKey} errorKey={errorKey}
warning={warning || submitWarning} warning={submitWarning}
totalTx={totalTx} totalTx={totalTx}
positionOfCurrentTx={positionOfCurrentTx} positionOfCurrentTx={positionOfCurrentTx}
nextTxId={nextTxId} nextTxId={nextTxId}
@ -789,7 +730,7 @@ export default class ConfirmTransactionBase extends Component {
lastTx={lastTx} lastTx={lastTx}
ofText={ofText} ofText={ofText}
requestsWaitingText={requestsWaitingText} requestsWaitingText={requestsWaitingText}
disabled={!propsValid || !valid || submitting} disabled={!valid || submitting}
onEdit={() => this.handleEdit()} onEdit={() => this.handleEdit()}
onCancelAll={() => this.handleCancelAll()} onCancelAll={() => this.handleCancelAll()}
onCancel={() => this.handleCancel()} onCancel={() => this.handleCancel()}