diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 9c3bbf2dd..27b228fda 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -74,6 +74,7 @@ const VALID_UNAPPROVED_TRANSACTION_TYPES = [ TRANSACTION_TYPES.SIMPLE_SEND, TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER, TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM, + TRANSACTION_TYPES.CONTRACT_INTERACTION, ]; /** diff --git a/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.component.js b/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.component.js index 6dc94607f..3fc952324 100644 --- a/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.component.js +++ b/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.component.js @@ -13,6 +13,7 @@ export default function UserPreferencedCurrencyDisplay({ showEthLogo, type, showFiat, + showCurrencySuffix, ...restProps }) { const { currency, numberOfDecimals } = useUserPreferencedCurrency(type, { @@ -43,6 +44,7 @@ export default function UserPreferencedCurrencyDisplay({ data-testid={dataTestId} numberOfDecimals={numberOfDecimals} prefixComponent={prefixComponent} + suffix={showCurrencySuffix && !showEthLogo && currency} /> ); } @@ -68,4 +70,5 @@ UserPreferencedCurrencyDisplay.propTypes = { PropTypes.number, ]), showFiat: PropTypes.bool, + showCurrencySuffix: PropTypes.bool, }; diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index f5e412e85..10bc0ae6e 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -18,6 +18,7 @@ import { INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR, KNOWN_RECIPIENT_ADDRESS_WARNING, NEGATIVE_ETH_ERROR, + RECIPIENT_TYPES, } from '../../pages/send/send.constants'; import { @@ -388,6 +389,7 @@ export const draftTransactionInitialState = { error: null, nickname: '', warning: null, + type: '', recipientWarningAcknowledged: false, }, status: SEND_STATUSES.VALID, @@ -1169,6 +1171,12 @@ const slice = createSlice({ draftTransaction.recipient.warning = action.payload; }, + updateRecipientType: (state, action) => { + const draftTransaction = + state.draftTransactions[state.currentTransactionUUID]; + draftTransaction.recipient.type = action.payload; + }, + updateDraftTransactionStatus: (state, action) => { const draftTransaction = state.draftTransactions[state.currentTransactionUUID]; @@ -1881,6 +1889,7 @@ export function updateRecipientUserInput(userInput) { if (inputIsValidHexAddress) { const smartContractAddress = await isSmartContractAddress(userInput); if (smartContractAddress) { + dispatch(actions.updateRecipientType(RECIPIENT_TYPES.SMART_CONTRACT)); const { symbol, decimals } = getTokenMetadata(userInput, tokenMap) || {}; @@ -2270,7 +2279,10 @@ export function signTransaction() { updateTransactionGasFees(draftTransaction.id, editingTx.txParams), ); } else { - let transactionType = TRANSACTION_TYPES.SIMPLE_SEND; + let transactionType = + draftTransaction.recipient.type === RECIPIENT_TYPES.SMART_CONTRACT + ? TRANSACTION_TYPES.CONTRACT_INTERACTION + : TRANSACTION_TYPES.SIMPLE_SEND; if (draftTransaction.asset.type !== ASSET_TYPES.NATIVE) { transactionType = diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index a2dbc3c34..f069212e7 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -2428,6 +2428,7 @@ describe('Send Slice', () => { nickname: '', warning: null, recipientWarningAcknowledged: false, + type: '', }, status: SEND_STATUSES.VALID, transactionType: '0x0', @@ -2570,6 +2571,7 @@ describe('Send Slice', () => { error: null, nickname: '', warning: null, + type: '', recipientWarningAcknowledged: false, }, status: SEND_STATUSES.VALID, @@ -2759,6 +2761,7 @@ describe('Send Slice', () => { error: null, warning: null, nickname: '', + type: '', recipientWarningAcknowledged: false, }, status: SEND_STATUSES.VALID, diff --git a/ui/helpers/utils/transactions.util.js b/ui/helpers/utils/transactions.util.js index 0d5b06907..f2b1ed628 100644 --- a/ui/helpers/utils/transactions.util.js +++ b/ui/helpers/utils/transactions.util.js @@ -128,8 +128,11 @@ export function getLatestSubmittedTxWithNonce( } export async function isSmartContractAddress(address) { - const { isContractCode } = await readAddressAsContract(global.eth, address); - return isContractCode; + const { isContractAddress } = await readAddressAsContract( + global.eth, + address, + ); + return isContractAddress; } export function sumHexes(...args) { diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 571bc3524..704880c6c 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -870,20 +870,24 @@ export default class ConfirmTransactionBase extends Component { } renderTitleComponent() { - const { title, hexTransactionAmount } = this.props; + const { title, hexTransactionAmount, txData } = this.props; // Title string passed in by props takes priority if (title) { return null; } + const isContractInteraction = + txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION; + return ( ); } diff --git a/ui/pages/send/send.constants.js b/ui/pages/send/send.constants.js index c1db26722..6fefd204f 100644 --- a/ui/pages/send/send.constants.js +++ b/ui/pages/send/send.constants.js @@ -47,6 +47,11 @@ const ENS_ILLEGAL_CHARACTER = 'ensIllegalCharacter'; const ENS_UNKNOWN_ERROR = 'ensUnknownError'; const ENS_REGISTRATION_ERROR = 'ensRegistrationError'; +const RECIPIENT_TYPES = { + SMART_CONTRACT: 'SMART_CONTRACT', + NON_CONTRACT: 'NON_CONTRACT', +}; + export { MAX_GAS_LIMIT_DEC, HIGH_FEE_WARNING_MULTIPLIER, @@ -72,4 +77,5 @@ export { CONFUSING_ENS_ERROR, TOKEN_TRANSFER_FUNCTION_SIGNATURE, COLLECTIBLE_TRANSFER_FROM_FUNCTION_SIGNATURE, + RECIPIENT_TYPES, };