-
-
Notifications
You must be signed in to change notification settings - Fork 277
Feat/notify beyond first srp #8108
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
base: main
Are you sure you want to change the base?
Changes from all commits
ab09250
bb924b4
1af525b
a19bc42
8c41aa0
4d1d3a7
8a788a9
a28b3bb
d1e3349
b9a5b40
f4aaf01
e40e497
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 |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import { | |
| isValidHexAddress, | ||
| toChecksumHexAddress, | ||
| } from '@metamask/controller-utils'; | ||
| import { KeyringTypes } from '@metamask/keyring-controller'; | ||
| import type { | ||
| KeyringControllerStateChangeEvent, | ||
| KeyringControllerGetStateAction, | ||
|
|
@@ -45,6 +44,7 @@ import type { OrderInput } from './types/perps'; | |
| import type { | ||
| NotificationServicesPushControllerEnablePushNotificationsAction, | ||
| NotificationServicesPushControllerDisablePushNotificationsAction, | ||
| NotificationServicesPushControllerDeletePushNotificationLinksAction, | ||
| NotificationServicesPushControllerSubscribeToNotificationsAction, | ||
| NotificationServicesPushControllerStateChangeEvent, | ||
| NotificationServicesPushControllerOnNewNotificationEvent, | ||
|
|
@@ -234,6 +234,7 @@ type AllowedActions = | |
| // Push Notifications Controller Requests | ||
| | NotificationServicesPushControllerEnablePushNotificationsAction | ||
| | NotificationServicesPushControllerDisablePushNotificationsAction | ||
| | NotificationServicesPushControllerDeletePushNotificationLinksAction | ||
| | NotificationServicesPushControllerSubscribeToNotificationsAction; | ||
|
|
||
| // Events | ||
|
|
@@ -358,6 +359,16 @@ export default class NotificationServicesController extends BaseController< | |
| // Do nothing, failing silently. | ||
| } | ||
| }, | ||
| deletePushNotificationLinks: async (addresses: string[]): Promise<void> => { | ||
| try { | ||
| await this.messenger.call( | ||
| 'NotificationServicesPushController:deletePushNotificationLinks', | ||
| addresses, | ||
| ); | ||
| } catch { | ||
| // Do nothing, failing silently. | ||
| } | ||
| }, | ||
| subscribe: (): void => { | ||
| this.messenger.subscribe( | ||
| 'NotificationServicesPushController:onNewNotifications', | ||
|
|
@@ -399,11 +410,24 @@ export default class NotificationServicesController extends BaseController< | |
|
|
||
| getNotificationAccounts: (): string[] | null => { | ||
| const { keyrings } = this.messenger.call('KeyringController:getState'); | ||
| const firstHDKeyring = keyrings.find( | ||
| (keyring) => keyring.type === KeyringTypes.hd.toString(), | ||
| ); | ||
| const keyringAccounts = firstHDKeyring?.accounts ?? null; | ||
| return keyringAccounts; | ||
| const keyringAccounts = [ | ||
| ...new Set( | ||
| keyrings | ||
| .flatMap((keyring) => keyring.accounts) | ||
| .map((address) => { | ||
| try { | ||
| return toChecksumHexAddress(address); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }) | ||
| .filter( | ||
| (address): address is string => | ||
| address !== null && isValidHexAddress(address), | ||
| ), | ||
| ), | ||
| ]; | ||
| return keyringAccounts.length > 0 ? keyringAccounts : null; | ||
oilnam marked this conversation as resolved.
Show resolved
Hide resolved
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. Account discovery includes all keyring types, not just SRPsMedium Severity
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. Agreed & updated Changelog / PR description |
||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -950,6 +974,8 @@ export default class NotificationServicesController extends BaseController< | |
| accounts.map((address) => ({ address, enabled: false })), | ||
| this.#env, | ||
| ); | ||
|
|
||
| await this.#pushNotifications.deletePushNotificationLinks(accounts); | ||
| } catch { | ||
| throw new Error('Failed to delete OnChain triggers'); | ||
| } finally { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.