mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
create branching logic for different types of contract interactions for identifying the contract address (#13776)
This commit is contained in:
parent
52981e1967
commit
039c405314
@ -28,7 +28,7 @@ export default class ConfirmPageContainerContent extends Component {
|
|||||||
errorMessage: PropTypes.string,
|
errorMessage: PropTypes.string,
|
||||||
hasSimulationError: PropTypes.bool,
|
hasSimulationError: PropTypes.bool,
|
||||||
hideSubtitle: PropTypes.bool,
|
hideSubtitle: PropTypes.bool,
|
||||||
identiconAddress: PropTypes.string,
|
tokenAddress: PropTypes.string,
|
||||||
nonce: PropTypes.string,
|
nonce: PropTypes.string,
|
||||||
subtitleComponent: PropTypes.node,
|
subtitleComponent: PropTypes.node,
|
||||||
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
@ -106,7 +106,7 @@ export default class ConfirmPageContainerContent extends Component {
|
|||||||
titleComponent,
|
titleComponent,
|
||||||
subtitleComponent,
|
subtitleComponent,
|
||||||
hideSubtitle,
|
hideSubtitle,
|
||||||
identiconAddress,
|
tokenAddress,
|
||||||
nonce,
|
nonce,
|
||||||
detailsComponent,
|
detailsComponent,
|
||||||
dataComponent,
|
dataComponent,
|
||||||
@ -179,7 +179,7 @@ export default class ConfirmPageContainerContent extends Component {
|
|||||||
titleComponent={titleComponent}
|
titleComponent={titleComponent}
|
||||||
subtitleComponent={subtitleComponent}
|
subtitleComponent={subtitleComponent}
|
||||||
hideSubtitle={hideSubtitle}
|
hideSubtitle={hideSubtitle}
|
||||||
identiconAddress={identiconAddress}
|
tokenAddress={tokenAddress}
|
||||||
nonce={nonce}
|
nonce={nonce}
|
||||||
origin={origin}
|
origin={origin}
|
||||||
hideTitle={hideTitle}
|
hideTitle={hideTitle}
|
||||||
|
@ -20,22 +20,40 @@ const ConfirmPageContainerSummary = (props) => {
|
|||||||
subtitleComponent,
|
subtitleComponent,
|
||||||
hideSubtitle,
|
hideSubtitle,
|
||||||
className,
|
className,
|
||||||
identiconAddress,
|
tokenAddress,
|
||||||
|
toAddress,
|
||||||
nonce,
|
nonce,
|
||||||
origin,
|
origin,
|
||||||
hideTitle,
|
hideTitle,
|
||||||
image,
|
image,
|
||||||
transactionType,
|
transactionType,
|
||||||
toAddress,
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [showNicknamePopovers, setShowNicknamePopovers] = useState(false);
|
const [showNicknamePopovers, setShowNicknamePopovers] = useState(false);
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const { toName, isTrusted } = useAddressDetails(toAddress);
|
|
||||||
|
|
||||||
const isContractTypeTransaction =
|
const contractInitiatedTransactionType = [
|
||||||
transactionType === TRANSACTION_TYPES.CONTRACT_INTERACTION;
|
TRANSACTION_TYPES.CONTRACT_INTERACTION,
|
||||||
const checksummedAddress = toChecksumHexAddress(toAddress);
|
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER,
|
||||||
|
TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM,
|
||||||
|
];
|
||||||
|
const isContractTypeTransaction = contractInitiatedTransactionType.includes(
|
||||||
|
transactionType,
|
||||||
|
);
|
||||||
|
let contractAddress;
|
||||||
|
if (isContractTypeTransaction) {
|
||||||
|
// If the transaction is TOKEN_METHOD_TRANSFER or TOKEN_METHOD_TRANSFER_FROM
|
||||||
|
// the contract address is passed down as tokenAddress, if it is anyother
|
||||||
|
// type of contract interaction it is passed as toAddress
|
||||||
|
contractAddress =
|
||||||
|
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER ||
|
||||||
|
transactionType === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM
|
||||||
|
? tokenAddress
|
||||||
|
: toAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { toName, isTrusted } = useAddressDetails(contractAddress);
|
||||||
|
const checksummedAddress = toChecksumHexAddress(contractAddress);
|
||||||
|
|
||||||
const renderImage = () => {
|
const renderImage = () => {
|
||||||
if (image) {
|
if (image) {
|
||||||
@ -46,12 +64,12 @@ const ConfirmPageContainerSummary = (props) => {
|
|||||||
src={image}
|
src={image}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (identiconAddress) {
|
} else if (contractAddress) {
|
||||||
return (
|
return (
|
||||||
<Identicon
|
<Identicon
|
||||||
className="confirm-page-container-summary__icon"
|
className="confirm-page-container-summary__icon"
|
||||||
diameter={36}
|
diameter={36}
|
||||||
address={identiconAddress}
|
address={contractAddress}
|
||||||
image={image}
|
image={image}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -127,11 +145,11 @@ ConfirmPageContainerSummary.propTypes = {
|
|||||||
subtitleComponent: PropTypes.node,
|
subtitleComponent: PropTypes.node,
|
||||||
hideSubtitle: PropTypes.bool,
|
hideSubtitle: PropTypes.bool,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
identiconAddress: PropTypes.string,
|
tokenAddress: PropTypes.string,
|
||||||
|
toAddress: PropTypes.string,
|
||||||
nonce: PropTypes.string,
|
nonce: PropTypes.string,
|
||||||
origin: PropTypes.string.isRequired,
|
origin: PropTypes.string.isRequired,
|
||||||
hideTitle: PropTypes.bool,
|
hideTitle: PropTypes.bool,
|
||||||
toAddress: PropTypes.string,
|
|
||||||
transactionType: PropTypes.string,
|
transactionType: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
dataComponent: PropTypes.node,
|
dataComponent: PropTypes.node,
|
||||||
dataHexComponent: PropTypes.node,
|
dataHexComponent: PropTypes.node,
|
||||||
detailsComponent: PropTypes.node,
|
detailsComponent: PropTypes.node,
|
||||||
identiconAddress: PropTypes.string,
|
tokenAddress: PropTypes.string,
|
||||||
nonce: PropTypes.string,
|
nonce: PropTypes.string,
|
||||||
warning: PropTypes.string,
|
warning: PropTypes.string,
|
||||||
unapprovedTxCount: PropTypes.number,
|
unapprovedTxCount: PropTypes.number,
|
||||||
@ -126,7 +126,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
onCancelAll,
|
onCancelAll,
|
||||||
onCancel,
|
onCancel,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
identiconAddress,
|
tokenAddress,
|
||||||
nonce,
|
nonce,
|
||||||
unapprovedTxCount,
|
unapprovedTxCount,
|
||||||
warning,
|
warning,
|
||||||
@ -236,7 +236,7 @@ export default class ConfirmPageContainer extends Component {
|
|||||||
dataHexComponent={dataHexComponent}
|
dataHexComponent={dataHexComponent}
|
||||||
errorMessage={errorMessage}
|
errorMessage={errorMessage}
|
||||||
errorKey={errorKey}
|
errorKey={errorKey}
|
||||||
identiconAddress={identiconAddress}
|
tokenAddress={tokenAddress}
|
||||||
nonce={nonce}
|
nonce={nonce}
|
||||||
warning={warning}
|
warning={warning}
|
||||||
onCancelAll={onCancelAll}
|
onCancelAll={onCancelAll}
|
||||||
|
@ -93,7 +93,7 @@ export default function ConfirmTokenTransactionBase({
|
|||||||
toAddress={toAddress}
|
toAddress={toAddress}
|
||||||
image={image}
|
image={image}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
identiconAddress={tokenAddress}
|
tokenAddress={tokenAddress}
|
||||||
title={title}
|
title={title}
|
||||||
subtitleComponent={subtitleComponent()}
|
subtitleComponent={subtitleComponent()}
|
||||||
primaryTotalTextOverride={`${title} + ${ethTransactionTotal} ${nativeCurrency}`}
|
primaryTotalTextOverride={`${title} + ${ethTransactionTotal} ${nativeCurrency}`}
|
||||||
|
@ -114,7 +114,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
dataHexComponent: PropTypes.node,
|
dataHexComponent: PropTypes.node,
|
||||||
hideData: PropTypes.bool,
|
hideData: PropTypes.bool,
|
||||||
hideSubtitle: PropTypes.bool,
|
hideSubtitle: PropTypes.bool,
|
||||||
identiconAddress: PropTypes.string,
|
tokenAddress: PropTypes.string,
|
||||||
onEdit: PropTypes.func,
|
onEdit: PropTypes.func,
|
||||||
subtitleComponent: PropTypes.node,
|
subtitleComponent: PropTypes.node,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
@ -998,7 +998,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
methodData,
|
methodData,
|
||||||
title,
|
title,
|
||||||
hideSubtitle,
|
hideSubtitle,
|
||||||
identiconAddress,
|
tokenAddress,
|
||||||
contentComponent,
|
contentComponent,
|
||||||
onEdit,
|
onEdit,
|
||||||
nonce,
|
nonce,
|
||||||
@ -1080,7 +1080,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
contentComponent={contentComponent}
|
contentComponent={contentComponent}
|
||||||
nonce={customNonceValue || nonce}
|
nonce={customNonceValue || nonce}
|
||||||
unapprovedTxCount={unapprovedTxCount}
|
unapprovedTxCount={unapprovedTxCount}
|
||||||
identiconAddress={identiconAddress}
|
tokenAddress={tokenAddress}
|
||||||
errorMessage={submitError}
|
errorMessage={submitError}
|
||||||
errorKey={errorKey}
|
errorKey={errorKey}
|
||||||
hasSimulationError={hasSimulationError}
|
hasSimulationError={hasSimulationError}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user