@@ -39,6 +39,7 @@ const Send = () => {
39
39
40
40
const [ txHash , setTxHash ] = useState ( "" )
41
41
42
+ // TODO: how to call this after approve
42
43
const needApproval = useAsyncMemo ( async ( ) => {
43
44
if ( tokenInstance ) {
44
45
const isApproved = await checkApproval ( tokenInstance , gatewayAddress )
@@ -74,35 +75,40 @@ const Send = () => {
74
75
const handleSend = async ( ) => {
75
76
setSendLoading ( true )
76
77
setSendModalLoading ( true )
77
- const tx = isLayer1 ? await deposite ( ) : await withdraw ( )
78
- addNFTTransaction ( {
79
- hash : tx . hash ,
80
- fromName : fromNetwork . name ,
81
- toName : toNetwork . name ,
82
- fromExplore : fromNetwork . explorer ,
83
- toExplore : toNetwork . explorer ,
84
- tokenType : contract . type ,
85
- tokenAddress : isLayer1 ? contract . l1 : contract . l2 ,
86
- amounts : selectedList . map ( item => item . transferAmount ) ,
87
- tokenIds : selectedTokenIds ,
88
- isL1 : isLayer1 ,
89
- } )
90
- tx . wait ( )
91
- . then ( receipt => {
92
- console . log ( receipt , "send receipt" )
93
- updateNFTTransaction ( tx . hash , {
94
- fromBlockNumber : receipt . blockNumber ,
95
- } )
96
- setTxHash ( receipt . transactionHash )
97
- exciseSelected ( )
98
- } )
99
- . catch ( error => {
100
- updatePromptMessage ( error . message )
101
- } )
102
- . finally ( ( ) => {
103
- setSendLoading ( false )
104
- setSendModalLoading ( false )
78
+ try {
79
+ const tx = isLayer1 ? await deposite ( ) : await withdraw ( )
80
+ addNFTTransaction ( {
81
+ hash : tx . hash ,
82
+ fromName : fromNetwork . name ,
83
+ toName : toNetwork . name ,
84
+ fromExplore : fromNetwork . explorer ,
85
+ toExplore : toNetwork . explorer ,
86
+ tokenType : contract . type ,
87
+ tokenAddress : isLayer1 ? contract . l1 : contract . l2 ,
88
+ amounts : selectedList . map ( item => item . transferAmount ) ,
89
+ tokenIds : selectedTokenIds ,
90
+ isL1 : isLayer1 ,
105
91
} )
92
+
93
+ tx . wait ( )
94
+ . then ( receipt => {
95
+ updateNFTTransaction ( tx . hash , {
96
+ fromBlockNumber : receipt . blockNumber ,
97
+ } )
98
+ setTxHash ( receipt . transactionHash )
99
+ exciseSelected ( )
100
+ } )
101
+ . catch ( error => {
102
+ updatePromptMessage ( error . message )
103
+ } )
104
+ . finally ( ( ) => {
105
+ setSendLoading ( false )
106
+ setSendModalLoading ( false )
107
+ } )
108
+ } catch ( e ) {
109
+ setSendLoading ( false )
110
+ setSendModalLoading ( false )
111
+ }
106
112
}
107
113
108
114
const deposite = ( ) => {
0 commit comments