@reown/appkit-core-react-native 0.0.0-chore-solflare-20250730210452 → 0.0.0-chore-spring-effect-20250909214820

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 (153) hide show
  1. package/lib/commonjs/controllers/ApiController.js +121 -77
  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 +1 -3
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionsController.js +31 -33
  8. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
  9. package/lib/commonjs/controllers/ModalController.js +4 -1
  10. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  11. package/lib/commonjs/controllers/OnRampController.js +7 -4
  12. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  13. package/lib/commonjs/controllers/OptionsController.js +5 -4
  14. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  15. package/lib/commonjs/controllers/RouterController.js +2 -2
  16. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  17. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  18. package/lib/commonjs/controllers/WcController.js +73 -0
  19. package/lib/commonjs/controllers/WcController.js.map +1 -0
  20. package/lib/commonjs/index.js +14 -14
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/utils/AssetUtil.js +9 -7
  23. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  24. package/lib/commonjs/utils/ConstantsUtil.js +1 -5
  25. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  26. package/lib/commonjs/utils/CoreHelperUtil.js +7 -0
  27. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  28. package/lib/commonjs/utils/StorageUtil.js +0 -46
  29. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  30. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  31. package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
  32. package/lib/commonjs/utils/WalletUtil.js +23 -0
  33. package/lib/commonjs/utils/WalletUtil.js.map +1 -0
  34. package/lib/module/controllers/ApiController.js +121 -76
  35. package/lib/module/controllers/ApiController.js.map +1 -1
  36. package/lib/module/controllers/AssetController.js +0 -4
  37. package/lib/module/controllers/AssetController.js.map +1 -1
  38. package/lib/module/controllers/BlockchainApiController.js +1 -3
  39. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  40. package/lib/module/controllers/ConnectionsController.js +31 -33
  41. package/lib/module/controllers/ConnectionsController.js.map +1 -1
  42. package/lib/module/controllers/ModalController.js +4 -1
  43. package/lib/module/controllers/ModalController.js.map +1 -1
  44. package/lib/module/controllers/OnRampController.js +5 -2
  45. package/lib/module/controllers/OnRampController.js.map +1 -1
  46. package/lib/module/controllers/OptionsController.js +5 -4
  47. package/lib/module/controllers/OptionsController.js.map +1 -1
  48. package/lib/module/controllers/RouterController.js +2 -2
  49. package/lib/module/controllers/RouterController.js.map +1 -1
  50. package/lib/module/controllers/SwapController.js.map +1 -1
  51. package/lib/module/controllers/WcController.js +70 -0
  52. package/lib/module/controllers/WcController.js.map +1 -0
  53. package/lib/module/index.js +4 -2
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/utils/AssetUtil.js +9 -7
  56. package/lib/module/utils/AssetUtil.js.map +1 -1
  57. package/lib/module/utils/ConstantsUtil.js +1 -5
  58. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  59. package/lib/module/utils/CoreHelperUtil.js +8 -0
  60. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  61. package/lib/module/utils/StorageUtil.js +0 -47
  62. package/lib/module/utils/StorageUtil.js.map +1 -1
  63. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  64. package/lib/module/utils/SwapCalculationUtil.js +1 -0
  65. package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
  66. package/lib/module/utils/WalletUtil.js +19 -0
  67. package/lib/module/utils/WalletUtil.js.map +1 -0
  68. package/lib/typescript/controllers/ApiController.d.ts +1 -3
  69. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  70. package/lib/typescript/controllers/AssetController.d.ts +0 -2
  71. package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
  72. package/lib/typescript/controllers/BlockchainApiController.d.ts +4 -3
  73. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  74. package/lib/typescript/controllers/ConnectionsController.d.ts +3 -2
  75. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
  76. package/lib/typescript/controllers/EnsController.d.ts +1 -1
  77. package/lib/typescript/controllers/EventsController.d.ts +1 -1
  78. package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
  79. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  80. package/lib/typescript/controllers/OnRampController.d.ts +2 -2
  81. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  82. package/lib/typescript/controllers/OptionsController.d.ts +3 -4
  83. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  84. package/lib/typescript/controllers/RouterController.d.ts +4 -7
  85. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  86. package/lib/typescript/controllers/SwapController.d.ts +1 -2
  87. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  88. package/lib/typescript/controllers/WcController.d.ts +27 -0
  89. package/lib/typescript/controllers/WcController.d.ts.map +1 -0
  90. package/lib/typescript/index.d.ts +2 -3
  91. package/lib/typescript/index.d.ts.map +1 -1
  92. package/lib/typescript/utils/AssetUtil.d.ts +3 -3
  93. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  94. package/lib/typescript/utils/ConstantsUtil.d.ts +1 -1
  95. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  96. package/lib/typescript/utils/CoreHelperUtil.d.ts +2 -2
  97. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  98. package/lib/typescript/utils/EventUtil.d.ts +1 -1
  99. package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
  100. package/lib/typescript/utils/FetchUtil.d.ts +1 -1
  101. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  102. package/lib/typescript/utils/StorageUtil.d.ts +1 -8
  103. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  104. package/lib/typescript/utils/SwapApiUtil.d.ts +2 -3
  105. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  106. package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
  107. package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
  108. package/lib/typescript/utils/WalletUtil.d.ts +5 -0
  109. package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
  110. package/package.json +2 -2
  111. package/src/controllers/ApiController.ts +119 -74
  112. package/src/controllers/AssetController.ts +0 -6
  113. package/src/controllers/BlockchainApiController.ts +6 -6
  114. package/src/controllers/ConnectionsController.ts +47 -39
  115. package/src/controllers/EnsController.ts +1 -1
  116. package/src/controllers/EventsController.ts +1 -1
  117. package/src/controllers/ModalController.ts +5 -1
  118. package/src/controllers/OnRampController.ts +6 -2
  119. package/src/controllers/OptionsController.ts +17 -8
  120. package/src/controllers/RouterController.ts +14 -9
  121. package/src/controllers/SwapController.ts +3 -2
  122. package/src/controllers/WcController.ts +93 -0
  123. package/src/index.ts +3 -7
  124. package/src/utils/AssetUtil.ts +11 -8
  125. package/src/utils/ConstantsUtil.ts +2 -7
  126. package/src/utils/CoreHelperUtil.ts +13 -2
  127. package/src/utils/EventUtil.ts +1 -1
  128. package/src/utils/FetchUtil.ts +1 -1
  129. package/src/utils/StorageUtil.ts +6 -76
  130. package/src/utils/SwapApiUtil.ts +6 -2
  131. package/src/utils/SwapCalculationUtil.ts +1 -2
  132. package/src/utils/WalletUtil.ts +14 -0
  133. package/lib/commonjs/controllers/ConnectionController.js +0 -123
  134. package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
  135. package/lib/commonjs/utils/RouterUtil.js +0 -25
  136. package/lib/commonjs/utils/RouterUtil.js.map +0 -1
  137. package/lib/commonjs/utils/TypeUtil.js +0 -31
  138. package/lib/commonjs/utils/TypeUtil.js.map +0 -1
  139. package/lib/module/controllers/ConnectionController.js +0 -120
  140. package/lib/module/controllers/ConnectionController.js.map +0 -1
  141. package/lib/module/utils/RouterUtil.js +0 -21
  142. package/lib/module/utils/RouterUtil.js.map +0 -1
  143. package/lib/module/utils/TypeUtil.js +0 -26
  144. package/lib/module/utils/TypeUtil.js.map +0 -1
  145. package/lib/typescript/controllers/ConnectionController.d.ts +0 -55
  146. package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
  147. package/lib/typescript/utils/RouterUtil.d.ts +0 -5
  148. package/lib/typescript/utils/RouterUtil.d.ts.map +0 -1
  149. package/lib/typescript/utils/TypeUtil.d.ts +0 -705
  150. package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
  151. package/src/controllers/ConnectionController.ts +0 -185
  152. package/src/utils/RouterUtil.ts +0 -21
  153. package/src/utils/TypeUtil.ts +0 -899
