Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
don't catch browser provider error too early
Browse files Browse the repository at this point in the history
  • Loading branch information
levity committed Oct 11, 2018
1 parent 00e0050 commit b075eac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/eth/accounts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export async function getBrowserProvider() {
};

if (window.ethereum) {
try {
await window.ethereum.enable();
} catch (error) {
console.error(error);
}
await window.ethereum.enable();
return wrap(window.ethereum);
} else if (window.web3) {
return wrap(window.web3.currentProvider);
Expand Down
13 changes: 8 additions & 5 deletions test/eth/AccountsService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ describe('mocking window', () => {

test('browserProviderAccountFactory with window.ethereum, user rejects provider', async () => {
window.ethereum = {
enable: () => {
enable: async () => {
window.ethereum['sendAsync'] = mockProvider.sendAsync;
throw new Error();
throw new Error('nope');
}
};
global.console = { error: jest.fn() };
await browserProviderAccountFactory();
expect(console.error).toBeCalled();
expect.assertions(1);
try {
await browserProviderAccountFactory();
} catch (err) {
expect(err.message).toMatch(/nope/);
}
});
});

0 comments on commit b075eac

Please sign in to comment.