@reown/appkit-core-react-native 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +16 -21
- 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 +102 -112
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +248 -51
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -1
- package/lib/commonjs/controllers/EnsController.js +4 -4
- package/lib/commonjs/controllers/EnsController.js.map +1 -1
- package/lib/commonjs/controllers/EventsController.js +4 -4
- 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 +117 -53
- package/lib/commonjs/controllers/OnRampController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +10 -4
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/PublicStateController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js +6 -21
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SendController.js +100 -100
- 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 +109 -117
- package/lib/commonjs/controllers/SwapController.js.map +1 -1
- package/lib/commonjs/controllers/ThemeController.js.map +1 -1
- package/lib/commonjs/controllers/TransactionsController.js +23 -19
- 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 +3 -38
- 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 +6 -14
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +13 -425
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js +13 -8
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/EventUtil.js.map +1 -1
- package/lib/commonjs/utils/FetchUtil.js +34 -10
- package/lib/commonjs/utils/FetchUtil.js.map +1 -1
- package/lib/commonjs/utils/RouterUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +77 -129
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +2 -17
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapCalculationUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +17 -21
- 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 +103 -111
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +250 -51
- package/lib/module/controllers/ConnectionsController.js.map +1 -1
- package/lib/module/controllers/EnsController.js +4 -2
- package/lib/module/controllers/EnsController.js.map +1 -1
- package/lib/module/controllers/EventsController.js +3 -1
- 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 +118 -52
- package/lib/module/controllers/OnRampController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +12 -4
- 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 +8 -21
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SendController.js +99 -97
- 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 +111 -117
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +2 -0
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +23 -17
- 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 +5 -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 +8 -14
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +15 -425
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js +15 -6
- 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 +36 -10
- 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 +80 -129
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +4 -17
- 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/typescript/controllers/ApiController.d.ts +3 -4
- 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 +21 -13
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +19 -17
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -1
- 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 +1 -1
- package/lib/typescript/controllers/ModalController.d.ts.map +1 -1
- package/lib/typescript/controllers/OnRampController.d.ts +4 -3
- package/lib/typescript/controllers/OnRampController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +4 -4
- package/lib/typescript/controllers/OptionsController.d.ts.map +1 -1
- package/lib/typescript/controllers/RouterController.d.ts +5 -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 +11 -11
- package/lib/typescript/controllers/SwapController.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 +1 -7
- 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 +7 -415
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +4 -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 +1 -1
- package/lib/typescript/utils/FetchUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +8 -19
- 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/package.json +9 -23
- package/src/controllers/ApiController.ts +24 -28
- package/src/controllers/AssetController.ts +0 -6
- package/src/controllers/BlockchainApiController.ts +76 -121
- package/src/controllers/ConnectionsController.ts +308 -78
- package/src/controllers/EnsController.ts +3 -3
- package/src/controllers/EventsController.ts +2 -2
- package/src/controllers/ModalController.ts +7 -9
- package/src/controllers/OnRampController.ts +179 -82
- package/src/controllers/OptionsController.ts +24 -8
- package/src/controllers/RouterController.ts +12 -54
- package/src/controllers/SendController.ts +123 -112
- package/src/controllers/SnackController.ts +31 -5
- package/src/controllers/SwapController.ts +130 -146
- package/src/controllers/TransactionsController.ts +24 -18
- package/src/controllers/WcController.ts +93 -0
- package/src/index.ts +2 -21
- package/src/utils/AssetUtil.ts +7 -17
- package/src/utils/ConstantsUtil.ts +15 -429
- package/src/utils/CoreHelperUtil.ts +31 -8
- package/src/utils/EventUtil.ts +1 -1
- package/src/utils/FetchUtil.ts +38 -11
- package/src/utils/StorageUtil.ts +146 -157
- package/src/utils/SwapApiUtil.ts +18 -37
- package/src/utils/SwapCalculationUtil.ts +1 -2
- package/lib/commonjs/controllers/AccountController.js +0 -93
- package/lib/commonjs/controllers/AccountController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectionController.js +0 -132
- package/lib/commonjs/controllers/ConnectionController.js.map +0 -1
- package/lib/commonjs/controllers/ConnectorController.js +0 -50
- 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/NetworkUtil.js +0 -46
- package/lib/commonjs/utils/NetworkUtil.js.map +0 -1
- package/lib/commonjs/utils/TypeUtil.js +0 -6
- 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 -127
- package/lib/module/controllers/ConnectionController.js.map +0 -1
- package/lib/module/controllers/ConnectorController.js +0 -45
- 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/NetworkUtil.js +0 -40
- package/lib/module/utils/NetworkUtil.js.map +0 -1
- package/lib/module/utils/TypeUtil.js +0 -2
- 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 -68
- 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 -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/NetworkUtil.d.ts +0 -8
- package/lib/typescript/utils/NetworkUtil.d.ts.map +0 -1
- package/lib/typescript/utils/TypeUtil.d.ts +0 -817
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
- package/src/controllers/AccountController.ts +0 -128
- package/src/controllers/ConnectionController.ts +0 -208
- package/src/controllers/ConnectorController.ts +0 -64
- package/src/controllers/NetworkController.ts +0 -120
- package/src/controllers/WebviewController.ts +0 -63
- package/src/utils/NetworkUtil.ts +0 -33
- package/src/utils/TypeUtil.ts +0 -995
package/src/utils/FetchUtil.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestCache } from '
|
|
1
|
+
import type { RequestCache } from '@reown/appkit-common-react-native';
|
|
2
2
|
|
|
3
3
|
// -- Types ----------------------------------------------------------------------
|
|
4
4
|
interface Options {
|
|
@@ -88,26 +88,53 @@ export class FetchUtil {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
private createUrl({ path, params }: RequestArguments) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
let fullUrl: string;
|
|
92
|
+
|
|
93
|
+
const isAbsoluteUrl = path.startsWith('http://') || path.startsWith('https://');
|
|
94
|
+
|
|
95
|
+
if (isAbsoluteUrl) {
|
|
96
|
+
fullUrl = path;
|
|
97
|
+
} else {
|
|
98
|
+
const baseUrl = this.baseUrl.endsWith('/') ? this.baseUrl : `${this.baseUrl}/`;
|
|
99
|
+
const pathUrl = path.startsWith('/') ? path.substring(1) : path;
|
|
100
|
+
fullUrl = `${baseUrl}${pathUrl}`;
|
|
98
101
|
}
|
|
99
102
|
|
|
103
|
+
const allParams: Record<string, string | undefined> = { ...params };
|
|
100
104
|
if (this.clientId) {
|
|
101
|
-
|
|
105
|
+
allParams['clientId'] = this.clientId;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const queryParams: string[] = [];
|
|
109
|
+
for (const key in allParams) {
|
|
110
|
+
const value = allParams[key];
|
|
111
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
112
|
+
queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (queryParams.length > 0) {
|
|
117
|
+
const queryString = queryParams.join('&');
|
|
118
|
+
if (fullUrl.includes('?')) {
|
|
119
|
+
fullUrl = `${fullUrl}&${queryString}`;
|
|
120
|
+
} else {
|
|
121
|
+
fullUrl = `${fullUrl}?${queryString}`;
|
|
122
|
+
}
|
|
102
123
|
}
|
|
103
124
|
|
|
104
|
-
return
|
|
125
|
+
return fullUrl;
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
private async processResponse<T>(response: Response) {
|
|
108
129
|
if (!response.ok) {
|
|
109
130
|
if (response.headers.get('content-type')?.includes('application/json')) {
|
|
110
|
-
|
|
131
|
+
try {
|
|
132
|
+
const errorData = await response.json();
|
|
133
|
+
|
|
134
|
+
return Promise.reject(errorData);
|
|
135
|
+
} catch (jsonError) {
|
|
136
|
+
return Promise.reject(`Code: ${response.status} - ${response.statusText}`);
|
|
137
|
+
}
|
|
111
138
|
}
|
|
112
139
|
|
|
113
140
|
const errorText = await response.text();
|
package/src/utils/StorageUtil.ts
CHANGED
|
@@ -1,40 +1,27 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
-
import type {
|
|
4
|
-
OnRampCountry,
|
|
5
|
-
OnRampFiatCurrency,
|
|
6
|
-
OnRampFiatLimit,
|
|
7
|
-
OnRampServiceProvider,
|
|
8
|
-
WcWallet
|
|
9
|
-
} from './TypeUtil';
|
|
10
2
|
import {
|
|
3
|
+
type OnRampCountry,
|
|
4
|
+
type OnRampFiatCurrency,
|
|
5
|
+
type OnRampFiatLimit,
|
|
6
|
+
type OnRampServiceProvider,
|
|
7
|
+
type OnRampCountryDefaults,
|
|
8
|
+
type WcWallet,
|
|
11
9
|
DateUtil,
|
|
12
|
-
type SocialProvider,
|
|
13
|
-
type New_ConnectorType,
|
|
14
10
|
type ConnectorType,
|
|
15
|
-
type ChainNamespace
|
|
11
|
+
type ChainNamespace,
|
|
12
|
+
type WalletDeepLink,
|
|
13
|
+
ConstantsUtil
|
|
16
14
|
} from '@reown/appkit-common-react-native';
|
|
17
|
-
|
|
18
|
-
// -- Helpers -----------------------------------------------------------------
|
|
19
|
-
const WC_DEEPLINK = 'WALLETCONNECT_DEEPLINK_CHOICE';
|
|
20
|
-
const RECENT_WALLET = '@w3m/recent';
|
|
21
|
-
const CONNECTED_WALLET_IMAGE_URL = '@w3m/connected_wallet_image_url';
|
|
22
|
-
const CONNECTED_CONNECTOR = '@w3m/connected_connector';
|
|
23
|
-
const CONNECTED_CONNECTORS = '@appkit/connected_connectors';
|
|
24
|
-
const CONNECTED_SOCIAL = '@appkit/connected_social';
|
|
25
|
-
const ONRAMP_PREFERRED_COUNTRY = '@appkit/onramp_preferred_country';
|
|
26
|
-
const ONRAMP_COUNTRIES = '@appkit/onramp_countries';
|
|
27
|
-
const ONRAMP_SERVICE_PROVIDERS = '@appkit/onramp_service_providers';
|
|
28
|
-
const ONRAMP_FIAT_LIMITS = '@appkit/onramp_fiat_limits';
|
|
29
|
-
const ONRAMP_FIAT_CURRENCIES = '@appkit/onramp_fiat_currencies';
|
|
30
|
-
const ONRAMP_PREFERRED_FIAT_CURRENCY = '@appkit/onramp_preferred_fiat_currency';
|
|
31
|
-
const ACTIVE_NAMESPACE = '@appkit/active_namespace';
|
|
15
|
+
import { OptionsController } from '../controllers/OptionsController';
|
|
32
16
|
|
|
33
17
|
// -- Utility -----------------------------------------------------------------
|
|
34
18
|
export const StorageUtil = {
|
|
35
|
-
setWalletConnectDeepLink({ href, name }:
|
|
19
|
+
setWalletConnectDeepLink({ href, name }: WalletDeepLink) {
|
|
36
20
|
try {
|
|
37
|
-
|
|
21
|
+
OptionsController.getStorage().setItem(ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK, {
|
|
22
|
+
href,
|
|
23
|
+
name
|
|
24
|
+
});
|
|
38
25
|
} catch {
|
|
39
26
|
console.info('Unable to set WalletConnect deep link');
|
|
40
27
|
}
|
|
@@ -42,9 +29,11 @@ export const StorageUtil = {
|
|
|
42
29
|
|
|
43
30
|
async getWalletConnectDeepLink() {
|
|
44
31
|
try {
|
|
45
|
-
const deepLink = await
|
|
32
|
+
const deepLink = await OptionsController.getStorage().getItem<WalletDeepLink>(
|
|
33
|
+
ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK
|
|
34
|
+
);
|
|
46
35
|
if (deepLink) {
|
|
47
|
-
return
|
|
36
|
+
return deepLink;
|
|
48
37
|
}
|
|
49
38
|
} catch {
|
|
50
39
|
console.info('Unable to get WalletConnect deep link');
|
|
@@ -55,9 +44,9 @@ export const StorageUtil = {
|
|
|
55
44
|
|
|
56
45
|
async removeWalletConnectDeepLink() {
|
|
57
46
|
try {
|
|
58
|
-
await
|
|
47
|
+
await OptionsController.getStorage().removeItem(ConstantsUtil.STORAGE_KEYS.WC_DEEPLINK);
|
|
59
48
|
} catch {
|
|
60
|
-
console.info('Unable to
|
|
49
|
+
console.info('Unable to remove WalletConnect deep link');
|
|
61
50
|
}
|
|
62
51
|
},
|
|
63
52
|
|
|
@@ -74,7 +63,10 @@ export const StorageUtil = {
|
|
|
74
63
|
if (recentWallets.length > 2) {
|
|
75
64
|
recentWallets.pop();
|
|
76
65
|
}
|
|
77
|
-
|
|
66
|
+
OptionsController.getStorage().setItem(
|
|
67
|
+
ConstantsUtil.STORAGE_KEYS.RECENT_WALLET,
|
|
68
|
+
recentWallets
|
|
69
|
+
);
|
|
78
70
|
|
|
79
71
|
return recentWallets;
|
|
80
72
|
} catch {
|
|
@@ -86,7 +78,10 @@ export const StorageUtil = {
|
|
|
86
78
|
|
|
87
79
|
async setRecentWallets(wallets: WcWallet[]) {
|
|
88
80
|
try {
|
|
89
|
-
await
|
|
81
|
+
await OptionsController.getStorage().setItem(
|
|
82
|
+
ConstantsUtil.STORAGE_KEYS.RECENT_WALLET,
|
|
83
|
+
wallets
|
|
84
|
+
);
|
|
90
85
|
} catch {
|
|
91
86
|
console.info('Unable to set recent wallets');
|
|
92
87
|
}
|
|
@@ -94,9 +89,11 @@ export const StorageUtil = {
|
|
|
94
89
|
|
|
95
90
|
async getRecentWallets(): Promise<WcWallet[]> {
|
|
96
91
|
try {
|
|
97
|
-
const recent = await
|
|
92
|
+
const recent = await OptionsController.getStorage().getItem(
|
|
93
|
+
ConstantsUtil.STORAGE_KEYS.RECENT_WALLET
|
|
94
|
+
);
|
|
98
95
|
|
|
99
|
-
return recent
|
|
96
|
+
return recent ?? [];
|
|
100
97
|
} catch {
|
|
101
98
|
console.info('Unable to get recent wallets');
|
|
102
99
|
}
|
|
@@ -104,40 +101,11 @@ export const StorageUtil = {
|
|
|
104
101
|
return [];
|
|
105
102
|
},
|
|
106
103
|
|
|
107
|
-
//TODO: remove this
|
|
108
|
-
async setConnectedConnector(connectorType: ConnectorType) {
|
|
109
|
-
try {
|
|
110
|
-
await AsyncStorage.setItem(CONNECTED_CONNECTOR, JSON.stringify(connectorType));
|
|
111
|
-
} catch {
|
|
112
|
-
console.info('Unable to set Connected Connector');
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
async getConnectedConnector(): Promise<ConnectorType | undefined> {
|
|
117
|
-
try {
|
|
118
|
-
const connector = (await AsyncStorage.getItem(CONNECTED_CONNECTOR)) as ConnectorType;
|
|
119
|
-
|
|
120
|
-
return connector ? JSON.parse(connector) : undefined;
|
|
121
|
-
} catch {
|
|
122
|
-
console.info('Unable to get Connected Connector');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return undefined;
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
async removeConnectedConnector() {
|
|
129
|
-
try {
|
|
130
|
-
await AsyncStorage.removeItem(CONNECTED_CONNECTOR);
|
|
131
|
-
} catch {
|
|
132
|
-
console.info('Unable to remove Connected Connector');
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
104
|
async setConnectedConnectors({
|
|
137
105
|
type,
|
|
138
106
|
namespaces
|
|
139
107
|
}: {
|
|
140
|
-
type:
|
|
108
|
+
type: ConnectorType;
|
|
141
109
|
namespaces: string[];
|
|
142
110
|
}) {
|
|
143
111
|
try {
|
|
@@ -145,144 +113,151 @@ export const StorageUtil = {
|
|
|
145
113
|
// Only add if it doesn't exist already
|
|
146
114
|
if (!currentConnectors.some(c => c.type === type)) {
|
|
147
115
|
const updatedConnectors = [...currentConnectors, { type, namespaces }];
|
|
148
|
-
await
|
|
116
|
+
await OptionsController.getStorage().setItem(
|
|
117
|
+
ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS,
|
|
118
|
+
updatedConnectors
|
|
119
|
+
);
|
|
149
120
|
}
|
|
150
121
|
} catch {
|
|
151
122
|
console.info('Unable to set Connected Connector');
|
|
152
123
|
}
|
|
153
124
|
},
|
|
154
125
|
|
|
155
|
-
async getConnectedConnectors(): Promise<{ type:
|
|
126
|
+
async getConnectedConnectors(): Promise<{ type: ConnectorType; namespaces: string[] }[]> {
|
|
156
127
|
try {
|
|
157
|
-
const connectors = await
|
|
128
|
+
const connectors = await OptionsController.getStorage().getItem<
|
|
129
|
+
{ type: ConnectorType; namespaces: string[] }[]
|
|
130
|
+
>(ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS);
|
|
158
131
|
|
|
159
|
-
return connectors
|
|
160
|
-
} catch {
|
|
132
|
+
return connectors ?? [];
|
|
133
|
+
} catch (err) {
|
|
161
134
|
console.info('Unable to get Connected Connector');
|
|
162
135
|
}
|
|
163
136
|
|
|
164
137
|
return [];
|
|
165
138
|
},
|
|
166
139
|
|
|
167
|
-
async removeConnectedConnectors(type:
|
|
140
|
+
async removeConnectedConnectors(type: ConnectorType) {
|
|
168
141
|
try {
|
|
169
142
|
const currentConnectors = await StorageUtil.getConnectedConnectors();
|
|
170
143
|
const updatedConnectors = currentConnectors.filter(c => c.type !== type);
|
|
171
|
-
await
|
|
144
|
+
await OptionsController.getStorage().setItem(
|
|
145
|
+
ConstantsUtil.STORAGE_KEYS.CONNECTED_CONNECTORS,
|
|
146
|
+
updatedConnectors
|
|
147
|
+
);
|
|
172
148
|
} catch {
|
|
173
149
|
console.info('Unable to remove Connected Connector');
|
|
174
150
|
}
|
|
175
151
|
},
|
|
176
152
|
|
|
177
|
-
async
|
|
153
|
+
async setOnRampPreferredCountry(country: OnRampCountry) {
|
|
178
154
|
try {
|
|
179
|
-
await
|
|
155
|
+
await OptionsController.getStorage().setItem(
|
|
156
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_COUNTRY,
|
|
157
|
+
country
|
|
158
|
+
);
|
|
180
159
|
} catch {
|
|
181
|
-
console.info('Unable to set
|
|
160
|
+
console.info('Unable to set OnRamp Preferred Country');
|
|
182
161
|
}
|
|
183
162
|
},
|
|
184
163
|
|
|
185
|
-
async
|
|
164
|
+
async getOnRampPreferredCountry() {
|
|
186
165
|
try {
|
|
187
|
-
|
|
166
|
+
const country = await OptionsController.getStorage().getItem<OnRampCountry>(
|
|
167
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_COUNTRY
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return country ?? undefined;
|
|
188
171
|
} catch {
|
|
189
|
-
console.info('Unable to get
|
|
172
|
+
console.info('Unable to get OnRamp Preferred Country');
|
|
190
173
|
}
|
|
191
174
|
|
|
192
175
|
return undefined;
|
|
193
176
|
},
|
|
194
177
|
|
|
195
|
-
async
|
|
196
|
-
try {
|
|
197
|
-
await AsyncStorage.removeItem(CONNECTED_WALLET_IMAGE_URL);
|
|
198
|
-
} catch {
|
|
199
|
-
console.info('Unable to remove Connected Wallet Image URL');
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
async setConnectedSocialProvider(provider: SocialProvider) {
|
|
178
|
+
async setOnRampPreferredFiatCurrency(currency: OnRampFiatCurrency) {
|
|
204
179
|
try {
|
|
205
|
-
await
|
|
180
|
+
await OptionsController.getStorage().setItem(
|
|
181
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_FIAT_CURRENCY,
|
|
182
|
+
currency
|
|
183
|
+
);
|
|
206
184
|
} catch {
|
|
207
|
-
console.info('Unable to set
|
|
185
|
+
console.info('Unable to set OnRamp Preferred Fiat Currency');
|
|
208
186
|
}
|
|
209
187
|
},
|
|
210
188
|
|
|
211
|
-
async
|
|
189
|
+
async getOnRampPreferredFiatCurrency() {
|
|
212
190
|
try {
|
|
213
|
-
const
|
|
191
|
+
const currency = await OptionsController.getStorage().getItem<OnRampFiatCurrency>(
|
|
192
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_PREFERRED_FIAT_CURRENCY
|
|
193
|
+
);
|
|
214
194
|
|
|
215
|
-
return
|
|
195
|
+
return currency ?? undefined;
|
|
216
196
|
} catch {
|
|
217
|
-
console.info('Unable to get
|
|
197
|
+
console.info('Unable to get OnRamp Preferred Fiat Currency');
|
|
218
198
|
}
|
|
219
199
|
|
|
220
200
|
return undefined;
|
|
221
201
|
},
|
|
222
202
|
|
|
223
|
-
async
|
|
224
|
-
try {
|
|
225
|
-
await AsyncStorage.removeItem(CONNECTED_SOCIAL);
|
|
226
|
-
} catch {
|
|
227
|
-
console.info('Unable to remove Connected Social Provider');
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
async setOnRampPreferredCountry(country: OnRampCountry) {
|
|
203
|
+
async setOnRampCountries(countries: OnRampCountry[]) {
|
|
232
204
|
try {
|
|
233
|
-
await
|
|
205
|
+
await OptionsController.getStorage().setItem(
|
|
206
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES,
|
|
207
|
+
countries
|
|
208
|
+
);
|
|
234
209
|
} catch {
|
|
235
|
-
console.info('Unable to set OnRamp
|
|
210
|
+
console.info('Unable to set OnRamp Countries');
|
|
236
211
|
}
|
|
237
212
|
},
|
|
238
213
|
|
|
239
|
-
async
|
|
214
|
+
async getOnRampCountries() {
|
|
240
215
|
try {
|
|
241
|
-
const
|
|
216
|
+
const countries = await OptionsController.getStorage().getItem<OnRampCountry[]>(
|
|
217
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES
|
|
218
|
+
);
|
|
242
219
|
|
|
243
|
-
return
|
|
220
|
+
return countries ?? [];
|
|
244
221
|
} catch {
|
|
245
|
-
console.info('Unable to get OnRamp
|
|
222
|
+
console.info('Unable to get OnRamp Countries');
|
|
246
223
|
}
|
|
247
224
|
|
|
248
|
-
return
|
|
225
|
+
return [];
|
|
249
226
|
},
|
|
250
227
|
|
|
251
|
-
async
|
|
228
|
+
async setOnRampCountriesDefaults(countriesDefaults: OnRampCountryDefaults[]) {
|
|
252
229
|
try {
|
|
253
|
-
|
|
230
|
+
const timestamp = Date.now();
|
|
231
|
+
|
|
232
|
+
await OptionsController.getStorage().setItem(
|
|
233
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES_DEFAULTS,
|
|
234
|
+
{ data: countriesDefaults, timestamp }
|
|
235
|
+
);
|
|
254
236
|
} catch {
|
|
255
|
-
console.info('Unable to set OnRamp
|
|
237
|
+
console.info('Unable to set OnRamp Countries Defaults');
|
|
256
238
|
}
|
|
257
239
|
},
|
|
258
240
|
|
|
259
|
-
async
|
|
241
|
+
async getOnRampCountriesDefaults() {
|
|
260
242
|
try {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
} catch {
|
|
265
|
-
console.info('Unable to get OnRamp Preferred Fiat Currency');
|
|
266
|
-
}
|
|
243
|
+
const result = await OptionsController.getStorage().getItem(
|
|
244
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_COUNTRIES_DEFAULTS
|
|
245
|
+
);
|
|
267
246
|
|
|
268
|
-
|
|
269
|
-
|
|
247
|
+
if (!result) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
270
250
|
|
|
271
|
-
|
|
272
|
-
try {
|
|
273
|
-
await AsyncStorage.setItem(ONRAMP_COUNTRIES, JSON.stringify(countries));
|
|
274
|
-
} catch {
|
|
275
|
-
console.info('Unable to set OnRamp Countries');
|
|
276
|
-
}
|
|
277
|
-
},
|
|
251
|
+
const { data, timestamp } = result;
|
|
278
252
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
253
|
+
// Cache for 1 week
|
|
254
|
+
if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
|
|
255
|
+
return [];
|
|
256
|
+
}
|
|
282
257
|
|
|
283
|
-
return
|
|
258
|
+
return (data as OnRampCountryDefaults[]) ?? [];
|
|
284
259
|
} catch {
|
|
285
|
-
console.info('Unable to get OnRamp Countries');
|
|
260
|
+
console.info('Unable to get OnRamp Countries Defaults');
|
|
286
261
|
}
|
|
287
262
|
|
|
288
263
|
return [];
|
|
@@ -292,9 +267,9 @@ export const StorageUtil = {
|
|
|
292
267
|
try {
|
|
293
268
|
const timestamp = Date.now();
|
|
294
269
|
|
|
295
|
-
await
|
|
296
|
-
ONRAMP_SERVICE_PROVIDERS,
|
|
297
|
-
|
|
270
|
+
await OptionsController.getStorage().setItem(
|
|
271
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_SERVICE_PROVIDERS,
|
|
272
|
+
{ data: serviceProviders, timestamp }
|
|
298
273
|
);
|
|
299
274
|
} catch {
|
|
300
275
|
console.info('Unable to set OnRamp Service Providers');
|
|
@@ -303,20 +278,22 @@ export const StorageUtil = {
|
|
|
303
278
|
|
|
304
279
|
async getOnRampServiceProviders() {
|
|
305
280
|
try {
|
|
306
|
-
const result = await
|
|
281
|
+
const result = await OptionsController.getStorage().getItem(
|
|
282
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_SERVICE_PROVIDERS
|
|
283
|
+
);
|
|
307
284
|
|
|
308
285
|
if (!result) {
|
|
309
286
|
return [];
|
|
310
287
|
}
|
|
311
288
|
|
|
312
|
-
const { data, timestamp } =
|
|
289
|
+
const { data, timestamp } = result;
|
|
313
290
|
|
|
314
291
|
// Cache for 1 week
|
|
315
292
|
if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
|
|
316
293
|
return [];
|
|
317
294
|
}
|
|
318
295
|
|
|
319
|
-
return
|
|
296
|
+
return (data as OnRampServiceProvider[]) ?? [];
|
|
320
297
|
} catch (err) {
|
|
321
298
|
console.error(err);
|
|
322
299
|
console.info('Unable to get OnRamp Service Providers');
|
|
@@ -329,10 +306,10 @@ export const StorageUtil = {
|
|
|
329
306
|
try {
|
|
330
307
|
const timestamp = Date.now();
|
|
331
308
|
|
|
332
|
-
await
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
);
|
|
309
|
+
await OptionsController.getStorage().setItem(ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_LIMITS, {
|
|
310
|
+
data: fiatLimits,
|
|
311
|
+
timestamp
|
|
312
|
+
});
|
|
336
313
|
} catch {
|
|
337
314
|
console.info('Unable to set OnRamp Fiat Limits');
|
|
338
315
|
}
|
|
@@ -340,20 +317,22 @@ export const StorageUtil = {
|
|
|
340
317
|
|
|
341
318
|
async getOnRampFiatLimits() {
|
|
342
319
|
try {
|
|
343
|
-
const result = await
|
|
320
|
+
const result = await OptionsController.getStorage().getItem(
|
|
321
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_LIMITS
|
|
322
|
+
);
|
|
344
323
|
|
|
345
324
|
if (!result) {
|
|
346
325
|
return [];
|
|
347
326
|
}
|
|
348
327
|
|
|
349
|
-
const { data, timestamp } =
|
|
328
|
+
const { data, timestamp } = result;
|
|
350
329
|
|
|
351
330
|
// Cache for 1 week
|
|
352
331
|
if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
|
|
353
332
|
return [];
|
|
354
333
|
}
|
|
355
334
|
|
|
356
|
-
return
|
|
335
|
+
return (data as OnRampFiatLimit[]) ?? [];
|
|
357
336
|
} catch {
|
|
358
337
|
console.info('Unable to get OnRamp Fiat Limits');
|
|
359
338
|
}
|
|
@@ -365,9 +344,9 @@ export const StorageUtil = {
|
|
|
365
344
|
try {
|
|
366
345
|
const timestamp = Date.now();
|
|
367
346
|
|
|
368
|
-
await
|
|
369
|
-
ONRAMP_FIAT_CURRENCIES,
|
|
370
|
-
|
|
347
|
+
await OptionsController.getStorage().setItem(
|
|
348
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_CURRENCIES,
|
|
349
|
+
{ data: fiatCurrencies, timestamp }
|
|
371
350
|
);
|
|
372
351
|
} catch {
|
|
373
352
|
console.info('Unable to set OnRamp Fiat Currencies');
|
|
@@ -376,20 +355,22 @@ export const StorageUtil = {
|
|
|
376
355
|
|
|
377
356
|
async getOnRampFiatCurrencies() {
|
|
378
357
|
try {
|
|
379
|
-
const result = await
|
|
358
|
+
const result = await OptionsController.getStorage().getItem(
|
|
359
|
+
ConstantsUtil.STORAGE_KEYS.ONRAMP_FIAT_CURRENCIES
|
|
360
|
+
);
|
|
380
361
|
|
|
381
362
|
if (!result) {
|
|
382
363
|
return [];
|
|
383
364
|
}
|
|
384
365
|
|
|
385
|
-
const { data, timestamp } =
|
|
366
|
+
const { data, timestamp } = result;
|
|
386
367
|
|
|
387
368
|
// Cache for 1 week
|
|
388
369
|
if (timestamp && DateUtil.isMoreThanOneWeekAgo(timestamp)) {
|
|
389
370
|
return [];
|
|
390
371
|
}
|
|
391
372
|
|
|
392
|
-
return
|
|
373
|
+
return (data as OnRampFiatCurrency[]) ?? [];
|
|
393
374
|
} catch {
|
|
394
375
|
console.info('Unable to get OnRamp Fiat Currencies');
|
|
395
376
|
}
|
|
@@ -400,12 +381,17 @@ export const StorageUtil = {
|
|
|
400
381
|
async setActiveNamespace(namespace?: ChainNamespace) {
|
|
401
382
|
try {
|
|
402
383
|
if (!namespace) {
|
|
403
|
-
await
|
|
384
|
+
await OptionsController.getStorage().removeItem(
|
|
385
|
+
ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE
|
|
386
|
+
);
|
|
404
387
|
|
|
405
388
|
return;
|
|
406
389
|
}
|
|
407
390
|
|
|
408
|
-
await
|
|
391
|
+
await OptionsController.getStorage().setItem(
|
|
392
|
+
ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE,
|
|
393
|
+
namespace
|
|
394
|
+
);
|
|
409
395
|
} catch {
|
|
410
396
|
console.info('Unable to set Active Namespace');
|
|
411
397
|
}
|
|
@@ -413,10 +399,13 @@ export const StorageUtil = {
|
|
|
413
399
|
|
|
414
400
|
async getActiveNamespace() {
|
|
415
401
|
try {
|
|
416
|
-
const namespace = (await
|
|
402
|
+
const namespace = (await OptionsController.getStorage().getItem(
|
|
403
|
+
ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE
|
|
404
|
+
)) as ChainNamespace;
|
|
417
405
|
|
|
418
406
|
return namespace ?? undefined;
|
|
419
407
|
} catch (err) {
|
|
408
|
+
console.error(err);
|
|
420
409
|
console.info('Unable to get Active Namespace');
|
|
421
410
|
}
|
|
422
411
|
|
|
@@ -425,7 +414,7 @@ export const StorageUtil = {
|
|
|
425
414
|
|
|
426
415
|
async removeActiveNamespace() {
|
|
427
416
|
try {
|
|
428
|
-
await
|
|
417
|
+
await OptionsController.getStorage().removeItem(ConstantsUtil.STORAGE_KEYS.ACTIVE_NAMESPACE);
|
|
429
418
|
} catch {
|
|
430
419
|
console.info('Unable to remove Active Namespace');
|
|
431
420
|
}
|
package/src/utils/SwapApiUtil.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { BlockchainApiController } from '../controllers/BlockchainApiController';
|
|
2
|
-
import { OptionsController } from '../controllers/OptionsController';
|
|
3
1
|
import type {
|
|
4
|
-
|
|
2
|
+
Balance,
|
|
3
|
+
CaipNetworkId,
|
|
5
4
|
BlockchainApiSwapAllowanceRequest,
|
|
6
5
|
SwapTokenWithBalance
|
|
7
|
-
} from '
|
|
8
|
-
import {
|
|
6
|
+
} from '@reown/appkit-common-react-native';
|
|
7
|
+
import { BlockchainApiController } from '../controllers/BlockchainApiController';
|
|
8
|
+
import { OptionsController } from '../controllers/OptionsController';
|
|
9
9
|
import { ConnectionsController } from '../controllers/ConnectionsController';
|
|
10
|
-
import type { CaipNetworkId } from '@reown/appkit-common-react-native';
|
|
11
10
|
import { ConstantsUtil } from './ConstantsUtil';
|
|
12
11
|
|
|
13
12
|
export const SwapApiUtil = {
|
|
@@ -64,43 +63,25 @@ export const SwapApiUtil = {
|
|
|
64
63
|
return false;
|
|
65
64
|
},
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
const { activeAddress, activeNetwork: network } = ConnectionsController.state;
|
|
69
|
-
const address = activeAddress?.split(':')[2];
|
|
70
|
-
|
|
71
|
-
if (!address) {
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const response = await BlockchainApiController.getBalance(
|
|
76
|
-
address,
|
|
77
|
-
network?.caipNetworkId,
|
|
78
|
-
forceUpdate
|
|
79
|
-
);
|
|
80
|
-
const balances = response?.balances.filter(balance => balance.quantity.decimals !== '0');
|
|
81
|
-
|
|
82
|
-
AccountController.setTokenBalance(balances);
|
|
83
|
-
|
|
84
|
-
return this.mapBalancesToSwapTokens(balances);
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
mapBalancesToSwapTokens(balances?: BlockchainApiBalanceResponse['balances']) {
|
|
66
|
+
mapBalancesToSwapTokens(balances?: Balance[]) {
|
|
88
67
|
const { activeNamespace, activeCaipNetworkId } = ConnectionsController.state;
|
|
89
68
|
const address = activeNamespace
|
|
90
69
|
? ConstantsUtil.NATIVE_TOKEN_ADDRESS[activeNamespace]
|
|
91
70
|
: undefined;
|
|
92
71
|
|
|
93
72
|
return (
|
|
94
|
-
balances
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
73
|
+
balances
|
|
74
|
+
?.filter(balance => balance?.quantity?.numeric)
|
|
75
|
+
.map(
|
|
76
|
+
token =>
|
|
77
|
+
({
|
|
78
|
+
...token,
|
|
79
|
+
address: token?.address ?? `${token?.chainId ?? activeCaipNetworkId}:${address}`,
|
|
80
|
+
decimals: parseInt(token.quantity?.decimals ?? '0', 10),
|
|
81
|
+
logoUri: token.iconUrl,
|
|
82
|
+
eip2612: false
|
|
83
|
+
}) as SwapTokenWithBalance
|
|
84
|
+
) || []
|
|
104
85
|
);
|
|
105
86
|
},
|
|
106
87
|
|