@metamask/profile-sync-controller 5.0.0 → 7.0.0

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 (240) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  3. package/dist/controllers/authentication/AuthenticationController.d.cts +2 -2
  4. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  5. package/dist/controllers/authentication/AuthenticationController.d.mts +2 -2
  6. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  7. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  8. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +0 -5
  9. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -1
  10. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -1
  11. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -1
  12. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +0 -5
  13. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -1
  14. package/dist/controllers/authentication/services.cjs +0 -2
  15. package/dist/controllers/authentication/services.cjs.map +1 -1
  16. package/dist/controllers/authentication/services.d.cts +5 -3
  17. package/dist/controllers/authentication/services.d.cts.map +1 -1
  18. package/dist/controllers/authentication/services.d.mts +5 -3
  19. package/dist/controllers/authentication/services.d.mts.map +1 -1
  20. package/dist/controllers/authentication/services.mjs +0 -2
  21. package/dist/controllers/authentication/services.mjs.map +1 -1
  22. package/dist/controllers/user-storage/UserStorageController.cjs +11 -42
  23. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  24. package/dist/controllers/user-storage/UserStorageController.d.cts +8 -15
  25. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  26. package/dist/controllers/user-storage/UserStorageController.d.mts +8 -15
  27. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  28. package/dist/controllers/user-storage/UserStorageController.mjs +11 -42
  29. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  30. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +3 -15
  31. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +1 -1
  32. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +10 -10
  33. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +1 -1
  34. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +10 -10
  35. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +1 -1
  36. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +4 -16
  37. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +1 -1
  38. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +5 -1
  39. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -1
  40. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts +4 -0
  41. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -1
  42. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +4 -0
  43. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -1
  44. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +5 -1
  45. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -1
  46. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +1 -1
  47. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -1
  48. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -1
  49. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -1
  50. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +1 -1
  51. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -1
  52. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +5 -2
  53. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -1
  54. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +3 -0
  55. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -1
  56. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +3 -0
  57. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -1
  58. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +5 -2
  59. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -1
  60. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs +2 -0
  61. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +1 -1
  62. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts +1 -0
  63. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +1 -1
  64. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts +1 -0
  65. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +1 -1
  66. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs +2 -0
  67. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +1 -1
  68. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +3 -1
  69. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +1 -1
  70. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +5 -5
  71. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +1 -1
  72. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +5 -5
  73. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +1 -1
  74. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +3 -1
  75. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +1 -1
  76. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +4 -2
  77. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
  78. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +3 -0
  79. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
  80. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +3 -0
  81. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
  82. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +4 -2
  83. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
  84. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +3 -6
  85. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -1
  86. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +1 -0
  87. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -1
  88. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +1 -0
  89. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -1
  90. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +3 -6
  91. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -1
  92. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +6 -2
  93. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
  94. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +5 -0
  95. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
  96. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +5 -0
  97. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
  98. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +6 -2
  99. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
  100. package/dist/controllers/user-storage/account-syncing/types.cjs.map +1 -1
  101. package/dist/controllers/user-storage/account-syncing/types.d.cts +1 -1
  102. package/dist/controllers/user-storage/account-syncing/types.d.cts.map +1 -1
  103. package/dist/controllers/user-storage/account-syncing/types.d.mts +1 -1
  104. package/dist/controllers/user-storage/account-syncing/types.d.mts.map +1 -1
  105. package/dist/controllers/user-storage/account-syncing/types.mjs.map +1 -1
  106. package/dist/controllers/user-storage/account-syncing/utils.cjs +3 -1
  107. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
  108. package/dist/controllers/user-storage/account-syncing/utils.d.cts +2 -0
  109. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
  110. package/dist/controllers/user-storage/account-syncing/utils.d.mts +2 -0
  111. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
  112. package/dist/controllers/user-storage/account-syncing/utils.mjs +3 -1
  113. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
  114. package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs +1 -0
  115. package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs.map +1 -1
  116. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts +1 -0
  117. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts.map +1 -1
  118. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts +1 -0
  119. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts.map +1 -1
  120. package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs +1 -0
  121. package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs.map +1 -1
  122. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +3 -3
  123. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
  124. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +2 -0
  125. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
  126. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +2 -0
  127. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
  128. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +3 -3
  129. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
  130. package/dist/controllers/user-storage/network-syncing/services.cjs +5 -0
  131. package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
  132. package/dist/controllers/user-storage/network-syncing/services.d.cts +5 -1
  133. package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
  134. package/dist/controllers/user-storage/network-syncing/services.d.mts +5 -1
  135. package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
  136. package/dist/controllers/user-storage/network-syncing/services.mjs +5 -0
  137. package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
  138. package/dist/controllers/user-storage/network-syncing/sync-all.cjs +1 -1
  139. package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -1
  140. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -1
  141. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -1
  142. package/dist/controllers/user-storage/network-syncing/sync-all.mjs +1 -1
  143. package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -1
  144. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
  145. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
  146. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
  147. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
  148. package/dist/controllers/user-storage/network-syncing/update-network-utils.cjs +3 -0
  149. package/dist/controllers/user-storage/network-syncing/update-network-utils.cjs.map +1 -1
  150. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts +3 -0
  151. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts.map +1 -1
  152. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts +3 -0
  153. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts.map +1 -1
  154. package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs +3 -0
  155. package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs.map +1 -1
  156. package/dist/controllers/user-storage/services.cjs +0 -1
  157. package/dist/controllers/user-storage/services.cjs.map +1 -1
  158. package/dist/controllers/user-storage/services.d.cts.map +1 -1
  159. package/dist/controllers/user-storage/services.d.mts.map +1 -1
  160. package/dist/controllers/user-storage/services.mjs +0 -1
  161. package/dist/controllers/user-storage/services.mjs.map +1 -1
  162. package/dist/controllers/user-storage/utils.cjs +2 -0
  163. package/dist/controllers/user-storage/utils.cjs.map +1 -1
  164. package/dist/controllers/user-storage/utils.d.cts +2 -0
  165. package/dist/controllers/user-storage/utils.d.cts.map +1 -1
  166. package/dist/controllers/user-storage/utils.d.mts +2 -0
  167. package/dist/controllers/user-storage/utils.d.mts.map +1 -1
  168. package/dist/controllers/user-storage/utils.mjs +2 -0
  169. package/dist/controllers/user-storage/utils.mjs.map +1 -1
  170. package/dist/sdk/__fixtures__/mock-auth.cjs +0 -15
  171. package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -1
  172. package/dist/sdk/__fixtures__/mock-auth.mjs +0 -15
  173. package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -1
  174. package/dist/sdk/__fixtures__/mock-userstorage.cjs +0 -2
  175. package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -1
  176. package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -1
  177. package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -1
  178. package/dist/sdk/__fixtures__/mock-userstorage.mjs +0 -2
  179. package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -1
  180. package/dist/sdk/__fixtures__/test-utils.cjs +2 -1
  181. package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -1
  182. package/dist/sdk/__fixtures__/test-utils.d.cts +1 -0
  183. package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -1
  184. package/dist/sdk/__fixtures__/test-utils.d.mts +1 -0
  185. package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -1
  186. package/dist/sdk/__fixtures__/test-utils.mjs +2 -1
  187. package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -1
  188. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +1 -1
  189. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
  190. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
  191. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
  192. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +1 -1
  193. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  194. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +1 -1
  195. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  196. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  197. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  198. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +1 -1
  199. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  200. package/dist/sdk/authentication-jwt-bearer/services.cjs +1 -2
  201. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  202. package/dist/sdk/authentication-jwt-bearer/services.d.cts +1 -1
  203. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  204. package/dist/sdk/authentication-jwt-bearer/services.d.mts +1 -1
  205. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  206. package/dist/sdk/authentication-jwt-bearer/services.mjs +1 -2
  207. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  208. package/dist/sdk/authentication.cjs +0 -3
  209. package/dist/sdk/authentication.cjs.map +1 -1
  210. package/dist/sdk/authentication.d.cts.map +1 -1
  211. package/dist/sdk/authentication.d.mts.map +1 -1
  212. package/dist/sdk/authentication.mjs +0 -3
  213. package/dist/sdk/authentication.mjs.map +1 -1
  214. package/dist/sdk/user-storage.cjs +1 -3
  215. package/dist/sdk/user-storage.cjs.map +1 -1
  216. package/dist/sdk/user-storage.d.cts +1 -1
  217. package/dist/sdk/user-storage.d.cts.map +1 -1
  218. package/dist/sdk/user-storage.d.mts +1 -1
  219. package/dist/sdk/user-storage.d.mts.map +1 -1
  220. package/dist/sdk/user-storage.mjs +1 -3
  221. package/dist/sdk/user-storage.mjs.map +1 -1
  222. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +4 -4
  223. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -1
  224. package/dist/sdk/utils/eip-6963-metamask-provider.mjs +4 -4
  225. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
  226. package/dist/shared/encryption/constants.cjs +0 -2
  227. package/dist/shared/encryption/constants.cjs.map +1 -1
  228. package/dist/shared/encryption/constants.d.cts.map +1 -1
  229. package/dist/shared/encryption/constants.d.mts.map +1 -1
  230. package/dist/shared/encryption/constants.mjs +0 -2
  231. package/dist/shared/encryption/constants.mjs.map +1 -1
  232. package/dist/shared/encryption/encryption.cjs +1 -0
  233. package/dist/shared/encryption/encryption.cjs.map +1 -1
  234. package/dist/shared/encryption/encryption.d.cts +1 -0
  235. package/dist/shared/encryption/encryption.d.cts.map +1 -1
  236. package/dist/shared/encryption/encryption.d.mts +1 -0
  237. package/dist/shared/encryption/encryption.d.mts.map +1 -1
  238. package/dist/shared/encryption/encryption.mjs +1 -0
  239. package/dist/shared/encryption/encryption.mjs.map +1 -1
  240. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,gDAAsC;AACjE,OAAO,EAAE,wBAAwB,EAAE,6CAAyC;AAC5E,OAAO,EAAE,sCAAsC,EAAE,qBAAiB;AAClE,OAAO,EAAE,sBAAsB,EAAE,2BAAuB;AAExD;;;;;;;GAOG;AACH,MAAM,UAAU,yCAAyC,CAAC,OAIzD;IACC,MAAM,cAAc,GAAG,wBAAwB,EAAE,CAAC;IAElD,cAAc,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;QACpE,cAAc,CAAC,aAAa,CAAC,OAAO,CAClC,iCAAiC,EACjC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAoB,CACjD,CAAC;QACF,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,wBAAwB,CAAC,eAAe,CACrD,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;QAC9B,sBAAsB,CAAC,GAAG,CAAsB,CACnD,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wCAAwC,CACtD,IAAiC,EACjC,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QAC1C,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,sCAAsC,CAAC,UAAU,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wCAAwC,CACtD,IAAc,EACd,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3B,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { createSHA256Hash } from '../../../../shared/encryption';\nimport { mockUserStorageMessenger } from '../../__fixtures__/mockMessenger';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\nimport { MOCK_INTERNAL_ACCOUNTS } from './mockAccounts';\n\n/**\n * Test Utility - create a mock user storage messenger for account syncing tests\n *\n * @param options - options for the mock messenger\n * @param options.accounts - options for the accounts part of the controller\n * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action\n * @returns Mock User Storage Messenger\n */\nexport function mockUserStorageMessengerForAccountSyncing(options?: {\n accounts?: {\n accountsList?: InternalAccount[];\n };\n}) {\n const messengerMocks = mockUserStorageMessenger();\n\n messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {\n messengerMocks.baseMessenger.publish(\n 'AccountsController:accountAdded',\n MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount,\n );\n return MOCK_INTERNAL_ACCOUNTS.ONE[0].address;\n });\n\n messengerMocks.mockAccountsListAccounts.mockReturnValue(\n (options?.accounts?.accountsList ??\n MOCK_INTERNAL_ACCOUNTS.ALL) as InternalAccount[],\n );\n\n return messengerMocks;\n}\n\n/**\n * Test Utility - creates a realistic expected batch upsert payload\n * @param data - data supposed to be upserted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchUpsertBody(\n data: [string, InternalAccount][],\n storageKey: string,\n) {\n return data.map(([entryKey, entryValue]) => [\n createSHA256Hash(String(entryKey) + storageKey),\n JSON.stringify(mapInternalAccountToUserStorageAccount(entryValue)),\n ]);\n}\n\n/**\n * Test Utility - creates a realistic expected batch delete payload\n * @param data - data supposed to be deleted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchDeleteBody(\n data: string[],\n storageKey: string,\n) {\n return data.map((entryKey) =>\n createSHA256Hash(String(entryKey) + storageKey),\n );\n}\n"]}
1
+ {"version":3,"file":"test-utils.mjs","sourceRoot":"","sources":["../../../../../src/controllers/user-storage/account-syncing/__fixtures__/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,2BAAuB;AACxD,OAAO,EAAE,gBAAgB,EAAE,gDAAsC;AACjE,OAAO,EAAE,wBAAwB,EAAE,6CAAyC;AAC5E,OAAO,EAAE,sCAAsC,EAAE,qBAAiB;AAElE;;;;;;;GAOG;AACH,MAAM,UAAU,yCAAyC,CAAC,OAIzD;IACC,MAAM,cAAc,GAAG,wBAAwB,EAAE,CAAC;IAElD,cAAc,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE;QACpE,cAAc,CAAC,aAAa,CAAC,OAAO,CAClC,iCAAiC,EACjC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAoB,CACjD,CAAC;QACF,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,wBAAwB,CAAC,eAAe,CACrD,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;QAC9B,sBAAsB,CAAC,GAAG,CAAsB,CACnD,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wCAAwC,CACtD,IAAiC,EACjC,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC;QAC1C,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,sCAAsC,CAAC,UAAU,CAAC,CAAC;KACnE,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wCAAwC,CACtD,IAAc,EACd,UAAkB;IAElB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC3B,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { MOCK_INTERNAL_ACCOUNTS } from './mockAccounts';\nimport { createSHA256Hash } from '../../../../shared/encryption';\nimport { mockUserStorageMessenger } from '../../__fixtures__/mockMessenger';\nimport { mapInternalAccountToUserStorageAccount } from '../utils';\n\n/**\n * Test Utility - create a mock user storage messenger for account syncing tests\n *\n * @param options - options for the mock messenger\n * @param options.accounts - options for the accounts part of the controller\n * @param options.accounts.accountsList - list of accounts to return for the 'AccountsController:listAccounts' action\n * @returns Mock User Storage Messenger\n */\nexport function mockUserStorageMessengerForAccountSyncing(options?: {\n accounts?: {\n accountsList?: InternalAccount[];\n };\n}) {\n const messengerMocks = mockUserStorageMessenger();\n\n messengerMocks.mockKeyringAddNewAccount.mockImplementation(async () => {\n messengerMocks.baseMessenger.publish(\n 'AccountsController:accountAdded',\n MOCK_INTERNAL_ACCOUNTS.ONE[0] as InternalAccount,\n );\n return MOCK_INTERNAL_ACCOUNTS.ONE[0].address;\n });\n\n messengerMocks.mockAccountsListAccounts.mockReturnValue(\n (options?.accounts?.accountsList ??\n MOCK_INTERNAL_ACCOUNTS.ALL) as InternalAccount[],\n );\n\n return messengerMocks;\n}\n\n/**\n * Test Utility - creates a realistic expected batch upsert payload\n *\n * @param data - data supposed to be upserted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchUpsertBody(\n data: [string, InternalAccount][],\n storageKey: string,\n) {\n return data.map(([entryKey, entryValue]) => [\n createSHA256Hash(String(entryKey) + storageKey),\n JSON.stringify(mapInternalAccountToUserStorageAccount(entryValue)),\n ]);\n}\n\n/**\n * Test Utility - creates a realistic expected batch delete payload\n *\n * @param data - data supposed to be deleted\n * @param storageKey - storage key\n * @returns expected body\n */\nexport function createExpectedAccountSyncBatchDeleteBody(\n data: string[],\n storageKey: string,\n) {\n return data.map((entryKey) =>\n createSHA256Hash(String(entryKey) + storageKey),\n );\n}\n"]}
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.syncInternalAccountsWithUserStorage = exports.saveInternalAccountsListToUserStorage = exports.saveInternalAccountToUserStorage = void 0;
4
4
  const keyring_api_1 = require("@metamask/keyring-api");
