@metamask-previews/profile-sync-controller 5.0.0-preview-33c13522 → 5.0.0-preview-59b4e66e

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 (236) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  3. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  4. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +0 -5
  5. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -1
  6. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -1
  7. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -1
  8. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +0 -5
  9. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -1
  10. package/dist/controllers/authentication/services.cjs +0 -2
  11. package/dist/controllers/authentication/services.cjs.map +1 -1
  12. package/dist/controllers/authentication/services.d.cts +5 -3
  13. package/dist/controllers/authentication/services.d.cts.map +1 -1
  14. package/dist/controllers/authentication/services.d.mts +5 -3
  15. package/dist/controllers/authentication/services.d.mts.map +1 -1
  16. package/dist/controllers/authentication/services.mjs +0 -2
  17. package/dist/controllers/authentication/services.mjs.map +1 -1
  18. package/dist/controllers/user-storage/UserStorageController.cjs +5 -2
  19. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  20. package/dist/controllers/user-storage/UserStorageController.d.cts +4 -0
  21. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  22. package/dist/controllers/user-storage/UserStorageController.d.mts +4 -0
  23. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  24. package/dist/controllers/user-storage/UserStorageController.mjs +5 -2
  25. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  26. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +2 -0
  27. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +1 -1
  28. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +2 -0
  29. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +1 -1
  30. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +2 -0
  31. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +1 -1
  32. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +2 -0
  33. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +1 -1
  34. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +5 -1
  35. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -1
  36. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts +4 -0
  37. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -1
  38. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +4 -0
  39. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -1
  40. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +5 -1
  41. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -1
  42. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +1 -1
  43. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -1
  44. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -1
  45. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -1
  46. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +1 -1
  47. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -1
  48. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +5 -2
  49. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -1
  50. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +3 -0
  51. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -1
  52. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +3 -0
  53. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -1
  54. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +5 -2
  55. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -1
  56. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs +2 -0
  57. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +1 -1
  58. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts +1 -0
  59. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +1 -1
  60. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts +1 -0
  61. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +1 -1
  62. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs +2 -0
  63. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +1 -1
  64. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +3 -1
  65. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +1 -1
  66. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +2 -0
  67. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +1 -1
  68. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +2 -0
  69. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +1 -1
  70. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +3 -1
  71. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +1 -1
  72. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +4 -2
  73. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
  74. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +3 -0
  75. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
  76. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +3 -0
  77. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
  78. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +4 -2
  79. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
  80. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +3 -6
  81. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -1
  82. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts +1 -0
  83. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -1
  84. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts +1 -0
  85. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -1
  86. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +3 -6
  87. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -1
  88. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +6 -2
  89. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
  90. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +5 -0
  91. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
  92. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +5 -0
  93. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
  94. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +6 -2
  95. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
  96. package/dist/controllers/user-storage/account-syncing/types.cjs.map +1 -1
  97. package/dist/controllers/user-storage/account-syncing/types.d.cts +1 -1
  98. package/dist/controllers/user-storage/account-syncing/types.d.cts.map +1 -1
  99. package/dist/controllers/user-storage/account-syncing/types.d.mts +1 -1
  100. package/dist/controllers/user-storage/account-syncing/types.d.mts.map +1 -1
  101. package/dist/controllers/user-storage/account-syncing/types.mjs.map +1 -1
  102. package/dist/controllers/user-storage/account-syncing/utils.cjs +3 -1
  103. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
  104. package/dist/controllers/user-storage/account-syncing/utils.d.cts +2 -0
  105. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
  106. package/dist/controllers/user-storage/account-syncing/utils.d.mts +2 -0
  107. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
  108. package/dist/controllers/user-storage/account-syncing/utils.mjs +3 -1
  109. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
  110. package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs +1 -0
  111. package/dist/controllers/user-storage/network-syncing/add-network-utils.cjs.map +1 -1
  112. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts +1 -0
  113. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.cts.map +1 -1
  114. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts +1 -0
  115. package/dist/controllers/user-storage/network-syncing/add-network-utils.d.mts.map +1 -1
  116. package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs +1 -0
  117. package/dist/controllers/user-storage/network-syncing/add-network-utils.mjs.map +1 -1
  118. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +3 -3
  119. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
  120. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +2 -0
  121. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
  122. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +2 -0
  123. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
  124. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +3 -3
  125. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
  126. package/dist/controllers/user-storage/network-syncing/services.cjs +5 -0
  127. package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
  128. package/dist/controllers/user-storage/network-syncing/services.d.cts +5 -1
  129. package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
  130. package/dist/controllers/user-storage/network-syncing/services.d.mts +5 -1
  131. package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
  132. package/dist/controllers/user-storage/network-syncing/services.mjs +5 -0
  133. package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
  134. package/dist/controllers/user-storage/network-syncing/sync-all.cjs +1 -1
  135. package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -1
  136. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -1
  137. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -1
  138. package/dist/controllers/user-storage/network-syncing/sync-all.mjs +1 -1
  139. package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -1
  140. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
  141. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
  142. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
  143. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
  144. package/dist/controllers/user-storage/network-syncing/update-network-utils.cjs +3 -0
  145. package/dist/controllers/user-storage/network-syncing/update-network-utils.cjs.map +1 -1
  146. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts +3 -0
  147. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.cts.map +1 -1
  148. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts +3 -0
  149. package/dist/controllers/user-storage/network-syncing/update-network-utils.d.mts.map +1 -1
  150. package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs +3 -0
  151. package/dist/controllers/user-storage/network-syncing/update-network-utils.mjs.map +1 -1
  152. package/dist/controllers/user-storage/services.cjs +0 -1
  153. package/dist/controllers/user-storage/services.cjs.map +1 -1
  154. package/dist/controllers/user-storage/services.d.cts.map +1 -1
  155. package/dist/controllers/user-storage/services.d.mts.map +1 -1
  156. package/dist/controllers/user-storage/services.mjs +0 -1
  157. package/dist/controllers/user-storage/services.mjs.map +1 -1
  158. package/dist/controllers/user-storage/utils.cjs +2 -0
  159. package/dist/controllers/user-storage/utils.cjs.map +1 -1
  160. package/dist/controllers/user-storage/utils.d.cts +2 -0
  161. package/dist/controllers/user-storage/utils.d.cts.map +1 -1
  162. package/dist/controllers/user-storage/utils.d.mts +2 -0
  163. package/dist/controllers/user-storage/utils.d.mts.map +1 -1
  164. package/dist/controllers/user-storage/utils.mjs +2 -0
  165. package/dist/controllers/user-storage/utils.mjs.map +1 -1
  166. package/dist/sdk/__fixtures__/mock-auth.cjs +0 -15
  167. package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -1
  168. package/dist/sdk/__fixtures__/mock-auth.mjs +0 -15
  169. package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -1
  170. package/dist/sdk/__fixtures__/mock-userstorage.cjs +0 -2
  171. package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -1
  172. package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -1
  173. package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -1
  174. package/dist/sdk/__fixtures__/mock-userstorage.mjs +0 -2
  175. package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -1
  176. package/dist/sdk/__fixtures__/test-utils.cjs +2 -1
  177. package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -1
  178. package/dist/sdk/__fixtures__/test-utils.d.cts +1 -0
  179. package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -1
  180. package/dist/sdk/__fixtures__/test-utils.d.mts +1 -0
  181. package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -1
  182. package/dist/sdk/__fixtures__/test-utils.mjs +2 -1
  183. package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -1
  184. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +1 -1
  185. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
  186. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
  187. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
  188. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +1 -1
  189. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  190. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +1 -1
  191. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  192. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  193. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  194. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +1 -1
  195. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  196. package/dist/sdk/authentication-jwt-bearer/services.cjs +1 -2
  197. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  198. package/dist/sdk/authentication-jwt-bearer/services.d.cts +1 -1
  199. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  200. package/dist/sdk/authentication-jwt-bearer/services.d.mts +1 -1
  201. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  202. package/dist/sdk/authentication-jwt-bearer/services.mjs +1 -2
  203. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  204. package/dist/sdk/authentication.cjs +0 -3
  205. package/dist/sdk/authentication.cjs.map +1 -1
  206. package/dist/sdk/authentication.d.cts.map +1 -1
  207. package/dist/sdk/authentication.d.mts.map +1 -1
  208. package/dist/sdk/authentication.mjs +0 -3
  209. package/dist/sdk/authentication.mjs.map +1 -1
  210. package/dist/sdk/user-storage.cjs +1 -3
  211. package/dist/sdk/user-storage.cjs.map +1 -1
  212. package/dist/sdk/user-storage.d.cts +1 -1
  213. package/dist/sdk/user-storage.d.cts.map +1 -1
  214. package/dist/sdk/user-storage.d.mts +1 -1
  215. package/dist/sdk/user-storage.d.mts.map +1 -1
  216. package/dist/sdk/user-storage.mjs +1 -3
  217. package/dist/sdk/user-storage.mjs.map +1 -1
  218. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +4 -4
  219. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -1
  220. package/dist/sdk/utils/eip-6963-metamask-provider.mjs +4 -4
  221. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
  222. package/dist/shared/encryption/constants.cjs +0 -2
  223. package/dist/shared/encryption/constants.cjs.map +1 -1
  224. package/dist/shared/encryption/constants.d.cts.map +1 -1
  225. package/dist/shared/encryption/constants.d.mts.map +1 -1
  226. package/dist/shared/encryption/constants.mjs +0 -2
  227. package/dist/shared/encryption/constants.mjs.map +1 -1
  228. package/dist/shared/encryption/encryption.cjs +1 -0
  229. package/dist/shared/encryption/encryption.cjs.map +1 -1
  230. package/dist/shared/encryption/encryption.d.cts +1 -0
  231. package/dist/shared/encryption/encryption.d.cts.map +1 -1
  232. package/dist/shared/encryption/encryption.d.mts +1 -0
  233. package/dist/shared/encryption/encryption.d.mts.map +1 -1
  234. package/dist/shared/encryption/encryption.mjs +1 -0
  235. package/dist/shared/encryption/encryption.mjs.map +1 -1
  236. package/package.json +6 -6
@@ -10,12 +10,14 @@ import type { UserStorageAccount } from "./types.cjs";
10
10
  export declare const isNameDefaultAccountName: (name: string) => boolean;
11
11
  /**
12
12
  * Map an internal account to a user storage account
13
+ *
13
14
  * @param internalAccount - An internal account
14
15
  * @returns A user storage account
15
16
  */
16
17
  export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
