@reown/appkit-core-react-native 2.0.0 → 2.0.1

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 (282) hide show
  1. package/lib/commonjs/controllers/ApiController.js +148 -82
  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 +127 -134
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionsController.js +280 -60
  8. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
  9. package/lib/commonjs/controllers/EnsController.js +6 -4
  10. package/lib/commonjs/controllers/EnsController.js.map +1 -1
  11. package/lib/commonjs/controllers/EventsController.js +55 -5
  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 +134 -53
  18. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  19. package/lib/commonjs/controllers/OptionsController.js +20 -7
  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 +115 -99
  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 +119 -119
  29. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  30. package/lib/commonjs/controllers/ThemeController.js +5 -0
  31. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  32. package/lib/commonjs/controllers/TransactionsController.js +25 -19
  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 +30 -37
  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 -17
  48. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  49. package/lib/commonjs/utils/ConstantsUtil.js +14 -431
  50. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  51. package/lib/commonjs/utils/CoreHelperUtil.js +33 -10
  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 +41 -12
  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 +119 -172
  59. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  60. package/lib/commonjs/utils/SwapApiUtil.js +2 -17
  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 +150 -82
  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 +128 -133
  70. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  71. package/lib/module/controllers/ConnectionsController.js +282 -60
  72. package/lib/module/controllers/ConnectionsController.js.map +1 -1
  73. package/lib/module/controllers/EnsController.js +6 -2
  74. package/lib/module/controllers/EnsController.js.map +1 -1
  75. package/lib/module/controllers/EventsController.js +54 -2
  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 +135 -52
  82. package/lib/module/controllers/OnRampController.js.map +1 -1
  83. package/lib/module/controllers/OptionsController.js +22 -7
  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 +114 -96
  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 +121 -119
  94. package/lib/module/controllers/SwapController.js.map +1 -1
  95. package/lib/module/controllers/ThemeController.js +7 -0
  96. package/lib/module/controllers/ThemeController.js.map +1 -1
  97. package/lib/module/controllers/TransactionsController.js +25 -17
  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 +12 -7
  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 -17
  112. package/lib/module/utils/AssetUtil.js.map +1 -1
  113. package/lib/module/utils/ConstantsUtil.js +16 -431
  114. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  115. package/lib/module/utils/CoreHelperUtil.js +35 -8
  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 +44 -12
  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 +122 -172
  124. package/lib/module/utils/StorageUtil.js.map +1 -1
  125. package/lib/module/utils/SwapApiUtil.js +4 -17
  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 +8 -7
  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 +21 -13
  136. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  137. package/lib/typescript/controllers/ConnectionsController.d.ts +22 -18
  138. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
  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 +1 -1
  146. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  147. package/lib/typescript/controllers/OnRampController.d.ts +4 -3
  148. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  149. package/lib/typescript/controllers/OptionsController.d.ts +8 -6
  150. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  151. package/lib/typescript/controllers/RouterController.d.ts +6 -21
  152. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  153. package/lib/typescript/controllers/SendController.d.ts +5 -7
  154. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  155. package/lib/typescript/controllers/SnackController.d.ts +3 -3
  156. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  157. package/lib/typescript/controllers/SwapController.d.ts +11 -11
  158. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  159. package/lib/typescript/controllers/ThemeController.d.ts +2 -0
  160. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  161. package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
  162. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  163. package/lib/typescript/controllers/WcController.d.ts +27 -0
  164. package/lib/typescript/controllers/WcController.d.ts.map +1 -0
  165. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts +174 -0
  166. package/lib/typescript/features/reown-authentication/ReownAuthentication.d.ts.map +1 -0
  167. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts +16 -0
  168. package/lib/typescript/features/reown-authentication/ReownAuthenticationMessenger.d.ts.map +1 -0
  169. package/lib/typescript/features/reown-authentication/index.d.ts +3 -0
  170. package/lib/typescript/features/reown-authentication/index.d.ts.map +1 -0
  171. package/lib/typescript/index.d.ts +6 -8
  172. package/lib/typescript/index.d.ts.map +1 -1
  173. package/lib/typescript/utils/ApiUtil.d.ts +1 -1
  174. package/lib/typescript/utils/AssetUtil.d.ts +3 -4
  175. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  176. package/lib/typescript/utils/ConstantsUtil.d.ts +7 -416
  177. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  178. package/lib/typescript/utils/CoreHelperUtil.d.ts +8 -6
  179. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  180. package/lib/typescript/utils/EventUtil.d.ts +1 -1
  181. package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
  182. package/lib/typescript/utils/FetchUtil.d.ts +3 -3
  183. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  184. package/lib/typescript/utils/LogUtils.d.ts +15 -0
  185. package/lib/typescript/utils/LogUtils.d.ts.map +1 -0
  186. package/lib/typescript/utils/StorageUtil.d.ts +8 -19
  187. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  188. package/lib/typescript/utils/SwapApiUtil.d.ts +3 -4
  189. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  190. package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
  191. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  192. package/lib/typescript/utils/WalletUtil.d.ts +5 -0
  193. package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
  194. package/package.json +12 -25
  195. package/src/controllers/ApiController.ts +158 -80
  196. package/src/controllers/AssetController.ts +0 -6
  197. package/src/controllers/BlockchainApiController.ts +109 -144
  198. package/src/controllers/ConnectionsController.ts +372 -88
  199. package/src/controllers/EnsController.ts +5 -3
  200. package/src/controllers/EventsController.ts +74 -3
  201. package/src/controllers/LogController.ts +250 -0
  202. package/src/controllers/ModalController.ts +11 -9
  203. package/src/controllers/OnRampController.ts +195 -82
  204. package/src/controllers/OptionsController.ts +40 -13
  205. package/src/controllers/RouterController.ts +20 -58
  206. package/src/controllers/SendController.ts +148 -112
  207. package/src/controllers/SnackController.ts +31 -5
  208. package/src/controllers/SwapController.ts +140 -148
  209. package/src/controllers/ThemeController.ts +7 -0
  210. package/src/controllers/TransactionsController.ts +26 -18
  211. package/src/controllers/WcController.ts +93 -0
  212. package/src/features/reown-authentication/ReownAuthentication.ts +475 -0
  213. package/src/features/reown-authentication/ReownAuthenticationMessenger.ts +80 -0
  214. package/src/features/reown-authentication/index.ts +2 -0
  215. package/src/index.ts +15 -22
  216. package/src/utils/ApiUtil.ts +1 -1
  217. package/src/utils/AssetUtil.ts +9 -20
  218. package/src/utils/ConstantsUtil.ts +16 -435
  219. package/src/utils/CoreHelperUtil.ts +62 -11
  220. package/src/utils/EventUtil.ts +1 -1
  221. package/src/utils/FetchUtil.ts +50 -14
  222. package/src/utils/LogUtils.ts +179 -0
  223. package/src/utils/StorageUtil.ts +171 -199
  224. package/src/utils/SwapApiUtil.ts +18 -37
  225. package/src/utils/SwapCalculationUtil.ts +1 -2
  226. package/src/utils/WalletUtil.ts +14 -0
  227. package/lib/commonjs/controllers/AccountController.js +0 -93
  228. package/lib/commonjs/controllers/AccountController.js.map +0 -1
  229. package/lib/commonjs/controllers/ConnectionController.js +0 -132
  230. package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
  231. package/lib/commonjs/controllers/ConnectorController.js +0 -50
  232. package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
  233. package/lib/commonjs/controllers/NetworkController.js +0 -90
  234. package/lib/commonjs/controllers/NetworkController.js.map +0 -1
  235. package/lib/commonjs/controllers/WebviewController.js +0 -52
  236. package/lib/commonjs/controllers/WebviewController.js.map +0 -1
  237. package/lib/commonjs/utils/NetworkUtil.js +0 -46
  238. package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
  239. package/lib/commonjs/utils/RouterUtil.js +0 -25
  240. package/lib/commonjs/utils/RouterUtil.js.map +0 -1
  241. package/lib/commonjs/utils/TypeUtil.js +0 -6
  242. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  243. package/lib/module/controllers/AccountController.js +0 -88
  244. package/lib/module/controllers/AccountController.js.map +0 -1
  245. package/lib/module/controllers/ConnectionController.js +0 -127
  246. package/lib/module/controllers/ConnectionController.js.map +0 -1
  247. package/lib/module/controllers/ConnectorController.js +0 -45
  248. package/lib/module/controllers/ConnectorController.js.map +0 -1
  249. package/lib/module/controllers/NetworkController.js +0 -85
  250. package/lib/module/controllers/NetworkController.js.map +0 -1
  251. package/lib/module/controllers/WebviewController.js +0 -47
  252. package/lib/module/controllers/WebviewController.js.map +0 -1
  253. package/lib/module/utils/NetworkUtil.js +0 -40
  254. package/lib/module/utils/NetworkUtil.js.map +0 -1
  255. package/lib/module/utils/RouterUtil.js +0 -19
  256. package/lib/module/utils/RouterUtil.js.map +0 -1
  257. package/lib/module/utils/TypeUtil.js +0 -2
  258. package/lib/module/utils/TypeUtil.js.map +0 -1
  259. package/lib/typescript/controllers/AccountController.d.ts +0 -33
  260. package/lib/typescript/controllers/AccountController.d.ts.map +0 -1
  261. package/lib/typescript/controllers/ConnectionController.d.ts +0 -68
  262. package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
  263. package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
  264. package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
  265. package/lib/typescript/controllers/NetworkController.d.ts +0 -34
  266. package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
  267. package/lib/typescript/controllers/WebviewController.d.ts +0 -21
  268. package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
  269. package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
  270. package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
  271. package/lib/typescript/utils/RouterUtil.d.ts +0 -5
  272. package/lib/typescript/utils/RouterUtil.d.ts.map +0 -1
  273. package/lib/typescript/utils/TypeUtil.d.ts +0 -817
  274. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  275. package/src/controllers/AccountController.ts +0 -128
  276. package/src/controllers/ConnectionController.ts +0 -208
  277. package/src/controllers/ConnectorController.ts +0 -64
  278. package/src/controllers/NetworkController.ts +0 -120
  279. package/src/controllers/WebviewController.ts +0 -63
  280. package/src/utils/NetworkUtil.ts +0 -33
  281. package/src/utils/RouterUtil.ts +0 -21
  282. package/src/utils/TypeUtil.ts +0 -995
