Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url from sender/tab, better per-extension errors #44

Merged
merged 2 commits into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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