@reown/appkit-core-react-native 0.0.0-develop-20250728141602 → 0.0.0-develop-20251008155354

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 (291) hide show
  1. package/lib/commonjs/controllers/ApiController.js +157 -91
  2. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  3. package/lib/commonjs/controllers/AssetController.js +0 -4
  4. package/lib/commonjs/controllers/AssetController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +180 -78
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionsController.js +425 -0
  8. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
  9. package/lib/commonjs/controllers/EnsController.js +2 -0
  10. package/lib/commonjs/controllers/EnsController.js.map +1 -1
  11. package/lib/commonjs/controllers/EventsController.js +51 -1
  12. package/lib/commonjs/controllers/EventsController.js.map +1 -1
  13. package/lib/commonjs/controllers/LogController.js +188 -0
  14. package/lib/commonjs/controllers/LogController.js.map +1 -0
  15. package/lib/commonjs/controllers/ModalController.js +9 -7
  16. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  17. package/lib/commonjs/controllers/OnRampController.js +47 -20
  18. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  19. package/lib/commonjs/controllers/OptionsController.js +28 -10
  20. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  21. package/lib/commonjs/controllers/PublicStateController.js.map +1 -1
  22. package/lib/commonjs/controllers/RouterController.js +7 -22
  23. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  24. package/lib/commonjs/controllers/SendController.js +111 -95
  25. package/lib/commonjs/controllers/SendController.js.map +1 -1
  26. package/lib/commonjs/controllers/SnackController.js +29 -5
  27. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  28. package/lib/commonjs/controllers/SwapController.js +162 -151
  29. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  30. package/lib/commonjs/controllers/ThemeController.js +14 -1
  31. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  32. package/lib/commonjs/controllers/TransactionsController.js +24 -18
  33. package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
  34. package/lib/commonjs/controllers/WcController.js +73 -0
  35. package/lib/commonjs/controllers/WcController.js.map +1 -0
  36. package/lib/commonjs/features/reown-authentication/ReownAuthentication.js +272 -0
  37. package/lib/commonjs/features/reown-authentication/ReownAuthentication.js.map +1 -0
  38. package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js +48 -0
  39. package/lib/commonjs/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
  40. package/lib/commonjs/features/reown-authentication/index.js +28 -0
  41. package/lib/commonjs/features/reown-authentication/index.js.map +1 -0
  42. package/lib/commonjs/index.js +33 -40
  43. package/lib/commonjs/index.js.map +1 -1
  44. package/lib/commonjs/package.json +1 -0
  45. package/lib/commonjs/utils/ApiUtil.js +1 -1
  46. package/lib/commonjs/utils/ApiUtil.js.map +1 -1
  47. package/lib/commonjs/utils/AssetUtil.js +8 -18
  48. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  49. package/lib/commonjs/utils/ConstantsUtil.js +117 -5
  50. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  51. package/lib/commonjs/utils/CoreHelperUtil.js +32 -9
  52. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  53. package/lib/commonjs/utils/EventUtil.js.map +1 -1
  54. package/lib/commonjs/utils/FetchUtil.js +7 -2
  55. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  56. package/lib/commonjs/utils/LogUtils.js +131 -0
  57. package/lib/commonjs/utils/LogUtils.js.map +1 -0
  58. package/lib/commonjs/utils/StorageUtil.js +131 -150
  59. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  60. package/lib/commonjs/utils/SwapApiUtil.js +15 -21
  61. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  62. package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
  63. package/lib/commonjs/utils/WalletUtil.js +23 -0
  64. package/lib/commonjs/utils/WalletUtil.js.map +1 -0
  65. package/lib/module/controllers/ApiController.js +159 -91
  66. package/lib/module/controllers/ApiController.js.map +1 -1
  67. package/lib/module/controllers/AssetController.js +2 -4
  68. package/lib/module/controllers/AssetController.js.map +1 -1
  69. package/lib/module/controllers/BlockchainApiController.js +182 -78
  70. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  71. package/lib/module/controllers/ConnectionsController.js +422 -0
  72. package/lib/module/controllers/ConnectionsController.js.map +1 -0
  73. package/lib/module/controllers/EnsController.js +4 -0
  74. package/lib/module/controllers/EnsController.js.map +1 -1
  75. package/lib/module/controllers/EventsController.js +53 -1
  76. package/lib/module/controllers/EventsController.js.map +1 -1
  77. package/lib/module/controllers/LogController.js +185 -0
  78. package/lib/module/controllers/LogController.js.map +1 -0
  79. package/lib/module/controllers/ModalController.js +11 -7
  80. package/lib/module/controllers/ModalController.js.map +1 -1
  81. package/lib/module/controllers/OnRampController.js +45 -16
  82. package/lib/module/controllers/OnRampController.js.map +1 -1
  83. package/lib/module/controllers/OptionsController.js +30 -10
  84. package/lib/module/controllers/OptionsController.js.map +1 -1
  85. package/lib/module/controllers/PublicStateController.js +2 -0
  86. package/lib/module/controllers/PublicStateController.js.map +1 -1
  87. package/lib/module/controllers/RouterController.js +9 -22
  88. package/lib/module/controllers/RouterController.js.map +1 -1
  89. package/lib/module/controllers/SendController.js +113 -95
  90. package/lib/module/controllers/SendController.js.map +1 -1
  91. package/lib/module/controllers/SnackController.js +31 -5
  92. package/lib/module/controllers/SnackController.js.map +1 -1
  93. package/lib/module/controllers/SwapController.js +164 -151
  94. package/lib/module/controllers/SwapController.js.map +1 -1
  95. package/lib/module/controllers/ThemeController.js +16 -1
  96. package/lib/module/controllers/ThemeController.js.map +1 -1
  97. package/lib/module/controllers/TransactionsController.js +26 -18
  98. package/lib/module/controllers/TransactionsController.js.map +1 -1
  99. package/lib/module/controllers/WcController.js +70 -0
  100. package/lib/module/controllers/WcController.js.map +1 -0
  101. package/lib/module/features/reown-authentication/ReownAuthentication.js +268 -0
  102. package/lib/module/features/reown-authentication/ReownAuthentication.js.map +1 -0
  103. package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js +43 -0
  104. package/lib/module/features/reown-authentication/ReownAuthenticationMessenger.js.map +1 -0
  105. package/lib/module/features/reown-authentication/index.js +5 -0
  106. package/lib/module/features/reown-authentication/index.js.map +1 -0
  107. package/lib/module/index.js +13 -8
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/utils/ApiUtil.js +3 -1
  110. package/lib/module/utils/ApiUtil.js.map +1 -1
  111. package/lib/module/utils/AssetUtil.js +10 -18
  112. package/lib/module/utils/AssetUtil.js.map +1 -1
  113. package/lib/module/utils/ConstantsUtil.js +119 -5
  114. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  115. package/lib/module/utils/CoreHelperUtil.js +34 -7
  116. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  117. package/lib/module/utils/EventUtil.js +2 -0
  118. package/lib/module/utils/EventUtil.js.map +1 -1
  119. package/lib/module/utils/FetchUtil.js +10 -2
  120. package/lib/module/utils/FetchUtil.js.map +1 -1
  121. package/lib/module/utils/LogUtils.js +121 -0
  122. package/lib/module/utils/LogUtils.js.map +1 -0
  123. package/lib/module/utils/StorageUtil.js +134 -150
  124. package/lib/module/utils/StorageUtil.js.map +1 -1
  125. package/lib/module/utils/SwapApiUtil.js +17 -21
  126. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  127. package/lib/module/utils/SwapCalculationUtil.js +3 -0
  128. package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
  129. package/lib/module/utils/WalletUtil.js +19 -0
  130. package/lib/module/utils/WalletUtil.js.map +1 -0
  131. package/lib/typescript/controllers/ApiController.d.ts +9 -8
  132. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  133. package/lib/typescript/controllers/AssetController.d.ts +0 -2
  134. package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
  135. package/lib/typescript/controllers/BlockchainApiController.d.ts +29 -11
  136. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  137. package/lib/typescript/controllers/ConnectionsController.d.ts +47 -0
  138. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
  139. package/lib/typescript/controllers/EnsController.d.ts +1 -1
  140. package/lib/typescript/controllers/EnsController.d.ts.map +1 -1
  141. package/lib/typescript/controllers/EventsController.d.ts +13 -1
  142. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  143. package/lib/typescript/controllers/LogController.d.ts +65 -0
  144. package/lib/typescript/controllers/LogController.d.ts.map +1 -0
  145. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  146. package/lib/typescript/controllers/OnRampController.d.ts +2 -2
  147. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  148. package/lib/typescript/controllers/OptionsController.d.ts +11 -6
  149. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  150. package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
  151. package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
  152. package/lib/typescript/controllers/RouterController.d.ts +6 -20
  153. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  154. package/lib/typescript/controllers/SendController.d.ts +5 -7
  155. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  156. package/lib/typescript/controllers/SnackController.d.ts +3 -3
  157. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  158. package/lib/typescript/controllers/SwapController.d.ts +12 -12
  159. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  160. package/lib/typescript/controllers/ThemeController.d.ts +3 -1
  161. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  162. package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
  163. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  164. package/lib/typescript/controllers/WcController.d.ts +27 -0
  165. package/lib/typescript/controllers/WcController.d.ts.map +1 -0
  166. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts +174 -0
  167. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -0
  168. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts +16 -0
  169. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts.map +1 -0
  170. package/lib/typescript/features/reown-authentication/index.d.ts +3 -0
  171. package/lib/typescript/features/reown-authentication/index.d.ts.map +1 -0
  172. package/lib/typescript/index.d.ts +7 -9
  173. package/lib/typescript/index.d.ts.map +1 -1
  174. package/lib/typescript/utils/ApiUtil.d.ts +1 -1
  175. package/lib/typescript/utils/AssetUtil.d.ts +3 -4
  176. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  177. package/lib/typescript/utils/ConstantsUtil.d.ts +11 -2
  178. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  179. package/lib/typescript/utils/CoreHelperUtil.d.ts +8 -6
  180. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  181. package/lib/typescript/utils/EventUtil.d.ts +1 -1
  182. package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
  183. package/lib/typescript/utils/FetchUtil.d.ts +4 -4
  184. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  185. package/lib/typescript/utils/LogUtils.d.ts +15 -0
  186. package/lib/typescript/utils/LogUtils.d.ts.map +1 -0
  187. package/lib/typescript/utils/StorageUtil.d.ts +15 -16
  188. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  189. package/lib/typescript/utils/SwapApiUtil.d.ts +3 -4
  190. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  191. package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
  192. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  193. package/lib/typescript/utils/WalletUtil.d.ts +5 -0
  194. package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
  195. package/package.json +11 -24
  196. package/src/controllers/ApiController.ts +167 -84
  197. package/src/controllers/AssetController.ts +0 -6
  198. package/src/controllers/BlockchainApiController.ts +168 -66
  199. package/src/controllers/ConnectionsController.ts +575 -0
  200. package/src/controllers/EnsController.ts +3 -1
  201. package/src/controllers/EventsController.ts +73 -2
  202. package/src/controllers/LogController.ts +250 -0
  203. package/src/controllers/ModalController.ts +10 -7
  204. package/src/controllers/OnRampController.ts +54 -19
  205. package/src/controllers/OptionsController.ts +46 -18
  206. package/src/controllers/PublicStateController.ts +1 -1
  207. package/src/controllers/RouterController.ts +20 -57
  208. package/src/controllers/SendController.ts +147 -111
  209. package/src/controllers/SnackController.ts +31 -5
  210. package/src/controllers/SwapController.ts +185 -183
  211. package/src/controllers/ThemeController.ts +18 -2
  212. package/src/controllers/TransactionsController.ts +27 -19
  213. package/src/controllers/WcController.ts +93 -0
  214. package/src/features/reown-authentication/ReownAuthentication.ts +475 -0
  215. package/src/features/reown-authentication/ReownAuthenticationMessenger.ts +80 -0
  216. package/src/features/reown-authentication/index.ts +2 -0
  217. package/src/index.ts +17 -20
  218. package/src/utils/ApiUtil.ts +1 -1
  219. package/src/utils/AssetUtil.ts +9 -22
  220. package/src/utils/ConstantsUtil.ts +121 -6
  221. package/src/utils/CoreHelperUtil.ts +66 -10
  222. package/src/utils/EventUtil.ts +1 -1
  223. package/src/utils/FetchUtil.ts +14 -5
  224. package/src/utils/LogUtils.ts +179 -0
  225. package/src/utils/StorageUtil.ts +191 -176
  226. package/src/utils/SwapApiUtil.ts +30 -37
  227. package/src/utils/SwapCalculationUtil.ts +1 -2
  228. package/src/utils/WalletUtil.ts +14 -0
  229. package/lib/commonjs/controllers/AccountController.js +0 -93
  230. package/lib/commonjs/controllers/AccountController.js.map +0 -1
  231. package/lib/commonjs/controllers/ConnectionController.js +0 -126
  232. package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
  233. package/lib/commonjs/controllers/ConnectorController.js +0 -49
  234. package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
  235. package/lib/commonjs/controllers/NetworkController.js +0 -90
  236. package/lib/commonjs/controllers/NetworkController.js.map +0 -1
  237. package/lib/commonjs/controllers/WebviewController.js +0 -52
  238. package/lib/commonjs/controllers/WebviewController.js.map +0 -1
  239. package/lib/commonjs/utils/ConnectionUtil.js +0 -33
  240. package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
  241. package/lib/commonjs/utils/NetworkUtil.js +0 -46
  242. package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
  243. package/lib/commonjs/utils/RouterUtil.js +0 -25
  244. package/lib/commonjs/utils/RouterUtil.js.map +0 -1
  245. package/lib/commonjs/utils/TypeUtil.js +0 -35
  246. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  247. package/lib/module/controllers/AccountController.js +0 -88
  248. package/lib/module/controllers/AccountController.js.map +0 -1
  249. package/lib/module/controllers/ConnectionController.js +0 -121
  250. package/lib/module/controllers/ConnectionController.js.map +0 -1
  251. package/lib/module/controllers/ConnectorController.js +0 -44
  252. package/lib/module/controllers/ConnectorController.js.map +0 -1
  253. package/lib/module/controllers/NetworkController.js +0 -85
  254. package/lib/module/controllers/NetworkController.js.map +0 -1
  255. package/lib/module/controllers/WebviewController.js +0 -47
  256. package/lib/module/controllers/WebviewController.js.map +0 -1
  257. package/lib/module/utils/ConnectionUtil.js +0 -27
  258. package/lib/module/utils/ConnectionUtil.js.map +0 -1
  259. package/lib/module/utils/NetworkUtil.js +0 -40
  260. package/lib/module/utils/NetworkUtil.js.map +0 -1
  261. package/lib/module/utils/RouterUtil.js +0 -19
  262. package/lib/module/utils/RouterUtil.js.map +0 -1
  263. package/lib/module/utils/TypeUtil.js +0 -28
  264. package/lib/module/utils/TypeUtil.js.map +0 -1
  265. package/lib/typescript/controllers/AccountController.d.ts +0 -33
  266. package/lib/typescript/controllers/AccountController.d.ts.map +0 -1
  267. package/lib/typescript/controllers/ConnectionController.d.ts +0 -66
  268. package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
  269. package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
  270. package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
  271. package/lib/typescript/controllers/NetworkController.d.ts +0 -34
  272. package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
  273. package/lib/typescript/controllers/WebviewController.d.ts +0 -21
  274. package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
  275. package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
  276. package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
  277. package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
  278. package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
  279. package/lib/typescript/utils/RouterUtil.d.ts +0 -5
  280. package/lib/typescript/utils/RouterUtil.d.ts.map +0 -1
  281. package/lib/typescript/utils/TypeUtil.d.ts +0 -849
  282. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  283. package/src/controllers/AccountController.ts +0 -128
  284. package/src/controllers/ConnectionController.ts +0 -200
  285. package/src/controllers/ConnectorController.ts +0 -63
  286. package/src/controllers/NetworkController.ts +0 -120
  287. package/src/controllers/WebviewController.ts +0 -63
  288. package/src/utils/ConnectionUtil.ts +0 -27
  289. package/src/utils/NetworkUtil.ts +0 -33
  290. package/src/utils/RouterUtil.ts +0 -21
  291. package/src/utils/TypeUtil.ts +0 -1036
