@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
@@ -0,0 +1,250 @@
1
+ import { proxy } from 'valtio';
2
+ import { OptionsController } from './OptionsController';
3
+ import { sanitizeString, sanitizeStackTrace, sanitizeValue, sanitizeData } from '../utils/LogUtils';
4
+ import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
+
6
+ // -- Types --------------------------------------------- //
7
+ export type LogLevel = 'info' | 'warn' | 'error' | 'debug';
8
+
9
+ export interface LogEntry {
10
+ id: string;
11
+ timestamp: number;
12
+ level: LogLevel;
13
+ message: string;
14
+ fileName?: string;
15
+ functionName?: string;
16
+ data?: Record<string, unknown>;
17
+ }
18
+
19
+ export interface LogControllerState {
20
+ logs: LogEntry[];
21
+ }
22
+
23
+ // -- Constants ----------------------------------------- //
24
+ const MAX_LOGS_COUNT = 300; // Prevent memory issues
25
+
26
+ // -- State --------------------------------------------- //
27
+ const state = proxy<LogControllerState>({
28
+ logs: []
29
+ });
30
+
31
+ const generateLogId = (): string => {
32
+ return CoreHelperUtil.getUUID();
33
+ };
34
+
35
+ const logToConsole = (entry: LogEntry) => {
36
+ const { debug } = OptionsController.state;
37
+
38
+ if (!debug) {
39
+ return;
40
+ }
41
+
42
+ const location =
43
+ entry.fileName && entry.functionName
44
+ ? `[${entry.fileName}:${entry.functionName}]`
45
+ : entry.fileName
46
+ ? `[${entry.fileName}]`
47
+ : '';
48
+
49
+ const logMessage = `[AppKit] ${location} ${entry.message}`;
50
+
51
+ switch (entry.level) {
52
+ case 'error':
53
+ // eslint-disable-next-line no-console
54
+ console.error(logMessage);
55
+ break;
56
+ case 'warn':
57
+ console.warn(logMessage);
58
+ break;
59
+ case 'debug':
60
+ // eslint-disable-next-line no-console
61
+ console.debug(logMessage);
62
+ break;
63
+ case 'info':
64
+ default:
65
+ // eslint-disable-next-line no-console
66
+ console.log(logMessage);
67
+ break;
68
+ }
69
+ };
70
+
71
+ // -- Controller ---------------------------------------- //
72
+ export const LogController = {
73
+ state,
74
+
75
+ /**
76
+ * Destroy the LogController (cleanup resources)
77
+ */
78
+ destroy() {
79
+ // Clear all logs
80
+ state.logs = [];
81
+ },
82
+
83
+ /**
84
+ * Send a general log entry
85
+ */
86
+ sendLog(
87
+ level: LogLevel,
88
+ message: string,
89
+ fileName?: string,
90
+ functionName?: string,
91
+ data?: Record<string, unknown>
92
+ ) {
93
+ if (!OptionsController.state.debug) {
94
+ return;
95
+ }
96
+ const entry: LogEntry = {
97
+ id: generateLogId(),
98
+ timestamp: Date.now(),
99
+ level,
100
+ message: sanitizeString(message),
101
+ fileName,
102
+ functionName,
103
+ data: sanitizeData(data)
104
+ };
105
+
106
+ state.logs.push(entry);
107
+
108
+ // Enforce maximum log count
109
+ if (state.logs.length > MAX_LOGS_COUNT) {
110
+ state.logs = state.logs.slice(-MAX_LOGS_COUNT);
111
+ }
112
+
113
+ logToConsole(entry);
114
+ },
115
+
116
+ /**
117
+ * Send an error log entry - convenience method for try/catch blocks
118
+ */
119
+ sendError(
120
+ error: Error | string | unknown,
121
+ fileName?: string,
122
+ functionName?: string,
123
+ additionalData?: Record<string, unknown>
124
+ ) {
125
+ let message: string;
126
+ let data: Record<string, unknown> = sanitizeData(additionalData) || {};
127
+
128
+ if (error instanceof Error) {
129
+ message = error.message || 'Error occurred';
130
+ // Sanitize stack trace to remove sensitive file paths
131
+ data['stack'] = error.stack ? sanitizeStackTrace(error.stack) : undefined;
132
+ data['name'] = error.name;
133
+
134
+ // Sanitize any additional properties on the error object
135
+ const errorProps: Record<string, unknown> = {};
136
+ Object.getOwnPropertyNames(error).forEach(prop => {
137
+ if (prop !== 'message' && prop !== 'stack' && prop !== 'name') {
138
+ errorProps[prop] = (error as any)[prop];
139
+ }
140
+ });
141
+
142
+ if (Object.keys(errorProps).length > 0) {
143
+ Object.assign(data, sanitizeValue(errorProps) as Record<string, unknown>);
144
+ }
145
+ } else if (typeof error === 'string') {
146
+ message = error;
147
+ } else if (error && typeof error === 'object' && 'message' in error) {
148
+ // Handle error-like objects (e.g., RPC errors, custom error objects)
149
+ message = String((error as any).message) || 'Error occurred';
150
+ // Include all properties of the error object
151
+ Object.assign(data, sanitizeValue(error) as Record<string, unknown>);
152
+ } else {
153
+ message = 'Unknown error occurred';
154
+ // Sanitize the original error object
155
+ data['originalError'] = sanitizeValue(error);
156
+ }
157
+
158
+ // Note: sanitization happens in sendLog method
159
+ this.sendLog('error', message, fileName, functionName, data);
160
+ },
161
+
162
+ /**
163
+ * Send an info log entry
164
+ */
165
+ sendInfo(
166
+ message: string,
167
+ fileName?: string,
168
+ functionName?: string,
169
+ data?: Record<string, unknown>
170
+ ) {
171
+ this.sendLog('info', message, fileName, functionName, data);
172
+ },
173
+
174
+ /**
175
+ * Send a warning log entry
176
+ */
177
+ sendWarn(
178
+ message: string,
179
+ fileName?: string,
180
+ functionName?: string,
181
+ data?: Record<string, unknown>
182
+ ) {
183
+ this.sendLog('warn', message, fileName, functionName, data);
184
+ },
185
+
186
+ /**
187
+ * Send a debug log entry
188
+ */
189
+ sendDebug(
190
+ message: string,
191
+ fileName?: string,
192
+ functionName?: string,
193
+ data?: Record<string, unknown>
194
+ ) {
195
+ this.sendLog('debug', message, fileName, functionName, data);
196
+ },
197
+
198
+ /**
199
+ * Get all logs
200
+ */
201
+ getLogs(): LogEntry[] {
202
+ return [...state.logs];
203
+ },
204
+
205
+ /**
206
+ * Get logs by level
207
+ */
208
+ getLogsByLevel(level: LogLevel): LogEntry[] {
209
+ return state.logs.filter(log => log.level === level);
210
+ },
211
+
212
+ /**
213
+ * Get recent logs (last N entries)
214
+ */
215
+ getRecentLogs(count: number = 100): LogEntry[] {
216
+ return state.logs.slice(-count);
217
+ },
218
+
219
+ /**
220
+ * Clear all logs
221
+ */
222
+ clearLogs() {
223
+ state.logs = [];
224
+ },
225
+
226
+ /**
227
+ * Export logs as JSON string for debugging
228
+ */
229
+ exportLogs(): string {
230
+ return JSON.stringify(state.logs, null, 2);
231
+ },
232
+
233
+ /**
234
+ * Get logs count by level
235
+ */
236
+ getLogsStats(): Record<LogLevel, number> {
237
+ const stats: Record<LogLevel, number> = {
238
+ info: 0,
239
+ warn: 0,
240
+ error: 0,
241
+ debug: 0
242
+ };
243
+
244
+ state.logs.forEach(log => {
245
+ stats[log.level]++;
246
+ });
247
+
248
+ return stats;
249
+ }
250
+ };
@@ -1,10 +1,9 @@
1
1
  import { proxy } from 'valtio';
