@metamask-previews/profile-sync-controller 16.0.0-preview-510657d5 → 17.0.0-preview-d2bf8ff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +10 -3
  2. package/dist/controllers/user-storage/UserStorageController.cjs +3 -56
  3. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  4. package/dist/controllers/user-storage/UserStorageController.d.cts +2 -40
  5. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  6. package/dist/controllers/user-storage/UserStorageController.d.mts +2 -40
  7. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  8. package/dist/controllers/user-storage/UserStorageController.mjs +0 -53
  9. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  10. package/dist/controllers/user-storage/constants.cjs +0 -1
  11. package/dist/controllers/user-storage/constants.cjs.map +1 -1
  12. package/dist/controllers/user-storage/constants.d.cts +0 -1
  13. package/dist/controllers/user-storage/constants.d.cts.map +1 -1
  14. package/dist/controllers/user-storage/constants.d.mts +0 -1
  15. package/dist/controllers/user-storage/constants.d.mts.map +1 -1
  16. package/dist/controllers/user-storage/constants.mjs +0 -1
  17. package/dist/controllers/user-storage/constants.mjs.map +1 -1
  18. package/dist/shared/storage-schema.cjs +1 -3
  19. package/dist/shared/storage-schema.cjs.map +1 -1
  20. package/dist/shared/storage-schema.d.cts +0 -2
  21. package/dist/shared/storage-schema.d.cts.map +1 -1
  22. package/dist/shared/storage-schema.d.mts +0 -2
  23. package/dist/shared/storage-schema.d.mts.map +1 -1
  24. package/dist/shared/storage-schema.mjs +1 -3
  25. package/dist/shared/storage-schema.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/dist/controllers/user-storage/contact-syncing/constants.cjs +0 -12
  28. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +0 -1
  29. package/dist/controllers/user-storage/contact-syncing/constants.d.cts +0 -9
  30. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +0 -1
  31. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +0 -9
  32. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +0 -1
  33. package/dist/controllers/user-storage/contact-syncing/constants.mjs +0 -9
  34. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +0 -1
  35. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +0 -299
  36. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +0 -1
  37. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts +0 -44
  38. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +0 -1
  39. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +0 -44
  40. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +0 -1
  41. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs +0 -293
  42. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +0 -1
  43. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +0 -50
  44. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +0 -1
  45. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts +0 -8
  46. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +0 -1
  47. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +0 -8
  48. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +0 -1
  49. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs +0 -46
  50. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +0 -1
  51. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +0 -23
  52. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +0 -1
  53. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts +0 -9
  54. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +0 -1
  55. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +0 -9
  56. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +0 -1
  57. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs +0 -19
  58. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +0 -1
  59. package/dist/controllers/user-storage/contact-syncing/types.cjs +0 -3
  60. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +0 -1
  61. package/dist/controllers/user-storage/contact-syncing/types.d.cts +0 -35
  62. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +0 -1
  63. package/dist/controllers/user-storage/contact-syncing/types.d.mts +0 -35
  64. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +0 -1
  65. package/dist/controllers/user-storage/contact-syncing/types.mjs +0 -2
  66. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +0 -1
  67. package/dist/controllers/user-storage/contact-syncing/utils.cjs +0 -66
  68. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +0 -1
  69. package/dist/controllers/user-storage/contact-syncing/utils.d.cts +0 -37
  70. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +0 -1
  71. package/dist/controllers/user-storage/contact-syncing/utils.d.mts +0 -37
  72. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +0 -1
  73. package/dist/controllers/user-storage/contact-syncing/utils.mjs +0 -60
  74. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +0 -1
