@reown/appkit-core-react-native 0.0.0-chore-canary-20250722145858 → 0.0.0-chore-bump-builder-20250728194329

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 (209) hide show
  1. package/lib/commonjs/controllers/ApiController.js +27 -16
  2. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  3. package/lib/commonjs/controllers/BlockchainApiController.js +173 -103
  4. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/ConnectionController.js +8 -11
  6. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionsController.js +417 -0
  8. package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
  9. package/lib/commonjs/controllers/ModalController.js +6 -7
  10. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  11. package/lib/commonjs/controllers/OnRampController.js +58 -42
  12. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  13. package/lib/commonjs/controllers/OptionsController.js +17 -3
  14. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  15. package/lib/commonjs/controllers/RouterController.js +1 -22
  16. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  17. package/lib/commonjs/controllers/SendController.js +96 -96
  18. package/lib/commonjs/controllers/SendController.js.map +1 -1
  19. package/lib/commonjs/controllers/SnackController.js +29 -5
  20. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  21. package/lib/commonjs/controllers/SwapController.js +151 -150
  22. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  23. package/lib/commonjs/controllers/ThemeController.js +9 -1
  24. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  25. package/lib/commonjs/controllers/TransactionsController.js +22 -18
  26. package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
  27. package/lib/commonjs/index.js +3 -38
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/package.json +1 -0
  30. package/lib/commonjs/utils/AssetUtil.js +3 -15
  31. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  32. package/lib/commonjs/utils/ConstantsUtil.js +122 -5
  33. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  34. package/lib/commonjs/utils/CoreHelperUtil.js +11 -5
  35. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  36. package/lib/commonjs/utils/FetchUtil.js +7 -2
  37. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  38. package/lib/commonjs/utils/StorageUtil.js +99 -71
  39. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  40. package/lib/commonjs/utils/SwapApiUtil.js +15 -21
  41. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  42. package/lib/commonjs/utils/TypeUtil.js +25 -0
  43. package/lib/commonjs/utils/TypeUtil.js.map +1 -1
  44. package/lib/module/controllers/ApiController.js +28 -16
  45. package/lib/module/controllers/ApiController.js.map +1 -1
  46. package/lib/module/controllers/AssetController.js +2 -0
  47. package/lib/module/controllers/AssetController.js.map +1 -1
  48. package/lib/module/controllers/BlockchainApiController.js +174 -102
  49. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  50. package/lib/module/controllers/ConnectionController.js +10 -11
  51. package/lib/module/controllers/ConnectionController.js.map +1 -1
  52. package/lib/module/controllers/ConnectionsController.js +414 -0
  53. package/lib/module/controllers/ConnectionsController.js.map +1 -0
  54. package/lib/module/controllers/EnsController.js +2 -0
  55. package/lib/module/controllers/EnsController.js.map +1 -1
  56. package/lib/module/controllers/EventsController.js +2 -0
  57. package/lib/module/controllers/EventsController.js.map +1 -1
  58. package/lib/module/controllers/ModalController.js +8 -7
  59. package/lib/module/controllers/ModalController.js.map +1 -1
  60. package/lib/module/controllers/OnRampController.js +59 -41
  61. package/lib/module/controllers/OnRampController.js.map +1 -1
  62. package/lib/module/controllers/OptionsController.js +19 -3
  63. package/lib/module/controllers/OptionsController.js.map +1 -1
  64. package/lib/module/controllers/PublicStateController.js +2 -0
  65. package/lib/module/controllers/PublicStateController.js.map +1 -1
  66. package/lib/module/controllers/RouterController.js +3 -22
  67. package/lib/module/controllers/RouterController.js.map +1 -1
  68. package/lib/module/controllers/SendController.js +98 -96
  69. package/lib/module/controllers/SendController.js.map +1 -1
  70. package/lib/module/controllers/SnackController.js +31 -5
  71. package/lib/module/controllers/SnackController.js.map +1 -1
  72. package/lib/module/controllers/SwapController.js +153 -150
  73. package/lib/module/controllers/SwapController.js.map +1 -1
  74. package/lib/module/controllers/ThemeController.js +11 -1
  75. package/lib/module/controllers/ThemeController.js.map +1 -1
  76. package/lib/module/controllers/TransactionsController.js +24 -18
  77. package/lib/module/controllers/TransactionsController.js.map +1 -1
  78. package/lib/module/index.js +3 -6
  79. package/lib/module/index.js.map +1 -1
  80. package/lib/module/utils/ApiUtil.js +2 -0
  81. package/lib/module/utils/ApiUtil.js.map +1 -1
  82. package/lib/module/utils/AssetUtil.js +5 -15
  83. package/lib/module/utils/AssetUtil.js.map +1 -1
  84. package/lib/module/utils/ConstantsUtil.js +124 -5
  85. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  86. package/lib/module/utils/CoreHelperUtil.js +13 -5
  87. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  88. package/lib/module/utils/EventUtil.js +2 -0
  89. package/lib/module/utils/EventUtil.js.map +1 -1
  90. package/lib/module/utils/FetchUtil.js +9 -2
  91. package/lib/module/utils/FetchUtil.js.map +1 -1
  92. package/lib/module/utils/RouterUtil.js +2 -0
  93. package/lib/module/utils/RouterUtil.js.map +1 -1
  94. package/lib/module/utils/StorageUtil.js +103 -71
  95. package/lib/module/utils/StorageUtil.js.map +1 -1
  96. package/lib/module/utils/SwapApiUtil.js +17 -21
  97. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  98. package/lib/module/utils/SwapCalculationUtil.js +2 -0
  99. package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
  100. package/lib/module/utils/TypeUtil.js +25 -1
  101. package/lib/module/utils/TypeUtil.js.map +1 -1
  102. package/lib/typescript/controllers/ApiController.d.ts +3 -2
  103. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  104. package/lib/typescript/controllers/BlockchainApiController.d.ts +30 -11
  105. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  106. package/lib/typescript/controllers/ConnectionController.d.ts +5 -16
  107. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  108. package/lib/typescript/controllers/ConnectionsController.d.ts +45 -0
  109. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
  110. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  111. package/lib/typescript/controllers/OnRampController.d.ts +1 -2
  112. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  113. package/lib/typescript/controllers/OptionsController.d.ts +8 -2
  114. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  115. package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
  116. package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
  117. package/lib/typescript/controllers/RouterController.d.ts +4 -16
  118. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  119. package/lib/typescript/controllers/SendController.d.ts +5 -7
  120. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  121. package/lib/typescript/controllers/SnackController.d.ts +3 -3
  122. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  123. package/lib/typescript/controllers/SwapController.d.ts +12 -11
  124. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  125. package/lib/typescript/controllers/ThemeController.d.ts +1 -1
  126. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  127. package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
  128. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  129. package/lib/typescript/index.d.ts +1 -6
  130. package/lib/typescript/index.d.ts.map +1 -1
  131. package/lib/typescript/utils/AssetUtil.d.ts +2 -3
  132. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  133. package/lib/typescript/utils/ConstantsUtil.d.ts +11 -1
  134. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  135. package/lib/typescript/utils/CoreHelperUtil.d.ts +5 -4
  136. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  137. package/lib/typescript/utils/FetchUtil.d.ts +1 -1
  138. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  139. package/lib/typescript/utils/StorageUtil.d.ts +18 -12
  140. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  141. package/lib/typescript/utils/SwapApiUtil.d.ts +3 -3
  142. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  143. package/lib/typescript/utils/TypeUtil.d.ts +44 -184
  144. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  145. package/package.json +7 -7
  146. package/src/controllers/ApiController.ts +28 -10
  147. package/src/controllers/BlockchainApiController.ts +152 -89
  148. package/src/controllers/ConnectionController.ts +14 -29
  149. package/src/controllers/ConnectionsController.ts +543 -0
  150. package/src/controllers/ModalController.ts +6 -7
  151. package/src/controllers/OnRampController.ts +91 -59
  152. package/src/controllers/OptionsController.ts +27 -13
  153. package/src/controllers/PublicStateController.ts +1 -1
  154. package/src/controllers/RouterController.ts +5 -54
  155. package/src/controllers/SendController.ts +122 -111
  156. package/src/controllers/SnackController.ts +31 -5
  157. package/src/controllers/SwapController.ts +174 -181
  158. package/src/controllers/ThemeController.ts +11 -2
  159. package/src/controllers/TransactionsController.ts +25 -19
  160. package/src/index.ts +3 -14
  161. package/src/utils/AssetUtil.ts +4 -20
  162. package/src/utils/ConstantsUtil.ts +126 -5
  163. package/src/utils/CoreHelperUtil.ts +34 -7
  164. package/src/utils/FetchUtil.ts +9 -3
  165. package/src/utils/StorageUtil.ts +180 -78
  166. package/src/utils/SwapApiUtil.ts +27 -38
  167. package/src/utils/TypeUtil.ts +54 -182
  168. package/lib/commonjs/controllers/AccountController.js +0 -93
  169. package/lib/commonjs/controllers/AccountController.js.map +0 -1
  170. package/lib/commonjs/controllers/ConnectorController.js +0 -49
  171. package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
  172. package/lib/commonjs/controllers/NetworkController.js +0 -90
  173. package/lib/commonjs/controllers/NetworkController.js.map +0 -1
  174. package/lib/commonjs/controllers/WebviewController.js +0 -52
  175. package/lib/commonjs/controllers/WebviewController.js.map +0 -1
  176. package/lib/commonjs/utils/ConnectionUtil.js +0 -33
  177. package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
  178. package/lib/commonjs/utils/NetworkUtil.js +0 -46
  179. package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
  180. package/lib/module/controllers/AccountController.js +0 -88
  181. package/lib/module/controllers/AccountController.js.map +0 -1
  182. package/lib/module/controllers/ConnectorController.js +0 -44
  183. package/lib/module/controllers/ConnectorController.js.map +0 -1
  184. package/lib/module/controllers/NetworkController.js +0 -85
  185. package/lib/module/controllers/NetworkController.js.map +0 -1
  186. package/lib/module/controllers/WebviewController.js +0 -47
  187. package/lib/module/controllers/WebviewController.js.map +0 -1
  188. package/lib/module/utils/ConnectionUtil.js +0 -27
  189. package/lib/module/utils/ConnectionUtil.js.map +0 -1
  190. package/lib/module/utils/NetworkUtil.js +0 -40
  191. package/lib/module/utils/NetworkUtil.js.map +0 -1
  192. package/lib/typescript/controllers/AccountController.d.ts +0 -33
  193. package/lib/typescript/controllers/AccountController.d.ts.map +0 -1
  194. package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
  195. package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
  196. package/lib/typescript/controllers/NetworkController.d.ts +0 -34
  197. package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
  198. package/lib/typescript/controllers/WebviewController.d.ts +0 -21
  199. package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
  200. package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
  201. package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
  202. package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
  203. package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
  204. package/src/controllers/AccountController.ts +0 -128
  205. package/src/controllers/ConnectorController.ts +0 -63
  206. package/src/controllers/NetworkController.ts +0 -120
  207. package/src/controllers/WebviewController.ts +0 -63
  208. package/src/utils/ConnectionUtil.ts +0 -27
  209. package/src/utils/NetworkUtil.ts +0 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reown/appkit-core-react-native",
