@reown/appkit-core-react-native 0.0.0-feat-onramp-20250718200617 → 0.0.0-feat-coinbase-20250722173213

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 (195) hide show
  1. package/lib/commonjs/controllers/AccountController.js +20 -17
  2. package/lib/commonjs/controllers/AccountController.js.map +1 -1
  3. package/lib/commonjs/controllers/ApiController.js +28 -16
  4. package/lib/commonjs/controllers/ApiController.js.map +1 -1
  5. package/lib/commonjs/controllers/BlockchainApiController.js +166 -67
  6. package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
  7. package/lib/commonjs/controllers/ConnectionController.js +8 -11
  8. package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
  9. package/lib/commonjs/controllers/ConnectionsController.js +387 -0
  10. package/lib/commonjs/controllers/ConnectionsController.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 +6 -7
  16. package/lib/commonjs/controllers/ModalController.js.map +1 -1
  17. package/lib/commonjs/controllers/OnRampController.js +22 -70
  18. package/lib/commonjs/controllers/OnRampController.js.map +1 -1
  19. package/lib/commonjs/controllers/OptionsController.js +11 -3
  20. package/lib/commonjs/controllers/OptionsController.js.map +1 -1
  21. package/lib/commonjs/controllers/RouterController.js +1 -22
  22. package/lib/commonjs/controllers/RouterController.js.map +1 -1
  23. package/lib/commonjs/controllers/SendController.js +101 -101
  24. package/lib/commonjs/controllers/SendController.js.map +1 -1
  25. package/lib/commonjs/controllers/SnackController.js +29 -5
  26. package/lib/commonjs/controllers/SnackController.js.map +1 -1
  27. package/lib/commonjs/controllers/SwapController.js +151 -150
  28. package/lib/commonjs/controllers/SwapController.js.map +1 -1
  29. package/lib/commonjs/controllers/ThemeController.js +9 -1
  30. package/lib/commonjs/controllers/ThemeController.js.map +1 -1
  31. package/lib/commonjs/controllers/TransactionsController.js +25 -21
  32. package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
  33. package/lib/commonjs/index.js +3 -24
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/utils/AssetUtil.js +3 -15
  36. package/lib/commonjs/utils/AssetUtil.js.map +1 -1
  37. package/lib/commonjs/utils/ConstantsUtil.js +538 -9
  38. package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
  39. package/lib/commonjs/utils/CoreHelperUtil.js +12 -6
  40. package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
  41. package/lib/commonjs/utils/FetchUtil.js +9 -28
  42. package/lib/commonjs/utils/FetchUtil.js.map +1 -1
  43. package/lib/commonjs/utils/StorageUtil.js +51 -42
  44. package/lib/commonjs/utils/StorageUtil.js.map +1 -1
  45. package/lib/commonjs/utils/SwapApiUtil.js +15 -21
  46. package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
  47. package/lib/module/controllers/AccountController.js +20 -17
  48. package/lib/module/controllers/AccountController.js.map +1 -1
  49. package/lib/module/controllers/ApiController.js +27 -16
  50. package/lib/module/controllers/ApiController.js.map +1 -1
  51. package/lib/module/controllers/BlockchainApiController.js +166 -67
  52. package/lib/module/controllers/BlockchainApiController.js.map +1 -1
  53. package/lib/module/controllers/ConnectionController.js +8 -11
  54. package/lib/module/controllers/ConnectionController.js.map +1 -1
  55. package/lib/module/controllers/ConnectionsController.js +382 -0
  56. package/lib/module/controllers/ConnectionsController.js.map +1 -0
  57. package/lib/module/controllers/EnsController.js +2 -2
  58. package/lib/module/controllers/EnsController.js.map +1 -1
  59. package/lib/module/controllers/EventsController.js +1 -1
  60. package/lib/module/controllers/EventsController.js.map +1 -1
  61. package/lib/module/controllers/ModalController.js +6 -7
  62. package/lib/module/controllers/ModalController.js.map +1 -1
  63. package/lib/module/controllers/OnRampController.js +22 -70
  64. package/lib/module/controllers/OnRampController.js.map +1 -1
  65. package/lib/module/controllers/OptionsController.js +11 -3
  66. package/lib/module/controllers/OptionsController.js.map +1 -1
  67. package/lib/module/controllers/RouterController.js +1 -22
  68. package/lib/module/controllers/RouterController.js.map +1 -1
  69. package/lib/module/controllers/SendController.js +98 -98
  70. package/lib/module/controllers/SendController.js.map +1 -1
  71. package/lib/module/controllers/SnackController.js +29 -5
  72. package/lib/module/controllers/SnackController.js.map +1 -1
  73. package/lib/module/controllers/SwapController.js +151 -150
  74. package/lib/module/controllers/SwapController.js.map +1 -1
  75. package/lib/module/controllers/ThemeController.js +9 -1
  76. package/lib/module/controllers/ThemeController.js.map +1 -1
  77. package/lib/module/controllers/TransactionsController.js +23 -19
  78. package/lib/module/controllers/TransactionsController.js.map +1 -1
  79. package/lib/module/index.js +1 -4
  80. package/lib/module/index.js.map +1 -1
  81. package/lib/module/utils/AssetUtil.js +3 -15
  82. package/lib/module/utils/AssetUtil.js.map +1 -1
  83. package/lib/module/utils/ConstantsUtil.js +538 -9
  84. package/lib/module/utils/ConstantsUtil.js.map +1 -1
  85. package/lib/module/utils/CoreHelperUtil.js +12 -6
  86. package/lib/module/utils/CoreHelperUtil.js.map +1 -1
  87. package/lib/module/utils/FetchUtil.js +9 -28
  88. package/lib/module/utils/FetchUtil.js.map +1 -1
  89. package/lib/module/utils/StorageUtil.js +51 -42
  90. package/lib/module/utils/StorageUtil.js.map +1 -1
  91. package/lib/module/utils/SwapApiUtil.js +15 -21
  92. package/lib/module/utils/SwapApiUtil.js.map +1 -1
  93. package/lib/typescript/controllers/AccountController.d.ts +4 -4
  94. package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
  95. package/lib/typescript/controllers/ApiController.d.ts +3 -2
  96. package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
  97. package/lib/typescript/controllers/BlockchainApiController.d.ts +28 -12
  98. package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
  99. package/lib/typescript/controllers/ConnectionController.d.ts +3 -11
  100. package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
  101. package/lib/typescript/controllers/ConnectionsController.d.ts +53 -0
  102. package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
  103. package/lib/typescript/controllers/ModalController.d.ts +1 -1
  104. package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
  105. package/lib/typescript/controllers/NetworkController.d.ts +1 -1
  106. package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
  107. package/lib/typescript/controllers/OnRampController.d.ts +1 -3
  108. package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
  109. package/lib/typescript/controllers/OptionsController.d.ts +7 -2
  110. package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
  111. package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
  112. package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
  113. package/lib/typescript/controllers/RouterController.d.ts +4 -16
  114. package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
  115. package/lib/typescript/controllers/SendController.d.ts +5 -7
  116. package/lib/typescript/controllers/SendController.d.ts.map +1 -1
  117. package/lib/typescript/controllers/SnackController.d.ts +3 -3
  118. package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
  119. package/lib/typescript/controllers/SwapController.d.ts +12 -11
  120. package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
  121. package/lib/typescript/controllers/ThemeController.d.ts +1 -1
  122. package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
  123. package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
  124. package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
  125. package/lib/typescript/index.d.ts +1 -4
  126. package/lib/typescript/index.d.ts.map +1 -1
  127. package/lib/typescript/utils/AssetUtil.d.ts +2 -3
  128. package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
  129. package/lib/typescript/utils/ConstantsUtil.d.ts +422 -3
  130. package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
  131. package/lib/typescript/utils/CoreHelperUtil.d.ts +5 -4
  132. package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
  133. package/lib/typescript/utils/FetchUtil.d.ts +1 -1
  134. package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
  135. package/lib/typescript/utils/StorageUtil.d.ts +14 -7
  136. package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
  137. package/lib/typescript/utils/SwapApiUtil.d.ts +3 -3
  138. package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
  139. package/lib/typescript/utils/TypeUtil.d.ts +42 -191
  140. package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
  141. package/package.json +4 -4
  142. package/src/controllers/AccountController.ts +23 -27
  143. package/src/controllers/ApiController.ts +29 -10
  144. package/src/controllers/BlockchainApiController.ts +140 -55
  145. package/src/controllers/ConnectionController.ts +12 -24
  146. package/src/controllers/ConnectionsController.ts +509 -0
  147. package/src/controllers/EnsController.ts +2 -2
  148. package/src/controllers/EventsController.ts +1 -1
  149. package/src/controllers/ModalController.ts +8 -8
  150. package/src/controllers/NetworkController.ts +1 -1
  151. package/src/controllers/OnRampController.ts +34 -99
  152. package/src/controllers/OptionsController.ts +19 -13
  153. package/src/controllers/PublicStateController.ts +1 -1
  154. package/src/controllers/RouterController.ts +5 -54
  155. package/src/controllers/SendController.ts +124 -113
  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 +26 -20
  160. package/src/index.ts +3 -6
  161. package/src/utils/AssetUtil.ts +4 -20
  162. package/src/utils/ConstantsUtil.ts +544 -9
  163. package/src/utils/CoreHelperUtil.ts +34 -9
  164. package/src/utils/FetchUtil.ts +10 -31
  165. package/src/utils/StorageUtil.ts +60 -48
  166. package/src/utils/SwapApiUtil.ts +27 -38
  167. package/src/utils/TypeUtil.ts +43 -193
  168. package/lib/commonjs/controllers/ConnectorController.js +0 -49
  169. package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
  170. package/lib/commonjs/controllers/WebviewController.js +0 -52
  171. package/lib/commonjs/controllers/WebviewController.js.map +0 -1
  172. package/lib/commonjs/utils/ConnectionUtil.js +0 -33
  173. package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
  174. package/lib/commonjs/utils/NetworkUtil.js +0 -46
  175. package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
  176. package/lib/module/controllers/ConnectorController.js +0 -44
  177. package/lib/module/controllers/ConnectorController.js.map +0 -1
  178. package/lib/module/controllers/WebviewController.js +0 -47
  179. package/lib/module/controllers/WebviewController.js.map +0 -1
  180. package/lib/module/utils/ConnectionUtil.js +0 -27
  181. package/lib/module/utils/ConnectionUtil.js.map +0 -1
  182. package/lib/module/utils/NetworkUtil.js +0 -40
  183. package/lib/module/utils/NetworkUtil.js.map +0 -1
  184. package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
  185. package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
  186. package/lib/typescript/controllers/WebviewController.d.ts +0 -21
  187. package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
  188. package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
  189. package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
  190. package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
  191. package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
  192. package/src/controllers/ConnectorController.ts +0 -63
  193. package/src/controllers/WebviewController.ts +0 -63
  194. package/src/utils/ConnectionUtil.ts +0 -27
  195. package/src/utils/NetworkUtil.ts +0 -33
