@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
@@ -1,19 +1,27 @@
1
- import { proxy, subscribe as sub } from 'valtio/vanilla';
1
+ import { proxy, subscribe as sub } from 'valtio';
2
2
  import { ApiController } from './ApiController';
3
3
  import { OptionsController } from './OptionsController';
4
4
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
5
  import { FetchUtil } from '../utils/FetchUtil';
6
- import type { Event, EventName } from '../utils/TypeUtil';
6
+ import type {
7
+ Event,
8
+ EventName,
9
+ WalletImpressionItem,
10
+ WcWallet
11
+ } from '@reown/appkit-common-react-native';
7
12
 
8
13
  // -- Helpers ------------------------------------------- //
9
14
  const baseUrl = CoreHelperUtil.getAnalyticsUrl();
10
15
  const api = new FetchUtil({ baseUrl });
11
16
  const excluded = ['MODAL_CREATED'];
17
+ const IMPRESSION_TIMEOUT = 3000;
12
18
 
13
19
  // -- Types --------------------------------------------- //
14
20
  export interface EventsControllerState {
15
21
  timestamp: number;
16
22
  data: Event;
23
+ pendingWalletImpressions: WalletImpressionItem[];
24
+ pendingImpressionTimeout?: NodeJS.Timeout;
17
25
  }
18
26
 
19
27
  // -- State --------------------------------------------- //
@@ -22,7 +30,9 @@ const state = proxy<EventsControllerState>({
22
30
  data: {
23
31
  type: 'track',
24
32
  event: 'MODAL_CREATED' // just for init purposes
25
- }
33
+ },
34
+ pendingWalletImpressions: [],
35
+ pendingImpressionTimeout: undefined
26
36
  });
27
37
 
28
38
  // -- Controller ---------------------------------------- //
@@ -41,6 +51,53 @@ export const EventsController = {
41
51
  });
42
52
  },
43
53
 
54
+ trackWalletImpression(props: {
55
+ wallet: WcWallet;
56
+ view: 'Connect' | 'AllWallets';
57
+ displayIndex: number;
58
+ query?: string;
59
+ installed?: boolean;
60
+ }) {
61
+ state.pendingWalletImpressions.push({
62
+ name: props.wallet.name ?? 'Unknown',
63
+ walletRank: props.wallet.order,
64
+ explorerId: props.wallet.id,
65
+ certified: props.wallet.badge_type === 'certified',
66
+ displayIndex: props.displayIndex,
67
+ view: props.view,
68
+ query: props.query,
69
+ installed: props.installed
70
+ });
71
+
72
+ if (state.pendingImpressionTimeout) {
73
+ clearTimeout(state.pendingImpressionTimeout);
74
+ }
75
+
76
+ state.pendingImpressionTimeout = setTimeout(() => {
77
+ EventsController.sendWalletImpressions();
78
+ }, IMPRESSION_TIMEOUT);
79
+ },
80
+
81
+ sendWalletImpressions() {
82
+ if (state.pendingImpressionTimeout) {
83
+ clearTimeout(state.pendingImpressionTimeout);
84
+ state.pendingImpressionTimeout = undefined;
85
+ }
86
+
87
+ const impressions = state.pendingWalletImpressions;
88
+
89
+ if (impressions.length === 0) {
90
+ return;
91
+ }
92
+
93
+ state.pendingWalletImpressions = [];
94
+ EventsController.sendEvent({
95
+ type: 'track',
96
+ event: 'WALLET_IMPRESSION',
97
+ items: impressions
98
+ });
99
+ },
100
+
44
101
  async _sendAnalyticsEvent(data: EventsControllerState['data'], timestamp: number) {
45
102
  if (excluded.includes(data.event)) {
46
103
  return;
@@ -50,6 +107,7 @@ export const EventsController = {
50
107
  await api.post({
51
108
  path: '/e',
52
109
  headers: ApiController._getApiHeaders(),
110
+ params: ApiController._getApiParams(),
53
111
  body: {
54
112
  eventId: CoreHelperUtil.getUUID(),
55
113
  bundleId: CoreHelperUtil.getBundleId(),
@@ -71,5 +129,18 @@ export const EventsController = {
71
129
  if (OptionsController.state.enableAnalytics) {
72
130
  EventsController._sendAnalyticsEvent(data, timestamp);
73
131
  }
132
+ },
133
+
134
+ resetState() {
135
+ if (state.pendingImpressionTimeout) {
136
+ clearTimeout(state.pendingImpressionTimeout);
137
+ state.pendingImpressionTimeout = undefined;
138
+ }
139
+ state.pendingWalletImpressions = [];
140
+ state.data = {
141
+ type: 'track',
142
+ event: 'MODAL_CREATED'
143
+ };
144
+ state.timestamp = Date.now();
74
145
  }
75
146
  };
@@ -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,11 +1,9 @@
1
1
  import { proxy } from 'valtio';
2
- import { AccountController } from './AccountController';
3
- import type { RouterControllerState } from './RouterController';
4
- import { RouterController } from './RouterController';
2
+ import { RouterController, type RouterControllerState } from './RouterController';
5
3
  import { PublicStateController } from './PublicStateController';
6
4
  import { EventsController } from './EventsController';
7
5
  import { ApiController } from './ApiController';
8
- import { ConnectorController } from './ConnectorController';
6
+ import { ConnectionsController } from './ConnectionsController';
9
7
 
10
8
  // -- Types --------------------------------------------- //
11
9
  export interface ModalControllerState {
@@ -31,11 +29,15 @@ export const ModalController = {
31
29
 
32
30
  async open(options?: ModalControllerArguments['open']) {
33
31
  await ApiController.state.prefetchPromise;
34
- const connected = AccountController.state.isConnected;
32
+ const isConnected = ConnectionsController.state.isConnected;
33
+ const isUniversalWallet = !!ConnectionsController.state.connection?.properties?.provider;
35
34
  if (options?.view) {
35
+ if (options.view === 'Account' && !isUniversalWallet) {
36
+ options.view = 'AccountDefault';
37
+ }
38
+
36
39
  RouterController.reset(options.view);
37
- } else if (AccountController.state.isConnected) {
38
- const isUniversalWallet = ConnectorController.state.connectedConnector === 'AUTH';
40
+ } else if (isConnected) {
39
41
  RouterController.reset(isUniversalWallet ? 'Account' : 'AccountDefault');
40
42
  } else {
41
43
  RouterController.reset('Connect');
@@ -45,12 +47,12 @@ export const ModalController = {
45
47
  EventsController.sendEvent({
46
48
  type: 'track',
47
49
  event: 'MODAL_OPEN',
48
- properties: { connected }
50
+ properties: { connected: isConnected }
49
51
  });
50
52
  },
51
53
 
52
54
  close() {
53
- const connected = AccountController.state.isConnected;
55
+ const connected = ConnectionsController.state.isConnected;
54
56
  state.open = false;
55
57
  PublicStateController.set({ open: false });
56
58
  EventsController.sendEvent({