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

Fix decrypt message confirmation UI crash (#10252)

The decrupt message confirmation UI will crash if the origin metadata
is not present. This PR makes the UI tolerant of that metadata being
missing. It was always intended to be optional anyway.
This commit is contained in:
Mark Stacey 2021-01-22 15:10:43 -03:30
parent a88a087b60
commit 6d5683dd3f

View File

@ -174,8 +174,9 @@ export default class ConfirmDecryptMessage extends Component {
const { decryptMessageInline, domainMetadata, txData } = this.props const { decryptMessageInline, domainMetadata, txData } = this.props
const { t } = this.context const { t } = this.context
const origin = domainMetadata[txData.msgParams.origin] const originMetadata = domainMetadata[txData.msgParams.origin]
const notice = t('decryptMessageNotice', [origin.name]) const name = originMetadata?.name || txData.msgParams.origin
const notice = t('decryptMessageNotice', [txData.msgParams.origin])
const { const {
hasCopied, hasCopied,
@ -191,15 +192,15 @@ export default class ConfirmDecryptMessage extends Component {
{this.renderAccountInfo()} {this.renderAccountInfo()}
<div className="request-decrypt-message__visual"> <div className="request-decrypt-message__visual">
<section> <section>
{origin.icon ? ( {originMetadata?.icon ? (
<img <img
className="request-decrypt-message__visual-identicon" className="request-decrypt-message__visual-identicon"
src={origin.icon} src={originMetadata?.icon}
alt="" alt=""
/> />
) : ( ) : (
<i className="request-decrypt-message__visual-identicon--default"> <i className="request-decrypt-message__visual-identicon--default">
{origin.name.charAt(0).toUpperCase()} {name.charAt(0).toUpperCase()}
</i> </i>
)} )}
<div className="request-decrypt-message__notice">{notice}</div> <div className="request-decrypt-message__notice">{notice}</div>