@reown/appkit-react-native 0.0.0-chore-spring-effect-20250909214820 → 0.0.0-chore-examples-20251009175707

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 (247) hide show
  1. package/lib/commonjs/AppKit.js +135 -89
  2. package/lib/commonjs/AppKit.js.map +1 -1
  3. package/lib/commonjs/AppKitContext.js +16 -10
  4. package/lib/commonjs/AppKitContext.js.map +1 -1
  5. package/lib/commonjs/connectors/WalletConnectConnector.js +24 -57
  6. package/lib/commonjs/connectors/WalletConnectConnector.js.map +1 -1
  7. package/lib/commonjs/hooks/useAccount.js +4 -3
  8. package/lib/commonjs/hooks/useAccount.js.map +1 -1
  9. package/lib/commonjs/hooks/useAppKit.js +12 -12
  10. package/lib/commonjs/hooks/useAppKit.js.map +1 -1
  11. package/lib/commonjs/hooks/useAppKitLogs.js +88 -0
  12. package/lib/commonjs/hooks/useAppKitLogs.js.map +1 -0
  13. package/lib/commonjs/hooks/useAppKitState.js +32 -0
  14. package/lib/commonjs/hooks/useAppKitState.js.map +1 -0
  15. package/lib/commonjs/hooks/useProvider.js +26 -8
  16. package/lib/commonjs/hooks/useProvider.js.map +1 -1
  17. package/lib/commonjs/hooks/useWalletInfo.js +6 -4
  18. package/lib/commonjs/hooks/useWalletInfo.js.map +1 -1
  19. package/lib/commonjs/index.js +22 -0
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/modal/w3m-modal/index.js +9 -1
  22. package/lib/commonjs/modal/w3m-modal/index.js.map +1 -1
  23. package/lib/commonjs/modal/w3m-router/index.js +19 -21
  24. package/lib/commonjs/modal/w3m-router/index.js.map +1 -1
  25. package/lib/commonjs/partials/w3m-account-wallet-features/index.js +1 -1
  26. package/lib/commonjs/partials/w3m-account-wallet-features/index.js.map +1 -1
  27. package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletItem.js +6 -3
  28. package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletItem.js.map +1 -1
  29. package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletList.js +66 -22
  30. package/lib/commonjs/partials/w3m-all-wallets-list/components/WalletList.js.map +1 -1
  31. package/lib/commonjs/partials/w3m-all-wallets-list/index.js +2 -1
  32. package/lib/commonjs/partials/w3m-all-wallets-list/index.js.map +1 -1
  33. package/lib/commonjs/partials/w3m-all-wallets-search/index.js +4 -1
  34. package/lib/commonjs/partials/w3m-all-wallets-search/index.js.map +1 -1
  35. package/lib/commonjs/partials/w3m-connecting-mobile/index.js +21 -1
  36. package/lib/commonjs/partials/w3m-connecting-mobile/index.js.map +1 -1
  37. package/lib/commonjs/partials/w3m-connecting-qrcode/index.js +5 -1
  38. package/lib/commonjs/partials/w3m-connecting-qrcode/index.js.map +1 -1
  39. package/lib/commonjs/partials/w3m-connecting-web/index.js +8 -2
  40. package/lib/commonjs/partials/w3m-connecting-web/index.js.map +1 -1
  41. package/lib/commonjs/partials/w3m-header/index.js +4 -4
  42. package/lib/commonjs/partials/w3m-header/index.js.map +1 -1
  43. package/lib/commonjs/utils/SIWXUtil.js +278 -0
  44. package/lib/commonjs/utils/SIWXUtil.js.map +1 -0
  45. package/lib/commonjs/views/w3m-account-default-view/index.js +3 -2
  46. package/lib/commonjs/views/w3m-account-default-view/index.js.map +1 -1
  47. package/lib/commonjs/views/w3m-all-wallets-view/index.js +7 -4
  48. package/lib/commonjs/views/w3m-all-wallets-view/index.js.map +1 -1
  49. package/lib/commonjs/views/w3m-connect-view/components/all-wallet-list.js +33 -6
  50. package/lib/commonjs/views/w3m-connect-view/components/all-wallet-list.js.map +1 -1
  51. package/lib/commonjs/views/w3m-connect-view/index.js +6 -3
  52. package/lib/commonjs/views/w3m-connect-view/index.js.map +1 -1
  53. package/lib/commonjs/views/w3m-connecting-external-view/index.js +21 -1
  54. package/lib/commonjs/views/w3m-connecting-external-view/index.js.map +1 -1
  55. package/lib/commonjs/views/w3m-connecting-social-view/index.js +1 -0
  56. package/lib/commonjs/views/w3m-connecting-social-view/index.js.map +1 -1
  57. package/lib/commonjs/views/w3m-connecting-view/index.js +12 -31
  58. package/lib/commonjs/views/w3m-connecting-view/index.js.map +1 -1
  59. package/lib/commonjs/views/w3m-network-switch-view/index.js +1 -0
  60. package/lib/commonjs/views/w3m-network-switch-view/index.js.map +1 -1
  61. package/lib/commonjs/views/w3m-onramp-settings-view/components/Country.js +3 -1
  62. package/lib/commonjs/views/w3m-onramp-settings-view/components/Country.js.map +1 -1
  63. package/lib/commonjs/views/w3m-onramp-settings-view/index.js +2 -1
  64. package/lib/commonjs/views/w3m-onramp-settings-view/index.js.map +1 -1
  65. package/lib/commonjs/views/w3m-onramp-view/components/LoadingView.js +1 -1
  66. package/lib/commonjs/views/w3m-onramp-view/components/LoadingView.js.map +1 -1
  67. package/lib/commonjs/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.js +7 -43
  68. package/lib/commonjs/views/w3m-siwx-sign-view/index.js.map +1 -0
  69. package/lib/commonjs/views/w3m-siwx-sign-view/styles.js.map +1 -0
  70. package/lib/commonjs/views/w3m-swap-view/index.js +1 -1
  71. package/lib/commonjs/views/w3m-swap-view/index.js.map +1 -1
  72. package/lib/commonjs/views/w3m-what-is-a-wallet-view/index.js +1 -1
  73. package/lib/commonjs/views/w3m-what-is-a-wallet-view/index.js.map +1 -1
  74. package/lib/module/AppKit.js +135 -89
  75. package/lib/module/AppKit.js.map +1 -1
  76. package/lib/module/AppKitContext.js +17 -11
  77. package/lib/module/AppKitContext.js.map +1 -1
  78. package/lib/module/connectors/WalletConnectConnector.js +22 -56
  79. package/lib/module/connectors/WalletConnectConnector.js.map +1 -1
  80. package/lib/module/hooks/useAccount.js +3 -3
  81. package/lib/module/hooks/useAccount.js.map +1 -1
  82. package/lib/module/hooks/useAppKit.js +13 -13
  83. package/lib/module/hooks/useAppKit.js.map +1 -1
  84. package/lib/module/hooks/useAppKitLogs.js +83 -0
  85. package/lib/module/hooks/useAppKitLogs.js.map +1 -0
  86. package/lib/module/hooks/useAppKitState.js +27 -0
  87. package/lib/module/hooks/useAppKitState.js.map +1 -0
  88. package/lib/module/hooks/useProvider.js +26 -9
  89. package/lib/module/hooks/useProvider.js.map +1 -1
  90. package/lib/module/hooks/useWalletInfo.js +6 -4
  91. package/lib/module/hooks/useWalletInfo.js.map +1 -1
  92. package/lib/module/index.js +7 -0
  93. package/lib/module/index.js.map +1 -1
  94. package/lib/module/modal/w3m-modal/index.js +9 -1
  95. package/lib/module/modal/w3m-modal/index.js.map +1 -1
  96. package/lib/module/modal/w3m-router/index.js +20 -22
  97. package/lib/module/modal/w3m-router/index.js.map +1 -1
  98. package/lib/module/partials/w3m-account-wallet-features/index.js +1 -1
  99. package/lib/module/partials/w3m-account-wallet-features/index.js.map +1 -1
  100. package/lib/module/partials/w3m-all-wallets-list/components/WalletItem.js +6 -3
  101. package/lib/module/partials/w3m-all-wallets-list/components/WalletItem.js.map +1 -1
  102. package/lib/module/partials/w3m-all-wallets-list/components/WalletList.js +67 -23
  103. package/lib/module/partials/w3m-all-wallets-list/components/WalletList.js.map +1 -1
  104. package/lib/module/partials/w3m-all-wallets-list/index.js +3 -2
  105. package/lib/module/partials/w3m-all-wallets-list/index.js.map +1 -1
  106. package/lib/module/partials/w3m-all-wallets-search/index.js +5 -2
  107. package/lib/module/partials/w3m-all-wallets-search/index.js.map +1 -1
  108. package/lib/module/partials/w3m-connecting-mobile/index.js +22 -2
  109. package/lib/module/partials/w3m-connecting-mobile/index.js.map +1 -1
  110. package/lib/module/partials/w3m-connecting-qrcode/index.js +6 -2
  111. package/lib/module/partials/w3m-connecting-qrcode/index.js.map +1 -1
  112. package/lib/module/partials/w3m-connecting-web/index.js +9 -3
  113. package/lib/module/partials/w3m-connecting-web/index.js.map +1 -1
  114. package/lib/module/partials/w3m-header/index.js +4 -4
  115. package/lib/module/partials/w3m-header/index.js.map +1 -1
  116. package/lib/module/utils/SIWXUtil.js +275 -0
  117. package/lib/module/utils/SIWXUtil.js.map +1 -0
  118. package/lib/module/views/w3m-account-default-view/index.js +4 -3
  119. package/lib/module/views/w3m-account-default-view/index.js.map +1 -1
  120. package/lib/module/views/w3m-all-wallets-view/index.js +7 -4
  121. package/lib/module/views/w3m-all-wallets-view/index.js.map +1 -1
  122. package/lib/module/views/w3m-connect-view/components/all-wallet-list.js +34 -7
  123. package/lib/module/views/w3m-connect-view/components/all-wallet-list.js.map +1 -1
  124. package/lib/module/views/w3m-connect-view/index.js +6 -3
  125. package/lib/module/views/w3m-connect-view/index.js.map +1 -1
  126. package/lib/module/views/w3m-connecting-external-view/index.js +22 -2
  127. package/lib/module/views/w3m-connecting-external-view/index.js.map +1 -1
  128. package/lib/module/views/w3m-connecting-social-view/index.js +2 -1
  129. package/lib/module/views/w3m-connecting-social-view/index.js.map +1 -1
  130. package/lib/module/views/w3m-connecting-view/index.js +14 -33
  131. package/lib/module/views/w3m-connecting-view/index.js.map +1 -1
  132. package/lib/module/views/w3m-network-switch-view/index.js +2 -1
  133. package/lib/module/views/w3m-network-switch-view/index.js.map +1 -1
  134. package/lib/module/views/w3m-onramp-settings-view/components/Country.js +3 -1
  135. package/lib/module/views/w3m-onramp-settings-view/components/Country.js.map +1 -1
  136. package/lib/module/views/w3m-onramp-settings-view/index.js +2 -1
  137. package/lib/module/views/w3m-onramp-settings-view/index.js.map +1 -1
  138. package/lib/module/views/w3m-onramp-view/components/LoadingView.js +1 -1
  139. package/lib/module/views/w3m-onramp-view/components/LoadingView.js.map +1 -1
  140. package/lib/module/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.js +7 -43
  141. package/lib/module/views/w3m-siwx-sign-view/index.js.map +1 -0
  142. package/lib/module/views/w3m-siwx-sign-view/styles.js.map +1 -0
  143. package/lib/module/views/w3m-swap-view/index.js +1 -1
  144. package/lib/module/views/w3m-swap-view/index.js.map +1 -1
  145. package/lib/module/views/w3m-what-is-a-wallet-view/index.js +1 -1
  146. package/lib/module/views/w3m-what-is-a-wallet-view/index.js.map +1 -1
  147. package/lib/typescript/AppKit.d.ts +13 -4
  148. package/lib/typescript/AppKit.d.ts.map +1 -1
  149. package/lib/typescript/AppKitContext.d.ts +1 -1
  150. package/lib/typescript/AppKitContext.d.ts.map +1 -1
  151. package/lib/typescript/connectors/WalletConnectConnector.d.ts.map +1 -1
  152. package/lib/typescript/hooks/useAccount.d.ts +1 -1
  153. package/lib/typescript/hooks/useAccount.d.ts.map +1 -1
  154. package/lib/typescript/hooks/useAppKit.d.ts +2 -2
  155. package/lib/typescript/hooks/useAppKit.d.ts.map +1 -1
  156. package/lib/typescript/hooks/useAppKitEvents.d.ts +88 -21
  157. package/lib/typescript/hooks/useAppKitEvents.d.ts.map +1 -1
  158. package/lib/typescript/hooks/useAppKitLogs.d.ts +57 -0
  159. package/lib/typescript/hooks/useAppKitLogs.d.ts.map +1 -0
  160. package/lib/typescript/hooks/useAppKitState.d.ts +38 -0
  161. package/lib/typescript/hooks/useAppKitState.d.ts.map +1 -0
  162. package/lib/typescript/hooks/useProvider.d.ts.map +1 -1
  163. package/lib/typescript/hooks/useWalletInfo.d.ts +1 -0
  164. package/lib/typescript/hooks/useWalletInfo.d.ts.map +1 -1
  165. package/lib/typescript/index.d.ts +6 -0
  166. package/lib/typescript/index.d.ts.map +1 -1
  167. package/lib/typescript/modal/w3m-modal/index.d.ts.map +1 -1
  168. package/lib/typescript/modal/w3m-router/index.d.ts.map +1 -1
  169. package/lib/typescript/partials/w3m-all-wallets-list/components/WalletItem.d.ts +4 -2
  170. package/lib/typescript/partials/w3m-all-wallets-list/components/WalletItem.d.ts.map +1 -1
  171. package/lib/typescript/partials/w3m-all-wallets-list/components/WalletList.d.ts +4 -2
  172. package/lib/typescript/partials/w3m-all-wallets-list/components/WalletList.d.ts.map +1 -1
  173. package/lib/typescript/partials/w3m-all-wallets-list/index.d.ts +1 -1
  174. package/lib/typescript/partials/w3m-all-wallets-list/index.d.ts.map +1 -1
  175. package/lib/typescript/partials/w3m-all-wallets-search/index.d.ts +1 -1
  176. package/lib/typescript/partials/w3m-all-wallets-search/index.d.ts.map +1 -1
  177. package/lib/typescript/partials/w3m-connecting-mobile/index.d.ts.map +1 -1
  178. package/lib/typescript/partials/w3m-connecting-qrcode/index.d.ts.map +1 -1
  179. package/lib/typescript/partials/w3m-connecting-web/index.d.ts.map +1 -1
  180. package/lib/typescript/types.d.ts +6 -7
  181. package/lib/typescript/types.d.ts.map +1 -1
  182. package/lib/typescript/utils/SIWXUtil.d.ts +34 -0
  183. package/lib/typescript/utils/SIWXUtil.d.ts.map +1 -0
  184. package/lib/typescript/views/w3m-account-default-view/index.d.ts.map +1 -1
  185. package/lib/typescript/views/w3m-all-wallets-view/index.d.ts.map +1 -1
  186. package/lib/typescript/views/w3m-connect-view/components/all-wallet-list.d.ts +1 -1
  187. package/lib/typescript/views/w3m-connect-view/components/all-wallet-list.d.ts.map +1 -1
  188. package/lib/typescript/views/w3m-connect-view/index.d.ts.map +1 -1
  189. package/lib/typescript/views/w3m-connecting-external-view/index.d.ts.map +1 -1
  190. package/lib/typescript/views/w3m-connecting-social-view/index.d.ts.map +1 -1
  191. package/lib/typescript/views/w3m-connecting-view/index.d.ts.map +1 -1
  192. package/lib/typescript/views/w3m-network-switch-view/index.d.ts.map +1 -1
  193. package/lib/typescript/views/w3m-onramp-settings-view/components/Country.d.ts +2 -1
  194. package/lib/typescript/views/w3m-onramp-settings-view/components/Country.d.ts.map +1 -1
  195. package/lib/typescript/views/w3m-onramp-settings-view/index.d.ts.map +1 -1
  196. package/lib/typescript/views/w3m-siwx-sign-view/index.d.ts +2 -0
  197. package/lib/typescript/views/w3m-siwx-sign-view/index.d.ts.map +1 -0
  198. package/lib/typescript/views/w3m-siwx-sign-view/styles.d.ts.map +1 -0
  199. package/package.json +9 -9
  200. package/src/AppKit.ts +148 -97
  201. package/src/AppKitContext.tsx +19 -11
  202. package/src/connectors/WalletConnectConnector.ts +33 -69
  203. package/src/hooks/useAccount.ts +9 -4
  204. package/src/hooks/useAppKit.ts +19 -13
  205. package/src/hooks/useAppKitLogs.ts +129 -0
  206. package/src/hooks/useAppKitState.ts +26 -0
  207. package/src/hooks/useProvider.ts +21 -6
  208. package/src/hooks/useWalletInfo.ts +5 -2
  209. package/src/index.ts +14 -0
  210. package/src/modal/w3m-modal/index.tsx +9 -1
  211. package/src/modal/w3m-router/index.tsx +15 -18
  212. package/src/partials/w3m-account-wallet-features/index.tsx +1 -1
  213. package/src/partials/w3m-all-wallets-list/components/WalletItem.tsx +13 -3
  214. package/src/partials/w3m-all-wallets-list/components/WalletList.tsx +79 -24
  215. package/src/partials/w3m-all-wallets-list/index.tsx +4 -2
  216. package/src/partials/w3m-all-wallets-search/index.tsx +16 -3
  217. package/src/partials/w3m-connecting-mobile/index.tsx +24 -2
  218. package/src/partials/w3m-connecting-qrcode/index.tsx +8 -2
  219. package/src/partials/w3m-connecting-web/index.tsx +11 -3
  220. package/src/partials/w3m-header/index.tsx +4 -4
  221. package/src/types.ts +7 -8
  222. package/src/utils/SIWXUtil.ts +359 -0
  223. package/src/views/w3m-account-default-view/index.tsx +5 -3
  224. package/src/views/w3m-all-wallets-view/index.tsx +11 -4
  225. package/src/views/w3m-connect-view/components/all-wallet-list.tsx +46 -15
  226. package/src/views/w3m-connect-view/index.tsx +6 -3
  227. package/src/views/w3m-connecting-external-view/index.tsx +24 -2
  228. package/src/views/w3m-connecting-social-view/index.tsx +3 -1
  229. package/src/views/w3m-connecting-view/index.tsx +16 -33
  230. package/src/views/w3m-network-switch-view/index.tsx +2 -0
  231. package/src/views/w3m-onramp-settings-view/components/Country.tsx +3 -1
  232. package/src/views/w3m-onramp-settings-view/index.tsx +1 -0
  233. package/src/views/w3m-onramp-view/components/LoadingView.tsx +1 -1
  234. package/src/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/index.tsx +7 -37
  235. package/src/views/w3m-swap-view/index.tsx +1 -1
  236. package/src/views/w3m-what-is-a-wallet-view/index.tsx +1 -1
  237. package/lib/commonjs/views/w3m-connecting-siwe-view/index.js.map +0 -1
  238. package/lib/commonjs/views/w3m-connecting-siwe-view/styles.js.map +0 -1
  239. package/lib/module/views/w3m-connecting-siwe-view/index.js.map +0 -1
  240. package/lib/module/views/w3m-connecting-siwe-view/styles.js.map +0 -1
  241. package/lib/typescript/views/w3m-connecting-siwe-view/index.d.ts +0 -2
  242. package/lib/typescript/views/w3m-connecting-siwe-view/index.d.ts.map +0 -1
  243. package/lib/typescript/views/w3m-connecting-siwe-view/styles.d.ts.map +0 -1
  244. /package/lib/commonjs/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.js +0 -0
  245. /package/lib/module/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.js +0 -0
  246. /package/lib/typescript/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.d.ts +0 -0
  247. /package/src/views/{w3m-connecting-siwe-view → w3m-siwx-sign-view}/styles.ts +0 -0
