@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,35 +0,0 @@
1
- import type { Hex } from "@metamask/utils";
2
- import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
3
- import type { UserStorageControllerMessenger } from "../UserStorageController.mjs";
4
- import type UserStorageController from "../UserStorageController.mjs";
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.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","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,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isContactBridgedFromAccounts = exports.mapUserStorageEntryToAddressBookEntry = exports.mapAddressBookEntryToUserStorageEntry = void 0;
4
- const controller_utils_1 = require("@metamask/controller-utils");
5
- const constants_1 = require("./constants.cjs");
6
- /**
7
- * Map an address book entry to a user storage address book entry
8
- * Always sets a current timestamp for entries going to remote storage
9
- *
10
- * @param addressBookEntry - An address book entry
11
- * @returns A user storage address book entry
12
- */
13
- const mapAddressBookEntryToUserStorageEntry = (addressBookEntry) => {
14
- const { address, name, chainId, memo, addressType, lastUpdatedAt, deleted, deletedAt, } = addressBookEntry;
15
- const now = Date.now();
16
- return {
17
- [constants_1.USER_STORAGE_VERSION_KEY]: constants_1.USER_STORAGE_VERSION,
18
- a: (0, controller_utils_1.toChecksumHexAddress)(address),
19
- n: name,
20
- c: chainId,
21
- ...(memo ? { m: memo } : {}),
22
- ...(addressType ? { t: addressType } : {}),
23
- lu: lastUpdatedAt || now,
24
- ...(deleted ? { d: deleted } : {}),
25
- ...(deletedAt ? { dt: deletedAt } : {}),
26
- };
27
- };
28
- exports.mapAddressBookEntryToUserStorageEntry = mapAddressBookEntryToUserStorageEntry;
29
- /**
30
- * Map a user storage address book entry to an address book entry
31
- * Preserves sync metadata from remote storage while keeping the
32
- * entry compatible with AddressBookController
33
- *
34
- * @param userStorageEntry - A user storage address book entry
35
- * @returns An address book entry with sync metadata for internal use
36
- */
37
- const mapUserStorageEntryToAddressBookEntry = (userStorageEntry) => {
38
- const addressBookEntry = {
39
- address: (0, controller_utils_1.toChecksumHexAddress)(userStorageEntry.a),
40
- name: userStorageEntry.n,
41
- chainId: userStorageEntry.c,
42
- memo: userStorageEntry.m || '',
43
- isEns: false,
44
- ...(userStorageEntry.t
45
- ? { addressType: userStorageEntry.t }
46
- : {}),
47
- // Include remote metadata for sync operation only (not stored in AddressBookController)
48
- ...(userStorageEntry.d ? { deleted: userStorageEntry.d } : {}),
49
- ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),
50
- ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),
51
- };
52
- return addressBookEntry;
53
- };
54
- exports.mapUserStorageEntryToAddressBookEntry = mapUserStorageEntryToAddressBookEntry;
55
- /**
56
- * Check if a contact entry is bridged from accounts
57
- * Contacts with chainId "*" are global accounts bridged from the accounts system
58
- *
59
- * @param contactEntry - The contact entry to check
60
- * @returns True if the contact is bridged from accounts
61
- */
62
- const isContactBridgedFromAccounts = (contactEntry) => {
63
- return String(contactEntry.chainId) === '*';
64
- };
65
- exports.isContactBridgedFromAccounts = isContactBridgedFromAccounts;
66
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":";;;AAIA,iEAAkE;AAElE,+CAA6E;AAa7E;;;;;;GAMG;AACI,MAAM,qCAAqC,GAAG,CACnD,gBAAkC,EACT,EAAE;IAC3B,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,WAAW,EACX,aAAa,EACb,OAAO,EACP,SAAS,GACV,GAAG,gBAAwC,CAAC;IAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,gCAAoB;QAChD,CAAC,EAAE,IAAA,uCAAoB,EAAC,OAAO,CAAC;QAChC,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,OAAO;QACV,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,EAAE,EAAE,aAAa,IAAI,GAAG;QACxB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,qCAAqC,yCA2BhD;AAEF;;;;;;;GAOG;AACI,MAAM,qCAAqC,GAAG,CACnD,gBAAyC,EACnB,EAAE;IACxB,MAAM,gBAAgB,GAAyB;QAC7C,OAAO,EAAE,IAAA,uCAAoB,EAAC,gBAAgB,CAAC,CAAC,CAAC;QACjD,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC3B,IAAI,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE;QAC9B,KAAK,EAAE,KAAK;QACZ,GAAG,CAAC,gBAAgB,CAAC,CAAC;YACpB,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAgB,EAAE;YACpD,CAAC,CAAC,EAAE,CAAC;QACP,wFAAwF;QACxF,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAnBW,QAAA,qCAAqC,yCAmBhD;AAEF;;;;;;GAMG;AACI,MAAM,4BAA4B,GAAG,CAC1C,YAA8B,EACrB,EAAE;IACX,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;AAC9C,CAAC,CAAC;AAJW,QAAA,4BAA4B,gCAIvC","sourcesContent":["import type {\n AddressBookEntry,\n AddressType,\n} from '@metamask/address-book-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\n\nimport { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from './constants';\nimport type { UserStorageContactEntry } from './types';\n\n/**\n * Extends AddressBookEntry with sync metadata\n * This is only used internally during the sync process and is not stored in AddressBookController\n */\nexport type SyncAddressBookEntry = AddressBookEntry & {\n lastUpdatedAt?: number;\n deleted?: boolean;\n deletedAt?: number;\n};\n\n/**\n * Map an address book entry to a user storage address book entry\n * Always sets a current timestamp for entries going to remote storage\n *\n * @param addressBookEntry - An address book entry\n * @returns A user storage address book entry\n */\nexport const mapAddressBookEntryToUserStorageEntry = (\n addressBookEntry: AddressBookEntry,\n): UserStorageContactEntry => {\n const {\n address,\n name,\n chainId,\n memo,\n addressType,\n lastUpdatedAt,\n deleted,\n deletedAt,\n } = addressBookEntry as SyncAddressBookEntry;\n\n const now = Date.now();\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: toChecksumHexAddress(address),\n n: name,\n c: chainId,\n ...(memo ? { m: memo } : {}),\n ...(addressType ? { t: addressType } : {}),\n lu: lastUpdatedAt || now,\n ...(deleted ? { d: deleted } : {}),\n ...(deletedAt ? { dt: deletedAt } : {}),\n };\n};\n\n/**\n * Map a user storage address book entry to an address book entry\n * Preserves sync metadata from remote storage while keeping the\n * entry compatible with AddressBookController\n *\n * @param userStorageEntry - A user storage address book entry\n * @returns An address book entry with sync metadata for internal use\n */\nexport const mapUserStorageEntryToAddressBookEntry = (\n userStorageEntry: UserStorageContactEntry,\n): SyncAddressBookEntry => {\n const addressBookEntry: SyncAddressBookEntry = {\n address: toChecksumHexAddress(userStorageEntry.a),\n name: userStorageEntry.n,\n chainId: userStorageEntry.c,\n memo: userStorageEntry.m || '',\n isEns: false,\n ...(userStorageEntry.t\n ? { addressType: userStorageEntry.t as AddressType }\n : {}),\n // Include remote metadata for sync operation only (not stored in AddressBookController)\n ...(userStorageEntry.d ? { deleted: userStorageEntry.d } : {}),\n ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),\n ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),\n };\n\n return addressBookEntry;\n};\n\n/**\n * Check if a contact entry is bridged from accounts\n * Contacts with chainId \"*\" are global accounts bridged from the accounts system\n *\n * @param contactEntry - The contact entry to check\n * @returns True if the contact is bridged from accounts\n */\nexport const isContactBridgedFromAccounts = (\n contactEntry: AddressBookEntry,\n): boolean => {\n return String(contactEntry.chainId) === '*';\n};\n"]}
@@ -1,37 +0,0 @@
1
- import type { AddressBookEntry } from "@metamask/address-book-controller";
2
- import type { UserStorageContactEntry } from "./types.cjs";
3
- /**
4
- * Extends AddressBookEntry with sync metadata
5
- * This is only used internally during the sync process and is not stored in AddressBookController
6
- */
7
- export type SyncAddressBookEntry = AddressBookEntry & {
8
- lastUpdatedAt?: number;
9
- deleted?: boolean;
10
- deletedAt?: number;
11
- };
12
- /**
13
- * Map an address book entry to a user storage address book entry
14
- * Always sets a current timestamp for entries going to remote storage
15
- *
16
- * @param addressBookEntry - An address book entry
17
- * @returns A user storage address book entry
18
- */
19
- export declare const mapAddressBookEntryToUserStorageEntry: (addressBookEntry: AddressBookEntry) => UserStorageContactEntry;
20
- /**
21
- * Map a user storage address book entry to an address book entry
22
- * Preserves sync metadata from remote storage while keeping the
23
- * entry compatible with AddressBookController
24
- *
25
- * @param userStorageEntry - A user storage address book entry
26
- * @returns An address book entry with sync metadata for internal use
27
- */
28
- export declare const mapUserStorageEntryToAddressBookEntry: (userStorageEntry: UserStorageContactEntry) => SyncAddressBookEntry;
29
- /**
30
- * Check if a contact entry is bridged from accounts
31
- * Contacts with chainId "*" are global accounts bridged from the accounts system
32
- *
33
- * @param contactEntry - The contact entry to check
34
- * @returns True if the contact is bridged from accounts
35
- */
36
- export declare const isContactBridgedFromAccounts: (contactEntry: AddressBookEntry) => boolean;
37
- //# sourceMappingURL=utils.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,0CAA0C;AAI3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAgB;AAEvD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,gBAAgB,KACjC,uBAyBF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,uBAAuB,KACxC,oBAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,iBACzB,gBAAgB,KAC7B,OAEF,CAAC"}
@@ -1,37 +0,0 @@
1
- import type { AddressBookEntry } from "@metamask/address-book-controller";
2
- import type { UserStorageContactEntry } from "./types.mjs";
3
- /**
4
- * Extends AddressBookEntry with sync metadata
5
- * This is only used internally during the sync process and is not stored in AddressBookController
6
- */
7
- export type SyncAddressBookEntry = AddressBookEntry & {
8
- lastUpdatedAt?: number;
9
- deleted?: boolean;
10
- deletedAt?: number;
11
- };
12
- /**
13
- * Map an address book entry to a user storage address book entry
14
- * Always sets a current timestamp for entries going to remote storage
15
- *
16
- * @param addressBookEntry - An address book entry
17
- * @returns A user storage address book entry
18
- */
19
- export declare const mapAddressBookEntryToUserStorageEntry: (addressBookEntry: AddressBookEntry) => UserStorageContactEntry;
20
- /**
21
- * Map a user storage address book entry to an address book entry
22
- * Preserves sync metadata from remote storage while keeping the
23
- * entry compatible with AddressBookController
24
- *
25
- * @param userStorageEntry - A user storage address book entry
26
- * @returns An address book entry with sync metadata for internal use
27
- */
28
- export declare const mapUserStorageEntryToAddressBookEntry: (userStorageEntry: UserStorageContactEntry) => SyncAddressBookEntry;
29
- /**
30
- * Check if a contact entry is bridged from accounts
31
- * Contacts with chainId "*" are global accounts bridged from the accounts system
32
- *
33
- * @param contactEntry - The contact entry to check
34
- * @returns True if the contact is bridged from accounts
35
- */
36
- export declare const isContactBridgedFromAccounts: (contactEntry: AddressBookEntry) => boolean;
37
- //# sourceMappingURL=utils.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,0CAA0C;AAI3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAgB;AAEvD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,gBAAgB,KACjC,uBAyBF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,uBAAuB,KACxC,oBAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,iBACzB,gBAAgB,KAC7B,OAEF,CAAC"}
@@ -1,60 +0,0 @@
1
- import { toChecksumHexAddress } from "@metamask/controller-utils";
2
- import { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
3
- /**
4
- * Map an address book entry to a user storage address book entry
5
- * Always sets a current timestamp for entries going to remote storage
6
- *
7
- * @param addressBookEntry - An address book entry
8
- * @returns A user storage address book entry
9
- */
10
- export const mapAddressBookEntryToUserStorageEntry = (addressBookEntry) => {
11
- const { address, name, chainId, memo, addressType, lastUpdatedAt, deleted, deletedAt, } = addressBookEntry;
12
- const now = Date.now();
13
- return {
14
- [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,
15
- a: toChecksumHexAddress(address),
16
- n: name,
17
- c: chainId,
18
- ...(memo ? { m: memo } : {}),
19
- ...(addressType ? { t: addressType } : {}),
20
- lu: lastUpdatedAt || now,
21
- ...(deleted ? { d: deleted } : {}),
22
- ...(deletedAt ? { dt: deletedAt } : {}),
23
- };
24
- };
25
- /**
26
- * Map a user storage address book entry to an address book entry
27
- * Preserves sync metadata from remote storage while keeping the
28
- * entry compatible with AddressBookController
29
- *
30
- * @param userStorageEntry - A user storage address book entry
31
- * @returns An address book entry with sync metadata for internal use
32
- */
33
- export const mapUserStorageEntryToAddressBookEntry = (userStorageEntry) => {
34
- const addressBookEntry = {
35
- address: toChecksumHexAddress(userStorageEntry.a),
36
- name: userStorageEntry.n,
37
- chainId: userStorageEntry.c,
38
- memo: userStorageEntry.m || '',
39
- isEns: false,
40
- ...(userStorageEntry.t
41
- ? { addressType: userStorageEntry.t }
42
- : {}),
43
- // Include remote metadata for sync operation only (not stored in AddressBookController)
44
- ...(userStorageEntry.d ? { deleted: userStorageEntry.d } : {}),
45
- ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),
46
- ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),
47
- };
48
- return addressBookEntry;
49
- };
50
- /**
51
- * Check if a contact entry is bridged from accounts
52
- * Contacts with chainId "*" are global accounts bridged from the accounts system
53
- *
54
- * @param contactEntry - The contact entry to check
55
- * @returns True if the contact is bridged from accounts
56
- */
57
- export const isContactBridgedFromAccounts = (contactEntry) => {
58
- return String(contactEntry.chainId) === '*';
59
- };
60
- //# sourceMappingURL=utils.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,mCAAmC;AAElE,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,wBAAoB;AAa7E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,gBAAkC,EACT,EAAE;IAC3B,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,WAAW,EACX,aAAa,EACb,OAAO,EACP,SAAS,GACV,GAAG,gBAAwC,CAAC;IAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,oBAAoB;QAChD,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC;QAChC,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,OAAO;QACV,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,EAAE,EAAE,aAAa,IAAI,GAAG;QACxB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,gBAAyC,EACnB,EAAE;IACxB,MAAM,gBAAgB,GAAyB;QAC7C,OAAO,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACjD,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC3B,IAAI,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE;QAC9B,KAAK,EAAE,KAAK;QACZ,GAAG,CAAC,gBAAgB,CAAC,CAAC;YACpB,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAgB,EAAE;YACpD,CAAC,CAAC,EAAE,CAAC;QACP,wFAAwF;QACxF,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,YAA8B,EACrB,EAAE;IACX,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import type {\n AddressBookEntry,\n AddressType,\n} from '@metamask/address-book-controller';\nimport { toChecksumHexAddress } from '@metamask/controller-utils';\n\nimport { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from './constants';\nimport type { UserStorageContactEntry } from './types';\n\n/**\n * Extends AddressBookEntry with sync metadata\n * This is only used internally during the sync process and is not stored in AddressBookController\n */\nexport type SyncAddressBookEntry = AddressBookEntry & {\n lastUpdatedAt?: number;\n deleted?: boolean;\n deletedAt?: number;\n};\n\n/**\n * Map an address book entry to a user storage address book entry\n * Always sets a current timestamp for entries going to remote storage\n *\n * @param addressBookEntry - An address book entry\n * @returns A user storage address book entry\n */\nexport const mapAddressBookEntryToUserStorageEntry = (\n addressBookEntry: AddressBookEntry,\n): UserStorageContactEntry => {\n const {\n address,\n name,\n chainId,\n memo,\n addressType,\n lastUpdatedAt,\n deleted,\n deletedAt,\n } = addressBookEntry as SyncAddressBookEntry;\n\n const now = Date.now();\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: toChecksumHexAddress(address),\n n: name,\n c: chainId,\n ...(memo ? { m: memo } : {}),\n ...(addressType ? { t: addressType } : {}),\n lu: lastUpdatedAt || now,\n ...(deleted ? { d: deleted } : {}),\n ...(deletedAt ? { dt: deletedAt } : {}),\n };\n};\n\n/**\n * Map a user storage address book entry to an address book entry\n * Preserves sync metadata from remote storage while keeping the\n * entry compatible with AddressBookController\n *\n * @param userStorageEntry - A user storage address book entry\n * @returns An address book entry with sync metadata for internal use\n */\nexport const mapUserStorageEntryToAddressBookEntry = (\n userStorageEntry: UserStorageContactEntry,\n): SyncAddressBookEntry => {\n const addressBookEntry: SyncAddressBookEntry = {\n address: toChecksumHexAddress(userStorageEntry.a),\n name: userStorageEntry.n,\n chainId: userStorageEntry.c,\n memo: userStorageEntry.m || '',\n isEns: false,\n ...(userStorageEntry.t\n ? { addressType: userStorageEntry.t as AddressType }\n : {}),\n // Include remote metadata for sync operation only (not stored in AddressBookController)\n ...(userStorageEntry.d ? { deleted: userStorageEntry.d } : {}),\n ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),\n ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),\n };\n\n return addressBookEntry;\n};\n\n/**\n * Check if a contact entry is bridged from accounts\n * Contacts with chainId \"*\" are global accounts bridged from the accounts system\n *\n * @param contactEntry - The contact entry to check\n * @returns True if the contact is bridged from accounts\n */\nexport const isContactBridgedFromAccounts = (\n contactEntry: AddressBookEntry,\n): boolean => {\n return String(contactEntry.chainId) === '*';\n};\n"]}