import { toast } from 'react-toastify'
export const withToast = (promise) => {
toast.promise(
promise,
{
pending: {
render(){
return (
Your transaction is being processed.
Hang tight... Just few more moments.
)
},
icon: false,
},
success: {
render({data}){
return (
Tx: {data.transactionHash.slice(0, 20)}...
Has been succesfuly processed.
See Tx Details
)
},
// other options
icon: "🟢",
},
error: {
render({data}){
// When the promise reject, data will contains the error
return {data.message ?? "Transaction has failed"}
}
}
},
{
closeButton: true
}
)
}