@reown/appkit-core-react-native 0.0.0-fix-approved-networks-20250822000414 → 0.0.0-fix-ui-changes-20250828183750
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.
- package/lib/commonjs/controllers/ApiController.js +75 -38
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/AssetController.js +0 -4
- package/lib/commonjs/controllers/AssetController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +156 -57
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +402 -0
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js.map +1 -1
- package/lib/commonjs/controllers/ModalController.js +6 -7
- package/lib/commonjs/controllers/ModalController.js.map +1 -1
- package/lib/commonjs/controllers/OnRampController.js +29 -19
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +22 -7
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/PublicStateController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js +7 -22
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +96 -96
- package/lib/commonjs/controllers/SendController.js.map +1 -1
- package/lib/commonjs/controllers/SnackController.js +29 -5
- package/lib/commonjs/controllers/SnackController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +154 -151
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js +9 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +22 -18
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/controllers/WcController.js +73 -0
- package/lib/commonjs/controllers/WcController.js.map +1 -0
- package/lib/commonjs/index.js +13 -41
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/utils/ApiUtil.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js +8 -18
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +122 -5
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +19 -7
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/EventUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js.map +1 -1
- package/lib/commonjs/utils/RouterUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +90 -108
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +15 -21
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/commonjs/utils/WalletUtil.js +23 -0
- package/lib/commonjs/utils/WalletUtil.js.map +1 -0
- package/lib/module/controllers/ApiController.js +77 -38
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/AssetController.js +2 -4
- package/lib/module/controllers/AssetController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +158 -57
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +399 -0
- package/lib/module/controllers/ConnectionsController.js.map +1 -0
- package/lib/module/controllers/EnsController.js +2 -0
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +2 -0
- package/lib/module/controllers/EventsController.js.map +1 -1
- package/lib/module/controllers/ModalController.js +8 -7
- package/lib/module/controllers/ModalController.js.map +1 -1
- package/lib/module/controllers/OnRampController.js +27 -15
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +24 -7
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/PublicStateController.js +2 -0
- package/lib/module/controllers/PublicStateController.js.map +1 -1
- package/lib/module/controllers/RouterController.js +9 -22
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +98 -96
- package/lib/module/controllers/SendController.js.map +1 -1
- package/lib/module/controllers/SnackController.js +31 -5
- package/lib/module/controllers/SnackController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +156 -151
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +11 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +24 -18
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/controllers/WcController.js +70 -0
- package/lib/module/controllers/WcController.js.map +1 -0
- package/lib/module/index.js +7 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ApiUtil.js +2 -0
- package/lib/module/utils/ApiUtil.js.map +1 -1
- package/lib/module/utils/AssetUtil.js +10 -18
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +124 -5
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +21 -5
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/EventUtil.js +2 -0
- package/lib/module/utils/EventUtil.js.map +1 -1
- package/lib/module/utils/FetchUtil.js +2 -0
- package/lib/module/utils/FetchUtil.js.map +1 -1
- package/lib/module/utils/RouterUtil.js +2 -0
- package/lib/module/utils/RouterUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +93 -108
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +17 -21
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/utils/SwapCalculationUtil.js +3 -0
- package/lib/module/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/module/utils/WalletUtil.js +19 -0
- package/lib/module/utils/WalletUtil.js.map +1 -0
- package/lib/typescript/controllers/ApiController.d.ts +4 -5
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/AssetController.d.ts +0 -2
- package/lib/typescript/controllers/AssetController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +29 -11
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +45 -0
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
- package/lib/typescript/controllers/EnsController.d.ts +1 -1
- package/lib/typescript/controllers/EventsController.d.ts +1 -1
- package/lib/typescript/controllers/EventsController.d.ts.map +1 -1
- package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
- package/lib/typescript/controllers/OnRampController.d.ts +2 -2
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +9 -4
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts +1 -1
- package/lib/typescript/controllers/PublicStateController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +6 -20
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- package/lib/typescript/controllers/SendController.d.ts +5 -7
- package/lib/typescript/controllers/SendController.d.ts.map +1 -1
- package/lib/typescript/controllers/SnackController.d.ts +3 -3
- package/lib/typescript/controllers/SnackController.d.ts.map +1 -1
- package/lib/typescript/controllers/SwapController.d.ts +12 -12
- package/lib/typescript/controllers/SwapController.d.ts.map +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts +1 -1
- package/lib/typescript/controllers/ThemeController.d.ts.map +1 -1
- package/lib/typescript/controllers/TransactionsController.d.ts +3 -3
- package/lib/typescript/controllers/TransactionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/WcController.d.ts +27 -0
- package/lib/typescript/controllers/WcController.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/AssetUtil.d.ts +3 -4
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +12 -2
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +5 -4
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/EventUtil.d.ts +1 -1
- package/lib/typescript/utils/EventUtil.d.ts.map +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts +2 -2
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +15 -16
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapApiUtil.d.ts +3 -4
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapCalculationUtil.d.ts +1 -1
- package/lib/typescript/utils/SwapCalculationUtil.d.ts.map +1 -1
- package/lib/typescript/utils/WalletUtil.d.ts +5 -0
- package/lib/typescript/utils/WalletUtil.d.ts.map +1 -0
- package/package.json +8 -22
- package/src/controllers/ApiController.ts +83 -40
- package/src/controllers/AssetController.ts +0 -6
- package/src/controllers/BlockchainApiController.ts +136 -44
- package/src/controllers/ConnectionsController.ts +521 -0
- package/src/controllers/EnsController.ts +1 -1
- package/src/controllers/EventsController.ts +1 -1
- package/src/controllers/ModalController.ts +6 -7
- package/src/controllers/OnRampController.ts +37 -18
- package/src/controllers/OptionsController.ts +37 -14
- package/src/controllers/PublicStateController.ts +1 -1
- package/src/controllers/RouterController.ts +17 -54
- package/src/controllers/SendController.ts +122 -111
- package/src/controllers/SnackController.ts +31 -5
- package/src/controllers/SwapController.ts +177 -183
- package/src/controllers/ThemeController.ts +11 -2
- package/src/controllers/TransactionsController.ts +25 -19
- package/src/controllers/WcController.ts +93 -0
- package/src/index.ts +6 -20
- package/src/utils/AssetUtil.ts +9 -22
- package/src/utils/ConstantsUtil.ts +126 -6
- package/src/utils/CoreHelperUtil.ts +45 -7
- package/src/utils/EventUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +2 -2
- package/src/utils/StorageUtil.ts +163 -131
- package/src/utils/SwapApiUtil.ts +30 -37
- package/src/utils/SwapCalculationUtil.ts +1 -2
- package/src/utils/WalletUtil.ts +14 -0
- package/lib/commonjs/controllers/AccountController.js +0 -93
- package/lib/commonjs/controllers/AccountController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectionController.js +0 -126
- package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectorController.js +0 -49
- package/lib/commonjs/controllers/ConnectorController.js.map +0 -1
- package/lib/commonjs/controllers/NetworkController.js +0 -90
- package/lib/commonjs/controllers/NetworkController.js.map +0 -1
- package/lib/commonjs/controllers/WebviewController.js +0 -52
- package/lib/commonjs/controllers/WebviewController.js.map +0 -1
- package/lib/commonjs/utils/ConnectionUtil.js +0 -33
- package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
- package/lib/commonjs/utils/NetworkUtil.js +0 -46
- package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -35
- package/lib/commonjs/utils/TypeUtil.js.map +0 -1
- package/lib/module/controllers/AccountController.js +0 -88
- package/lib/module/controllers/AccountController.js.map +0 -1
- package/lib/module/controllers/ConnectionController.js +0 -121
- package/lib/module/controllers/ConnectionController.js.map +0 -1
- package/lib/module/controllers/ConnectorController.js +0 -44
- package/lib/module/controllers/ConnectorController.js.map +0 -1
- package/lib/module/controllers/NetworkController.js +0 -85
- package/lib/module/controllers/NetworkController.js.map +0 -1
- package/lib/module/controllers/WebviewController.js +0 -47
- package/lib/module/controllers/WebviewController.js.map +0 -1
- package/lib/module/utils/ConnectionUtil.js +0 -27
- package/lib/module/utils/ConnectionUtil.js.map +0 -1
- package/lib/module/utils/NetworkUtil.js +0 -40
- package/lib/module/utils/NetworkUtil.js.map +0 -1
- package/lib/module/utils/TypeUtil.js +0 -28
- package/lib/module/utils/TypeUtil.js.map +0 -1
- package/lib/typescript/controllers/AccountController.d.ts +0 -33
- package/lib/typescript/controllers/AccountController.d.ts.map +0 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +0 -66
- package/lib/typescript/controllers/ConnectionController.d.ts.map +0 -1
- package/lib/typescript/controllers/ConnectorController.d.ts +0 -18
- package/lib/typescript/controllers/ConnectorController.d.ts.map +0 -1
- package/lib/typescript/controllers/NetworkController.d.ts +0 -35
- package/lib/typescript/controllers/NetworkController.d.ts.map +0 -1
- package/lib/typescript/controllers/WebviewController.d.ts +0 -21
- package/lib/typescript/controllers/WebviewController.d.ts.map +0 -1
- package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
- package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +0 -8
- package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
- package/lib/typescript/utils/TypeUtil.d.ts +0 -850
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
- package/src/controllers/AccountController.ts +0 -128
- package/src/controllers/ConnectionController.ts +0 -200
- package/src/controllers/ConnectorController.ts +0 -63
- package/src/controllers/NetworkController.ts +0 -120
- package/src/controllers/WebviewController.ts +0 -63
- package/src/utils/ConnectionUtil.ts +0 -27
- package/src/utils/NetworkUtil.ts +0 -33
- package/src/utils/TypeUtil.ts +0 -1039
|
@@ -4,20 +4,21 @@ import { proxy } from 'valtio';
|
|
|
4
4
|
import { CoreHelperUtil } from '../utils/CoreHelperUtil';
|
|
5
5
|
import { FetchUtil } from '../utils/FetchUtil';
|
|
6
6
|
import { StorageUtil } from '../utils/StorageUtil';
|
|
7
|
-
import
|
|
8
|
-
ApiGetAnalyticsConfigResponse,
|
|
9
|
-
ApiGetDataWalletsResponse,
|
|
10
|
-
ApiGetWalletsRequest,
|
|
11
|
-
ApiGetWalletsResponse,
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import {
|
|
8
|
+
type ApiGetAnalyticsConfigResponse,
|
|
9
|
+
type ApiGetDataWalletsResponse,
|
|
10
|
+
type ApiGetWalletsRequest,
|
|
11
|
+
type ApiGetWalletsResponse,
|
|
12
|
+
type CustomWallet,
|
|
13
|
+
type WcWallet,
|
|
14
|
+
PresetsUtil
|
|
15
|
+
} from '@reown/appkit-common-react-native';
|
|
14
16
|
import { AssetController } from './AssetController';
|
|
15
|
-
import { NetworkController } from './NetworkController';
|
|
16
17
|
import { OptionsController } from './OptionsController';
|
|
17
|
-
import {
|
|
18
|
-
import { ConnectionController } from './ConnectionController';
|
|
18
|
+
import { WcController } from './WcController';
|
|
19
19
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
20
20
|
import { SnackController } from './SnackController';
|
|
21
|
+
import { ConnectionsController } from './ConnectionsController';
|
|
21
22
|
|
|
22
23
|
// -- Helpers ------------------------------------------- //
|
|
23
24
|
const baseUrl = CoreHelperUtil.getApiUrl();
|
|
@@ -84,42 +85,30 @@ export const ApiController = {
|
|
|
84
85
|
}
|
|
85
86
|
},
|
|
86
87
|
|
|
87
|
-
async
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
AssetController.setConnectorImage(imageId, url);
|
|
88
|
+
async _fetchNetworkImage(networkId: string) {
|
|
89
|
+
const imageId = PresetsUtil.NetworkImageIds[networkId];
|
|
90
|
+
if (!imageId) {
|
|
91
|
+
return;
|
|
92
92
|
}
|
|
93
|
-
},
|
|
94
93
|
|
|
95
|
-
async _fetchNetworkImage(imageId: string) {
|
|
96
94
|
const headers = ApiController._getApiHeaders();
|
|
97
95
|
const url = await api.fetchImage(`/public/getAssetImage/${imageId}`, headers);
|
|
98
96
|
if (url) {
|
|
99
|
-
AssetController.setNetworkImage(
|
|
97
|
+
AssetController.setNetworkImage(networkId, url);
|
|
100
98
|
}
|
|
101
99
|
},
|
|
102
100
|
|
|
103
|
-
async fetchConnectorImages() {
|
|
104
|
-
const { connectors } = ConnectorController.state;
|
|
105
|
-
const ids = connectors.map(({ imageId }) => imageId).filter(Boolean);
|
|
106
|
-
await CoreHelperUtil.allSettled(
|
|
107
|
-
(ids as string[]).map(id => ApiController._fetchConnectorImage(id))
|
|
108
|
-
);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
101
|
async fetchNetworkImages() {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
if (ids) {
|
|
102
|
+
const networks = ConnectionsController.state.networks;
|
|
103
|
+
if (networks) {
|
|
115
104
|
await CoreHelperUtil.allSettled(
|
|
116
|
-
|
|
105
|
+
networks.map(network => ApiController._fetchNetworkImage(network.id as string))
|
|
117
106
|
);
|
|
118
107
|
}
|
|
119
108
|
},
|
|
120
109
|
|
|
121
110
|
async fetchInstalledWallets() {
|
|
122
|
-
const { includeWalletIds } = OptionsController.state;
|
|
111
|
+
const { includeWalletIds, customWallets } = OptionsController.state;
|
|
123
112
|
const path = Platform.select({ default: 'getIosData', android: 'getAndroidData' });
|
|
124
113
|
const response = await api.get<ApiGetDataWalletsResponse>({
|
|
125
114
|
path,
|
|
@@ -141,10 +130,20 @@ export const ApiController = {
|
|
|
141
130
|
};
|
|
142
131
|
});
|
|
143
132
|
|
|
133
|
+
const customPromises = customWallets?.map(async item => {
|
|
134
|
+
return {
|
|
135
|
+
id: item.id,
|
|
136
|
+
isInstalled: await CoreHelperUtil.checkInstalled(item)
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
|
|
144
140
|
const results = await Promise.all(promises);
|
|
145
141
|
const installed = results.filter(({ isInstalled }) => isInstalled).map(({ id }) => id);
|
|
146
142
|
const { excludeWalletIds } = OptionsController.state;
|
|
143
|
+
const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
|
|
147
144
|
|
|
145
|
+
// Collect API-sourced installed wallets
|
|
146
|
+
let apiInstalledWallets: WcWallet[] = [];
|
|
148
147
|
if (installed.length > 0) {
|
|
149
148
|
const walletResponse = await api.get<ApiGetWalletsResponse>({
|
|
150
149
|
path: '/getWallets',
|
|
@@ -154,7 +153,8 @@ export const ApiController = {
|
|
|
154
153
|
platform: this.platform(),
|
|
155
154
|
entries: installed?.length.toString(),
|
|
156
155
|
include: installed?.join(','),
|
|
157
|
-
exclude: excludeWalletIds?.join(',')
|
|
156
|
+
exclude: excludeWalletIds?.join(','),
|
|
157
|
+
chains: chains.join(',')
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
|
|
@@ -163,15 +163,39 @@ export const ApiController = {
|
|
|
163
163
|
await CoreHelperUtil.allSettled(
|
|
164
164
|
(walletImages as string[]).map(id => ApiController._fetchWalletImage(id))
|
|
165
165
|
);
|
|
166
|
-
|
|
167
|
-
this.updateRecentWalletsInfo(walletResponse.data);
|
|
166
|
+
apiInstalledWallets = walletResponse.data;
|
|
168
167
|
}
|
|
169
168
|
}
|
|
169
|
+
|
|
170
|
+
// Collect custom installed wallets
|
|
171
|
+
let customInstalledWallets: CustomWallet[] = [];
|
|
172
|
+
if (customPromises?.length) {
|
|
173
|
+
const customResults = await Promise.all(customPromises);
|
|
174
|
+
const customInstalled = customResults
|
|
175
|
+
.filter(({ isInstalled }) => isInstalled)
|
|
176
|
+
.map(({ id }) => id);
|
|
177
|
+
customInstalledWallets =
|
|
178
|
+
customWallets?.filter(wallet => customInstalled.includes(wallet.id)) ?? [];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Merge and de-duplicate by id, preserving order (API first, then custom)
|
|
182
|
+
const byId = new Map<string, WcWallet>();
|
|
183
|
+
[...apiInstalledWallets, ...customInstalledWallets].forEach(wallet => {
|
|
184
|
+
if (!byId.has(wallet.id)) {
|
|
185
|
+
byId.set(wallet.id, wallet);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
const combinedInstalled = Array.from(byId.values());
|
|
189
|
+
state.installed = combinedInstalled;
|
|
190
|
+
if (combinedInstalled.length) {
|
|
191
|
+
this.updateRecentWalletsInfo(combinedInstalled);
|
|
192
|
+
}
|
|
170
193
|
},
|
|
171
194
|
|
|
172
195
|
async fetchFeaturedWallets() {
|
|
173
196
|
const { featuredWalletIds } = OptionsController.state;
|
|
174
197
|
const exclude = state.installed.map(({ id }) => id);
|
|
198
|
+
const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
|
|
175
199
|
|
|
176
200
|
if (featuredWalletIds?.length) {
|
|
177
201
|
const response = await api.get<ApiGetWalletsResponse>({
|
|
@@ -184,7 +208,8 @@ export const ApiController = {
|
|
|
184
208
|
? String(featuredWalletIds.length)
|
|
185
209
|
: recommendedEntries,
|
|
186
210
|
include: featuredWalletIds?.join(','),
|
|
187
|
-
exclude: exclude?.join(',')
|
|
211
|
+
exclude: exclude?.join(','),
|
|
212
|
+
chains: chains.join(',')
|
|
188
213
|
}
|
|
189
214
|
});
|
|
190
215
|
if (!response) return;
|
|
@@ -201,9 +226,22 @@ export const ApiController = {
|
|
|
201
226
|
}
|
|
202
227
|
},
|
|
203
228
|
|
|
229
|
+
async fetchCustomWalletImages() {
|
|
230
|
+
const { customWallets } = OptionsController.state;
|
|
231
|
+
if (!customWallets?.length) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const images = customWallets.map(w => w.image_id).filter(Boolean);
|
|
236
|
+
await CoreHelperUtil.allSettled(
|
|
237
|
+
(images as string[]).map(id => ApiController._fetchWalletImage(id))
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
|
|
204
241
|
async fetchRecommendedWallets() {
|
|
205
242
|
const { installed } = ApiController.state;
|
|
206
243
|
const { includeWalletIds, excludeWalletIds, featuredWalletIds } = OptionsController.state;
|
|
244
|
+
const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
|
|
207
245
|
|
|
208
246
|
const exclude = [
|
|
209
247
|
...installed.map(({ id }) => id),
|
|
@@ -219,7 +257,8 @@ export const ApiController = {
|
|
|
219
257
|
platform: this.platform(),
|
|
220
258
|
entries: recommendedEntries,
|
|
221
259
|
include: includeWalletIds?.join(','),
|
|
222
|
-
exclude: exclude?.join(',')
|
|
260
|
+
exclude: exclude?.join(','),
|
|
261
|
+
chains: chains.join(',')
|
|
223
262
|
}
|
|
224
263
|
});
|
|
225
264
|
|
|
@@ -242,6 +281,7 @@ export const ApiController = {
|
|
|
242
281
|
|
|
243
282
|
async fetchWallets({ page }: Pick<ApiGetWalletsRequest, 'page'>) {
|
|
244
283
|
const { includeWalletIds, excludeWalletIds, featuredWalletIds } = OptionsController.state;
|
|
284
|
+
const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
|
|
245
285
|
const exclude = [
|
|
246
286
|
...state.installed.map(({ id }) => id),
|
|
247
287
|
...state.recommended.map(({ id }) => id),
|
|
@@ -256,7 +296,8 @@ export const ApiController = {
|
|
|
256
296
|
platform: this.platform(),
|
|
257
297
|
entries: String(defaultEntries),
|
|
258
298
|
include: includeWalletIds?.join(','),
|
|
259
|
-
exclude: exclude.join(',')
|
|
299
|
+
exclude: exclude.join(','),
|
|
300
|
+
chains: chains.join(',')
|
|
260
301
|
}
|
|
261
302
|
});
|
|
262
303
|
|
|
@@ -279,6 +320,7 @@ export const ApiController = {
|
|
|
279
320
|
|
|
280
321
|
async searchWallet({ search }: Pick<ApiGetWalletsRequest, 'search'>) {
|
|
281
322
|
const { includeWalletIds, excludeWalletIds } = OptionsController.state;
|
|
323
|
+
const chains = CoreHelperUtil.getRequestedCaipNetworkIds();
|
|
282
324
|
state.search = [];
|
|
283
325
|
const response = await api.get<ApiGetWalletsResponse>({
|
|
284
326
|
path: '/getWallets',
|
|
@@ -289,7 +331,8 @@ export const ApiController = {
|
|
|
289
331
|
entries: String(defaultEntries),
|
|
290
332
|
search,
|
|
291
333
|
include: includeWalletIds?.join(','),
|
|
292
|
-
exclude: excludeWalletIds?.join(',')
|
|
334
|
+
exclude: excludeWalletIds?.join(','),
|
|
335
|
+
chains: chains.join(',')
|
|
293
336
|
}
|
|
294
337
|
});
|
|
295
338
|
|
|
@@ -324,7 +367,7 @@ export const ApiController = {
|
|
|
324
367
|
|
|
325
368
|
if (update) {
|
|
326
369
|
await StorageUtil.setRecentWallets(updatedRecent);
|
|
327
|
-
|
|
370
|
+
WcController.setRecentWallets(updatedRecent);
|
|
328
371
|
}
|
|
329
372
|
},
|
|
330
373
|
|
|
@@ -339,7 +382,7 @@ export const ApiController = {
|
|
|
339
382
|
ApiController.fetchFeaturedWallets(),
|
|
340
383
|
ApiController.fetchRecommendedWallets(),
|
|
341
384
|
ApiController.fetchNetworkImages(),
|
|
342
|
-
ApiController.
|
|
385
|
+
ApiController.fetchCustomWalletImages()
|
|
343
386
|
];
|
|
344
387
|
if (OptionsController.state.enableAnalytics === undefined) {
|
|
345
388
|
promises.push(ApiController.fetchAnalyticsConfig());
|
|
@@ -4,7 +4,6 @@ import { proxy } from 'valtio';
|
|
|
4
4
|
export interface AssetControllerState {
|
|
5
5
|
walletImages: Record<string, string>;
|
|
6
6
|
networkImages: Record<string, string>;
|
|
7
|
-
connectorImages: Record<string, string>;
|
|
8
7
|
tokenImages: Record<string, string>;
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -12,7 +11,6 @@ export interface AssetControllerState {
|
|
|
12
11
|
const state = proxy<AssetControllerState>({
|
|
13
12
|
walletImages: {},
|
|
14
13
|
networkImages: {},
|
|
15
|
-
connectorImages: {},
|
|
16
14
|
tokenImages: {}
|
|
17
15
|
});
|
|
18
16
|
|
|
@@ -28,10 +26,6 @@ export const AssetController = {
|
|
|
28
26
|
state.networkImages[key] = value;
|
|
29
27
|
},
|
|
30
28
|
|
|
31
|
-
setConnectorImage(key: string, value: string) {
|
|
32
|
-
state.connectorImages[key] = value;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
29
|
setTokenImage(key: string, value: string) {
|
|
36
30
|
state.tokenImages[key] = value;
|
|
37
31
|
}
|
|
@@ -33,12 +33,16 @@ import type {
|
|
|
33
33
|
BlockchainApiOnRampWidgetRequest,
|
|
34
34
|
BlockchainApiOnRampQuotesRequest,
|
|
35
35
|
OnRampFiatLimit,
|
|
36
|
-
OnRampCountryDefaults
|
|
37
|
-
|
|
36
|
+
OnRampCountryDefaults,
|
|
37
|
+
CaipAddress,
|
|
38
|
+
CaipNetworkId
|
|
39
|
+
} from '@reown/appkit-common-react-native';
|
|
38
40
|
import { OptionsController } from './OptionsController';
|
|
39
41
|
import { ConstantsUtil } from '../utils/ConstantsUtil';
|
|
40
42
|
import { ApiUtil } from '../utils/ApiUtil';
|
|
41
43
|
|
|
44
|
+
import { SnackController } from './SnackController';
|
|
45
|
+
|
|
42
46
|
// -- Helpers ------------------------------------------- //
|
|
43
47
|
const baseUrl = CoreHelperUtil.getBlockchainApiUrl();
|
|
44
48
|
|
|
@@ -57,22 +61,53 @@ const getHeaders = () => {
|
|
|
57
61
|
export const EXCLUDED_ONRAMP_PROVIDERS = ['BINANCECONNECT', 'COINBASEPAY'];
|
|
58
62
|
|
|
59
63
|
// -- Types --------------------------------------------- //
|
|
64
|
+
type WithCaipNetworkId = { caipNetworkId: CaipNetworkId };
|
|
65
|
+
|
|
60
66
|
export interface BlockchainApiControllerState {
|
|
61
67
|
clientId: string | null;
|
|
62
68
|
api: FetchUtil;
|
|
69
|
+
supportedChains: { http: CaipNetworkId[]; ws: CaipNetworkId[] };
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
// -- State --------------------------------------------- //
|
|
66
73
|
const state = proxy<BlockchainApiControllerState>({
|
|
67
74
|
clientId: null,
|
|
68
|
-
api: new FetchUtil({ baseUrl })
|
|
75
|
+
api: new FetchUtil({ baseUrl }),
|
|
76
|
+
supportedChains: { http: [], ws: [] }
|
|
69
77
|
});
|
|
70
78
|
|
|
71
79
|
// -- Controller ---------------------------------------- //
|
|
72
80
|
export const BlockchainApiController = {
|
|
73
81
|
state,
|
|
74
82
|
|
|
75
|
-
|
|
83
|
+
async isNetworkSupported(networkId?: CaipNetworkId) {
|
|
84
|
+
if (!networkId) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
if (!state.supportedChains.http.length) {
|
|
89
|
+
await BlockchainApiController.getSupportedNetworks();
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return state.supportedChains.http.includes(networkId);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
async getSupportedNetworks() {
|
|
99
|
+
const supportedChains = await state.api.get<BlockchainApiControllerState['supportedChains']>({
|
|
100
|
+
path: 'v1/supported-chains'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
state.supportedChains = supportedChains!;
|
|
104
|
+
|
|
105
|
+
return supportedChains;
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
async fetchIdentity(params: BlockchainApiIdentityRequest) {
|
|
109
|
+
const { address } = params;
|
|
110
|
+
|
|
76
111
|
return state.api.get<BlockchainApiIdentityResponse>({
|
|
77
112
|
path: `/v1/identity/${address}`,
|
|
78
113
|
params: {
|
|
@@ -82,29 +117,38 @@ export const BlockchainApiController = {
|
|
|
82
117
|
});
|
|
83
118
|
},
|
|
84
119
|
|
|
85
|
-
fetchTransactions({
|
|
86
|
-
account,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
120
|
+
async fetchTransactions(params: BlockchainApiTransactionsRequest) {
|
|
121
|
+
const { account, projectId, cursor, signal, cache, chainId } = params;
|
|
122
|
+
const isSupported = await BlockchainApiController.isNetworkSupported(chainId);
|
|
123
|
+
|
|
124
|
+
if (!isSupported) {
|
|
125
|
+
return { data: [], next: undefined };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const response = await state.api.get<BlockchainApiTransactionsResponse>({
|
|
94
129
|
path: `/v1/account/${account}/history`,
|
|
95
130
|
headers: getHeaders(),
|
|
96
131
|
params: {
|
|
97
132
|
projectId,
|
|
98
133
|
cursor,
|
|
99
|
-
|
|
134
|
+
chainId
|
|
100
135
|
},
|
|
101
136
|
signal,
|
|
102
137
|
cache
|
|
103
138
|
});
|
|
139
|
+
|
|
140
|
+
return response;
|
|
104
141
|
},
|
|
105
142
|
|
|
106
|
-
fetchTokenPrice(
|
|
107
|
-
|
|
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>({
|
|
108
152
|
path: '/v1/fungible/price',
|
|
109
153
|
body: {
|
|
110
154
|
projectId,
|
|
@@ -113,9 +157,20 @@ export const BlockchainApiController = {
|
|
|
113
157
|
},
|
|
114
158
|
headers: getHeaders()
|
|
115
159
|
});
|
|
160
|
+
|
|
161
|
+
return response;
|
|
116
162
|
},
|
|
117
163
|
|
|
118
|
-
fetchSwapAllowance(
|
|
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
|
+
|
|
119
174
|
return state.api.get<BlockchainApiSwapAllowanceResponse>({
|
|
120
175
|
path: `/v1/convert/allowance`,
|
|
121
176
|
params: {
|
|
@@ -127,7 +182,14 @@ export const BlockchainApiController = {
|
|
|
127
182
|
});
|
|
128
183
|
},
|
|
129
184
|
|
|
130
|
-
fetchGasPrice(
|
|
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
|
+
|
|
131
193
|
return state.api.get<BlockchainApiGasPriceResponse>({
|
|
132
194
|
path: `/v1/convert/gas-price`,
|
|
133
195
|
headers: getHeaders(),
|
|
@@ -138,14 +200,16 @@ export const BlockchainApiController = {
|
|
|
138
200
|
});
|
|
139
201
|
},
|
|
140
202
|
|
|
141
|
-
fetchSwapQuote({
|
|
142
|
-
projectId,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
|
|
149
213
|
return state.api.get<BlockchainApiSwapQuoteResponse>({
|
|
150
214
|
path: `/v1/convert/quotes`,
|
|
151
215
|
headers: getHeaders(),
|
|
@@ -160,7 +224,14 @@ export const BlockchainApiController = {
|
|
|
160
224
|
});
|
|
161
225
|
},
|
|
162
226
|
|
|
163
|
-
fetchSwapTokens(
|
|
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
|
+
|
|
164
235
|
return state.api.get<BlockchainApiSwapTokensResponse>({
|
|
165
236
|
path: `/v1/convert/tokens`,
|
|
166
237
|
headers: getHeaders(),
|
|
@@ -171,13 +242,16 @@ export const BlockchainApiController = {
|
|
|
171
242
|
});
|
|
172
243
|
},
|
|
173
244
|
|
|
174
|
-
generateSwapCalldata({
|
|
175
|
-
amount,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
|
|
181
255
|
return state.api.post<BlockchainApiGenerateSwapCalldataResponse>({
|
|
182
256
|
path: '/v1/convert/build-transaction',
|
|
183
257
|
headers: getHeaders(),
|
|
@@ -194,12 +268,16 @@ export const BlockchainApiController = {
|
|
|
194
268
|
});
|
|
195
269
|
},
|
|
196
270
|
|
|
197
|
-
generateApproveCalldata({
|
|
198
|
-
from,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
+
|
|
203
281
|
return state.api.get<BlockchainApiGenerateApproveCalldataResponse>({
|
|
204
282
|
path: `/v1/convert/build-approve`,
|
|
205
283
|
headers: getHeaders(),
|
|
@@ -212,15 +290,29 @@ export const BlockchainApiController = {
|
|
|
212
290
|
});
|
|
213
291
|
},
|
|
214
292
|
|
|
215
|
-
async getBalance(address
|
|
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
|
+
|
|
216
308
|
return state.api.get<BlockchainApiBalanceResponse>({
|
|
217
|
-
path: `/v1/account/${
|
|
309
|
+
path: `/v1/account/${plainAddress}/balance`,
|
|
218
310
|
headers: getHeaders(),
|
|
219
311
|
params: {
|
|
220
312
|
currency: 'usd',
|
|
221
313
|
projectId: OptionsController.state.projectId,
|
|
222
|
-
chainId
|
|
223
|
-
forceUpdate
|
|
314
|
+
chainId: `${namespace}:${chain}`,
|
|
315
|
+
forceUpdate: forceUpdate?.join(',')
|
|
224
316
|
}
|
|
225
317
|
});
|
|
226
318
|
},
|