@reown/appkit-core-react-native 0.0.0-feat-onramp-20250722205908 → 0.0.0-feat-coinbase-20250723173858

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 +204 -74
  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 -69
  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 +203 -73
  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 +23 -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 +29 -15
  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 +179 -65
  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 +35 -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();
@@ -54,25 +56,59 @@ const getHeaders = () => {
54
56
  };
55
57
  };
56
58
 
57
- export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
58
-
59
59
  // -- Types --------------------------------------------- //
60
+ type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
61
+
60
62
  export interface BlockchainApiControllerState {
61
63
  clientId: string | null;
62
64
  api: FetchUtil;
65
+ supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
63
66
  }
64
67
 
65
68
  // -- State --------------------------------------------- //
66
69
  const state = proxy<BlockchainApiControllerState>({
67
70
  clientId: null,
68
- api: new FetchUtil({ baseUrl })
71
+ api: new FetchUtil({ baseUrl }),
72
+ supportedChains: { http: [], ws: [] }
69
73
  });
70
74
 
71
75
  // -- Controller ---------------------------------------- //
72
76
  export const BlockchainApiController = {
73
77
  state,
74
78
 
75
- 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
+
76
112
  return state.api.get<BlockchainApiIdentityResponse>({
77
113
  path: `/v1/identity/${address}`,
78
114
  params: {
@@ -82,29 +118,39 @@ export const BlockchainApiController = {
82
118
  });
83
119
  },
84
120
 
85
- fetchTransactions({
86
- account,
87
- projectId,
88
- cursor,
89
- onramp,
90
- signal,
91
- cache
92
- }: BlockchainApiTransactionsRequest) {
93
- 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>({
94
130
  path: `/v1/account/${account}/history`,
95
131
  headers: getHeaders(),
96
132
  params: {
97
133
  projectId,
98
134
  cursor,
99
- onramp
135
+ onramp,
136
+ chainId
100
137
  },
101
138
  signal,
102
139
  cache
103
140
  });
141
+
142
+ return response;
104
143
  },
105
144
 
106
- fetchTokenPrice({ projectId, addresses }: BlockchainApiTokenPriceRequest) {
107
- 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>({
108
154
  path: '/v1/fungible/price',
109
155
  body: {
110
156
  projectId,
@@ -113,9 +159,20 @@ export const BlockchainApiController = {
113
159
  },
114
160
  headers: getHeaders()
115
161
  });
162
+
163
+ return response;
116
164
  },
117
165
 
118
- 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
+
119
176
  return state.api.get<BlockchainApiSwapAllowanceResponse>({
120
177
  path: `/v1/convert/allowance`,
121
178
  params: {
@@ -127,7 +184,14 @@ export const BlockchainApiController = {
127
184
  });
128
185
  },
129
186
 
130
- 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
+
131
195
  return state.api.get<BlockchainApiGasPriceResponse>({
132
196
  path: `/v1/convert/gas-price`,
133
197
  headers: getHeaders(),
@@ -138,14 +202,16 @@ export const BlockchainApiController = {
138
202
  });
139
203
  },
140
204
 
141
- fetchSwapQuote({
142
- projectId,
143
- amount,
144
- userAddress,
145
- from,
146
- to,
147
- gasPrice
148
- }: 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
+
149
215
  return state.api.get<BlockchainApiSwapQuoteResponse>({
150
216
  path: `/v1/convert/quotes`,
151
217
  headers: getHeaders(),
@@ -160,7 +226,14 @@ export const BlockchainApiController = {
160
226
  });
161
227
  },
162
228
 
163
- 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
+
164
237
  return state.api.get<BlockchainApiSwapTokensResponse>({
165
238
  path: `/v1/convert/tokens`,
166
239
  headers: getHeaders(),
@@ -171,13 +244,16 @@ export const BlockchainApiController = {
171
244
  });
172
245
  },
173
246
 
174
- generateSwapCalldata({
175
- amount,
176
- from,
177
- projectId,
178
- to,
179
- userAddress
180
- }: 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
+
181
257
  return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
182
258
  path: '/v1/convert/build-transaction',
183
259
  headers: getHeaders(),
@@ -194,12 +270,16 @@ export const BlockchainApiController = {
194
270
  });
195
271
  },
196
272
 
197
- generateApproveCalldata({
198
- from,
199
- projectId,
200
- to,
201
- userAddress
202
- }: 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
+
203
283
  return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
204
284
  path: `/v1/convert/build-approve`,
205
285
  headers: getHeaders(),
@@ -212,15 +292,29 @@ export const BlockchainApiController = {
212
292
  });
213
293
  },
214
294
 
215
- 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
+
216
310
  return state.api.get<BlockchainApiBalanceResponse>({
217
- path: `/v1/account/${address}/balance`,
311
+ path: `/v1/account/${plainAddress}/balance`,
218
312
  headers: getHeaders(),
219
313
  params: {
220
314
  currency: 'usd',
221
315
  projectId: OptionsController.state.projectId,
222
- chainId,
223
- forceUpdate
316
+ chainId: `${namespace}:${chain}`,
317
+ forceUpdate: forceUpdate?.join(',')
224
318
  }
225
319
  });
226
320
  },
@@ -236,6 +330,17 @@ export const BlockchainApiController = {
236
330
  });
237
331
  },
