@reown/appkit-core-react-native 0.0.0-feat-multi-social-20250715153550 → 0.0.0-feat-onramp-20250718185718

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 (194) hide show
  1. package/lib/commonjs/controllers/AccountController.js +17 -20
  2. package/lib/commonjs/controllers/AccountController.js.map +1 -1
  3. package/lib/commonjs/controllers/ApiController.js +15 -17
  4. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +29 -110
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionController.js +11 -8
  8. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  9. package/lib/commonjs/controllers/ConnectorController.js +49 -0
  10. package/lib/commonjs/controllers/ConnectorController.js.map +1 -0
  11. package/lib/commonjs/controllers/EnsController.js +4 -4
  12. package/lib/commonjs/controllers/EnsController.js.map +1 -1
  13. package/lib/commonjs/controllers/EventsController.js +4 -4
  14. package/lib/commonjs/controllers/EventsController.js.map +1 -1
  15. package/lib/commonjs/controllers/ModalController.js +2 -2
  16. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  17. package/lib/commonjs/controllers/OnRampController.js +60 -20
  18. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  19. package/lib/commonjs/controllers/OptionsController.js +3 -8
  20. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  21. package/lib/commonjs/controllers/RouterController.js +22 -1
  22. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  23. package/lib/commonjs/controllers/SendController.js +33 -34
  24. package/lib/commonjs/controllers/SendController.js.map +1 -1
  25. package/lib/commonjs/controllers/SnackController.js +5 -29
  26. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  27. package/lib/commonjs/controllers/SwapController.js +148 -136
  28. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  29. package/lib/commonjs/controllers/ThemeController.js +1 -9
  30. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  31. package/lib/commonjs/controllers/TransactionsController.js +21 -25
  32. package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
  33. package/lib/commonjs/controllers/WebviewController.js +52 -0
  34. package/lib/commonjs/controllers/WebviewController.js.map +1 -0
  35. package/lib/commonjs/index.js +24 -3
  36. package/lib/commonjs/index.js.map +1 -1
  37. package/lib/commonjs/utils/AssetUtil.js +12 -8
  38. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  39. package/lib/commonjs/utils/ConnectionUtil.js +33 -0
  40. package/lib/commonjs/utils/ConnectionUtil.js.map +1 -0
  41. package/lib/commonjs/utils/ConstantsUtil.js +8 -537
  42. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  43. package/lib/commonjs/utils/CoreHelperUtil.js +4 -4
  44. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  45. package/lib/commonjs/utils/FetchUtil.js +28 -9
  46. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  47. package/lib/commonjs/utils/NetworkUtil.js +46 -0
  48. package/lib/commonjs/utils/NetworkUtil.js.map +1 -0
  49. package/lib/commonjs/utils/StorageUtil.js +42 -51
  50. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  51. package/lib/commonjs/utils/SwapApiUtil.js +21 -15
  52. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  53. package/lib/module/controllers/AccountController.js +17 -20
  54. package/lib/module/controllers/AccountController.js.map +1 -1
  55. package/lib/module/controllers/ApiController.js +15 -16
  56. package/lib/module/controllers/ApiController.js.map +1 -1
  57. package/lib/module/controllers/BlockchainApiController.js +29 -110
  58. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  59. package/lib/module/controllers/ConnectionController.js +11 -8
  60. package/lib/module/controllers/ConnectionController.js.map +1 -1
  61. package/lib/module/controllers/ConnectorController.js +44 -0
  62. package/lib/module/controllers/ConnectorController.js.map +1 -0
  63. package/lib/module/controllers/EnsController.js +2 -2
  64. package/lib/module/controllers/EnsController.js.map +1 -1
  65. package/lib/module/controllers/EventsController.js +1 -1
  66. package/lib/module/controllers/EventsController.js.map +1 -1
  67. package/lib/module/controllers/ModalController.js +2 -2
  68. package/lib/module/controllers/ModalController.js.map +1 -1
  69. package/lib/module/controllers/OnRampController.js +60 -20
  70. package/lib/module/controllers/OnRampController.js.map +1 -1
  71. package/lib/module/controllers/OptionsController.js +3 -8
  72. package/lib/module/controllers/OptionsController.js.map +1 -1
  73. package/lib/module/controllers/RouterController.js +22 -1
  74. package/lib/module/controllers/RouterController.js.map +1 -1
  75. package/lib/module/controllers/SendController.js +30 -31
  76. package/lib/module/controllers/SendController.js.map +1 -1
  77. package/lib/module/controllers/SnackController.js +5 -29
  78. package/lib/module/controllers/SnackController.js.map +1 -1
  79. package/lib/module/controllers/SwapController.js +148 -136
  80. package/lib/module/controllers/SwapController.js.map +1 -1
  81. package/lib/module/controllers/ThemeController.js +1 -9
  82. package/lib/module/controllers/ThemeController.js.map +1 -1
  83. package/lib/module/controllers/TransactionsController.js +19 -23
  84. package/lib/module/controllers/TransactionsController.js.map +1 -1
  85. package/lib/module/controllers/WebviewController.js +47 -0
  86. package/lib/module/controllers/WebviewController.js.map +1 -0
  87. package/lib/module/index.js +4 -1
  88. package/lib/module/index.js.map +1 -1
  89. package/lib/module/utils/AssetUtil.js +12 -8
  90. package/lib/module/utils/AssetUtil.js.map +1 -1
  91. package/lib/module/utils/ConnectionUtil.js +27 -0
  92. package/lib/module/utils/ConnectionUtil.js.map +1 -0
  93. package/lib/module/utils/ConstantsUtil.js +8 -537
  94. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  95. package/lib/module/utils/CoreHelperUtil.js +4 -4
  96. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  97. package/lib/module/utils/FetchUtil.js +28 -9
  98. package/lib/module/utils/FetchUtil.js.map +1 -1
  99. package/lib/module/utils/NetworkUtil.js +40 -0
  100. package/lib/module/utils/NetworkUtil.js.map +1 -0
  101. package/lib/module/utils/StorageUtil.js +42 -51
  102. package/lib/module/utils/StorageUtil.js.map +1 -1
  103. package/lib/module/utils/SwapApiUtil.js +21 -15
  104. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  105. package/lib/typescript/controllers/AccountController.d.ts +4 -4
  106. package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
  107. package/lib/typescript/controllers/ApiController.d.ts +1 -1
  108. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  109. package/lib/typescript/controllers/BlockchainApiController.d.ts +4 -16
  110. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  111. package/lib/typescript/controllers/ConnectionController.d.ts +11 -3
  112. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  113. package/lib/typescript/controllers/ConnectorController.d.ts +18 -0
  114. package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -0
  115. package/lib/typescript/controllers/ModalController.d.ts +1 -1
  116. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  117. package/lib/typescript/controllers/NetworkController.d.ts +1 -1
  118. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  119. package/lib/typescript/controllers/OnRampController.d.ts +3 -1
  120. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  121. package/lib/typescript/controllers/OptionsController.d.ts +2 -5
  122. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  123. package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
  124. package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
  125. package/lib/typescript/controllers/RouterController.d.ts +16 -4
  126. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  127. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  128. package/lib/typescript/controllers/SnackController.d.ts +3 -3
  129. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  130. package/lib/typescript/controllers/SwapController.d.ts +9 -9
  131. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  132. package/lib/typescript/controllers/ThemeController.d.ts +1 -1
  133. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  134. package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
  135. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  136. package/lib/typescript/controllers/WebviewController.d.ts +21 -0
  137. package/lib/typescript/controllers/WebviewController.d.ts.map +1 -0
  138. package/lib/typescript/index.d.ts +4 -1
  139. package/lib/typescript/index.d.ts.map +1 -1
  140. package/lib/typescript/utils/AssetUtil.d.ts +3 -3
  141. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  142. package/lib/typescript/utils/ConnectionUtil.d.ts +4 -0
  143. package/lib/typescript/utils/ConnectionUtil.d.ts.map +1 -0
  144. package/lib/typescript/utils/ConstantsUtil.d.ts +1 -421
  145. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  146. package/lib/typescript/utils/CoreHelperUtil.d.ts +3 -3
  147. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  148. package/lib/typescript/utils/FetchUtil.d.ts +1 -1
  149. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  150. package/lib/typescript/utils/NetworkUtil.d.ts +8 -0
  151. package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -0
  152. package/lib/typescript/utils/StorageUtil.d.ts +7 -14
  153. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  154. package/lib/typescript/utils/SwapApiUtil.d.ts +3 -3
  155. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  156. package/lib/typescript/utils/TypeUtil.d.ts +172 -24
  157. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  158. package/package.json +4 -4
  159. package/src/controllers/AccountController.ts +27 -23
  160. package/src/controllers/ApiController.ts +9 -15
  161. package/src/controllers/BlockchainApiController.ts +32 -145
  162. package/src/controllers/ConnectionController.ts +24 -12
  163. package/src/controllers/ConnectorController.ts +63 -0
  164. package/src/controllers/EnsController.ts +2 -2
  165. package/src/controllers/EventsController.ts +1 -1
  166. package/src/controllers/ModalController.ts +3 -4
  167. package/src/controllers/NetworkController.ts +1 -1
  168. package/src/controllers/OnRampController.ts +91 -32
  169. package/src/controllers/OptionsController.ts +13 -14
  170. package/src/controllers/PublicStateController.ts +1 -1
  171. package/src/controllers/RouterController.ts +54 -5
  172. package/src/controllers/SendController.ts +30 -39
  173. package/src/controllers/SnackController.ts +5 -31
  174. package/src/controllers/SwapController.ts +178 -155
  175. package/src/controllers/ThemeController.ts +2 -11
  176. package/src/controllers/TransactionsController.ts +20 -26
  177. package/src/controllers/WebviewController.ts +63 -0
  178. package/src/index.ts +6 -3
  179. package/src/utils/AssetUtil.ts +14 -8
  180. package/src/utils/ConnectionUtil.ts +27 -0
  181. package/src/utils/ConstantsUtil.ts +8 -542
  182. package/src/utils/CoreHelperUtil.ts +7 -15
  183. package/src/utils/FetchUtil.ts +31 -10
  184. package/src/utils/NetworkUtil.ts +33 -0
  185. package/src/utils/StorageUtil.ts +48 -60
  186. package/src/utils/SwapApiUtil.ts +38 -27
  187. package/src/utils/TypeUtil.ts +172 -26
  188. package/lib/commonjs/controllers/ConnectionsController.js +0 -383
  189. package/lib/commonjs/controllers/ConnectionsController.js.map +0 -1
  190. package/lib/module/controllers/ConnectionsController.js +0 -378
  191. package/lib/module/controllers/ConnectionsController.js.map +0 -1
  192. package/lib/typescript/controllers/ConnectionsController.d.ts +0 -52
  193. package/lib/typescript/controllers/ConnectionsController.d.ts.map +0 -1
  194. package/src/controllers/ConnectionsController.ts +0 -503
