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

[WIP]: manifest v3 migration #274

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion packages/core/src/background/handlers/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default class Extension extends DotExtension {
}

private _windowOpen(path: AllowedPath): boolean {
const url = `${chrome.extension.getURL('index.html')}#${path}`;
const url = `${chrome.runtime.getURL('index.html')}#${path}`;

if (!ALLOWED_PATH.includes(path)) {
console.error('Not allowed to open the url:', url);
Expand Down
22 changes: 16 additions & 6 deletions packages/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"homepage_url": "https://github.com/PolymeshAssociation/polymesh-wallet",
"name": "Polymesh Wallet",
"short_name": "Polymesh",
"manifest_version": 2,
"manifest_version": 3,
"permissions": ["storage"],
"background": {
"scripts": ["background.js"],
"persistent": true
"service_worker": "background.js"
},
"browser_action": {
"action": {
"default_title": "Polymesh",
"default_popup": "index.html"
},
Expand All @@ -29,6 +28,17 @@
"64": "images/icon-64.png",
"128": "images/icon-128.png"
},
"web_accessible_resources": ["page.js"],
"content_security_policy": "script-src 'self' blob: 'unsafe-eval' 'wasm-eval'; object-src 'self'"
"web_accessible_resources": [
{
"resources": [
"page.js"
],
"matches": [
"*://*/*"
]
}
],
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
}
}
4 changes: 2 additions & 2 deletions packages/extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { PORTS } from '@polymeshassociation/extension-core/constants';
import { fatalErrorHandler } from '@polymeshassociation/extension-core/utils';

// setup the notification (same a FF default background, white text)
chrome.browserAction.setBadgeBackgroundColor({ color: '#d90000' });
chrome.browserAction.setBadgeText({ text: '' });
chrome.action.setBadgeBackgroundColor({ color: '#d90000' });
chrome.action.setBadgeText({ text: '' });

// This listener is invoked every time the extension is installed, updated, or reloaded.
chrome.runtime.onInstalled.addListener(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ window.addEventListener('message', ({ data, source }: Message): void => {
// inject our data injector
const script = document.createElement('script');

script.src = chrome.extension.getURL('page.js');
script.src = chrome.runtime.getURL('page.js');

script.onload = (): void => {
// remove the injecting tag when loaded
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function View({ children, className }: Props): React.ReactElement<Props> {
const _theme = themes[theme];

const switchTheme = (theme: AvailableThemes): void => {
localStorage.setItem('theme', theme);
// move to chrome.storage if needed
// localStorage.setItem('theme', theme);
setTheme(theme);
};

Expand Down
Loading