@reown/appkit-core-react-native 0.0.0-feat-onramp-20250409135734 → 0.0.0-feat-multichain-20250513150920
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 +11 -11
- package/lib/commonjs/controllers/ApiController.js.map +1 -1
- package/lib/commonjs/controllers/BlockchainApiController.js +102 -14
- package/lib/commonjs/controllers/BlockchainApiController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionController.js +7 -1
- package/lib/commonjs/controllers/ConnectionController.js.map +1 -1
- package/lib/commonjs/controllers/ConnectionsController.js +156 -0
- package/lib/commonjs/controllers/ConnectionsController.js.map +1 -0
- package/lib/commonjs/controllers/ConnectorController.js +1 -0
- package/lib/commonjs/controllers/ConnectorController.js.map +1 -1
- package/lib/commonjs/controllers/OptionsController.js +3 -3
- package/lib/commonjs/controllers/OptionsController.js.map +1 -1
- package/lib/commonjs/controllers/RouterController.js.map +1 -1
- package/lib/commonjs/controllers/SwapController.js +13 -5
- 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 +2 -2
- package/lib/commonjs/controllers/TransactionsController.js.map +1 -1
- package/lib/commonjs/index.js +3 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/AssetUtil.js +5 -6
- package/lib/commonjs/utils/AssetUtil.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +11 -5
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/CoreHelperUtil.js.map +1 -1
- package/lib/commonjs/utils/StorageUtil.js +67 -0
- package/lib/commonjs/utils/StorageUtil.js.map +1 -1
- package/lib/commonjs/utils/SwapApiUtil.js +9 -4
- package/lib/commonjs/utils/SwapApiUtil.js.map +1 -1
- package/lib/module/controllers/ApiController.js +11 -11
- package/lib/module/controllers/ApiController.js.map +1 -1
- package/lib/module/controllers/BlockchainApiController.js +102 -14
- package/lib/module/controllers/BlockchainApiController.js.map +1 -1
- package/lib/module/controllers/ConnectionController.js +7 -1
- package/lib/module/controllers/ConnectionController.js.map +1 -1
- package/lib/module/controllers/ConnectionsController.js +151 -0
- package/lib/module/controllers/ConnectionsController.js.map +1 -0
- package/lib/module/controllers/ConnectorController.js +1 -0
- package/lib/module/controllers/ConnectorController.js.map +1 -1
- package/lib/module/controllers/OptionsController.js +3 -3
- package/lib/module/controllers/OptionsController.js.map +1 -1
- package/lib/module/controllers/RouterController.js.map +1 -1
- package/lib/module/controllers/SwapController.js +13 -5
- package/lib/module/controllers/SwapController.js.map +1 -1
- package/lib/module/controllers/ThemeController.js +9 -1
- package/lib/module/controllers/ThemeController.js.map +1 -1
- package/lib/module/controllers/TransactionsController.js +2 -2
- package/lib/module/controllers/TransactionsController.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/AssetUtil.js +5 -6
- package/lib/module/utils/AssetUtil.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +11 -5
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/CoreHelperUtil.js.map +1 -1
- package/lib/module/utils/StorageUtil.js +67 -0
- package/lib/module/utils/StorageUtil.js.map +1 -1
- package/lib/module/utils/SwapApiUtil.js +9 -4
- package/lib/module/utils/SwapApiUtil.js.map +1 -1
- package/lib/typescript/controllers/AccountController.d.ts +2 -2
- package/lib/typescript/controllers/AccountController.d.ts.map +1 -1
- package/lib/typescript/controllers/ApiController.d.ts +1 -1
- package/lib/typescript/controllers/ApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts +14 -1
- package/lib/typescript/controllers/BlockchainApiController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionController.d.ts +2 -0
- package/lib/typescript/controllers/ConnectionController.d.ts.map +1 -1
- package/lib/typescript/controllers/ConnectionsController.d.ts +41 -0
- package/lib/typescript/controllers/ConnectionsController.d.ts.map +1 -0
- package/lib/typescript/controllers/ConnectorController.d.ts.map +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts +1 -1
- package/lib/typescript/controllers/NetworkController.d.ts.map +1 -1
- package/lib/typescript/controllers/OptionsController.d.ts +3 -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 +2 -1
- package/lib/typescript/controllers/RouterController.d.ts.map +1 -1
- 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/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/AssetUtil.d.ts +2 -2
- package/lib/typescript/utils/AssetUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +6 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/CoreHelperUtil.d.ts +2 -2
- package/lib/typescript/utils/CoreHelperUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StorageUtil.d.ts +13 -1
- package/lib/typescript/utils/StorageUtil.d.ts.map +1 -1
- package/lib/typescript/utils/SwapApiUtil.d.ts.map +1 -1
- package/lib/typescript/utils/TypeUtil.d.ts +3 -14
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/controllers/AccountController.ts +2 -2
- package/src/controllers/ApiController.ts +12 -7
- package/src/controllers/BlockchainApiController.ts +133 -13
- package/src/controllers/ConnectionController.ts +9 -1
- package/src/controllers/ConnectionsController.ts +235 -0
- package/src/controllers/ConnectorController.ts +1 -0
- package/src/controllers/NetworkController.ts +1 -1
- package/src/controllers/OptionsController.ts +7 -6
- package/src/controllers/PublicStateController.ts +1 -1
- package/src/controllers/RouterController.ts +2 -1
- package/src/controllers/SwapController.ts +14 -5
- package/src/controllers/ThemeController.ts +11 -2
- package/src/controllers/TransactionsController.ts +2 -2
- package/src/index.ts +5 -1
- package/src/utils/AssetUtil.ts +5 -7
- package/src/utils/ConstantsUtil.ts +12 -5
- package/src/utils/CoreHelperUtil.ts +8 -3
- package/src/utils/NetworkUtil.ts +1 -1
- package/src/utils/StorageUtil.ts +82 -1
- package/src/utils/SwapApiUtil.ts +10 -4
- package/src/utils/TypeUtil.ts +5 -19
- package/lib/commonjs/utils/ConnectionUtil.js +0 -33
- package/lib/commonjs/utils/ConnectionUtil.js.map +0 -1
- package/lib/module/utils/ConnectionUtil.js +0 -27
- package/lib/module/utils/ConnectionUtil.js.map +0 -1
- package/lib/typescript/utils/ConnectionUtil.d.ts +0 -4
- package/lib/typescript/utils/ConnectionUtil.d.ts.map +0 -1
- package/src/utils/ConnectionUtil.ts +0 -27
|
@@ -3,9 +3,9 @@ import { proxy, subscribe as sub } from 'valtio/vanilla';
|
|
|
3
3
|
import { OptionsController } from './OptionsController';
|
|
4
4
|
import { EventsController } from './EventsController';
|
|
5
5
|
import { SnackController } from './SnackController';
|
|
6
|
-
import { NetworkController } from './NetworkController';
|
|
7
6
|
import { BlockchainApiController } from './BlockchainApiController';
|
|
8
7
|
import { AccountController } from './AccountController';
|
|
8
|
+
import { ConnectionsController } from './ConnectionsController';
|
|
9
9
|
|
|
10
10
|
// -- Types --------------------------------------------- //
|
|
11
11
|
type TransactionByMonthMap = Record<string, Transaction[]>;
|
|
@@ -121,7 +121,7 @@ export const TransactionsController = {
|
|
|
121
121
|
},
|
|
122
122
|
|
|
123
123
|
filterByConnectedChain(transactions: Transaction[]) {
|
|
124
|
-
const chainId =
|
|
124
|
+
const chainId = ConnectionsController.state.activeCaipNetworkId;
|
|
125
125
|
const filteredTransactions = transactions.filter(
|
|
126
126
|
transaction => transaction.metadata.chain === chainId
|
|
127
127
|
);
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,11 @@ export {
|
|
|
21
21
|
type ConnectionControllerState
|
|
22
22
|
} from './controllers/ConnectionController';
|
|
23
23
|
|
|
24
|
+
export {
|
|
25
|
+
ConnectionsController,
|
|
26
|
+
type ConnectionsControllerState
|
|
27
|
+
} from './controllers/ConnectionsController';
|
|
28
|
+
|
|
24
29
|
export {
|
|
25
30
|
ConnectorController,
|
|
26
31
|
type ConnectorControllerState
|
|
@@ -62,7 +67,6 @@ export { WebviewController, type WebviewControllerState } from './controllers/We
|
|
|
62
67
|
// -- Utils -------------------------------------------------------------------
|
|
63
68
|
export { ApiUtil } from './utils/ApiUtil';
|
|
64
69
|
export { AssetUtil } from './utils/AssetUtil';
|
|
65
|
-
export { ConnectionUtil } from './utils/ConnectionUtil';
|
|
66
70
|
export { ConstantsUtil } from './utils/ConstantsUtil';
|
|
67
71
|
export { CoreHelperUtil } from './utils/CoreHelperUtil';
|
|
68
72
|
export { StorageUtil } from './utils/StorageUtil';
|
package/src/utils/AssetUtil.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetController } from '../controllers/AssetController';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Connector, WcWallet } from './TypeUtil';
|
|
3
3
|
|
|
4
4
|
export const AssetUtil = {
|
|
5
5
|
getWalletImage(wallet?: WcWallet) {
|
|
@@ -14,13 +14,11 @@ export const AssetUtil = {
|
|
|
14
14
|
return undefined;
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
getNetworkImage(
|
|
18
|
-
if
|
|
19
|
-
return network?.imageUrl;
|
|
20
|
-
}
|
|
17
|
+
getNetworkImage(networkId?: string | number) {
|
|
18
|
+
//TODO: check if imageUrl case is needed
|
|
21
19
|
|
|
22
|
-
if (
|
|
23
|
-
return AssetController.state.networkImages[
|
|
20
|
+
if (networkId) {
|
|
21
|
+
return AssetController.state.networkImages[networkId];
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
return undefined;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { ChainNamespace } from '@reown/appkit-common-react-native';
|
|
1
2
|
import type { Features } from './TypeUtil';
|
|
2
3
|
|
|
4
|
+
//TODO: enable this again after implemented
|
|
3
5
|
const defaultFeatures: Features = {
|
|
4
|
-
swaps:
|
|
5
|
-
onramp:
|
|
6
|
-
email:
|
|
7
|
-
emailShowWallets:
|
|
6
|
+
swaps: false,
|
|
7
|
+
onramp: false,
|
|
8
|
+
email: false,
|
|
9
|
+
emailShowWallets: false,
|
|
8
10
|
socials: ['x', 'discord', 'apple']
|
|
9
11
|
};
|
|
10
12
|
|
|
@@ -34,7 +36,12 @@ export const ConstantsUtil = {
|
|
|
34
36
|
|
|
35
37
|
LINKING_ERROR: 'LINKING_ERROR',
|
|
36
38
|
|
|
37
|
-
NATIVE_TOKEN_ADDRESS:
|
|
39
|
+
NATIVE_TOKEN_ADDRESS: {
|
|
40
|
+
eip155: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
41
|
+
solana: 'So11111111111111111111111111111111111111111',
|
|
42
|
+
polkadot: '0x',
|
|
43
|
+
bip122: '0x'
|
|
44
|
+
} as const satisfies Record<ChainNamespace, string>,
|
|
38
45
|
|
|
39
46
|
ONRAMP_ERROR_TYPES: OnRampErrorType,
|
|
40
47
|
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
|
|
3
3
|
import { Linking, Platform } from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ConstantsUtil as CommonConstants,
|
|
6
|
+
type Balance,
|
|
7
|
+
type CaipAddress,
|
|
8
|
+
type CaipNetwork
|
|
9
|
+
} from '@reown/appkit-common-react-native';
|
|
10
|
+
|
|
5
11
|
import * as ct from 'countries-and-timezones';
|
|
6
12
|
|
|
7
13
|
import { ConstantsUtil } from './ConstantsUtil';
|
|
8
|
-
import type {
|
|
9
|
-
|
|
14
|
+
import type { DataWallet, LinkingRecord } from './TypeUtil';
|
|
10
15
|
// -- Helpers -----------------------------------------------------------------
|
|
11
16
|
async function isAppInstalledIos(deepLink?: string): Promise<boolean> {
|
|
12
17
|
try {
|
package/src/utils/NetworkUtil.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { NetworkController } from '../controllers/NetworkController';
|
|
|
4
4
|
import { AccountController } from '../controllers/AccountController';
|
|
5
5
|
import { ConnectorController } from '../controllers/ConnectorController';
|
|
6
6
|
import { SwapController } from '../controllers/SwapController';
|
|
7
|
-
import type
|
|
7
|
+
import { type CaipNetwork } from '@reown/appkit-common-react-native';
|
|
8
8
|
|
|
9
9
|
export const NetworkUtil = {
|
|
10
10
|
async handleNetworkSwitch(network: CaipNetwork) {
|
package/src/utils/StorageUtil.ts
CHANGED
|
@@ -10,7 +10,9 @@ import type {
|
|
|
10
10
|
import {
|
|
11
11
|
DateUtil,
|
|
12
12
|
type SocialProvider,
|
|
13
|
-
type
|
|
13
|
+
type New_ConnectorType,
|
|
14
|
+
type ConnectorType,
|
|
15
|
+
type ChainNamespace
|
|
14
16
|
} from '@reown/appkit-common-react-native';
|
|
15
17
|
|
|
16
18
|
// -- Helpers -----------------------------------------------------------------
|
|
@@ -18,6 +20,7 @@ const WC_DEEPLINK = 'WALLETCONNECT_DEEPLINK_CHOICE';
|
|
|
18
20
|
const RECENT_WALLET = '@w3m/recent';
|
|
19
21
|
const CONNECTED_WALLET_IMAGE_URL = '@w3m/connected_wallet_image_url';
|
|
20
22
|
const CONNECTED_CONNECTOR = '@w3m/connected_connector';
|
|
23
|
+
const CONNECTED_CONNECTORS = '@appkit/connected_connectors';
|
|
21
24
|
const CONNECTED_SOCIAL = '@appkit/connected_social';
|
|
22
25
|
const ONRAMP_PREFERRED_COUNTRY = '@appkit/onramp_preferred_country';
|
|
23
26
|
const ONRAMP_COUNTRIES = '@appkit/onramp_countries';
|
|
@@ -25,6 +28,8 @@ const ONRAMP_SERVICE_PROVIDERS = '@appkit/onramp_service_providers';
|
|
|
25
28
|
const ONRAMP_FIAT_LIMITS = '@appkit/onramp_fiat_limits';
|
|
26
29
|
const ONRAMP_FIAT_CURRENCIES = '@appkit/onramp_fiat_currencies';
|
|
27
30
|
const ONRAMP_PREFERRED_FIAT_CURRENCY = '@appkit/onramp_preferred_fiat_currency';
|
|
31
|
+
const ACTIVE_NAMESPACE = '@appkit/active_namespace';
|
|
32
|
+
|
|
28
33
|
// -- Utility -----------------------------------------------------------------
|
|
29
34
|
export const StorageUtil = {
|
|
30
35
|
setWalletConnectDeepLink({ href, name }: { href: string; name: string }) {
|
|
@@ -99,6 +104,7 @@ export const StorageUtil = {
|
|
|
99
104
|
return [];
|
|
100
105
|
},
|
|
101
106
|
|
|
107
|
+
//TODO: remove this
|
|
102
108
|
async setConnectedConnector(connectorType: ConnectorType) {
|
|
103
109
|
try {
|
|
104
110
|
await AsyncStorage.setItem(CONNECTED_CONNECTOR, JSON.stringify(connectorType));
|
|
@@ -127,6 +133,47 @@ export const StorageUtil = {
|
|
|
127
133
|
}
|
|
128
134
|
},
|
|
129
135
|
|
|
136
|
+
async setConnectedConnectors({
|
|
137
|
+
type,
|
|
138
|
+
namespaces
|
|
139
|
+
}: {
|
|
140
|
+
type: New_ConnectorType;
|
|
141
|
+
namespaces: string[];
|
|
142
|
+
}) {
|
|
143
|
+
try {
|
|
144
|
+
const currentConnectors = (await StorageUtil.getConnectedConnectors()) || [];
|
|
145
|
+
// Only add if it doesn't exist already
|
|
146
|
+
if (!currentConnectors.some(c => c.type === type)) {
|
|
147
|
+
const updatedConnectors = [...currentConnectors, { type, namespaces }];
|
|
148
|
+
await AsyncStorage.setItem(CONNECTED_CONNECTORS, JSON.stringify(updatedConnectors));
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
console.info('Unable to set Connected Connector');
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
async getConnectedConnectors(): Promise<{ type: New_ConnectorType; namespaces: string[] }[]> {
|
|
156
|
+
try {
|
|
157
|
+
const connectors = await AsyncStorage.getItem(CONNECTED_CONNECTORS);
|
|
158
|
+
|
|
159
|
+
return connectors ? JSON.parse(connectors) : [];
|
|
160
|
+
} catch {
|
|
161
|
+
console.info('Unable to get Connected Connector');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return [];
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
async removeConnectedConnectors(type: New_ConnectorType) {
|
|
168
|
+
try {
|
|
169
|
+
const currentConnectors = await StorageUtil.getConnectedConnectors();
|
|
170
|
+
const updatedConnectors = currentConnectors.filter(c => c.type !== type);
|
|
171
|
+
await AsyncStorage.setItem(CONNECTED_CONNECTORS, JSON.stringify(updatedConnectors));
|
|
172
|
+
} catch {
|
|
173
|
+
console.info('Unable to remove Connected Connector');
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
|
|
130
177
|
async setConnectedWalletImageUrl(url: string) {
|
|
131
178
|
try {
|
|
132
179
|
await AsyncStorage.setItem(CONNECTED_WALLET_IMAGE_URL, url);
|
|
@@ -348,5 +395,39 @@ export const StorageUtil = {
|
|
|
348
395
|
}
|
|
349
396
|
|
|
350
397
|
return [];
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
async setActiveNamespace(namespace?: ChainNamespace) {
|
|
401
|
+
try {
|
|
402
|
+
if (!namespace) {
|
|
403
|
+
await AsyncStorage.removeItem(ACTIVE_NAMESPACE);
|
|
404
|
+
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
await AsyncStorage.setItem(ACTIVE_NAMESPACE, namespace);
|
|
409
|
+
} catch {
|
|
410
|
+
console.info('Unable to set Active Namespace');
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
async getActiveNamespace() {
|
|
415
|
+
try {
|
|
416
|
+
const namespace = (await AsyncStorage.getItem(ACTIVE_NAMESPACE)) as ChainNamespace;
|
|
417
|
+
|
|
418
|
+
return namespace ?? undefined;
|
|
419
|
+
} catch (err) {
|
|
420
|
+
console.info('Unable to get Active Namespace');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return undefined;
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
async removeActiveNamespace() {
|
|
427
|
+
try {
|
|
428
|
+
await AsyncStorage.removeItem(ACTIVE_NAMESPACE);
|
|
429
|
+
} catch {
|
|
430
|
+
console.info('Unable to remove Active Namespace');
|
|
431
|
+
}
|
|
351
432
|
}
|
|
352
433
|
};
|
package/src/utils/SwapApiUtil.ts
CHANGED
|
@@ -8,12 +8,14 @@ import type {
|
|
|
8
8
|
} from './TypeUtil';
|
|
9
9
|
import { AccountController } from '../controllers/AccountController';
|
|
10
10
|
import { ConnectionController } from '../controllers/ConnectionController';
|
|
11
|
+
import { ConnectionsController } from '../controllers/ConnectionsController';
|
|
11
12
|
|
|
12
13
|
export const SwapApiUtil = {
|
|
13
14
|
async getTokenList() {
|
|
15
|
+
const chainId = ConnectionsController.state.activeNetwork?.caipNetworkId ?? 'eip155:1';
|
|
14
16
|
const response = await BlockchainApiController.fetchSwapTokens({
|
|
15
17
|
projectId: OptionsController.state.projectId,
|
|
16
|
-
chainId
|
|
18
|
+
chainId
|
|
17
19
|
});
|
|
18
20
|
const tokens =
|
|
19
21
|
response?.tokens?.map(
|
|
@@ -62,14 +64,18 @@ export const SwapApiUtil = {
|
|
|
62
64
|
},
|
|
63
65
|
|
|
64
66
|
async getMyTokensWithBalance(forceUpdate?: string) {
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
+
const { activeAddress, activeNetwork: network } = ConnectionsController.state;
|
|
68
|
+
const address = activeAddress?.split(':')[2];
|
|
67
69
|
|
|
68
70
|
if (!address) {
|
|
69
71
|
return [];
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
const response = await BlockchainApiController.getBalance(
|
|
74
|
+
const response = await BlockchainApiController.getBalance(
|
|
75
|
+
address,
|
|
76
|
+
network?.caipNetworkId,
|
|
77
|
+
forceUpdate
|
|
78
|
+
);
|
|
73
79
|
const balances = response?.balances.filter(balance => balance.quantity.decimals !== '0');
|
|
74
80
|
|
|
75
81
|
AccountController.setTokenBalance(balances);
|
package/src/utils/TypeUtil.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type EventEmitter } from 'events';
|
|
2
|
+
import type { CaipAddress, CaipNetworkId } from '@reown/appkit-common-react-native';
|
|
3
|
+
|
|
2
4
|
import type {
|
|
3
5
|
Balance,
|
|
4
6
|
SocialProvider,
|
|
@@ -6,23 +8,13 @@ import type {
|
|
|
6
8
|
Transaction,
|
|
7
9
|
ConnectorType
|
|
8
10
|
} from '@reown/appkit-common-react-native';
|
|
11
|
+
|
|
9
12
|
import { OnRampErrorType } from './ConstantsUtil';
|
|
10
13
|
|
|
11
14
|
export interface BaseError {
|
|
12
15
|
message?: string;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export type CaipAddress = `${string}:${string}:${string}`;
|
|
16
|
-
|
|
17
|
-
export type CaipNetworkId = `${string}:${string}`;
|
|
18
|
-
|
|
19
|
-
export interface CaipNetwork {
|
|
20
|
-
id: CaipNetworkId;
|
|
21
|
-
name?: string;
|
|
22
|
-
imageId?: string;
|
|
23
|
-
imageUrl?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
18
|
export type ConnectedWalletInfo =
|
|
27
19
|
| {
|
|
28
20
|
name?: string;
|
|
@@ -179,6 +171,7 @@ export interface BlockchainApiTransactionsRequest {
|
|
|
179
171
|
onramp?: 'coinbase';
|
|
180
172
|
signal?: AbortSignal;
|
|
181
173
|
cache?: RequestCache;
|
|
174
|
+
chainId?: CaipNetworkId;
|
|
182
175
|
}
|
|
183
176
|
|
|
184
177
|
export interface BlockchainApiTransactionsResponse {
|
|
@@ -346,13 +339,6 @@ export type BlockchainApiOnRampWidgetResponse = {
|
|
|
346
339
|
};
|
|
347
340
|
|
|
348
341
|
// -- OptionsController Types ---------------------------------------------------
|
|
349
|
-
export interface Token {
|
|
350
|
-
address: string;
|
|
351
|
-
image?: string;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export type Tokens = Record<CaipNetworkId, Token>;
|
|
355
|
-
|
|
356
342
|
export type Metadata = {
|
|
357
343
|
name: string;
|
|
358
344
|
description: string;
|
|
@@ -461,7 +447,7 @@ export type Event =
|
|
|
461
447
|
type: 'track';
|
|
462
448
|
event: 'SWITCH_NETWORK';
|
|
463
449
|
properties: {
|
|
464
|
-
network: string;
|
|
450
|
+
network: number | string;
|
|
465
451
|
};
|
|
466
452
|
}
|
|
467
453
|
| {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ConnectionUtil = void 0;
|
|
7
|
-
var _AccountController = require("../controllers/AccountController");
|
|
8
|
-
var _ConnectionController = require("../controllers/ConnectionController");
|
|
9
|
-
var _EventsController = require("../controllers/EventsController");
|
|
10
|
-
var _ModalController = require("../controllers/ModalController");
|
|
11
|
-
var _RouterController = require("../controllers/RouterController");
|
|
12
|
-
var _TransactionsController = require("../controllers/TransactionsController");
|
|
13
|
-
const ConnectionUtil = exports.ConnectionUtil = {
|
|
14
|
-
async disconnect() {
|
|
15
|
-
try {
|
|
16
|
-
await _ConnectionController.ConnectionController.disconnect();
|
|
17
|
-
_ModalController.ModalController.close();
|
|
18
|
-
_AccountController.AccountController.setIsConnected(false);
|
|
19
|
-
_RouterController.RouterController.reset('Connect');
|
|
20
|
-
_TransactionsController.TransactionsController.resetTransactions();
|
|
21
|
-
_EventsController.EventsController.sendEvent({
|
|
22
|
-
type: 'track',
|
|
23
|
-
event: 'DISCONNECT_SUCCESS'
|
|
24
|
-
});
|
|
25
|
-
} catch (error) {
|
|
26
|
-
_EventsController.EventsController.sendEvent({
|
|
27
|
-
type: 'track',
|
|
28
|
-
event: 'DISCONNECT_ERROR'
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=ConnectionUtil.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_AccountController","require","_ConnectionController","_EventsController","_ModalController","_RouterController","_TransactionsController","ConnectionUtil","exports","disconnect","ConnectionController","ModalController","close","AccountController","setIsConnected","RouterController","reset","TransactionsController","resetTransactions","EventsController","sendEvent","type","event","error"],"sourceRoot":"../../../src","sources":["utils/ConnectionUtil.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AAEO,MAAMM,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC5B,MAAME,UAAUA,CAAA,EAAG;IACjB,IAAI;MACF,MAAMC,0CAAoB,CAACD,UAAU,CAAC,CAAC;MACvCE,gCAAe,CAACC,KAAK,CAAC,CAAC;MACvBC,oCAAiB,CAACC,cAAc,CAAC,KAAK,CAAC;MACvCC,kCAAgB,CAACC,KAAK,CAAC,SAAS,CAAC;MACjCC,8CAAsB,CAACC,iBAAiB,CAAC,CAAC;MAC1CC,kCAAgB,CAACC,SAAS,CAAC;QACzBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdJ,kCAAgB,CAACC,SAAS,CAAC;QACzBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ;EACF;AACF,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AccountController } from '../controllers/AccountController';
|
|
2
|
-
import { ConnectionController } from '../controllers/ConnectionController';
|
|
3
|
-
import { EventsController } from '../controllers/EventsController';
|
|
4
|
-
import { ModalController } from '../controllers/ModalController';
|
|
5
|
-
import { RouterController } from '../controllers/RouterController';
|
|
6
|
-
import { TransactionsController } from '../controllers/TransactionsController';
|
|
7
|
-
export const ConnectionUtil = {
|
|
8
|
-
async disconnect() {
|
|
9
|
-
try {
|
|
10
|
-
await ConnectionController.disconnect();
|
|
11
|
-
ModalController.close();
|
|
12
|
-
AccountController.setIsConnected(false);
|
|
13
|
-
RouterController.reset('Connect');
|
|
14
|
-
TransactionsController.resetTransactions();
|
|
15
|
-
EventsController.sendEvent({
|
|
16
|
-
type: 'track',
|
|
17
|
-
event: 'DISCONNECT_SUCCESS'
|
|
18
|
-
});
|
|
19
|
-
} catch (error) {
|
|
20
|
-
EventsController.sendEvent({
|
|
21
|
-
type: 'track',
|
|
22
|
-
event: 'DISCONNECT_ERROR'
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=ConnectionUtil.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["AccountController","ConnectionController","EventsController","ModalController","RouterController","TransactionsController","ConnectionUtil","disconnect","close","setIsConnected","reset","resetTransactions","sendEvent","type","event","error"],"sourceRoot":"../../../src","sources":["utils/ConnectionUtil.ts"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,oBAAoB,QAAQ,qCAAqC;AAC1E,SAASC,gBAAgB,QAAQ,iCAAiC;AAClE,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,gBAAgB,QAAQ,iCAAiC;AAClE,SAASC,sBAAsB,QAAQ,uCAAuC;AAE9E,OAAO,MAAMC,cAAc,GAAG;EAC5B,MAAMC,UAAUA,CAAA,EAAG;IACjB,IAAI;MACF,MAAMN,oBAAoB,CAACM,UAAU,CAAC,CAAC;MACvCJ,eAAe,CAACK,KAAK,CAAC,CAAC;MACvBR,iBAAiB,CAACS,cAAc,CAAC,KAAK,CAAC;MACvCL,gBAAgB,CAACM,KAAK,CAAC,SAAS,CAAC;MACjCL,sBAAsB,CAACM,iBAAiB,CAAC,CAAC;MAC1CT,gBAAgB,CAACU,SAAS,CAAC;QACzBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdb,gBAAgB,CAACU,SAAS,CAAC;QACzBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE;MACT,CAAC,CAAC;IACJ;EACF;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ConnectionUtil.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc;;CAmB1B,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AccountController } from '../controllers/AccountController';
|
|
2
|
-
import { ConnectionController } from '../controllers/ConnectionController';
|
|
3
|
-
import { EventsController } from '../controllers/EventsController';
|
|
4
|
-
import { ModalController } from '../controllers/ModalController';
|
|
5
|
-
import { RouterController } from '../controllers/RouterController';
|
|
6
|
-
import { TransactionsController } from '../controllers/TransactionsController';
|
|
7
|
-
|
|
8
|
-
export const ConnectionUtil = {
|
|
9
|
-
async disconnect() {
|
|
10
|
-
try {
|
|
11
|
-
await ConnectionController.disconnect();
|
|
12
|
-
ModalController.close();
|
|
13
|
-
AccountController.setIsConnected(false);
|
|
14
|
-
RouterController.reset('Connect');
|
|
15
|
-
TransactionsController.resetTransactions();
|
|
16
|
-
EventsController.sendEvent({
|
|
17
|
-
type: 'track',
|
|
18
|
-
event: 'DISCONNECT_SUCCESS'
|
|
19
|
-
});
|
|
20
|
-
} catch (error) {
|
|
21
|
-
EventsController.sendEvent({
|
|
22
|
-
type: 'track',
|
|
23
|
-
event: 'DISCONNECT_ERROR'
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|