package/src/AppKit.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  SendController,
16
16
  BlockchainApiController,
17
17
  WalletUtil,
18
+ LogController,
18
19
  type RouterControllerState
19
20
  } from '@reown/appkit-core-react-native';
20
21
 
@@ -37,13 +38,20 @@ import {
37
38
  type Connection,
38
39
  type WcWallet
39
40
  } from '@reown/appkit-common-react-native';
40
- import { SIWEController } from '@reown/appkit-siwe-react-native';
41
41
 
42
42
  import { WalletConnectConnector } from './connectors/WalletConnectConnector';
43
43
  import { WcHelpersUtil } from './utils/HelpersUtil';
44
44
  import { NetworkUtil } from './utils/NetworkUtil';
45
45
  import { RouterUtil } from './utils/RouterUtil';
46
46
  import { type AppKitConfig } from './types';
47
+ import { SIWXUtil } from './utils/SIWXUtil';
48
+
49
+ const APPKIT_INSTANCE_KEY = Symbol.for('__REOWN_APPKIT_INSTANCE__');
50
+
51
+ // Type helper to access the symbol-keyed property on globalThis
52
+ interface GlobalWithAppKit {
53
+ [key: symbol]: AppKit | undefined;
54
+ }
47
55
 
48
56
  export class AppKit {
49
57
  private projectId: string;
@@ -131,8 +139,7 @@ export class AppKit {
131
139
  const approvedNamespaces = await connector.connect({
132
140
  namespaces: this.namespaces,
133
141
  defaultNetwork: chain,
134
- universalLink: targetWallet?.link_mode ?? undefined,
135
- siweConfig: this.config?.siweConfig
142
+ universalLink: targetWallet?.link_mode ?? undefined
136
143
  });
137
144
 
138
145
  this.processConnection(connector, approvedNamespaces);
@@ -145,16 +152,12 @@ export class AppKit {
145
152
  });
146
153
  }