5
- const storage_schema_1 = require("../../../shared/storage-schema.cjs");
6
5
  const sync_utils_1 = require("./sync-utils.cjs");
7
6
  const utils_1 = require("./utils.cjs");
7
+ const storage_schema_1 = require("../../../shared/storage-schema.cjs");
8
8
  /**
9
9
  * Saves an individual internal account to the user storage.
10
+ *
10
11
  * @param internalAccount - The internal account to save
11
12
  * @param config - parameters used for saving the internal account
12
13
  * @param options - parameters used for saving the internal account
@@ -25,7 +26,6 @@ async function saveInternalAccountToUserStorage(internalAccount, config, options
25
26
  const mappedAccount = (0, utils_1.mapInternalAccountToUserStorageAccount)(internalAccount);
26
27
  await getUserStorageControllerInstance().performSetStorage(
27
28
  // ESLint is confused here.
28
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
29
29
  `${storage_schema_1.USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`, JSON.stringify(mappedAccount));
30
30
  }
31
31
  catch (e) {
@@ -37,6 +37,7 @@ async function saveInternalAccountToUserStorage(internalAccount, config, options
37
37
  exports.saveInternalAccountToUserStorage = saveInternalAccountToUserStorage;
38
38
  /**
39
39
  * Saves the list of internal accounts to the user storage.
40
+ *
40
41
  * @param config - parameters used for saving the list of internal accounts
41
42
  * @param options - parameters used for saving the list of internal accounts
42
43
  */