3
- "version": "0.0.0-chore-canary-20250722145858",
3
+ "version": "0.0.0-chore-bump-builder-20250728194329",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "types": "lib/typescript/index.d.ts",
6
6
  "module": "lib/module/index.js",
@@ -38,15 +38,15 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@reown/appkit-common-react-native": "0.0.0-chore-canary-20250722145858",
41
+ "@reown/appkit-common-react-native": "0.0.0-chore-bump-builder-20250728194329",
42
42
  "countries-and-timezones": "3.7.2",
43
- "valtio": "1.13.2"
43
+ "derive-valtio": "0.2.0",
44
+ "valtio": "2.1.5"
44
45
  },
45
46
  "peerDependencies": {
46
- "@react-native-async-storage/async-storage": ">=1.17.0",
47
- "@walletconnect/react-native-compat": ">=2.13.1",
48
- "react": ">=17",
49
- "react-native": ">=0.68.5"
47
+ "@walletconnect/react-native-compat": ">=2.16.1",
48
+ "react": ">=18",
49
+ "react-native": ">=0.72"
50
50
  },
51
51
  "react-native": "src/index.ts",
52
52
  "react-native-builder-bob": {
@@ -12,12 +12,13 @@ import type {
12
12
  WcWallet
13
13
  } from '../utils/TypeUtil';
14
14
  import { AssetController } from './AssetController';
15
- import { NetworkController } from './NetworkController';
16
15
  import { OptionsController } from './OptionsController';
17
- import { ConnectorController } from './ConnectorController';
16
+ // import { ConnectorController } from './ConnectorController';
18
17
  import { ConnectionController } from './ConnectionController';
19
18
  import { ApiUtil } from '../utils/ApiUtil';
20
19
  import { SnackController } from './SnackController';
20
+ import { ConnectionsController } from './ConnectionsController';
21
+ import { ConstantsUtil, PresetsUtil } from '@reown/appkit-common-react-native';
21
22
 
22
23
  // -- Helpers ------------------------------------------- //
23
24
  const baseUrl = CoreHelperUtil.getApiUrl();
@@ -92,16 +93,21 @@ export const ApiController = {
92
93
  }
93
94
  },