@@ -4,20 +4,22 @@ import { proxy } from 'valtio';
4
4
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
5
  import { FetchUtil } from '../utils/FetchUtil';
6
6
  import { StorageUtil } from '../utils/StorageUtil';
7
- import type {
8
- ApiGetAnalyticsConfigResponse,
9
- ApiGetDataWalletsResponse,
10
- ApiGetWalletsRequest,
11
- ApiGetWalletsResponse,
12
- WcWallet
13
- } from '../utils/TypeUtil';
7
+ import {
8
+ type ApiGetAnalyticsConfigResponse,
9
+ type ApiGetDataWalletsResponse,
10
+ type ApiGetWalletsRequest,
11
+ type ApiGetWalletsResponse,
12
+ type CustomWallet,
13
+ type WcWallet,
14
+ PresetsUtil
15
+ } from '@reown/appkit-common-react-native';
14
16
  import { AssetController } from './AssetController';
15
- import { NetworkController } from './NetworkController';
16
17
  import { OptionsController } from './OptionsController';
17
- import { ConnectorController } from './ConnectorController';
18
- import { ConnectionController } from './ConnectionController';
18
+ import { WcController } from './WcController';
19
19
  import { ApiUtil } from '../utils/ApiUtil';
20
20
  import { SnackController } from './SnackController';