2
- import { AccountController } from './AccountController';
3
2
  import { RouterController, type RouterControllerState } from './RouterController';
4
3
  import { PublicStateController } from './PublicStateController';
5
4
  import { EventsController } from './EventsController';
6
5
  import { ApiController } from './ApiController';
7
- import { ConnectorController } from './ConnectorController';
6
+ import { ConnectionsController } from './ConnectionsController';
8
7
 
9
8
  // -- Types --------------------------------------------- //
10
9
  export interface ModalControllerState {
@@ -30,11 +29,15 @@ export const ModalController = {
30
29
 
31
30
  async open(options?: ModalControllerArguments['open']) {
32
31
  await ApiController.state.prefetchPromise;
33
- const connected = AccountController.state.isConnected;
32
+ const isConnected = ConnectionsController.state.isConnected;
33
+ const isUniversalWallet = !!ConnectionsController.state.connection?.properties?.provider;
34
34
  if (options?.view) {
35
+ if (options.view === 'Account' && !isUniversalWallet) {
36
+ options.view = 'AccountDefault';
37
+ }
38
+
35
39
  RouterController.reset(options.view);
36
- } else if (AccountController.state.isConnected) {
37
- const isUniversalWallet = ConnectorController.state.connectedConnector === 'AUTH';
40
+ } else if (isConnected) {
38
41
  RouterController.reset(isUniversalWallet ? 'Account' : 'AccountDefault');
39
42
  } else {
40
43
  RouterController.reset('Connect');
@@ -44,12 +47,12 @@ export const ModalController = {
44
47
  EventsController.sendEvent({
45
48
  type: 'track',
46
49
  event: 'MODAL_OPEN',
47
- properties: { connected }
50
+ properties: { connected: isConnected }
48
51
  });
49
52
  },
50
53
 
51
54
  close() {
52
- const connected = AccountController.state.isConnected;
55
+ const connected = ConnectionsController.state.isConnected;
53
56
  state.open = false;
54
57
  PublicStateController.set({ open: false });
55
58
  EventsController.sendEvent({
@@ -1,5 +1,5 @@
1
- import { subscribeKey as subKey } from 'valtio/vanilla/utils';
2
- import { proxy, subscribe as sub } from 'valtio/vanilla';
1
+ import { subscribeKey as subKey } from 'valtio/utils';
2
+ import { proxy, subscribe as sub } from 'valtio';
3
3
  import {
4
4
  type OnRampPaymentMethod,
5
5
  type OnRampCountry,
@@ -12,17 +12,17 @@ import {
12
12
  type OnRampErrorTypeValues,
13
13
  type OnRampCountryDefaults,
14
14
  BlockchainOnRampError
15
- } from '../utils/TypeUtil';
15
+ } from '@reown/appkit-common-react-native';
16
16
 
17
17
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
18
- import { NetworkController } from './NetworkController';
19
- import { AccountController } from './AccountController';
20
18
  import { OptionsController } from './OptionsController';
21
19
  import { ConstantsUtil, OnRampErrorType } from '../utils/ConstantsUtil';
22
20
  import { StorageUtil } from '../utils/StorageUtil';
23
21
  import { SnackController } from './SnackController';
22
+ import { LogController } from './LogController';
24
23
  import { EventsController } from './EventsController';
25
24
  import { BlockchainApiController, EXCLUDED_ONRAMP_PROVIDERS } from './BlockchainApiController';
25
+ import { ConnectionsController } from './ConnectionsController';
26
26
 
27
27
  // -- Helpers ------------------------------------------- //
28
28
 
@@ -125,7 +125,11 @@ export const OnRampController = {
125
125
  state.countriesDefaults?.find(d => d.countryCode === country.countryCode)
126
126
  ?.defaultCurrencyCode || 'USD';
127
127
 
128
- const currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
128
+ let currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
129
+
130
+ if (!currency) {
131
+ currency = state.paymentCurrencies?.find(c => c.currencyCode === 'USD');
132
+ }
129
133
 
130
134
  if (currency) {
131
135
  this.setPaymentCurrency(currency);
@@ -139,6 +143,7 @@ export const OnRampController = {
139
143
 
140
144
  StorageUtil.setOnRampPreferredCountry(country);
141
145
  } catch (error) {
146
+ LogController.sendError(error, 'OnRampController.ts', 'setSelectedCountry');
142
147
  state.loading = false;
143
148
  state.error = {
144
149
  type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
@@ -188,16 +193,16 @@ export const OnRampController = {
188
193
 
189
194
  updateSelectedPurchaseCurrency() {
190
195
  let selectedCurrency;
191
- if (NetworkController.state.caipNetwork?.id) {
196
+ if (ConnectionsController.state.activeNetwork?.caipNetworkId) {
192
197
  const defaultCurrency =
193
198
  ConstantsUtil.NETWORK_DEFAULT_CURRENCIES[
194
- NetworkController.state.caipNetwork
195
- ?.id as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
199
+ ConnectionsController.state.activeNetwork
200
+ ?.caipNetworkId as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
196
201
  ];
197
202
  selectedCurrency = state.purchaseCurrencies?.find(c => c.currencyCode === defaultCurrency);
198
203
  }
199
204
 
200
- state.purchaseCurrency = selectedCurrency ?? state.purchaseCurrencies?.[0] ?? undefined;
205
+ state.purchaseCurrency = selectedCurrency ?? undefined;
201
206
  },
202
207
 
203
208
  getServiceProviderImage(serviceProviderName?: string) {
@@ -237,6 +242,7 @@ export const OnRampController = {
237
242
  countries.find(c => c.countryCode === countryCode) || countries[0] || undefined;
238
243
  }
239
244
  } catch (error) {
245
+ LogController.sendError(error, 'OnRampController.ts', 'fetchCountries');
240
246
  state.error = {
241
247
  type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
242
248
  message: 'Failed to load countries'
@@ -258,6 +264,7 @@ export const OnRampController = {
258
264
 
259
265
  state.countriesDefaults = countriesDefaults;
260
266
  } catch (error) {
267
+ LogController.sendError(error, 'OnRampController.ts', 'fetchCountriesDefaults');
261
268
  state.error = {
262
269
  type: OnRampErrorType.FAILED_TO_LOAD_COUNTRIES,
263
270
  message: 'Failed to load countries defaults'
@@ -279,6 +286,7 @@ export const OnRampController = {
279
286
 
280
287
  state.serviceProviders = serviceProviders || [];
281
288
  } catch (error) {
289
+ LogController.sendError(error, 'OnRampController.ts', 'fetchServiceProviders');
282
290
  state.error = {
283
291
  type: OnRampErrorType.FAILED_TO_LOAD_PROVIDERS,
284
292
  message: 'Failed to load service providers'
@@ -310,6 +318,7 @@ export const OnRampController = {
310
318
 
311
319
  state.selectedPaymentMethod = state.paymentMethods[0];
312
320
  } catch (error) {
321
+ LogController.sendError(error, 'OnRampController.ts', 'fetchPaymentMethods');
313
322
  state.error = {
314
323
  type: OnRampErrorType.FAILED_TO_LOAD_METHODS,
315
324
  message: 'Failed to load payment methods'
@@ -328,17 +337,18 @@ export const OnRampController = {
328
337
  state.purchaseCurrencies = cryptoCurrencies || [];
329
338
 
330
339
  let selectedCurrency;
331
- if (NetworkController.state.caipNetwork?.id) {
340
+ if (ConnectionsController.state.activeNetwork?.caipNetworkId) {
332
341
  const defaultCurrency =
333
342
  ConstantsUtil.NETWORK_DEFAULT_CURRENCIES[
334
- NetworkController.state.caipNetwork
335
- ?.id as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
336
- ] || 'ETH';
343
+ ConnectionsController.state.activeNetwork
344
+ ?.caipNetworkId as keyof typeof ConstantsUtil.NETWORK_DEFAULT_CURRENCIES
345
+ ];
337
346
  selectedCurrency = state.purchaseCurrencies?.find(c => c.currencyCode === defaultCurrency);
338
347
  }
339
348
 
340
- state.purchaseCurrency = selectedCurrency || cryptoCurrencies?.[0] || undefined;
349
+ state.purchaseCurrency = selectedCurrency || undefined;
341
350
  } catch (error) {
351
+ LogController.sendError(error, 'OnRampController.ts', 'fetchCryptoCurrencies');
342
352
  state.error = {
343
353
  type: OnRampErrorType.FAILED_TO_LOAD_CURRENCIES,
344
354
  message: 'Failed to load crypto currencies'
@@ -382,6 +392,7 @@ export const OnRampController = {
382
392
  this.setPaymentCurrency(defaultCurrency);
383
393
  }
384
394
  } catch (error) {
395
+ LogController.sendError(error, 'OnRampController.ts', 'fetchFiatCurrencies');
385
396
  state.error = {
386
397
  type: OnRampErrorType.FAILED_TO_LOAD_CURRENCIES,
387
398
  message: 'Failed to load fiat currencies'
@@ -420,7 +431,7 @@ export const OnRampController = {
420
431
  !state.selectedCountry?.countryCode ||
421
432
  !state.purchaseCurrency?.currencyCode ||
422
433
  !state.paymentCurrency?.currencyCode ||
423
- !AccountController.state.address
434
+ !ConnectionsController.state.activeAddress
424
435
  ) {
425
436
  throw new BlockchainOnRampError(OnRampErrorType.UNKNOWN, 'Invalid quote parameters');
426
437
  }
@@ -430,12 +441,20 @@ export const OnRampController = {
430
441
  state.selectedServiceProvider = undefined;
431
442
  state.error = undefined;
432
443
 
444
+ const plainAddress = CoreHelperUtil.getPlainAddress(
445
+ ConnectionsController.state.activeAddress
446
+ );
447
+
448
+ if (!plainAddress) {
449
+ throw new Error('Invalid address');
450
+ }
451
+
433
452
  const body = {
434
453
  countryCode: state.selectedCountry.countryCode,
435
454
  destinationCurrencyCode: state.purchaseCurrency.currencyCode,
436
455
  sourceAmount: state.paymentAmount!,
437
456
  sourceCurrencyCode: state.paymentCurrency.currencyCode,
438
- walletAddress: AccountController.state.address,
457
+ walletAddress: plainAddress,
439
458
  excludeProviders: EXCLUDED_ONRAMP_PROVIDERS
440
459
  };
441
460
 
@@ -492,6 +511,7 @@ export const OnRampController = {
492
511
  sp => sp.serviceProvider === state.selectedQuote?.serviceProvider
493
512
  );
494
513
  } catch (error: any) {
514
+ LogController.sendError(error, 'OnRampController.ts', 'getQuotes');
495
515
  if (error.name === 'AbortError') {
496
516
  // Do nothing, another request was made
497
517
  return;
@@ -524,7 +544,7 @@ export const OnRampController = {
524
544
  state.paymentCurrency?.currencyCode &&
525
545
  state.selectedCountry &&
526
546
  !state.loading &&
527
- AccountController.state.address
547
+ ConnectionsController.state.activeAddress
528
548
  );
529
549
  },
530
550
 
@@ -542,6 +562,7 @@ export const OnRampController = {
542
562
 
543
563
  state.paymentCurrenciesLimits = limits;
544
564
  } catch (error) {
565
+ LogController.sendError(error, 'OnRampController.ts', 'fetchFiatLimits');
545
566
  state.error = {
546
567
  type: OnRampErrorType.FAILED_TO_LOAD_LIMITS,
547
568
  message: 'Failed to load fiat limits'
@@ -551,6 +572,10 @@ export const OnRampController = {
551
572
  },
552
573
 
553
574
  async generateWidget({ quote }: { quote: OnRampQuote }) {
575
+ if (!ConnectionsController.state.activeAddress) {
576
+ throw new Error('No active address');
577
+ }
578
+
554
579
  const metadata = OptionsController.state.metadata;
555
580
  const eventProperties = {
556
581
  asset: quote.destinationCurrencyCode,
@@ -567,6 +592,14 @@ export const OnRampController = {
567
592
  throw new Error('Invalid quote');
568
593
  }
569
594
 
595
+ const plainAddress = CoreHelperUtil.getPlainAddress(
596
+ ConnectionsController.state.activeAddress
597
+ );
598
+
599
+ if (!plainAddress) {
600
+ throw new Error('Invalid address');
601
+ }
602
+
570
603
  const body = {
571
604
  countryCode: quote.countryCode,
572
605
  destinationCurrencyCode: quote.destinationCurrencyCode,
@@ -574,7 +607,7 @@ export const OnRampController = {
574
607
  serviceProvider: quote.serviceProvider,
575
608
  sourceAmount: quote.sourceAmount,
576
609
  sourceCurrencyCode: quote.sourceCurrencyCode,
577
- walletAddress: AccountController.state.address!,
610
+ walletAddress: plainAddress,
578
611
  redirectUrl: metadata?.redirect?.universal ?? metadata?.redirect?.native
579
612
  };
580
613
 
@@ -594,6 +627,7 @@ export const OnRampController = {
594
627
 
595
628
  return widget;
596
629
  } catch (e: any) {
630
+ LogController.sendError(e, 'OnRampController.ts', 'generateWidget', { quote });
597
631
  EventsController.sendEvent({
598
632
  type: 'track',
599
633
  event: 'BUY_FAIL',
@@ -639,6 +673,7 @@ export const OnRampController = {
639
673
  this.fetchFiatCurrencies()
640
674
  ]);
641
675
  } catch (error) {
676
+ LogController.sendError(error, 'OnRampController.ts', 'loadOnRampData');
642
677
  if (!state.error) {
643
678
  state.error = {
644
679
  type: OnRampErrorType.FAILED_TO_LOAD,
@@ -1,13 +1,16 @@
1
1
  import { proxy, ref } from 'valtio';
2
2
  import type {
3
+ Storage,
4
+ Metadata,
5
+ AppKitNetwork,
3
6
  CustomWallet,
4
7
  Features,
5
- Metadata,
6
8
  ProjectId,
7
9
  SdkType,
8
10
  SdkVersion,
9
- Tokens
10
- } from '../utils/TypeUtil';
11
+ SIWXConfig
12
+ } from '@reown/appkit-common-react-native';
13
+
11
14
  import { ConstantsUtil } from '../utils/ConstantsUtil';
12
15
 
13
16
  // -- Types --------------------------------------------- //
@@ -17,28 +20,31 @@ export interface ClipboardClient {
17
20
 
18
21
  export interface OptionsControllerState {
19
22
  projectId: ProjectId;
20
- _clipboardClient?: ClipboardClient;
23
+ clipboardClient?: ClipboardClient;
24
+ storage?: Storage;
21
25
  includeWalletIds?: string[];
22
26
  excludeWalletIds?: string[];
23
27
  featuredWalletIds?: string[];
24
28
  customWallets?: CustomWallet[];
25
- tokens?: Tokens;
26
29
  enableAnalytics?: boolean;
27
30
  sdkType: SdkType;
28
31
  sdkVersion: SdkVersion;
29
32
  metadata?: Metadata;
30
- isSiweEnabled?: boolean;
33
+ siwx?: SIWXConfig;
31
34
  isOnRampEnabled?: boolean;
32
35
  features?: Features;
33
36
  debug?: boolean;
37
+ defaultNetwork?: AppKitNetwork;
38
+ requestedNetworks?: AppKitNetwork[];
34
39
  }
35
40
 
36
41
  // -- State --------------------------------------------- //
37
42
  const state = proxy<OptionsControllerState>({
38
43
  projectId: '',
39
44
  sdkType: 'appkit',
40
- sdkVersion: 'react-native-wagmi-undefined',
45
+ sdkVersion: 'react-native-undefined-undefined',
41
46
  features: ConstantsUtil.DEFAULT_FEATURES,
47
+ customWallets: [],
42
48
  debug: false
43
49
  });
44
50
 
@@ -47,7 +53,7 @@ export const OptionsController = {
47
53
  state,
48
54
 
49
55
  setClipboardClient(client: ClipboardClient) {
50
- state._clipboardClient = ref(client);
56
+ state.clipboardClient = ref(client);
51
57
  },
52
58
 
53
59
  setProjectId(projectId: OptionsControllerState['projectId']) {
@@ -66,10 +72,6 @@ export const OptionsController = {
66
72
  state.featuredWalletIds = featuredWalletIds;
67
73
  },
68
74
 
69
- setTokens(tokens: OptionsControllerState['tokens']) {
70
- state.tokens = tokens;
71
- },
72
-
73
75
  setCustomWallets(customWallets: OptionsControllerState['customWallets']) {
74
76
  state.customWallets = customWallets;
75
77
  },
@@ -86,10 +88,6 @@ export const OptionsController = {
86
88
  state.metadata = metadata;
87
89
  },
88
90
 
89
- setIsSiweEnabled(isSiweEnabled: OptionsControllerState['isSiweEnabled']) {
90
- state.isSiweEnabled = isSiweEnabled;
91
- },
92
-
93
91
  setFeatures(features: OptionsControllerState['features']) {
94
92
  state.features = { ...ConstantsUtil.DEFAULT_FEATURES, ...features };
95
93
  },
@@ -102,12 +100,42 @@ export const OptionsController = {
102
100
  state.isOnRampEnabled = isOnRampEnabled;
103
101
  },
104
102
 
103
+ setStorage(storage?: OptionsControllerState['storage']) {
104
+ if (storage) {
105
+ state.storage = ref(storage);
106
+ }
107
+ },
108
+
109
+ setDefaultNetwork(defaultNetwork?: OptionsControllerState['defaultNetwork']) {
110
+ state.defaultNetwork = defaultNetwork;
111
+ },
112
+
113
+ setRequestedNetworks(requestedNetworks?: OptionsControllerState['requestedNetworks']) {
114
+ state.requestedNetworks = requestedNetworks;
115
+ },
116
+
117
+ setSiwx(siwx?: OptionsControllerState['siwx']) {
118
+ if (siwx && (siwx?.signOutOnDisconnect === undefined || siwx?.signOutOnDisconnect === null)) {
119
+ siwx.signOutOnDisconnect = true;
120
+ }
121
+
122
+ state.siwx = siwx;
123
+ },
124
+
105
125
  isClipboardAvailable() {
106
- return !!state._clipboardClient;
126
+ return !!state.clipboardClient;
127
+ },
128
+
129
+ getStorage() {
130
+ if (!state.storage) {
131
+ throw new Error('AppKit: Storage is not set');
132
+ }
133
+
134
+ return state.storage;
107
135
  },
108
136
 
109
137
  copyToClipboard(value: string) {
110
- const client = state._clipboardClient;
138
+ const client = state.clipboardClient;
111
139
  if (client) {
112
140
  client?.setString(value);
113
141
  }
@@ -1,6 +1,6 @@
1
1
  import { proxy, subscribe as sub } from 'valtio';
2
2
  import { subscribeKey as subKey } from 'valtio/utils';
3
- import type { CaipNetworkId } from '../utils/TypeUtil.js';
3
+ import type { CaipNetworkId } from '@reown/appkit-common-react-native';
4
4
 
5
5
  // -- Types --------------------------------------------- //
6
6
  export interface PublicStateControllerState {