1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

survive metamask failure to login

This commit is contained in:
Jernej Pregelj 2019-07-09 16:23:26 +02:00 committed by Matthias Kretschmann
parent 85304c2d09
commit 9e7df28b89
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -139,6 +139,19 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
}
}
private loadDefaultWeb3 = async () => {
this.setState(
{
isLogged: false,
isBurner: false,
web3: DEFAULT_WEB3
},
() => {
this.loadOcean()
}
)
}
private loadOcean = async () => {
const { ocean } = await provideOcean(this.state.web3)
this.setState({ ocean, isLoading: false }, () => {
@ -169,26 +182,11 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
}
)
} else {
this.loadOcean()
this.loadDefaultWeb3()
}
break
case 'BurnerWallet':
const burnerWalletProvider = new BurnerWalletProvider()
if (await burnerWalletProvider.isLogged()) {
await burnerWalletProvider.startLogin()
this.setState(
{
isLogged: true,
isBurner: true,
web3: burnerWalletProvider.getProvider()
},
() => {
this.loadOcean()
}
)
} else {
this.loginBurnerWallet()
}
this.loginBurnerWallet()
break
default:
this.loginBurnerWallet()