@metamask-previews/account-tree-controller 7.5.5-preview-421b16793 → 7.5.5-preview-e0f702919

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 (70) hide show
  1. package/CHANGELOG.md +0 -7
  2. package/dist/AccountTreeController-method-action-types.cjs.map +1 -1
  3. package/dist/AccountTreeController-method-action-types.d.cts +1 -28
  4. package/dist/AccountTreeController-method-action-types.d.cts.map +1 -1
  5. package/dist/AccountTreeController-method-action-types.d.mts +1 -28
  6. package/dist/AccountTreeController-method-action-types.d.mts.map +1 -1
  7. package/dist/AccountTreeController-method-action-types.mjs.map +1 -1
  8. package/dist/AccountTreeController.cjs +0 -36
  9. package/dist/AccountTreeController.cjs.map +1 -1
  10. package/dist/AccountTreeController.d.cts +0 -24
  11. package/dist/AccountTreeController.d.cts.map +1 -1
  12. package/dist/AccountTreeController.d.mts +0 -24
  13. package/dist/AccountTreeController.d.mts.map +1 -1
  14. package/dist/AccountTreeController.mjs +0 -36
  15. package/dist/AccountTreeController.mjs.map +1 -1
  16. package/dist/index.cjs +1 -5
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +1 -4
  19. package/dist/index.d.cts.map +1 -1
  20. package/dist/index.d.mts +1 -4
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +0 -2
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/types.cjs.map +1 -1
  25. package/dist/types.d.cts +3 -3
  26. package/dist/types.d.cts.map +1 -1
  27. package/dist/types.d.mts +3 -3
  28. package/dist/types.d.mts.map +1 -1
  29. package/dist/types.mjs.map +1 -1
  30. package/package.json +1 -3
  31. package/dist/state/export.cjs +0 -202
  32. package/dist/state/export.cjs.map +0 -1
  33. package/dist/state/export.d.cts +0 -40
  34. package/dist/state/export.d.cts.map +0 -1
  35. package/dist/state/export.d.mts +0 -40
  36. package/dist/state/export.d.mts.map +0 -1
  37. package/dist/state/export.mjs +0 -196
  38. package/dist/state/export.mjs.map +0 -1
  39. package/dist/state/id-map.cjs +0 -59
  40. package/dist/state/id-map.cjs.map +0 -1
  41. package/dist/state/id-map.d.cts +0 -41
  42. package/dist/state/id-map.d.cts.map +0 -1
  43. package/dist/state/id-map.d.mts +0 -41
  44. package/dist/state/id-map.d.mts.map +0 -1
  45. package/dist/state/id-map.mjs +0 -55
  46. package/dist/state/id-map.mjs.map +0 -1
  47. package/dist/state/import.cjs +0 -225
  48. package/dist/state/import.cjs.map +0 -1
  49. package/dist/state/import.d.cts +0 -27
  50. package/dist/state/import.d.cts.map +0 -1
  51. package/dist/state/import.d.mts +0 -27
  52. package/dist/state/import.d.mts.map +0 -1
  53. package/dist/state/import.mjs +0 -221
  54. package/dist/state/import.mjs.map +0 -1
  55. package/dist/state/payload.cjs +0 -67
  56. package/dist/state/payload.cjs.map +0 -1
  57. package/dist/state/payload.d.cts +0 -114
  58. package/dist/state/payload.d.cts.map +0 -1
  59. package/dist/state/payload.d.mts +0 -114
  60. package/dist/state/payload.d.mts.map +0 -1
  61. package/dist/state/payload.mjs +0 -61
  62. package/dist/state/payload.mjs.map +0 -1
  63. package/dist/state/snapshot.cjs +0 -110
  64. package/dist/state/snapshot.cjs.map +0 -1
  65. package/dist/state/snapshot.d.cts +0 -58
  66. package/dist/state/snapshot.d.cts.map +0 -1
  67. package/dist/state/snapshot.d.mts +0 -58
  68. package/dist/state/snapshot.d.mts.map +0 -1
  69. package/dist/state/snapshot.mjs +0 -106
  70. package/dist/state/snapshot.mjs.map +0 -1
