Skip to content

Commit

Permalink
fix: manifest v3 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
olia-nistratova committed Jun 20, 2024
1 parent e7b866e commit 64e5315
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
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

0 comments on commit 64e5315

Please sign in to comment.