147
154
  } catch (error) {
148
- console.warn('Connection failed:', error);
155
+ LogController.sendError(error, 'AppKit.ts', 'connect');
149
156
  throw error;
150
157
  }
151
158
  }
152
159
 
153
- private async processConnection(
154
- connector: WalletConnector,
155
- namespaces?: Namespaces,
156
- shouldCloseModal: boolean = true
157
- ) {
160
+ private async processConnection(connector: WalletConnector, namespaces?: Namespaces) {
158
161
  if (!namespaces || Object.keys(namespaces).length === 0) {
159
162
  throw new Error('No namespaces provided');
160
163
  }
@@ -176,19 +179,7 @@ export class AppKit {
176
179
  // Sync accounts
177
180
  await this.syncAccounts(initializedAdapters);
178
181
 
179
- // Handle SIWE if enabled
180
- this.handleSiweConnectionIfEnabled(shouldCloseModal);
181
- }
182
-
183
- private handleSiweConnectionIfEnabled(shouldCloseModal: boolean = true): void {
184
- if (
185
- OptionsController.state.isSiweEnabled &&
186
- ConnectionsController.state.activeNamespace === 'eip155'
187
- ) {
188
- this.handleSiweChange({ isConnection: true });
189
- } else if (shouldCloseModal) {
190
- ModalController.close();
191
- }
182
+ await SIWXUtil.initializeIfEnabled({ onDisconnect: this.disconnect, closeModal: true });
192
183
  }
193
184
 
194
185
  /**
@@ -196,7 +187,7 @@ export class AppKit {
196
187
  * @param namespace - The namespace to disconnect from.
197
188
  * @param isInternal - Whether the disconnect is internal (i.e. from the AppKit) or external (i.e. from wallet side).
198
189
  */
199
- async disconnect(namespace?: string, isInternal?: boolean): Promise<void> {
190
+ async disconnect(namespace?: ChainNamespace, isInternal?: boolean): Promise<void> {
200
191
  try {
201
192
  const activeNamespace = namespace ?? ConnectionsController.state.activeNamespace;
202
193
 
@@ -223,6 +214,7 @@ export class AppKit {
223
214
  SendController.resetState();
224
215
  OnRampController.resetState();
225
216
  WcController.resetState();
217
+ EventsController.resetState();
226
218
 
227
219
  if (ConnectionsController.state.activeNamespace === undefined) {
228
220
  ConnectionsController.setActiveNamespace(
@@ -230,15 +222,19 @@ export class AppKit {
230
222
  );
231
223
  }
232
224
 
233
- if (OptionsController.state.isSiweEnabled) {
234
- await SIWEController.signOut();
225
+ if (SIWXUtil.getSIWX()?.signOutOnDisconnect) {
226
+ await SIWXUtil.clearSessions();
235
227
  }
236
228
 
237
229
  EventsController.sendEvent({
238
230
  type: 'track',
239
- event: 'DISCONNECT_SUCCESS'
231
+ event: 'DISCONNECT_SUCCESS',
232
+ properties: {
233
+ namespace: activeNamespace
234
+ }
240
235
  });
241
236
  } catch (error) {
237
+ LogController.sendError(error, 'AppKit.ts', 'disconnect');
242
238
  EventsController.sendEvent({
243
239
  type: 'track',
244
240
  event: 'DISCONNECT_ERROR'
@@ -249,7 +245,7 @@ export class AppKit {
249
245
  /**
250
246
  * Returns the provider for a given namespace.
251
247
  * @param namespace - The namespace to get the provider for.
252
- * @returns The provider for the given namespace.
248
+ * @returns The provider for the given namespace, or null if not available or not yet initialized.
253
249
  */
254
250
  getProvider<T extends Provider>(namespace?: string): T | null {
255
251
  const activeNamespace = namespace ?? ConnectionsController.state.activeNamespace;
@@ -260,7 +256,15 @@ export class AppKit {
260
256
  );
261
257
  if (!connection || !connection.adapter || !connection.adapter.connector) return null;
262
258
 
263
- return connection.adapter.connector.getProvider() as T;
259
+ try {
260
+ return connection.adapter.connector.getProvider() as T | null;
261
+ } catch (error) {
262
+ // Provider not initialized yet during session restoration
263
+ // This can happen on app restart when restoring a previous connection
264
+ LogController.sendError(error, 'AppKit.ts', 'getProvider');
265
+
266
+ return null;
267
+ }
264
268
  }
265
269
 
266
270
  getNetworks() {
@@ -285,7 +289,7 @@ export class AppKit {
285
289
  type: 'track',
286
290
  event: 'SWITCH_NETWORK',
287
291
  properties: {
288
- network: network.id
292
+ network: network.caipNetworkId
289
293
  }
290
294
  });
291
295
 
@@ -298,15 +302,11 @@ export class AppKit {
298
302
 
299
303
  async close() {
300
304
  ModalController.close();
305
+ const isSIWXRequired = SIWXUtil.getSIWX()?.getRequired?.();
301
306
 
302
- if (OptionsController.state.isSiweEnabled && ConnectionsController.state.isConnected) {
303
- const session = await SIWEController.getSession();
304
- if (
305
- !session &&
306
- SIWEController.state.status !== 'success' &&
307
- ConnectionsController.state.activeNamespace === 'eip155' &&
308
- !!ConnectionsController.state.activeAddress
309
- ) {
307
+ if (isSIWXRequired && ConnectionsController.state.isConnected) {
308
+ const sessions = await SIWXUtil.getSessions();
309
+ if (!sessions.length) {
310
310
  return await this.disconnect();
311
311
  }
312
312
  }
@@ -317,6 +317,7 @@ export class AppKit {
317
317
 
318
318
  RouterUtil.checkOnRampBack();
319
319
  RouterUtil.checkSocialLoginBack();
320
+ EventsController.sendWalletImpressions();
320
321
  }
321
322
 
322
323
  back() {
@@ -326,6 +327,13 @@ export class AppKit {
326
327
  return RouterController.goBack();
327
328
  }
328
329
 
330
+ const isSIWXRequired = SIWXUtil.getSIWX()?.getRequired?.();
331
+
332
+ if (isSIWXRequired) {
333
+ // Don't close the modal if SIWX is required
334
+ return;
335
+ }
336
+
329
337
  return this.close();
330
338
  }
331
339
 
@@ -396,25 +404,44 @@ export class AppKit {
396
404
  * This attempts to restore previous sessions.
397
405
  */
398
406
  private async initConnectors() {
407
+ ModalController.setLoading(true);
408
+
409
+ //Always init the walletconnect connector
410
+ await this.createWalletConnectConnector();
411
+
399
412
  const connectedConnectors = await StorageUtil.getConnectedConnectors();
400
413
  if (connectedConnectors.length > 0) {
401
- ModalController.setLoading(true);
402
-
403
414
  for (const connected of connectedConnectors) {
404
415
  try {
405
416
  const connector = await this.createConnector(connected.type);
406
417
 
407
418
  const namespaces = connector.getNamespaces();
408
419
 
409
- await this.processConnection(connector, namespaces, false);
420
+ await this.processConnection(connector, namespaces);
410
421
  } catch (error) {
411
- // Use console.warn for non-critical initialization failures
412
- console.warn(`Failed to initialize connector type ${connected.type}:`, error);
422
+ LogController.sendError(error, 'AppKit.ts', 'initializeConnector', {
423
+ connectorType: connected.type
424
+ });
413
425
  await StorageUtil.removeConnectedConnectors(connected.type);
414
426
  }
415
427
  }
416
- ModalController.setLoading(false);
428
+
429
+ const address = ConnectionsController.state.activeAddress;
430
+ const walletInfo = ConnectionsController.state.walletInfo;
431
+ if (address) {
432
+ EventsController.sendEvent({
433
+ type: 'track',
434
+ event: 'CONNECT_SUCCESS',
435
+ address: CoreHelperUtil.getPlainAddress(address),
436
+ properties: {
437
+ name: walletInfo?.name ?? 'Unknown',
438
+ reconnect: true
439
+ }
440
+ });
441
+ }
417
442
  }
443
+
444
+ ModalController.setLoading(false);
418
445
  }
419
446
 
420
447
  private setupAdaptersAndSubscribe(
@@ -506,6 +533,7 @@ export class AppKit {
506
533
  );
507
534
  }
508
535
  } catch (error) {
536
+ LogController.sendError(error, 'AppKit.ts', 'syncIdentity');
509
537
  // Continue processing other addresses even if one fails
510
538
  }
511
539
  }
@@ -524,8 +552,9 @@ export class AppKit {
524
552
  this.syncNativeBalance(adapter, network);
525
553
  }
526
554
  }
527
- } catch {
555
+ } catch (error) {
528
556
  // ignore
557
+ LogController.sendError(error, 'AppKit.ts', 'refreshBalance');
529
558
  }
530
559
  }
531
560
 
@@ -603,11 +632,7 @@ export class AppKit {
603
632
  private subscribeToAdapterEvents(adapter: BlockchainAdapter): void {
604
633
  adapter.on('accountsChanged', ({ accounts }) => {
605
634
  const namespace = adapter.getSupportedNamespace();
606
- const hasChanged = ConnectionsController.updateAccounts(namespace, accounts);
607
-
608
- if (hasChanged && namespace === 'eip155') {
609
- this.handleSiweChange({ isAccountChange: true });
610
- }
635
+ ConnectionsController.updateAccounts(namespace, accounts);
611
636
  });
612
637
 
613
638
  adapter.on('chainChanged', async ({ chainId }) => {
@@ -618,6 +643,7 @@ export class AppKit {
618
643
 
619
644
  const namespace = adapter.getSupportedNamespace();
620
645
  const chain = `${namespace}:${chainId}` as CaipNetworkId;
646
+
621
647
  ConnectionsController.setActiveNetwork(namespace, chain);
622
648
 
623
649
  const connection = ConnectionsController.state.connections.get(namespace);
@@ -639,10 +665,13 @@ export class AppKit {
639
665
  TransactionsController.fetchTransactions(address, true);
640
666
  }
641
667
 
642
- // Check if user needs to sign in again
643
- if (namespace === 'eip155') {
644
- this.handleSiweChange({ isNetworkChange: true });
645
- }
668
+ const closeModal = RouterController.state.view === 'UnsupportedChain';
669
+
670
+ SIWXUtil.initializeIfEnabled({
671
+ onDisconnect: this.disconnect,
672
+ caipAddress: address,
673
+ closeModal
674
+ });
646
675
  });
647
676
 
648
677
  adapter.on('disconnect', () => {
@@ -658,6 +687,7 @@ export class AppKit {
658
687
 
659
688
  private async initControllers(options: AppKitConfig) {
660
689
  await this.initStorageAndValues(options);
690
+ let defaultNetwork;
661
691
 
662
692
  OptionsController.setProjectId(options.projectId);
663
693
  OptionsController.setMetadata(options.metadata);
@@ -667,15 +697,23 @@ export class AppKit {
667
697
  OptionsController.setFeaturedWalletIds(options.featuredWalletIds);
668
698
  OptionsController.setEnableAnalytics(options.enableAnalytics);
669
699
  OptionsController.setDebug(options.debug);
700
+
701
+ LogController.sendInfo('AppKit initialization started', 'AppKit.ts', 'initControllers', {
702
+ projectId: options.projectId,
703
+ adapters: this.adapters.map(a => a.constructor.name),
704
+ networks: this.networks.map(n => n.name),
705
+ debug: options.debug
706
+ });
707
+
670
708
  OptionsController.setFeatures(options.features);
671
709
  OptionsController.setRequestedNetworks(this.networks);
672
710
 
673
711
  if (options.defaultNetwork) {
674
- const network = NetworkUtil.formatNetwork(options.defaultNetwork, this.projectId);
675
- OptionsController.setDefaultNetwork(network);
712
+ defaultNetwork = NetworkUtil.formatNetwork(options.defaultNetwork, this.projectId);
713
+ OptionsController.setDefaultNetwork(defaultNetwork);
676
714
  }
677
715
 
678
- ThemeController.setThemeMode(options.themeMode);
716
+ ThemeController.setDefaultThemeMode(options.themeMode);
679
717
  ThemeController.setThemeVariables(options.themeVariables);
680
718
 
681
719
  OptionsController.setSdkVersion(
@@ -688,9 +726,8 @@ export class AppKit {
688
726
 
689
727
  ConnectionsController.setNetworks(this.networks);
690
728
 
691
- if (options.siweConfig) {
692
- SIWEController.setSIWEClient(options.siweConfig);
693
- OptionsController.setIsSiweEnabled(options.siweConfig.options.enabled);
729
+ if (options.siwx) {
730
+ OptionsController.setSiwx(options.siwx);
694
731
  }
695
732
 
696
733
  if (
@@ -699,6 +736,24 @@ export class AppKit {
699
736
  ) {
700
737
  OptionsController.setIsOnRampEnabled(true);
701
738
  }
739
+
740
+ EventsController.sendEvent({
741
+ type: 'track',
742
+ event: 'INITIALIZE',
743
+ properties: {
744
+ showWallets: options.features?.showWallets,
745
+ themeMode: options.themeMode,
746
+ themeVariables: options.themeVariables,
747
+ networks: this.networks.map(network => network.caipNetworkId).filter(Boolean),
748
+ defaultNetwork: defaultNetwork?.caipNetworkId,
749
+ metadata: options.metadata,
750
+ enableAnalytics: options.enableAnalytics,
751
+ features: options.features,
752
+ adapters: this.adapters.map(adapter => adapter?.constructor?.name).filter(Boolean),
753
+ extraConnectors: this.extraConnectors.map(connector => connector?.type).filter(Boolean),
754
+ siwx: !!options.siwx
755
+ }
756
+ });
702
757
  }
703
758
 
704
759
  private async initActiveNamespace() {
@@ -796,47 +851,43 @@ export class AppKit {
796
851
  ModalController.open({ view: routeName });
797
852
  }
798
853
  };
854
+ }
799
855
 
800
- private async handleSiweChange(params?: {
801
- isConnection?: boolean;
802
- isNetworkChange?: boolean;
803
- isAccountChange?: boolean;
804
- }) {
805
- const { isNetworkChange, isAccountChange, isConnection } = params ?? {};
806
- const { enabled, signOutOnAccountChange, signOutOnNetworkChange } =
807
- SIWEController.state._client?.options ?? {};
808
-
809
- if (!enabled || RouterController.state.view === 'ConnectingSiwe') {
810
- // Do nothing if view is connecting siwe or siwe is not enabled
811
- return;
812
- }
813
-
814
- const session = await SIWEController.getSession();
815
- if (session && isAccountChange) {
816
- if (signOutOnAccountChange) {
817
- // If the address has changed and signOnAccountChange is enabled, sign out
818
- await SIWEController.signOut();
819
-
820
- return this.navigate('ConnectingSiwe');
821
- }
822
- } else if (session && isNetworkChange) {
823
- if (signOutOnNetworkChange) {
824
- // If the network has changed and signOnNetworkChange is enabled, sign out
825
- await SIWEController.signOut();
826
-
827
- return this.navigate('ConnectingSiwe');
856
+ /**
857
+ * Creates or returns the existing AppKit singleton instance.
858
+ *
859
+ * @warning This function implements a singleton pattern. If an instance already exists,
860
+ * it will be returned and the provided config parameter will be IGNORED. If you need to
861
+ * change configuration, you must reload your application or clear the singleton manually.
862
+ *
863
+ * @param config - AppKit configuration options
864
+ * @returns The AppKit singleton instance
865
+ * @throws Error if configuration validation fails
866
+ */
867
+ export function createAppKit(config: AppKitConfig): AppKit {
868
+ try {
869
+ const globalWithAppKit = globalThis as GlobalWithAppKit;
870
+
871
+ if (!globalWithAppKit[APPKIT_INSTANCE_KEY]) {
872
+ if (config.debug && __DEV__) {
873
+ // using console.log to avoid possible issues with LogController not being initialized
874
+ //eslint-disable-next-line no-console
875
+ console.log('AppKit: Creating new instance - AppKit.ts:createAppKit');
828
876
  }
829
- } else if (!session) {
830
- // If it's connected but there's no session, show sign view
877
+ globalWithAppKit[APPKIT_INSTANCE_KEY] = new AppKit(config);
878
+ } else if (config.debug && __DEV__) {
879
+ //eslint-disable-next-line no-console
880
+ console.log('AppKit: Reusing existing instance - AppKit.ts:createAppKit');
881
+ }
831
882
 
832
- return this.navigate('ConnectingSiwe');
833
- } else if (isConnection) {
834
- // Already connected with 1CA
835
- ModalController.close();
883
+ return globalWithAppKit[APPKIT_INSTANCE_KEY]!;
884
+ } catch (error) {
885
+ if (__DEV__) {
886
+ // using console.error to avoid possible issues with LogController not being initialized
887
+ //eslint-disable-next-line no-console
888
+ console.error('AppKit: Failed to create instance - AppKit.ts:createAppKit', error);
836
889
  }
837
- }
838
- }
839
890
 
840
- export function createAppKit(config: AppKitConfig): AppKit {
841
- return new AppKit(config);
891
+ throw error;
892
+ }
842
893
  }
@@ -1,4 +1,4 @@
1
- import React, { createContext, useContext, type ReactNode } from 'react';
1
+ import React, { createContext, useContext, useMemo, type ReactNode } from 'react';
2
2
  import { AppKit } from './AppKit';
3
3
 
4
4
  interface AppKitContextType {
@@ -26,14 +26,22 @@ export const useInternalAppKit = () => {
26
26
  throw new Error('AppKit instance is not yet available in context.');
27
27
  }
28
28
 
29
- return {
30
- connect: context.appKit.connect.bind(context.appKit),
31
- disconnect: context.appKit.disconnect.bind(context.appKit),
32
- open: context.appKit.open.bind(context.appKit),
33
- close: context.appKit.close.bind(context.appKit),
34
- back: context.appKit.back.bind(context.appKit),
35
- switchNetwork: context.appKit.switchNetwork.bind(context.appKit),
36
- getProvider: context.appKit.getProvider.bind(context.appKit),
37
- switchAccountType: context.appKit.switchAccountType.bind(context.appKit)
38
- };
29
+ const stableFunctions = useMemo(() => {
30
+ if (!context.appKit) {
31
+ throw new Error('AppKit instance is not available');
32
+ }
33
+
34
+ return {
35
+ connect: context.appKit.connect.bind(context.appKit),
36
+ disconnect: context.appKit.disconnect.bind(context.appKit),
37
+ open: context.appKit.open.bind(context.appKit),
38
+ close: context.appKit.close.bind(context.appKit),
39
+ back: context.appKit.back.bind(context.appKit),
40
+ switchNetwork: context.appKit.switchNetwork.bind(context.appKit),
41
+ getProvider: context.appKit.getProvider.bind(context.appKit),
42
+ switchAccountType: context.appKit.switchAccountType.bind(context.appKit)
43
+ };
44
+ }, [context.appKit]);
45
+
46
+ return stableFunctions;
39
47
  };
@@ -1,5 +1,5 @@
1
1
  import { WcController } from '@reown/appkit-core-react-native';
2
- import { UniversalProvider, type IUniversalProvider } from '@walletconnect/universal-provider';
2
+ import UniversalProvider from '@walletconnect/universal-provider';
3
3
  import {
4
4
  WalletConnector,
5
5
  type AppKitNetwork,
@@ -14,7 +14,7 @@ import {
14
14
  type ConnectionProperties,
15
15
  type RequestArguments
16
16
  } from '@reown/appkit-common-react-native';
17
- import { getDidAddress, getDidChainId, SIWEController } from '@reown/appkit-siwe-react-native';
17
+ import { SIWXUtil } from '../utils/SIWXUtil';
18
18
 
19
19
  interface WalletConnectConnectorConfig {
20
20
  projectId: string;
@@ -42,7 +42,7 @@ export class WalletConnectConnector extends WalletConnector {
42
42
  }
43
43
 
44
44
  override async restoreSession(): Promise<boolean> {
45
- const provider = this.getProvider() as IUniversalProvider;
45
+ const provider = this.getProvider() as UniversalProvider;
46
46
  if (!provider) {
47
47
  return false;
48
48
  }
@@ -67,9 +67,15 @@ export class WalletConnectConnector extends WalletConnector {
67
67
  this.wallet = {
68
68
  ...metadata,
69
69
  name: metadata.name,
70
- icon: metadata.icons?.[0]
70
+ icon: metadata.icons?.[0],
71
+ type: 'walletconnect'
71
72
  };
72
73
  }
74
+ } else {
75
+ this.wallet = {
76
+ name: 'Unknown Wallet',
77
+ type: 'walletconnect'
78
+ };
73
79
  }
74
80
 
75
81
  return true;
@@ -81,7 +87,7 @@ export class WalletConnectConnector extends WalletConnector {
81
87
  }: {
82
88
  projectId: string;
83
89
  metadata: Metadata;
84
- }): Promise<IUniversalProvider> {
90
+ }): Promise<UniversalProvider> {
85
91
  if (!this.provider) {
86
92
  this.provider = (await UniversalProvider.init({
87
93
  projectId,
@@ -90,82 +96,36 @@ export class WalletConnectConnector extends WalletConnector {
90
96
  })) as Provider;
91
97
  }
92
98
 
93
- return this.provider as IUniversalProvider;
99
+ return this.provider as UniversalProvider;
94
100
  }
95
101
 
96
102
  override async connect(opts: ConnectOptions) {
97
- const { siweConfig, namespaces, defaultNetwork, universalLink } = opts;
103
+ const { namespaces, defaultNetwork, universalLink } = opts;
98
104
  function onUri(uri: string) {
99
105
  WcController.setWcUri(uri);
100
106
  }
101
107
 
102
- const provider = this.getProvider() as IUniversalProvider;
108
+ const provider = this.getProvider() as UniversalProvider;
103
109
 
104
110
  // @ts-ignore
105
111
  provider.on('display_uri', onUri);
106
112
 
107
- let session: IUniversalProvider['session'];
113
+ let session: UniversalProvider['session'];
108
114
 
109
115
  // SIWE
110
116
  const isEVMOnly = Object.keys(namespaces ?? {}).length === 1 && namespaces?.['eip155'];
111
- const params = await siweConfig?.getMessageParams?.();
112
- if (siweConfig?.options?.enabled && params && Object.keys(params).length > 0 && isEVMOnly) {
117
+
118
+ if (isEVMOnly && SIWXUtil.getSIWX()) {
113
119
  // 1CA is only supported on EVM
114
120
 
115
- // @ts-ignore
116
- const result = await provider.authenticate(
117
- {
118
- ...params,
119
- nonce: await siweConfig.getNonce(),
120
- methods: namespaces?.['eip155']?.methods,
121
- chains: params.chains
122
- },
121
+ session = await SIWXUtil.universalProviderAuthenticate({
122
+ universalProvider: this.provider as UniversalProvider,
123
+ chains: namespaces?.['eip155']?.chains ?? [],
124
+ methods: namespaces?.['eip155']?.methods ?? [],
123
125
  universalLink
124
- );
125
-
126
- // Auths is an array of signed CACAO objects https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-74.md
127
- const signedCacao = result?.auths?.[0];
128
- if (signedCacao) {
129
- const { p, s } = signedCacao;
130
- const chainId = getDidChainId(p.iss);
131
- const address = getDidAddress(p.iss);
132
-
133
- try {
134
- // Kicks off verifyMessage and populates external states
135
- const message = provider?.client?.formatAuthMessage({
136
- request: p,
137
- iss: p.iss
138
- })!;
139
-
140
- await SIWEController.verifyMessage({
141
- message,
142
- signature: s.s,
143
- cacao: signedCacao
144
- });
145
-
146
- if (address && chainId) {
147
- const siweSession = {
148
- address,
149
- chainId: parseInt(chainId, 10)
150
- };
151
-
152
- SIWEController.setSession(siweSession);
153
- SIWEController.onSignIn?.(siweSession);
154
- }
155
- } catch (error) {
156
- // eslint-disable-next-line no-console
157
- console.error('Error verifying message', error);
158
- // eslint-disable-next-line no-console
159
- await provider.disconnect().catch(console.error);
160
- // eslint-disable-next-line no-console
161
- await SIWEController.signOut().catch(console.error);
162
- throw error;
163
- }
164
- }
165
- session = result?.session;
126
+ });
166
127
  } else {
167
- session = await (this.provider as IUniversalProvider).connect({
168
- namespaces: {},
128
+ session = await (this.provider as UniversalProvider).connect({
169
129
  optionalNamespaces: namespaces
170
130
  });
171
131
  }
@@ -175,14 +135,18 @@ export class WalletConnectConnector extends WalletConnector {
175
135
  this.wallet = {
176
136
  ...metadata,
177
137
  name: metadata?.name,
178
- icon: metadata?.icons?.[0]
138
+ icon: metadata?.icons?.[0],
139
+ type: 'walletconnect'
179
140
  };
180
141
  } else {
181
- this.wallet = undefined;
142
+ this.wallet = {
143
+ name: 'Unknown Wallet',
144
+ type: 'walletconnect'
145
+ };
182
146
  }
183
147
 
184
148
  if (defaultNetwork?.caipNetworkId) {
185
- (this.provider as IUniversalProvider).setDefaultChain(defaultNetwork.caipNetworkId);
149
+ (this.provider as UniversalProvider).setDefaultChain(defaultNetwork.caipNetworkId);
186
150
  }
187
151
 
188
152
  if (session?.sessionProperties) {
@@ -229,7 +193,7 @@ export class WalletConnectConnector extends WalletConnector {
229
193
 
230
194
  override getNamespaces(): Namespaces {
231
195
  const namespaces =
232
- ((this.provider as IUniversalProvider)?.session?.namespaces as Namespaces) ?? {};
196
+ ((this.provider as UniversalProvider)?.session?.namespaces as Namespaces) ?? {};
233
197
  this.namespaces = namespaces;
234
198
 
235
199
  return namespaces;
@@ -244,7 +208,7 @@ export class WalletConnectConnector extends WalletConnector {
244
208
 
245
209
  let caipNetworkId = network.caipNetworkId ?? `eip155:${network.id}`;
246
210
 
247
- (this.provider as IUniversalProvider).setDefaultChain(caipNetworkId);
211
+ (this.provider as UniversalProvider).setDefaultChain(caipNetworkId);
248
212
 
249
213
  return Promise.resolve();
250
214
  }
@@ -259,7 +223,7 @@ export class WalletConnectConnector extends WalletConnector {
259
223
  return undefined;
260
224
  }
261
225
 
262
- const chainId = (this.provider as IUniversalProvider).rpcProviders[
226
+ const chainId = (this.provider as UniversalProvider).rpcProviders[
263
227
  namespace
264
228
  ]?.getDefaultChain?.();
265
229