@@ -61,6 +62,7 @@ exports.saveInternalAccountsListToUserStorage = saveInternalAccountsListToUserSt
61
62
  * Syncs the internal accounts list with the user storage accounts list.
62
63
  * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.
63
64
  * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.
65
+ *
64
66
  * @param config - parameters used for syncing the internal accounts list with the user storage accounts list
65
67
  * @param options - parameters used for syncing the internal accounts list with the user storage accounts list
66
68
  */
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mapp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gBACd,4BAA4B;gBAC5B,yBAAyB;aAC1B,CAAC;YACF,IAAI,iBAAiB,EAAE;gBACrB,+BAA+B,EAAE,CAC/B,6FAA6F,EAC7F,OAAO,CACR,CAAC;aACH;iBAAM;gBACL,+BAA+B,EAAE,CAC/B,oGAAoG,EACpG,OAAO,CACR,CAAC;aACH;SACF;QAED,qFAAqF;QACrF,mFAAmF;QACnF,MAAM,gCAAgC,EAAE,CAAC,qCAAqC,CAC5E,IAAI,CACL,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;QACvB,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,uEAAuE,YAAY,EAAE,CACtF,CAAC;KACH;YAAS;QACR,MAAM,gCAAgC,EAAE,CAAC,6BAA6B,CACpE,KAAK,CACN,CAAC;KACH;AACH,CAAC;AApRD,kFAoRC","sourcesContent":["import { isEvmAccountType } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport {\n canPerformAccountSyncing,\n getInternalAccountsList,\n getUserStorageAccountsList,\n} from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\nimport {\n doesInternalAccountHaveCorrectKeyringType,\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './utils';\n\n/**\n * Saves an individual internal account to the user storage.\n * @param internalAccount - The internal account to save\n * @param config - parameters used for saving the internal account\n * @param options - parameters used for saving the internal account\n */\nexport async function saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (\n !isAccountSyncingEnabled ||\n !canPerformAccountSyncing(config, options) ||\n !isEvmAccountType(internalAccount.type) ||\n !doesInternalAccountHaveCorrectKeyringType(internalAccount)\n ) {\n return;\n }\n\n try {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await getUserStorageControllerInstance().performSetStorage(\n // ESLint is confused here.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `${USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to save account to user storage - ${errorMessage}`,\n );\n }\n}\n\n/**\n * Saves the list of internal accounts to the user storage.\n * @param config - parameters used for saving the list of internal accounts\n * @param options - parameters used for saving the list of internal accounts\n */\nexport async function saveInternalAccountsListToUserStorage(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (!isAccountSyncingEnabled) {\n return;\n }\n\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList?.length) {\n return;\n }\n\n const internalAccountsListFormattedForUserStorage = internalAccountsList.map(\n mapInternalAccountToUserStorageAccount,\n );\n\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsListFormattedForUserStorage.map((account) => [\n account.a,\n JSON.stringify(account),\n ]),\n );\n}\n\ntype SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {\n maxNumberOfAccountsToAdd?: number;\n onAccountAdded?: () => void;\n onAccountNameUpdated?: () => void;\n onAccountSyncErroneousSituation?: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n};\n\n/**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n * @param config - parameters used for syncing the internal accounts list with the user storage accounts list\n * @param options - parameters used for syncing the internal accounts list with the user storage accounts list\n */\nexport async function syncInternalAccountsWithUserStorage(\n config: SyncInternalAccountsWithUserStorageConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n\n if (!canPerformAccountSyncing(config, options) || !isAccountSyncingEnabled) {\n return;\n }\n\n const {\n maxNumberOfAccountsToAdd = 100,\n onAccountAdded,\n onAccountNameUpdated,\n onAccountSyncErroneousSituation,\n } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n try {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n true,\n );\n\n const userStorageAccountsList = await getUserStorageAccountsList(options);\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await saveInternalAccountsListToUserStorage(\n { isAccountSyncingEnabled },\n options,\n );\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n return;\n }\n // Keep a record if erroneous situations are found during the sync\n // This is done so we can send the context to Sentry in case of an erroneous situation\n let erroneousSituationsFound = false;\n\n // Prepare an array of internal accounts to be saved to the user storage\n const internalAccountsToBeSavedToUserStorage: InternalAccount[] = [];\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreUserStorageAccountsThanInternalAccounts =\n userStorageAccountsList.length > internalAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts in user storage than internal accounts\n if (hasMoreUserStorageAccountsThanInternalAccounts) {\n const numberOfAccountsToAdd =\n Math.min(userStorageAccountsList.length, maxNumberOfAccountsToAdd) -\n internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n for (let i = 0; i < numberOfAccountsToAdd; i++) {\n await getMessenger().call('KeyringController:addNewAccount');\n onAccountAdded?.();\n }\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n const refreshedInternalAccountsList = await getInternalAccountsList(\n options,\n );\n\n const newlyAddedAccounts = refreshedInternalAccountsList.filter(\n (account) =>\n !internalAccountsList.find((a) => a.address === account.address),\n );\n\n for (const internalAccount of refreshedInternalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n // If the account is not present in user storage\n // istanbul ignore next\n if (!userStorageAccount) {\n // If the account was just added in the previous step, skip saving it, it's likely to be a bogus account\n if (newlyAddedAccounts.includes(internalAccount)) {\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was added to the internal accounts list but was not present in the user storage accounts list',\n {\n internalAccount,\n userStorageAccount,\n newlyAddedAccounts,\n userStorageAccountsList,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n },\n );\n continue;\n }\n // Otherwise, it means that this internal account was present before the sync, and needs to be saved to the user storage\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // From this point on, we know that the account is present in\n // both the internal accounts list and the user storage accounts list\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n onAccountNameUpdated?.();\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt > userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n const areInternalAndUserStorageAccountNamesEqual =\n internalAccount.metadata.name === userStorageAccount.n;\n\n if (!areInternalAndUserStorageAccountNamesEqual) {\n onAccountNameUpdated?.();\n }\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n // Save the internal accounts list to the user storage\n if (internalAccountsToBeSavedToUserStorage.length) {\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsToBeSavedToUserStorage.map((account) => [\n account.address,\n JSON.stringify(mapInternalAccountToUserStorageAccount(account)),\n ]),\n );\n }\n\n // In case we have corrupted user storage with accounts that don't exist in the internal accounts list\n // Delete those accounts from the user storage\n const userStorageAccountsToBeDeleted = userStorageAccountsList.filter(\n (account) =>\n !refreshedInternalAccountsList.find((a) => a.address === account.a),\n );\n\n if (userStorageAccountsToBeDeleted.length) {\n await getUserStorageControllerInstance().performBatchDeleteStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n userStorageAccountsToBeDeleted.map((account) => account.a),\n );\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was present in the user storage accounts list but was not found in the internal accounts list after the sync',\n {\n userStorageAccountsToBeDeleted,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n userStorageAccountsList,\n },\n );\n }\n\n if (erroneousSituationsFound) {\n const [finalUserStorageAccountsList, finalInternalAccountsList] =\n await Promise.all([\n getUserStorageAccountsList(options),\n getInternalAccountsList(options),\n ]);\n\n const doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList =\n finalInternalAccountsList.every((account) =>\n finalUserStorageAccountsList?.some(\n (userStorageAccount) => userStorageAccount.a === account.address,\n ),\n );\n\n // istanbul ignore next\n const doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList =\n (finalUserStorageAccountsList?.length || 0) > maxNumberOfAccountsToAdd\n ? true\n : finalUserStorageAccountsList?.every((account) =>\n finalInternalAccountsList.some(\n (internalAccount) => internalAccount.address === account.a,\n ),\n );\n\n const doFinalListsMatch =\n doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList &&\n doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList;\n\n const context = {\n finalUserStorageAccountsList,\n finalInternalAccountsList,\n };\n if (doFinalListsMatch) {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, but final state matches the expected state',\n context,\n );\n } else {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, and final state does not match the expected state',\n context,\n );\n }\n }\n\n // We do this here and not in the finally statement because we want to make sure that\n // the accounts are saved / updated / deleted at least once before we set this flag\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n false,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"controller-integration.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":";;;AAAA,uDAAyD;AAGzD,iDAIsB;AAEtB,uCAIiB;AACjB,uEAA4E;AAE5E;;;;;;GAMG;AACI,KAAK,UAAU,gCAAgC,CACpD,eAAgC,EAChC,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EA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,EACpG,OAAO,CACR,CAAC;aACH;SACF;QAED,qFAAqF;QACrF,mFAAmF;QACnF,MAAM,gCAAgC,EAAE,CAAC,qCAAqC,CAC5E,IAAI,CACL,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;QACvB,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,uEAAuE,YAAY,EAAE,CACtF,CAAC;KACH;YAAS;QACR,MAAM,gCAAgC,EAAE,CAAC,6BAA6B,CACpE,KAAK,CACN,CAAC;KACH;AACH,CAAC;AAnRD,kFAmRC","sourcesContent":["import { isEvmAccountType } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n canPerformAccountSyncing,\n getInternalAccountsList,\n getUserStorageAccountsList,\n} from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\nimport {\n doesInternalAccountHaveCorrectKeyringType,\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './utils';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Saves an individual internal account to the user storage.\n *\n * @param internalAccount - The internal account to save\n * @param config - parameters used for saving the internal account\n * @param options - parameters used for saving the internal account\n */\nexport async function saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (\n !isAccountSyncingEnabled ||\n !canPerformAccountSyncing(config, options) ||\n !isEvmAccountType(internalAccount.type) ||\n !doesInternalAccountHaveCorrectKeyringType(internalAccount)\n ) {\n return;\n }\n\n try {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await getUserStorageControllerInstance().performSetStorage(\n // ESLint is confused here.\n\n `${USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to save account to user storage - ${errorMessage}`,\n );\n }\n}\n\n/**\n * Saves the list of internal accounts to the user storage.\n *\n * @param config - parameters used for saving the list of internal accounts\n * @param options - parameters used for saving the list of internal accounts\n */\nexport async function saveInternalAccountsListToUserStorage(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (!isAccountSyncingEnabled) {\n return;\n }\n\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList?.length) {\n return;\n }\n\n const internalAccountsListFormattedForUserStorage = internalAccountsList.map(\n mapInternalAccountToUserStorageAccount,\n );\n\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsListFormattedForUserStorage.map((account) => [\n account.a,\n JSON.stringify(account),\n ]),\n );\n}\n\ntype SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {\n maxNumberOfAccountsToAdd?: number;\n onAccountAdded?: () => void;\n onAccountNameUpdated?: () => void;\n onAccountSyncErroneousSituation?: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n};\n\n/**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n *\n * @param config - parameters used for syncing the internal accounts list with the user storage accounts list\n * @param options - parameters used for syncing the internal accounts list with the user storage accounts list\n */\nexport async function syncInternalAccountsWithUserStorage(\n config: SyncInternalAccountsWithUserStorageConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n\n if (!canPerformAccountSyncing(config, options) || !isAccountSyncingEnabled) {\n return;\n }\n\n const {\n maxNumberOfAccountsToAdd = 100,\n onAccountAdded,\n onAccountNameUpdated,\n onAccountSyncErroneousSituation,\n } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n try {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n true,\n );\n\n const userStorageAccountsList = await getUserStorageAccountsList(options);\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await saveInternalAccountsListToUserStorage(\n { isAccountSyncingEnabled },\n options,\n );\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n return;\n }\n // Keep a record if erroneous situations are found during the sync\n // This is done so we can send the context to Sentry in case of an erroneous situation\n let erroneousSituationsFound = false;\n\n // Prepare an array of internal accounts to be saved to the user storage\n const internalAccountsToBeSavedToUserStorage: InternalAccount[] = [];\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreUserStorageAccountsThanInternalAccounts =\n userStorageAccountsList.length > internalAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts in user storage than internal accounts\n if (hasMoreUserStorageAccountsThanInternalAccounts) {\n const numberOfAccountsToAdd =\n Math.min(userStorageAccountsList.length, maxNumberOfAccountsToAdd) -\n internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n for (let i = 0; i < numberOfAccountsToAdd; i++) {\n await getMessenger().call('KeyringController:addNewAccount');\n onAccountAdded?.();\n }\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n const refreshedInternalAccountsList =\n await getInternalAccountsList(options);\n\n const newlyAddedAccounts = refreshedInternalAccountsList.filter(\n (account) =>\n !internalAccountsList.find((a) => a.address === account.address),\n );\n\n for (const internalAccount of refreshedInternalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n // If the account is not present in user storage\n // istanbul ignore next\n if (!userStorageAccount) {\n // If the account was just added in the previous step, skip saving it, it's likely to be a bogus account\n if (newlyAddedAccounts.includes(internalAccount)) {\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was added to the internal accounts list but was not present in the user storage accounts list',\n {\n internalAccount,\n userStorageAccount,\n newlyAddedAccounts,\n userStorageAccountsList,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n },\n );\n continue;\n }\n // Otherwise, it means that this internal account was present before the sync, and needs to be saved to the user storage\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // From this point on, we know that the account is present in\n // both the internal accounts list and the user storage accounts list\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n onAccountNameUpdated?.();\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt > userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n const areInternalAndUserStorageAccountNamesEqual =\n internalAccount.metadata.name === userStorageAccount.n;\n\n if (!areInternalAndUserStorageAccountNamesEqual) {\n onAccountNameUpdated?.();\n }\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n // Save the internal accounts list to the user storage\n if (internalAccountsToBeSavedToUserStorage.length) {\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsToBeSavedToUserStorage.map((account) => [\n account.address,\n JSON.stringify(mapInternalAccountToUserStorageAccount(account)),\n ]),\n );\n }\n\n // In case we have corrupted user storage with accounts that don't exist in the internal accounts list\n // Delete those accounts from the user storage\n const userStorageAccountsToBeDeleted = userStorageAccountsList.filter(\n (account) =>\n !refreshedInternalAccountsList.find((a) => a.address === account.a),\n );\n\n if (userStorageAccountsToBeDeleted.length) {\n await getUserStorageControllerInstance().performBatchDeleteStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n userStorageAccountsToBeDeleted.map((account) => account.a),\n );\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was present in the user storage accounts list but was not found in the internal accounts list after the sync',\n {\n userStorageAccountsToBeDeleted,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n userStorageAccountsList,\n },\n );\n }\n\n if (erroneousSituationsFound) {\n const [finalUserStorageAccountsList, finalInternalAccountsList] =\n await Promise.all([\n getUserStorageAccountsList(options),\n getInternalAccountsList(options),\n ]);\n\n const doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList =\n finalInternalAccountsList.every((account) =>\n finalUserStorageAccountsList?.some(\n (userStorageAccount) => userStorageAccount.a === account.address,\n ),\n );\n\n // istanbul ignore next\n const doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList =\n (finalUserStorageAccountsList?.length || 0) > maxNumberOfAccountsToAdd\n ? true\n : finalUserStorageAccountsList?.every((account) =>\n finalInternalAccountsList.some(\n (internalAccount) => internalAccount.address === account.a,\n ),\n );\n\n const doFinalListsMatch =\n doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList &&\n doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList;\n\n const context = {\n finalUserStorageAccountsList,\n finalInternalAccountsList,\n };\n if (doFinalListsMatch) {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, but final state matches the expected state',\n context,\n );\n } else {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, and final state does not match the expected state',\n context,\n );\n }\n }\n\n // We do this here and not in the finally statement because we want to make sure that\n // the accounts are saved / updated / deleted at least once before we set this flag\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n false,\n );\n }\n}\n"]}
@@ -2,6 +2,7 @@ import type { InternalAccount } from "@metamask/keyring-internal-api";
2
2
  import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.cjs";
3
3
  /**
4
4
  * Saves an individual internal account to the user storage.
5
+ *
5
6
  * @param internalAccount - The internal account to save
6
7
  * @param config - parameters used for saving the internal account
7
8
  * @param options - parameters used for saving the internal account
@@ -9,6 +10,7 @@ import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.cjs";
9
10
  export declare function saveInternalAccountToUserStorage(internalAccount: InternalAccount, config: AccountSyncingConfig, options: AccountSyncingOptions): Promise<void>;
10
11
  /**
11
12
  * Saves the list of internal accounts to the user storage.
13
+ *
12
14
  * @param config - parameters used for saving the list of internal accounts
13
15
  * @param options - parameters used for saving the list of internal accounts
14
16
  */
@@ -23,6 +25,7 @@ type SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {
23
25
  * Syncs the internal accounts list with the user storage accounts list.
24
26
  * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.
25
27
  * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.
28
+ *
26
29
  * @param config - parameters used for syncing the internal accounts list with the user storage accounts list
27
30
  * @param options - parameters used for syncing the internal accounts list with the user storage accounts list
28
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAQtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAO3E;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;GAIG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,KAAK,yCAAyC,GAAG,oBAAoB,GAAG;IACtE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,+BAA+B,CAAC,EAAE,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpC,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,EACjD,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiRf"}
1
+ {"version":3,"file":"controller-integration.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAQ3E;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;GAKG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,KAAK,yCAAyC,GAAG,oBAAoB,GAAG;IACtE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,+BAA+B,CAAC,EAAE,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpC,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,EACjD,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgRf"}
@@ -2,6 +2,7 @@ import type { InternalAccount } from "@metamask/keyring-internal-api";
2
2
  import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.mjs";
3
3
  /**
4
4
  * Saves an individual internal account to the user storage.
5
+ *
5
6
  * @param internalAccount - The internal account to save
6
7
  * @param config - parameters used for saving the internal account
7
8
  * @param options - parameters used for saving the internal account
@@ -9,6 +10,7 @@ import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.mjs";
9
10
  export declare function saveInternalAccountToUserStorage(internalAccount: InternalAccount, config: AccountSyncingConfig, options: AccountSyncingOptions): Promise<void>;
10
11
  /**
11
12
  * Saves the list of internal accounts to the user storage.
13
+ *
12
14
  * @param config - parameters used for saving the list of internal accounts
13
15
  * @param options - parameters used for saving the list of internal accounts
14
16
  */
@@ -23,6 +25,7 @@ type SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {
23
25
  * Syncs the internal accounts list with the user storage accounts list.
24
26
  * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.
25
27
  * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.
28
+ *
26
29
  * @param config - parameters used for syncing the internal accounts list with the user storage accounts list
27
30
  * @param options - parameters used for syncing the internal accounts list with the user storage accounts list
28
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAQtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAO3E;;;;;GAKG;AACH,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;GAIG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,KAAK,yCAAyC,GAAG,oBAAoB,GAAG;IACtE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,+BAA+B,CAAC,EAAE,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpC,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,EACjD,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiRf"}
1
+ {"version":3,"file":"controller-integration.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAQ3E;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;GAKG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,KAAK,yCAAyC,GAAG,oBAAoB,GAAG;IACtE,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,+BAA+B,CAAC,EAAE,CAChC,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpC,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,yCAAyC,EACjD,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgRf"}
@@ -1,9 +1,10 @@
1
1
  import { isEvmAccountType } from "@metamask/keyring-api";
2
- import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
3
2
  import { canPerformAccountSyncing, getInternalAccountsList, getUserStorageAccountsList } from "./sync-utils.mjs";
4
3
  import { doesInternalAccountHaveCorrectKeyringType, isNameDefaultAccountName, mapInternalAccountToUserStorageAccount } from "./utils.mjs";
4
+ import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
5
5
  /**
6
6
  * Saves an individual internal account to the user storage.
7
+ *
7
8
  * @param internalAccount - The internal account to save
8
9
  * @param config - parameters used for saving the internal account
9
10
  * @param options - parameters used for saving the internal account
@@ -22,7 +23,6 @@ export async function saveInternalAccountToUserStorage(internalAccount, config,
22
23
  const mappedAccount = mapInternalAccountToUserStorageAccount(internalAccount);
23
24
  await getUserStorageControllerInstance().performSetStorage(
24
25
  // ESLint is confused here.
25
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
26
26
  `${USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`, JSON.stringify(mappedAccount));
27
27
  }
28
28
  catch (e) {
@@ -33,6 +33,7 @@ export async function saveInternalAccountToUserStorage(internalAccount, config,
33
33
  }
34
34
  /**
35
35
  * Saves the list of internal accounts to the user storage.
36
+ *
36
37
  * @param config - parameters used for saving the list of internal accounts
37
38
  * @param options - parameters used for saving the list of internal accounts
38
39
  */
@@ -56,6 +57,7 @@ export async function saveInternalAccountsListToUserStorage(config, options) {
56
57
  * Syncs the internal accounts list with the user storage accounts list.
57
58
  * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.
58
59
  * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.
60
+ *
59
61
  * @param config - parameters used for syncing the internal accounts list with the user storage accounts list
60
62
  * @param options - parameters used for syncing the internal accounts list with the user storage accounts list
61
63
  */
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],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AC;YAER,MAAM,iBAAiB,GACrB,oEAAoE;gBACpE,oEAAoE,CAAC;YAEvE,MAAM,OAAO,GAAG;gBACd,4BAA4B;gBAC5B,yBAAyB;aAC1B,CAAC;YACF,IAAI,iBAAiB,EAAE;gBACrB,+BAA+B,EAAE,CAC/B,6FAA6F,EAC7F,OAAO,CACR,CAAC;aACH;iBAAM;gBACL,+BAA+B,EAAE,CAC/B,oGAAoG,EACpG,OAAO,CACR,CAAC;aACH;SACF;QAED,qFAAqF;QACrF,mFAAmF;QACnF,MAAM,gCAAgC,EAAE,CAAC,qCAAqC,CAC5E,IAAI,CACL,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;QACvB,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,uEAAuE,YAAY,EAAE,CACtF,CAAC;KACH;YAAS;QACR,MAAM,gCAAgC,EAAE,CAAC,6BAA6B,CACpE,KAAK,CACN,CAAC;KACH;AACH,CAAC","sourcesContent":["import { isEvmAccountType } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport {\n canPerformAccountSyncing,\n getInternalAccountsList,\n getUserStorageAccountsList,\n} from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\nimport {\n doesInternalAccountHaveCorrectKeyringType,\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './utils';\n\n/**\n * Saves an individual internal account to the user storage.\n * @param internalAccount - The internal account to save\n * @param config - parameters used for saving the internal account\n * @param options - parameters used for saving the internal account\n */\nexport async function saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (\n !isAccountSyncingEnabled ||\n !canPerformAccountSyncing(config, options) ||\n !isEvmAccountType(internalAccount.type) ||\n !doesInternalAccountHaveCorrectKeyringType(internalAccount)\n ) {\n return;\n }\n\n try {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await getUserStorageControllerInstance().performSetStorage(\n // ESLint is confused here.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `${USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to save account to user storage - ${errorMessage}`,\n );\n }\n}\n\n/**\n * Saves the list of internal accounts to the user storage.\n * @param config - parameters used for saving the list of internal accounts\n * @param options - parameters used for saving the list of internal accounts\n */\nexport async function saveInternalAccountsListToUserStorage(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (!isAccountSyncingEnabled) {\n return;\n }\n\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList?.length) {\n return;\n }\n\n const internalAccountsListFormattedForUserStorage = internalAccountsList.map(\n mapInternalAccountToUserStorageAccount,\n );\n\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsListFormattedForUserStorage.map((account) => [\n account.a,\n JSON.stringify(account),\n ]),\n );\n}\n\ntype SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {\n maxNumberOfAccountsToAdd?: number;\n onAccountAdded?: () => void;\n onAccountNameUpdated?: () => void;\n onAccountSyncErroneousSituation?: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n};\n\n/**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n * @param config - parameters used for syncing the internal accounts list with the user storage accounts list\n * @param options - parameters used for syncing the internal accounts list with the user storage accounts list\n */\nexport async function syncInternalAccountsWithUserStorage(\n config: SyncInternalAccountsWithUserStorageConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n\n if (!canPerformAccountSyncing(config, options) || !isAccountSyncingEnabled) {\n return;\n }\n\n const {\n maxNumberOfAccountsToAdd = 100,\n onAccountAdded,\n onAccountNameUpdated,\n onAccountSyncErroneousSituation,\n } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n try {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n true,\n );\n\n const userStorageAccountsList = await getUserStorageAccountsList(options);\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await saveInternalAccountsListToUserStorage(\n { isAccountSyncingEnabled },\n options,\n );\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n return;\n }\n // Keep a record if erroneous situations are found during the sync\n // This is done so we can send the context to Sentry in case of an erroneous situation\n let erroneousSituationsFound = false;\n\n // Prepare an array of internal accounts to be saved to the user storage\n const internalAccountsToBeSavedToUserStorage: InternalAccount[] = [];\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreUserStorageAccountsThanInternalAccounts =\n userStorageAccountsList.length > internalAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts in user storage than internal accounts\n if (hasMoreUserStorageAccountsThanInternalAccounts) {\n const numberOfAccountsToAdd =\n Math.min(userStorageAccountsList.length, maxNumberOfAccountsToAdd) -\n internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n for (let i = 0; i < numberOfAccountsToAdd; i++) {\n await getMessenger().call('KeyringController:addNewAccount');\n onAccountAdded?.();\n }\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n const refreshedInternalAccountsList = await getInternalAccountsList(\n options,\n );\n\n const newlyAddedAccounts = refreshedInternalAccountsList.filter(\n (account) =>\n !internalAccountsList.find((a) => a.address === account.address),\n );\n\n for (const internalAccount of refreshedInternalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n // If the account is not present in user storage\n // istanbul ignore next\n if (!userStorageAccount) {\n // If the account was just added in the previous step, skip saving it, it's likely to be a bogus account\n if (newlyAddedAccounts.includes(internalAccount)) {\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was added to the internal accounts list but was not present in the user storage accounts list',\n {\n internalAccount,\n userStorageAccount,\n newlyAddedAccounts,\n userStorageAccountsList,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n },\n );\n continue;\n }\n // Otherwise, it means that this internal account was present before the sync, and needs to be saved to the user storage\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // From this point on, we know that the account is present in\n // both the internal accounts list and the user storage accounts list\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n onAccountNameUpdated?.();\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt > userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n const areInternalAndUserStorageAccountNamesEqual =\n internalAccount.metadata.name === userStorageAccount.n;\n\n if (!areInternalAndUserStorageAccountNamesEqual) {\n onAccountNameUpdated?.();\n }\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n // Save the internal accounts list to the user storage\n if (internalAccountsToBeSavedToUserStorage.length) {\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsToBeSavedToUserStorage.map((account) => [\n account.address,\n JSON.stringify(mapInternalAccountToUserStorageAccount(account)),\n ]),\n );\n }\n\n // In case we have corrupted user storage with accounts that don't exist in the internal accounts list\n // Delete those accounts from the user storage\n const userStorageAccountsToBeDeleted = userStorageAccountsList.filter(\n (account) =>\n !refreshedInternalAccountsList.find((a) => a.address === account.a),\n );\n\n if (userStorageAccountsToBeDeleted.length) {\n await getUserStorageControllerInstance().performBatchDeleteStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n userStorageAccountsToBeDeleted.map((account) => account.a),\n );\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was present in the user storage accounts list but was not found in the internal accounts list after the sync',\n {\n userStorageAccountsToBeDeleted,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n userStorageAccountsList,\n },\n );\n }\n\n if (erroneousSituationsFound) {\n const [finalUserStorageAccountsList, finalInternalAccountsList] =\n await Promise.all([\n getUserStorageAccountsList(options),\n getInternalAccountsList(options),\n ]);\n\n const doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList =\n finalInternalAccountsList.every((account) =>\n finalUserStorageAccountsList?.some(\n (userStorageAccount) => userStorageAccount.a === account.address,\n ),\n );\n\n // istanbul ignore next\n const doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList =\n (finalUserStorageAccountsList?.length || 0) > maxNumberOfAccountsToAdd\n ? true\n : finalUserStorageAccountsList?.every((account) =>\n finalInternalAccountsList.some(\n (internalAccount) => internalAccount.address === account.a,\n ),\n );\n\n const doFinalListsMatch =\n doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList &&\n doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList;\n\n const context = {\n finalUserStorageAccountsList,\n finalInternalAccountsList,\n };\n if (doFinalListsMatch) {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, but final state matches the expected state',\n context,\n );\n } else {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, and final state does not match the expected state',\n context,\n );\n }\n }\n\n // We do this here and not in the finally statement because we want to make sure that\n // the accounts are saved / updated / deleted at least once before we set this flag\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n false,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"controller-integration.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/controller-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AAGzD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0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yB;aAC1B,CAAC;YACF,IAAI,iBAAiB,EAAE;gBACrB,+BAA+B,EAAE,CAC/B,6FAA6F,EAC7F,OAAO,CACR,CAAC;aACH;iBAAM;gBACL,+BAA+B,EAAE,CAC/B,oGAAoG,EACpG,OAAO,CACR,CAAC;aACH;SACF;QAED,qFAAqF;QACrF,mFAAmF;QACnF,MAAM,gCAAgC,EAAE,CAAC,qCAAqC,CAC5E,IAAI,CACL,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;QACvB,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,uEAAuE,YAAY,EAAE,CACtF,CAAC;KACH;YAAS;QACR,MAAM,gCAAgC,EAAE,CAAC,6BAA6B,CACpE,KAAK,CACN,CAAC;KACH;AACH,CAAC","sourcesContent":["import { isEvmAccountType } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n canPerformAccountSyncing,\n getInternalAccountsList,\n getUserStorageAccountsList,\n} from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\nimport {\n doesInternalAccountHaveCorrectKeyringType,\n isNameDefaultAccountName,\n mapInternalAccountToUserStorageAccount,\n} from './utils';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Saves an individual internal account to the user storage.\n *\n * @param internalAccount - The internal account to save\n * @param config - parameters used for saving the internal account\n * @param options - parameters used for saving the internal account\n */\nexport async function saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (\n !isAccountSyncingEnabled ||\n !canPerformAccountSyncing(config, options) ||\n !isEvmAccountType(internalAccount.type) ||\n !doesInternalAccountHaveCorrectKeyringType(internalAccount)\n ) {\n return;\n }\n\n try {\n // Map the internal account to the user storage account schema\n const mappedAccount =\n mapInternalAccountToUserStorageAccount(internalAccount);\n\n await getUserStorageControllerInstance().performSetStorage(\n // ESLint is confused here.\n\n `${USER_STORAGE_FEATURE_NAMES.accounts}.${internalAccount.address}`,\n JSON.stringify(mappedAccount),\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to save account to user storage - ${errorMessage}`,\n );\n }\n}\n\n/**\n * Saves the list of internal accounts to the user storage.\n *\n * @param config - parameters used for saving the list of internal accounts\n * @param options - parameters used for saving the list of internal accounts\n */\nexport async function saveInternalAccountsListToUserStorage(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n const { getUserStorageControllerInstance } = options;\n\n if (!isAccountSyncingEnabled) {\n return;\n }\n\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList?.length) {\n return;\n }\n\n const internalAccountsListFormattedForUserStorage = internalAccountsList.map(\n mapInternalAccountToUserStorageAccount,\n );\n\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsListFormattedForUserStorage.map((account) => [\n account.a,\n JSON.stringify(account),\n ]),\n );\n}\n\ntype SyncInternalAccountsWithUserStorageConfig = AccountSyncingConfig & {\n maxNumberOfAccountsToAdd?: number;\n onAccountAdded?: () => void;\n onAccountNameUpdated?: () => void;\n onAccountSyncErroneousSituation?: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n};\n\n/**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n *\n * @param config - parameters used for syncing the internal accounts list with the user storage accounts list\n * @param options - parameters used for syncing the internal accounts list with the user storage accounts list\n */\nexport async function syncInternalAccountsWithUserStorage(\n config: SyncInternalAccountsWithUserStorageConfig,\n options: AccountSyncingOptions,\n): Promise<void> {\n const { isAccountSyncingEnabled } = config;\n\n if (!canPerformAccountSyncing(config, options) || !isAccountSyncingEnabled) {\n return;\n }\n\n const {\n maxNumberOfAccountsToAdd = 100,\n onAccountAdded,\n onAccountNameUpdated,\n onAccountSyncErroneousSituation,\n } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n try {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n true,\n );\n\n const userStorageAccountsList = await getUserStorageAccountsList(options);\n\n if (!userStorageAccountsList || !userStorageAccountsList.length) {\n await saveInternalAccountsListToUserStorage(\n { isAccountSyncingEnabled },\n options,\n );\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n return;\n }\n // Keep a record if erroneous situations are found during the sync\n // This is done so we can send the context to Sentry in case of an erroneous situation\n let erroneousSituationsFound = false;\n\n // Prepare an array of internal accounts to be saved to the user storage\n const internalAccountsToBeSavedToUserStorage: InternalAccount[] = [];\n\n // Compare internal accounts list with user storage accounts list\n // First step: compare lengths\n const internalAccountsList = await getInternalAccountsList(options);\n\n if (!internalAccountsList || !internalAccountsList.length) {\n throw new Error(`Failed to get internal accounts list`);\n }\n\n const hasMoreUserStorageAccountsThanInternalAccounts =\n userStorageAccountsList.length > internalAccountsList.length;\n\n // We don't want to remove existing accounts for a user\n // so we only add new accounts if the user has more accounts in user storage than internal accounts\n if (hasMoreUserStorageAccountsThanInternalAccounts) {\n const numberOfAccountsToAdd =\n Math.min(userStorageAccountsList.length, maxNumberOfAccountsToAdd) -\n internalAccountsList.length;\n\n // Create new accounts to match the user storage accounts list\n for (let i = 0; i < numberOfAccountsToAdd; i++) {\n await getMessenger().call('KeyringController:addNewAccount');\n onAccountAdded?.();\n }\n }\n\n // Second step: compare account names\n // Get the internal accounts list again since new accounts might have been added in the previous step\n const refreshedInternalAccountsList =\n await getInternalAccountsList(options);\n\n const newlyAddedAccounts = refreshedInternalAccountsList.filter(\n (account) =>\n !internalAccountsList.find((a) => a.address === account.address),\n );\n\n for (const internalAccount of refreshedInternalAccountsList) {\n const userStorageAccount = userStorageAccountsList.find(\n (account) => account.a === internalAccount.address,\n );\n\n // If the account is not present in user storage\n // istanbul ignore next\n if (!userStorageAccount) {\n // If the account was just added in the previous step, skip saving it, it's likely to be a bogus account\n if (newlyAddedAccounts.includes(internalAccount)) {\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was added to the internal accounts list but was not present in the user storage accounts list',\n {\n internalAccount,\n userStorageAccount,\n newlyAddedAccounts,\n userStorageAccountsList,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n },\n );\n continue;\n }\n // Otherwise, it means that this internal account was present before the sync, and needs to be saved to the user storage\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // From this point on, we know that the account is present in\n // both the internal accounts list and the user storage accounts list\n\n // One or both accounts have default names\n const isInternalAccountNameDefault = isNameDefaultAccountName(\n internalAccount.metadata.name,\n );\n const isUserStorageAccountNameDefault = isNameDefaultAccountName(\n userStorageAccount.n,\n );\n\n // Internal account has default name\n if (isInternalAccountNameDefault) {\n if (!isUserStorageAccountNameDefault) {\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n },\n );\n\n onAccountNameUpdated?.();\n }\n continue;\n }\n\n // Internal account has custom name but user storage account has default name\n if (isUserStorageAccountNameDefault) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n\n // Both accounts have custom names\n\n // User storage account has a nameLastUpdatedAt timestamp\n // Note: not storing the undefined checks in constants to act as a type guard\n if (userStorageAccount.nlu !== undefined) {\n if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n const isInternalAccountNameNewer =\n internalAccount.metadata.nameLastUpdatedAt > userStorageAccount.nlu;\n\n if (isInternalAccountNameNewer) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n getMessenger().call(\n 'AccountsController:updateAccountMetadata',\n internalAccount.id,\n {\n name: userStorageAccount.n,\n nameLastUpdatedAt: userStorageAccount.nlu,\n },\n );\n\n const areInternalAndUserStorageAccountNamesEqual =\n internalAccount.metadata.name === userStorageAccount.n;\n\n if (!areInternalAndUserStorageAccountNamesEqual) {\n onAccountNameUpdated?.();\n }\n\n continue;\n } else if (internalAccount.metadata.nameLastUpdatedAt !== undefined) {\n internalAccountsToBeSavedToUserStorage.push(internalAccount);\n continue;\n }\n }\n\n // Save the internal accounts list to the user storage\n if (internalAccountsToBeSavedToUserStorage.length) {\n await getUserStorageControllerInstance().performBatchSetStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n internalAccountsToBeSavedToUserStorage.map((account) => [\n account.address,\n JSON.stringify(mapInternalAccountToUserStorageAccount(account)),\n ]),\n );\n }\n\n // In case we have corrupted user storage with accounts that don't exist in the internal accounts list\n // Delete those accounts from the user storage\n const userStorageAccountsToBeDeleted = userStorageAccountsList.filter(\n (account) =>\n !refreshedInternalAccountsList.find((a) => a.address === account.a),\n );\n\n if (userStorageAccountsToBeDeleted.length) {\n await getUserStorageControllerInstance().performBatchDeleteStorage(\n USER_STORAGE_FEATURE_NAMES.accounts,\n userStorageAccountsToBeDeleted.map((account) => account.a),\n );\n erroneousSituationsFound = true;\n onAccountSyncErroneousSituation?.(\n 'An account was present in the user storage accounts list but was not found in the internal accounts list after the sync',\n {\n userStorageAccountsToBeDeleted,\n internalAccountsList,\n refreshedInternalAccountsList,\n internalAccountsToBeSavedToUserStorage,\n userStorageAccountsList,\n },\n );\n }\n\n if (erroneousSituationsFound) {\n const [finalUserStorageAccountsList, finalInternalAccountsList] =\n await Promise.all([\n getUserStorageAccountsList(options),\n getInternalAccountsList(options),\n ]);\n\n const doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList =\n finalInternalAccountsList.every((account) =>\n finalUserStorageAccountsList?.some(\n (userStorageAccount) => userStorageAccount.a === account.address,\n ),\n );\n\n // istanbul ignore next\n const doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList =\n (finalUserStorageAccountsList?.length || 0) > maxNumberOfAccountsToAdd\n ? true\n : finalUserStorageAccountsList?.every((account) =>\n finalInternalAccountsList.some(\n (internalAccount) => internalAccount.address === account.a,\n ),\n );\n\n const doFinalListsMatch =\n doesEveryAccountInInternalAccountsListExistInUserStorageAccountsList &&\n doesEveryAccountInUserStorageAccountsListExistInInternalAccountsList;\n\n const context = {\n finalUserStorageAccountsList,\n finalInternalAccountsList,\n };\n if (doFinalListsMatch) {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, but final state matches the expected state',\n context,\n );\n } else {\n onAccountSyncErroneousSituation?.(\n 'Erroneous situations were found during the sync, and final state does not match the expected state',\n context,\n );\n }\n }\n\n // We do this here and not in the finally statement because we want to make sure that\n // the accounts are saved / updated / deleted at least once before we set this flag\n await getUserStorageControllerInstance().setHasAccountSyncingSyncedAtLeastOnce(\n true,\n );\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `UserStorageController - failed to sync user storage accounts list - ${errorMessage}`,\n );\n } finally {\n await getUserStorageControllerInstance().setIsAccountSyncingInProgress(\n false,\n );\n }\n}\n"]}
@@ -5,14 +5,13 @@ const controller_integration_1 = require("./controller-integration.cjs");
5
5
  const sync_utils_1 = require("./sync-utils.cjs");
6
6
  /**
7
7
  * Initialize and setup events to listen to for account syncing
8
+ *
8
9
  * @param config - configuration parameters
9
10
  * @param options - parameters used for initializing and enabling account syncing
10
11
  */
11
12
  function setupAccountSyncingSubscriptions(config, options) {
12
13
  const { getMessenger, getUserStorageControllerInstance } = options;
13
- getMessenger().subscribe('AccountsController:accountAdded',
14
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
15
- async (account) => {
14
+ getMessenger().subscribe('AccountsController:accountAdded', async (account) => {
16
15
  if (!(0, sync_utils_1.canPerformAccountSyncing)(config, options) ||
17
16
  !getUserStorageControllerInstance().state
18
17
  .hasAccountSyncingSyncedAtLeastOnce) {
@@ -20,9 +19,7 @@ function setupAccountSyncingSubscriptions(config, options) {
20
19
  }
21
20
  await (0, controller_integration_1.saveInternalAccountToUserStorage)(account, config, options);
22
21
  });
23
- getMessenger().subscribe('AccountsController:accountRenamed',
24
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
25
- async (account) => {
22
+ getMessenger().subscribe('AccountsController:accountRenamed', async (account) => {
26
23
  if (!(0, sync_utils_1.canPerformAccountSyncing)(config, options) ||
27
24
  !getUserStorageControllerInstance().state
28
25
  .hasAccountSyncingSyncedAtLeastOnce) {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-subscriptions.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":";;;AAAA,yEAA4E;AAC5E,iDAAwD;AAGxD;;;;GAIG;AACH,SAAgB,gCAAgC,CAC9C,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,YAAY,EAAE,CAAC,SAAS,CACtB,iCAAiC;IACjC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,IAAA,qCAAwB,EAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,IAAA,yDAAgC,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC;IACnC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,IAAA,qCAAwB,EAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,IAAA,yDAAgC,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC;AArCD,4EAqCC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n * @param config - configuration parameters\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n getMessenger().subscribe(\n 'AccountsController:accountAdded',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n}\n"]}
1
+ {"version":3,"file":"setup-subscriptions.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":";;;AAAA,yEAA4E;AAC5E,iDAAwD;AAGxD;;;;;GAKG;AACH,SAAgB,gCAAgC,CAC9C,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,YAAY,EAAE,CAAC,SAAS,CACtB,iCAAiC,EAEjC,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,IAAA,qCAAwB,EAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,IAAA,yDAAgC,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC,EAEnC,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,IAAA,qCAAwB,EAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,IAAA,yDAAgC,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC;AArCD,4EAqCC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n *\n * @param config - configuration parameters\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n getMessenger().subscribe(\n 'AccountsController:accountAdded',\n\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.cjs";
2
2
  /**
3
3
  * Initialize and setup events to listen to for account syncing
4
+ *
4
5
  * @param config - configuration parameters
5
6
  * @param options - parameters used for initializing and enabling account syncing
6
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"setup-subscriptions.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAE3E;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,QAmC/B"}
1
+ {"version":3,"file":"setup-subscriptions.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAE3E;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,QAmC/B"}
@@ -1,6 +1,7 @@
1
1
  import type { AccountSyncingConfig, AccountSyncingOptions } from "./types.mjs";
2
2
  /**
3
3
  * Initialize and setup events to listen to for account syncing
4
+ *
4
5
  * @param config - configuration parameters
5
6
  * @param options - parameters used for initializing and enabling account syncing
6
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"setup-subscriptions.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAE3E;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,QAmC/B"}
1
+ {"version":3,"file":"setup-subscriptions.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAgB;AAE3E;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,QAmC/B"}
@@ -2,14 +2,13 @@ import { saveInternalAccountToUserStorage } from "./controller-integration.mjs";
2
2
  import { canPerformAccountSyncing } from "./sync-utils.mjs";
3
3
  /**
4
4
  * Initialize and setup events to listen to for account syncing
5
+ *
5
6
  * @param config - configuration parameters
6
7
  * @param options - parameters used for initializing and enabling account syncing
7
8
  */
8
9
  export function setupAccountSyncingSubscriptions(config, options) {
9
10
  const { getMessenger, getUserStorageControllerInstance } = options;
10
- getMessenger().subscribe('AccountsController:accountAdded',
11
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
12
- async (account) => {
11
+ getMessenger().subscribe('AccountsController:accountAdded', async (account) => {
13
12
  if (!canPerformAccountSyncing(config, options) ||
14
13
  !getUserStorageControllerInstance().state
15
14
  .hasAccountSyncingSyncedAtLeastOnce) {
@@ -17,9 +16,7 @@ export function setupAccountSyncingSubscriptions(config, options) {
17
16
  }
18
17
  await saveInternalAccountToUserStorage(account, config, options);
19
18
  });
20
- getMessenger().subscribe('AccountsController:accountRenamed',
21
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
22
- async (account) => {
19
+ getMessenger().subscribe('AccountsController:accountRenamed', async (account) => {
23
20
  if (!canPerformAccountSyncing(config, options) ||
24
21
  !getUserStorageControllerInstance().state
25
22
  .hasAccountSyncingSyncedAtLeastOnce) {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,qCAAiC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,YAAY,EAAE,CAAC,SAAS,CACtB,iCAAiC;IACjC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC;IACnC,kEAAkE;IAClE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n * @param config - configuration parameters\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n getMessenger().subscribe(\n 'AccountsController:accountAdded',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n}\n"]}
1
+ {"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,qCAAiC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,YAAY,EAAE,CAAC,SAAS,CACtB,iCAAiC,EAEjC,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;IAEF,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC,EAEnC,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;YAC1C,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingConfig, AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n *\n * @param config - configuration parameters\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n getMessenger().subscribe(\n 'AccountsController:accountAdded',\n\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n\n async (account) => {\n if (\n !canPerformAccountSyncing(config, options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, config, options);\n },\n );\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUserStorageAccountsList = exports.getInternalAccountsList = exports.canPerformAccountSyncing = void 0;
4
- const storage_schema_1 = require("../../../shared/storage-schema.cjs");
5
4
  const utils_1 = require("./utils.cjs");
5
+ const storage_schema_1 = require("../../../shared/storage-schema.cjs");
6
6
  /**
7
7
  * Checks if account syncing can be performed based on a set of conditions
8
+ *
8
9
  * @param config - configuration parameters
9
10
  * @param options - parameters used for checking if account syncing can be performed
10
11
  * @returns Returns true if account syncing can be performed, false otherwise.
@@ -25,18 +26,21 @@ function canPerformAccountSyncing(config, options) {
25
26
  exports.canPerformAccountSyncing = canPerformAccountSyncing;
26
27
  /**
27
28
  * Get the list of internal accounts
29
+ *
28
30
  * @param options - parameters used for getting the list of internal accounts
31
+ * @returns the list of internal accounts
29
32
  */
30
33
  async function getInternalAccountsList(options) {
31
34
  const { getMessenger } = options;
32
- // eslint-disable-next-line @typescript-eslint/await-thenable
33
35
  const internalAccountsList = await getMessenger().call('AccountsController:listAccounts');
34
36
  return internalAccountsList?.filter(utils_1.doesInternalAccountHaveCorrectKeyringType);
35
37
  }
36
38
  exports.getInternalAccountsList = getInternalAccountsList;
37
39
  /**
38
40
  * Get the list of user storage accounts
41
+ *
39
42
  * @param options - parameters used for getting the list of user storage accounts
43
+ * @returns the list of user storage accounts
40
44
  */
41
45
  async function getUserStorageAccountsList(options) {
42
46
  const { getUserStorageControllerInstance } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":";;;AAEA,uEAA4E;AAM5E,uCAAoE;AAEpE;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,GAC3D,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC3C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,CAAC,uBAAuB;QACxB,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAvBD,4DAuBC;AAED;;;GAGG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,6DAA6D;IAC7D,MAAM,oBAAoB,GAAG,MAAM,YAAY,EAAE,CAAC,IAAI,CACpD,iCAAiC,CAClC,CAAC;IAEF,OAAO,oBAAoB,EAAE,MAAM,CACjC,iDAAyC,CAC1C,CAAC;AACJ,CAAC;AAbD,0DAaC;AAED;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC9C,OAA8B;IAE9B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,2CAA0B,CAAC,QAAQ,CACpC,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC;AAbD,gEAaC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type {\n AccountSyncingConfig,\n AccountSyncingOptions,\n UserStorageAccount,\n} from './types';\nimport { doesInternalAccountHaveCorrectKeyringType } from './utils';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n * @param config - configuration parameters\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): boolean {\n const { isAccountSyncingEnabled } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const { isProfileSyncingEnabled, isAccountSyncingInProgress } =\n getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isProfileSyncingEnabled ||\n !isAuthEnabled ||\n !isAccountSyncingEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * @param options - parameters used for getting the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n const internalAccountsList = await getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n return internalAccountsList?.filter(\n doesInternalAccountHaveCorrectKeyringType,\n );\n}\n\n/**\n * Get the list of user storage accounts\n * @param options - parameters used for getting the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
1
+ {"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":";;;AAOA,uCAAoE;AACpE,uEAA4E;AAE5E;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,MAA4B,EAC5B,OAA8B;IAE9B,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,GAC3D,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC3C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,CAAC,uBAAuB;QACxB,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAvBD,4DAuBC;AAED;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,MAAM,oBAAoB,GAAG,MAAM,YAAY,EAAE,CAAC,IAAI,CACpD,iCAAiC,CAClC,CAAC;IAEF,OAAO,oBAAoB,EAAE,MAAM,CACjC,iDAAyC,CAC1C,CAAC;AACJ,CAAC;AAZD,0DAYC;AAED;;;;;GAKG;AACI,KAAK,UAAU,0BAA0B,CAC9C,OAA8B;IAE9B,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,2CAA0B,CAAC,QAAQ,CACpC,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC;AAbD,gEAaC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type {\n AccountSyncingConfig,\n AccountSyncingOptions,\n UserStorageAccount,\n} from './types';\nimport { doesInternalAccountHaveCorrectKeyringType } from './utils';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n *\n * @param config - configuration parameters\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n config: AccountSyncingConfig,\n options: AccountSyncingOptions,\n): boolean {\n const { isAccountSyncingEnabled } = config;\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const { isProfileSyncingEnabled, isAccountSyncingInProgress } =\n getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isProfileSyncingEnabled ||\n !isAuthEnabled ||\n !isAccountSyncingEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n *\n * @param options - parameters used for getting the list of internal accounts\n * @returns the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n const internalAccountsList = await getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n return internalAccountsList?.filter(\n doesInternalAccountHaveCorrectKeyringType,\n );\n}\n\n/**\n * Get the list of user storage accounts\n *\n * @param options - parameters used for getting the list of user storage accounts\n * @returns the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
@@ -2,6 +2,7 @@ import type { InternalAccount } from "@metamask/keyring-internal-api";
2
2
  import type { AccountSyncingConfig, AccountSyncingOptions, UserStorageAccount } from "./types.cjs";
3
3
  /**
4
4
  * Checks if account syncing can be performed based on a set of conditions
5
+ *
5
6
  * @param config - configuration parameters
6
7
  * @param options - parameters used for checking if account syncing can be performed
7
8
  * @returns Returns true if account syncing can be performed, false otherwise.
@@ -9,12 +10,16 @@ import type { AccountSyncingConfig, AccountSyncingOptions, UserStorageAccount }
9
10
  export declare function canPerformAccountSyncing(config: AccountSyncingConfig, options: AccountSyncingOptions): boolean;
10
11
  /**
11
12
  * Get the list of internal accounts
13
+ *
12
14
  * @param options - parameters used for getting the list of internal accounts
15
+ * @returns the list of internal accounts
13
16
  */
14
17
  export declare function getInternalAccountsList(options: AccountSyncingOptions): Promise<InternalAccount[]>;
15
18
  /**
16
19
  * Get the list of user storage accounts
20
+ *
17
21
  * @param options - parameters used for getting the list of user storage accounts
22
+ * @returns the list of user storage accounts
18
23
  */
19
24
  export declare function getUserStorageAccountsList(options: AccountSyncingOptions): Promise<UserStorageAccount[] | null>;
20
25
  //# sourceMappingURL=sync-utils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EACnB,oBAAgB;AAGjB;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAoBT;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAW5B;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAWtC"}
1
+ {"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EACnB,oBAAgB;AAIjB;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAoBT;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CAU5B;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAWtC"}