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