@@ -1,293 +0,0 @@
1
- import { canPerformContactSyncing } from "./sync-utils.mjs";
2
- import { mapAddressBookEntryToUserStorageEntry, mapUserStorageEntryToAddressBookEntry } from "./utils.mjs";
3
- import { isContactBridgedFromAccounts } from "./utils.mjs";
4
- import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
5
- /**
6
- * Creates a unique key for a contact based on chainId and address
7
- *
8
- * @param contact - The contact to create a key for
9
- * @returns A unique string key
10
- */
11
- function createContactKey(contact) {
12
- if (!contact.address) {
13
- throw new Error('Contact address is required to create storage key');
14
- }
15
- return `${contact.chainId}_${contact.address.toLowerCase()}`;
16
- }
17
- /**
18
- * Syncs contacts between local storage and user storage (remote).
19
- *
20
- * Handles the following syncing scenarios:
21
- * 1. First Sync: When local contacts exist but there are no remote contacts, uploads all local contacts.
22
- * 2. New Device Sync: Downloads remote contacts that don't exist locally (empty local address book).
23
- * 3. Simple Merge: Ensures both sides (local & remote) have all contacts.
24
- * 4. Contact Naming Conflicts: When same contact has different names, uses most recent by timestamp.
25
- * 5. Local Updates: When a contact was updated locally, syncs changes to remote if local is newer.
26
- * 6. Remote Updates: When a contact was updated remotely, applies changes locally if remote is newer.
27
- * 7. Local Deletions: Handled by real-time event handlers (deleteContactInRemoteStorage) to prevent false positives.
28
- * 8. Remote Deletions: When a contact was deleted remotely, applies deletion locally.
29
- * 9. Concurrent Updates: Resolves conflicts using timestamps to determine the winner.
30
- * 10. Restore After Delete: If a contact is modified after being deleted, restores it.
31
- * 11. ChainId Differences: Treats same address on different chains as separate contacts.
32
- *
33
- * @param config - Parameters used for syncing callbacks
34
- * @param options - Parameters used for syncing operations
35
- */
36
- export async function syncContactsWithUserStorage(config, options) {
37
- const { getMessenger, getUserStorageControllerInstance } = options;
38
- const { onContactSyncErroneousSituation, onContactUpdated, onContactDeleted, } = config;
39
- try {
40
- // Cannot perform sync, conditions not met
41
- if (!canPerformContactSyncing(options)) {
42
- return;
43
- }
44
- // Activate sync semaphore to prevent event loops
45
- await getUserStorageControllerInstance().setIsContactSyncingInProgress(true);
46
- // Get all local contacts from AddressBookController (exclude chain "*" contacts)
47
- const localVisibleContacts = getMessenger()
48
- .call('AddressBookController:list')
49
- .filter((contact) => !isContactBridgedFromAccounts(contact))
50
- .filter((contact) => contact.address && contact.chainId) || [];
51
- // Get remote contacts from user storage API
52
- const remoteContacts = await getRemoteContacts(options);
53
- // SCENARIO 1: First Sync - No remote contacts but local contacts exist
54
- if (!remoteContacts || remoteContacts.length === 0) {
55
- if (localVisibleContacts.length > 0) {
56
- await saveContactsToUserStorage(localVisibleContacts, options);
57
- }
58
- return;
59
- }
60
- // Filter remote contacts to exclude invalid ones
61
- const validRemoteContacts = remoteContacts.filter((contact) => contact.address && contact.chainId);
62
- // Prepare maps for efficient lookup
63
- const localContactsMap = new Map();
64
- const remoteContactsMap = new Map();
65
- localVisibleContacts.forEach((contact) => {
66
- const key = createContactKey(contact);
67
- localContactsMap.set(key, contact);
68
- });
69
- validRemoteContacts.forEach((contact) => {
70
- const key = createContactKey(contact);
71
- remoteContactsMap.set(key, contact);
72
- });
73
- // Lists to track contacts that need to be synced
74
- const contactsToAddOrUpdateLocally = [];
75
- const contactsToDeleteLocally = [];
76
- const contactsToUpdateRemotely = [];
77
- // SCENARIO 2 & 6: Process remote contacts - handle new device sync and remote updates
78
- for (const remoteContact of validRemoteContacts) {
79
- const key = createContactKey(remoteContact);
80
- const localContact = localContactsMap.get(key);
81
- // Handle remote contact based on its status and local existence
82
- if (remoteContact.deleted) {
83
- // SCENARIO 8: Remote deletion - should be applied locally if contact exists locally
84
- if (localContact) {
85
- contactsToDeleteLocally.push(remoteContact);
86
- }
87
- }
88
- else if (!localContact) {
89
- // SCENARIO 2: New contact from remote - import to local
90
- contactsToAddOrUpdateLocally.push(remoteContact);
91
- }
92
- else {
93
- // SCENARIO 4 & 6: Contact exists on both sides - check for conflicts
94
- const hasContentDifference = localContact.name !== remoteContact.name ||
95
- localContact.memo !== remoteContact.memo;
96
- if (hasContentDifference) {
97
- // Check timestamps to determine which version to keep
98
- const localTimestamp = localContact.lastUpdatedAt || 0;
99
- const remoteTimestamp = remoteContact.lastUpdatedAt || 0;
100
- if (localTimestamp >= remoteTimestamp) {
101
- // Local is newer (or same age) - use local version
102
- contactsToUpdateRemotely.push(localContact);
103
- }
104
- else {
105
- // Remote is newer - use remote version
106
- contactsToAddOrUpdateLocally.push(remoteContact);
107
- }
108
- }
109
- // Else: content is identical, no action needed
110
- }
111
- }
112
- // SCENARIO 3 & 5: Process local contacts not in remote
113
- for (const localContact of localVisibleContacts) {
114
- const key = createContactKey(localContact);
115
- const remoteContact = remoteContactsMap.get(key);
116
- if (!remoteContact) {
117
- // New local contact - add to remote
118
- contactsToUpdateRemotely.push(localContact);
119
- }
120
- }
121
- // Apply local deletions
122
- for (const contact of contactsToDeleteLocally) {
123
- try {
124
- getMessenger().call('AddressBookController:delete', contact.chainId, contact.address);
125
- if (onContactDeleted) {
126
- onContactDeleted();
127
- }
128
- }
129
- catch (error) {
130
- console.error('Error deleting contact:', error);
131
- }
132
- }
133
- // Apply local additions/updates
134
- for (const contact of contactsToAddOrUpdateLocally) {
135
- if (!contact.deleted) {
136
- try {
137
- getMessenger().call('AddressBookController:set', contact.address, contact.name || '', contact.chainId, contact.memo || '', contact.addressType);
138
- if (onContactUpdated) {
139
- onContactUpdated();
140
- }
141
- }
142
- catch (error) {
143
- console.error('Error updating contact:', error);
144
- }
145
- }
146
- }
147
- // Apply changes to remote storage
148
- if (contactsToUpdateRemotely.length > 0) {
149
- // Update existing remote contacts with new contacts
150
- const updatedRemoteContacts = [...validRemoteContacts];
151
- for (const localContact of contactsToUpdateRemotely) {
152
- const key = createContactKey(localContact);
153
- const existingIndex = updatedRemoteContacts.findIndex((c) => createContactKey(c) === key);
154
- const now = Date.now();
155
- const updatedEntry = {
156
- ...localContact,
157
- lastUpdatedAt: now,
158
- deleted: false, // Ensure it's not deleted
159
- };
160
- if (existingIndex !== -1) {
161
- // Update existing contact
162
- updatedRemoteContacts[existingIndex] = updatedEntry;
163
- }
164
- else {
165
- // Add new contact
166
- updatedRemoteContacts.push(updatedEntry);
167
- }
168
- }
169
- // Save updated contacts to remote storage
170
- await saveContactsToUserStorage(updatedRemoteContacts, options);
171
- }
172
- }
173
- catch (error) {
174
- if (onContactSyncErroneousSituation) {
175
- onContactSyncErroneousSituation('Error synchronizing contacts', {
176
- error,
177
- });
178
- // Re-throw the error to be handled by the caller
179
- throw error;
180
- }
181
- }
182
- finally {
183
- await getUserStorageControllerInstance().setIsContactSyncingInProgress(false);
184
- }
185
- }
186
- /**
187
- * Retrieves remote contacts from user storage API
188
- *
189
- * @param options - Parameters used for retrieving remote contacts
190
- * @returns Array of contacts from remote storage, or null if none found
191
- */
192
- async function getRemoteContacts(options) {
193
- const { getUserStorageControllerInstance } = options;
194
- try {
195
- const remoteContactsJsonArray = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.addressBook);
196
- if (!remoteContactsJsonArray || remoteContactsJsonArray.length === 0) {
197
- return null;
198
- }
199
- // Parse each JSON entry and convert from UserStorageContactEntry to AddressBookEntry
200
- const remoteStorageEntries = remoteContactsJsonArray.map((contactJson) => {
201
- const entry = JSON.parse(contactJson);
202
- return mapUserStorageEntryToAddressBookEntry(entry);
203
- });
204
- return remoteStorageEntries;
205
- }
206
- catch {
207
- return null;
208
- }
209
- }
210
- /**
211
- * Saves local contacts to user storage
212
- *
213
- * @param contacts - The contacts to save to user storage
214
- * @param options - Parameters used for saving contacts
215
- */
216
- async function saveContactsToUserStorage(contacts, options) {
217
- const { getUserStorageControllerInstance } = options;
218
- if (!contacts || contacts.length === 0) {
219
- return;
220
- }
221
- // Convert each AddressBookEntry to UserStorageContactEntry format and create key-value pairs
222
- const storageEntries = contacts.map((contact) => {
223
- const key = createContactKey(contact);
224
- const storageEntry = mapAddressBookEntryToUserStorageEntry(contact);
225
- return [key, JSON.stringify(storageEntry)];
226
- });
227
- await getUserStorageControllerInstance().performBatchSetStorage(USER_STORAGE_FEATURE_NAMES.addressBook, storageEntries);
228
- }
229
- /**
230
- * Updates a single contact in remote storage without performing a full sync
231
- * This is used when a contact is updated locally to efficiently push changes to remote
232
- *
233
- * @param contact - The contact that was updated locally
234
- * @param options - Parameters used for syncing operations
235
- */
236
- export async function updateContactInRemoteStorage(contact, options) {
237
- if (!canPerformContactSyncing(options) ||
238
- !contact.address ||
239
- !contact.chainId) {
240
- return;
241
- }
242
- const { getUserStorageControllerInstance } = options;
243
- // Create an updated entry with timestamp
244
- const updatedEntry = {
245
- ...contact,
246
- lastUpdatedAt: contact.lastUpdatedAt || Date.now(),
247
- deleted: false, // Explicitly set to false in case this was previously deleted
248
- };
249
- const key = createContactKey(contact);
250
- const storageEntry = mapAddressBookEntryToUserStorageEntry(updatedEntry);
251
- // Save individual contact to remote storage
252
- await getUserStorageControllerInstance().performSetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`, JSON.stringify(storageEntry));
253
- }
254
- /**
255
- * Marks a single contact as deleted in remote storage without performing a full sync
256
- * This is used when a contact is deleted locally to efficiently push the deletion to remote
257
- *
258
- * @param contact - The contact that was deleted locally (contains at least address and chainId)
259
- * @param options - Parameters used for syncing operations
260
- */
261
- export async function deleteContactInRemoteStorage(contact, options) {
262
- if (!canPerformContactSyncing(options) ||
263
- !contact.address ||
264
- !contact.chainId) {
265
- return;
266
- }
267
- const { getUserStorageControllerInstance } = options;
268
- const key = createContactKey(contact);
269
- try {
270
- // Try to get the existing contact first
271
- const existingContactJson = await getUserStorageControllerInstance().performGetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`);
272
- if (existingContactJson) {
273
- // Mark the existing contact as deleted
274
- const existingStorageEntry = JSON.parse(existingContactJson);
275
- const existingContact = mapUserStorageEntryToAddressBookEntry(existingStorageEntry);
276
- const now = Date.now();
277
- const deletedContact = {
278
- ...existingContact,
279
- deleted: true,
280
- deletedAt: now,
281
- lastUpdatedAt: now,
282
- };
283
- const deletedStorageEntry = mapAddressBookEntryToUserStorageEntry(deletedContact);
284
- // Save the deleted contact back to storage
285
- await getUserStorageControllerInstance().performSetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`, JSON.stringify(deletedStorageEntry));
286
- }
287
- }
288
- catch {
289
- // If contact doesn't exist in remote storage, no need to mark as deleted
290
- console.warn('Contact not found in remote storage for deletion:', key);
291
- }
292
- }
293
- //# sourceMappingURL=controller-integration.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller-integration.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/controller-integration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD,OAAO,EACL,qCAAqC,EACrC,qCAAqC,EAEtC,oBAAgB;AACjB,OAAO,EAAE,4BAA4B,EAAE,oBAAgB;AACvD,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAW5E;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAyB;IACjD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IACD,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;AAC/D,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAyC,EACzC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IACnE,MAAM,EACJ,+BAA+B,EAC/B,gBAAgB,EAChB,gBAAgB,GACjB,GAAG,MAAM,CAAC;IAEX,IAAI;QACF,0CAA0C;QAC1C,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE;YACtC,OAAO;SACR;QAED,iDAAiD;QACjD,MAAM,gCAAgC,EAAE,CAAC,6BAA6B,CACpE,IAAI,CACL,CAAC;QAEF,iFAAiF;QACjF,MAAM,oBAAoB,GACxB,YAAY,EAAE;aACX,IAAI,CAAC,4BAA4B,CAAC;aAClC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;aAC3D,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEnE,4CAA4C;QAC5C,MAAM,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Content":["import type { AddressBookEntry } from '@metamask/address-book-controller';\n\nimport { canPerformContactSyncing } from './sync-utils';\nimport type { ContactSyncingOptions } from './types';\nimport type { UserStorageContactEntry } from './types';\nimport {\n mapAddressBookEntryToUserStorageEntry,\n mapUserStorageEntryToAddressBookEntry,\n type SyncAddressBookEntry,\n} from './utils';\nimport { isContactBridgedFromAccounts } from './utils';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\nexport type SyncContactsWithUserStorageConfig = {\n onContactSyncErroneousSituation?: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n onContactUpdated?: () => void;\n onContactDeleted?: () => void;\n};\n\n/**\n * Creates a unique key for a contact based on chainId and address\n *\n * @param contact - The contact to create a key for\n * @returns A unique string key\n */\nfunction createContactKey(contact: AddressBookEntry): string {\n if (!contact.address) {\n throw new Error('Contact address is required to create storage key');\n }\n return `${contact.chainId}_${contact.address.toLowerCase()}`;\n}\n\n/**\n * Syncs contacts between local storage and user storage (remote).\n *\n * Handles the following syncing scenarios:\n * 1. First Sync: When local contacts exist but there are no remote contacts, uploads all local contacts.\n * 2. New Device Sync: Downloads remote contacts that don't exist locally (empty local address book).\n * 3. Simple Merge: Ensures both sides (local & remote) have all contacts.\n * 4. Contact Naming Conflicts: When same contact has different names, uses most recent by timestamp.\n * 5. Local Updates: When a contact was updated locally, syncs changes to remote if local is newer.\n * 6. Remote Updates: When a contact was updated remotely, applies changes locally if remote is newer.\n * 7. Local Deletions: Handled by real-time event handlers (deleteContactInRemoteStorage) to prevent false positives.\n * 8. Remote Deletions: When a contact was deleted remotely, applies deletion locally.\n * 9. Concurrent Updates: Resolves conflicts using timestamps to determine the winner.\n * 10. Restore After Delete: If a contact is modified after being deleted, restores it.\n * 11. ChainId Differences: Treats same address on different chains as separate contacts.\n *\n * @param config - Parameters used for syncing callbacks\n * @param options - Parameters used for syncing operations\n */\nexport async function syncContactsWithUserStorage(\n config: SyncContactsWithUserStorageConfig,\n options: ContactSyncingOptions,\n): Promise<void> {\n const { getMessenger, getUserStorageControllerInstance } = options;\n const {\n onContactSyncErroneousSituation,\n onContactUpdated,\n onContactDeleted,\n } = config;\n\n try {\n // Cannot perform sync, conditions not met\n if (!canPerformContactSyncing(options)) {\n return;\n }\n\n // Activate sync semaphore to prevent event loops\n await getUserStorageControllerInstance().setIsContactSyncingInProgress(\n true,\n );\n\n // Get all local contacts from AddressBookController (exclude chain \"*\" contacts)\n const localVisibleContacts =\n getMessenger()\n .call('AddressBookController:list')\n .filter((contact) => !isContactBridgedFromAccounts(contact))\n .filter((contact) => contact.address && contact.chainId) || [];\n\n // Get remote contacts from user storage API\n const remoteContacts = await getRemoteContacts(options);\n\n // SCENARIO 1: First Sync - No remote contacts but local contacts exist\n if (!remoteContacts || remoteContacts.length === 0) {\n if (localVisibleContacts.length > 0) {\n await saveContactsToUserStorage(localVisibleContacts, options);\n }\n return;\n }\n\n // Filter remote contacts to exclude invalid ones\n const validRemoteContacts = remoteContacts.filter(\n (contact) => contact.address && contact.chainId,\n );\n\n // Prepare maps for efficient lookup\n const localContactsMap = new Map<string, AddressBookEntry>();\n const remoteContactsMap = new Map<string, SyncAddressBookEntry>();\n\n localVisibleContacts.forEach((contact) => {\n const key = createContactKey(contact);\n localContactsMap.set(key, contact);\n });\n\n validRemoteContacts.forEach((contact) => {\n const key = createContactKey(contact);\n remoteContactsMap.set(key, contact);\n });\n\n // Lists to track contacts that need to be synced\n const contactsToAddOrUpdateLocally: SyncAddressBookEntry[] = [];\n const contactsToDeleteLocally: SyncAddressBookEntry[] = [];\n const contactsToUpdateRemotely: AddressBookEntry[] = [];\n\n // SCENARIO 2 & 6: Process remote contacts - handle new device sync and remote updates\n for (const remoteContact of validRemoteContacts) {\n const key = createContactKey(remoteContact);\n const localContact = localContactsMap.get(key);\n\n // Handle remote contact based on its status and local existence\n if (remoteContact.deleted) {\n // SCENARIO 8: Remote deletion - should be applied locally if contact exists locally\n if (localContact) {\n contactsToDeleteLocally.push(remoteContact);\n }\n } else if (!localContact) {\n // SCENARIO 2: New contact from remote - import to local\n contactsToAddOrUpdateLocally.push(remoteContact);\n } else {\n // SCENARIO 4 & 6: Contact exists on both sides - check for conflicts\n const hasContentDifference =\n localContact.name !== remoteContact.name ||\n localContact.memo !== remoteContact.memo;\n\n if (hasContentDifference) {\n // Check timestamps to determine which version to keep\n const localTimestamp = localContact.lastUpdatedAt || 0;\n const remoteTimestamp = remoteContact.lastUpdatedAt || 0;\n\n if (localTimestamp >= remoteTimestamp) {\n // Local is newer (or same age) - use local version\n contactsToUpdateRemotely.push(localContact);\n } else {\n // Remote is newer - use remote version\n contactsToAddOrUpdateLocally.push(remoteContact);\n }\n }\n\n // Else: content is identical, no action needed\n }\n }\n\n // SCENARIO 3 & 5: Process local contacts not in remote\n for (const localContact of localVisibleContacts) {\n const key = createContactKey(localContact);\n const remoteContact = remoteContactsMap.get(key);\n\n if (!remoteContact) {\n // New local contact - add to remote\n contactsToUpdateRemotely.push(localContact);\n }\n }\n\n // Apply local deletions\n for (const contact of contactsToDeleteLocally) {\n try {\n getMessenger().call(\n 'AddressBookController:delete',\n contact.chainId,\n contact.address,\n );\n\n if (onContactDeleted) {\n onContactDeleted();\n }\n } catch (error) {\n console.error('Error deleting contact:', error);\n }\n }\n\n // Apply local additions/updates\n for (const contact of contactsToAddOrUpdateLocally) {\n if (!contact.deleted) {\n try {\n getMessenger().call(\n 'AddressBookController:set',\n contact.address,\n contact.name || '',\n contact.chainId,\n contact.memo || '',\n contact.addressType,\n );\n\n if (onContactUpdated) {\n onContactUpdated();\n }\n } catch (error) {\n console.error('Error updating contact:', error);\n }\n }\n }\n\n // Apply changes to remote storage\n if (contactsToUpdateRemotely.length > 0) {\n // Update existing remote contacts with new contacts\n const updatedRemoteContacts = [...validRemoteContacts];\n\n for (const localContact of contactsToUpdateRemotely) {\n const key = createContactKey(localContact);\n const existingIndex = updatedRemoteContacts.findIndex(\n (c) => createContactKey(c) === key,\n );\n\n const now = Date.now();\n const updatedEntry = {\n ...localContact,\n lastUpdatedAt: now,\n deleted: false, // Ensure it's not deleted\n } as SyncAddressBookEntry;\n\n if (existingIndex !== -1) {\n // Update existing contact\n updatedRemoteContacts[existingIndex] = updatedEntry;\n } else {\n // Add new contact\n updatedRemoteContacts.push(updatedEntry);\n }\n }\n\n // Save updated contacts to remote storage\n await saveContactsToUserStorage(updatedRemoteContacts, options);\n }\n } catch (error) {\n if (onContactSyncErroneousSituation) {\n onContactSyncErroneousSituation('Error synchronizing contacts', {\n error,\n });\n\n // Re-throw the error to be handled by the caller\n throw error;\n }\n } finally {\n await getUserStorageControllerInstance().setIsContactSyncingInProgress(\n false,\n );\n }\n}\n\n/**\n * Retrieves remote contacts from user storage API\n *\n * @param options - Parameters used for retrieving remote contacts\n * @returns Array of contacts from remote storage, or null if none found\n */\nasync function getRemoteContacts(\n options: ContactSyncingOptions,\n): Promise<SyncAddressBookEntry[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n try {\n const remoteContactsJsonArray =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.addressBook,\n );\n\n if (!remoteContactsJsonArray || remoteContactsJsonArray.length === 0) {\n return null;\n }\n\n // Parse each JSON entry and convert from UserStorageContactEntry to AddressBookEntry\n const remoteStorageEntries = remoteContactsJsonArray.map((contactJson) => {\n const entry = JSON.parse(contactJson) as UserStorageContactEntry;\n return mapUserStorageEntryToAddressBookEntry(entry);\n });\n\n return remoteStorageEntries;\n } catch {\n return null;\n }\n}\n\n/**\n * Saves local contacts to user storage\n *\n * @param contacts - The contacts to save to user storage\n * @param options - Parameters used for saving contacts\n */\nasync function saveContactsToUserStorage(\n contacts: AddressBookEntry[],\n options: ContactSyncingOptions,\n): Promise<void> {\n const { getUserStorageControllerInstance } = options;\n\n if (!contacts || contacts.length === 0) {\n return;\n }\n\n // Convert each AddressBookEntry to UserStorageContactEntry format and create key-value pairs\n const storageEntries: [string, string][] = contacts.map((contact) => {\n const key = createContactKey(contact);\n const storageEntry = mapAddressBookEntryToUserStorageEntry(contact);\n return [key, JSON.stringify(storageEntry)];\n });\n\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.addressBook,\n storageEntries,\n );\n}\n\n/**\n * Updates a single contact in remote storage without performing a full sync\n * This is used when a contact is updated locally to efficiently push changes to remote\n *\n * @param contact - The contact that was updated locally\n * @param options - Parameters used for syncing operations\n */\nexport async function updateContactInRemoteStorage(\n contact: AddressBookEntry,\n options: ContactSyncingOptions,\n): Promise<void> {\n if (\n !canPerformContactSyncing(options) ||\n !contact.address ||\n !contact.chainId\n ) {\n return;\n }\n\n const { getUserStorageControllerInstance } = options;\n\n // Create an updated entry with timestamp\n const updatedEntry = {\n ...contact,\n lastUpdatedAt: contact.lastUpdatedAt || Date.now(),\n deleted: false, // Explicitly set to false in case this was previously deleted\n } as SyncAddressBookEntry;\n\n const key = createContactKey(contact);\n const storageEntry = mapAddressBookEntryToUserStorageEntry(updatedEntry);\n\n // Save individual contact to remote storage\n await getUserStorageControllerInstance().performSetStorage(\n `${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`,\n JSON.stringify(storageEntry),\n );\n}\n\n/**\n * Marks a single contact as deleted in remote storage without performing a full sync\n * This is used when a contact is deleted locally to efficiently push the deletion to remote\n *\n * @param contact - The contact that was deleted locally (contains at least address and chainId)\n * @param options - Parameters used for syncing operations\n */\nexport async function deleteContactInRemoteStorage(\n contact: AddressBookEntry,\n options: ContactSyncingOptions,\n): Promise<void> {\n if (\n !canPerformContactSyncing(options) ||\n !contact.address ||\n !contact.chainId\n ) {\n return;\n }\n\n const { getUserStorageControllerInstance } = options;\n const key = createContactKey(contact);\n\n try {\n // Try to get the existing contact first\n const existingContactJson =\n await getUserStorageControllerInstance().performGetStorage(\n `${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`,\n );\n\n if (existingContactJson) {\n // Mark the existing contact as deleted\n const existingStorageEntry = JSON.parse(\n existingContactJson,\n ) as UserStorageContactEntry;\n const existingContact =\n mapUserStorageEntryToAddressBookEntry(existingStorageEntry);\n\n const now = Date.now();\n const deletedContact = {\n ...existingContact,\n deleted: true,\n deletedAt: now,\n lastUpdatedAt: now,\n } as SyncAddressBookEntry;\n\n const deletedStorageEntry =\n mapAddressBookEntryToUserStorageEntry(deletedContact);\n\n // Save the deleted contact back to storage\n await getUserStorageControllerInstance().performSetStorage(\n `${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`,\n JSON.stringify(deletedStorageEntry),\n );\n }\n } catch {\n // If contact doesn't exist in remote storage, no need to mark as deleted\n console.warn('Contact not found in remote storage for deletion:', key);\n }\n}\n"]}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupContactSyncingSubscriptions = void 0;
4
- const controller_integration_1 = require("./controller-integration.cjs");
5
- const sync_utils_1 = require("./sync-utils.cjs");
6
- const utils_1 = require("./utils.cjs");
7
- /**
8
- * Initialize and setup events to listen to for contact syncing
9
- *
10
- * @param options - parameters used for initializing and enabling contact syncing
11
- */
12
- function setupContactSyncingSubscriptions(options) {
13
- const { getMessenger } = options;
14
- // Listen for contact updates and immediately sync the individual contact
15
- getMessenger().subscribe('AddressBookController:contactUpdated', (contactEntry) => {
16
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
17
- (async () => {
18
- if (!(0, sync_utils_1.canPerformContactSyncing)(options) ||
19
- (0, utils_1.isContactBridgedFromAccounts)(contactEntry)) {
20
- return;
21
- }
22
- try {
23
- // Use the targeted method to update just this contact
24
- await (0, controller_integration_1.updateContactInRemoteStorage)(contactEntry, options);
25
- }
26
- catch (error) {
27
- console.error('Error updating contact in remote storage:', error);
28
- }
29
- })();
30
- });
31
- // Listen for contact deletions and immediately sync the individual deletion
32
- getMessenger().subscribe('AddressBookController:contactDeleted', (contactEntry) => {
33
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
34
- (async () => {
35
- if (!(0, sync_utils_1.canPerformContactSyncing)(options) ||
36
- (0, utils_1.isContactBridgedFromAccounts)(contactEntry)) {
37
- return;
38
- }
39
- try {
40
- // Use the targeted method to delete just this contact
41
- await (0, controller_integration_1.deleteContactInRemoteStorage)(contactEntry, options);
42
- }
43
- catch (error) {
44
- console.error('Error deleting contact from remote storage:', error);
45
- }
46
- })();
47
- });
48
- }
49
- exports.setupContactSyncingSubscriptions = setupContactSyncingSubscriptions;
50
- //# sourceMappingURL=setup-subscriptions.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-subscriptions.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/setup-subscriptions.ts"],"names":[],"mappings":";;;AAEA,yEAGkC;AAClC,iDAAwD;AAExD,uCAAuD;AAEvD;;;;GAIG;AACH,SAAgB,gCAAgC,CAC9C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,yEAAyE;IACzE,YAAY,EAAE,CAAC,SAAS,CACtB,sCAAsC,EACtC,CAAC,YAA8B,EAAE,EAAE;QACjC,mEAAmE;QACnE,CAAC,KAAK,IAAI,EAAE;YACV,IACE,CAAC,IAAA,qCAAwB,EAAC,OAAO,CAAC;gBAClC,IAAA,oCAA4B,EAAC,YAAY,CAAC,EAC1C;gBACA,OAAO;aACR;YAED,IAAI;gBACF,sDAAsD;gBACtD,MAAM,IAAA,qDAA4B,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;aACnE;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,CACF,CAAC;IAEF,4EAA4E;IAC5E,YAAY,EAAE,CAAC,SAAS,CACtB,sCAAsC,EACtC,CAAC,YAA8B,EAAE,EAAE;QACjC,mEAAmE;QACnE,CAAC,KAAK,IAAI,EAAE;YACV,IACE,CAAC,IAAA,qCAAwB,EAAC,OAAO,CAAC;gBAClC,IAAA,oCAA4B,EAAC,YAAY,CAAC,EAC1C;gBACA,OAAO;aACR;YAED,IAAI;gBACF,sDAAsD;gBACtD,MAAM,IAAA,qDAA4B,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;aACrE;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,CACF,CAAC;AACJ,CAAC;AAlDD,4EAkDC","sourcesContent":["import type { AddressBookEntry } from '@metamask/address-book-controller';\n\nimport {\n updateContactInRemoteStorage,\n deleteContactInRemoteStorage,\n} from './controller-integration';\nimport { canPerformContactSyncing } from './sync-utils';\nimport type { ContactSyncingOptions } from './types';\nimport { isContactBridgedFromAccounts } from './utils';\n\n/**\n * Initialize and setup events to listen to for contact syncing\n *\n * @param options - parameters used for initializing and enabling contact syncing\n */\nexport function setupContactSyncingSubscriptions(\n options: ContactSyncingOptions,\n): void {\n const { getMessenger } = options;\n\n // Listen for contact updates and immediately sync the individual contact\n getMessenger().subscribe(\n 'AddressBookController:contactUpdated',\n (contactEntry: AddressBookEntry) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n if (\n !canPerformContactSyncing(options) ||\n isContactBridgedFromAccounts(contactEntry)\n ) {\n return;\n }\n\n try {\n // Use the targeted method to update just this contact\n await updateContactInRemoteStorage(contactEntry, options);\n } catch (error) {\n console.error('Error updating contact in remote storage:', error);\n }\n })();\n },\n );\n\n // Listen for contact deletions and immediately sync the individual deletion\n getMessenger().subscribe(\n 'AddressBookController:contactDeleted',\n (contactEntry: AddressBookEntry) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n if (\n !canPerformContactSyncing(options) ||\n isContactBridgedFromAccounts(contactEntry)\n ) {\n return;\n }\n\n try {\n // Use the targeted method to delete just this contact\n await deleteContactInRemoteStorage(contactEntry, options);\n } catch (error) {\n console.error('Error deleting contact from remote storage:', error);\n }\n })();\n },\n );\n}\n"]}
@@ -1,8 +0,0 @@
1
- import type { ContactSyncingOptions } from "./types.cjs";
2
- /**
3
- * Initialize and setup events to listen to for contact syncing
4
- *
5
- * @param options - parameters used for initializing and enabling contact syncing
6
- */
7
- export declare function setupContactSyncingSubscriptions(options: ContactSyncingOptions): void;
8
- //# sourceMappingURL=setup-subscriptions.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-subscriptions.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAgB;AAGrD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAgDN"}
@@ -1,8 +0,0 @@
1
- import type { ContactSyncingOptions } from "./types.mjs";
2
- /**
3
- * Initialize and setup events to listen to for contact syncing
4
- *
5
- * @param options - parameters used for initializing and enabling contact syncing
6
- */
7
- export declare function setupContactSyncingSubscriptions(options: ContactSyncingOptions): void;
8
- //# sourceMappingURL=setup-subscriptions.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-subscriptions.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAgB;AAGrD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAgDN"}
@@ -1,46 +0,0 @@
1
- import { updateContactInRemoteStorage, deleteContactInRemoteStorage } from "./controller-integration.mjs";
2
- import { canPerformContactSyncing } from "./sync-utils.mjs";
3
- import { isContactBridgedFromAccounts } from "./utils.mjs";
4
- /**
5
- * Initialize and setup events to listen to for contact syncing
6
- *
7
- * @param options - parameters used for initializing and enabling contact syncing
8
- */
9
- export function setupContactSyncingSubscriptions(options) {
10
- const { getMessenger } = options;
11
- // Listen for contact updates and immediately sync the individual contact
12
- getMessenger().subscribe('AddressBookController:contactUpdated', (contactEntry) => {
13
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
14
- (async () => {
15
- if (!canPerformContactSyncing(options) ||
16
- isContactBridgedFromAccounts(contactEntry)) {
17
- return;
18
- }
19
- try {
20
- // Use the targeted method to update just this contact
21
- await updateContactInRemoteStorage(contactEntry, options);
22
- }
23
- catch (error) {
24
- console.error('Error updating contact in remote storage:', error);
25
- }
26
- })();
27
- });
28
- // Listen for contact deletions and immediately sync the individual deletion
29
- getMessenger().subscribe('AddressBookController:contactDeleted', (contactEntry) => {
30
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
31
- (async () => {
32
- if (!canPerformContactSyncing(options) ||
33
- isContactBridgedFromAccounts(contactEntry)) {
34
- return;
35
- }
36
- try {
37
- // Use the targeted method to delete just this contact
38
- await deleteContactInRemoteStorage(contactEntry, options);
39
- }
40
- catch (error) {
41
- console.error('Error deleting contact from remote storage:', error);
42
- }
43
- })();
44
- });
45
- }
46
- //# sourceMappingURL=setup-subscriptions.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC7B,qCAAiC;AAClC,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAExD,OAAO,EAAE,4BAA4B,EAAE,oBAAgB;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,yEAAyE;IACzE,YAAY,EAAE,CAAC,SAAS,CACtB,sCAAsC,EACtC,CAAC,YAA8B,EAAE,EAAE;QACjC,mEAAmE;QACnE,CAAC,KAAK,IAAI,EAAE;YACV,IACE,CAAC,wBAAwB,CAAC,OAAO,CAAC;gBAClC,4BAA4B,CAAC,YAAY,CAAC,EAC1C;gBACA,OAAO;aACR;YAED,IAAI;gBACF,sDAAsD;gBACtD,MAAM,4BAA4B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;aACnE;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,CACF,CAAC;IAEF,4EAA4E;IAC5E,YAAY,EAAE,CAAC,SAAS,CACtB,sCAAsC,EACtC,CAAC,YAA8B,EAAE,EAAE;QACjC,mEAAmE;QACnE,CAAC,KAAK,IAAI,EAAE;YACV,IACE,CAAC,wBAAwB,CAAC,OAAO,CAAC;gBAClC,4BAA4B,CAAC,YAAY,CAAC,EAC1C;gBACA,OAAO;aACR;YAED,IAAI;gBACF,sDAAsD;gBACtD,MAAM,4BAA4B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;aACrE;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AddressBookEntry } from '@metamask/address-book-controller';\n\nimport {\n updateContactInRemoteStorage,\n deleteContactInRemoteStorage,\n} from './controller-integration';\nimport { canPerformContactSyncing } from './sync-utils';\nimport type { ContactSyncingOptions } from './types';\nimport { isContactBridgedFromAccounts } from './utils';\n\n/**\n * Initialize and setup events to listen to for contact syncing\n *\n * @param options - parameters used for initializing and enabling contact syncing\n */\nexport function setupContactSyncingSubscriptions(\n options: ContactSyncingOptions,\n): void {\n const { getMessenger } = options;\n\n // Listen for contact updates and immediately sync the individual contact\n getMessenger().subscribe(\n 'AddressBookController:contactUpdated',\n (contactEntry: AddressBookEntry) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n if (\n !canPerformContactSyncing(options) ||\n isContactBridgedFromAccounts(contactEntry)\n ) {\n return;\n }\n\n try {\n // Use the targeted method to update just this contact\n await updateContactInRemoteStorage(contactEntry, options);\n } catch (error) {\n console.error('Error updating contact in remote storage:', error);\n }\n })();\n },\n );\n\n // Listen for contact deletions and immediately sync the individual deletion\n getMessenger().subscribe(\n 'AddressBookController:contactDeleted',\n (contactEntry: AddressBookEntry) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n (async () => {\n if (\n !canPerformContactSyncing(options) ||\n isContactBridgedFromAccounts(contactEntry)\n ) {\n return;\n }\n\n try {\n // Use the targeted method to delete just this contact\n await deleteContactInRemoteStorage(contactEntry, options);\n } catch (error) {\n console.error('Error deleting contact from remote storage:', error);\n }\n })();\n },\n );\n}\n"]}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canPerformContactSyncing = void 0;
4
- /**
5
- * Check if we can perform contact syncing
6
- *
7
- * @param options - parameters used for checking if we can perform contact syncing
8
- * @returns whether we can perform contact syncing
9
- */
10
- function canPerformContactSyncing(options) {
11
- const { getMessenger, getUserStorageControllerInstance } = options;
12
- const { isBackupAndSyncEnabled, isContactSyncingEnabled, isContactSyncingInProgress, } = getUserStorageControllerInstance().state;
13
- const isAuthEnabled = getMessenger().call('AuthenticationController:isSignedIn');
14
- if (!isBackupAndSyncEnabled ||
15
- !isContactSyncingEnabled ||
16
- isContactSyncingInProgress ||
17
- !isAuthEnabled) {
18
- return false;
19
- }
20
- return true;
21
- }
22
- exports.canPerformContactSyncing = canPerformContactSyncing;
23
- //# sourceMappingURL=sync-utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/sync-utils.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC7C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,sBAAsB;QACvB,CAAC,uBAAuB;QACxB,0BAA0B;QAC1B,CAAC,aAAa,EACd;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAxBD,4DAwBC","sourcesContent":["import type { ContactSyncingOptions } from './types';\n\n/**\n * Check if we can perform contact syncing\n *\n * @param options - parameters used for checking if we can perform contact syncing\n * @returns whether we can perform contact syncing\n */\nexport function canPerformContactSyncing(\n options: ContactSyncingOptions,\n): boolean {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const {\n isBackupAndSyncEnabled,\n isContactSyncingEnabled,\n isContactSyncingInProgress,\n } = getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isBackupAndSyncEnabled ||\n !isContactSyncingEnabled ||\n isContactSyncingInProgress ||\n !isAuthEnabled\n ) {\n return false;\n }\n\n return true;\n}\n"]}
@@ -1,9 +0,0 @@
1
- import type { ContactSyncingOptions } from "./types.cjs";
2
- /**
3
- * Check if we can perform contact syncing
4
- *
5
- * @param options - parameters used for checking if we can perform contact syncing
6
- * @returns whether we can perform contact syncing
7
- */
8
- export declare function canPerformContactSyncing(options: ContactSyncingOptions): boolean;
9
- //# sourceMappingURL=sync-utils.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAgB;AAErD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAsBT"}
@@ -1,9 +0,0 @@
1
- import type { ContactSyncingOptions } from "./types.mjs";
2
- /**
3
- * Check if we can perform contact syncing
4
- *
5
- * @param options - parameters used for checking if we can perform contact syncing
6
- * @returns whether we can perform contact syncing
7
- */
8
- export declare function canPerformContactSyncing(options: ContactSyncingOptions): boolean;
9
- //# sourceMappingURL=sync-utils.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAgB;AAErD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAsBT"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Check if we can perform contact syncing
3
- *
4
- * @param options - parameters used for checking if we can perform contact syncing
5
- * @returns whether we can perform contact syncing
6
- */
7
- export function canPerformContactSyncing(options) {
8
- const { getMessenger, getUserStorageControllerInstance } = options;
9
- const { isBackupAndSyncEnabled, isContactSyncingEnabled, isContactSyncingInProgress, } = getUserStorageControllerInstance().state;
10
- const isAuthEnabled = getMessenger().call('AuthenticationController:isSignedIn');
11
- if (!isBackupAndSyncEnabled ||
12
- !isContactSyncingEnabled ||
13
- isContactSyncingInProgress ||
14
- !isAuthEnabled) {
15
- return false;
16
- }
17
- return true;
18
- }
19
- //# sourceMappingURL=sync-utils.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/sync-utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC7C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,sBAAsB;QACvB,CAAC,uBAAuB;QACxB,0BAA0B;QAC1B,CAAC,aAAa,EACd;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { ContactSyncingOptions } from './types';\n\n/**\n * Check if we can perform contact syncing\n *\n * @param options - parameters used for checking if we can perform contact syncing\n * @returns whether we can perform contact syncing\n */\nexport function canPerformContactSyncing(\n options: ContactSyncingOptions,\n): boolean {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const {\n isBackupAndSyncEnabled,\n isContactSyncingEnabled,\n isContactSyncingInProgress,\n } = getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isBackupAndSyncEnabled ||\n !isContactSyncingEnabled ||\n isContactSyncingInProgress ||\n !isAuthEnabled\n ) {\n return false;\n }\n\n return true;\n}\n"]}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\n\nexport type UserStorageContactEntry = {\n /**\n * The Version 'v' of the User Storage.\n * NOTE - will allow us to support upgrade/downgrades in the future\n */\n [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;\n /** the address 'a' of the contact */\n a: string;\n /** the name 'n' of the contact */\n n: string;\n /** the chainId 'c' of the contact */\n c: Hex;\n /** the memo 'm' of the contact (optional) */\n m?: string;\n /** the addressType 't' of the contact (optional) */\n t?: string;\n /** the lastUpdatedAt timestamp 'lu' of the contact */\n lu?: number;\n /** the deleted flag 'd' of the contact (optional) */\n d?: boolean;\n /** the deletedAt timestamp 'dt' of the contact (optional) */\n dt?: number;\n};\n\n/**\n * Options for contact syncing operations\n */\nexport type ContactSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n};\n"]}
@@ -1,35 +0,0 @@
1
- import type { Hex } from "@metamask/utils";
2
- import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.cjs";
3
- import type { UserStorageControllerMessenger } from "../UserStorageController.cjs";
4
- import type UserStorageController from "../UserStorageController.cjs";
5
- export type UserStorageContactEntry = {
6
- /**
7
- * The Version 'v' of the User Storage.
8
- * NOTE - will allow us to support upgrade/downgrades in the future
9
- */
10
- [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
11
- /** the address 'a' of the contact */
12
- a: string;
13
- /** the name 'n' of the contact */
14
- n: string;
15
- /** the chainId 'c' of the contact */
16
- c: Hex;
17
- /** the memo 'm' of the contact (optional) */
18
- m?: string;
19
- /** the addressType 't' of the contact (optional) */
20
- t?: string;
21
- /** the lastUpdatedAt timestamp 'lu' of the contact */
22
- lu?: number;
23
- /** the deleted flag 'd' of the contact (optional) */
24
- d?: boolean;
25
- /** the deletedAt timestamp 'dt' of the contact (optional) */
26
- dt?: number;
27
- };
28
- /**
29
- * Options for contact syncing operations
30
- */
31
- export type ContactSyncingOptions = {
32
- getUserStorageControllerInstance: () => UserStorageController;
33
- getMessenger: () => UserStorageControllerMessenger;
34
- };
35
- //# sourceMappingURL=types.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AACrB,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAElE,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,CAAC,wBAAwB,CAAC,EAAE,OAAO,oBAAoB,CAAC;IACxD,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,GAAG,CAAC;IACP,6CAA6C;IAC7C,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ,6DAA6D;IAC7D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;CACpD,CAAC"}