@metamask-previews/account-tree-controller 1.4.0-preview-44207a4 → 1.4.1-preview-e8868d87
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.
- package/CHANGELOG.md +14 -1
- package/dist/backup-and-sync/syncing/wallet.cjs +6 -1
- package/dist/backup-and-sync/syncing/wallet.cjs.map +1 -1
- package/dist/backup-and-sync/syncing/wallet.d.cts.map +1 -1
- package/dist/backup-and-sync/syncing/wallet.d.mts.map +1 -1
- package/dist/backup-and-sync/syncing/wallet.mjs +6 -1
- package/dist/backup-and-sync/syncing/wallet.mjs.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Ensure `isLegacyAccountSyncingDisabled` is always set in `UserStorageSyncedWallet` after one successful full sync ([#6805](https://github.com/MetaMask/core/pull/6805))
|
|
13
|
+
- This was not set in some rare edge case scenarios, and created situations were legacy syncs would always be re-triggered during full syncs.
|
|
14
|
+
- We now verify this field is correctly set, and also catch empty objects for `UserStorageSyncedWallet`.
|
|
15
|
+
|
|
16
|
+
## [1.4.1]
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Bump `@metamask/base-controller` from `^8.4.0` to `^8.4.1` ([#6807](https://github.com/MetaMask/core/pull/6807))
|
|
21
|
+
|
|
10
22
|
## [1.4.0]
|
|
11
23
|
|
|
12
24
|
### Changed
|
|
@@ -347,7 +359,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
347
359
|
- Initial release ([#5847](https://github.com/MetaMask/core/pull/5847))
|
|
348
360
|
- Grouping accounts into 3 main categories: Entropy source, Snap ID, keyring types.
|
|
349
361
|
|
|
350
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.4.
|
|
362
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.4.1...HEAD
|
|
363
|
+
[1.4.1]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.4.0...@metamask/account-tree-controller@1.4.1
|
|
351
364
|
[1.4.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.3.0...@metamask/account-tree-controller@1.4.0
|
|
352
365
|
[1.3.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.2.0...@metamask/account-tree-controller@1.3.0
|
|
353
366
|
[1.2.0]: https://github.com/MetaMask/core/compare/@metamask/account-tree-controller@1.1.0...@metamask/account-tree-controller@1.2.0
|
|
@@ -17,7 +17,8 @@ const network_operations_1 = require("../user-storage/network-operations.cjs");
|
|
|
17
17
|
*/
|
|
18
18
|
async function syncWalletMetadataAndCheckIfPushNeeded(context, localWallet, walletFromUserStorage, profileId) {
|
|
19
19
|
const walletPersistedMetadata = context.controller.state.accountWalletsMetadata[localWallet.id];
|
|
20
|
-
if (!walletFromUserStorage
|
|
20
|
+
if (!walletFromUserStorage ||
|
|
21
|
+
Object.keys(walletFromUserStorage).length === 0) {
|
|
21
22
|
(0, logger_1.backupAndSyncLogger)(`Wallet ${localWallet.id} did not exist in user storage, pushing to user storage...`);
|
|
22
23
|
return true;
|
|
23
24
|
}
|
|
@@ -38,6 +39,10 @@ async function syncWalletMetadataAndCheckIfPushNeeded(context, localWallet, wall
|
|
|
38
39
|
},
|
|
39
40
|
});
|
|
40
41
|
shouldPushWallet || (shouldPushWallet = shouldPushForName);
|
|
42
|
+
// Avoid re-triggering legacy-syncing (in case this field is missing on the remote
|
|
43
|
+
// wallet object).
|
|
44
|
+
const shouldPushForMissingLegacyField = !Object.prototype.hasOwnProperty.call(walletFromUserStorage, 'isLegacyAccountSyncingDisabled');
|
|
45
|
+
shouldPushWallet || (shouldPushWallet = shouldPushForMissingLegacyField);
|
|
41
46
|
return shouldPushWallet;
|
|
42
47
|
}
|
|
43
48
|
exports.syncWalletMetadataAndCheckIfPushNeeded = syncWalletMetadataAndCheckIfPushNeeded;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,6CAAmD;AAEnD,sDAA2D;AAE3D,wCAIkB;AAClB,+EAA6E;AAE7E;;;;;;;;GAQG;AACI,KAAK,UAAU,sCAAsC,CAC1D,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"wallet.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,6CAAmD;AAEnD,sDAA2D;AAE3D,wCAIkB;AAClB,+EAA6E;AAE7E;;;;;;;;GAQG;AACI,KAAK,UAAU,sCAAsC,CAC1D,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAElE,IACE,CAAC,qBAAqB;QACtB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC,EAC/C;QACA,IAAA,4BAAmB,EACjB,UAAU,WAAW,CAAC,EAAE,4DAA4D,CACrF,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IACD,uDAAuD;IACvD,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,iCAAiC;IACjC,MAAM,iBAAiB,GAAG,MAAM,IAAA,iCAAsB,EAAC;QACrD,OAAO;QACP,aAAa,EAAE,uBAAuB,EAAE,IAAI;QAC5C,mBAAmB,EAAE,qBAAqB,CAAC,IAAI;QAC/C,wBAAwB,EAAE,CAAC,KAAK,EAAE,EAAE,CAClC,qCAA6B,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;QAClE,gBAAgB,EAAE,CAAC,IAAY,EAAE,EAAE;YACjC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;QACD,SAAS,EAAE;YACT,MAAM,EAAE,uCAA2B,CAAC,aAAa;YACjD,SAAS;SACV;KACF,CAAC,CAAC;IAEH,gBAAgB,KAAhB,gBAAgB,GAAK,iBAAiB,EAAC;IAEvC,kFAAkF;IAClF,kBAAkB;IAClB,MAAM,+BAA+B,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAC3E,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IAEF,gBAAgB,KAAhB,gBAAgB,GAAK,+BAA+B,EAAC;IAErD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAjDD,wFAiDC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,kBAAkB,CACtC,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAAG,MAAM,sCAAsC,CAC1E,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,SAAS,CACV,CAAC;IAEF,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,4CAAuB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;KACrD;AACH,CAAC;AAhBD,gDAgBC","sourcesContent":["import { compareAndSyncMetadata } from './metadata';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport { BackupAndSyncAnalyticsEvent } from '../analytics';\nimport type { ProfileId } from '../authentication';\nimport {\n UserStorageSyncedWalletSchema,\n type BackupAndSyncContext,\n type UserStorageSyncedWallet,\n} from '../types';\nimport { pushWalletToUserStorage } from '../user-storage/network-operations';\n\n/**\n * Syncs wallet metadata fields and determines if the wallet needs to be pushed to user storage.\n *\n * @param context - The sync context containing controller and messenger.\n * @param localWallet - The local wallet to sync.\n * @param walletFromUserStorage - The wallet data from user storage, if any.\n * @param profileId - The profile ID for analytics.\n * @returns Promise resolving to true if the wallet should be pushed to user storage.\n */\nexport async function syncWalletMetadataAndCheckIfPushNeeded(\n context: BackupAndSyncContext,\n localWallet: AccountWalletEntropyObject,\n walletFromUserStorage: UserStorageSyncedWallet | null | undefined,\n profileId: ProfileId,\n): Promise<boolean> {\n const walletPersistedMetadata =\n context.controller.state.accountWalletsMetadata[localWallet.id];\n\n if (\n !walletFromUserStorage ||\n Object.keys(walletFromUserStorage).length === 0\n ) {\n backupAndSyncLogger(\n `Wallet ${localWallet.id} did not exist in user storage, pushing to user storage...`,\n );\n return true;\n }\n // Track if we need to push this wallet to user storage\n let shouldPushWallet = false;\n\n // Compare and sync name metadata\n const shouldPushForName = await compareAndSyncMetadata({\n context,\n localMetadata: walletPersistedMetadata?.name,\n userStorageMetadata: walletFromUserStorage.name,\n validateUserStorageValue: (value) =>\n UserStorageSyncedWalletSchema.schema.name.schema.value.is(value),\n applyLocalUpdate: (name: string) => {\n context.controller.setAccountWalletName(localWallet.id, name);\n },\n analytics: {\n action: BackupAndSyncAnalyticsEvent.WalletRenamed,\n profileId,\n },\n });\n\n shouldPushWallet ||= shouldPushForName;\n\n // Avoid re-triggering legacy-syncing (in case this field is missing on the remote\n // wallet object).\n const shouldPushForMissingLegacyField = !Object.prototype.hasOwnProperty.call(\n walletFromUserStorage,\n 'isLegacyAccountSyncingDisabled',\n );\n\n shouldPushWallet ||= shouldPushForMissingLegacyField;\n\n return shouldPushWallet;\n}\n\n/**\n * Syncs wallet metadata and pushes it to user storage if needed.\n *\n * @param context - The sync context containing controller and messenger.\n * @param localWallet - The local wallet to sync.\n * @param walletFromUserStorage - The wallet data from user storage, if any.\n * @param profileId - The profile ID for analytics.\n */\nexport async function syncWalletMetadata(\n context: BackupAndSyncContext,\n localWallet: AccountWalletEntropyObject,\n walletFromUserStorage: UserStorageSyncedWallet | null | undefined,\n profileId: ProfileId,\n): Promise<void> {\n const shouldPushToUserStorage = await syncWalletMetadataAndCheckIfPushNeeded(\n context,\n localWallet,\n walletFromUserStorage,\n profileId,\n );\n\n if (shouldPushToUserStorage) {\n await pushWalletToUserStorage(context, localWallet);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,oCAA0B;AACnD,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"wallet.d.cts","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,oCAA0B;AACnD,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC,CA4ClB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,oCAA0B;AACnD,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"wallet.d.mts","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,oCAA0B;AACnD,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,sCAAsC,CAC1D,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC,CA4ClB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,0BAA0B,EACvC,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAAG,SAAS,EACjE,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -14,7 +14,8 @@ import { pushWalletToUserStorage } from "../user-storage/network-operations.mjs"
|
|
|
14
14
|
*/
|
|
15
15
|
export async function syncWalletMetadataAndCheckIfPushNeeded(context, localWallet, walletFromUserStorage, profileId) {
|
|
16
16
|
const walletPersistedMetadata = context.controller.state.accountWalletsMetadata[localWallet.id];
|
|
17
|
-
if (!walletFromUserStorage
|
|
17
|
+
if (!walletFromUserStorage ||
|
|
18
|
+
Object.keys(walletFromUserStorage).length === 0) {
|
|
18
19
|
backupAndSyncLogger(`Wallet ${localWallet.id} did not exist in user storage, pushing to user storage...`);
|
|
19
20
|
return true;
|
|
20
21
|
}
|
|
@@ -35,6 +36,10 @@ export async function syncWalletMetadataAndCheckIfPushNeeded(context, localWalle
|
|
|
35
36
|
},
|
|
36
37
|
});
|
|
37
38
|
shouldPushWallet || (shouldPushWallet = shouldPushForName);
|
|
39
|
+
// Avoid re-triggering legacy-syncing (in case this field is missing on the remote
|
|
40
|
+
// wallet object).
|
|
41
|
+
const shouldPushForMissingLegacyField = !Object.prototype.hasOwnProperty.call(walletFromUserStorage, 'isLegacyAccountSyncingDisabled');
|
|
42
|
+
shouldPushWallet || (shouldPushWallet = shouldPushForMissingLegacyField);
|
|
38
43
|
return shouldPushWallet;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAmB;AACpD,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAEnD,OAAO,EAAE,2BAA2B,EAAE,+BAAqB;AAE3D,OAAO,EACL,6BAA6B,EAG9B,qBAAiB;AAClB,OAAO,EAAE,uBAAuB,EAAE,+CAA2C;AAE7E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAElE,IAAI,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"wallet.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/syncing/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,uBAAmB;AACpD,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAEnD,OAAO,EAAE,2BAA2B,EAAE,+BAAqB;AAE3D,OAAO,EACL,6BAA6B,EAG9B,qBAAiB;AAClB,OAAO,EAAE,uBAAuB,EAAE,+CAA2C;AAE7E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sCAAsC,CAC1D,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAC3B,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAElE,IACE,CAAC,qBAAqB;QACtB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC,EAC/C;QACA,mBAAmB,CACjB,UAAU,WAAW,CAAC,EAAE,4DAA4D,CACrF,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IACD,uDAAuD;IACvD,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,iCAAiC;IACjC,MAAM,iBAAiB,GAAG,MAAM,sBAAsB,CAAC;QACrD,OAAO;QACP,aAAa,EAAE,uBAAuB,EAAE,IAAI;QAC5C,mBAAmB,EAAE,qBAAqB,CAAC,IAAI;QAC/C,wBAAwB,EAAE,CAAC,KAAK,EAAE,EAAE,CAClC,6BAA6B,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;QAClE,gBAAgB,EAAE,CAAC,IAAY,EAAE,EAAE;YACjC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;QACD,SAAS,EAAE;YACT,MAAM,EAAE,2BAA2B,CAAC,aAAa;YACjD,SAAS;SACV;KACF,CAAC,CAAC;IAEH,gBAAgB,KAAhB,gBAAgB,GAAK,iBAAiB,EAAC;IAEvC,kFAAkF;IAClF,kBAAkB;IAClB,MAAM,+BAA+B,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAC3E,qBAAqB,EACrB,gCAAgC,CACjC,CAAC;IAEF,gBAAgB,KAAhB,gBAAgB,GAAK,+BAA+B,EAAC;IAErD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA6B,EAC7B,WAAuC,EACvC,qBAAiE,EACjE,SAAoB;IAEpB,MAAM,uBAAuB,GAAG,MAAM,sCAAsC,CAC1E,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,SAAS,CACV,CAAC;IAEF,IAAI,uBAAuB,EAAE;QAC3B,MAAM,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;KACrD;AACH,CAAC","sourcesContent":["import { compareAndSyncMetadata } from './metadata';\nimport { backupAndSyncLogger } from '../../logger';\nimport type { AccountWalletEntropyObject } from '../../wallet';\nimport { BackupAndSyncAnalyticsEvent } from '../analytics';\nimport type { ProfileId } from '../authentication';\nimport {\n UserStorageSyncedWalletSchema,\n type BackupAndSyncContext,\n type UserStorageSyncedWallet,\n} from '../types';\nimport { pushWalletToUserStorage } from '../user-storage/network-operations';\n\n/**\n * Syncs wallet metadata fields and determines if the wallet needs to be pushed to user storage.\n *\n * @param context - The sync context containing controller and messenger.\n * @param localWallet - The local wallet to sync.\n * @param walletFromUserStorage - The wallet data from user storage, if any.\n * @param profileId - The profile ID for analytics.\n * @returns Promise resolving to true if the wallet should be pushed to user storage.\n */\nexport async function syncWalletMetadataAndCheckIfPushNeeded(\n context: BackupAndSyncContext,\n localWallet: AccountWalletEntropyObject,\n walletFromUserStorage: UserStorageSyncedWallet | null | undefined,\n profileId: ProfileId,\n): Promise<boolean> {\n const walletPersistedMetadata =\n context.controller.state.accountWalletsMetadata[localWallet.id];\n\n if (\n !walletFromUserStorage ||\n Object.keys(walletFromUserStorage).length === 0\n ) {\n backupAndSyncLogger(\n `Wallet ${localWallet.id} did not exist in user storage, pushing to user storage...`,\n );\n return true;\n }\n // Track if we need to push this wallet to user storage\n let shouldPushWallet = false;\n\n // Compare and sync name metadata\n const shouldPushForName = await compareAndSyncMetadata({\n context,\n localMetadata: walletPersistedMetadata?.name,\n userStorageMetadata: walletFromUserStorage.name,\n validateUserStorageValue: (value) =>\n UserStorageSyncedWalletSchema.schema.name.schema.value.is(value),\n applyLocalUpdate: (name: string) => {\n context.controller.setAccountWalletName(localWallet.id, name);\n },\n analytics: {\n action: BackupAndSyncAnalyticsEvent.WalletRenamed,\n profileId,\n },\n });\n\n shouldPushWallet ||= shouldPushForName;\n\n // Avoid re-triggering legacy-syncing (in case this field is missing on the remote\n // wallet object).\n const shouldPushForMissingLegacyField = !Object.prototype.hasOwnProperty.call(\n walletFromUserStorage,\n 'isLegacyAccountSyncingDisabled',\n );\n\n shouldPushWallet ||= shouldPushForMissingLegacyField;\n\n return shouldPushWallet;\n}\n\n/**\n * Syncs wallet metadata and pushes it to user storage if needed.\n *\n * @param context - The sync context containing controller and messenger.\n * @param localWallet - The local wallet to sync.\n * @param walletFromUserStorage - The wallet data from user storage, if any.\n * @param profileId - The profile ID for analytics.\n */\nexport async function syncWalletMetadata(\n context: BackupAndSyncContext,\n localWallet: AccountWalletEntropyObject,\n walletFromUserStorage: UserStorageSyncedWallet | null | undefined,\n profileId: ProfileId,\n): Promise<void> {\n const shouldPushToUserStorage = await syncWalletMetadataAndCheckIfPushNeeded(\n context,\n localWallet,\n walletFromUserStorage,\n profileId,\n );\n\n if (shouldPushToUserStorage) {\n await pushWalletToUserStorage(context, localWallet);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/account-tree-controller",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1-preview-e8868d87",
|
|
4
4
|
"description": "Controller to group account together based on some pre-defined rules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@metamask/base-controller": "^8.4.
|
|
50
|
+
"@metamask/base-controller": "^8.4.1",
|
|
51
51
|
"@metamask/snaps-sdk": "^9.0.0",
|
|
52
52
|
"@metamask/snaps-utils": "^11.0.0",
|
|
53
53
|
"@metamask/superstruct": "^3.1.0",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@metamask/account-api": "^0.12.0",
|
|
60
|
-
"@metamask/accounts-controller": "^33.1.
|
|
60
|
+
"@metamask/accounts-controller": "^33.1.1",
|
|
61
61
|
"@metamask/auto-changelog": "^3.4.4",
|
|
62
62
|
"@metamask/keyring-api": "^21.0.0",
|
|
63
|
-
"@metamask/keyring-controller": "^23.1.
|
|
64
|
-
"@metamask/multichain-account-service": "^1.6.
|
|
65
|
-
"@metamask/profile-sync-controller": "^25.1.
|
|
63
|
+
"@metamask/keyring-controller": "^23.1.1",
|
|
64
|
+
"@metamask/multichain-account-service": "^1.6.1",
|
|
65
|
+
"@metamask/profile-sync-controller": "^25.1.1",
|
|
66
66
|
"@metamask/providers": "^22.1.0",
|
|
67
67
|
"@metamask/snaps-controllers": "^14.0.1",
|
|
68
68
|
"@types/jest": "^27.4.1",
|