@@ -18,6 +18,7 @@ import {
1818 INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR ,
1919 KNOWN_RECIPIENT_ADDRESS_WARNING ,
2020 NEGATIVE_ETH_ERROR ,
21+ RECIPIENT_TYPES ,
2122} from '../../pages/send/send.constants' ;
2223
2324import {
@@ -82,14 +83,18 @@ import {
8283 getTokens ,
8384 getUnapprovedTxs ,
8485} from '../metamask/metamask' ;
86+ import {
87+ isSmartContractAddress ,
88+ sumHexes ,
89+ } from '../../helpers/utils/transactions.util' ;
8590
8691import { resetEnsResolution } from '../ens' ;
8792import {
8893 isBurnAddress ,
8994 isValidHexAddress ,
9095 toChecksumHexAddress ,
9196} from '../../../shared/modules/hexstring-utils' ;
92- import { sumHexes } from '../../helpers/utils/transactions.util' ;
97+
9398import fetchEstimatedL1Fee from '../../helpers/utils/optimism/fetchEstimatedL1Fee' ;
9499
95100import { TOKEN_STANDARDS , ETH } from '../../helpers/constants/common' ;
@@ -383,6 +388,7 @@ export const draftTransactionInitialState = {
383388 error : null ,
384389 nickname : '' ,
385390 warning : null ,
391+ type : '' ,
386392 recipientWarningAcknowledged : false ,
387393 } ,
388394 status : SEND_STATUSES . VALID ,
@@ -1172,6 +1178,12 @@ const slice = createSlice({
11721178 draftTransaction . recipient . warning = action . payload ;
11731179 } ,
11741180
1181+ updateRecipientType : ( state , action ) => {
1182+ const draftTransaction =
1183+ state . draftTransactions [ state . currentTransactionUUID ] ;
1184+ draftTransaction . recipient . type = action . payload ;
1185+ } ,
1186+
11751187 updateDraftTransactionStatus : ( state , action ) => {
11761188 const draftTransaction =
11771189 state . draftTransactions [ state . currentTransactionUUID ] ;
@@ -1876,19 +1888,24 @@ export function updateRecipientUserInput(userInput) {
18761888 const inputIsValidHexAddress = isValidHexAddress ( userInput ) ;
18771889 let isProbablyAnAssetContract = false ;
18781890 if ( inputIsValidHexAddress ) {
1879- const { symbol, decimals } = getTokenMetadata ( userInput , tokenMap ) || { } ;
1891+ const smartContractAddress = await isSmartContractAddress ( userInput ) ;
1892+ if ( smartContractAddress ) {
1893+ dispatch ( actions . updateRecipientType ( RECIPIENT_TYPES . SMART_CONTRACT ) ) ;
1894+ const { symbol, decimals } =
1895+ getTokenMetadata ( userInput , tokenMap ) || { } ;
18801896
1881- isProbablyAnAssetContract = symbol && decimals !== undefined ;
1897+ isProbablyAnAssetContract = symbol && decimals !== undefined ;
18821898
1883- if ( ! isProbablyAnAssetContract ) {
1884- try {
1885- const { standard } = await getTokenStandardAndDetails (
1886- userInput ,
1887- sendingAddress ,
1888- ) ;
1889- isProbablyAnAssetContract = Boolean ( standard ) ;
1890- } catch ( e ) {
1891- console . log ( e ) ;
1899+ if ( ! isProbablyAnAssetContract ) {
1900+ try {
1901+ const { standard } = await getTokenStandardAndDetails (
1902+ userInput ,
1903+ sendingAddress ,
1904+ ) ;
1905+ isProbablyAnAssetContract = Boolean ( standard ) ;
1906+ } catch ( e ) {
1907+ console . log ( e ) ;
1908+ }
18921909 }
18931910 }
18941911 }
@@ -2259,7 +2276,10 @@ export function signTransaction() {
22592276 updateTransactionGasFees ( draftTransaction . id , editingTx . txParams ) ,
22602277 ) ;
22612278 } else {
2262- let transactionType = TRANSACTION_TYPES . SIMPLE_SEND ;
2279+ let transactionType =
2280+ draftTransaction . recipient . type === RECIPIENT_TYPES . SMART_CONTRACT
2281+ ? TRANSACTION_TYPES . CONTRACT_INTERACTION
2282+ : TRANSACTION_TYPES . SIMPLE_SEND ;
22632283
22642284 if ( draftTransaction . asset . type !== ASSET_TYPES . NATIVE ) {
22652285 transactionType =
0 commit comments