@@ -32,12 +32,14 @@ import type {
32
32
  OnRampQuote,
33
33
  BlockchainApiOnRampWidgetRequest,
34
34
  BlockchainApiOnRampQuotesRequest,
35
- OnRampFiatLimit,
36
- OnRampCountryDefaults
35
+ OnRampFiatLimit
37
36
  } from '../utils/TypeUtil';
38
37
  import { OptionsController } from './OptionsController';
39
38
  import { ConstantsUtil } from '../utils/ConstantsUtil';
40
39
  import { ApiUtil } from '../utils/ApiUtil';
40
+ import type { CaipAddress, CaipNetworkId } from '@reown/appkit-common-react-native';
41
+
42
+ import { SnackController } from './SnackController';
41
43
 
42
44
  // -- Helpers ------------------------------------------- //
43
45
  const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
@@ -55,22 +57,58 @@ const getHeaders = () => {
55
57
  };
56
58
 
57
59
  // -- Types --------------------------------------------- //
60
+ type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
61
+
58
62
  export interface BlockchainApiControllerState {
59
63
  clientId: string | null;
60
64
  api: FetchUtil;
65
+ supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
61
66
  }
62
67
 
63
68
  // -- State --------------------------------------------- //
64
69
  const state = proxy<BlockchainApiControllerState>({
65
70
  clientId: null,
66
- api: new FetchUtil({ baseUrl })
71
+ api: new FetchUtil({ baseUrl }),
72
+ supportedChains: { http: [], ws: [] }
67
73
  });