@@ -32,14 +32,12 @@ import type {
32
32
  OnRampQuote,
33
33
  BlockchainApiOnRampWidgetRequest,
34
34
  BlockchainApiOnRampQuotesRequest,
35
- OnRampFiatLimit
35
+ OnRampFiatLimit,
36
+ OnRampCountryDefaults
36
37
  } from '../utils/TypeUtil';
37
38
  import { OptionsController } from './OptionsController';
38
39
  import { ConstantsUtil } from '../utils/ConstantsUtil';
39
40
  import { ApiUtil } from '../utils/ApiUtil';
40
- import type { CaipAddress, CaipNetworkId } from '@reown/appkit-common-react-native';
41
- import { ConnectionsController } from './ConnectionsController';
42
- import { SnackController } from './SnackController';
43
41
 
44
42
  // -- Helpers ------------------------------------------- //
45
43
  const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
@@ -60,54 +58,19 @@ const getHeaders = () => {
60
58
  export interface BlockchainApiControllerState {
61
59
  clientId: string | null;
62
60
  api: FetchUtil;
63
- supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
64
61
  }
65
62
 
66
63
  // -- State --------------------------------------------- //
67
64
  const state = proxy<BlockchainApiControllerState>({
68
65
  clientId: null,
69
- api: new FetchUtil({ baseUrl }),
70
- supportedChains: { http: [], ws: [] }
66
+ api: new FetchUtil({ baseUrl })
71
67
  });
72
68
 
73
69
  // -- Controller ---------------------------------------- //
74
70
  export const BlockchainApiController = {
75
71
  state,
76
72
 
77
- async isNetworkSupported(networkId?: CaipNetworkId) {
78
- if (!networkId) {
79
- return false;
80
- }
81
- try {
82
- if (!state.supportedChains.http.length) {
83
- await BlockchainApiController.getSupportedNetworks();
84
- }
85
- } catch (e) {
86
- return false;
87
- }
88
-
89
- return state.supportedChains.http.includes(networkId);
90
- },
91
-
92
- async getSupportedNetworks() {
93
- const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
94
- path: 'v1/supported-chains'
95
- });
96
-
97
- state.supportedChains = supportedChains!;
98
-
99
- return supportedChains;
100
- },
101
-
102
- async fetchIdentity({ address }: BlockchainApiIdentityRequest) {
103
- const isSupported = await BlockchainApiController.isNetworkSupported(
104
- ConnectionsController.state.activeCaipNetworkId
105
- );
106
-
107
- if (!isSupported) {
108
- return { avatar: '', name: '' };
109
- }
110
-
73
+ fetchIdentity({ address }: BlockchainApiIdentityRequest) {
111
74
  return state.api.get<BlockchainApiIdentityResponse>({
112
75
  path: `/v1/identity/${address}`,
113
76
  params: {
@@ -117,48 +80,29 @@ export const BlockchainApiController = {
117
80
  });
118
81
  },
119
82
 
120
- async fetchTransactions({
83
+ fetchTransactions({
121
84
  account,
122
85
  projectId,
123
86
  cursor,
124
87
  onramp,
125
88
  signal,
126
- cache,
127
- chainId
89
+ cache
128
90
  }: BlockchainApiTransactionsRequest) {
129
- const _chainId = chainId ?? ConnectionsController.state.activeCaipNetworkId;
130
- const isSupported = await BlockchainApiController.isNetworkSupported(_chainId);
131
-
132
- if (!isSupported) {
133
- return { data: [], next: undefined };
134
- }
135
-
136
- const response = await state.api.get<BlockchainApiTransactionsResponse>({
91
+ return state.api.get<BlockchainApiTransactionsResponse>({
137
92
  path: `/v1/account/${account}/history`,
138
93
  headers: getHeaders(),
139
94
  params: {
140
95
  projectId,
141
96
  cursor,
142
- onramp,
143
- chainId: _chainId
97
+ onramp
144
98
  },
145
99
  signal,
146
100
  cache
147
101
  });
148
-
149
- return response;
150
102
  },
151
103
 
152
- async fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest) {
153
- const isSupported = await BlockchainApiController.isNetworkSupported(
154
- ConnectionsController.state.activeCaipNetworkId
155
- );
156
-
157
- if (!isSupported) {
158
- return { fungibles: [] };
159
- }
160
-
161
- const response = await state.api.post<BlockchainApiTokenPriceResponse>({
104
+ fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest) {
105
+ return state.api.post<BlockchainApiTokenPriceResponse>({
162
106
  path: '/v1/fungible/price',
163
107
  body: {
164
108
  projectId,
@@ -167,23 +111,9 @@ export const BlockchainApiController = {
167
111
  },
168
112
  headers: getHeaders()
169
113
  });
170
-
171
- return response;
172
114
  },
173
115
 
174
- async fetchSwapAllowance({
175
- projectId,
176
- tokenAddress,
177
- userAddress
178
- }: BlockchainApiSwapAllowanceRequest) {
179
- const isSupported = await BlockchainApiController.isNetworkSupported(
180
- ConnectionsController.state.activeCaipNetworkId
181
- );
182
-
183
- if (!isSupported) {
184
- return { allowance: '0' };
185
- }
186
-
116
+ fetchSwapAllowance({ projectId, tokenAddress, userAddress }: BlockchainApiSwapAllowanceRequest) {
187
117
  return state.api.get<BlockchainApiSwapAllowanceResponse>({
188
118
  path: `/v1/convert/allowance`,
189
119
  params: {
@@ -195,15 +125,7 @@ export const BlockchainApiController = {
195
125
  });
196
126
  },
197
127
 
198
- async fetchGasPrice({ projectId, chainId }: BlockchainApiGasPriceRequest) {
199
- const isSupported = await BlockchainApiController.isNetworkSupported(
200
- ConnectionsController.state.activeCaipNetworkId
201
- );
202
-
203
- if (!isSupported) {
204
- throw new Error('Network not supported for Gas Price');
205
- }
206
-
128
+ fetchGasPrice({ projectId, chainId }: BlockchainApiGasPriceRequest) {
207
129
  return state.api.get<BlockchainApiGasPriceResponse>({
208
130
  path: `/v1/convert/gas-price`,
209
131
  headers: getHeaders(),
@@ -214,7 +136,7 @@ export const BlockchainApiController = {
214
136
  });
215
137
  },
216
138
 
217
- async fetchSwapQuote({
139
+ fetchSwapQuote({
218
140
  projectId,
219
141
  amount,
220
142
  userAddress,
@@ -222,14 +144,6 @@ export const BlockchainApiController = {
222
144
  to,
223
145
  gasPrice
224
146
  }: BlockchainApiSwapQuoteRequest) {
225
- const isSupported = await BlockchainApiController.isNetworkSupported(
226
- ConnectionsController.state.activeCaipNetworkId
227
- );
228
-
229
- if (!isSupported) {
230
- return { quotes: [] };
231
- }
232
-
233
147
  return state.api.get<BlockchainApiSwapQuoteResponse>({
234
148
  path: `/v1/convert/quotes`,
235
149
  headers: getHeaders(),
@@ -244,15 +158,7 @@ export const BlockchainApiController = {
244
158
  });
245
159
  },
246
160
 
247
- async fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
248
- const isSupported = await BlockchainApiController.isNetworkSupported(
249
- ConnectionsController.state.activeCaipNetworkId
250
- );
251
-
252
- if (!isSupported) {
253
- return { tokens: [] };
254
- }
255
-
161
+ fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
256
162
  return state.api.get<BlockchainApiSwapTokensResponse>({
257
163
  path: `/v1/convert/tokens`,
258
164
  headers: getHeaders(),
@@ -263,21 +169,13 @@ export const BlockchainApiController = {
263
169
  });
264
170
  },
265
171
 
266
- async generateSwapCalldata({
172
+ generateSwapCalldata({
267
173
  amount,
268
174
  from,
269
175
  projectId,
270
176
  to,
271
177
  userAddress
272
178
  }: BlockchainApiGenerateSwapCalldataRequest) {
273
- const isSupported = await BlockchainApiController.isNetworkSupported(
274
- ConnectionsController.state.activeCaipNetworkId
275
- );
276
-
277
- if (!isSupported) {
278
- throw new Error('Network not supported for Swaps');
279
- }
280
-
281
179
  return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
282
180
  path: '/v1/convert/build-transaction',
283
181
  headers: getHeaders(),
@@ -294,20 +192,12 @@ export const BlockchainApiController = {
294
192
  });
295
193
  },
296
194
 
297
- async generateApproveCalldata({
195
+ generateApproveCalldata({
298
196
  from,
299
197
  projectId,
300
198
  to,
301
199
  userAddress
302
200
  }: BlockchainApiGenerateApproveCalldataRequest) {
303
- const isSupported = await BlockchainApiController.isNetworkSupported(
304
- ConnectionsController.state.activeCaipNetworkId
305
- );
306
-
307
- if (!isSupported) {
308
- throw new Error('Network not supported for Swaps');
309
- }
310
-
311
201
  return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
312
202
  path: `/v1/convert/build-approve`,
313
203
  headers: getHeaders(),
@@ -320,30 +210,15 @@ export const BlockchainApiController = {
320
210
  });
321
211
  },
322
212
 
323
- async getBalance(address?: CaipAddress, forceUpdate?: CaipAddress[]) {
324
- const isSupported = await BlockchainApiController.isNetworkSupported(
325
- ConnectionsController.state.activeCaipNetworkId
326
- );
327
- if (!isSupported) {
328
- SnackController.showError('Token Balance Unavailable');
329
-
330
- return { balances: [] };
331
- }
332
-
333
- const [namespace, chain, plainAddress] = address?.split(':') ?? [];
334
-
335
- if (!namespace || !chain || !plainAddress) {
336
- throw new Error('Invalid address');
337
- }
338
-
213
+ async getBalance(address: string, chainId?: string, forceUpdate?: string) {
339
214
  return state.api.get<BlockchainApiBalanceResponse>({
340
- path: `/v1/account/${plainAddress}/balance`,
215
+ path: `/v1/account/${address}/balance`,
341
216
  headers: getHeaders(),
342
217
  params: {
343
218
  currency: 'usd',
344
219
  projectId: OptionsController.state.projectId,
345
- chainId: `${namespace}:${chain}`,
346
- forceUpdate: forceUpdate?.join(',')
220
+ chainId,
221
+ forceUpdate
347
222
  }
348
223
  });
349
224
  },
@@ -426,12 +301,24 @@ export const BlockchainApiController = {
426
301
  });
427
302
  },
428
303
 
304
+ async fetchOnRampCountriesDefaults() {
305
+ return await state.api.get<OnRampCountryDefaults[]>({
306
+ path: '/v1/onramp/providers/properties',
307
+ headers: getHeaders(),
308
+ params: {
309
+ projectId: OptionsController.state.projectId,
310
+ type: 'countries-defaults'
311
+ }
312
+ });
313
+ },
314
+
429
315
  async getOnRampQuotes(body: BlockchainApiOnRampQuotesRequest, signal?: AbortSignal) {
430
316
  return await state.api.post<OnRampQuote[]>({
431
317
  path: '/v1/onramp/multi/quotes',
432
318
  headers: getHeaders(),
433
319
  body: {
434
320
  projectId: OptionsController.state.projectId,
321
+ excludedProviders: ['BINANCECONNECT', 'COINBASEPAY'],
435
322
  ...body
436
323
  },
437
324
  signal
@@ -4,19 +4,28 @@ import type { SocialProvider } 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,
7
8
  EstimateGasTransactionArgs,
8
9
  SendTransactionArgs,
9
10
  WcWallet,
10
11
  WriteContractArgs
11
12
  } from '../utils/TypeUtil';
13
+ import { ConnectorController } from './ConnectorController';
12
14
 
13
15
  // -- Types --------------------------------------------- //
16
+ export interface ConnectExternalOptions {
17
+ id: Connector['id'];
18
+ type: Connector['type'];
19
+ provider?: Connector['provider'];
20
+ info?: Connector['info'];
21
+ }
14
22
 
15
23
  export interface ConnectionControllerClient {
16
24
  connectWalletConnect: (
17
25
  onUri: (uri: string) => void,
18
26
  walletUniversalLink?: string
19
27
  ) => Promise<void>;
28
+ connectExternal?: (options: ConnectExternalOptions) => Promise<void>;
20
29
  signMessage: (message: string) => Promise<string>;
21
30
  sendTransaction: (args: SendTransactionArgs) => Promise<`0x${string}` | null>;
22
31
  parseUnits: (value: string, decimals: number) => bigint;
@@ -40,8 +49,9 @@ export interface ConnectionControllerState {
40
49
  wcError?: boolean;
41
50
  pressedWallet?: WcWallet;
42
51
  recentWallets?: WcWallet[];
43
- connectedWalletImageUrl?: string; //TODO: remove this
44
- connectedSocialProvider?: SocialProvider; // TODO: remove this
52
+ selectedSocialProvider?: SocialProvider;
53
+ connectedWalletImageUrl?: string;
54
+ connectedSocialProvider?: SocialProvider;
45
55
  }
46
56
 
47
57
  type StateKey = keyof ConnectionControllerState;
@@ -81,6 +91,11 @@ export const ConnectionController = {
81
91
  }, walletUniversalLink);
82
92
  },
83
93
 
94
+ async connectExternal(options: ConnectExternalOptions) {
95
+ await this._getClient().connectExternal?.(options);
96
+ ConnectorController.setConnectedConnector(options.type);
97
+ },
98
+
84
99
  async signMessage(message: string) {
85
100
  return this._getClient().signMessage(message);
86
101
  },
@@ -105,19 +120,14 @@ export const ConnectionController = {
105
120
  state.pressedWallet = undefined;
106
121
  },
107
122
 
108
- setWcPromise(wcPromise: ConnectionControllerState['wcPromise']) {
109
- state.wcPromise = wcPromise;
110
- },
111
-
112
- setWcUri(wcUri: ConnectionControllerState['wcUri']) {
113
- state.wcUri = wcUri;
114
- state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
115
- },
116
-
117
123
  setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
118
124
  state.recentWallets = wallets;
119
125
  },
120
126
 
127
+ setSelectedSocialProvider(provider: ConnectionControllerState['selectedSocialProvider']) {
128
+ state.selectedSocialProvider = provider;
129
+ },
130
+
121
131
  async setConnectedWalletImageUrl(url: ConnectionControllerState['connectedWalletImageUrl']) {
122
132
  state.connectedWalletImageUrl = url;
123
133
 
@@ -175,12 +185,14 @@ export const ConnectionController = {
175
185
  resetWcConnection() {
176
186
  this.clearUri();
177
187
  state.pressedWallet = undefined;
188
+ state.selectedSocialProvider = undefined;
178
189
  ConnectionController.setConnectedWalletImageUrl(undefined);
179
- // ConnectorController.setConnectedConnector(undefined);
190
+ ConnectorController.setConnectedConnector(undefined);
180
191
  StorageUtil.removeWalletConnectDeepLink();
181
192
  },
182
193
 
183
194
  async disconnect() {
195
+ await this._getClient().disconnect();
184
196
  this.resetWcConnection();
185
197
  // remove transactions
186
198
  // RouterController.reset('Connect');
@@ -0,0 +1,63 @@
1
+ import type { ConnectorType } from '@reown/appkit-common-react-native';
2
+ import { subscribeKey as subKey } from 'valtio/utils';
3
+ import { proxy, ref } from 'valtio';
4
+ import type { Connector } from '../utils/TypeUtil';
5
+ import { StorageUtil } from '../utils/StorageUtil';
6
+
7
+ // -- Types --------------------------------------------- //
8
+ export interface ConnectorControllerState {
9
+ connectors: Connector[];
10
+ connectedConnector?: ConnectorType;
11
+ authLoading?: boolean;
12
+ }
13
+
14
+ type StateKey = keyof ConnectorControllerState;
15
+
16
+ // -- State --------------------------------------------- //
17
+ const state = proxy<ConnectorControllerState>({
18
+ connectors: []
19
+ });
20
+
21
+ // -- Controller ---------------------------------------- //
22
+ export const ConnectorController = {
23
+ state,
24
+
25
+ subscribeKey<K extends StateKey>(key: K, callback: (value: ConnectorControllerState[K]) => void) {
26
+ return subKey(state, key, callback);
27
+ },
28
+
29
+ setConnectors(connectors: ConnectorControllerState['connectors']) {
30
+ state.connectors = connectors.map(c => ref(c));
31
+ },
32
+
33
+ addConnector(connector: Connector) {
34
+ state.connectors = [...state.connectors, ref(connector)];
35
+ },
36
+
37
+ getConnectors() {
38
+ return state.connectors;
39
+ },
40
+
41
+ getAuthConnector() {
42
+ return state.connectors.find(c => c.type === 'AUTH');
43
+ },
44
+
45
+ setConnectedConnector(
46
+ connectorType: ConnectorControllerState['connectedConnector'],
47
+ saveStorage = true
48
+ ) {
49
+ state.connectedConnector = connectorType;
50
+
51
+ if (saveStorage) {
52
+ if (connectorType) {
53
+ StorageUtil.setConnectedConnector(connectorType);
54
+ } else {
55
+ StorageUtil.removeConnectedConnector();
56
+ }
57
+ }
58
+ },
59
+
60
+ setAuthLoading(loading: ConnectorControllerState['authLoading']) {
61
+ state.authLoading = loading;
62
+ }
63
+ };
@@ -1,5 +1,5 @@
1
- import { subscribeKey as subKey } from 'valtio/vanilla/utils';
2
- import { proxy, subscribe as sub } from 'valtio/vanilla';
1
+ import { subscribeKey as subKey } from 'valtio/utils';
2
+ import { proxy, subscribe as sub } from 'valtio';
3
3
  import { BlockchainApiController } from './BlockchainApiController';
4
4
  import type { BlockchainApiEnsError } from '../utils/TypeUtil';
5
5
 
@@ -1,4 +1,4 @@
1
- import { proxy, subscribe as sub } from 'valtio/vanilla';
1
+ import { proxy, subscribe as sub } from 'valtio';
2
2
  import { ApiController } from './ApiController';
3
3
  import { OptionsController } from './OptionsController';
4
4
  import { CoreHelperUtil } from '../utils/CoreHelperUtil';
@@ -1,11 +1,10 @@
1
1
  import { proxy } from 'valtio';
2
2
  import { AccountController } from './AccountController';
3
- import type { RouterControllerState } from './RouterController';
4
- import { RouterController } from './RouterController';
3
+ import { RouterController, type RouterControllerState } from './RouterController';
5
4
  import { PublicStateController } from './PublicStateController';
6
5
  import { EventsController } from './EventsController';
7
6
  import { ApiController } from './ApiController';
8
- import { ConnectionsController } from './ConnectionsController';
7
+ import { ConnectorController } from './ConnectorController';
9
8
 
10
9
  // -- Types --------------------------------------------- //
11
10
  export interface ModalControllerState {
@@ -35,7 +34,7 @@ export const ModalController = {
35
34
  if (options?.view) {
36
35
  RouterController.reset(options.view);
37
36
  } else if (AccountController.state.isConnected) {
38
- const isUniversalWallet = !!ConnectionsController.state.connection?.properties?.provider;
37
+ const isUniversalWallet = ConnectorController.state.connectedConnector === 'AUTH';
39
38
  RouterController.reset(isUniversalWallet ? 'Account' : 'AccountDefault');
40
39
  } else {
41
40
  RouterController.reset('Connect');
@@ -1,5 +1,5 @@
1
1
  import { proxy, ref } from 'valtio';
2
- import type { CaipNetwork, CaipNetworkId } from '@reown/appkit-common-react-native';
2
+ import type { CaipNetwork, CaipNetworkId } from '../utils/TypeUtil';
3
3
  import { PublicStateController } from './PublicStateController';
4
4
  import { NetworkUtil } from '@reown/appkit-common-react-native';
5
5
  import { ConstantsUtil } from '../utils/ConstantsUtil';