Skip to content

Commit

Permalink
url from sender/tab, better per-extension errors (#44)
Browse files Browse the repository at this point in the history
* url from sender/tab, better per-extension errors

* Remove debug log
  • Loading branch information
jacogr authored Jun 2, 2019
1 parent 1a18a2e commit e7c6272
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
11 changes: 7 additions & 4 deletions packages/extension-dapp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedExtensionInfo, InjectedWindow, Unsubcall } from './types';
import { InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedWindow, Unsubcall } from './types';

// our extension adaptor for other kinds of extensions
import compatInjector from './compat';
Expand Down Expand Up @@ -44,9 +44,12 @@ export function web3Enable (originName: string): Promise<Array<InjectedExtension
web3EnablePromise = compatInjector().then(() =>
Promise.all(
Object.entries(win.injectedWeb3).map(([name, { enable, version }]) =>
Promise
.all([Promise.resolve({ name, version }), enable(originName)])
.catch(() => [{ name, version }, null] as [InjectedExtensionInfo, null])
Promise.all([
Promise.resolve({ name, version }),
enable(originName).catch((error: Error) => {
console.error(`Error initializing ${name}: ${error.message}`);
})
])
)
)
.then((values) =>
Expand Down
5 changes: 1 addition & 4 deletions packages/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
},
"content_scripts": [{
"js": ["content.js"],
"matches": [
"https://polkadot.js.org/apps/*",
"http://localhost:3000/*"
],
"matches": ["http://*/*", "https://*/*"],
"run_at": "document_start"
}],
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/background/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function handler ({ id, message, request }: MessageRequest, port:
const sender = port.sender as chrome.runtime.MessageSender;
const from = isPopup
? 'popup'
: sender.tab && sender.tab.url;
: (sender.tab && sender.tab.url) || sender.url;
const source = `${from || FALLBACK_URL}: ${id}: ${message}`;

console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
Expand Down

0 comments on commit e7c6272

Please sign in to comment.