@@ -2,16 +2,24 @@
2
2
 
3
3
  import { Linking, Platform } from 'react-native';
4
4
  import {
5
+ BlockchainAdapter,
5
6
  ConstantsUtil as CommonConstants,
7
+ type AdapterType,
6
8
  type Balance,
7
9
  type CaipAddress,
8
- type CaipNetwork
10
+ type CaipNetwork,
11
+ type ChainNamespace,
12
+ type SocialProvider,
13
+ type LinkingRecord,
14
+ type DataWallet,
15
+ type SdkVersion
9
16
  } from '@reown/appkit-common-react-native';
10
17
 
11
18
  import * as ct from 'countries-and-timezones';
12
19
 
13
20
  import { ConstantsUtil } from './ConstantsUtil';
14
- import type { DataWallet, LinkingRecord } from './TypeUtil';
21
+ import { OptionsController } from '../controllers/OptionsController';
22
+
15
23
  // -- Helpers -----------------------------------------------------------------
16
24
  async function isAppInstalledIos(deepLink?: string): Promise<boolean> {
17
25
  try {
@@ -45,6 +53,20 @@ export const CoreHelperUtil = {
45
53
  return Date.now() - lastRetry >= ConstantsUtil.ONE_SEC_MS;
46
54
  },
47
55
 
56
+ isCaipAddress(address?: unknown): address is CaipAddress {
57
+ if (typeof address !== 'string') {
58
+ return false;
59
+ }
60
+
61
+ const sections = address.split(':');
62
+ const namespace = sections[0];
63
+
64
+ return (
65
+ sections.filter(Boolean).length === 3 &&
66
+ (namespace as string) in CommonConstants.CHAIN_NAME_MAP
67
+ );
68
+ },
69
+
48
70
  getPairingExpiry() {
49
71
  return Date.now() + ConstantsUtil.FOUR_MINUTES_MS;
50
72
  },
@@ -53,8 +75,12 @@ export const CoreHelperUtil = {
53
75
  return caipAddress?.split(':')[1];
54
76
  },
55
77
 
56
- getPlainAddress(caipAddress: CaipAddress | undefined) {
57
- return caipAddress?.split(':')[2];
78
+ getPlainAddress(address: CaipAddress | string | undefined) {
79
+ if (this.isCaipAddress(address)) {
80
+ return address?.split(':')[2];
81
+ }
82
+
83
+ return address;
58
84
  },
59
85
 
60
86
  async wait(milliseconds: number) {
@@ -102,7 +128,7 @@ export const CoreHelperUtil = {
102
128
  };
103
129
  },
104
130
 
105
- formatUniversalUrl(appUrl: string, wcUri: string): LinkingRecord {
131
+ formatUniversalUrl(appUrl: string, wcUri: string, provider?: SocialProvider): LinkingRecord {
106
132
  if (CoreHelperUtil.isLinkModeURL(wcUri)) {
107
133
  return {
108
134
  redirect: wcUri,
@@ -120,7 +146,9 @@ export const CoreHelperUtil = {
120
146
  const encodedWcUrl = encodeURIComponent(wcUri);
121
147
 
122
148
  return {
123
- redirect: `${safeAppUrl}wc?uri=${encodedWcUrl}`,
149
+ redirect: provider
150
+ ? `${safeAppUrl}wc?uri=${encodedWcUrl}&provider=${provider}`
151
+ : `${safeAppUrl}wc?uri=${encodedWcUrl}`,
124
152
  href: safeAppUrl
125
153
  };
126
154
  },
@@ -149,8 +177,8 @@ export const CoreHelperUtil = {
149
177
  return formattedBalance ? `${formattedBalance} ${symbol}` : `0.000 ${symbol || ''}`;
150
178
  },
151
179
 
152
- isAddress(address: string, chain = 'eip155'): boolean {
153
- switch (chain) {
180
+ isAddress(address: string, namespace: ChainNamespace = 'eip155'): boolean {
181
+ switch (namespace) {
154
182
  case 'eip155':
155
183
  if (!/^(?:0x)?[0-9a-f]{40}$/iu.test(address)) {
156
184
  return false;
@@ -191,7 +219,7 @@ export const CoreHelperUtil = {
191
219
  const { timeZone } = new Intl.DateTimeFormat().resolvedOptions();
192
220
  const country = ct.getCountryForTimezone(timeZone);
193
221
 
194
- return country ? country.id : 'US'; // 'id' is the ISO country code (e.g., "GB" for United Kingdom)
222
+ return country ? country.id : 'US'; // 'id' is the ISO country code (e.g., "US" for United States)
195
223
  } catch (error) {
196
224
  return 'US';
197
225
  }
@@ -224,7 +252,7 @@ export const CoreHelperUtil = {
224
252
  });
225
253
  },
226
254
 
227
- getBundleId() {
255
+ getBundleId(): string | undefined {
228
256
  if ((global as any)?.Application?.applicationId) {
229
257
  return (global as any)?.Application?.applicationId;
230
258
  }
@@ -282,7 +310,7 @@ export const CoreHelperUtil = {
282
310
 
283
311
  let sum = 0;
284
312
  for (const item of array) {
285
- sum += item.value ?? 0;
313
+ sum += item?.value ?? 0;
286
314
  }
287
315
 
288
316
  const roundedNumber = sum.toFixed(2);
@@ -322,5 +350,28 @@ export const CoreHelperUtil = {
322
350
  func(...args);
323
351
  }, wait);
324
352
  };
353
+ },
354
+
355
+ generateSdkVersion(adapters: BlockchainAdapter[], version: string): SdkVersion {
356
+ const hasNoAdapters = adapters.length === 0;
357
+ const universalType: AdapterType = 'universal';
358
+
359
+ const adapterNames = hasNoAdapters
360
+ ? universalType
361
+ : adapters
362
+ .sort((a, b) => a.adapterType.localeCompare(b.adapterType))
363
+ .map(adapter => adapter.adapterType)
364
+ .join(',');
365
+
366
+ return `react-native-${adapterNames}-${version}`;
367
+ },
368
+
369
+ getRequestedCaipNetworkIds() {
370
+ const chains = OptionsController.state.requestedNetworks;
371
+ if (!chains) return [];
372
+
373
+ const requestedIds = chains.map(caipNetwork => caipNetwork.caipNetworkId);
374
+
375
+ return requestedIds;
325
376
  }
326
377
  };
@@ -1,4 +1,4 @@
1
- import type { Platform, WcWallet } from './TypeUtil';
1
+ import type { Platform, WcWallet } from '@reown/appkit-common-react-native';
2
2
 
3
3
  export const EventUtil = {
4
4
  getWalletPlatform(wallet: WcWallet, installed?: boolean): Platform | undefined {
@@ -1,4 +1,5 @@
1
- import type { RequestCache } from './TypeUtil';
1
+ import type { RequestCache } from '@reown/appkit-common-react-native';
2
+ import { LogController } from '../controllers/LogController';
2
3
 
3
4
  // -- Types ----------------------------------------------------------------------
4
5
  interface Options {
@@ -71,9 +72,13 @@ export class FetchUtil {
71
72
  return this.processResponse<T>(response);
72
73
  }
73
74
 
74
- public async fetchImage(path: string, headers?: Record<string, string>) {
75
+ public async fetchImage(
76
+ path: string,
77
+ headers?: Record<string, string>,
78
+ params?: Record<string, string>
79
+ ) {
75
80
  try {
76
- const url = this.createUrl({ path }).toString();
81
+ const url = this.createUrl({ path, params }).toString();
77
82
  const response = await fetch(url, { headers });
78
83
  const blob = await response.blob();
79
84
  const reader = new FileReader();
@@ -87,30 +92,61 @@ export class FetchUtil {
87
92
  }
88
93
  }
89
94
 
90
- private createUrl({ path, params }: RequestArguments) {
91
- const url = new URL(path, this.baseUrl);
92
- if (params) {
93
- Object.entries(params).forEach(([key, value]) => {
94
- if (value) {
95
- url.searchParams.append(key, value);
96
- }
97
- });
95
+ public createUrl({ path, params }: RequestArguments) {
96
+ let fullUrl: string;
97
+
98
+ const isAbsoluteUrl = path.startsWith('http://') || path.startsWith('https://');
99
+
100
+ if (isAbsoluteUrl) {
101
+ fullUrl = path;
102
+ } else {
103
+ const baseUrl = this.baseUrl.endsWith('/') ? this.baseUrl : `${this.baseUrl}/`;
104
+ const pathUrl = path.startsWith('/') ? path.substring(1) : path;
105
+ fullUrl = `${baseUrl}${pathUrl}`;
98
106
  }
99
107
 
108
+ const allParams: Record<string, string | undefined> = { ...params };
100
109
  if (this.clientId) {
101
- url.searchParams.append('clientId', this.clientId);
110
+ allParams['clientId'] = this.clientId;
111
+ }
112
+
113
+ const queryParams: string[] = [];
114
+ for (const key in allParams) {
115
+ const value = allParams[key];
116
+ if (value !== undefined && value !== null && value !== '') {
117
+ queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
118
+ }
102
119
  }
103
120
 
104
- return url.toString();
121
+ if (queryParams.length > 0) {
122
+ const queryString = queryParams.join('&');
123
+ if (fullUrl.includes('?')) {
124
+ fullUrl = `${fullUrl}&${queryString}`;
125
+ } else {
126
+ fullUrl = `${fullUrl}?${queryString}`;
127
+ }
128
+ }
129
+
130
+ return fullUrl;
105
131
  }
106
132
 
107
133
  private async processResponse<T>(response: Response) {
108
134
  if (!response.ok) {
109
135
  if (response.headers.get('content-type')?.includes('application/json')) {
110
- return Promise.reject((await response.json()) as T);
136
+ try {
137
+ const errorData = await response.json();
138
+ LogController.sendError(JSON.stringify(errorData), 'FetchUtil.ts', 'processResponse');
139
+
140
+ return Promise.reject(errorData);
141
+ } catch (jsonError) {
142
+ LogController.sendError(jsonError, 'FetchUtil.ts', 'processResponse');
143
+
144
+ return Promise.reject(`Code: ${response.status} - ${response.statusText}`);
145
+ }
111
146
  }
112
147
 
113
148
  const errorText = await response.text();
149
+ LogController.sendError(errorText, 'FetchUtil.ts', 'processResponse');
114
150
 
115
151
  return Promise.reject(`Code: ${response.status} - ${response.statusText} - ${errorText}`);
116
152
  }
@@ -0,0 +1,179 @@
1
+ // -- Constants ----------------------------------------- //
2
+ const SENSITIVE_KEYS = [
3
+ 'password',
4
+ 'pass',
5
+ 'pwd',
6
+ 'secret',
7
+ 'token',
8
+ 'key',
9
+ 'auth',
10
+ 'authorization',
11
+ 'bearer',
12
+ 'credential',
13
+ 'api_key',
14
+ 'apikey',
15
+ 'access_token',
16
+ 'refresh_token',
17
+ 'private_key',
18
+ 'privatekey',
19
+ 'mnemonic',
20
+ 'seed',
21
+ 'phrase',
22
+ 'wallet',
23
+ 'address',
24
+ 'email',
25
+ 'phone',
26
+ 'ssn',
27
+ 'social',
28
+ 'credit',
29
+ 'card',
30
+ 'cvv',
31
+ 'connection_string',
32
+ 'connection',
33
+ 'user_token'
34
+ ];
35
+
36
+ const MAX_STRING_LENGTH = 480; // Maximum length for any string value (account for potential replacements)
37
+ const MAX_STACK_LINES = 10; // Maximum lines in stack trace
38
+
39
+ // -- Data Sanitization Functions ---------------------- //
40
+ export const sanitizeString = (value: string): string => {
41
+ if (typeof value !== 'string') {
42
+ value = String(value);
43
+ }
44
+
45
+ if (value.length > MAX_STRING_LENGTH) {
46
+ return value.substring(0, MAX_STRING_LENGTH) + '... [truncated]';
47
+ }
48
+
49
+ return value;
50
+ };
51
+
52
+ export const sanitizeStackTrace = (stack: string): string => {
53
+ if (typeof stack !== 'string') {
54
+ stack = String(stack);
55
+ }
56
+
57
+ const lines = stack.split('\n');
58
+ const sanitizedLines = lines.slice(0, MAX_STACK_LINES).map(line => {
59
+ // Remove file paths that might contain sensitive info
60
+ return line.replace(/\/[^\s]*\//g, '/[path]/');
61
+ });
62
+
63
+ if (lines.length > MAX_STACK_LINES) {
64
+ sanitizedLines.push('... [stack trace truncated]');
65
+ }
66
+
67
+ return sanitizedLines.join('\n');
68
+ };
69
+
70
+ export const sanitizeUrl = (url: string): string => {
71
+ try {
72
+ const urlObj = new URL(url);
73
+ // Remove query parameters that might contain sensitive data
74
+ urlObj.search = '';
75
+ // Keep only the origin and pathname
76
+
77
+ return urlObj.origin + urlObj.pathname;
78
+ } catch {
79
+ // If URL parsing fails, just return sanitized string
80
+
81
+ return sanitizeString(url);
82
+ }
83
+ };
84
+
85
+ const isSensitiveKey = (key: string): boolean => {
86
+ const lowerKey = key.toLowerCase();
87
+
88
+ return SENSITIVE_KEYS.some(sensitiveKey => lowerKey.includes(sensitiveKey));
89
+ };
90
+
91
+ export const sanitizeValue = (value: unknown, visited = new WeakSet()): unknown => {
92
+ if (value === null || value === undefined) {
93
+ return value;
94
+ }
95
+
96
+ if (typeof value === 'string') {
97
+ // Check if it looks like a URL
98
+ if (value.startsWith('http://') || value.startsWith('https://')) {
99
+ return sanitizeUrl(value);
100
+ }
101
+
102
+ return sanitizeString(value);
103
+ }
104
+
105
+ if (typeof value === 'number' || typeof value === 'boolean') {
106
+ return value;
107
+ }
108
+
109
+ if (Array.isArray(value)) {
110
+ // Prevent circular references in arrays
111
+ if (visited.has(value)) {
112
+ return '[Circular Reference]';
113
+ }
114
+
115
+ visited.add(value);
116
+ const result = value.slice(0, 10).map(item => sanitizeValue(item, visited));
117
+ visited.delete(value);
118
+
119
+ return result;
120
+ }
121
+
122
+ if (typeof value === 'object') {
123
+ return sanitizeObject(value as Record<string, unknown>, visited);
124
+ }
125
+
126
+ // For other types, convert to string and sanitize
127
+ return sanitizeString(String(value));
128
+ };
129
+
130
+ export const sanitizeObject = (
131
+ obj: Record<string, unknown>,
132
+ visited = new WeakSet()
133
+ ): Record<string, unknown> => {
134
+ // Prevent circular references
135
+ if (visited.has(obj)) {
136
+ return { '[Circular Reference]': true };
137
+ }
138
+
139
+ visited.add(obj);
140
+
141
+ const sanitized: Record<string, unknown> = {};
142
+ const keys = Object.keys(obj).slice(0, 20); // Limit number of keys
143
+
144
+ for (const key of keys) {
145
+ if (isSensitiveKey(key)) {
146
+ sanitized[key] = '[REDACTED]';
147
+ } else {
148
+ sanitized[key] = sanitizeValue(obj[key], visited);
149
+ }
150
+ }
151
+
152
+ if (Object.keys(obj).length > 20) {
153
+ sanitized['...'] = '[additional properties truncated]';
154
+ }
155
+
156
+ visited.delete(obj);
157
+
158
+ return sanitized;
159
+ };
160
+
161
+ export const sanitizeData = (
162
+ data?: Record<string, unknown>
163
+ ): Record<string, unknown> | undefined => {
164
+ if (!data) {
165
+ return undefined;
166
+ }
167
+
168
+ return sanitizeObject(data);
169
+ };
170
+
171
+ // -- Utility Functions --------------------------------- //
172
+ export const LogUtils = {
173
+ sanitizeString,
174
+ sanitizeStackTrace,
175
+ sanitizeUrl,
176
+ sanitizeValue,
177
+ sanitizeObject,
178
+ sanitizeData
179
+ };