68
74
 
69
75
  // -- Controller ---------------------------------------- //
70
76
  export const BlockchainApiController = {
71
77
  state,
72
78
 
73
- fetchIdentity({ address }: BlockchainApiIdentityRequest) {
79
+ async isNetworkSupported(networkId?: CaipNetworkId) {
80
+ if (!networkId) {
81
+ return false;
82
+ }
83
+ try {
84
+ if (!state.supportedChains.http.length) {
85
+ await BlockchainApiController.getSupportedNetworks();
86
+ }
87
+ } catch (e) {
88
+ return false;
89
+ }
90
+
91
+ return state.supportedChains.http.includes(networkId);
92
+ },
93
+
94
+ async getSupportedNetworks() {
95
+ const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
96
+ path: 'v1/supported-chains'
97
+ });
98
+
99
+ state.supportedChains = supportedChains!;
100
+
101
+ return supportedChains;
102
+ },
103
+
104
+ async fetchIdentity(params: BlockchainApiIdentityRequest & WithCaipNetworkId) {
105
+ const { address, caipNetworkId } = params;
106
+ const isSupported = await BlockchainApiController.isNetworkSupported(caipNetworkId);
107
+
108
+ if (!isSupported) {
109
+ return { avatar: '', name: '' };
110
+ }
111
+
74
112
  return state.api.get<BlockchainApiIdentityResponse>({
75
113
  path: `/v1/identity/${address}`,
76
114
  params: {
@@ -80,29 +118,39 @@ export const BlockchainApiController = {
80
118
  });
81
119
  },
82
120
 
83
- fetchTransactions({
84
- account,
85
- projectId,
86
- cursor,
87
- onramp,
88
- signal,
89
- cache
90
- }: BlockchainApiTransactionsRequest) {
91
- return state.api.get<BlockchainApiTransactionsResponse>({
121
+ async fetchTransactions(params: BlockchainApiTransactionsRequest) {
122
+ const { account, projectId, cursor, onramp, signal, cache, chainId } = params;
123
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
124
+
125
+ if (!isSupported) {
126
+ return { data: [], next: undefined };
127
+ }
128
+
129
+ const response = await state.api.get<BlockchainApiTransactionsResponse>({
92
130
  path: `/v1/account/${account}/history`,
93
131
  headers: getHeaders(),
94
132
  params: {
95
133
  projectId,
96
134
  cursor,
97
- onramp
135
+ onramp,
136
+ chainId
98
137
  },
99
138
  signal,
100
139
  cache
101
140
  });
141
+
142
+ return response;
102
143
  },
103
144
 
104
- fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest) {
105
- return state.api.post<BlockchainApiTokenPriceResponse>({
145
+ async fetchTokenPrice(params: BlockchainApiTokenPriceRequest & WithCaipNetworkId) {
146
+ const { projectId, addresses, caipNetworkId } = params;
147
+ const isSupported = await BlockchainApiController.isNetworkSupported(caipNetworkId);
148
+
149
+ if (!isSupported) {
150
+ return { fungibles: [] };
151
+ }
152
+
153
+ const response = await state.api.post<BlockchainApiTokenPriceResponse>({
106
154
  path: '/v1/fungible/price',
107
155
  body: {
108
156
  projectId,
@@ -111,9 +159,20 @@ export const BlockchainApiController = {
111
159
  },
112
160
  headers: getHeaders()
113
161
  });
162
+
163
+ return response;
114
164
  },
115
165
 
116
- fetchSwapAllowance({ projectId, tokenAddress, userAddress }: BlockchainApiSwapAllowanceRequest) {
166
+ async fetchSwapAllowance(params: BlockchainApiSwapAllowanceRequest) {
167
+ const { projectId, tokenAddress, userAddress } = params;
168
+ const [namespace, chain] = userAddress.split(':');
169
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
170
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
171
+
172
+ if (!isSupported) {
173
+ return { allowance: '0' };
174
+ }
175
+
117
176
  return state.api.get<BlockchainApiSwapAllowanceResponse>({
118
177
  path: `/v1/convert/allowance`,
119
178
  params: {
@@ -125,7 +184,14 @@ export const BlockchainApiController = {
125
184
  });
126
185
  },
127
186
 
128
- fetchGasPrice({ projectId, chainId }: BlockchainApiGasPriceRequest) {
187
+ async fetchGasPrice(params: BlockchainApiGasPriceRequest) {
188
+ const { projectId, chainId } = params;
189
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
190
+
191
+ if (!isSupported) {
192
+ throw new Error('Network not supported for Gas Price');
193
+ }
194
+
129
195
  return state.api.get<BlockchainApiGasPriceResponse>({
130
196
  path: `/v1/convert/gas-price`,
131
197
  headers: getHeaders(),
@@ -136,14 +202,16 @@ export const BlockchainApiController = {
136
202
  });
137
203
  },
138
204
 
139
- fetchSwapQuote({
140
- projectId,
141
- amount,
142
- userAddress,
143
- from,
144
- to,
145
- gasPrice
146
- }: BlockchainApiSwapQuoteRequest) {
205
+ async fetchSwapQuote(params: BlockchainApiSwapQuoteRequest) {
206
+ const { projectId, amount, userAddress, from, to, gasPrice } = params;
207
+ const [namespace, chain] = userAddress.split(':');
208
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
209
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
210
+
211
+ if (!isSupported) {
212
+ return { quotes: [] };
213
+ }
214
+
147
215
  return state.api.get<BlockchainApiSwapQuoteResponse>({
148
216
  path: `/v1/convert/quotes`,
149
217
  headers: getHeaders(),
@@ -158,7 +226,14 @@ export const BlockchainApiController = {
158
226
  });
159
227
  },
160
228
 
161
- fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
229
+ async fetchSwapTokens(params: BlockchainApiSwapTokensRequest) {
230
+ const { projectId, chainId } = params;
231
+ const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
232
+
233
+ if (!isSupported) {
234
+ return { tokens: [] };
235
+ }
236
+
162
237
  return state.api.get<BlockchainApiSwapTokensResponse>({
163
238
  path: `/v1/convert/tokens`,
164
239
  headers: getHeaders(),
@@ -169,13 +244,16 @@ export const BlockchainApiController = {
169
244
  });
170
245
  },
171
246
 
172
- generateSwapCalldata({
173
- amount,
174
- from,
175
- projectId,
176
- to,
177
- userAddress
178
- }: BlockchainApiGenerateSwapCalldataRequest) {
247
+ async generateSwapCalldata(params: BlockchainApiGenerateSwapCalldataRequest) {
248
+ const { amount, from, projectId, to, userAddress } = params;
249
+ const [namespace, chain] = userAddress.split(':');
250
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
251
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
252
+
253
+ if (!isSupported) {
254
+ throw new Error('Network not supported for Swaps');
255
+ }
256
+
179
257
  return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
180
258
  path: '/v1/convert/build-transaction',
181
259
  headers: getHeaders(),
@@ -192,12 +270,16 @@ export const BlockchainApiController = {
192
270
  });
193
271
  },
194
272
 
195
- generateApproveCalldata({
196
- from,
197
- projectId,
198
- to,
199
- userAddress
200
- }: BlockchainApiGenerateApproveCalldataRequest) {
273
+ async generateApproveCalldata(params: BlockchainApiGenerateApproveCalldataRequest) {
274
+ const { from, projectId, to, userAddress } = params;
275
+ const [namespace, chain] = userAddress.split(':');
276
+ const networkId: CaipNetworkId = `${namespace}:${chain}`;
277
+ const isSupported = await BlockchainApiController.isNetworkSupported(networkId);
278
+
279
+ if (!isSupported) {
280
+ throw new Error('Network not supported for Swaps');
281
+ }
282
+
201
283
  return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
202
284
  path: `/v1/convert/build-approve`,
203
285
  headers: getHeaders(),
@@ -210,15 +292,29 @@ export const BlockchainApiController = {
210
292
  });
211
293
  },
212
294
 
213
- async getBalance(address: string, chainId?: string, forceUpdate?: string) {
295
+ async getBalance(address?: CaipAddress, forceUpdate?: CaipAddress[]) {
296
+ const [namespace, chain, plainAddress] = address?.split(':') ?? [];
297
+
298
+ if (!namespace || !chain || !plainAddress) {
299
+ throw new Error('Invalid address');
300
+ }
301
+
302
+ const isSupported = await BlockchainApiController.isNetworkSupported(`${namespace}:${chain}`);
303
+
304
+ if (!isSupported) {
305
+ SnackController.showError('Token Balance Unavailable');
306
+
307
+ return { balances: [] };
308
+ }
309
+
214
310
  return state.api.get<BlockchainApiBalanceResponse>({
215
- path: `/v1/account/${address}/balance`,
311
+ path: `/v1/account/${plainAddress}/balance`,
216
312
  headers: getHeaders(),
217
313
  params: {
218
314
  currency: 'usd',
219
315
  projectId: OptionsController.state.projectId,
220
- chainId,
221
- forceUpdate
316
+ chainId: `${namespace}:${chain}`,
317
+ forceUpdate: forceUpdate?.join(',')
222
318
  }
223
319
  });
224
320
  },
@@ -301,17 +397,6 @@ export const BlockchainApiController = {
301
397
  });
302
398
  },
303
399
 
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
-
315
400
  async getOnRampQuotes(body: BlockchainApiOnRampQuotesRequest, signal?: AbortSignal) {
316
401
  return await state.api.post<OnRampQuote[]>({
317
402
  path: '/v1/onramp/multi/quotes',
@@ -4,28 +4,19 @@ 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,
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;
@@ -49,9 +40,8 @@ export interface ConnectionControllerState {
49
40
  wcError?: boolean;
50
41
  pressedWallet?: WcWallet;
51
42
  recentWallets?: WcWallet[];
52
- selectedSocialProvider?: SocialProvider;
53
- connectedWalletImageUrl?: string;
54
- connectedSocialProvider?: SocialProvider;
43
+ connectedWalletImageUrl?: string; //TODO: remove this
44
+ connectedSocialProvider?: SocialProvider; // TODO: remove this
55
45
  }
56
46
 
57
47
  type StateKey = keyof ConnectionControllerState;
@@ -91,11 +81,6 @@ export const ConnectionController = {
91
81
  }, walletUniversalLink);
92
82
  },
93
83
 
94
- async connectExternal(options: ConnectExternalOptions) {
95
- await this._getClient().connectExternal?.(options);
96
- ConnectorController.setConnectedConnector(options.type);
97
- },
98
-
99
84
  async signMessage(message: string) {
100
85
  return this._getClient().signMessage(message);
101
86
  },
@@ -120,12 +105,17 @@ export const ConnectionController = {
120
105
  state.pressedWallet = undefined;
121
106
  },
122
107
 
123
- setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
124
- state.recentWallets = wallets;
108
+ setWcPromise(wcPromise: ConnectionControllerState['wcPromise']) {
109
+ state.wcPromise = wcPromise;
125
110
  },
126
111
 
127
- setSelectedSocialProvider(provider: ConnectionControllerState['selectedSocialProvider']) {
128
- state.selectedSocialProvider = provider;
112
+ setWcUri(wcUri: ConnectionControllerState['wcUri']) {
113
+ state.wcUri = wcUri;
114
+ state.wcPairingExpiry = CoreHelperUtil.getPairingExpiry();
115
+ },
116
+
117
+ setRecentWallets(wallets: ConnectionControllerState['recentWallets']) {
118
+ state.recentWallets = wallets;
129
119
  },
130
120
 
131
121
  async setConnectedWalletImageUrl(url: ConnectionControllerState['connectedWalletImageUrl']) {
@@ -185,14 +175,12 @@ export const ConnectionController = {
185
175
  resetWcConnection() {
186
176
  this.clearUri();
187
177
  state.pressedWallet = undefined;
188
- state.selectedSocialProvider = undefined;
189
178
  ConnectionController.setConnectedWalletImageUrl(undefined);
190
- ConnectorController.setConnectedConnector(undefined);
179
+ // ConnectorController.setConnectedConnector(undefined);
191
180
  StorageUtil.removeWalletConnectDeepLink();
192
181
  },
193
182
 
194
183
  async disconnect() {
195
- await this._getClient().disconnect();
196
184
  this.resetWcConnection();
197
185
  // remove transactions
198
186
  // RouterController.reset('Connect');