238
332
 
333
+ async fetchOnRampCountries() {
334
+ return await state.api.get<OnRampCountry[]>({
335
+ path: '/v1/onramp/providers/properties',
336
+ headers: getHeaders(),
337
+ params: {
338
+ projectId: OptionsController.state.projectId,
339
+ type: 'countries'
340
+ }
341
+ });
342
+ },
343
+
239
344
  async fetchOnRampServiceProviders() {
240
345
  return await state.api.get<OnRampServiceProvider[]>({
241
346
  path: '/v1/onramp/providers',
@@ -246,39 +351,48 @@ export const BlockchainApiController = {
246
351
  });
247
352
  },
248
353
 
249
- async fetchOnRampCountries() {
250
- return await this.fetchProperties<OnRampCountry[]>('countries');
251
- },
252
-
253
354
  async fetchOnRampPaymentMethods(params: { countries?: string }) {
254
- return await this.fetchProperties<OnRampPaymentMethod[]>('payment-methods', params);
355
+ return await state.api.get<OnRampPaymentMethod[]>({
356
+ path: '/v1/onramp/providers/properties',
357
+ headers: getHeaders(),
358
+ params: {
359
+ projectId: OptionsController.state.projectId,
360
+ type: 'payment-methods',
361
+ ...params
362
+ }
363
+ });
255
364
  },
256
365
 
257
366
  async fetchOnRampCryptoCurrencies(params: { countries?: string }) {
258
- return await this.fetchProperties<OnRampCryptoCurrency[]>('crypto-currencies', params);
367
+ return await state.api.get<OnRampCryptoCurrency[]>({
368
+ path: '/v1/onramp/providers/properties',
369
+ headers: getHeaders(),
370
+ params: {
371
+ projectId: OptionsController.state.projectId,
372
+ type: 'crypto-currencies',
373
+ ...params
374
+ }
375
+ });
259
376
  },
260
377
 
261
378
  async fetchOnRampFiatCurrencies() {
262
- return await this.fetchProperties<OnRampFiatCurrency[]>('fiat-currencies');
379
+ return await state.api.get<OnRampFiatCurrency[]>({
380
+ path: '/v1/onramp/providers/properties',
381
+ headers: getHeaders(),
382
+ params: {
383
+ projectId: OptionsController.state.projectId,
384
+ type: 'fiat-currencies'
385
+ }
386
+ });
263
387
  },
264
388
 
265
389
  async fetchOnRampFiatLimits() {
266
- return await this.fetchProperties<OnRampFiatLimit[]>('fiat-purchases-limits');
267
- },
268
-
269
- async fetchOnRampCountriesDefaults() {
270
- return await this.fetchProperties<OnRampCountryDefaults[]>('countries-defaults');
271
- },
272
-
273
- async fetchProperties<T>(type: string, params?: Record<string, string>) {
274
- return await state.api.get<T>({
390
+ return await state.api.get<OnRampFiatLimit[]>({
275
391
  path: '/v1/onramp/providers/properties',
276
392
  headers: getHeaders(),
277
393
  params: {
278
394
  projectId: OptionsController.state.projectId,
279
- type,
280
- excludeProviders: EXCLUDED_ONRAMP_PROVIDERS.join(','),
281
- ...params
395
+ type: 'fiat-purchases-limits'
282
396
  }
283
397
  });
284
398
  },
@@ -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');