Skip to content

Commit

Permalink
fix: fix contract address display in confirmation page
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri committed Sep 27, 2023
1 parent 941b734 commit b5538dd
Showing 4 changed files with 19 additions and 6 deletions.
8 changes: 8 additions & 0 deletions test/data/mock-state.json
Original file line number Diff line number Diff line change
@@ -20,6 +20,14 @@
"warning": null,
"customTokenAmount": "10"
},
"confirmTransaction": {
"txData": {
"txParams": {
"gas": "0x153e2",
"value": "0x0"
}
}
},
"history": {
"mostRecentOverviewPage": "/mostRecentOverviewPage"
},
Original file line number Diff line number Diff line change
@@ -319,6 +319,8 @@ describe('Confirm Page Container Container Test', () => {
};

mockState.metamask.addressBook = addressBook;
mockState.confirmTransaction.txData.txParams.to =
'0x7a1A4Ad9cc746a70ee58568466f7996dD0aCE4E8';

const store = configureMockStore()(mockState);

Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { TransactionType } from '../../../../../../shared/constants/transaction'
import { toChecksumHexAddress } from '../../../../../../shared/modules/hexstring-utils';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import useAddressDetails from '../../../../../hooks/useAddressDetails';
import { getIpfsGateway } from '../../../../../selectors';
import { getIpfsGateway, txDataSelector } from '../../../../../selectors';

import Identicon from '../../../../ui/identicon';
import InfoTooltip from '../../../../ui/info-tooltip';
@@ -25,7 +25,6 @@ const ConfirmPageContainerSummary = (props) => {
subtitleComponent,
className,
tokenAddress,
toAddress,
nonce,
origin,
image,
@@ -36,6 +35,10 @@ const ConfirmPageContainerSummary = (props) => {
const t = useI18nContext();
const ipfsGateway = useSelector(getIpfsGateway);

const txData = useSelector(txDataSelector);
const { txParams = {} } = txData;
const { to: txParamsToAddress } = txParams;

const contractInitiatedTransactionType = [
TransactionType.contractInteraction,
TransactionType.tokenMethodTransfer,
@@ -48,14 +51,15 @@ const ConfirmPageContainerSummary = (props) => {
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
// type of contract interaction it is "to" from txParams

contractAddress =
transactionType === TransactionType.tokenMethodTransfer ||
transactionType === TransactionType.tokenMethodTransferFrom ||
transactionType === TransactionType.tokenMethodSafeTransferFrom ||
transactionType === TransactionType.tokenMethodSetApprovalForAll
? tokenAddress
: toAddress;
: txParamsToAddress;
}

const { toName, isTrusted } = useAddressDetails(contractAddress);
@@ -146,7 +150,6 @@ ConfirmPageContainerSummary.propTypes = {
subtitleComponent: PropTypes.node,
className: PropTypes.string,
tokenAddress: PropTypes.string,
toAddress: PropTypes.string,
nonce: PropTypes.string,
origin: PropTypes.string.isRequired,
transactionType: PropTypes.string,
Original file line number Diff line number Diff line change
@@ -83,8 +83,8 @@ import {
TransactionStatus,
TransactionType,
} from '../../../shared/constants/transaction';
import { getTokenAddressParam } from '../../helpers/utils/token-util';
import { calcGasTotal } from '../../../shared/lib/transactions-controller-utils';
import { getTokenAddressParam } from '../../helpers/utils/token-util';
import ConfirmTransactionBase from './confirm-transaction-base.component';

let customNonceValue = '';

0 comments on commit b5538dd

Please sign in to comment.