@@ -18,7 +18,6 @@ import {
18
18
  import { StorageUtil } from '../utils/StorageUtil';
19
19
  import { BlockchainApiController } from './BlockchainApiController';
20
20
  import { SnackController } from './SnackController';
21
- import { OptionsController } from './OptionsController';
22
21
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
23
22
 
24
23
  // -- Types --------------------------------------------- //
@@ -81,11 +80,13 @@ const updateConnection = (
81
80
  namespace: ChainNamespace,
82
81
  connection: Connection,
83
82
  updates: Partial<Connection>
84
- ) => {
85
- if (!connection) return;
83
+ ): Connection => {
86
84
  const newConnectionsMap = new Map(baseState.connections);
87
- newConnectionsMap.set(namespace, { ...connection, ...updates });
85
+ const newConnection = { ...connection, ...updates };
86
+ newConnectionsMap.set(namespace, newConnection);
88
87
  baseState.connections = newConnectionsMap;
88
+
89
+ return newConnection;
89
90
  };
90
91
 
91
92
  const getActiveIdentity = (connection: Connection): Identity | undefined => {
@@ -132,27 +133,6 @@ const derivedState = derive(
132
133
  return undefined;
133
134
  }
134
135
 
135
- // Check if there's a specific token configured in OptionsController
136
- const configuredTokens = OptionsController.state.tokens;
137
- const activeNetwork = snap.networks.find(
138
- network =>
139
- network.chainNamespace === snap.activeNamespace &&
140
- network.id?.toString() === connection.caipNetwork?.split(':')[1]
141
- );
142
-
143
- if (configuredTokens && activeNetwork) {
144
- const configuredToken = configuredTokens[activeNetwork.caipNetworkId];
145
- if (configuredToken) {
146
- // Find the configured token in the balances
147
- const specificToken = addressBalances.find(
148
- balance => balance.address === configuredToken.address
149
- );
150
- if (specificToken) {
151
- return specificToken;
152
- }
153
- }
154
- }
155
-
156
136
  // Return the native token (first balance without address)
157
137
  const nativeToken = addressBalances.find(balance => !balance.address);
158
138
  if (nativeToken) {
@@ -228,6 +208,10 @@ export const ConnectionsController = {
228
208
  state: derivedState,
229
209
 
230
210
  setActiveNamespace(namespace?: ChainNamespace) {
211
+ if (baseState.activeNamespace === namespace) {
212
+ return;
213
+ }
214
+
231
215
  baseState.activeNamespace = namespace;
232
216
  StorageUtil.setActiveNamespace(namespace);
233
217
  },
@@ -269,16 +253,19 @@ export const ConnectionsController = {
269
253
  baseState.connections = newConnectionsMap;
270
254
  },
271
255
 
272
- updateAccounts(namespace: ChainNamespace, accounts: CaipAddress[]) {
256
+ updateAccounts(namespace: ChainNamespace, accounts: CaipAddress[]): boolean {
273
257
  const connection = baseState.connections.get(namespace);
274
258
  if (!connection) {
275
- return;
259
+ return false;
276
260
  }
277
261
 
278
- const newConnectionsMap = new Map(baseState.connections);
279
- const updatedConnection = { ...connection, accounts };
280
- newConnectionsMap.set(namespace, updatedConnection);
281
- baseState.connections = newConnectionsMap;
262
+ if (connection.accounts.toString() === accounts.toString()) {
263
+ return false;
264
+ }
265
+
266
+ updateConnection(namespace, connection, { accounts });
267
+
268
+ return true;
282
269
  },
283
270
 
284
271
  updateBalance(namespace: ChainNamespace, address: CaipAddress, balance: Balance) {
@@ -349,10 +336,9 @@ export const ConnectionsController = {
349
336
  return;
350
337
  }
351
338
 
352
- baseState.connections.set(namespace, {
353
- ...connection,
354
- caipNetwork: networkId
355
- });
339
+ updateConnection(namespace, connection, { caipNetwork: networkId });
340
+
341
+ this.setActiveNamespace(namespace);
356
342
  },
357
343
 
358
344
  setNetworks(networks: AppKitNetwork[]) {
@@ -360,6 +346,11 @@ export const ConnectionsController = {
360
346
  },
361
347
 
362
348
  getConnectedNetworks() {
349
+ const connection = getActiveConnection(baseState);
350
+ if (!connection) {
351
+ return [];
352
+ }
353
+
363
354
  return baseState.networks.filter(
364
355
  network =>
365
356
  baseState.connections
@@ -368,14 +359,31 @@ export const ConnectionsController = {
368
359
  );
369
360
  },
370
361
 
362
+ getAvailableNetworks() {
363
+ const connection = getActiveConnection(baseState);
364
+
365
+ if (!connection) {
366
+ return baseState.networks;
367
+ }
368
+
369
+ const canAddEvmChain = connection.properties?.canAddEvmChain;
370
+
371
+ return baseState.networks.filter(
372
+ network =>
373
+ baseState.connections
374
+ .get(network.chainNamespace)
375
+ ?.accounts.some(account => account.startsWith(network.caipNetworkId)) ||
376
+ (canAddEvmChain && network.chainNamespace === 'eip155')
377
+ );
378
+ },
379
+
371
380
  setAccountType(namespace: ChainNamespace, type: AccountType) {
372
381
  const connection = baseState.connections.get(namespace);
373
382
  if (!connection) return;
374
383
 
375
- const newConnectionsMap = new Map(baseState.connections);
376
- const newConnection = { ...connection, type };
377
- newConnectionsMap.set(namespace, newConnection);
378
- baseState.connections = newConnectionsMap;
384
+ const newConnection = updateConnection(namespace, connection, { type });
385
+
386
+ return getActiveAddress(newConnection);
379
387
  },
380
388
 
381
389
  async disconnect(namespace: ChainNamespace, isInternal = true) {
@@ -1,7 +1,7 @@
1
1
  import { subscribeKey as subKey } from 'valtio/utils';
2
2
  import { proxy, subscribe as sub } from 'valtio';
3
3
  import { BlockchainApiController } from './BlockchainApiController';
4
- import type { BlockchainApiEnsError } from '../utils/TypeUtil';
4
+ import type { BlockchainApiEnsError } from '@reown/appkit-common-react-native';
5
5
 
6
6
  // -- Types --------------------------------------------- //
7
7
 
@@ -3,7 +3,7 @@ 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 { Event, EventName } from '@reown/appkit-common-react-native';
7
7
 
8
8
  // -- Helpers ------------------------------------------- //
9
9
  const baseUrl = CoreHelperUtil.getAnalyticsUrl();
@@ -30,10 +30,14 @@ export const ModalController = {
30
30
  async open(options?: ModalControllerArguments['open']) {
31
31
  await ApiController.state.prefetchPromise;
32
32
  const isConnected = ConnectionsController.state.isConnected;
33
+ const isUniversalWallet = !!ConnectionsController.state.connection?.properties?.provider;
33
34
  if (options?.view) {
35
+ if (options.view === 'Account' && !isUniversalWallet) {
36
+ options.view = 'AccountDefault';
37
+ }
38
+
34
39
  RouterController.reset(options.view);
35
40
  } else if (isConnected) {
36
- const isUniversalWallet = !!ConnectionsController.state.connection?.properties?.provider;
37
41
  RouterController.reset(isUniversalWallet ? 'Account' : 'AccountDefault');
38
42
  } else {
39
43
  RouterController.reset('Connect');
@@ -12,7 +12,7 @@ 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
18
  import { OptionsController } from './OptionsController';
@@ -124,7 +124,11 @@ export const OnRampController = {
124
124
  state.countriesDefaults?.find(d => d.countryCode === country.countryCode)
125
125
  ?.defaultCurrencyCode || 'USD';
126
126
 
127
- const currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
127
+ let currency = state.paymentCurrencies?.find(c => c.currencyCode === currencyCode);
128
+
129
+ if (!currency) {
130
+ currency = state.paymentCurrencies?.find(c => c.currencyCode === 'USD');
131
+ }
128
132
 
129
133
  if (currency) {
130
134
  this.setPaymentCurrency(currency);
@@ -1,6 +1,14 @@
1
1
  import { proxy, ref } from 'valtio';
2
- import type { Tokens, Storage, Metadata, AppKitNetwork } from '@reown/appkit-common-react-native';
3
- import type { CustomWallet, Features, ProjectId, SdkType, SdkVersion } from '../utils/TypeUtil';
2
+ import type {
3
+ Storage,
4
+ Metadata,
5
+ AppKitNetwork,
6
+ CustomWallet,
7
+ Features,
8
+ ProjectId,
9
+ SdkType,
10
+ SdkVersion
11
+ } from '@reown/appkit-common-react-native';
4
12
 
5
13
  import { ConstantsUtil } from '../utils/ConstantsUtil';
6
14
 
@@ -17,7 +25,6 @@ export interface OptionsControllerState {
17
25
  excludeWalletIds?: string[];
18
26
  featuredWalletIds?: string[];
19
27
  customWallets?: CustomWallet[];
20
- tokens?: Tokens;
21
28
  enableAnalytics?: boolean;
22
29
  sdkType: SdkType;
23
30
  sdkVersion: SdkVersion;
@@ -27,14 +34,16 @@ export interface OptionsControllerState {
27
34
  features?: Features;
28
35
  debug?: boolean;
29
36
  defaultNetwork?: AppKitNetwork;
37
+ requestedNetworks?: AppKitNetwork[];
30
38
  }
31
39
 
32
40
  // -- State --------------------------------------------- //
33
41
  const state = proxy<OptionsControllerState>({
34
42
  projectId: '',
35
43
  sdkType: 'appkit',
36
- sdkVersion: 'react-native-wagmi-undefined',
44
+ sdkVersion: 'react-native-undefined-undefined',
37
45
  features: ConstantsUtil.DEFAULT_FEATURES,
46
+ customWallets: [],
38
47
  debug: false
39
48
  });
40
49
 
@@ -62,10 +71,6 @@ export const OptionsController = {
62
71
  state.featuredWalletIds = featuredWalletIds;
63
72
  },
64
73
 
65
- setTokens(tokens: OptionsControllerState['tokens']) {
66
- state.tokens = tokens;
67
- },
68
-
69
74
  setCustomWallets(customWallets: OptionsControllerState['customWallets']) {
70
75
  state.customWallets = customWallets;
71
76
  },
@@ -108,6 +113,10 @@ export const OptionsController = {
108
113
  state.defaultNetwork = defaultNetwork;
109
114
  },
110
115
 
116
+ setRequestedNetworks(requestedNetworks?: OptionsControllerState['requestedNetworks']) {
117
+ state.requestedNetworks = requestedNetworks;
118
+ },
119
+
111
120
  isClipboardAvailable() {
112
121
  return !!state.clipboardClient;
113
122
  },
@@ -1,7 +1,10 @@
1
1
  import { proxy } from 'valtio';
2
- import type { CaipNetwork, SocialProvider } from '@reown/appkit-common-react-native';
3
-
4
- import type { WcWallet, OnRampTransactionResult } from '../utils/TypeUtil';
2
+ import type {
3
+ AppKitNetwork,
4
+ SocialProvider,
5
+ WcWallet,
6
+ OnRampTransactionResult
7
+ } from '@reown/appkit-common-react-native';
5
8
 
6
9
  // -- Types --------------------------------------------- //
7
10
  export interface RouterControllerState {
@@ -17,12 +20,12 @@ export interface RouterControllerState {
17
20
  | 'ConnectingWalletConnect'
18
21
  | 'GetWallet'
19
22
  | 'Networks'
23
+ | 'SwitchNetwork'
20
24
  | 'OnRamp'
21
25
  | 'OnRampCheckout'
22
26
  | 'OnRampLoading'
23
27
  | 'OnRampSettings'
24
28
  | 'OnRampTransaction'
25
- | 'SwitchNetwork'
26
29
  | 'Swap'
27
30
  | 'SwapPreview'
28
31
  | 'Transactions'
@@ -39,9 +42,7 @@ export interface RouterControllerState {
39
42
  navigationDirection: 'forward' | 'backward' | 'none';
40
43
  data?: {
41
44
  wallet?: WcWallet;
42
- network?: CaipNetwork;
43
- email?: string;
44
- newEmail?: string;
45
+ network?: AppKitNetwork;
45
46
  onrampResult?: OnRampTransactionResult;
46
47
  socialProvider?: SocialProvider;
47
48
  };
@@ -58,9 +59,13 @@ const state = proxy<RouterControllerState>({
58
59
  export const RouterController = {
59
60
  state,
60
61
 
61
- push(view: RouterControllerState['view'], data?: RouterControllerState['data']) {
62
+ push(
63
+ view: RouterControllerState['view'],
64
+ data?: RouterControllerState['data'],
65
+ direction: 'forward' | 'backward' = 'forward'
66
+ ) {
62
67
  if (view !== state.view) {
63
- state.navigationDirection = 'forward';
68
+ state.navigationDirection = direction;
64
69
  state.view = view;
65
70
  state.history = [...state.history, view];
66
71
  state.data = data;
@@ -3,7 +3,9 @@ import { proxy, subscribe as sub } from 'valtio';
3
3
  import {
4
4
  NumberUtil,
5
5
  type CaipAddress,
6
- type CaipNetworkId
6
+ type CaipNetworkId,
7
+ type SwapInputTarget,
8
+ type SwapTokenWithBalance
7
9
  } from '@reown/appkit-common-react-native';
8
10
 
9
11
  import { ConstantsUtil } from '../utils/ConstantsUtil';
@@ -13,7 +15,6 @@ import { OptionsController } from './OptionsController';
13
15
  import { SwapCalculationUtil } from '../utils/SwapCalculationUtil';
14
16
  import { SnackController } from './SnackController';
15
17
  import { RouterController } from './RouterController';
16
- import type { SwapInputTarget, SwapTokenWithBalance } from '../utils/TypeUtil';
17
18
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
18
19
  import { TransactionsController } from './TransactionsController';
19
20
  import { EventsController } from './EventsController';
@@ -0,0 +1,93 @@
1
+ import { proxy } from 'valtio';
2
+ import { subscribeKey as subKey } from 'valtio/utils';
3
+ import type { WalletDeepLink, WcWallet } from '@reown/appkit-common-react-native';
4
+ import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
+ import { StorageUtil } from '../utils/StorageUtil';
6
+
7
+ // -- Types --------------------------------------------- //
8
+ export interface WcControllerState {
9
+ wcUri?: string;
10
+ wcPromise?: Promise<void>;
11
+ wcPairingExpiry?: number;
12
+ wcLinking?: WalletDeepLink;
13
+ wcError?: boolean;
14
+ pressedWallet?: WcWallet;
15
+ recentWallets?: WcWallet[];
16
+ }
17
+
18
+ type StateKey = keyof WcControllerState;
19
+
20
+ // -- State --------------------------------------------- //
21
+ const state = proxy<WcControllerState>({
22
+ wcError: false
23
+ });
24
+
25
+ // -- Controller ---------------------------------------- //
26
+ export const WcController = {
27
+ state,
28
+
29
+ subscribeKey<K extends StateKey>(key: K, callback: (value: WcControllerState[K]) => void) {
30
+ return subKey(state, key, callback);
31
+ },
32
+
33
+ setWcLinking(wcLinking: WcControllerState['wcLinking']) {
34
+ state.wcLinking = wcLinking;
35
+ },
36
+
37
+ removeWcLinking() {
38
+ state.wcLinking = undefined;
39
+ },
40
+
41
+ setWcError(wcError: WcControllerState['wcError']) {
42
+ state.wcError = wcError;
43
+ },
44
+
45
+ setPressedWallet(wallet: WcControllerState['pressedWallet']) {
46
+ state.pressedWallet = wallet;
47
+ },
48
+
49
+ removePressedWallet() {
50
+ state.pressedWallet = undefined;
51
+ },
52
+
53
+ setWcPromise(wcPromise: WcControllerState['wcPromise']) {
54
+ state.wcPromise = wcPromise;
55
+ },
56
+
57
+ setWcUri(wcUri: WcControllerState['wcUri']) {
58
+ state.wcUri = wcUri;
59
+ state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
60
+ },
61
+
62
+ setRecentWallets(wallets: WcControllerState['recentWallets']) {
63
+ state.recentWallets = wallets;
64
+ },
65
+
66
+ async addRecentWallet(wallet: WcWallet) {
67
+ const recentWallets = await StorageUtil.addRecentWallet(wallet);
68
+ if (recentWallets) {
69
+ WcController.setRecentWallets(recentWallets);
70
+ }
71
+ },
72
+
73
+ setConnectedWallet: async (wcLinking: WalletDeepLink, pressedWallet?: WcWallet) => {
74
+ StorageUtil.setWalletConnectDeepLink(wcLinking);
75
+
76
+ if (pressedWallet) {
77
+ WcController.addRecentWallet(pressedWallet);
78
+ }
79
+ },
80
+
81
+ clearUri() {
82
+ state.wcUri = undefined;
83
+ state.wcPairingExpiry = undefined;
84
+ state.wcPromise = undefined;
85
+ state.wcLinking = undefined;
86
+ },
87
+
88
+ resetState() {
89
+ this.clearUri();
90
+ state.pressedWallet = undefined;
91
+ StorageUtil.removeWalletConnectDeepLink();
92
+ }
93
+ };
package/src/index.ts CHANGED
@@ -7,11 +7,7 @@ export {
7
7
 
8
8
  export { RouterController, type RouterControllerState } from './controllers/RouterController';
9
9
 
10
- export {
11
- ConnectionController,
12
- type ConnectionControllerClient,
13
- type ConnectionControllerState
14
- } from './controllers/ConnectionController';
10
+ export { WcController, type WcControllerState } from './controllers/WcController';
15
11
 
16
12
  export {
17
13
  ConnectionsController,
@@ -57,6 +53,6 @@ export { ConstantsUtil } from './utils/ConstantsUtil';
57
53
  export { CoreHelperUtil } from './utils/CoreHelperUtil';
58
54
  export { StorageUtil } from './utils/StorageUtil';
59
55
  export { EventUtil } from './utils/EventUtil';
60
- export { RouterUtil } from './utils/RouterUtil';
56
+ export { WalletUtil } from './utils/WalletUtil';
61
57
 
62
- export type * from './utils/TypeUtil';
58
+ // Types are now exported from @reown/appkit-common-react-native
@@ -1,24 +1,27 @@
1
- import { AssetController } from '../controllers/AssetController';
2
- import type { WcWallet } from './TypeUtil';
1
+ import type { AppKitNetwork, WcWallet } from '@reown/appkit-common-react-native';
3
2
 
4
3
  export const AssetUtil = {
5
- getWalletImage(wallet?: WcWallet) {
4
+ getWalletImage(wallet?: WcWallet, walletImages?: Record<string, string>) {
6
5
  if (wallet?.image_url) {
7
6
  return wallet?.image_url;
8
7
  }
9
8
 
10
9
  if (wallet?.image_id) {
11
- return AssetController.state.walletImages[wallet.image_id];
10
+ return walletImages?.[wallet.image_id];
12
11
  }
13
12
 
14
13
  return undefined;
15
14
  },
16
15
 
17
- getConnectorImage(imageId?: string) {
18
- if (imageId) {
19
- return AssetController.state.connectorImages[imageId];
16
+ getNetworkImage(network?: AppKitNetwork, networkImages?: Record<string, string>) {
17
+ if (!network) {
18
+ return undefined;
20
19
  }
21
20
 
22
- return undefined;
21
+ if (network?.imageUrl) {
22
+ return network.imageUrl;
23
+ }
24
+
25
+ return networkImages?.[network?.id];
23
26
  }
24
27
  };
@@ -1,5 +1,4 @@
1
- import type { ChainNamespace } from '@reown/appkit-common-react-native';
2
- import type { Features } from './TypeUtil';
1
+ import type { ChainNamespace, Features } from '@reown/appkit-common-react-native';
3
2
 
4
3
  const defaultFeatures: Features = {
5
4
  swaps: true,
@@ -220,8 +219,6 @@ export const ConstantsUtil = {
220
219
  'eip155:1499',
221
220
  // Sonic
222
221
  'eip155:7007',
223
- // Swellchain
224
- 'eip155:7777777',
225
222
  // Taiko
226
223
  'eip155:167000',
227
224
  // Viction
@@ -239,9 +236,7 @@ export const ConstantsUtil = {
239
236
  // ZkLink Nova
240
237
  'eip155:810180',
241
238
  // re.al
242
- 'eip155:666',
243
- // Zora
244
- 'eip155:7777777'
239
+ 'eip155:666'
245
240
  ],
246
241
 
247
242
  SWAP_SUPPORTED_NETWORKS: [
@@ -10,13 +10,15 @@ import {
10
10
  type CaipNetwork,
11
11
  type ChainNamespace,
12
12
  type SocialProvider,
13
- type LinkingRecord
13
+ type LinkingRecord,
14
+ type DataWallet,
15
+ type SdkVersion
14
16
  } from '@reown/appkit-common-react-native';
15
17
 
16
18
  import * as ct from 'countries-and-timezones';
17
19
 
18
20
  import { ConstantsUtil } from './ConstantsUtil';
19
- import type { DataWallet, SdkVersion } from './TypeUtil';
21
+ import { OptionsController } from '../controllers/OptionsController';
20
22
 
21
23
  // -- Helpers -----------------------------------------------------------------
22
24
  async function isAppInstalledIos(deepLink?: string): Promise<boolean> {
@@ -344,5 +346,14 @@ export const CoreHelperUtil = {
344
346
  .join(',');
345
347
 
346
348
  return `react-native-${adapterNames}-${version}`;
349
+ },
350
+
351
+ getRequestedCaipNetworkIds() {
352
+ const chains = OptionsController.state.requestedNetworks;
353
+ if (!chains) return [];
354
+
355
+ const requestedIds = chains.map(caipNetwork => caipNetwork.caipNetworkId);
356
+
357
+ return requestedIds;
347
358
  }
348
359
  };
@@ -1,4 +1,4 @@
1
- import type { Platform, WcWallet } from './TypeUtil';
1
+ import type { Platform, WcWallet } from '@reown/appkit-common-react-native';
2
2
 
3
3
  export const EventUtil = {
4
4
  getWalletPlatform(wallet: WcWallet, installed?: boolean): Platform | undefined {
@@ -1,4 +1,4 @@
1
- import type { RequestCache } from './TypeUtil';
1
+ import type { RequestCache } from '@reown/appkit-common-react-native';
2
2
 
3
3
  // -- Types ----------------------------------------------------------------------
4
4
  interface Options {
@@ -1,15 +1,12 @@
1
1
  /* eslint-disable no-console */
2
- import type {
3
- OnRampCountry,
4
- OnRampFiatCurrency,
5
- OnRampFiatLimit,
6
- OnRampServiceProvider,
7
- OnRampCountryDefaults,
8
- WcWallet
9
- } from './TypeUtil';
10
2
  import {
3
+ type OnRampCountry,
4
+ type OnRampFiatCurrency,
5
+ type OnRampFiatLimit,
6
+ type OnRampServiceProvider,
7
+ type OnRampCountryDefaults,
8
+ type WcWallet,
11
9
  DateUtil,
12
- type SocialProvider,
13
10
  type ConnectorType,
14
11
  type ChainNamespace,
15
12
  type WalletDeepLink,
@@ -153,73 +150,6 @@ export const StorageUtil = {
153
150
  }
154
151
  },
155
152
 
156
- async setConnectedWalletImageUrl(url: string) {
157
- try {
158
- await OptionsController.getStorage().setItem(
159
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL,
160
- url
161
- );
162
- } catch {
163
- console.info('Unable to set Connected Wallet Image URL');
164
- }
165
- },
166
-
167
- async getConnectedWalletImageUrl() {
168
- try {
169
- return await OptionsController.getStorage().getItem(
170
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
171
- );
172
- } catch {
173
- console.info('Unable to get Connected Wallet Image URL');
174
- }
175
-
176
- return undefined;
177
- },
178
-
179
- async removeConnectedWalletImageUrl() {
180
- try {
181
- await OptionsController.getStorage().removeItem(
182
- ConstantsUtil.STORAGE_KEYS.CONNECTED_WALLET_IMAGE_URL
183
- );
184
- } catch (e) {
185
- console.error(e);
186
- console.info('Unable to remove Connected Wallet Image URL');
187
- }
188
- },
189
-
190
- async setConnectedSocialProvider(provider: SocialProvider) {
191
- try {
192
- await OptionsController.getStorage().setItem(
193
- ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL,
194
- provider
195
- );
196
- } catch {
197
- console.info('Unable to set Connected Social Provider');
198
- }
199
- },
200
-
201
- async getConnectedSocialProvider(): Promise<SocialProvider | undefined> {
202
- try {
203
- const provider = await OptionsController.getStorage().getItem<SocialProvider>(
204
- ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL
205
- );
206
-
207
- return provider ?? undefined;
208
- } catch {
209
- console.info('Unable to get Connected Social Provider');
210
- }
211
-
212
- return undefined;
213
- },
214
-
215
- async removeConnectedSocialProvider() {
216
- try {
217
- await OptionsController.getStorage().removeItem(ConstantsUtil.STORAGE_KEYS.CONNECTED_SOCIAL);
218
- } catch {
219
- console.info('Unable to remove Connected Social Provider');
220
- }
221
- },
222
-
223
153
  async setOnRampPreferredCountry(country: OnRampCountry) {
224
154
  try {
225
155
  await OptionsController.getStorage().setItem(
@@ -1,7 +1,11 @@
1
- import type { Balance, CaipNetworkId } from '@reown/appkit-common-react-native';
1
+ import type {
2
+ Balance,
3
+ CaipNetworkId,
4
+ BlockchainApiSwapAllowanceRequest,
5
+ SwapTokenWithBalance
6
+ } from '@reown/appkit-common-react-native';
2
7
  import { BlockchainApiController } from '../controllers/BlockchainApiController';
3
8
  import { OptionsController } from '../controllers/OptionsController';
4
- import type { BlockchainApiSwapAllowanceRequest, SwapTokenWithBalance } from './TypeUtil';
5
9
  import { ConnectionsController } from '../controllers/ConnectionsController';
6
10
  import { ConstantsUtil } from './ConstantsUtil';
7
11