Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dispatchedToasts--
}
if (options?.onClose) {
options.onClose(props)
}
}
const toastOptions = { ...options, onClose: onToastClose }
switch (type) {
case SUCCESS:
toast.success(renderToast, toastOptions)
break
case WARNING:
toast.warning(renderToast, toastOptions)
break
case INFO:
toast.info(renderToast, toastOptions)
break
default:
toast.error(renderToast, toastOptions)
}
} else if (options?.isNotification) {
// If it is a notification, try to push it to the browser if borwser notifications are enabled
// - Emit a an event to be processed in the BrowserNotificationsContainer
Emitter.emit(
BROWSER_NOTIFICATIONS_EVENT_KEY,
{
message: toastMessage,
title: toastTitle,
},
async checkMetamaskSetup() {
const web3 = await getWeb3();
if (web3.currentProvider.isMetaMask) {
const accounts = await web3.eth.getAccounts();
if (accounts.length) {
let contracts = localStorage.getItem("tokens");
contracts = contracts.split(",");
this.props.getTransactions(web3, accounts[0], contracts);
this.setState({ accounts });
} else {
toast.warning("Unlock Metamask");
}
} else {
toast.warning("Install Metamask");
}
}
async checkMetamaskSetup() {
const web3 = await getWeb3();
if (web3.currentProvider.isMetaMask) {
const accounts = await web3.eth.getAccounts();
if (accounts.length) {
let contracts = localStorage.getItem("tokens");
contracts = contracts.split(",");
this.props.getTransactions(web3, accounts[0], contracts);
this.setState({ accounts });
} else {
toast.warning("Unlock Metamask");
}
} else {
toast.warning("Install Metamask");
}
}
_showHandler = () => {
switch(this.state.type) {
case 'info':
toast.info(contentInfo);
break;
case 'success':
toast.success(contentSuccess);
break;
case 'warning':
toast.warning(contentWarning);
break;
case 'error':
toast.error(contentError);
break;
default:
toast(contentDefault);
break;
}
}
async checkMetamaskSetup() {
const web3 = await getWeb3();
if (web3.currentProvider.isMetaMask) {
const accounts = await web3.eth.getAccounts();
if (accounts.length) {
this.props.history.push("wallet");
} else {
toast.warning("Unlock Metamask");
}
} else {
toast.warning("Install Metamask");
}
}
_showHandler = () => {
switch(this.state.type) {
case 'info':
toast.info(contentInfo);
break;
case 'success':
toast.success(contentSuccess);
break;
case 'warning':
toast.warning(contentWarning);
break;
case 'error':
toast.error(contentError);
break;
default:
toast(contentDefault);
break;
}
}
async checkMetamaskSetup() {
const web3 = await getWeb3();
if (web3.currentProvider.isMetaMask) {
const accounts = await web3.eth.getAccounts();
if (accounts.length) {
this.props.history.push("wallet");
} else {
toast.warning("Unlock Metamask");
}
} else {
toast.warning("Install Metamask");
}
}