portis-project / web-sdk

Portis Web SDK
https://portis.io
MIT License
77 stars 31 forks source link

OnLogout & onError Portis event handlers not being called #138

Open FlorianML opened 3 years ago

FlorianML commented 3 years ago

Working with integrating Portis into my company's app. I'm able to pull the account using the implementation below but having issues fully logging out. After calling await portis.logout() it resolves with success: true but it does not trigger the onLogout callback. Instead I get an error (attached below) which also does not get communicated to the onError callback.

Reviewing the network activity, there are still calls being made from the widget after the provider has logged out so I'm unsure if the previous issue has anything to do with it

Code Snippet:

const { Portis } = window;

export async function getPortisAddresses() {
  let portis = new Portis(process.env.REACT_APP_PORTIS_ID, 'mainnet');

  portis.onLogout(() => {
    if (isDev()) {
      // eslint-disable-next-line no-console
      console.log('logging out');
    }
  });
  portis.onError((error) => {
    if (isDev()) {
      // eslint-disable-next-line no-console
      console.log('error occured', error);
    }
  });

  const accounts = await portis.provider.enable();

  // deactivate portis
 await portis.logout();

  portis = undefined;
  return accounts;
}

Error:

Screen Shot 2021-10-01 at 12 00 41 PM
fsobh commented 2 years ago

Having the same issue