94
95
 
95
- async _fetchNetworkImage(imageId: string) {
96
+ async _fetchNetworkImage(networkId: string) {
97
+ const imageId = PresetsUtil.NetworkImageIds[networkId];
98
+ if (!imageId) {
99
+ return;
100
+ }
101
+
96
102
  const headers = ApiController._getApiHeaders();
97
103
  const url = await api.fetchImage(`/public/getAssetImage/${imageId}`, headers);
98
104
  if (url) {
99
- AssetController.setNetworkImage(imageId, url);
105
+ AssetController.setNetworkImage(networkId, url);
100
106
  }
101
107
  },
102
108
 
103
109
  async fetchConnectorImages() {
104
- const { connectors } = ConnectorController.state;
110
+ const connectors = [{ imageId: ConstantsUtil.WALLET_CONNECT_IMAGE_ID }];
105
111
  const ids = connectors.map(({ imageId }) => imageId).filter(Boolean);
106
112
  await CoreHelperUtil.allSettled(
107
113
  (ids as string[]).map(id => ApiController._fetchConnectorImage(id))
@@ -109,11 +115,10 @@ export const ApiController = {
109
115
  },
110
116
 
111
117
  async fetchNetworkImages() {
112
- const { requestedCaipNetworks } = NetworkController.state;
113
- const ids = requestedCaipNetworks?.map(({ imageId }) => imageId).filter(Boolean);
114
- if (ids) {
118
+ const networks = ConnectionsController.state.networks;
119
+ if (networks) {
115
120
  await CoreHelperUtil.allSettled(
116
- (ids as string[]).map(id => ApiController._fetchNetworkImage(id))
121
+ networks.map(network => ApiController._fetchNetworkImage(network.id as string))
117
122
  );
118
123
  }
119
124
  },
@@ -201,6 +206,18 @@ export const ApiController = {
201
206
  }
202
207
  },
203
208
 
209
+ async fetchCustomWalletImages() {
210
+ const { customWallets } = OptionsController.state;
211
+ if (!customWallets?.length) {
212
+ return;
213
+ }
214
+
215
+ const images = customWallets.map(w => w.image_id).filter(Boolean);
216
+ await CoreHelperUtil.allSettled(
217
+ (images as string[]).map(id => ApiController._fetchWalletImage(id))
218
+ );
219
+ },
220
+
204
221
  async fetchRecommendedWallets() {
205
222
  const { installed } = ApiController.state;
206
223
  const { includeWalletIds, excludeWalletIds, featuredWalletIds } = OptionsController.state;
@@ -339,7 +356,8 @@ export const ApiController = {
339
356
  ApiController.fetchFeaturedWallets(),
340
357
  ApiController.fetchRecommendedWallets(),
341
358
  ApiController.fetchNetworkImages(),
342
- ApiController.fetchConnectorImages()
359
+ ApiController.fetchConnectorImages(),
360
+ ApiController.fetchCustomWalletImages()
343
361
  ];
344
362
  if (OptionsController.state.enableAnalytics === undefined) {
345
363
  promises.push(ApiController.fetchAnalyticsConfig());
@@ -38,6 +38,9 @@ import type {
38
38
  import { OptionsController } from './OptionsController';
39
39
  import { ConstantsUtil } from '../utils/ConstantsUtil';
40
40
  import { ApiUtil } from '../utils/ApiUtil';
41
+ import type { CaipAddress, CaipNetworkId } from '@reown/appkit-common-react-native';
42
+
43
+ import { SnackController } from './SnackController';
41
44
 
42
45
  // -- Helpers ------------------------------------------- //
43
46
  const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
@@ -54,23 +57,56 @@ const getHeaders = () => {
54
57
  };
55
58
  };
56
59
 
60
+ export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
61
+
57
62
  // -- Types --------------------------------------------- //
63
+ type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
64
+
58
65
  export interface BlockchainApiControllerState {
59
66
  clientId: string | null;
60
67
  api: FetchUtil;
68
+ supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
61
69
  }
62
70
 
63
71
  // -- State --------------------------------------------- //
64
72
  const state = proxy<BlockchainApiControllerState>({
65
73
  clientId: null,
66
- api: new FetchUtil({ baseUrl })
74
+ api: new FetchUtil({ baseUrl }),
75
+ supportedChains: { http: [], ws: [] }
67
76
  });
68
77
 
69
78
  // -- Controller ---------------------------------------- //
70
79
  export const BlockchainApiController = {
71
80
  state,
72
81
 
73
- fetchIdentity({ address }: BlockchainApiIdentityRequest) {
82
+ async isNetworkSupported(networkId?: CaipNetworkId) {
83
+ if (!networkId) {
84
+ return false;
85
+ }
86
+ try {
87
+ if (!state.supportedChains.http.length) {
88
+ await BlockchainApiController.getSupportedNetworks();
89
+ }
90
+ } catch (e) {
91
+ return false;
92
+ }
93
+
94
+ return state.supportedChains.http.includes(networkId);
95
+ },
96
+
97
+ async getSupportedNetworks() {
98
+ const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
99
+ path: 'v1/supported-chains'
100
+ });
101
+
102
+ state.supportedChains = supportedChains!;
103
+
104
+ return supportedChains;
105
+ },
106
+
107
+ async fetchIdentity(params: BlockchainApiIdentityRequest) {
108
+ const { address } = params;
109
+
74
110
  return state.api.get<BlockchainApiIdentityResponse>({
75
111
  path: `/v1/identity/${address}`,
76
112
  params: {
@@ -80,29 +116,39 @@ export const BlockchainApiController = {
80
116
  });
81
117
  },
82
118
 
83
- fetchTransactions({
84
- account,
85
- projectId,
86
- cursor,
87
- onramp,
88
- signal,
89
- cache
90
- }: BlockchainApiTransactionsRequest) {
91
- return state.api.get<BlockchainApiTransactionsResponse>({
119
+ async fetchTransactions(params: BlockchainApiTransactionsRequest) {
120
+ const { account, projectId, cursor, onramp, signal, cache, chainId } = params;
121
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
122
+
123
+ if (!isSupported) {
124
+ return { data: [], next: undefined };
125
+ }
126
+
127
+ const response = await state.api.get<BlockchainApiTransactionsResponse>({
92
128
  path: `/v1/account/${account}/history`,
93
129
  headers: getHeaders(),
94
130
  params: {
95
131
  projectId,
96
132
  cursor,
97
- onramp
133
+ onramp,
134
+ chainId
98
135
  },
99
136
  signal,
100
137
  cache
101
138
  });
139
+
140
+ return response;
102
141
  },
103
142
 
104
- fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest) {
105
- return state.api.post<BlockchainApiTokenPriceResponse>({
143
+ async fetchTokenPrice(params: BlockchainApiTokenPriceRequest & WithCaipNetworkId) {
144
+ const { projectId, addresses, caipNetworkId } = params;
145
+ const isSupported = await BlockchainApiController.isNetworkSupported(caipNetworkId);
146
+
147
+ if (!isSupported) {
148
+ return { fungibles: [] };
149
+ }
150
+
151
+ const response = await state.api.post<BlockchainApiTokenPriceResponse>({
106
152
  path: '/v1/fungible/price',
107
153
  body: {
108
154
  projectId,
@@ -111,9 +157,20 @@ export const BlockchainApiController = {
111
157
  },
112
158
  headers: getHeaders()
113
159
  });
160
+
161
+ return response;
114
162
  },
115
163
 
116
- fetchSwapAllowance({ projectId, tokenAddress, userAddress }: BlockchainApiSwapAllowanceRequest) {
164
+ async fetchSwapAllowance(params: BlockchainApiSwapAllowanceRequest) {
165
+ const { projectId, tokenAddress, userAddress } = params;
166
+ const [namespace, chain] = userAddress.split(':');
167
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
168
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
169
+
170
+ if (!isSupported) {
171
+ return { allowance: '0' };
172
+ }
173
+
117
174
  return state.api.get<BlockchainApiSwapAllowanceResponse>({
118
175
  path: `/v1/convert/allowance`,
119
176
  params: {
@@ -125,7 +182,14 @@ export const BlockchainApiController = {
125
182
  });
126
183
  },
127
184
 
128
- fetchGasPrice({ projectId, chainId }: BlockchainApiGasPriceRequest) {
185
+ async fetchGasPrice(params: BlockchainApiGasPriceRequest) {
186
+ const { projectId, chainId } = params;
187
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
188
+
189
+ if (!isSupported) {
190
+ throw new Error('Network not supported for Gas Price');
191
+ }
192
+
129
193
  return state.api.get<BlockchainApiGasPriceResponse>({
130
194
  path: `/v1/convert/gas-price`,
131
195
  headers: getHeaders(),
@@ -136,14 +200,16 @@ export const BlockchainApiController = {
136
200
  });
137
201
  },
138
202
 
139
- fetchSwapQuote({
140
- projectId,
141
- amount,
142
- userAddress,
143
- from,
144
- to,
145
- gasPrice
146
- }: BlockchainApiSwapQuoteRequest) {
203
+ async fetchSwapQuote(params: BlockchainApiSwapQuoteRequest) {
204
+ const { projectId, amount, userAddress, from, to, gasPrice } = params;
205
+ const [namespace, chain] = userAddress.split(':');
206
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
207
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
208
+
209
+ if (!isSupported) {
210
+ return { quotes: [] };
211
+ }
212
+
147
213
  return state.api.get<BlockchainApiSwapQuoteResponse>({
148
214
  path: `/v1/convert/quotes`,
149
215
  headers: getHeaders(),
@@ -158,7 +224,14 @@ export const BlockchainApiController = {
158
224
  });
159
225
  },
160
226
 
161
- fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
227
+ async fetchSwapTokens(params: BlockchainApiSwapTokensRequest) {
228
+ const { projectId, chainId } = params;
229
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
230
+
231
+ if (!isSupported) {
232
+ return { tokens: [] };
233
+ }
234
+
162
235
  return state.api.get<BlockchainApiSwapTokensResponse>({
163
236
  path: `/v1/convert/tokens`,
164
237
  headers: getHeaders(),
@@ -169,13 +242,16 @@ export const BlockchainApiController = {
169
242
  });
170
243
  },
171
244
 
172
- generateSwapCalldata({
173
- amount,
174
- from,
175
- projectId,
176
- to,
177
- userAddress
178
- }: BlockchainApiGenerateSwapCalldataRequest) {
245
+ async generateSwapCalldata(params: BlockchainApiGenerateSwapCalldataRequest) {
246
+ const { amount, from, projectId, to, userAddress } = params;
247
+ const [namespace, chain] = userAddress.split(':');
248
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
249
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
250
+
251
+ if (!isSupported) {
252
+ throw new Error('Network not supported for Swaps');
253
+ }
254
+
179
255
  return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
180
256
  path: '/v1/convert/build-transaction',
181
257
  headers: getHeaders(),
@@ -192,12 +268,16 @@ export const BlockchainApiController = {
192
268
  });
193
269
  },
194
270
 
195
- generateApproveCalldata({
196
- from,
197
- projectId,
198
- to,
199
- userAddress
200
- }: BlockchainApiGenerateApproveCalldataRequest) {
271
+ async generateApproveCalldata(params: BlockchainApiGenerateApproveCalldataRequest) {
272
+ const { from, projectId, to, userAddress } = params;
273
+ const [namespace, chain] = userAddress.split(':');
274
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
275
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
276
+
277
+ if (!isSupported) {
278
+ throw new Error('Network not supported for Swaps');
279
+ }
280
+
201
281
  return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
202
282
  path: `/v1/convert/build-approve`,
203
283
  headers: getHeaders(),
@@ -210,15 +290,29 @@ export const BlockchainApiController = {
210
290
  });
211
291
  },
212
292
 
213
- async getBalance(address: string, chainId?: string, forceUpdate?: string) {
293
+ async getBalance(address?: CaipAddress, forceUpdate?: CaipAddress[]) {
294
+ const [namespace, chain, plainAddress] = address?.split(':') ?? [];
295
+
296
+ if (!namespace || !chain || !plainAddress) {
297
+ throw new Error('Invalid address');
298
+ }
299
+
300
+ const isSupported = await BlockchainApiController.isNetworkSupported(`${namespace}:${chain}`);
301
+
302
+ if (!isSupported) {
303
+ SnackController.showError('Token Balance Unavailable');
304
+
305
+ return { balances: [] };
306
+ }
307
+
214
308
  return state.api.get<BlockchainApiBalanceResponse>({
215
- path: `/v1/account/${address}/balance`,
309
+ path: `/v1/account/${plainAddress}/balance`,
216
310
  headers: getHeaders(),
217
311
  params: {
218
312
  currency: 'usd',
219
313
  projectId: OptionsController.state.projectId,
220
- chainId,
221
- forceUpdate
314
+ chainId: `${namespace}:${chain}`,
315
+ forceUpdate: forceUpdate?.join(',')
222
316
  }
223
317
  });
224
318
  },
@@ -234,17 +328,6 @@ export const BlockchainApiController = {
234
328
  });
235
329
  },
236
330
 
237
- async fetchOnRampCountries() {
238
- return await state.api.get<OnRampCountry[]>({
239
- path: '/v1/onramp/providers/properties',
240
- headers: getHeaders(),
241
- params: {
242
- projectId: OptionsController.state.projectId,
243
- type: 'countries'
244
- }
245
- });
246
- },
247
-
248
331
  async fetchOnRampServiceProviders() {
249
332
  return await state.api.get<OnRampServiceProvider[]>({
250
333
  path: '/v1/onramp/providers',
@@ -255,59 +338,39 @@ export const BlockchainApiController = {
255
338
  });
256
339
  },
257
340
 
341
+ async fetchOnRampCountries() {
342
+ return await this.fetchProperties<OnRampCountry[]>('countries');
343
+ },
344
+
258
345
  async fetchOnRampPaymentMethods(params: { countries?: string }) {
259
- return await state.api.get<OnRampPaymentMethod[]>({
260
- path: '/v1/onramp/providers/properties',
261
- headers: getHeaders(),
262
- params: {
263
- projectId: OptionsController.state.projectId,
264
- type: 'payment-methods',
265
- ...params
266
- }
267
- });
346
+ return await this.fetchProperties<OnRampPaymentMethod[]>('payment-methods', params);
268
347
  },
269
348
 
270
349
  async fetchOnRampCryptoCurrencies(params: { countries?: string }) {
271
- return await state.api.get<OnRampCryptoCurrency[]>({
272
- path: '/v1/onramp/providers/properties',
273
- headers: getHeaders(),
274
- params: {
275
- projectId: OptionsController.state.projectId,
276
- type: 'crypto-currencies',
277
- ...params
278
- }
279
- });
350
+ return await this.fetchProperties<OnRampCryptoCurrency[]>('crypto-currencies', params);
280
351
  },
281
352
 
282
353
  async fetchOnRampFiatCurrencies() {
283
- return await state.api.get<OnRampFiatCurrency[]>({
284
- path: '/v1/onramp/providers/properties',
285
- headers: getHeaders(),
286
- params: {
287
- projectId: OptionsController.state.projectId,
288
- type: 'fiat-currencies'
289
- }
290
- });
354
+ return await this.fetchProperties<OnRampFiatCurrency[]>('fiat-currencies');
291
355
  },
292
356
 
293
357
  async fetchOnRampFiatLimits() {
294
- return await state.api.get<OnRampFiatLimit[]>({
295
- path: '/v1/onramp/providers/properties',
296
- headers: getHeaders(),
297
- params: {
298
- projectId: OptionsController.state.projectId,
299
- type: 'fiat-purchases-limits'
300
- }
301
- });
358
+ return await this.fetchProperties<OnRampFiatLimit[]>('fiat-purchases-limits');
302
359
  },
303
360
 
304
361
  async fetchOnRampCountriesDefaults() {
305
- return await state.api.get<OnRampCountryDefaults[]>({
362
+ return await this.fetchProperties<OnRampCountryDefaults[]>('countries-defaults');
363
+ },
364
+
365
+ async fetchProperties<T>(type: string, params?: Record<string, string>) {
366
+ return await state.api.get<T>({
306
367
  path: '/v1/onramp/providers/properties',
307
368
  headers: getHeaders(),
308
369
  params: {
309
370
  projectId: OptionsController.state.projectId,
310
- type: 'countries-defaults'
371
+ type,
372
+ excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
373
+ ...params
311
374
  }
312
375
  });
313
376
  },
@@ -1,31 +1,22 @@
1
1
  import { proxy, ref } from 'valtio';
2
2
  import { subscribeKey as subKey } from 'valtio/utils';
3
- import type { SocialProvider } from '@reown/appkit-common-react-native';
3
+ import type { SocialProvider, WalletDeepLink } from '@reown/appkit-common-react-native';
4
4
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
5
5
  import { StorageUtil } from '../utils/StorageUtil';
6
6
  import type {
7
- Connector,
8
7
  EstimateGasTransactionArgs,
9
8
  SendTransactionArgs,
10
9
  WcWallet,
11
10
  WriteContractArgs
12
11
  } from '../utils/TypeUtil';
13
- import { ConnectorController } from './ConnectorController';
14
12
 
15
13
  // -- Types --------------------------------------------- //
16
- export interface ConnectExternalOptions {
17
- id: Connector['id'];
18
- type: Connector['type'];
19
- provider?: Connector['provider'];
20
- info?: Connector['info'];
21
- }
22
14
 
23
15
  export interface ConnectionControllerClient {
24
16
  connectWalletConnect: (
25
17
  onUri: (uri: string) => void,
26
18
  walletUniversalLink?: string
27
19
  ) => Promise<void>;
28
- connectExternal?: (options: ConnectExternalOptions) => Promise<void>;
29
20
  signMessage: (message: string) => Promise<string>;
30
21
  sendTransaction: (args: SendTransactionArgs) => Promise<`0x${string}` | null>;
31
22
  parseUnits: (value: string, decimals: number) => bigint;
@@ -42,16 +33,12 @@ export interface ConnectionControllerState {
42
33
  wcUri?: string;
43
34
  wcPromise?: Promise<void>;
44
35
  wcPairingExpiry?: number;
45
- wcLinking?: {
46
- href: string;
47
- name: string;
48
- };
36
+ wcLinking?: WalletDeepLink;
49
37
  wcError?: boolean;
50
38
  pressedWallet?: WcWallet;
51
39
  recentWallets?: WcWallet[];
52
- selectedSocialProvider?: SocialProvider;
53
- connectedWalletImageUrl?: string;
54
- connectedSocialProvider?: SocialProvider;
40
+ connectedWalletImageUrl?: string; //TODO: remove this
41
+ connectedSocialProvider?: SocialProvider; // TODO: remove this
55
42
  }
56
43
 
57
44
  type StateKey = keyof ConnectionControllerState;
@@ -91,11 +78,6 @@ export const ConnectionController = {
91
78
  }, walletUniversalLink);
92
79
  },
93
80
 
94
- async connectExternal(options: ConnectExternalOptions) {
95
- await this._getClient().connectExternal?.(options);
96
- ConnectorController.setConnectedConnector(options.type);
97
- },
98
-
99
81
  async signMessage(message: string) {
100
82
  return this._getClient().signMessage(message);
101
83
  },
@@ -120,12 +102,17 @@ export const ConnectionController = {
120
102
  state.pressedWallet = undefined;
121
103
  },
122
104
 
123
- setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
124
- state.recentWallets = wallets;
105
+ setWcPromise(wcPromise: ConnectionControllerState['wcPromise']) {
106
+ state.wcPromise = wcPromise;
125
107
  },
126
108
 
127
- setSelectedSocialProvider(provider: ConnectionControllerState['selectedSocialProvider']) {
128
- state.selectedSocialProvider = provider;
109
+ setWcUri(wcUri: ConnectionControllerState['wcUri']) {
110
+ state.wcUri = wcUri;
111
+ state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
112
+ },
113
+
114
+ setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
115
+ state.recentWallets = wallets;
129
116
  },
130
117
 
131
118
  async setConnectedWalletImageUrl(url: ConnectionControllerState['connectedWalletImageUrl']) {
@@ -185,14 +172,12 @@ export const ConnectionController = {
185
172
  resetWcConnection() {
186
173
  this.clearUri();
187
174
  state.pressedWallet = undefined;
188
- state.selectedSocialProvider = undefined;
189
175
  ConnectionController.setConnectedWalletImageUrl(undefined);
190
- ConnectorController.setConnectedConnector(undefined);
176
+ // ConnectorController.setConnectedConnector(undefined);
191
177
  StorageUtil.removeWalletConnectDeepLink();
192
178
  },
193
179
 
194
180
  async disconnect() {
195
- await this._getClient().disconnect();
196
181
  this.resetWcConnection();
197
182
  // remove transactions
198
183
  // RouterController.reset('Connect');