diff --git a/packages/rpcs/wallet_getSidePanelEnabled/index.js b/packages/rpcs/wallet_getSidePanelEnabled/index.js index a803b207..408ba2ba 100644 --- a/packages/rpcs/wallet_getSidePanelEnabled/index.js +++ b/packages/rpcs/wallet_getSidePanelEnabled/index.js @@ -5,7 +5,7 @@ export const NAME = 'wallet_getSidePanelEnabled' const getSidePanel = async () => { const browser = (await import('webextension-polyfill')).default - browser.storage.local.get(SIDE_PANEL_KEY) + return browser.storage.local.get(SIDE_PANEL_KEY) } export const schemas = { @@ -19,7 +19,7 @@ export const permissions = { } export const main = async ({rpcs: {wallet_getSidePanelSupported}}) => { - if (!wallet_getSidePanelSupported()) { + if (!(await wallet_getSidePanelSupported())) { return false } const res = await getSidePanel() diff --git a/packages/rpcs/wallet_setSidePanelBehavior/index.js b/packages/rpcs/wallet_setSidePanelBehavior/index.js index 0a0eccfc..c5bcfe83 100644 --- a/packages/rpcs/wallet_setSidePanelBehavior/index.js +++ b/packages/rpcs/wallet_setSidePanelBehavior/index.js @@ -11,19 +11,10 @@ export const permissions = { export const main = async ({ rpcs: {wallet_getSidePanelSupported, wallet_getSidePanelEnabled}, }) => { + const isSupported = await wallet_getSidePanelSupported() + if (!isSupported) return const isEnabled = await wallet_getSidePanelEnabled() - const isSupported = wallet_getSidePanelSupported() - if (isEnabled) { - if (isSupported) { - await chrome.sidePanel.setPanelBehavior({ - openPanelOnActionClick: true, - }) - } - } else { - if (isSupported) { - await chrome.sidePanel.setPanelBehavior({ - openPanelOnActionClick: false, - }) - } - } + await chrome.sidePanel.setPanelBehavior({ + openPanelOnActionClick: isEnabled, + }) } diff --git a/packages/rpcs/wallet_setSidePanelEnabled/index.js b/packages/rpcs/wallet_setSidePanelEnabled/index.js index 52d2d60f..d3448b1f 100644 --- a/packages/rpcs/wallet_setSidePanelEnabled/index.js +++ b/packages/rpcs/wallet_setSidePanelEnabled/index.js @@ -5,7 +5,7 @@ export const NAME = 'wallet_setSidePanelEnabled' const setSidePanel = async enabled => { const browser = (await import('webextension-polyfill')).default - browser.storage.local.set({[SIDE_PANEL_KEY]: enabled}) + return browser.storage.local.set({[SIDE_PANEL_KEY]: enabled}) } export const schemas = { @@ -22,7 +22,7 @@ export const main = async ({ params, rpcs: {wallet_getSidePanelSupported, wallet_setSidePanelBehavior}, }) => { - if (!wallet_getSidePanelSupported()) { + if (!(await wallet_getSidePanelSupported())) { throw new Error('Side panel is not supported') } await setSidePanel(params.enabled)