@metamask-previews/profile-sync-controller 17.1.0-preview-ca9d0265 → 17.1.0-preview-e149187d

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 +0 -5
  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 -281
  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 -275
  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 -64
  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 -36
  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 -36
  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 -58
  74. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +0 -1
@@ -1,275 +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 && contact.name?.trim()) || [];
51
- // Get remote contacts from user storage API
52
- const remoteContacts = await getRemoteContacts(options);
53
- // Filter remote contacts to exclude invalid ones (or empty array if no remote contacts)
54
- const validRemoteContacts = remoteContacts?.filter((contact) => contact.address && contact.chainId && contact.name?.trim()) || [];
55
- // Prepare maps for efficient lookup
56
- const localContactsMap = new Map();
57
- const remoteContactsMap = new Map();
58
- localVisibleContacts.forEach((contact) => {
59
- const key = createContactKey(contact);
60
- localContactsMap.set(key, contact);
61
- });
62
- validRemoteContacts.forEach((contact) => {
63
- const key = createContactKey(contact);
64
- remoteContactsMap.set(key, contact);
65
- });
66
- // Lists to track contacts that need to be synced
67
- const contactsToAddOrUpdateLocally = [];
68
- const contactsToDeleteLocally = [];
69
- const contactsToUpdateRemotely = [];
70
- // SCENARIO 2 & 6: Process remote contacts - handle new device sync and remote updates
71
- for (const remoteContact of validRemoteContacts) {
72
- const key = createContactKey(remoteContact);
73
- const localContact = localContactsMap.get(key);
74
- // Handle remote contact based on its status and local existence
75
- if (remoteContact.deletedAt) {
76
- // SCENARIO 8: Remote deletion - should be applied locally if contact exists locally
77
- if (localContact) {
78
- contactsToDeleteLocally.push(remoteContact);
79
- }
80
- }
81
- else if (!localContact) {
82
- // SCENARIO 2: New contact from remote - import to local
83
- contactsToAddOrUpdateLocally.push(remoteContact);
84
- }
85
- else {
86
- // SCENARIO 4 & 6: Contact exists on both sides - check for conflicts
87
- const hasContentDifference = localContact.name !== remoteContact.name ||
88
- localContact.memo !== remoteContact.memo;
89
- if (hasContentDifference) {
90
- // Check timestamps to determine which version to keep
91
- const localTimestamp = localContact.lastUpdatedAt || 0;
92
- const remoteTimestamp = remoteContact.lastUpdatedAt || 0;
93
- if (localTimestamp >= remoteTimestamp) {
94
- // Local is newer (or same age) - use local version
95
- contactsToUpdateRemotely.push(localContact);
96
- }
97
- else {
98
- // Remote is newer - use remote version
99
- contactsToAddOrUpdateLocally.push(remoteContact);
100
- }
101
- }
102
- // Else: content is identical, no action needed
103
- }
104
- }
105
- // SCENARIO 1, 3 & 5: Process local contacts not in remote - handles first sync and new local contacts
106
- for (const localContact of localVisibleContacts) {
107
- const key = createContactKey(localContact);
108
- const remoteContact = remoteContactsMap.get(key);
109
- if (!remoteContact) {
110
- // New local contact or first sync - add to remote
111
- contactsToUpdateRemotely.push(localContact);
112
- }
113
- }
114
- // Apply local deletions
115
- for (const contact of contactsToDeleteLocally) {
116
- try {
117
- getMessenger().call('AddressBookController:delete', contact.chainId, contact.address);
118
- if (onContactDeleted) {
119
- onContactDeleted();
120
- }
121
- }
122
- catch (error) {
123
- console.error('Error deleting contact:', error);
124
- }
125
- }
126
- // Apply local additions/updates
127
- for (const contact of contactsToAddOrUpdateLocally) {
128
- if (!contact.deletedAt) {
129
- try {
130
- getMessenger().call('AddressBookController:set', contact.address, contact.name || '', contact.chainId, contact.memo || '', contact.addressType);
131
- if (onContactUpdated) {
132
- onContactUpdated();
133
- }
134
- }
135
- catch (error) {
136
- console.error('Error updating contact:', error);
137
- }
138
- }
139
- }
140
- // Apply changes to remote storage
141
- if (contactsToUpdateRemotely.length > 0) {
142
- const updatedRemoteContacts = {};
143
- for (const localContact of contactsToUpdateRemotely) {
144
- const key = createContactKey(localContact);
145
- updatedRemoteContacts[key] = {
146
- ...remoteContactsMap.get(key),
147
- ...localContact,
148
- lastUpdatedAt: Date.now(), // mark as updated
149
- };
150
- }
151
- // Save updated contacts to remote storage
152
- await saveContactsToUserStorage(Object.values(updatedRemoteContacts), options);
153
- }
154
- }
155
- catch (error) {
156
- if (onContactSyncErroneousSituation) {
157
- onContactSyncErroneousSituation('Error synchronizing contacts', {
158
- error,
159
- });
160
- // Re-throw the error to be handled by the caller
161
- throw error;
162
- }
163
- }
164
- finally {
165
- await getUserStorageControllerInstance().setIsContactSyncingInProgress(false);
166
- }
167
- }
168
- /**
169
- * Retrieves remote contacts from user storage API
170
- *
171
- * @param options - Parameters used for retrieving remote contacts
172
- * @returns Array of contacts from remote storage, or null if none found
173
- */
174
- async function getRemoteContacts(options) {
175
- const { getUserStorageControllerInstance } = options;
176
- try {
177
- const remoteContactsJsonArray = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.addressBook);
178
- if (!remoteContactsJsonArray || remoteContactsJsonArray.length === 0) {
179
- return null;
180
- }
181
- // Parse each JSON entry and convert from UserStorageContactEntry to AddressBookEntry
182
- const remoteStorageEntries = remoteContactsJsonArray.map((contactJson) => {
183
- const entry = JSON.parse(contactJson);
184
- return mapUserStorageEntryToAddressBookEntry(entry);
185
- });
186
- return remoteStorageEntries;
187
- }
188
- catch {
189
- return null;
190
- }
191
- }
192
- /**
193
- * Saves local contacts to user storage
194
- *
195
- * @param contacts - The contacts to save to user storage
196
- * @param options - Parameters used for saving contacts
197
- */
198
- async function saveContactsToUserStorage(contacts, options) {
199
- const { getUserStorageControllerInstance } = options;
200
- if (!contacts || contacts.length === 0) {
201
- return;
202
- }
203
- // Convert each AddressBookEntry to UserStorageContactEntry format and create key-value pairs
204
- const storageEntries = contacts.map((contact) => {
205
- const key = createContactKey(contact);
206
- const storageEntry = mapAddressBookEntryToUserStorageEntry(contact);
207
- return [key, JSON.stringify(storageEntry)];
208
- });
209
- await getUserStorageControllerInstance().performBatchSetStorage(USER_STORAGE_FEATURE_NAMES.addressBook, storageEntries);
210
- }
211
- /**
212
- * Updates a single contact in remote storage without performing a full sync
213
- * This is used when a contact is updated locally to efficiently push changes to remote
214
- *
215
- * @param contact - The contact that was updated locally
216
- * @param options - Parameters used for syncing operations
217
- */
218
- export async function updateContactInRemoteStorage(contact, options) {
219
- if (!canPerformContactSyncing(options) ||
220
- !contact.address ||
221
- !contact.chainId ||
222
- !contact.name?.trim()) {
223
- return;
224
- }
225
- const { getUserStorageControllerInstance } = options;
226
- // Create an updated entry with timestamp
227
- const updatedEntry = {
228
- ...contact,
229
- lastUpdatedAt: contact.lastUpdatedAt || Date.now(),
230
- };
231
- const key = createContactKey(contact);
232
- const storageEntry = mapAddressBookEntryToUserStorageEntry(updatedEntry);
233
- // Save individual contact to remote storage
234
- await getUserStorageControllerInstance().performSetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`, JSON.stringify(storageEntry));
235
- }
236
- /**
237
- * Marks a single contact as deleted in remote storage without performing a full sync
238
- * This is used when a contact is deleted locally to efficiently push the deletion to remote
239
- *
240
- * @param contact - The contact that was deleted locally (contains at least address and chainId)
241
- * @param options - Parameters used for syncing operations
242
- */
243
- export async function deleteContactInRemoteStorage(contact, options) {
244
- if (!canPerformContactSyncing(options) ||
245
- !contact.address ||
246
- !contact.chainId ||
247
- !contact.name?.trim()) {
248
- return;
249
- }
250
- const { getUserStorageControllerInstance } = options;
251
- const key = createContactKey(contact);
252
- try {
253
- // Try to get the existing contact first
254
- const existingContactJson = await getUserStorageControllerInstance().performGetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`);
255
- if (existingContactJson) {
256
- // Mark the existing contact as deleted
257
- const existingStorageEntry = JSON.parse(existingContactJson);
258
- const existingContact = mapUserStorageEntryToAddressBookEntry(existingStorageEntry);
259
- const now = Date.now();
260
- const deletedContact = {
261
- ...existingContact,
262
- deletedAt: now,
263
- lastUpdatedAt: now,
264
- };
265
- const deletedStorageEntry = mapAddressBookEntryToUserStorageEntry(deletedContact);
266
- // Save the deleted contact back to storage
267
- await getUserStorageControllerInstance().performSetStorage(`${USER_STORAGE_FEATURE_NAMES.addressBook}.${key}`, JSON.stringify(deletedStorageEntry));
268
- }
269
- }
270
- catch {
271
- // If contact doesn't exist in remote storage, no need to mark as deleted
272
- console.warn('Contact not found in remote storage for deletion:', key);
273
- }
274
- }
275
- //# 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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CAAC,oBAAoB,CAAC,CAAC;YAE9D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,cAAc,GAAG;gBACrB,GAAG,eAAe;gBAClB,SAAS,EAAE,GAAG;gBACd,aAAa,EAAE,GAAG;aACK,CAAC;YAE1B,MAAM,mBAAmB,GACvB,qCAAqC,CAAC,cAAc,CAAC,CAAC;YAExD,2CAA2C;YAC3C,MAAM,gCAAgC,EAAE,CAAC,iBAAiB,CACxD,GAAG,0BAA0B,CAAC,WAAW,IAAI,GAAG,EAAE,EAClD,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CACpC,CAAC;SACH;KACF;IAAC,MAAM;QACN,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,mDAAmD,EAAE,GAAG,CAAC,CAAC;KACxE;AACH,CAAC","sourcesContent":["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(\n (contact) =>\n contact.address && contact.chainId && contact.name?.trim(),\n ) || [];\n\n // Get remote contacts from user storage API\n const remoteContacts = await getRemoteContacts(options);\n\n // Filter remote contacts to exclude invalid ones (or empty array if no remote contacts)\n const validRemoteContacts =\n remoteContacts?.filter(\n (contact) => contact.address && contact.chainId && contact.name?.trim(),\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.deletedAt) {\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 1, 3 & 5: Process local contacts not in remote - handles first sync and new local contacts\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 or first sync - 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.deletedAt) {\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 const updatedRemoteContacts: Record<string, SyncAddressBookEntry> = {};\n for (const localContact of contactsToUpdateRemotely) {\n const key = createContactKey(localContact);\n updatedRemoteContacts[key] = {\n ...remoteContactsMap.get(key), // Start with an existing remote contact if it exists\n ...localContact, // override with local changes\n lastUpdatedAt: Date.now(), // mark as updated\n };\n }\n // Save updated contacts to remote storage\n await saveContactsToUserStorage(\n Object.values(updatedRemoteContacts),\n options,\n );\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 !contact.name?.trim()\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 } 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 !contact.name?.trim()\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 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 isEns flag 'e' of the contact (optional) */\n e?: boolean;\n /** the lastUpdatedAt timestamp 'lu' of the contact */\n lu?: number;\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 isEns flag 'e' of the contact (optional) */
22
- e?: boolean;
23
- /** the lastUpdatedAt timestamp 'lu' of the contact */
24
- lu?: number;
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,mDAAmD;IACnD,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,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"}