21
+ import { ConnectionsController } from './ConnectionsController';
22
+ import { LogController } from './LogController';
21
23
 
22
24
  // -- Helpers ------------------------------------------- //
23
25
  const baseUrl = CoreHelperUtil.getApiUrl();
@@ -64,13 +66,18 @@ export const ApiController = {
64
66
  return subKey(state, key, callback);
65
67
  },
66
68
 
67
- _getApiHeaders() {
69
+ _getApiParams() {
68
70
  const { projectId, sdkType, sdkVersion } = OptionsController.state;
69
71
 
70
72
  return {
71
- 'x-project-id': projectId,
72
- 'x-sdk-type': sdkType,
73
- 'x-sdk-version': sdkVersion,
73
+ projectId,
74
+ st: sdkType,
75
+ sv: sdkVersion
76
+ };
77
+ },
78
+
79
+ _getApiHeaders() {
80
+ return {
74
81
  'User-Agent': ApiUtil.getUserAgent(),
75
82
  'origin': ApiUtil.getOrigin()
76
83
  };
@@ -78,113 +85,164 @@ export const ApiController = {
78
85
 
79
86
  async _fetchWalletImage(imageId: string) {
80
87
  const headers = ApiController._getApiHeaders();
81
- const url = await api.fetchImage(`/getWalletImage/${imageId}`, headers);
88
+ const url = await api.fetchImage(
89
+ `/getWalletImage/${imageId}`,
90
+ headers,
91
+ ApiController._getApiParams()
92
+ );
82
93
  if (url) {
83
94
  AssetController.setWalletImage(imageId, url);
84
95
  }
85
96
  },
86
97
 
87
- async _fetchConnectorImage(imageId: string) {
88
- const headers = ApiController._getApiHeaders();
89
- const url = await api.fetchImage(`/public/getAssetImage/${imageId}`, headers);
90
- if (url) {
91
- AssetController.setConnectorImage(imageId, url);
98
+ async _fetchNetworkImage(networkId: string) {
99
+ const imageId = PresetsUtil.NetworkImageIds[networkId];
100
+ if (!imageId) {
101
+ return;
92
102
  }
93
- },
94
103
 
95
- async _fetchNetworkImage(imageId: string) {
96
104
  const headers = ApiController._getApiHeaders();
97
- const url = await api.fetchImage(`/public/getAssetImage/${imageId}`, headers);
105
+ const url = await api.fetchImage(
106
+ `/public/getAssetImage/${imageId}`,
107
+ headers,
108
+ ApiController._getApiParams()
109
+ );
98
110
  if (url) {
99
- AssetController.setNetworkImage(imageId, url);
111
+ AssetController.setNetworkImage(networkId, url);
100
112
  }
101
113
  },
102
114
 
103
- async fetchConnectorImages() {
104
- const { connectors } = ConnectorController.state;
105
- const ids = connectors.map(({ imageId }) => imageId).filter(Boolean);
106
- await CoreHelperUtil.allSettled(
107
- (ids as string[]).map(id => ApiController._fetchConnectorImage(id))
108
- );
109
- },
110
-
111
115
  async fetchNetworkImages() {
112
- const { requestedCaipNetworks } = NetworkController.state;
113
- const ids = requestedCaipNetworks?.map(({ imageId }) => imageId).filter(Boolean);
114
- if (ids) {
116
+ const networks = ConnectionsController.state.networks;
117
+ if (networks) {
115
118
  await CoreHelperUtil.allSettled(
116
- (ids as string[]).map(id => ApiController._fetchNetworkImage(id))
119
+ networks.map(network => ApiController._fetchNetworkImage(network.id as string))
117
120
  );
118
121
  }
119
122
  },
120
123
 
121
124
  async fetchInstalledWallets() {
122
- const { includeWalletIds } = OptionsController.state;
123
- const path = Platform.select({ default: 'getIosData', android: 'getAndroidData' });
124
- const response = await api.get<ApiGetDataWalletsResponse>({
125
- path,
126
- headers: ApiController._getApiHeaders()
127
- });
125
+ // Add timeout to prevent hanging
126
+ const controller = new AbortController();
127
+ let timeoutId: NodeJS.Timeout | undefined;
128
128
 
129
- if (!response) return;
129
+ try {
130
+ const { includeWalletIds, customWallets } = OptionsController.state;
131
+ const path = Platform.select({ default: 'getIosData', android: 'getAndroidData' });
132
+ const response = await api.get<ApiGetDataWalletsResponse>({
133
+ path,
134
+ params: ApiController._getApiParams(),
135
+ headers: ApiController._getApiHeaders()
136
+ });
130
137
 
131
- let { data: walletData } = response;
138
+ if (!response) return;
132
139
 
133
- if (includeWalletIds?.length) {
134
- walletData = walletData.filter(({ id }) => includeWalletIds.includes(id));
135
- }
140
+ let { data: walletData } = response;
136
141
 
137
- const promises = walletData.map(async item => {
138
- return {
139
- id: item.id,
140
- isInstalled: await CoreHelperUtil.checkInstalled(item)
141
- };
142
- });
142
+ if (includeWalletIds?.length) {
143
+ walletData = walletData.filter(({ id }) => includeWalletIds.includes(id));
144
+ }
143
145
 
144
- const results = await Promise.all(promises);
145
- const installed = results.filter(({ isInstalled }) => isInstalled).map(({ id }) => id);
146
- const { excludeWalletIds } = OptionsController.state;
146
+ const promises = walletData.map(async item => {
147
+ return {
148
+ id: item.id,
149
+ isInstalled: await CoreHelperUtil.checkInstalled(item)
150
+ };
151
+ });
147
152
 
148
- if (installed.length > 0) {
149
- const walletResponse = await api.get<ApiGetWalletsResponse>({
150
- path: '/getWallets',
151
- headers: ApiController._getApiHeaders(),
152
- params: {
153
- page: '1',
154
- platform: this.platform(),
155
- entries: installed?.length.toString(),
156
- include: installed?.join(','),
157
- exclude: excludeWalletIds?.join(',')
158
- }
153
+ const customPromises = customWallets?.map(async item => {
154
+ return {
155
+ id: item.id,
156
+ isInstalled: await CoreHelperUtil.checkInstalled(item)
157
+ };
159
158
  });
160
159
 
161
- if (walletResponse?.data) {
162
- const walletImages = walletResponse.data.map(d => d.image_id).filter(Boolean);
163
- await CoreHelperUtil.allSettled(
164
- (walletImages as string[]).map(id => ApiController._fetchWalletImage(id))
165
- );
166
- state.installed = walletResponse.data;
167
- this.updateRecentWalletsInfo(walletResponse.data);
160
+ const results = await Promise.all(promises);
161
+ const installed = results.filter(({ isInstalled }) => isInstalled).map(({ id }) => id);
162
+ const { excludeWalletIds } = OptionsController.state;
163
+ const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
164
+
165
+ // Add timeout to prevent hanging
166
+ timeoutId = setTimeout(() => controller.abort(), 10000);
167
+
168
+ // Collect API-sourced installed wallets
169
+ let apiInstalledWallets: WcWallet[] = [];
170
+ if (installed.length > 0) {
171
+ const walletResponse = await api.get<ApiGetWalletsResponse>({
172
+ path: '/getWallets',
173
+ headers: ApiController._getApiHeaders(),
174
+ params: {
175
+ ...ApiController._getApiParams(),
176
+ page: '1',
177
+ platform: this.platform(),
178
+ entries: installed?.length.toString(),
179
+ include: installed?.join(','),
180
+ exclude: excludeWalletIds?.join(','),
181
+ chains: chains.join(',')
182
+ },
183
+ signal: controller.signal
184
+ });
185
+
186
+ if (walletResponse?.data) {
187
+ const walletImages = walletResponse.data.map(d => d.image_id).filter(Boolean);
188
+ await CoreHelperUtil.allSettled(
189
+ (walletImages as string[]).map(id => ApiController._fetchWalletImage(id))
190
+ );
191
+ apiInstalledWallets = walletResponse.data;
192
+ }
193
+ }
194
+
195
+ clearTimeout(timeoutId);
196
+
197
+ // Collect custom installed wallets
198
+ let customInstalledWallets: CustomWallet[] = [];
199
+ if (customPromises?.length) {
200
+ const customResults = await Promise.all(customPromises);
201
+ const customInstalled = customResults
202
+ .filter(({ isInstalled }) => isInstalled)
203
+ .map(({ id }) => id);
204
+ customInstalledWallets =
205
+ customWallets?.filter(wallet => customInstalled.includes(wallet.id)) ?? [];
168
206
  }
207
+
208
+ // Merge and de-duplicate by id, preserving order (API first, then custom)
209
+ const byId = new Map<string, WcWallet>();
210
+ [...apiInstalledWallets, ...customInstalledWallets].forEach(wallet => {
211
+ if (!byId.has(wallet.id)) {
212
+ byId.set(wallet.id, wallet);
213
+ }
214
+ });
215
+ const combinedInstalled = Array.from(byId.values());
216
+ state.installed = combinedInstalled;
217
+ if (combinedInstalled.length) {
218
+ this.updateRecentWalletsInfo(combinedInstalled);
219
+ }
220
+ } catch (error) {
221
+ state.installed = [];
222
+ clearTimeout(timeoutId);
223
+ LogController.sendError(error, 'ApiController.ts', 'fetchInstalledWallets');
169
224
  }
170
225
  },
171
226
 
172
227
  async fetchFeaturedWallets() {
173
228
  const { featuredWalletIds } = OptionsController.state;
174
229
  const exclude = state.installed.map(({ id }) => id);
230
+ const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
175
231
 
176
232
  if (featuredWalletIds?.length) {
177
233
  const response = await api.get<ApiGetWalletsResponse>({
178
234
  path: '/getWallets',
179
235
  headers: ApiController._getApiHeaders(),
180
236
  params: {
237
+ ...ApiController._getApiParams(),
181
238
  page: '1',
182
239
  platform: this.platform(),
183
240
  entries: featuredWalletIds?.length
184
241
  ? String(featuredWalletIds.length)
185
242
  : recommendedEntries,
186
243
  include: featuredWalletIds?.join(','),
187
- exclude: exclude?.join(',')
244
+ exclude: exclude?.join(','),
245
+ chains: chains.join(',')
188
246
  }
189
247
  });
190
248
  if (!response) return;
@@ -201,9 +259,22 @@ export const ApiController = {
201
259
  }
202
260
  },
203
261
 
262
+ async fetchCustomWalletImages() {
263
+ const { customWallets } = OptionsController.state;
264
+ if (!customWallets?.length) {
265
+ return;
266
+ }
267
+
268
+ const images = customWallets.map(w => w.image_id).filter(Boolean);
269
+ await CoreHelperUtil.allSettled(
270
+ (images as string[]).map(id => ApiController._fetchWalletImage(id))
271
+ );
272
+ },
273
+
204
274
  async fetchRecommendedWallets() {
205
275
  const { installed } = ApiController.state;
206
276
  const { includeWalletIds, excludeWalletIds, featuredWalletIds } = OptionsController.state;
277
+ const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
207
278
 
208
279
  const exclude = [
209
280
  ...installed.map(({ id }) => id),
@@ -215,11 +286,13 @@ export const ApiController = {
215
286
  path: '/getWallets',
216
287
  headers: ApiController._getApiHeaders(),
217
288
  params: {
289
+ ...ApiController._getApiParams(),
218
290
  page: '1',
219
291
  platform: this.platform(),
220
292
  entries: recommendedEntries,
221
293
  include: includeWalletIds?.join(','),
222
- exclude: exclude?.join(',')
294
+ exclude: exclude?.join(','),
295
+ chains: chains.join(',')
223
296
  }
224
297
  });
225
298
 
@@ -242,6 +315,7 @@ export const ApiController = {
242
315
 
243
316
  async fetchWallets({ page }: Pick<ApiGetWalletsRequest, 'page'>) {
244
317
  const { includeWalletIds, excludeWalletIds, featuredWalletIds } = OptionsController.state;
318
+ const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
245
319
  const exclude = [
246
320
  ...state.installed.map(({ id }) => id),
247
321
  ...state.recommended.map(({ id }) => id),
@@ -252,11 +326,13 @@ export const ApiController = {
252
326
  path: '/getWallets',
253
327
  headers: ApiController._getApiHeaders(),
254
328
  params: {
329
+ ...ApiController._getApiParams(),
255
330
  page: String(page),
256
331
  platform: this.platform(),
257
332
  entries: String(defaultEntries),
258
333
  include: includeWalletIds?.join(','),
259
- exclude: exclude.join(',')
334
+ exclude: exclude.join(','),
335
+ chains: chains.join(',')
260
336
  }
261
337
  });
262
338
 
@@ -279,17 +355,20 @@ export const ApiController = {
279
355
 
280
356
  async searchWallet({ search }: Pick<ApiGetWalletsRequest, 'search'>) {
281
357
  const { includeWalletIds, excludeWalletIds } = OptionsController.state;
358
+ const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
282
359
  state.search = [];
283
360
  const response = await api.get<ApiGetWalletsResponse>({
284
361
  path: '/getWallets',
285
362
  headers: ApiController._getApiHeaders(),
286
363
  params: {
364
+ ...ApiController._getApiParams(),
287
365
  page: '1',
288
366
  platform: this.platform(),
289
367
  entries: String(defaultEntries),
290
368
  search,
291
369
  include: includeWalletIds?.join(','),
292
- exclude: excludeWalletIds?.join(',')
370
+ exclude: excludeWalletIds?.join(','),
371
+ chains: chains.join(',')
293
372
  }
294
373
  });
295
374
 
@@ -324,7 +403,7 @@ export const ApiController = {
324
403
 
325
404
  if (update) {
326
405
  await StorageUtil.setRecentWallets(updatedRecent);
327
- ConnectionController.setRecentWallets(updatedRecent);
406
+ WcController.setRecentWallets(updatedRecent);
328
407
  }
329
408
  },
330
409
 
@@ -332,19 +411,22 @@ export const ApiController = {
332
411
  try {
333
412
  state.prefetchError = false;
334
413
  state.prefetchLoading = true;
335
- // this fetch must resolve first so we filter them in the other wallet requests
336
- await ApiController.fetchInstalledWallets();
337
414
 
338
415
  const promises = [
339
- ApiController.fetchFeaturedWallets(),
340
- ApiController.fetchRecommendedWallets(),
341
416
  ApiController.fetchNetworkImages(),
342
- ApiController.fetchConnectorImages()
417
+ ApiController.fetchCustomWalletImages()
343
418
  ];
419
+
344
420
  if (OptionsController.state.enableAnalytics === undefined) {
345
421
  promises.push(ApiController.fetchAnalyticsConfig());
346
422
  }
347
423
 
424
+ // this fetch must resolve first so we filter them in the other wallet requests
425
+ await ApiController.fetchInstalledWallets();
426
+
427
+ promises.push(ApiController.fetchFeaturedWallets());
428
+ promises.push(ApiController.fetchRecommendedWallets());
429
+
348
430
  state.prefetchPromise = Promise.race([
349
431
  CoreHelperUtil.allSettled(promises),
350
432
  CoreHelperUtil.wait(3000)
@@ -363,6 +445,7 @@ export const ApiController = {
363
445
  async fetchAnalyticsConfig() {
364
446
  const response = await api.get<ApiGetAnalyticsConfigResponse>({
365
447
  path: '/getAnalyticsConfig',
448
+ params: ApiController._getApiParams(),
366
449
  headers: ApiController._getApiHeaders()
367
450
  });
368
451
  if (!response) return;
@@ -4,7 +4,6 @@ import { proxy } from 'valtio';
4
4
  export interface AssetControllerState {
5
5
  walletImages: Record<string, string>;
6
6
  networkImages: Record<string, string>;
7
- connectorImages: Record<string, string>;
8
7
  tokenImages: Record<string, string>;
9
8
  }
10
9
 
@@ -12,7 +11,6 @@ export interface AssetControllerState {
12
11
  const state = proxy<AssetControllerState>({
13
12
  walletImages: {},
14
13
  networkImages: {},
15
- connectorImages: {},
16
14
  tokenImages: {}
17
15
  });
18
16
 
@@ -28,10 +26,6 @@ export const AssetController = {
28
26
  state.networkImages[key] = value;
29
27
  },
30
28
 
31
- setConnectorImage(key: string, value: string) {
32
- state.connectorImages[key] = value;
33
- },
34
-
35
29
  setTokenImage(key: string, value: string) {
36
30
  state.tokenImages[key] = value;
37
31
  }