-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feat: open to Activity tab on failed transaction #41531
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,9 @@ import { | |
| ENVIRONMENT_TYPE_SIDEPANEL, | ||
| PLATFORM_FIREFOX, | ||
| MESSAGE_TYPE, | ||
| POPUP_FILE, | ||
| POPUP_INIT_FILE, | ||
| SIDEPANEL_FILE, | ||
| } from '../../shared/constants/app'; | ||
| import { EXTENSION_MESSAGES } from '../../shared/constants/messages'; | ||
| import { BACKGROUND_LIVENESS_METHOD } from '../../shared/constants/ui-initialization'; | ||
|
|
@@ -154,6 +157,7 @@ log.setLevel(process.env.METAMASK_DEBUG ? 'debug' : 'info', false); | |
| const platform = new ExtensionPlatform(); | ||
| const notificationManager = new NotificationManager(); | ||
| const isFirefox = getPlatform() === PLATFORM_FIREFOX; | ||
| const POPUP_LAUNCH_FILE = isFirefox ? POPUP_FILE : POPUP_INIT_FILE; | ||
|
|
||
| /** | ||
| * Parses port connection info for routing decisions. | ||
|
|
@@ -1837,36 +1841,39 @@ export function setupController( | |
| onTransactionFailed, | ||
| ); | ||
|
|
||
| function onTransactionFailed() { | ||
| failedTxCount += 1; | ||
| const popupFile = isFirefox ? 'popup.html' : 'popup-init.html'; | ||
| function setClientOpenOptions(tab) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const popup = tab ? `${POPUP_LAUNCH_FILE}?tab=${tab}` : POPUP_LAUNCH_FILE; | ||
| const sidepanelPath = tab ? `${SIDEPANEL_FILE}?tab=${tab}` : SIDEPANEL_FILE; | ||
|
|
||
| try { | ||
| if (isManifestV3) { | ||
| browser.action.setPopup({ popup: `${popupFile}?tab=activity` }); | ||
| browser.action.setPopup({ popup }); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set the next popup action |
||
| browser.sidePanel?.setOptions?.({ path: sidepanelPath }); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set sidepanel option on next open |
||
| } else { | ||
| browser.browserAction.setPopup({ popup: `${popupFile}?tab=activity` }); | ||
| browser.browserAction.setPopup({ popup }); | ||
| } | ||
| } catch (e) { | ||
| console.error('Error setting failed tx badge popup:', e); | ||
| console.error('Error setting extension action URLs:', e); | ||
| } | ||
| } | ||
|
|
||
| function onTransactionFailed() { | ||
| if (isClientOpenStatus()) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return; | ||
| } | ||
|
|
||
| failedTxCount += 1; | ||
| setClientOpenOptions('activity'); | ||
| updateBadge(); | ||
| } | ||
|
|
||
| function clearFailedTxBadge() { | ||
| if (!failedTxCount) { | ||
| return; | ||
| } | ||
|
|
||
| failedTxCount = 0; | ||
| const popupFile = isFirefox ? 'popup.html' : 'popup-init.html'; | ||
| try { | ||
| if (isManifestV3) { | ||
| browser.action.setPopup({ popup: popupFile }); | ||
| } else { | ||
| browser.browserAction.setPopup({ popup: popupFile }); | ||
| } | ||
| } catch (e) { | ||
| console.error('Error clearing failed tx badge popup:', e); | ||
| } | ||
| setClientOpenOptions(); | ||
| updateBadge(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring