Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async refreshAccount(reload : boolean, address: string) {
toast.dismiss()
if (this.networkName !== NetworkName.Mainnet) {
if (this.status !== MetamaskStatus.InvalidNetwork) {
this.status = MetamaskStatus.InvalidNetwork
this.onStateChange()
}
return
}
try {
if (reload) {
// Easy way out for now
// TODO: Make all modules refresh all acct based state when setWeb3Account() is called
window.location.reload()
}
this.conn.onmessage = event => {
console.log('Message received from server : ', event)
if (event.data === 'update') {
toast.dismiss()
toast.warn('Ce Media a été mis à jour')
this.getClient().then(this.setClient)
}
}
const close = () => reactToastify.dismiss(toastId);
return {update, close};
async getBalance(force: boolean = false) : Promise {
if (!force) {
await this.ready
}
toast.dismiss(ToastType.Balance)
this.oneBalance = (await this.token.balanceOf(this.address as string)).div( 10 ** 18 ).toNumber()
web3.eth.getBalance(this.address as string, (err, balance) => {
if (err || balance === null) {
throw (err)
}
this.ethBalance = balance.div(10 ** 18).toNumber()
if (this.ethBalance === 0) {
toast(`Note you have no ETH in this wallet.`, {
autoClose: false,
toastId: ToastType.Balance
})
} else
if (this.oneBalance === 0) {
function dismissAlert(id) {
toast.dismiss(id);
}
componentWillUnmount() {
if (toast.isActive('loginFailed')) {
toast.dismiss('loginFailed');
}
}
export const saveTools = (tools) => {
if (!tools.autoSave && prevLocalStorageState) {
toast(' ⚠️ Auto save to local storage is now off!', { toastId: 'rrtrlsoff', position: 'top-right', autoClose: false });
} else if (tools.autoSave && !prevLocalStorageState) {
toast.dismiss('rrtrlsoffinit');
toast.dismiss('rrtrlsoff');
toast(' 💾 Auto save to local storage is now on!', { toastId: 'rrtrlson', position: 'top-right', autoClose: 10000 });
}
prevLocalStorageState = tools.autoSave;
if (ls.setItem(STORED_TOOLS_KEY, tools)) {
toast.dismiss('rrterrorsaveresume');
debounce(() => toast(' 💾 saved to local storage...', { toastId: 'rrtresumesaved', position: 'top-right' }),
100,
false,
'rrtresumesaved');
} else {
debounce(() => toast(' ⚠️ error saving to local storage...', { toastId: 'rrterrorsaveresume', position: 'top-right' }),
100,
false,
'rrterrorsaveresume');
}
export const saveTools = (tools) => {
if (!tools.autoSave && prevLocalStorageState) {
toast(' ⚠️ Auto save to local storage is now off!', { toastId: 'rrtrlsoff', position: 'top-right', autoClose: false });
} else if (tools.autoSave && !prevLocalStorageState) {
toast.dismiss('rrtrlsoffinit');
toast.dismiss('rrtrlsoff');
toast(' 💾 Auto save to local storage is now on!', { toastId: 'rrtrlson', position: 'top-right', autoClose: 10000 });
}
prevLocalStorageState = tools.autoSave;
if (ls.setItem(STORED_TOOLS_KEY, tools)) {
toast.dismiss('rrterrorsaveresume');
debounce(() => toast(' 💾 saved to local storage...', { toastId: 'rrtresumesaved', position: 'top-right' }),
100,
false,
'rrtresumesaved');
} else {
debounce(() => toast(' ⚠️ error saving to local storage...', { toastId: 'rrterrorsaveresume', position: 'top-right' }),
100,
false,
'rrterrorsaveresume');
}
return tools;
export function dismiss(toastId: number) {
toast.dismiss(toastId);
}
componentDidMount() {
this.props.checkUserLogin();
toast.dismiss('login-alert');
}