@@ -277,6 +277,28 @@ export default function DeployContract() {
277277 setSourceAccountError ( "" ) ;
278278 } ;
279279
280+ const autoCloseFloatNotification = useCallback (
281+ ( {
282+ id,
283+ title,
284+ description,
285+ } : {
286+ id : string ;
287+ title : string ;
288+ description : string ;
289+ } ) => {
290+ addFloatNotification ( {
291+ id,
292+ title,
293+ description,
294+ type : "success" ,
295+ // Close after 3 seconds
296+ closeAt : Date . now ( ) + 3000 ,
297+ } ) ;
298+ } ,
299+ [ addFloatNotification ] ,
300+ ) ;
301+
280302 useEffect ( ( ) => {
281303 if ( selectedFile && ( ! isRpcWasmBinarySuccess || ! isUploadTxSuccess ) ) {
282304 const fn = async ( ) => {
@@ -322,36 +344,33 @@ export default function DeployContract() {
322344 // Show float notification on upload tx created success
323345 useEffect ( ( ) => {
324346 if ( isUploadTxSuccess ) {
325- addFloatNotification ( {
347+ autoCloseFloatNotification ( {
326348 id : "upload-build-tx-success" ,
327349 title : "Upload transaction created" ,
328350 description :
329351 "Upload transaction was created successfully. You can sign it next." ,
330- type : "success" ,
331352 } ) ;
332353 }
333- } , [ addFloatNotification , isUploadTxSuccess ] ) ;
354+ } , [ autoCloseFloatNotification , isUploadTxSuccess ] ) ;
334355
335356 // Show float notification when upload tx is signed
336357 useEffect ( ( ) => {
337358 if ( signUploadSuccess ) {
338- addFloatNotification ( {
359+ autoCloseFloatNotification ( {
339360 id : "upload-sign-tx-success" ,
340361 title : "Upload transaction signed" ,
341362 description : `${ signUploadSuccess } . You can submit it to the network next.` ,
342- type : "success" ,
343363 } ) ;
344364 }
345- } , [ addFloatNotification , signUploadSuccess ] ) ;
365+ } , [ autoCloseFloatNotification , signUploadSuccess ] ) ;
346366
347367 // Show float notification when upload tx is submitted
348368 useEffect ( ( ) => {
349369 if ( isSubmitUploadTxSuccess ) {
350- addFloatNotification ( {
370+ autoCloseFloatNotification ( {
351371 id : "upload-submit-tx-success" ,
352372 title : "Contract uploaded to the network" ,
353373 description : `${ selectedFile ?. name } file has been uploaded successfully.` ,
354- type : "success" ,
355374 } ) ;
356375
357376 // Collapse the upload block on success
@@ -363,7 +382,7 @@ export default function DeployContract() {
363382 delay : 300 ,
364383 } ) ;
365384 }
366- } , [ addFloatNotification , isSubmitUploadTxSuccess , selectedFile ?. name ] ) ;
385+ } , [ autoCloseFloatNotification , isSubmitUploadTxSuccess , selectedFile ?. name ] ) ;
367386
368387 // ===========================================================================
369388 // Deploy effects
@@ -372,39 +391,36 @@ export default function DeployContract() {
372391 // Show float notification on deploy tx created success
373392 useEffect ( ( ) => {
374393 if ( isDeployTxSuccess ) {
375- addFloatNotification ( {
394+ autoCloseFloatNotification ( {
376395 id : "deploy-build-tx-success" ,
377396 title : "Deploy transaction created" ,
378397 description :
379398 "Deploy transaction was created successfully. You can sign it next." ,
380- type : "success" ,
381399 } ) ;
382400 }
383- } , [ addFloatNotification , isDeployTxSuccess ] ) ;
401+ } , [ autoCloseFloatNotification , isDeployTxSuccess ] ) ;
384402
385403 // Show float notification when deploy tx is signed
386404 useEffect ( ( ) => {
387405 if ( signDeploySuccess ) {
388- addFloatNotification ( {
406+ autoCloseFloatNotification ( {
389407 id : "deploy-sign-tx-success" ,
390408 title : "Deploy transaction signed" ,
391409 description : `${ signDeploySuccess } . You can submit it to the network next.` ,
392- type : "success" ,
393410 } ) ;
394411 }
395- } , [ addFloatNotification , signDeploySuccess ] ) ;
412+ } , [ autoCloseFloatNotification , signDeploySuccess ] ) ;
396413
397414 // Show float notification when deploy tx is submitted
398415 useEffect ( ( ) => {
399416 if ( isSubmitDeployTxSuccess ) {
400- addFloatNotification ( {
417+ autoCloseFloatNotification ( {
401418 id : "deploy-submit-tx-success" ,
402419 title : "Contract deployed!" ,
403420 description : `${ selectedFile ?. name } file has been successfully deployed.` ,
404- type : "success" ,
405421 } ) ;
406422 }
407- } , [ addFloatNotification , isSubmitDeployTxSuccess , selectedFile ?. name ] ) ;
423+ } , [ autoCloseFloatNotification , isSubmitDeployTxSuccess , selectedFile ?. name ] ) ;
408424
409425 useEffect ( ( ) => {
410426 // Collapse deploy block on success
0 commit comments