@reown/appkit-core-react-native 0.0.0-develop-20250728153935 → 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 -850
  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 -1039
@@ -1,50 +1,43 @@
1
1
  /* eslint-disable no-console */
2
- import AsyncStorage from '@react-native-async-storage/async-storage';
3
- import type {
4
- OnRampCountry,
5
- OnRampCountryDefaults,
6
- OnRampFiatCurrency,
7
- OnRampFiatLimit,
8
- OnRampServiceProvider,
9
- WcWallet
10
- } from './TypeUtil';
11
2
  import {
3
+ type OnRampCountry,
4
+ type OnRampFiatCurrency,
5
+ type OnRampFiatLimit,
6
+ type OnRampServiceProvider,
7
+ type OnRampCountryDefaults,
8
+ type WcWallet,
12
9
  DateUtil,
13
- type SocialProvider,
14
- type ConnectorType
10
+ type ConnectorType,
11
+ type ChainNamespace,
12
+ type WalletDeepLink,
13
+ SafeStorageKeys
15
14
  } from '@reown/appkit-common-react-native';
15
+ import { OptionsController } from '../controllers/OptionsController';
16
+ import { LogController } from '../controllers/LogController';
16
17
 
17
- // -- Helpers -----------------------------------------------------------------
18
- const WC_DEEPLINK = 'WALLETCONNECT_DEEPLINK_CHOICE';
19
- const RECENT_WALLET = '@w3m/recent';
20
- const CONNECTED_WALLET_IMAGE_URL = '@w3m/connected_wallet_image_url';
21
- const CONNECTED_CONNECTOR = '@w3m/connected_connector';
22
- const CONNECTED_SOCIAL = '@appkit/connected_social';
23
- const ONRAMP_PREFERRED_COUNTRY = '@appkit/onramp_preferred_country';
24
- const ONRAMP_COUNTRIES = '@appkit/onramp_countries';
25
- const ONRAMP_COUNTRIES_DEFAULTS = '@appkit/onramp_countries_defaults';
26
- const ONRAMP_SERVICE_PROVIDERS = '@appkit/onramp_service_providers';
27
- const ONRAMP_FIAT_LIMITS = '@appkit/onramp_fiat_limits';
28
- const ONRAMP_FIAT_CURRENCIES = '@appkit/onramp_fiat_currencies';
29
- const ONRAMP_PREFERRED_FIAT_CURRENCY = '@appkit/onramp_preferred_fiat_currency';
30
18
  // -- Utility -----------------------------------------------------------------