@@ -1,58 +0,0 @@
1
- import { IdMap } from "./id-map.mjs";
2
- import type { AccountGroupPayloadId, AccountTreePayload, AccountTreeSnapshotEntry, AccountWalletPayloadId } from "./payload.mjs";
3
- /**
4
- * Immutable value object returned by {@link AccountTreeController.exportState}.
5
- *
6
- * Holds an ID map (local ↔ payload) populated during export so callers can
7
- * bridge between internal controller IDs and the stable cross-device IDs that
8
- * appear in the serialized payload. The map is absent for snapshots produced
9
- * by {@link AccountTreeSnapshot.deserialize} — `toLocalId` / `toPayloadId`
10
- * return `undefined` in that case.
11
- */
12
- export declare class AccountTreeSnapshot {
13
- #private;
14
- constructor(entries: AccountTreeSnapshotEntry[], idMap: IdMap | null);
15
- /**
16
- * Returns a new snapshot containing only the wallet entries for which
17
- * `predicate` returns `true`. The ID map is pruned to match.
18
- *
19
- * @param predicate - Function called with each wallet entry.
20
- * @returns A filtered snapshot.
21
- */
22
- filter(predicate: (entry: AccountTreeSnapshotEntry) => boolean): AccountTreeSnapshot;
23
- /**
24
- * Converts a payload ID (wallet or group) to the corresponding local
25
- * `AccountTreeController` ID.
26
- *
27
- * @param payloadId - Stable cross-device wallet or group payload ID.
28
- * @returns The local controller ID, or `undefined` if not found or no ID map is present.
29
- */
30
- toLocalId(payloadId: AccountWalletPayloadId | AccountGroupPayloadId): ReturnType<IdMap['getLocalId']>;
31
- /**
32
- * Converts a local `AccountTreeController` ID (wallet or group) to its
33
- * stable cross-device payload ID.
34
- *
35
- * @param localId - Local controller wallet or group ID.
36
- * @returns The payload ID, or `undefined` if not found or no ID map is present.
37
- */
38
- toPayloadId(localId: Parameters<IdMap['add']>[0]): ReturnType<IdMap['getPayloadId']>;
39
- /**
40
- * Serializes the snapshot to a versioned {@link AccountTreePayload}.
41
- *
42
- * @returns The versioned payload.
43
- */
44
- serialize(): AccountTreePayload;
45
- /**
46
- * Deserializes and validates a raw value as an `AccountTreePayload`,
47
- * running any necessary version migrations.
48
- *
49
- * The returned snapshot has no ID map — `toLocalId` / `toPayloadId` return
50
- * `undefined`. Use `AccountTreeController.exportState` when you need the map.
51
- *
52
- * @param raw - Unknown value to parse.
53
- * @returns A migrated snapshot.
54
- * @throws If `raw` is not a valid payload or its version exceeds the current version.
55
- */
56
- static deserialize(raw: unknown): AccountTreeSnapshot;
57
- }
58
- //# sourceMappingURL=snapshot.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.d.mts","sourceRoot":"","sources":["../../src/state/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,qBAAoB;AACpC,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACvB,sBAAqB;AAGtB;;;;;;;;GAQG;AACH,qBAAa,mBAAmB;;gBAKlB,OAAO,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAKpE;;;;;;OAMG;IACH,MAAM,CACJ,SAAS,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,OAAO,GACtD,mBAAmB;IAwBtB;;;;;;OAMG;IACH,SAAS,CACP,SAAS,EAAE,sBAAsB,GAAG,qBAAqB,GACxD,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAIlC;;;;;;OAMG;IACH,WAAW,CACT,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GACnC,UAAU,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAIpC;;;;OAIG;IACH,SAAS,IAAI,kBAAkB;IAO/B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB;CAItD"}
@@ -1,106 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _AccountTreeSnapshot_entries, _AccountTreeSnapshot_idMap;
13
- import { IdMap } from "./id-map.mjs";
14
- import { ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION, migrate } from "./payload.mjs";
15
- /**
16
- * Immutable value object returned by {@link AccountTreeController.exportState}.
17
- *
18
- * Holds an ID map (local ↔ payload) populated during export so callers can
19
- * bridge between internal controller IDs and the stable cross-device IDs that
20
- * appear in the serialized payload. The map is absent for snapshots produced
21
- * by {@link AccountTreeSnapshot.deserialize} — `toLocalId` / `toPayloadId`
22
- * return `undefined` in that case.
23
- */
24
- export class AccountTreeSnapshot {
25
- constructor(entries, idMap) {
26
- _AccountTreeSnapshot_entries.set(this, void 0);
27
- _AccountTreeSnapshot_idMap.set(this, void 0);
28
- __classPrivateFieldSet(this, _AccountTreeSnapshot_entries, entries, "f");
29
- __classPrivateFieldSet(this, _AccountTreeSnapshot_idMap, idMap, "f");
30
- }
31
- /**
32
- * Returns a new snapshot containing only the wallet entries for which
33
- * `predicate` returns `true`. The ID map is pruned to match.
34
- *
35
- * @param predicate - Function called with each wallet entry.
36
- * @returns A filtered snapshot.
37
- */
38
- filter(predicate) {
39
- const filteredEntries = __classPrivateFieldGet(this, _AccountTreeSnapshot_entries, "f").filter(predicate);
40
- if (!__classPrivateFieldGet(this, _AccountTreeSnapshot_idMap, "f")) {
41
- return new AccountTreeSnapshot(filteredEntries, null);
42
- }
43
- const pairs = [];
44
- for (const entry of filteredEntries) {
45
- const localWalletId = __classPrivateFieldGet(this, _AccountTreeSnapshot_idMap, "f").getLocalId(entry.id);
46
- if (localWalletId !== undefined) {
47
- pairs.push([localWalletId, entry.id]);
48
- }
49
- for (const group of entry.groups) {
50
- const localGroupId = __classPrivateFieldGet(this, _AccountTreeSnapshot_idMap, "f").getLocalId(group.id);
51
- if (localGroupId !== undefined) {
52
- pairs.push([localGroupId, group.id]);
53
- }
54
- }
55
- }
56
- return new AccountTreeSnapshot(filteredEntries, new IdMap(pairs));
57
- }
58
- /**
59
- * Converts a payload ID (wallet or group) to the corresponding local
60
- * `AccountTreeController` ID.
61
- *
62
- * @param payloadId - Stable cross-device wallet or group payload ID.
63
- * @returns The local controller ID, or `undefined` if not found or no ID map is present.
64
- */
65
- toLocalId(payloadId) {
66
- return __classPrivateFieldGet(this, _AccountTreeSnapshot_idMap, "f")?.getLocalId(payloadId);
67
- }
68
- /**
69
- * Converts a local `AccountTreeController` ID (wallet or group) to its
70
- * stable cross-device payload ID.
71
- *
72
- * @param localId - Local controller wallet or group ID.
73
- * @returns The payload ID, or `undefined` if not found or no ID map is present.
74
- */
75
- toPayloadId(localId) {
76
- return __classPrivateFieldGet(this, _AccountTreeSnapshot_idMap, "f")?.getPayloadId(localId);
77
- }
78
- /**
79
- * Serializes the snapshot to a versioned {@link AccountTreePayload}.
80
- *
81
- * @returns The versioned payload.
82
- */
83
- serialize() {
84
- return {
85
- version: ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION,
86
- wallets: __classPrivateFieldGet(this, _AccountTreeSnapshot_entries, "f"),
87
- };
88
- }
89
- /**
90
- * Deserializes and validates a raw value as an `AccountTreePayload`,
91
- * running any necessary version migrations.
92
- *
93
- * The returned snapshot has no ID map — `toLocalId` / `toPayloadId` return
94
- * `undefined`. Use `AccountTreeController.exportState` when you need the map.
95
- *
96
- * @param raw - Unknown value to parse.
97
- * @returns A migrated snapshot.
98
- * @throws If `raw` is not a valid payload or its version exceeds the current version.
99
- */
100
- static deserialize(raw) {
101
- const payload = migrate(raw);
102
- return new AccountTreeSnapshot(payload.wallets, null);
103
- }
104
- }
105
- _AccountTreeSnapshot_entries = new WeakMap(), _AccountTreeSnapshot_idMap = new WeakMap();
106
- //# sourceMappingURL=snapshot.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.mjs","sourceRoot":"","sources":["../../src/state/snapshot.ts"],"names":[],"mappings":";;;;;;;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,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CACP,SAAyD;QAEzD,OAAO,uBAAA,IAAI,kCAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CACT,OAAoC;QAEpC,OAAO,uBAAA,IAAI,kCAAO,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO;YACL,OAAO,EAAE,oCAAoC;YAC7C,OAAO,EAAE,uBAAA,IAAI,oCAAS;SACvB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAAC,GAAY;QAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;CACF","sourcesContent":["import { IdMap } from './id-map.js';\nimport type {\n AccountGroupPayloadId,\n AccountTreePayload,\n AccountTreeSnapshotEntry,\n AccountWalletPayloadId,\n} from './payload.js';\nimport { ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION, migrate } from './payload.js';\n\n/**\n * Immutable value object returned by {@link AccountTreeController.exportState}.\n *\n * Holds an ID map (local ↔ payload) populated during export so callers can\n * bridge between internal controller IDs and the stable cross-device IDs that\n * appear in the serialized payload. The map is absent for snapshots produced\n * by {@link AccountTreeSnapshot.deserialize} — `toLocalId` / `toPayloadId`\n * return `undefined` in that case.\n */\nexport class AccountTreeSnapshot {\n readonly #entries: AccountTreeSnapshotEntry[];\n\n readonly #idMap: IdMap | null;\n\n constructor(entries: AccountTreeSnapshotEntry[], idMap: IdMap | null) {\n this.#entries = entries;\n this.#idMap = idMap;\n }\n\n /**\n * Returns a new snapshot containing only the wallet entries for which\n * `predicate` returns `true`. The ID map is pruned to match.\n *\n * @param predicate - Function called with each wallet entry.\n * @returns A filtered snapshot.\n */\n filter(\n predicate: (entry: AccountTreeSnapshotEntry) => boolean,\n ): AccountTreeSnapshot {\n const filteredEntries = this.#entries.filter(predicate);\n\n if (!this.#idMap) {\n return new AccountTreeSnapshot(filteredEntries, null);\n }\n\n const pairs: Parameters<IdMap['add']>[] = [];\n for (const entry of filteredEntries) {\n const localWalletId = this.#idMap.getLocalId(entry.id);\n if (localWalletId !== undefined) {\n pairs.push([localWalletId, entry.id]);\n }\n for (const group of entry.groups) {\n const localGroupId = this.#idMap.getLocalId(group.id);\n if (localGroupId !== undefined) {\n pairs.push([localGroupId, group.id]);\n }\n }\n }\n\n return new AccountTreeSnapshot(filteredEntries, new IdMap(pairs));\n }\n\n /**\n * Converts a payload ID (wallet or group) to the corresponding local\n * `AccountTreeController` ID.\n *\n * @param payloadId - Stable cross-device wallet or group payload ID.\n * @returns The local controller ID, or `undefined` if not found or no ID map is present.\n */\n toLocalId(\n payloadId: AccountWalletPayloadId | AccountGroupPayloadId,\n ): ReturnType<IdMap['getLocalId']> {\n return this.#idMap?.getLocalId(payloadId);\n }\n\n /**\n * Converts a local `AccountTreeController` ID (wallet or group) to its\n * stable cross-device payload ID.\n *\n * @param localId - Local controller wallet or group ID.\n * @returns The payload ID, or `undefined` if not found or no ID map is present.\n */\n toPayloadId(\n localId: Parameters<IdMap['add']>[0],\n ): ReturnType<IdMap['getPayloadId']> {\n return this.#idMap?.getPayloadId(localId);\n }\n\n /**\n * Serializes the snapshot to a versioned {@link AccountTreePayload}.\n *\n * @returns The versioned payload.\n */\n serialize(): AccountTreePayload {\n return {\n version: ACCOUNT_TREE_PAYLOAD_CURRENT_VERSION,\n wallets: this.#entries,\n };\n }\n\n /**\n * Deserializes and validates a raw value as an `AccountTreePayload`,\n * running any necessary version migrations.\n *\n * The returned snapshot has no ID map — `toLocalId` / `toPayloadId` return\n * `undefined`. Use `AccountTreeController.exportState` when you need the map.\n *\n * @param raw - Unknown value to parse.\n * @returns A migrated snapshot.\n * @throws If `raw` is not a valid payload or its version exceeds the current version.\n */\n static deserialize(raw: unknown): AccountTreeSnapshot {\n const payload = migrate(raw);\n return new AccountTreeSnapshot(payload.wallets, null);\n }\n}\n"]}