@ -1,4 +1,4 @@
import React , { useState } from 'react' ;
import React , { useContext , use State } from 'react' ;
import { useHistory } from 'react-router-dom' ;
import { useHistory } from 'react-router-dom' ;
import { useDispatch , useSelector } from 'react-redux' ;
import { useDispatch , useSelector } from 'react-redux' ;
import { util } from '@metamask/controllers' ;
import { util } from '@metamask/controllers' ;
@ -17,6 +17,7 @@ import ActionableMessage from '../../components/ui/actionable-message';
import PageContainer from '../../components/ui/page-container' ;
import PageContainer from '../../components/ui/page-container' ;
import {
import {
addCollectibleVerifyOwnership ,
addCollectibleVerifyOwnership ,
getTokenStandardAndDetails ,
removeToken ,
removeToken ,
setNewCollectibleAddedMessage ,
setNewCollectibleAddedMessage ,
} from '../../store/actions' ;
} from '../../store/actions' ;
@ -24,6 +25,8 @@ import FormField from '../../components/ui/form-field';
import { getIsMainnet , getUseCollectibleDetection } from '../../selectors' ;
import { getIsMainnet , getUseCollectibleDetection } from '../../selectors' ;
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask' ;
import { getCollectiblesDetectionNoticeDismissed } from '../../ducks/metamask/metamask' ;
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice' ;
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice' ;
import { MetaMetricsContext } from '../../contexts/metametrics' ;
import { ASSET _TYPES } from '../../../shared/constants/transaction' ;
export default function AddCollectible ( ) {
export default function AddCollectible ( ) {
const t = useI18nContext ( ) ;
const t = useI18nContext ( ) ;
@ -47,6 +50,7 @@ export default function AddCollectible() {
const [ tokenId , setTokenId ] = useState ( '' ) ;
const [ tokenId , setTokenId ] = useState ( '' ) ;
const [ disabled , setDisabled ] = useState ( true ) ;
const [ disabled , setDisabled ] = useState ( true ) ;
const [ collectibleAddFailed , setCollectibleAddFailed ] = useState ( false ) ;
const [ collectibleAddFailed , setCollectibleAddFailed ] = useState ( false ) ;
const trackEvent = useContext ( MetaMetricsContext ) ;
const handleAddCollectible = async ( ) => {
const handleAddCollectible = async ( ) => {
try {
try {
@ -65,6 +69,26 @@ export default function AddCollectible() {
) ;
) ;
}
}
dispatch ( setNewCollectibleAddedMessage ( 'success' ) ) ;
dispatch ( setNewCollectibleAddedMessage ( 'success' ) ) ;
const tokenDetails = await getTokenStandardAndDetails (
address ,
null ,
tokenId . toString ( ) ,
) ;
trackEvent ( {
event : 'Token Added' ,
category : 'Wallet' ,
sensitiveProperties : {
token _contract _address : address ,
token _symbol : tokenDetails ? . symbol ,
tokenId : tokenId . toString ( ) ,
asset _type : ASSET _TYPES . COLLECTIBLE ,
token _standard : tokenDetails ? . standard ,
source : 'custom' ,
} ,
} ) ;
history . push ( DEFAULT _ROUTE ) ;
history . push ( DEFAULT _ROUTE ) ;
} ;
} ;