31
19
  export const StorageUtil = {
32
- setWalletConnectDeepLink({ href, name }: { href: string; name: string }) {
20
+ setWalletConnectDeepLink({ href, name }: WalletDeepLink) {
33
21
  try {
34
- AsyncStorage.setItem(WC_DEEPLINK, JSON.stringify({ href, name }));
35
- } catch {
36
- console.info('Unable to set WalletConnect deep link');
22
+ OptionsController.getStorage().setItem(SafeStorageKeys.WC_DEEPLINK, {
23
+ href,
24
+ name
25
+ });
26
+ } catch (error) {
27
+ LogController.sendError(error, 'StorageUtil.ts', 'setWalletConnectDeepLink');
37
28
  }
38
29
  },
39
30
 
40
31
  async getWalletConnectDeepLink() {
41
32
  try {
42
- const deepLink = await AsyncStorage.getItem(WC_DEEPLINK);
33
+ const deepLink = await OptionsController.getStorage().getItem<WalletDeepLink>(
34
+ SafeStorageKeys.WC_DEEPLINK
35
+ );
43
36
  if (deepLink) {
44
- return JSON.parse(deepLink);
37
+ return deepLink;
45
38
  }
46
- } catch {
47
- console.info('Unable to get WalletConnect deep link');
39
+ } catch (error) {
40
+ LogController.sendError(error, 'StorageUtil.ts', 'getWalletConnectDeepLink');
48
41
  }
49
42
 
50
43
  return undefined;
@@ -52,9 +45,9 @@ export const StorageUtil = {
52
45
 
53
46
  async removeWalletConnectDeepLink() {
54
47
  try {
55
- await AsyncStorage.removeItem(WC_DEEPLINK);
56
- } catch {
57
- console.info('Unable to delete WalletConnect deep link');
48
+ await OptionsController.getStorage().removeItem(SafeStorageKeys.WC_DEEPLINK);
49
+ } catch (error) {
50
+ LogController.sendError(error, 'StorageUtil.ts', 'removeWalletConnectDeepLink');
58
51
  }
59
52
  },
60
53
 
@@ -71,11 +64,11 @@ export const StorageUtil = {
71
64
  if (recentWallets.length > 2) {
72
65
  recentWallets.pop();
73
66
  }
74
- AsyncStorage.setItem(RECENT_WALLET, JSON.stringify(recentWallets));
67
+ OptionsController.getStorage().setItem(SafeStorageKeys.RECENT_WALLET, recentWallets);
75
68
 
76
69
  return recentWallets;
77
- } catch {
78
- console.info('Unable to set recent wallet');
70
+ } catch (error) {
71
+ LogController.sendError(error, 'StorageUtil.ts', 'addRecentWallet');
79
72
 
80
73
  return undefined;
81
74
  }
@@ -83,119 +76,91 @@ export const StorageUtil = {
83
76
 
84
77
  async setRecentWallets(wallets: WcWallet[]) {
85
78
  try {
86
- await AsyncStorage.setItem(RECENT_WALLET, JSON.stringify(wallets));
87
- } catch {
88
- console.info('Unable to set recent wallets');
79
+ await OptionsController.getStorage().setItem(SafeStorageKeys.RECENT_WALLET, wallets);
80
+ } catch (error) {
81
+ LogController.sendError(error, 'StorageUtil.ts', 'setRecentWallets');
89
82
  }
90
83
  },
91
84
 
92
85
  async getRecentWallets(): Promise<WcWallet[]> {
93
86
  try {
94
- const recent = await AsyncStorage.getItem(RECENT_WALLET);
87
+ const recent = await OptionsController.getStorage().getItem(SafeStorageKeys.RECENT_WALLET);
95
88
 
96
- return recent ? JSON.parse(recent) : [];
97
- } catch {
98
- console.info('Unable to get recent wallets');
89
+ return recent ?? [];
90
+ } catch (error) {
91
+ LogController.sendError(error, 'StorageUtil.ts', 'getRecentWallets');
99
92
  }
100
93
 
101
94
  return [];
102
95
  },
103
96
 
104
- async setConnectedConnector(connectorType: ConnectorType) {
105
- try {
106
- await AsyncStorage.setItem(CONNECTED_CONNECTOR, JSON.stringify(connectorType));
107
- } catch {
108
- console.info('Unable to set Connected Connector');
109
- }
110
- },
111
-
112
- async getConnectedConnector(): Promise<ConnectorType | undefined> {
97
+ async setConnectedConnectors({
98
+ type,
99
+ namespaces
100
+ }: {
101
+ type: ConnectorType;
102
+ namespaces: string[];
103
+ }) {
113
104
  try {
114
- const connector = (await AsyncStorage.getItem(CONNECTED_CONNECTOR)) as ConnectorType;
115
-
116
- return connector ? JSON.parse(connector) : undefined;
117
- } catch {
118
- console.info('Unable to get Connected Connector');
119
- }
120
-
121
- return undefined;
122
- },
123
-
124
- async removeConnectedConnector() {
125
- try {
126
- await AsyncStorage.removeItem(CONNECTED_CONNECTOR);
127
- } catch {
128
- console.info('Unable to remove Connected Connector');
129
- }
130
- },
131
-
132
- async setConnectedWalletImageUrl(url: string) {
133
- try {
134
- await AsyncStorage.setItem(CONNECTED_WALLET_IMAGE_URL, url);
135
- } catch {
136
- console.info('Unable to set Connected Wallet Image URL');
137
- }
138
- },
139
-
140
- async getConnectedWalletImageUrl() {
141
- try {
142
- return await AsyncStorage.getItem(CONNECTED_WALLET_IMAGE_URL);
143
- } catch {
144
- console.info('Unable to get Connected Wallet Image URL');
145
- }
146
-
147
- return undefined;
148
- },
149
-
150
- async removeConnectedWalletImageUrl() {
151
- try {
152
- await AsyncStorage.removeItem(CONNECTED_WALLET_IMAGE_URL);
153
- } catch {
154
- console.info('Unable to remove Connected Wallet Image URL');
155
- }
156
- },
157
-
158
- async setConnectedSocialProvider(provider: SocialProvider) {
159
- try {
160
- await AsyncStorage.setItem(CONNECTED_SOCIAL, JSON.stringify(provider));
161
- } catch {
162
- console.info('Unable to set Connected Social Provider');
105
+ const currentConnectors = (await StorageUtil.getConnectedConnectors()) || [];
106
+ // Only add if it doesn't exist already
107
+ if (!currentConnectors.some(c => c.type === type)) {
108
+ const updatedConnectors = [...currentConnectors, { type, namespaces }];
109
+ await OptionsController.getStorage().setItem(
110
+ SafeStorageKeys.CONNECTED_CONNECTORS,
111
+ updatedConnectors
112
+ );
113
+ }
114
+ } catch (error) {
115
+ LogController.sendError(error, 'StorageUtil.ts', 'setConnectedConnectors');
163
116
  }
164
117
  },
165
118
 
166
- async getConnectedSocialProvider() {
119
+ async getConnectedConnectors(): Promise<{ type: ConnectorType; namespaces: string[] }[]> {
167
120
  try {
168
- const provider = (await AsyncStorage.getItem(CONNECTED_SOCIAL)) as SocialProvider;
121
+ const connectors = await OptionsController.getStorage().getItem<
122
+ { type: ConnectorType; namespaces: string[] }[]
123
+ >(SafeStorageKeys.CONNECTED_CONNECTORS);
169
124
 
170
- return provider ? JSON.parse(provider) : undefined;
171
- } catch {
172
- console.info('Unable to get Connected Social Provider');
125
+ return connectors ?? [];
126
+ } catch (err) {
127
+ LogController.sendError(err, 'StorageUtil.ts', 'getConnectedConnectors');
173
128
  }
174
129
 
175
- return undefined;
130
+ return [];
176
131
  },
177
132
 
178
- async removeConnectedSocialProvider() {
133
+ async removeConnectedConnectors(type: ConnectorType) {
179
134
  try {
180
- await AsyncStorage.removeItem(CONNECTED_SOCIAL);
181
- } catch {
182
- console.info('Unable to remove Connected Social Provider');
135
+ const currentConnectors = await StorageUtil.getConnectedConnectors();
136
+ const updatedConnectors = currentConnectors.filter(c => c.type !== type);
137
+ await OptionsController.getStorage().setItem(
138
+ SafeStorageKeys.CONNECTED_CONNECTORS,
139
+ updatedConnectors
140
+ );
141
+ } catch (error) {
142
+ LogController.sendError(error, 'StorageUtil.ts', 'removeConnectedConnectors');
183
143
  }
184
144
  },
185
145
 
186
146
  async setOnRampPreferredCountry(country: OnRampCountry) {
187
147
  try {
188
- await AsyncStorage.setItem(ONRAMP_PREFERRED_COUNTRY, JSON.stringify(country));
189
- } catch {
190
- console.info('Unable to set OnRamp Preferred Country');
148
+ await OptionsController.getStorage().setItem(
149
+ SafeStorageKeys.ONRAMP_PREFERRED_COUNTRY,
150
+ country
151
+ );
152
+ } catch (error) {
153
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampPreferredCountry');
191
154
  }
192
155
  },
193
156
 
194
157
  async getOnRampPreferredCountry() {
195
158
  try {
196
- const country = await AsyncStorage.getItem(ONRAMP_PREFERRED_COUNTRY);
159
+ const country = await OptionsController.getStorage().getItem<OnRampCountry>(
160
+ SafeStorageKeys.ONRAMP_PREFERRED_COUNTRY
161
+ );
197
162
 
198
- return country ? (JSON.parse(country) as OnRampCountry) : undefined;
163
+ return country ?? undefined;
199
164
  } catch {
200
165
  console.info('Unable to get OnRamp Preferred Country');
201
166
  }
@@ -205,19 +170,24 @@ export const StorageUtil = {
205
170
 
206
171
  async setOnRampPreferredFiatCurrency(currency: OnRampFiatCurrency) {
207
172
  try {
208
- await AsyncStorage.setItem(ONRAMP_PREFERRED_FIAT_CURRENCY, JSON.stringify(currency));
209
- } catch {
210
- console.info('Unable to set OnRamp Preferred Fiat Currency');
173
+ await OptionsController.getStorage().setItem(
174
+ SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY,
175
+ currency
176
+ );
177
+ } catch (error) {
178
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampPreferredFiatCurrency');
211
179
  }
212
180
  },
213
181
 
214
182
  async getOnRampPreferredFiatCurrency() {
215
183
  try {
216
- const currency = await AsyncStorage.getItem(ONRAMP_PREFERRED_FIAT_CURRENCY);
184
+ const currency = await OptionsController.getStorage().getItem<OnRampFiatCurrency>(
185
+ SafeStorageKeys.ONRAMP_PREFERRED_FIAT_CURRENCY
186
+ );
217
187
 
218
- return currency ? (JSON.parse(currency) as OnRampFiatCurrency) : undefined;
219
- } catch {
220
- console.info('Unable to get OnRamp Preferred Fiat Currency');
188
+ return currency ?? undefined;
189
+ } catch (error) {
190
+ LogController.sendError(error, 'StorageUtil.ts', 'getOnRampPreferredFiatCurrency');
221
191
  }
222
192
 
223
193
  return undefined;
@@ -225,19 +195,21 @@ export const StorageUtil = {
225
195
 
226
196
  async setOnRampCountries(countries: OnRampCountry[]) {
227
197
  try {
228
- await AsyncStorage.setItem(ONRAMP_COUNTRIES, JSON.stringify(countries));
229
- } catch {
230
- console.info('Unable to set OnRamp Countries');
198
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_COUNTRIES, countries);
199
+ } catch (error) {
200
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampCountries');
231
201
  }
232
202
  },
233
203
 
234
204
  async getOnRampCountries() {
235
205
  try {
236
- const countries = await AsyncStorage.getItem(ONRAMP_COUNTRIES);
206
+ const countries = await OptionsController.getStorage().getItem<OnRampCountry[]>(
207
+ SafeStorageKeys.ONRAMP_COUNTRIES
208
+ );
237
209
 
238
- return countries ? (JSON.parse(countries) as OnRampCountry[]) : [];
239
- } catch {
240
- console.info('Unable to get OnRamp Countries');
210
+ return countries ?? [];
211
+ } catch (error) {
212
+ LogController.sendError(error, 'StorageUtil.ts', 'getOnRampCountries');
241
213
  }
242
214
 
243
215
  return [];
@@ -247,33 +219,35 @@ export const StorageUtil = {
247
219
  try {
248
220
  const timestamp = Date.now();
249
221
 
250
- await AsyncStorage.setItem(
251
- ONRAMP_COUNTRIES_DEFAULTS,
252
- JSON.stringify({ data: countriesDefaults, timestamp })
253
- );
254
- } catch {
255
- console.info('Unable to set OnRamp Countries Defaults');
222
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_COUNTRIES_DEFAULTS, {
223
+ data: countriesDefaults,
224
+ timestamp
225
+ });
226
+ } catch (error) {
227
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampCountriesDefaults');
256
228
  }
257
229
  },
258
230
 
259
231
  async getOnRampCountriesDefaults() {
260
232
  try {
261
- const result = await AsyncStorage.getItem(ONRAMP_COUNTRIES_DEFAULTS);
233
+ const result = await OptionsController.getStorage().getItem(
234
+ SafeStorageKeys.ONRAMP_COUNTRIES_DEFAULTS
235
+ );
262
236
 
263
237
  if (!result) {
264
238
  return [];
265
239
  }
266
240
 
267
- const { data, timestamp } = JSON.parse(result);
241
+ const { data, timestamp } = result;
268
242
 
269
243
  // Cache for 1 week
270
244
  if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
271
245
  return [];
272
246
  }
273
247
 
274
- return data ? (data as OnRampCountryDefaults[]) : [];
275
- } catch {
276
- console.info('Unable to get OnRamp Countries Defaults');
248
+ return (data as OnRampCountryDefaults[]) ?? [];
249
+ } catch (error) {
250
+ LogController.sendError(error, 'StorageUtil.ts', 'getOnRampCountriesDefaults');
277
251
  }
278
252
 
279
253
  return [];
@@ -283,34 +257,35 @@ export const StorageUtil = {
283
257
  try {
284
258
  const timestamp = Date.now();
285
259
 
286
- await AsyncStorage.setItem(
287
- ONRAMP_SERVICE_PROVIDERS,
288
- JSON.stringify({ data: serviceProviders, timestamp })
289
- );
290
- } catch {
291
- console.info('Unable to set OnRamp Service Providers');
260
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_SERVICE_PROVIDERS, {
261
+ data: serviceProviders,
262
+ timestamp
263
+ });
264
+ } catch (error) {
265
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampServiceProviders');
292
266
  }
293
267
  },
294
268
 
295
269
  async getOnRampServiceProviders() {
296
270
  try {
297
- const result = await AsyncStorage.getItem(ONRAMP_SERVICE_PROVIDERS);
271
+ const result = await OptionsController.getStorage().getItem(
272
+ SafeStorageKeys.ONRAMP_SERVICE_PROVIDERS
273
+ );
298
274
 
299
275
  if (!result) {
300
276
  return [];
301
277
  }
302
278
 
303
- const { data, timestamp } = JSON.parse(result);
279
+ const { data, timestamp } = result;
304
280
 
305
281
  // Cache for 1 week
306
282
  if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
307
283
  return [];
308
284
  }
309
285
 
310
- return data ? (data as OnRampServiceProvider[]) : [];
286
+ return (data as OnRampServiceProvider[]) ?? [];
311
287
  } catch (err) {
312
- console.error(err);
313
- console.info('Unable to get OnRamp Service Providers');
288
+ LogController.sendError(err, 'StorageUtil.ts', 'getOnRampServiceProviders');
314
289
  }
315
290
 
316
291
  return [];
@@ -320,33 +295,35 @@ export const StorageUtil = {
320
295
  try {
321
296
  const timestamp = Date.now();
322
297
 
323
- await AsyncStorage.setItem(
324
- ONRAMP_FIAT_LIMITS,
325
- JSON.stringify({ data: fiatLimits, timestamp })
326
- );
327
- } catch {
328
- console.info('Unable to set OnRamp Fiat Limits');
298
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_FIAT_LIMITS, {
299
+ data: fiatLimits,
300
+ timestamp
301
+ });
302
+ } catch (error) {
303
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampFiatLimits');
329
304
  }
330
305
  },
331
306
 
332
307
  async getOnRampFiatLimits() {
333
308
  try {
334
- const result = await AsyncStorage.getItem(ONRAMP_FIAT_LIMITS);
309
+ const result = await OptionsController.getStorage().getItem(
310
+ SafeStorageKeys.ONRAMP_FIAT_LIMITS
311
+ );
335
312
 
336
313
  if (!result) {
337
314
  return [];
338
315
  }
339
316
 
340
- const { data, timestamp } = JSON.parse(result);
317
+ const { data, timestamp } = result;
341
318
 
342
319
  // Cache for 1 week
343
320
  if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
344
321
  return [];
345
322
  }
346
323
 
347
- return data ? (data as OnRampFiatLimit[]) : [];
348
- } catch {
349
- console.info('Unable to get OnRamp Fiat Limits');
324
+ return (data as OnRampFiatLimit[]) ?? [];
325
+ } catch (error) {
326
+ LogController.sendError(error, 'StorageUtil.ts', 'getOnRampFiatLimits');
350
327
  }
351
328
 
352
329
  return [];
@@ -356,35 +333,73 @@ export const StorageUtil = {
356
333
  try {
357
334
  const timestamp = Date.now();
358
335
 
359
- await AsyncStorage.setItem(
360
- ONRAMP_FIAT_CURRENCIES,
361
- JSON.stringify({ data: fiatCurrencies, timestamp })
362
- );
363
- } catch {
364
- console.info('Unable to set OnRamp Fiat Currencies');
336
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ONRAMP_FIAT_CURRENCIES, {
337
+ data: fiatCurrencies,
338
+ timestamp
339
+ });
340
+ } catch (error) {
341
+ LogController.sendError(error, 'StorageUtil.ts', 'setOnRampFiatCurrencies');
365
342
  }
366
343
  },
367
344
 
368
345
  async getOnRampFiatCurrencies() {
369
346
  try {
370
- const result = await AsyncStorage.getItem(ONRAMP_FIAT_CURRENCIES);
347
+ const result = await OptionsController.getStorage().getItem(
348
+ SafeStorageKeys.ONRAMP_FIAT_CURRENCIES
349
+ );
371
350
 
372
351
  if (!result) {
373
352
  return [];
374
353
  }
375
354
 
376
- const { data, timestamp } = JSON.parse(result);
355
+ const { data, timestamp } = result;
377
356
 
378
357
  // Cache for 1 week
379
358
  if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
380
359
  return [];
381
360
  }
382
361
 
383
- return data ? (data as OnRampFiatCurrency[]) : [];
384
- } catch {
385
- console.info('Unable to get OnRamp Fiat Currencies');
362
+ return (data as OnRampFiatCurrency[]) ?? [];
363
+ } catch (error) {
364
+ LogController.sendError(error, 'StorageUtil.ts', 'getOnRampFiatCurrencies');
386
365
  }
387
366
 
388
367
  return [];
368
+ },
369
+
370
+ async setActiveNamespace(namespace?: ChainNamespace) {
371
+ try {
372
+ if (!namespace) {
373
+ await OptionsController.getStorage().removeItem(SafeStorageKeys.ACTIVE_NAMESPACE);
374
+
375
+ return;
376
+ }
377
+
378
+ await OptionsController.getStorage().setItem(SafeStorageKeys.ACTIVE_NAMESPACE, namespace);
379
+ } catch (error) {
380
+ LogController.sendError(error, 'StorageUtil.ts', 'setActiveNamespace');
381
+ }
382
+ },
383
+
384
+ async getActiveNamespace() {
385
+ try {
386
+ const namespace = (await OptionsController.getStorage().getItem(
387
+ SafeStorageKeys.ACTIVE_NAMESPACE
388
+ )) as ChainNamespace;
389
+
390
+ return namespace ?? undefined;
391
+ } catch (err) {
392
+ LogController.sendError(err, 'StorageUtil.ts', 'getActiveNamespace');
393
+ }
394
+
395
+ return undefined;
396
+ },
397
+
398
+ async removeActiveNamespace() {
399
+ try {
400
+ await OptionsController.getStorage().removeItem(SafeStorageKeys.ACTIVE_NAMESPACE);
401
+ } catch (error) {
402
+ LogController.sendError(error, 'StorageUtil.ts', 'removeActiveNamespace');
403
+ }
389
404
  }
390
405
  };
@@ -1,19 +1,21 @@
1
- import { BlockchainApiController } from '../controllers/BlockchainApiController';
2
- import { OptionsController } from '../controllers/OptionsController';
3
- import { NetworkController } from '../controllers/NetworkController';
4
1
  import type {
5
- BlockchainApiBalanceResponse,
2
+ Balance,
3
+ CaipNetworkId,
6
4
  BlockchainApiSwapAllowanceRequest,
7
5
  SwapTokenWithBalance
8
- } from './TypeUtil';
9
- import { AccountController } from '../controllers/AccountController';
10
- import { ConnectionController } from '../controllers/ConnectionController';
6
+ } from '@reown/appkit-common-react-native';
7
+ import { BlockchainApiController } from '../controllers/BlockchainApiController';
8
+ import { OptionsController } from '../controllers/OptionsController';
9
+ import { ConnectionsController } from '../controllers/ConnectionsController';
10
+ import { ConstantsUtil } from './ConstantsUtil';
11
11
 
12
12
  export const SwapApiUtil = {
13
13
  async getTokenList() {
14
+ const chainId: CaipNetworkId =
15
+ ConnectionsController.state.activeNetwork?.caipNetworkId ?? 'eip155:1';
14
16
  const response = await BlockchainApiController.fetchSwapTokens({
15
17
  projectId: OptionsController.state.projectId,
16
- chainId: NetworkController.state.caipNetwork?.id
18
+ chainId
17
19
  });
18
20
  const tokens =
19
21
  response?.tokens?.map(
@@ -52,7 +54,7 @@ export const SwapApiUtil = {
52
54
 
53
55
  if (response?.allowance && sourceTokenAmount && sourceTokenDecimals) {
54
56
  const parsedValue =
55
- ConnectionController.parseUnits(sourceTokenAmount, sourceTokenDecimals) || 0;
57
+ ConnectionsController.parseUnits(sourceTokenAmount, sourceTokenDecimals) || 0;
56
58
  const hasAllowance = BigInt(response.allowance) >= parsedValue;
57
59
 
58
60
  return hasAllowance;
@@ -61,40 +63,31 @@ export const SwapApiUtil = {
61
63
  return false;
62
64
  },
63
65
 
64
- async getMyTokensWithBalance(forceUpdate?: string) {
65
- const address = AccountController.state.address;
66
- const chainId = NetworkController.state.caipNetwork?.id;
67
-
68
- if (!address) {
69
- return [];
70
- }
71
-
72
- const response = await BlockchainApiController.getBalance(address, chainId, forceUpdate);
73
- const balances = response?.balances.filter(balance => balance.quantity.decimals !== '0');
66
+ mapBalancesToSwapTokens(balances?: Balance[]) {
67
+ const { activeNamespace, activeCaipNetworkId } = ConnectionsController.state;
68
+ const address = activeNamespace
69
+ ? ConstantsUtil.NATIVE_TOKEN_ADDRESS[activeNamespace]
70
+ : undefined;
74
71
 
75
- AccountController.setTokenBalance(balances);
76
-
77
- return this.mapBalancesToSwapTokens(balances);
78
- },
79
-
80
- mapBalancesToSwapTokens(balances?: BlockchainApiBalanceResponse['balances']) {
81
72
  return (
82
- balances?.map(
83
- token =>
84
- ({
85
- ...token,
86
- address: token?.address || NetworkController.getActiveNetworkTokenAddress(),
87
- decimals: parseInt(token.quantity.decimals, 10),
88
- logoUri: token.iconUrl,
89
- eip2612: false
90
- }) as SwapTokenWithBalance
91
- ) || []
73
+ balances
74
+ ?.filter(balance => balance?.quantity?.numeric)
75
+ .map(
76
+ token =>
77
+ ({
78
+ ...token,
79
+ address: token?.address ?? `${token?.chainId ?? activeCaipNetworkId}:${address}`,
80
+ decimals: parseInt(token.quantity?.decimals ?? '0', 10),
81
+ logoUri: token.iconUrl,
82
+ eip2612: false
83
+ }) as SwapTokenWithBalance
84
+ ) || []
92
85
  );
93
86
  },
94
87
 
95
88
  async fetchGasPrice() {
96
89
  const projectId = OptionsController.state.projectId;
97
- const caipNetwork = NetworkController.state.caipNetwork;
90
+ const caipNetwork = ConnectionsController.state.activeNetwork;
98
91
 
99
92
  if (!caipNetwork) {
100
93
  return null;
@@ -102,7 +95,7 @@ export const SwapApiUtil = {
102
95
 
103
96
  return await BlockchainApiController.fetchGasPrice({
104
97
  projectId,
105
- chainId: caipNetwork.id
98
+ chainId: caipNetwork.caipNetworkId
106
99
  });
107
100
  }
108
101
  };
@@ -1,7 +1,6 @@
1
1
  // -- Types --------------------------------------------- //
2
2
 
3
- import { NumberUtil } from '@reown/appkit-common-react-native';
4
- import type { SwapTokenWithBalance } from './TypeUtil';
3
+ import { NumberUtil, type SwapTokenWithBalance } from '@reown/appkit-common-react-native';
5
4
 
6
5
  // -- Util ---------------------------------------- //
7
6
  export const SwapCalculationUtil = {