17
18
  /**
18
19
  * Checks if the given internal account has the correct keyring type.
20
+ *
19
21
  * @param account - The internal account to check
20
22
  * @returns Returns true if the internal account has the correct keyring type, false otherwise.
21
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
@@ -10,12 +10,14 @@ import type { UserStorageAccount } from "./types.mjs";
10
10
  export declare const isNameDefaultAccountName: (name: string) => boolean;
11
11
  /**
12
12
  * Map an internal account to a user storage account
13
+ *
13
14
  * @param internalAccount - An internal account
14
15
  * @returns A user storage account
15
16
  */
16
17
  export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
17
18
  /**
18
19
  * Checks if the given internal account has the correct keyring type.
20
+ *
19
21
  * @param account - The internal account to check
20
22
  * @returns Returns true if the internal account has the correct keyring type, false otherwise.
21
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,yCAAyC,CACvD,OAAO,EAAE,eAAe,WAGzB"}
@@ -14,6 +14,7 @@ export const isNameDefaultAccountName = (name) => {
14
14
  };
15
15
  /**
16
16
  * Map an internal account to a user storage account
17
+ *
17
18
  * @param internalAccount - An internal account
18
19
  * @returns A user storage account
19
20
  */
@@ -30,10 +31,11 @@ export const mapInternalAccountToUserStorageAccount = (internalAccount) => {
30
31
  };
31
32
  /**
32
33
  * Checks if the given internal account has the correct keyring type.
34
+ *
33
35
  * @param account - The internal account to check
34
36
  * @returns Returns true if the internal account has the correct keyring type, false otherwise.
35
37
  */
36
38
  export function doesInternalAccountHaveCorrectKeyringType(account) {
37
- return account.metadata.keyring.type === KeyringTypes.hd;
39
+ return account.metadata.keyring.type === String(KeyringTypes.hd);
38
40
  }
39
41
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,wBAAoB;AAGrB;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,oBAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAAwB;IAExB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n\n/**\n * Checks if the given internal account has the correct keyring type.\n * @param account - The internal account to check\n * @returns Returns true if the internal account has the correct keyring type, false otherwise.\n */\nexport function doesInternalAccountHaveCorrectKeyringType(\n account: InternalAccount,\n) {\n return account.metadata.keyring.type === KeyringTypes.hd;\n}\n"]}
1
+ {"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,wBAAoB;AAGrB;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,oBAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,yCAAyC,CACvD,OAAwB;IAExB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n *\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n\n/**\n * Checks if the given internal account has the correct keyring type.\n *\n * @param account - The internal account to check\n * @returns Returns true if the internal account has the correct keyring type, false otherwise.\n */\nexport function doesInternalAccountHaveCorrectKeyringType(\n account: InternalAccount,\n) {\n return account.metadata.keyring.type === String(KeyringTypes.hd);\n}\n"]}
@@ -5,6 +5,7 @@ exports.MAX_NETWORKS_SIZE = 50;
5
5
  /**
6
6
  * Calculates the available space to add new networks
7
7
  * exported for testability.
8
+ *
8
9
  * @param originalListSize - size of original list
9
10
  * @param maxSize - max size
10
11
  * @returns a positive number on the available space
@@ -1 +1 @@
1
- {"version":3,"file":"add-network-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACI,MAAM,4BAA4B,GAAG,CAC1C,gBAAwB,EACxB,OAAe,EACf,EAAE;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC;AACjD,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAAG,CACrC,gBAAwC,EACxC,aAAqC,EACrC,OAAO,GAAG,yBAAiB,EAC3B,EAAE;IACF,MAAM,cAAc,GAAG,IAAA,oCAA4B,EACjD,gBAAgB,CAAC,MAAM,EACvB,OAAO,CACR,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,CACvC,cAAc,EACd,aAAa,CAAC,MAAM,CACrB,CAAC;IAEF,yCAAyC;IACzC,6DAA6D;IAC7D,OAAO,aAAa;SACjB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAClD,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACxC,CAAC,CAAC;AAnBW,QAAA,uBAAuB,2BAmBlC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\n\nexport const MAX_NETWORKS_SIZE = 50;\n\n/**\n * Calculates the available space to add new networks\n * exported for testability.\n * @param originalListSize - size of original list\n * @param maxSize - max size\n * @returns a positive number on the available space\n */\nexport const calculateAvailableSpaceToAdd = (\n originalListSize: number,\n maxSize: number,\n) => {\n return Math.max(0, maxSize - originalListSize);\n};\n\n/**\n * Returns a bounded number of networks to add (set by a max bound)\n * The items will be ordered to give determinism on items to append (not random)\n *\n * @param originalNetworks - The original list of network configurations.\n * @param networksToAdd - The list of network configurations to add.\n * @param maxSize - The maximum allowed size of the list. Defaults to MAX_NETWORKS_SIZE.\n * @returns The networks to add, sorted by chainId.\n */\nexport const getBoundedNetworksToAdd = (\n originalNetworks: NetworkConfiguration[],\n networksToAdd: NetworkConfiguration[],\n maxSize = MAX_NETWORKS_SIZE,\n) => {\n const availableSpace = calculateAvailableSpaceToAdd(\n originalNetworks.length,\n maxSize,\n );\n const numberOfNetworksToAppend = Math.min(\n availableSpace,\n networksToAdd.length,\n );\n\n // Order and slice the networks to append\n // Ordering so we have some determinism on the order of items\n return networksToAdd\n .sort((a, b) => a.chainId.localeCompare(b.chainId))\n .slice(0, numberOfNetworksToAppend);\n};\n"]}
1
+ {"version":3,"file":"add-network-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;;GAOG;AACI,MAAM,4BAA4B,GAAG,CAC1C,gBAAwB,EACxB,OAAe,EACf,EAAE;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC;AACjD,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAAG,CACrC,gBAAwC,EACxC,aAAqC,EACrC,OAAO,GAAG,yBAAiB,EAC3B,EAAE;IACF,MAAM,cAAc,GAAG,IAAA,oCAA4B,EACjD,gBAAgB,CAAC,MAAM,EACvB,OAAO,CACR,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,CACvC,cAAc,EACd,aAAa,CAAC,MAAM,CACrB,CAAC;IAEF,yCAAyC;IACzC,6DAA6D;IAC7D,OAAO,aAAa;SACjB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAClD,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACxC,CAAC,CAAC;AAnBW,QAAA,uBAAuB,2BAmBlC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\n\nexport const MAX_NETWORKS_SIZE = 50;\n\n/**\n * Calculates the available space to add new networks\n * exported for testability.\n *\n * @param originalListSize - size of original list\n * @param maxSize - max size\n * @returns a positive number on the available space\n */\nexport const calculateAvailableSpaceToAdd = (\n originalListSize: number,\n maxSize: number,\n) => {\n return Math.max(0, maxSize - originalListSize);\n};\n\n/**\n * Returns a bounded number of networks to add (set by a max bound)\n * The items will be ordered to give determinism on items to append (not random)\n *\n * @param originalNetworks - The original list of network configurations.\n * @param networksToAdd - The list of network configurations to add.\n * @param maxSize - The maximum allowed size of the list. Defaults to MAX_NETWORKS_SIZE.\n * @returns The networks to add, sorted by chainId.\n */\nexport const getBoundedNetworksToAdd = (\n originalNetworks: NetworkConfiguration[],\n networksToAdd: NetworkConfiguration[],\n maxSize = MAX_NETWORKS_SIZE,\n) => {\n const availableSpace = calculateAvailableSpaceToAdd(\n originalNetworks.length,\n maxSize,\n );\n const numberOfNetworksToAppend = Math.min(\n availableSpace,\n networksToAdd.length,\n );\n\n // Order and slice the networks to append\n // Ordering so we have some determinism on the order of items\n return networksToAdd\n .sort((a, b) => a.chainId.localeCompare(b.chainId))\n .slice(0, numberOfNetworksToAppend);\n};\n"]}
@@ -3,6 +3,7 @@ export declare const MAX_NETWORKS_SIZE = 50;
3
3
  /**
4
4
  * Calculates the available space to add new networks
5
5
  * exported for testability.
6
+ *
6
7
  * @param originalListSize - size of original list
7
8
  * @param maxSize - max size
8
9
  * @returns a positive number on the available space
@@ -1 +1 @@
1
- {"version":3,"file":"add-network-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAEzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,qBACrB,MAAM,WACf,MAAM,WAGhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,qBAChB,oBAAoB,EAAE,iBACzB,oBAAoB,EAAE,6CAiBtC,CAAC"}
1
+ {"version":3,"file":"add-network-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAEzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,qBACrB,MAAM,WACf,MAAM,WAGhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,qBAChB,oBAAoB,EAAE,iBACzB,oBAAoB,EAAE,6CAiBtC,CAAC"}
@@ -3,6 +3,7 @@ export declare const MAX_NETWORKS_SIZE = 50;
3
3
  /**
4
4
  * Calculates the available space to add new networks
5
5
  * exported for testability.
6
+ *
6
7
  * @param originalListSize - size of original list
7
8
  * @param maxSize - max size
8
9
  * @returns a positive number on the available space
@@ -1 +1 @@
1
- {"version":3,"file":"add-network-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAEzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,qBACrB,MAAM,WACf,MAAM,WAGhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,qBAChB,oBAAoB,EAAE,iBACzB,oBAAoB,EAAE,6CAiBtC,CAAC"}
1
+ {"version":3,"file":"add-network-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAEzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,qBACrB,MAAM,WACf,MAAM,WAGhB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,qBAChB,oBAAoB,EAAE,iBACzB,oBAAoB,EAAE,6CAiBtC,CAAC"}
@@ -2,6 +2,7 @@ export const MAX_NETWORKS_SIZE = 50;
2
2
  /**
3
3
  * Calculates the available space to add new networks
4
4
  * exported for testability.
5
+ *
5
6
  * @param originalListSize - size of original list
6
7
  * @param maxSize - max size
7
8
  * @returns a positive number on the available space
@@ -1 +1 @@
1
- {"version":3,"file":"add-network-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,gBAAwB,EACxB,OAAe,EACf,EAAE;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAAwC,EACxC,aAAqC,EACrC,OAAO,GAAG,iBAAiB,EAC3B,EAAE;IACF,MAAM,cAAc,GAAG,4BAA4B,CACjD,gBAAgB,CAAC,MAAM,EACvB,OAAO,CACR,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,CACvC,cAAc,EACd,aAAa,CAAC,MAAM,CACrB,CAAC;IAEF,yCAAyC;IACzC,6DAA6D;IAC7D,OAAO,aAAa;SACjB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAClD,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\n\nexport const MAX_NETWORKS_SIZE = 50;\n\n/**\n * Calculates the available space to add new networks\n * exported for testability.\n * @param originalListSize - size of original list\n * @param maxSize - max size\n * @returns a positive number on the available space\n */\nexport const calculateAvailableSpaceToAdd = (\n originalListSize: number,\n maxSize: number,\n) => {\n return Math.max(0, maxSize - originalListSize);\n};\n\n/**\n * Returns a bounded number of networks to add (set by a max bound)\n * The items will be ordered to give determinism on items to append (not random)\n *\n * @param originalNetworks - The original list of network configurations.\n * @param networksToAdd - The list of network configurations to add.\n * @param maxSize - The maximum allowed size of the list. Defaults to MAX_NETWORKS_SIZE.\n * @returns The networks to add, sorted by chainId.\n */\nexport const getBoundedNetworksToAdd = (\n originalNetworks: NetworkConfiguration[],\n networksToAdd: NetworkConfiguration[],\n maxSize = MAX_NETWORKS_SIZE,\n) => {\n const availableSpace = calculateAvailableSpaceToAdd(\n originalNetworks.length,\n maxSize,\n );\n const numberOfNetworksToAppend = Math.min(\n availableSpace,\n networksToAdd.length,\n );\n\n // Order and slice the networks to append\n // Ordering so we have some determinism on the order of items\n return networksToAdd\n .sort((a, b) => a.chainId.localeCompare(b.chainId))\n .slice(0, numberOfNetworksToAppend);\n};\n"]}
1
+ {"version":3,"file":"add-network-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/add-network-utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,gBAAwB,EACxB,OAAe,EACf,EAAE;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAAwC,EACxC,aAAqC,EACrC,OAAO,GAAG,iBAAiB,EAC3B,EAAE;IACF,MAAM,cAAc,GAAG,4BAA4B,CACjD,gBAAgB,CAAC,MAAM,EACvB,OAAO,CACR,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAI,CAAC,GAAG,CACvC,cAAc,EACd,aAAa,CAAC,MAAM,CACrB,CAAC;IAEF,yCAAyC;IACzC,6DAA6D;IAC7D,OAAO,aAAa;SACjB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAClD,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\n\nexport const MAX_NETWORKS_SIZE = 50;\n\n/**\n * Calculates the available space to add new networks\n * exported for testability.\n *\n * @param originalListSize - size of original list\n * @param maxSize - max size\n * @returns a positive number on the available space\n */\nexport const calculateAvailableSpaceToAdd = (\n originalListSize: number,\n maxSize: number,\n) => {\n return Math.max(0, maxSize - originalListSize);\n};\n\n/**\n * Returns a bounded number of networks to add (set by a max bound)\n * The items will be ordered to give determinism on items to append (not random)\n *\n * @param originalNetworks - The original list of network configurations.\n * @param networksToAdd - The list of network configurations to add.\n * @param maxSize - The maximum allowed size of the list. Defaults to MAX_NETWORKS_SIZE.\n * @returns The networks to add, sorted by chainId.\n */\nexport const getBoundedNetworksToAdd = (\n originalNetworks: NetworkConfiguration[],\n networksToAdd: NetworkConfiguration[],\n maxSize = MAX_NETWORKS_SIZE,\n) => {\n const availableSpace = calculateAvailableSpaceToAdd(\n originalNetworks.length,\n maxSize,\n );\n const numberOfNetworksToAppend = Math.min(\n availableSpace,\n networksToAdd.length,\n );\n\n // Order and slice the networks to append\n // Ordering so we have some determinism on the order of items\n return networksToAdd\n .sort((a, b) => a.chainId.localeCompare(b.chainId))\n .slice(0, numberOfNetworksToAppend);\n};\n"]}
@@ -30,9 +30,7 @@ exports.isMainNetworkSyncInProgress = false;
30
30
  function startNetworkSyncing(props) {
31
31
  const { messenger, getStorageConfig, isMutationSyncBlocked } = props;
32
32
  try {
33
- messenger.subscribe('NetworkController:networkRemoved',
34
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
35
- async (networkConfiguration) => {
33
+ messenger.subscribe('NetworkController:networkRemoved', async (networkConfiguration) => {
36
34
  try {
37
35
  // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations
38
36
  if (isMutationSyncBlocked()) {
@@ -62,6 +60,7 @@ exports.startNetworkSyncing = startNetworkSyncing;
62
60
  /**
63
61
  * method that will dispatch the `NetworkController:updateNetwork` action.
64
62
  * transforms and corrects the network configuration (and RPCs) we pass through.
63
+ *
65
64
  * @param props - properties
66
65
  * @param props.messenger - messenger to call the action
67
66
  * @param props.originalNetworkConfiguration - original network config (from network controller state)
@@ -81,6 +80,7 @@ exports.dispatchUpdateNetwork = dispatchUpdateNetwork;
81
80
  /**
82
81
  * Action to perform the main network sync.
83
82
  * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update
83
+ *
84
84
  * @param props - parameters used for this main sync
85
85
  */
86
86
  async function performMainNetworkSync(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":";;;;;;AACA,wDAA2B;AAI3B,+DAA8D;AAC9D,6CAAkD;AAClD,6CAAkD;AAClD,yDAAsE;AACtE,qEAAkE;AAiBlE;;;GAGG;AACH,2BAA2B;AAC3B,uDAAuD;AAC5C,QAAA,2BAA2B,GAAG,KAAK,CAAC;AAE/C;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IACrE,IAAI;QACF,SAAS,CAAC,SAAS,CACjB,kCAAkC;QAClC,kEAAkE;QAClE,KAAK,EAAE,oBAAoB,EAAE,EAAE;YAC7B,IAAI;gBACF,oGAAoG;gBACpG,IAAI,qBAAqB,EAAE,EAAE;oBAC3B,OAAO;iBACR;gBAED,yEAAyE;gBACzE,kCAAkC;gBAClC,IAAI,mCAA2B,EAAE;oBAC/B,OAAO;iBACR;gBAED,MAAM,IAAI,GAAG,MAAM,gBAAgB,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO;iBACR;gBACD,MAAM,IAAA,8BAAa,EAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;aACjD;YAAC,MAAM;gBACN,qBAAqB;aACtB;QACH,CAAC,CACF,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,kBAAG,CAAC,IAAI,CAAC,2CAA2C,EAAE,CAAC,CAAC,CAAC;KAC1D;AACH,CAAC;AAhCD,kDAgCC;AAED;;;;;;;;GAQG;AACI,MAAM,qBAAqB,GAAG,KAAK,EAAE,KAK3C,EAAE,EAAE;IACH,MAAM,EAC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} from '@metamask/network-controller';\nimport log from 'loglevel';\n\nimport type { UserStorageBaseOptions } from '../services';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport { getBoundedNetworksToAdd } from './add-network-utils';\nimport { getAllRemoteNetworks } from './services';\nimport { findNetworksToUpdate } from './sync-all';\nimport { batchUpdateNetworks, deleteNetwork } from './sync-mutations';\nimport { createUpdateNetworkProps } from './update-network-utils';\n\ntype StartNetworkSyncingProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n isMutationSyncBlocked: () => boolean;\n};\n\ntype PerformMainNetworkSyncProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n maxNetworksToAdd?: number;\n onNetworkAdded?: (chainId: string) => void;\n onNetworkUpdated?: (chainId: string) => void;\n onNetworkRemoved?: (chainId: string) => void;\n};\n\n/**\n * Global in-mem cache to signify that the network syncing is in progress\n * Ensures that listeners do not fire during main sync (prevent double requests)\n */\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let isMainNetworkSyncInProgress = false;\n\n/**\n * Initialize and setup events to listen to for network syncing\n * We will be listening to:\n * - Remove Event, to indicate that we need to remote network from remote\n *\n * We will not be listening to:\n * - Add/Update events are not required, as we can sync these during the main sync\n *\n * @param props - parameters used for initializing and enabling network syncing\n */\nexport function startNetworkSyncing(props: StartNetworkSyncingProps) {\n const { messenger, getStorageConfig, isMutationSyncBlocked } = props;\n try {\n messenger.subscribe(\n 'NetworkController:networkRemoved',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (networkConfiguration) => {\n try {\n // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations\n if (isMutationSyncBlocked()) {\n return;\n }\n\n // As main sync is in progress, it will already local and remote networks\n // So no need to re-process again.\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n await deleteNetwork(networkConfiguration, opts);\n } catch {\n // Silently fail sync\n }\n },\n );\n } catch (e) {\n log.warn('NetworkSyncing, event subscription failed', e);\n }\n}\n\n/**\n * method that will dispatch the `NetworkController:updateNetwork` action.\n * transforms and corrects the network configuration (and RPCs) we pass through.\n * @param props - properties\n * @param props.messenger - messenger to call the action\n * @param props.originalNetworkConfiguration - original network config (from network controller state)\n * @param props.newNetworkConfiguration - new network config (from remote)\n * @param props.selectedNetworkClientId - currently selected network client id\n */\nexport const dispatchUpdateNetwork = async (props: {\n messenger: UserStorageControllerMessenger;\n originalNetworkConfiguration: NetworkConfiguration;\n newNetworkConfiguration: NetworkConfiguration;\n selectedNetworkClientId: string;\n}) => {\n const {\n messenger,\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n } = props;\n\n const { updateNetworkFields, newSelectedRpcEndpointIndex } =\n createUpdateNetworkProps({\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n });\n\n await messenger.call(\n 'NetworkController:updateNetwork',\n updateNetworkFields.chainId,\n updateNetworkFields,\n { replacementSelectedRpcEndpointIndex: newSelectedRpcEndpointIndex },\n );\n};\n\n/**\n * Action to perform the main network sync.\n * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update\n * @param props - parameters used for this main sync\n */\nexport async function performMainNetworkSync(\n props: PerformMainNetworkSyncProps,\n) {\n const {\n messenger,\n getStorageConfig,\n maxNetworksToAdd,\n onNetworkAdded,\n onNetworkRemoved,\n onNetworkUpdated,\n } = props;\n\n // Edge-Case, we do not want to re-run the main-sync if it already is in progress\n /* istanbul ignore if - this is not testable */\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n isMainNetworkSyncInProgress = true;\n try {\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n\n const networkControllerState = messenger.call('NetworkController:getState');\n const localNetworks = Object.values(\n networkControllerState.networkConfigurationsByChainId ?? {},\n );\n\n const remoteNetworks = await getAllRemoteNetworks(opts);\n const networkChanges = findNetworksToUpdate({\n localNetworks,\n remoteNetworks,\n });\n\n log.debug('performMainNetworkSync() - Network Syncing Started', {\n localNetworks,\n remoteNetworks,\n networkChanges,\n });\n\n // Update Remote\n if (\n networkChanges?.remoteNetworksToUpdate &&\n networkChanges.remoteNetworksToUpdate.length > 0\n ) {\n await batchUpdateNetworks(networkChanges?.remoteNetworksToUpdate, opts);\n }\n\n // Add missing local networks\n const boundedNetworkedToAdd =\n networkChanges?.missingLocalNetworks &&\n getBoundedNetworksToAdd(\n localNetworks,\n networkChanges.missingLocalNetworks,\n maxNetworksToAdd,\n );\n if (boundedNetworkedToAdd && boundedNetworkedToAdd.length > 0) {\n const errors: unknown[] = [];\n boundedNetworkedToAdd.forEach((n) => {\n try {\n messenger.call('NetworkController:addNetwork', n);\n onNetworkAdded?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:addNetwork failures',\n errors,\n );\n }\n }\n\n // Update local networks\n if (\n networkChanges?.localNetworksToUpdate &&\n networkChanges.localNetworksToUpdate.length > 0\n ) {\n const errors: unknown[] = [];\n for (const n of networkChanges.localNetworksToUpdate) {\n try {\n await dispatchUpdateNetwork({\n messenger,\n originalNetworkConfiguration:\n networkControllerState.networkConfigurationsByChainId[n.chainId],\n newNetworkConfiguration: n,\n selectedNetworkClientId:\n networkControllerState.selectedNetworkClientId,\n });\n onNetworkUpdated?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n }\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:updateNetwork failed',\n errors,\n );\n }\n }\n\n // Remove local networks\n if (\n networkChanges?.localNetworksToRemove &&\n networkChanges.localNetworksToRemove.length > 0\n ) {\n const errors: unknown[] = [];\n networkChanges.localNetworksToRemove.forEach((n) => {\n try {\n messenger.call('NetworkController:removeNetwork', n.chainId);\n onNetworkRemoved?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:removeNetwork failed',\n errors,\n );\n }\n }\n } catch (e) {\n /* istanbul ignore next - only logs errors, not useful to test */\n log.error('performMainNetworkSync() failed', e);\n // Silently fail sync\n } finally {\n isMainNetworkSyncInProgress = false;\n }\n}\n"]}
1
+ {"version":3,"file":"controller-integration.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":";;;;;;AACA,wDAA2B;AAE3B,+DAA8D;AAC9D,6CAAkD;AAClD,6CAAkD;AAClD,yDAAsE;AACtE,qEAAkE;AAmBlE;;;GAGG;AACH,2BAA2B;AAC3B,uDAAuD;AAC5C,QAAA,2BAA2B,GAAG,KAAK,CAAC;AAE/C;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IACrE,IAAI;QACF,SAAS,CAAC,SAAS,CACjB,kCAAkC,EAElC,KAAK,EAAE,oBAAoB,EAAE,EAAE;YAC7B,IAAI;gBACF,oGAAoG;gBACpG,IAAI,qBAAqB,EAAE,EAAE;oBAC3B,OAAO;iBACR;gBAED,yEAAyE;gBACzE,kCAAkC;gBAClC,IAAI,mCAA2B,EAAE;oBAC/B,OAAO;iBACR;gBAED,MAAM,IAAI,GAAG,MAAM,gBAAgB,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO;iBACR;gBACD,MAAM,IAAA,8BAAa,EAAC,oBAAoB,EAAE,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;gBACrB,kBAAG,CAAC,KAAK,CACP,mEAAmE,EACnE,MAAM,CACP,CAAC;aACH;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,iEAAiE;QACjE,kBAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;QAChD,qBAAqB;KACtB;YAAS;QACR,mCAA2B,GAAG,KAAK,CAAC;KACrC;AACH,CAAC;AAjJD,wDAiJC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\nimport log from 'loglevel';\n\nimport { getBoundedNetworksToAdd } from './add-network-utils';\nimport { getAllRemoteNetworks } from './services';\nimport { findNetworksToUpdate } from './sync-all';\nimport { batchUpdateNetworks, deleteNetwork } from './sync-mutations';\nimport { createUpdateNetworkProps } from './update-network-utils';\nimport type { UserStorageBaseOptions } from '../services';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\n\ntype StartNetworkSyncingProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n isMutationSyncBlocked: () => boolean;\n};\n\ntype PerformMainNetworkSyncProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n maxNetworksToAdd?: number;\n onNetworkAdded?: (chainId: string) => void;\n onNetworkUpdated?: (chainId: string) => void;\n onNetworkRemoved?: (chainId: string) => void;\n};\n\n/**\n * Global in-mem cache to signify that the network syncing is in progress\n * Ensures that listeners do not fire during main sync (prevent double requests)\n */\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let isMainNetworkSyncInProgress = false;\n\n/**\n * Initialize and setup events to listen to for network syncing\n * We will be listening to:\n * - Remove Event, to indicate that we need to remote network from remote\n *\n * We will not be listening to:\n * - Add/Update events are not required, as we can sync these during the main sync\n *\n * @param props - parameters used for initializing and enabling network syncing\n */\nexport function startNetworkSyncing(props: StartNetworkSyncingProps) {\n const { messenger, getStorageConfig, isMutationSyncBlocked } = props;\n try {\n messenger.subscribe(\n 'NetworkController:networkRemoved',\n\n async (networkConfiguration) => {\n try {\n // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations\n if (isMutationSyncBlocked()) {\n return;\n }\n\n // As main sync is in progress, it will already local and remote networks\n // So no need to re-process again.\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n await deleteNetwork(networkConfiguration, opts);\n } catch {\n // Silently fail sync\n }\n },\n );\n } catch (e) {\n log.warn('NetworkSyncing, event subscription failed', e);\n }\n}\n\n/**\n * method that will dispatch the `NetworkController:updateNetwork` action.\n * transforms and corrects the network configuration (and RPCs) we pass through.\n *\n * @param props - properties\n * @param props.messenger - messenger to call the action\n * @param props.originalNetworkConfiguration - original network config (from network controller state)\n * @param props.newNetworkConfiguration - new network config (from remote)\n * @param props.selectedNetworkClientId - currently selected network client id\n */\nexport const dispatchUpdateNetwork = async (props: {\n messenger: UserStorageControllerMessenger;\n originalNetworkConfiguration: NetworkConfiguration;\n newNetworkConfiguration: NetworkConfiguration;\n selectedNetworkClientId: string;\n}) => {\n const {\n messenger,\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n } = props;\n\n const { updateNetworkFields, newSelectedRpcEndpointIndex } =\n createUpdateNetworkProps({\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n });\n\n await messenger.call(\n 'NetworkController:updateNetwork',\n updateNetworkFields.chainId,\n updateNetworkFields,\n { replacementSelectedRpcEndpointIndex: newSelectedRpcEndpointIndex },\n );\n};\n\n/**\n * Action to perform the main network sync.\n * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update\n *\n * @param props - parameters used for this main sync\n */\nexport async function performMainNetworkSync(\n props: PerformMainNetworkSyncProps,\n) {\n const {\n messenger,\n getStorageConfig,\n maxNetworksToAdd,\n onNetworkAdded,\n onNetworkRemoved,\n onNetworkUpdated,\n } = props;\n\n // Edge-Case, we do not want to re-run the main-sync if it already is in progress\n /* istanbul ignore if - this is not testable */\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n isMainNetworkSyncInProgress = true;\n try {\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n\n const networkControllerState = messenger.call('NetworkController:getState');\n const localNetworks = Object.values(\n networkControllerState.networkConfigurationsByChainId ?? {},\n );\n\n const remoteNetworks = await getAllRemoteNetworks(opts);\n const networkChanges = findNetworksToUpdate({\n localNetworks,\n remoteNetworks,\n });\n\n log.debug('performMainNetworkSync() - Network Syncing Started', {\n localNetworks,\n remoteNetworks,\n networkChanges,\n });\n\n // Update Remote\n if (\n networkChanges?.remoteNetworksToUpdate &&\n networkChanges.remoteNetworksToUpdate.length > 0\n ) {\n await batchUpdateNetworks(networkChanges?.remoteNetworksToUpdate, opts);\n }\n\n // Add missing local networks\n const boundedNetworkedToAdd =\n networkChanges?.missingLocalNetworks &&\n getBoundedNetworksToAdd(\n localNetworks,\n networkChanges.missingLocalNetworks,\n maxNetworksToAdd,\n );\n if (boundedNetworkedToAdd && boundedNetworkedToAdd.length > 0) {\n const errors: unknown[] = [];\n boundedNetworkedToAdd.forEach((n) => {\n try {\n messenger.call('NetworkController:addNetwork', n);\n onNetworkAdded?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:addNetwork failures',\n errors,\n );\n }\n }\n\n // Update local networks\n if (\n networkChanges?.localNetworksToUpdate &&\n networkChanges.localNetworksToUpdate.length > 0\n ) {\n const errors: unknown[] = [];\n for (const n of networkChanges.localNetworksToUpdate) {\n try {\n await dispatchUpdateNetwork({\n messenger,\n originalNetworkConfiguration:\n networkControllerState.networkConfigurationsByChainId[n.chainId],\n newNetworkConfiguration: n,\n selectedNetworkClientId:\n networkControllerState.selectedNetworkClientId,\n });\n onNetworkUpdated?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n }\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:updateNetwork failed',\n errors,\n );\n }\n }\n\n // Remove local networks\n if (\n networkChanges?.localNetworksToRemove &&\n networkChanges.localNetworksToRemove.length > 0\n ) {\n const errors: unknown[] = [];\n networkChanges.localNetworksToRemove.forEach((n) => {\n try {\n messenger.call('NetworkController:removeNetwork', n.chainId);\n onNetworkRemoved?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:removeNetwork failed',\n errors,\n );\n }\n }\n } catch (e) {\n /* istanbul ignore next - only logs errors, not useful to test */\n log.error('performMainNetworkSync() failed', e);\n // Silently fail sync\n } finally {\n isMainNetworkSyncInProgress = false;\n }\n}\n"]}
@@ -33,6 +33,7 @@ export declare function startNetworkSyncing(props: StartNetworkSyncingProps): vo
33
33
  /**
34
34
  * method that will dispatch the `NetworkController:updateNetwork` action.
35
35
  * transforms and corrects the network configuration (and RPCs) we pass through.
36
+ *
36
37
  * @param props - properties
37
38
  * @param props.messenger - messenger to call the action
38
39
  * @param props.originalNetworkConfiguration - original network config (from network controller state)
@@ -48,6 +49,7 @@ export declare const dispatchUpdateNetwork: (props: {
48
49
  /**
49
50
  * Action to perform the main network sync.
50
51
  * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update
52
+ *
51
53
  * @param props - parameters used for this main sync
52
54
  */
53
55
  export declare function performMainNetworkSync(props: PerformMainNetworkSyncProps): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAGzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AAC1D,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAO/E,KAAK,wBAAwB,GAAG;IAC9B,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,qBAAqB,EAAE,MAAM,OAAO,CAAC;CACtC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AAGH,eAAO,IAAI,2BAA2B,SAAQ,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,QAgClE;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,UAAiB;IACjD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,4BAA4B,EAAE,oBAAoB,CAAC;IACnD,uBAAuB,EAAE,oBAAoB,CAAC;IAC9C,uBAAuB,EAAE,MAAM,CAAC;CACjC,kBAqBA,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,2BAA2B,iBAgJnC"}
1
+ {"version":3,"file":"controller-integration.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/contro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34
  * method that will dispatch the `NetworkController:updateNetwork` action.
35
35
  * transforms and corrects the network configuration (and RPCs) we pass through.
36
+ *
36
37
  * @param props - properties
37
38
  * @param props.messenger - messenger to call the action
38
39
  * @param props.originalNetworkConfiguration - original network config (from network controller state)
@@ -48,6 +49,7 @@ export declare const dispatchUpdateNetwork: (props: {
48
49
  /**
49
50
  * Action to perform the main network sync.
50
51
  * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update
52
+ *
51
53
  * @param props - parameters used for this main sync
52
54
  */
53
55
  export declare function performMainNetworkSync(props: PerformMainNetworkSyncProps): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAGzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AAC1D,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAO/E,KAAK,wBAAwB,GAAG;IAC9B,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,qBAAqB,EAAE,MAAM,OAAO,CAAC;CACtC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AAGH,eAAO,IAAI,2BAA2B,SAAQ,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,QAgClE;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,UAAiB;IACjD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,4BAA4B,EAAE,oBAAoB,CAAC;IACnD,uBAAuB,EAAE,oBAAoB,CAAC;IAC9C,uBAAuB,EAAE,MAAM,CAAC;CACjC,kBAqBA,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,2BAA2B,iBAgJnC"}
1
+ {"version":3,"file":"controller-integration.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qCAAqC;AAQzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AAC1D,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAE/E,KAAK,wBAAwB,GAAG;IAC9B,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,qBAAqB,EAAE,MAAM,OAAO,CAAC;CACtC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,8BAA8B,CAAC;IAC1C,gBAAgB,EAAE,MAAM,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AAGH,eAAO,IAAI,2BAA2B,SAAQ,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,QAgClE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,UAAiB;IACjD,SAAS,EAAE,8BAA8B,CAAC;IAC1C,4BAA4B,EAAE,oBAAoB,CAAC;IACnD,uBAAuB,EAAE,oBAAoB,CAAC;IAC9C,uBAAuB,EAAE,MAAM,CAAC;CACjC,kBAqBA,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,2BAA2B,iBAgJnC"}
@@ -31,9 +31,7 @@ export let isMainNetworkSyncInProgress = false;
31
31
  export function startNetworkSyncing(props) {
32
32
  const { messenger, getStorageConfig, isMutationSyncBlocked } = props;
33
33
  try {
34
- messenger.subscribe('NetworkController:networkRemoved',
35
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
36
- async (networkConfiguration) => {
34
+ messenger.subscribe('NetworkController:networkRemoved', async (networkConfiguration) => {
37
35
  try {
38
36
  // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations
39
37
  if (isMutationSyncBlocked()) {
@@ -62,6 +60,7 @@ export function startNetworkSyncing(props) {
62
60
  /**
63
61
  * method that will dispatch the `NetworkController:updateNetwork` action.
64
62
  * transforms and corrects the network configuration (and RPCs) we pass through.
63
+ *
65
64
  * @param props - properties
66
65
  * @param props.messenger - messenger to call the action
67
66
  * @param props.originalNetworkConfiguration - original network config (from network controller state)
@@ -80,6 +79,7 @@ export const dispatchUpdateNetwork = async (props) => {
80
79
  /**
81
80
  * Action to perform the main network sync.
82
81
  * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update
82
+ *
83
83
  * @param props - parameters used for this main sync
84
84
  */
85
85
  export async function performMainNetworkSync(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"controller-integration.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"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C,CAAC;iBAC/B;gBAAC,OAAO,CAAC,EAAE;oBACV,gEAAgE;oBAChE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACf,yDAAyD;iBAC1D;aACF;YAED,+DAA+D;YAC/D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,GAAG,CAAC,KAAK,CACP,mEAAmE,EACnE,MAAM,CACP,CAAC;aACH;SACF;QAED,wBAAwB;QACxB,IACE,cAAc,EAAE,qBAAqB;YACrC,cAAc,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAC/C;YACA,MAAM,MAAM,GAAc,EAAE,CAAC;YAC7B,cAAc,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;gBACjD,IAAI;oBACF,SAAS,CAAC,IAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;oBAC7D,gBAAgB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBAC/B;gBAAC,OAAO,CAAC,EAAE;oBACV,gEAAgE;oBAChE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACf,yDAAyD;iBAC1D;YACH,CAAC,CAAC,CAAC;YAEH,+DAA+D;YAC/D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,GAAG,CAAC,KAAK,CACP,mEAAmE,EACnE,MAAM,CACP,CAAC;aACH;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,iEAAiE;QACjE,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;QAChD,qBAAqB;KACtB;YAAS;QACR,2BAA2B,GAAG,KAAK,CAAC;KACrC;AACH,CAAC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\nimport log from 'loglevel';\n\nimport type { UserStorageBaseOptions } from '../services';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport { getBoundedNetworksToAdd } from './add-network-utils';\nimport { getAllRemoteNetworks } from './services';\nimport { findNetworksToUpdate } from './sync-all';\nimport { batchUpdateNetworks, deleteNetwork } from './sync-mutations';\nimport { createUpdateNetworkProps } from './update-network-utils';\n\ntype StartNetworkSyncingProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n isMutationSyncBlocked: () => boolean;\n};\n\ntype PerformMainNetworkSyncProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n maxNetworksToAdd?: number;\n onNetworkAdded?: (chainId: string) => void;\n onNetworkUpdated?: (chainId: string) => void;\n onNetworkRemoved?: (chainId: string) => void;\n};\n\n/**\n * Global in-mem cache to signify that the network syncing is in progress\n * Ensures that listeners do not fire during main sync (prevent double requests)\n */\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let isMainNetworkSyncInProgress = false;\n\n/**\n * Initialize and setup events to listen to for network syncing\n * We will be listening to:\n * - Remove Event, to indicate that we need to remote network from remote\n *\n * We will not be listening to:\n * - Add/Update events are not required, as we can sync these during the main sync\n *\n * @param props - parameters used for initializing and enabling network syncing\n */\nexport function startNetworkSyncing(props: StartNetworkSyncingProps) {\n const { messenger, getStorageConfig, isMutationSyncBlocked } = props;\n try {\n messenger.subscribe(\n 'NetworkController:networkRemoved',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (networkConfiguration) => {\n try {\n // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations\n if (isMutationSyncBlocked()) {\n return;\n }\n\n // As main sync is in progress, it will already local and remote networks\n // So no need to re-process again.\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n await deleteNetwork(networkConfiguration, opts);\n } catch {\n // Silently fail sync\n }\n },\n );\n } catch (e) {\n log.warn('NetworkSyncing, event subscription failed', e);\n }\n}\n\n/**\n * method that will dispatch the `NetworkController:updateNetwork` action.\n * transforms and corrects the network configuration (and RPCs) we pass through.\n * @param props - properties\n * @param props.messenger - messenger to call the action\n * @param props.originalNetworkConfiguration - original network config (from network controller state)\n * @param props.newNetworkConfiguration - new network config (from remote)\n * @param props.selectedNetworkClientId - currently selected network client id\n */\nexport const dispatchUpdateNetwork = async (props: {\n messenger: UserStorageControllerMessenger;\n originalNetworkConfiguration: NetworkConfiguration;\n newNetworkConfiguration: NetworkConfiguration;\n selectedNetworkClientId: string;\n}) => {\n const {\n messenger,\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n } = props;\n\n const { updateNetworkFields, newSelectedRpcEndpointIndex } =\n createUpdateNetworkProps({\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n });\n\n await messenger.call(\n 'NetworkController:updateNetwork',\n updateNetworkFields.chainId,\n updateNetworkFields,\n { replacementSelectedRpcEndpointIndex: newSelectedRpcEndpointIndex },\n );\n};\n\n/**\n * Action to perform the main network sync.\n * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update\n * @param props - parameters used for this main sync\n */\nexport async function performMainNetworkSync(\n props: PerformMainNetworkSyncProps,\n) {\n const {\n messenger,\n getStorageConfig,\n maxNetworksToAdd,\n onNetworkAdded,\n onNetworkRemoved,\n onNetworkUpdated,\n } = props;\n\n // Edge-Case, we do not want to re-run the main-sync if it already is in progress\n /* istanbul ignore if - this is not testable */\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n isMainNetworkSyncInProgress = true;\n try {\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n\n const networkControllerState = messenger.call('NetworkController:getState');\n const localNetworks = Object.values(\n networkControllerState.networkConfigurationsByChainId ?? {},\n );\n\n const remoteNetworks = await getAllRemoteNetworks(opts);\n const networkChanges = findNetworksToUpdate({\n localNetworks,\n remoteNetworks,\n });\n\n log.debug('performMainNetworkSync() - Network Syncing Started', {\n localNetworks,\n remoteNetworks,\n networkChanges,\n });\n\n // Update Remote\n if (\n networkChanges?.remoteNetworksToUpdate &&\n networkChanges.remoteNetworksToUpdate.length > 0\n ) {\n await batchUpdateNetworks(networkChanges?.remoteNetworksToUpdate, opts);\n }\n\n // Add missing local networks\n const boundedNetworkedToAdd =\n networkChanges?.missingLocalNetworks &&\n getBoundedNetworksToAdd(\n localNetworks,\n networkChanges.missingLocalNetworks,\n maxNetworksToAdd,\n );\n if (boundedNetworkedToAdd && boundedNetworkedToAdd.length > 0) {\n const errors: unknown[] = [];\n boundedNetworkedToAdd.forEach((n) => {\n try {\n messenger.call('NetworkController:addNetwork', n);\n onNetworkAdded?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:addNetwork failures',\n errors,\n );\n }\n }\n\n // Update local networks\n if (\n networkChanges?.localNetworksToUpdate &&\n networkChanges.localNetworksToUpdate.length > 0\n ) {\n const errors: unknown[] = [];\n for (const n of networkChanges.localNetworksToUpdate) {\n try {\n await dispatchUpdateNetwork({\n messenger,\n originalNetworkConfiguration:\n networkControllerState.networkConfigurationsByChainId[n.chainId],\n newNetworkConfiguration: n,\n selectedNetworkClientId:\n networkControllerState.selectedNetworkClientId,\n });\n onNetworkUpdated?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n }\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:updateNetwork failed',\n errors,\n );\n }\n }\n\n // Remove local networks\n if (\n networkChanges?.localNetworksToRemove &&\n networkChanges.localNetworksToRemove.length > 0\n ) {\n const errors: unknown[] = [];\n networkChanges.localNetworksToRemove.forEach((n) => {\n try {\n messenger.call('NetworkController:removeNetwork', n.chainId);\n onNetworkRemoved?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:removeNetwork failed',\n errors,\n );\n }\n }\n } catch (e) {\n /* istanbul ignore next - only logs errors, not useful to test */\n log.error('performMainNetworkSync() failed', e);\n // Silently fail sync\n } finally {\n isMainNetworkSyncInProgress = false;\n }\n}\n"]}
1
+ {"version":3,"file":"controller-integration.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/controller-integration.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,IAAG,iBAAiB;;AAE3B,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,OAAO,EAAE,oBAAoB,EAAE,uBAAmB;AAClD,OAAO,EAAE,oBAAoB,EAAE,uBAAmB;AAClD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,6BAAyB;AACtE,OAAO,EAAE,wBAAwB,EAAE,mCAA+B;AAmBlE;;;GAGG;AACH,2BAA2B;AAC3B,uDAAuD;AACvD,MAAM,CAAC,IAAI,2BAA2B,GAAG,KAAK,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IACrE,IAAI;QACF,SAAS,CAAC,SAAS,CACjB,kCAAkC,EAElC,KAAK,EAAE,oBAAoB,EAAE,EAAE;YAC7B,IAAI;gBACF,oGAAoG;gBACpG,IAAI,qBAAqB,EAAE,EAAE;oBAC3B,OAAO;iBACR;gBAED,yEAAyE;gBACzE,kCAAkC;gBAClC,IAAI,2BAA2B,EAAE;oBAC/B,OAAO;iBACR;gBAED,MAAM,IAAI,GAAG,MAAM,gBAAgB,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO;iBACR;gB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ACP,mEAAmE,EACnE,MAAM,CACP,CAAC;aACH;SACF;KACF;IAAC,OAAO,CAAC,EAAE;QACV,iEAAiE;QACjE,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;QAChD,qBAAqB;KACtB;YAAS;QACR,2BAA2B,GAAG,KAAK,CAAC;KACrC;AACH,CAAC","sourcesContent":["import type { NetworkConfiguration } from '@metamask/network-controller';\nimport log from 'loglevel';\n\nimport { getBoundedNetworksToAdd } from './add-network-utils';\nimport { getAllRemoteNetworks } from './services';\nimport { findNetworksToUpdate } from './sync-all';\nimport { batchUpdateNetworks, deleteNetwork } from './sync-mutations';\nimport { createUpdateNetworkProps } from './update-network-utils';\nimport type { UserStorageBaseOptions } from '../services';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\n\ntype StartNetworkSyncingProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n isMutationSyncBlocked: () => boolean;\n};\n\ntype PerformMainNetworkSyncProps = {\n messenger: UserStorageControllerMessenger;\n getStorageConfig: () => Promise<UserStorageBaseOptions | null>;\n maxNetworksToAdd?: number;\n onNetworkAdded?: (chainId: string) => void;\n onNetworkUpdated?: (chainId: string) => void;\n onNetworkRemoved?: (chainId: string) => void;\n};\n\n/**\n * Global in-mem cache to signify that the network syncing is in progress\n * Ensures that listeners do not fire during main sync (prevent double requests)\n */\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let isMainNetworkSyncInProgress = false;\n\n/**\n * Initialize and setup events to listen to for network syncing\n * We will be listening to:\n * - Remove Event, to indicate that we need to remote network from remote\n *\n * We will not be listening to:\n * - Add/Update events are not required, as we can sync these during the main sync\n *\n * @param props - parameters used for initializing and enabling network syncing\n */\nexport function startNetworkSyncing(props: StartNetworkSyncingProps) {\n const { messenger, getStorageConfig, isMutationSyncBlocked } = props;\n try {\n messenger.subscribe(\n 'NetworkController:networkRemoved',\n\n async (networkConfiguration) => {\n try {\n // If blocked (e.g. we have not yet performed a main-sync), then we should not perform any mutations\n if (isMutationSyncBlocked()) {\n return;\n }\n\n // As main sync is in progress, it will already local and remote networks\n // So no need to re-process again.\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n await deleteNetwork(networkConfiguration, opts);\n } catch {\n // Silently fail sync\n }\n },\n );\n } catch (e) {\n log.warn('NetworkSyncing, event subscription failed', e);\n }\n}\n\n/**\n * method that will dispatch the `NetworkController:updateNetwork` action.\n * transforms and corrects the network configuration (and RPCs) we pass through.\n *\n * @param props - properties\n * @param props.messenger - messenger to call the action\n * @param props.originalNetworkConfiguration - original network config (from network controller state)\n * @param props.newNetworkConfiguration - new network config (from remote)\n * @param props.selectedNetworkClientId - currently selected network client id\n */\nexport const dispatchUpdateNetwork = async (props: {\n messenger: UserStorageControllerMessenger;\n originalNetworkConfiguration: NetworkConfiguration;\n newNetworkConfiguration: NetworkConfiguration;\n selectedNetworkClientId: string;\n}) => {\n const {\n messenger,\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n } = props;\n\n const { updateNetworkFields, newSelectedRpcEndpointIndex } =\n createUpdateNetworkProps({\n originalNetworkConfiguration,\n newNetworkConfiguration,\n selectedNetworkClientId,\n });\n\n await messenger.call(\n 'NetworkController:updateNetwork',\n updateNetworkFields.chainId,\n updateNetworkFields,\n { replacementSelectedRpcEndpointIndex: newSelectedRpcEndpointIndex },\n );\n};\n\n/**\n * Action to perform the main network sync.\n * It will fetch local networks and remote networks, then determines which networks (local and remote) to add/update\n *\n * @param props - parameters used for this main sync\n */\nexport async function performMainNetworkSync(\n props: PerformMainNetworkSyncProps,\n) {\n const {\n messenger,\n getStorageConfig,\n maxNetworksToAdd,\n onNetworkAdded,\n onNetworkRemoved,\n onNetworkUpdated,\n } = props;\n\n // Edge-Case, we do not want to re-run the main-sync if it already is in progress\n /* istanbul ignore if - this is not testable */\n if (isMainNetworkSyncInProgress) {\n return;\n }\n\n isMainNetworkSyncInProgress = true;\n try {\n const opts = await getStorageConfig();\n if (!opts) {\n return;\n }\n\n const networkControllerState = messenger.call('NetworkController:getState');\n const localNetworks = Object.values(\n networkControllerState.networkConfigurationsByChainId ?? {},\n );\n\n const remoteNetworks = await getAllRemoteNetworks(opts);\n const networkChanges = findNetworksToUpdate({\n localNetworks,\n remoteNetworks,\n });\n\n log.debug('performMainNetworkSync() - Network Syncing Started', {\n localNetworks,\n remoteNetworks,\n networkChanges,\n });\n\n // Update Remote\n if (\n networkChanges?.remoteNetworksToUpdate &&\n networkChanges.remoteNetworksToUpdate.length > 0\n ) {\n await batchUpdateNetworks(networkChanges?.remoteNetworksToUpdate, opts);\n }\n\n // Add missing local networks\n const boundedNetworkedToAdd =\n networkChanges?.missingLocalNetworks &&\n getBoundedNetworksToAdd(\n localNetworks,\n networkChanges.missingLocalNetworks,\n maxNetworksToAdd,\n );\n if (boundedNetworkedToAdd && boundedNetworkedToAdd.length > 0) {\n const errors: unknown[] = [];\n boundedNetworkedToAdd.forEach((n) => {\n try {\n messenger.call('NetworkController:addNetwork', n);\n onNetworkAdded?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:addNetwork failures',\n errors,\n );\n }\n }\n\n // Update local networks\n if (\n networkChanges?.localNetworksToUpdate &&\n networkChanges.localNetworksToUpdate.length > 0\n ) {\n const errors: unknown[] = [];\n for (const n of networkChanges.localNetworksToUpdate) {\n try {\n await dispatchUpdateNetwork({\n messenger,\n originalNetworkConfiguration:\n networkControllerState.networkConfigurationsByChainId[n.chainId],\n newNetworkConfiguration: n,\n selectedNetworkClientId:\n networkControllerState.selectedNetworkClientId,\n });\n onNetworkUpdated?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n }\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:updateNetwork failed',\n errors,\n );\n }\n }\n\n // Remove local networks\n if (\n networkChanges?.localNetworksToRemove &&\n networkChanges.localNetworksToRemove.length > 0\n ) {\n const errors: unknown[] = [];\n networkChanges.localNetworksToRemove.forEach((n) => {\n try {\n messenger.call('NetworkController:removeNetwork', n.chainId);\n onNetworkRemoved?.(n.chainId);\n } catch (e) {\n /* istanbul ignore next - allocates logs, do not need to test */\n errors.push(e);\n // Silently fail, we can try this again on next main sync\n }\n });\n\n /* istanbul ignore if - only logs errors, not useful to test */\n if (errors.length > 0) {\n log.error(\n 'performMainNetworkSync() - NetworkController:removeNetwork failed',\n errors,\n );\n }\n }\n } catch (e) {\n /* istanbul ignore next - only logs errors, not useful to test */\n log.error('performMainNetworkSync() failed', e);\n // Silently fail sync\n } finally {\n isMainNetworkSyncInProgress = false;\n }\n}\n"]}
@@ -6,6 +6,7 @@ const services_1 = require("../services.cjs");
6
6
  // TODO - parse type, and handle version changes
7
7
  /**
8
8
  * parses the raw remote data to the NetworkConfiguration shape
9
+ *
9
10
  * @todo - improve parsing instead of asserting
10
11
  * @todo - improve version handling
11
12
  * @param rawData - raw remote user storage data
@@ -22,6 +23,7 @@ function parseNetworkConfiguration(rawData) {
22
23
  const isDefined = (value) => value !== undefined && value !== null;
23
24
  /**
24
25
  * gets all remote networks from user storage
26
+ *
25
27
  * @param opts - user storage options/configuration
26
28
  * @returns array of all remote networks
27
29
  */
@@ -38,8 +40,10 @@ async function getAllRemoteNetworks(opts) {
38
40
  exports.getAllRemoteNetworks = getAllRemoteNetworks;
39
41
  /**
40
42
  * Upserts a remote network to user storage
43
+ *
41
44
  * @param network - network we are updating or inserting
42
45
  * @param opts - user storage options/configuration
46
+ * @returns void
43
47
  */
44
48
  async function upsertRemoteNetwork(network, opts) {
45
49
  const chainId = network.chainId.toString();
@@ -52,6 +56,7 @@ async function upsertRemoteNetwork(network, opts) {
52
56
  exports.upsertRemoteNetwork = upsertRemoteNetwork;
53
57
  /**
54
58
  * Batch upsert a list of remote networks into user storage
59
+ *
55
60
  * @param networks - a list of networks to update or insert
56
61
  * @param opts - user storage options/configuration
57
62
  */
@@ -1 +1 @@
1
- {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":";;;AAAA,uEAA4E;AAE5E,8CAIqB;AAGrB,gDAAgD;AAChD;;;;;;GAMG;AACH,SAAS,yBAAyB,CAAC,OAAe;IAChD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;KAC1D;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,SAAS,GAAG,CAAQ,KAA+B,EAAkB,EAAE,CAC3E,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAExC;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CACxC,IAA4B;IAE5B,MAAM,UAAU,GACd,CAAC,MAAM,IAAA,0CAA+B,EAAC;QACrC,GAAG,IAAI;QACP,IAAI,EAAE,2CAA0B,CAAC,QAAQ;KAC1C,CAAC,CAAC,IAAI,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,UAAU;SACvB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;SACpD,MAAM,CAAC,SAAS,CAAC,CAAC;IAErB,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,oDAcC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CACvC,OAAmC,EACnC,IAA4B;IAE5B,MAAM,OAAO,GAAW,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,MAAM,IAAA,4BAAiB,EAAC,IAAI,EAAE;QACnC,GAAG,IAAI;QACP,IAAI,EAAE,YAAY,OAAO,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAVD,kDAUC;AAED;;;;GAIG;AACI,KAAK,UAAU,yBAAyB,CAC7C,QAAsC,EACtC,IAA4B;IAE5B,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAqB,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,IAAA,iCAAsB,EAAC,oBAAoB,EAAE;QACjD,IAAI,EAAE,UAAU;QAChB,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAdD,8DAcC","sourcesContent":["import { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type { UserStorageBaseOptions } from '../services';\nimport {\n batchUpsertUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from '../services';\nimport type { RemoteNetworkConfiguration } from './types';\n\n// TODO - parse type, and handle version changes\n/**\n * parses the raw remote data to the NetworkConfiguration shape\n * @todo - improve parsing instead of asserting\n * @todo - improve version handling\n * @param rawData - raw remote user storage data\n * @returns NetworkConfiguration or undefined if failed to parse\n */\nfunction parseNetworkConfiguration(rawData: string) {\n try {\n return JSON.parse(rawData) as RemoteNetworkConfiguration;\n } catch {\n return undefined;\n }\n}\n\nconst isDefined = <Value>(value: Value | null | undefined): value is Value =>\n value !== undefined && value !== null;\n\n/**\n * gets all remote networks from user storage\n * @param opts - user storage options/configuration\n * @returns array of all remote networks\n */\nexport async function getAllRemoteNetworks(\n opts: UserStorageBaseOptions,\n): Promise<RemoteNetworkConfiguration[]> {\n const rawResults =\n (await getUserStorageAllFeatureEntries({\n ...opts,\n path: USER_STORAGE_FEATURE_NAMES.networks,\n })) ?? [];\n\n const results = rawResults\n .map((rawData) => parseNetworkConfiguration(rawData))\n .filter(isDefined);\n\n return results;\n}\n\n/**\n * Upserts a remote network to user storage\n * @param network - network we are updating or inserting\n * @param opts - user storage options/configuration\n */\nexport async function upsertRemoteNetwork(\n network: RemoteNetworkConfiguration,\n opts: UserStorageBaseOptions,\n) {\n const chainId: string = network.chainId.toString();\n const data = JSON.stringify(network);\n return await upsertUserStorage(data, {\n ...opts,\n path: `networks.${chainId}`,\n });\n}\n\n/**\n * Batch upsert a list of remote networks into user storage\n * @param networks - a list of networks to update or insert\n * @param opts - user storage options/configuration\n */\nexport async function batchUpsertRemoteNetworks(\n networks: RemoteNetworkConfiguration[],\n opts: UserStorageBaseOptions,\n): Promise<void> {\n const networkPathAndValues = networks.map((n) => {\n const path = n.chainId;\n const data = JSON.stringify(n);\n return [path, data] as [string, string];\n });\n\n await batchUpsertUserStorage(networkPathAndValues, {\n path: 'networks',\n ...opts,\n });\n}\n"]}
1
+ {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":";;;AACA,uEAA4E;AAE5E,8CAIqB;AAErB,gDAAgD;AAChD;;;;;;;GAOG;AACH,SAAS,yBAAyB,CAAC,OAAe;IAChD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;KAC1D;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,SAAS,GAAG,CAAQ,KAA+B,EAAkB,EAAE,CAC3E,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAExC;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACxC,IAA4B;IAE5B,MAAM,UAAU,GACd,CAAC,MAAM,IAAA,0CAA+B,EAAC;QACrC,GAAG,IAAI;QACP,IAAI,EAAE,2CAA0B,CAAC,QAAQ;KAC1C,CAAC,CAAC,IAAI,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,UAAU;SACvB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;SACpD,MAAM,CAAC,SAAS,CAAC,CAAC;IAErB,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,oDAcC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,mBAAmB,CACvC,OAAmC,EACnC,IAA4B;IAE5B,MAAM,OAAO,GAAW,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,MAAM,IAAA,4BAAiB,EAAC,IAAI,EAAE;QACnC,GAAG,IAAI;QACP,IAAI,EAAE,YAAY,OAAO,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAVD,kDAUC;AAED;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAC7C,QAAsC,EACtC,IAA4B;IAE5B,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAqB,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,IAAA,iCAAsB,EAAC,oBAAoB,EAAE;QACjD,IAAI,EAAE,UAAU;QAChB,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAdD,8DAcC","sourcesContent":["import type { RemoteNetworkConfiguration } from './types';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type { UserStorageBaseOptions } from '../services';\nimport {\n batchUpsertUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from '../services';\n\n// TODO - parse type, and handle version changes\n/**\n * parses the raw remote data to the NetworkConfiguration shape\n *\n * @todo - improve parsing instead of asserting\n * @todo - improve version handling\n * @param rawData - raw remote user storage data\n * @returns NetworkConfiguration or undefined if failed to parse\n */\nfunction parseNetworkConfiguration(rawData: string) {\n try {\n return JSON.parse(rawData) as RemoteNetworkConfiguration;\n } catch {\n return undefined;\n }\n}\n\nconst isDefined = <Value>(value: Value | null | undefined): value is Value =>\n value !== undefined && value !== null;\n\n/**\n * gets all remote networks from user storage\n *\n * @param opts - user storage options/configuration\n * @returns array of all remote networks\n */\nexport async function getAllRemoteNetworks(\n opts: UserStorageBaseOptions,\n): Promise<RemoteNetworkConfiguration[]> {\n const rawResults =\n (await getUserStorageAllFeatureEntries({\n ...opts,\n path: USER_STORAGE_FEATURE_NAMES.networks,\n })) ?? [];\n\n const results = rawResults\n .map((rawData) => parseNetworkConfiguration(rawData))\n .filter(isDefined);\n\n return results;\n}\n\n/**\n * Upserts a remote network to user storage\n *\n * @param network - network we are updating or inserting\n * @param opts - user storage options/configuration\n * @returns void\n */\nexport async function upsertRemoteNetwork(\n network: RemoteNetworkConfiguration,\n opts: UserStorageBaseOptions,\n) {\n const chainId: string = network.chainId.toString();\n const data = JSON.stringify(network);\n return await upsertUserStorage(data, {\n ...opts,\n path: `networks.${chainId}`,\n });\n}\n\n/**\n * Batch upsert a list of remote networks into user storage\n *\n * @param networks - a list of networks to update or insert\n * @param opts - user storage options/configuration\n */\nexport async function batchUpsertRemoteNetworks(\n networks: RemoteNetworkConfiguration[],\n opts: UserStorageBaseOptions,\n): Promise<void> {\n const networkPathAndValues = networks.map((n) => {\n const path = n.chainId;\n const data = JSON.stringify(n);\n return [path, data] as [string, string];\n });\n\n await batchUpsertUserStorage(networkPathAndValues, {\n path: 'networks',\n ...opts,\n });\n}\n"]}
@@ -1,19 +1,23 @@
1
- import type { UserStorageBaseOptions } from "../services.cjs";
2
1
  import type { RemoteNetworkConfiguration } from "./types.cjs";
2
+ import type { UserStorageBaseOptions } from "../services.cjs";
3
3
  /**
4
4
  * gets all remote networks from user storage
5
+ *
5
6
  * @param opts - user storage options/configuration
6
7
  * @returns array of all remote networks
7
8
  */
8
9
  export declare function getAllRemoteNetworks(opts: UserStorageBaseOptions): Promise<RemoteNetworkConfiguration[]>;
9
10
  /**
10
11
  * Upserts a remote network to user storage
12
+ *
11
13
  * @param network - network we are updating or inserting
12
14
  * @param opts - user storage options/configuration
15
+ * @returns void
13
16
  */
14
17
  export declare function upsertRemoteNetwork(network: RemoteNetworkConfiguration, opts: UserStorageBaseOptions): Promise<void>;
15
18
  /**
16
19
  * Batch upsert a list of remote networks into user storage
20
+ *
17
21
  * @param networks - a list of networks to update or insert
18
22
  * @param opts - user storage options/configuration
19
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AAM1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAqB1D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAYvC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,sBAAsB,iBAQ7B;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,0BAA0B,EAAE,EACtC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAWf"}
1
+ {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AA2B1D;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAYvC;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,sBAAsB,iBAQ7B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,0BAA0B,EAAE,EACtC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -1,19 +1,23 @@
1
- import type { UserStorageBaseOptions } from "../services.mjs";
2
1
  import type { RemoteNetworkConfiguration } from "./types.mjs";
2
+ import type { UserStorageBaseOptions } from "../services.mjs";
3
3
  /**
4
4
  * gets all remote networks from user storage
5
+ *
5
6
  * @param opts - user storage options/configuration
6
7
  * @returns array of all remote networks
7
8
  */
8
9
  export declare function getAllRemoteNetworks(opts: UserStorageBaseOptions): Promise<RemoteNetworkConfiguration[]>;
9
10
  /**
10
11
  * Upserts a remote network to user storage
12
+ *
11
13
  * @param network - network we are updating or inserting
12
14
  * @param opts - user storage options/configuration
15
+ * @returns void
13
16
  */
14
17
  export declare function upsertRemoteNetwork(network: RemoteNetworkConfiguration, opts: UserStorageBaseOptions): Promise<void>;
15
18
  /**
16
19
  * Batch upsert a list of remote networks into user storage
20
+ *
17
21
  * @param networks - a list of networks to update or insert
18
22
  * @param opts - user storage options/configuration
19
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AAM1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAqB1D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAYvC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,sBAAsB,iBAQ7B;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,0BAA0B,EAAE,EACtC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAWf"}
1
+ {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAoB;AA2B1D;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAYvC;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,sBAAsB,iBAQ7B;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,0BAA0B,EAAE,EACtC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -3,6 +3,7 @@ import { batchUpsertUserStorage, getUserStorageAllFeatureEntries, upsertUserStor
3
3
  // TODO - parse type, and handle version changes
4
4
  /**
5
5
  * parses the raw remote data to the NetworkConfiguration shape
6
+ *
6
7
  * @todo - improve parsing instead of asserting
7
8
  * @todo - improve version handling
8
9
  * @param rawData - raw remote user storage data
@@ -19,6 +20,7 @@ function parseNetworkConfiguration(rawData) {
19
20
  const isDefined = (value) => value !== undefined && value !== null;
20
21
  /**
21
22
  * gets all remote networks from user storage
23
+ *
22
24
  * @param opts - user storage options/configuration
23
25
  * @returns array of all remote networks
24
26
  */
@@ -34,8 +36,10 @@ export async function getAllRemoteNetworks(opts) {
34
36
  }
35
37
  /**
36
38
  * Upserts a remote network to user storage
39
+ *
37
40
  * @param network - network we are updating or inserting
38
41
  * @param opts - user storage options/configuration
42
+ * @returns void
39
43
  */
40
44
  export async function upsertRemoteNetwork(network, opts) {
41
45
  const chainId = network.chainId.toString();
@@ -47,6 +51,7 @@ export async function upsertRemoteNetwork(network, opts) {
47
51
  }
48
52
  /**
49
53
  * Batch upsert a list of remote networks into user storage
54
+ *
50
55
  * @param networks - a list of networks to update or insert
51
56
  * @param opts - user storage options/configuration
52
57
  */
@@ -1 +1 @@
1
- {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAE5E,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,iBAAiB,EAClB,wBAAoB;AAGrB,gDAAgD;AAChD;;;;;;GAMG;AACH,SAAS,yBAAyB,CAAC,OAAe;IAChD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;KAC1D;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,SAAS,GAAG,CAAQ,KAA+B,EAAkB,EAAE,CAC3E,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAA4B;IAE5B,MAAM,UAAU,GACd,CAAC,MAAM,+BAA+B,CAAC;QACrC,GAAG,IAAI;QACP,IAAI,EAAE,0BAA0B,CAAC,QAAQ;KAC1C,CAAC,CAAC,IAAI,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,UAAU;SACvB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;SACpD,MAAM,CAAC,SAAS,CAAC,CAAC;IAErB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAmC,EACnC,IAA4B;IAE5B,MAAM,OAAO,GAAW,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,MAAM,iBAAiB,CAAC,IAAI,EAAE;QACnC,GAAG,IAAI;QACP,IAAI,EAAE,YAAY,OAAO,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,QAAsC,EACtC,IAA4B;IAE5B,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC9C,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,EAAE,IAAI,CAAqB,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,sBAAsB,CAAC,oBAAoB,EAAE;QACjD,IAAI,EAAE,UAAU;QAChB,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type { UserStorageBaseOptions } from '../services';\nimport {\n batchUpsertUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from '../services';\nimport type { RemoteNetworkConfiguration } from './types';\n\n// TODO - parse type, and handle version changes\n/**\n * parses the raw remote data to the NetworkConfiguration shape\n * @todo - improve parsing instead of asserting\n * @todo - improve version handling\n * @param rawData - raw remote user storage data\n * @returns NetworkConfiguration or undefined if failed to parse\n */\nfunction parseNetworkConfiguration(rawData: string) {\n try {\n return JSON.parse(rawData) as RemoteNetworkConfiguration;\n } catch {\n return undefined;\n }\n}\n\nconst isDefined = <Value>(value: Value | null | undefined): value is Value =>\n value !== undefined && value !== null;\n\n/**\n * gets all remote networks from user storage\n * @param opts - user storage options/configuration\n * @returns array of all remote networks\n */\nexport async function getAllRemoteNetworks(\n opts: UserStorageBaseOptions,\n): Promise<RemoteNetworkConfiguration[]> {\n const rawResults =\n (await getUserStorageAllFeatureEntries({\n ...opts,\n path: USER_STORAGE_FEATURE_NAMES.networks,\n })) ?? [];\n\n const results = rawResults\n .map((rawData) => parseNetworkConfiguration(rawData))\n .filter(isDefined);\n\n return results;\n}\n\n/**\n * Upserts a remote network to user storage\n * @param network - network we are updating or inserting\n * @param opts - user storage options/configuration\n */\nexport async function upsertRemoteNetwork(\n network: RemoteNetworkConfiguration,\n opts: UserStorageBaseOptions,\n) {\n const chainId: string = network.chainId.toString();\n const data = JSON.stringify(network);\n return await upsertUserStorage(data, {\n ...opts,\n path: `networks.${chainId}`,\n });\n}\n\n/**\n * Batch upsert a list of remote networks into user storage\n * @param networks - a list of networks to update or insert\n * @param opts - user storage options/configuration\n */\nexport async function batchUpsertRemoteNetworks(\n networks: RemoteNetworkConfiguration[],\n opts: UserStorageBaseOptions,\n): Promise<void> {\n const networkPathAndValues = networks.map((n) => {\n const path = n.chainId;\n const data = JSON.stringify(n);\n return [path, data] as [string, string];\n });\n\n await batchUpsertUserStorage(networkPathAndValues, {\n path: 'networks',\n ...opts,\n });\n}\n"]}
1
+ {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/services.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAE5E,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,iBAAiB,EAClB,wBAAoB;AAErB,gDAAgD;AAChD;;;;;;;GAOG;AACH,SAAS,yBAAyB,CAAC,OAAe;IAChD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA+B,CAAC;KAC1D;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,SAAS,GAAG,CAAQ,KAA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AAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { RemoteNetworkConfiguration } from './types';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\nimport type { UserStorageBaseOptions } from '../services';\nimport {\n batchUpsertUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from '../services';\n\n// TODO - parse type, and handle version changes\n/**\n * parses the raw remote data to the NetworkConfiguration shape\n *\n * @todo - improve parsing instead of asserting\n * @todo - improve version handling\n * @param rawData - raw remote user storage data\n * @returns NetworkConfiguration or undefined if failed to parse\n */\nfunction parseNetworkConfiguration(rawData: string) {\n try {\n return JSON.parse(rawData) as RemoteNetworkConfiguration;\n } catch {\n return undefined;\n }\n}\n\nconst isDefined = <Value>(value: Value | null | undefined): value is Value =>\n value !== undefined && value !== null;\n\n/**\n * gets all remote networks from user storage\n *\n * @param opts - user storage options/configuration\n * @returns array of all remote networks\n */\nexport async function getAllRemoteNetworks(\n opts: UserStorageBaseOptions,\n): Promise<RemoteNetworkConfiguration[]> {\n const rawResults =\n (await getUserStorageAllFeatureEntries({\n ...opts,\n path: USER_STORAGE_FEATURE_NAMES.networks,\n })) ?? [];\n\n const results = rawResults\n .map((rawData) => parseNetworkConfiguration(rawData))\n .filter(isDefined);\n\n return results;\n}\n\n/**\n * Upserts a remote network to user storage\n *\n * @param network - network we are updating or inserting\n * @param opts - user storage options/configuration\n * @returns void\n */\nexport async function upsertRemoteNetwork(\n network: RemoteNetworkConfiguration,\n opts: UserStorageBaseOptions,\n) {\n const chainId: string = network.chainId.toString();\n const data = JSON.stringify(network);\n return await upsertUserStorage(data, {\n ...opts,\n path: `networks.${chainId}`,\n });\n}\n\n/**\n * Batch upsert a list of remote networks into user storage\n *\n * @param networks - a list of networks to update or insert\n * @param opts - user storage options/configuration\n */\nexport async function batchUpsertRemoteNetworks(\n networks: RemoteNetworkConfiguration[],\n opts: UserStorageBaseOptions,\n): Promise<void> {\n const networkPathAndValues = networks.map((n) => {\n const path = n.chainId;\n const data = JSON.stringify(n);\n return [path, data] as [string, string];\n });\n\n await batchUpsertUserStorage(networkPathAndValues, {\n path: 'networks',\n ...opts,\n });\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findNetworksToUpdate = exports.getUpdatedNetworkLists = exports.getMissingNetworkLists = exports.checkWhichNetworkIsLatest = exports.getDataStructures = void 0;
4
- const utils_1 = require("../utils.cjs");
5
4
  const types_1 = require("./types.cjs");
5
+ const utils_1 = require("../utils.cjs");
6
6
  const createMap = (networks) => {
7
7
  return new Map(networks.map((n) => [n.chainId, n]));
8
8
  };