@dynamic-labs/sdk-react-core 4.7.2 → 4.8.0
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/CHANGELOG.md +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.cjs +2 -2
- package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.js +2 -2
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +6 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +6 -1
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +7 -2
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.d.ts +1 -2
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +7 -2
- package/src/lib/components/TransactionCard/TransactionCard.cjs +16 -12
- package/src/lib/components/TransactionCard/TransactionCard.js +16 -12
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +14 -4
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.d.ts +1 -0
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +14 -4
- package/src/lib/context/DynamicContext/DynamicContext.cjs +12 -11
- package/src/lib/context/DynamicContext/DynamicContext.js +12 -11
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.cjs +22 -0
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.d.ts +5 -0
- package/src/lib/utils/functions/getTransactionLink/getTransactionLink.js +18 -0
- package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.cjs +9 -4
- package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.js +9 -4
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.cjs +3 -3
- package/src/lib/utils/functions/isSupportedNetwork/isSupportedNetwork.js +3 -3
- package/src/lib/utils/functions/networksAndChains/networksAndChains.cjs +31 -11
- package/src/lib/utils/functions/networksAndChains/networksAndChains.d.ts +6 -2
- package/src/lib/utils/functions/networksAndChains/networksAndChains.js +31 -11
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +11 -3
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +11 -3
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +5 -8
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +5 -8
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +0 -1
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +0 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +3 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.js +3 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +3 -2
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.cjs +9 -2
- package/src/lib/widgets/DynamicWidget/views/ReceiveWalletFunds/utils/useSubmitWalletFunding/useSubmitWalletFunding.js +9 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
const getTransactionLink = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
|
|
9
|
+
try {
|
|
10
|
+
const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
|
|
11
|
+
if (!blockExplorerUrl)
|
|
12
|
+
return undefined;
|
|
13
|
+
const url = new URL(blockExplorerUrl);
|
|
14
|
+
url.pathname = `/tx/${transactionHash}`;
|
|
15
|
+
return url.toString();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.getTransactionLink = getTransactionLink;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
const getTransactionLink = (_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, transactionHash, }) {
|
|
5
|
+
try {
|
|
6
|
+
const [blockExplorerUrl] = yield walletConnector.getBlockExplorerUrlsForCurrentNetwork();
|
|
7
|
+
if (!blockExplorerUrl)
|
|
8
|
+
return undefined;
|
|
9
|
+
const url = new URL(blockExplorerUrl);
|
|
10
|
+
url.pathname = `/tx/${transactionHash}`;
|
|
11
|
+
return url.toString();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { getTransactionLink };
|
package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.cjs
CHANGED
|
@@ -4,12 +4,17 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
|
|
8
9
|
const isMultiAssetSupportedNetwork = (filteredTokenBalances, walletConnector, network) => {
|
|
9
|
-
|
|
10
|
-
((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain)
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (!network ||
|
|
11
|
+
((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) !== sdkApiCore.ChainEnum.Sol &&
|
|
12
|
+
(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) !== sdkApiCore.ChainEnum.Evm)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const isNetworkMultiAssetSupported = filteredTokenBalances
|
|
16
|
+
.flatMap((tb) => tb.networkId)
|
|
17
|
+
.includes(utils.parseChainId(network));
|
|
13
18
|
return Boolean(isNetworkMultiAssetSupported);
|
|
14
19
|
};
|
|
15
20
|
|
package/src/lib/utils/functions/isMultiAssetSupportedNetwork/isMultiAssetSupportedNetwork.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { parseChainId } from '@dynamic-labs/utils';
|
|
3
4
|
|
|
4
5
|
const isMultiAssetSupportedNetwork = (filteredTokenBalances, walletConnector, network) => {
|
|
5
|
-
|
|
6
|
-
((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain)
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (!network ||
|
|
7
|
+
((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) !== ChainEnum.Sol &&
|
|
8
|
+
(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) !== ChainEnum.Evm)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const isNetworkMultiAssetSupported = filteredTokenBalances
|
|
12
|
+
.flatMap((tb) => tb.networkId)
|
|
13
|
+
.includes(parseChainId(network));
|
|
9
14
|
return Boolean(isNetworkMultiAssetSupported);
|
|
10
15
|
};
|
|
11
16
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
const isSupportedNetwork = ({ walletConnector, network }) => {
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
7
|
+
const enabledNetworks = walletConnector.getEnabledNetworks();
|
|
8
|
+
if (!enabledNetworks.length) {
|
|
9
9
|
return true;
|
|
10
10
|
}
|
|
11
|
-
const isCurrentNetworkSupported =
|
|
11
|
+
const isCurrentNetworkSupported = enabledNetworks.some(({ chainId }) => String(chainId) === String(network));
|
|
12
12
|
return isCurrentNetworkSupported;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
const isSupportedNetwork = ({ walletConnector, network }) => {
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
3
|
+
const enabledNetworks = walletConnector.getEnabledNetworks();
|
|
4
|
+
if (!enabledNetworks.length) {
|
|
5
5
|
return true;
|
|
6
6
|
}
|
|
7
|
-
const isCurrentNetworkSupported =
|
|
7
|
+
const isCurrentNetworkSupported = enabledNetworks.some(({ chainId }) => String(chainId) === String(network));
|
|
8
8
|
return isCurrentNetworkSupported;
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -3,23 +3,43 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
var logger = require('../../../shared/logger.cjs');
|
|
9
|
+
require('@dynamic-labs/iconic');
|
|
10
|
+
require('react');
|
|
11
|
+
require('react/jsx-runtime');
|
|
12
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
require('../../../shared/consts/index.cjs');
|
|
7
18
|
|
|
8
|
-
const getNetworkInfoEntry = (chain, networkInfo) => {
|
|
9
|
-
|
|
19
|
+
const getNetworkInfoEntry = ({ chain, networkId, networkInfo, }) => {
|
|
20
|
+
var _a;
|
|
21
|
+
logger.logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', {
|
|
22
|
+
chain,
|
|
23
|
+
networkId,
|
|
24
|
+
networkInfo,
|
|
25
|
+
});
|
|
26
|
+
if (!chain || !networkId) {
|
|
10
27
|
return;
|
|
11
28
|
}
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const networkData = networkInfo[
|
|
16
|
-
networkInfo[values.ChainEnumToVerifiedCredentialName[normalizedChainSymbol.toUpperCase()]];
|
|
29
|
+
const normalizedChain = (_a = walletConnectorCore.getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.name;
|
|
30
|
+
if (!normalizedChain)
|
|
31
|
+
return;
|
|
32
|
+
const networkData = networkInfo[normalizedChain];
|
|
17
33
|
if (!networkData)
|
|
18
34
|
return;
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
logger.logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', {
|
|
36
|
+
networkData,
|
|
37
|
+
normalizedChain,
|
|
38
|
+
});
|
|
39
|
+
if (['evm', 'solana'].includes(normalizedChain)) {
|
|
40
|
+
return networkData.find((e) => e.chainId.toString() === networkId.toString());
|
|
21
41
|
}
|
|
22
|
-
//
|
|
42
|
+
// Other networks
|
|
23
43
|
return networkData[0];
|
|
24
44
|
};
|
|
25
45
|
const getEvmChainName = (chainId) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Chain } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
interface NativeCurrency {
|
|
3
3
|
decimals: number;
|
|
4
4
|
iconUrl?: string;
|
|
@@ -11,6 +11,10 @@ export interface NetworkInfoEntry {
|
|
|
11
11
|
iconUrls: string[];
|
|
12
12
|
name: string;
|
|
13
13
|
}
|
|
14
|
-
export declare const getNetworkInfoEntry: (chain
|
|
14
|
+
export declare const getNetworkInfoEntry: ({ chain, networkId, networkInfo, }: {
|
|
15
|
+
chain: Chain | undefined;
|
|
16
|
+
networkId: string | number | undefined;
|
|
17
|
+
networkInfo: Record<string, NetworkInfoEntry[]>;
|
|
18
|
+
}) => NetworkInfoEntry | undefined;
|
|
15
19
|
export declare const getEvmChainName: (chainId: number) => string;
|
|
16
20
|
export {};
|
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
2
|
+
import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { logger } from '../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import '../../../shared/consts/index.js';
|
|
3
14
|
|
|
4
|
-
const getNetworkInfoEntry = (chain, networkInfo) => {
|
|
5
|
-
|
|
15
|
+
const getNetworkInfoEntry = ({ chain, networkId, networkInfo, }) => {
|
|
16
|
+
var _a;
|
|
17
|
+
logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', {
|
|
18
|
+
chain,
|
|
19
|
+
networkId,
|
|
20
|
+
networkInfo,
|
|
21
|
+
});
|
|
22
|
+
if (!chain || !networkId) {
|
|
6
23
|
return;
|
|
7
24
|
}
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const networkData = networkInfo[
|
|
12
|
-
networkInfo[ChainEnumToVerifiedCredentialName[normalizedChainSymbol.toUpperCase()]];
|
|
25
|
+
const normalizedChain = (_a = getChainInfo(chain)) === null || _a === void 0 ? void 0 : _a.name;
|
|
26
|
+
if (!normalizedChain)
|
|
27
|
+
return;
|
|
28
|
+
const networkData = networkInfo[normalizedChain];
|
|
13
29
|
if (!networkData)
|
|
14
30
|
return;
|
|
15
|
-
|
|
16
|
-
|
|
31
|
+
logger.logVerboseTroubleshootingMessage('[getNetworkInfoEntry]', {
|
|
32
|
+
networkData,
|
|
33
|
+
normalizedChain,
|
|
34
|
+
});
|
|
35
|
+
if (['evm', 'solana'].includes(normalizedChain)) {
|
|
36
|
+
return networkData.find((e) => e.chainId.toString() === networkId.toString());
|
|
17
37
|
}
|
|
18
|
-
//
|
|
38
|
+
// Other networks
|
|
19
39
|
return networkData[0];
|
|
20
40
|
};
|
|
21
41
|
const getEvmChainName = (chainId) => {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
|
|
8
|
-
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }) => React.useMemo(() => {
|
|
8
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, }) => React.useMemo(() => {
|
|
9
9
|
var _a, _b, _c, _d, _e;
|
|
10
10
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
11
11
|
if (!networks)
|
|
@@ -20,7 +20,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
20
20
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
21
21
|
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
22
22
|
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
23
|
-
|
|
23
|
+
let solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
24
|
+
solanaNetworks = overrideNetworks(solanaNetworksOverrides, solanaNetworks);
|
|
24
25
|
const eclipseNetworks = (_e = eclipse === null || eclipse === void 0 ? void 0 : eclipse.networks) === null || _e === void 0 ? void 0 : _e.map((net) => createNetwork(net));
|
|
25
26
|
if (evmNetworksOverrides) {
|
|
26
27
|
if (Array.isArray(evmNetworksOverrides)) {
|
|
@@ -38,11 +39,18 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
38
39
|
starknet: starknetNetworks,
|
|
39
40
|
};
|
|
40
41
|
return networkConfigurations;
|
|
41
|
-
}, [
|
|
42
|
+
}, [
|
|
43
|
+
projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks,
|
|
44
|
+
cosmosNetworkOverrides,
|
|
45
|
+
evmNetworksOverrides,
|
|
46
|
+
solanaNetworksOverrides,
|
|
47
|
+
]);
|
|
42
48
|
const createNetwork = (network, parser = (input) => input) => ({
|
|
43
49
|
bech32Prefix: network.bech32Prefix,
|
|
44
50
|
blockExplorerUrls: network.blockExplorerUrls,
|
|
45
51
|
chainId: parser(network.chainId),
|
|
52
|
+
cluster: network.cluster,
|
|
53
|
+
genesisHash: network.genesisHash,
|
|
46
54
|
iconUrls: network.iconUrls,
|
|
47
55
|
lcdUrl: network.lcdUrl,
|
|
48
56
|
name: network.name,
|
|
@@ -4,6 +4,7 @@ type UseNetworkConfigurationsFromProjectSettingsProps = {
|
|
|
4
4
|
projectSettings: ProjectSettings | undefined;
|
|
5
5
|
evmNetworksOverrides?: NetworksOverrides;
|
|
6
6
|
cosmosNetworkOverrides?: NetworksOverrides;
|
|
7
|
+
solanaNetworksOverrides?: NetworksOverrides;
|
|
7
8
|
};
|
|
8
|
-
export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
|
|
9
|
+
export declare const useNetworkConfigurationsFromProjectSettings: ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, }: UseNetworkConfigurationsFromProjectSettingsProps) => {};
|
|
9
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, }) => useMemo(() => {
|
|
4
|
+
const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNetworkOverrides, evmNetworksOverrides, solanaNetworksOverrides, }) => useMemo(() => {
|
|
5
5
|
var _a, _b, _c, _d, _e;
|
|
6
6
|
const networks = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks;
|
|
7
7
|
if (!networks)
|
|
@@ -16,7 +16,8 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
16
16
|
let evmNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
17
17
|
evmNetworks = overrideNetworks(evmNetworksOverrides, evmNetworks);
|
|
18
18
|
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
19
|
-
|
|
19
|
+
let solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
20
|
+
solanaNetworks = overrideNetworks(solanaNetworksOverrides, solanaNetworks);
|
|
20
21
|
const eclipseNetworks = (_e = eclipse === null || eclipse === void 0 ? void 0 : eclipse.networks) === null || _e === void 0 ? void 0 : _e.map((net) => createNetwork(net));
|
|
21
22
|
if (evmNetworksOverrides) {
|
|
22
23
|
if (Array.isArray(evmNetworksOverrides)) {
|
|
@@ -34,11 +35,18 @@ const useNetworkConfigurationsFromProjectSettings = ({ projectSettings, cosmosNe
|
|
|
34
35
|
starknet: starknetNetworks,
|
|
35
36
|
};
|
|
36
37
|
return networkConfigurations;
|
|
37
|
-
}, [
|
|
38
|
+
}, [
|
|
39
|
+
projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks,
|
|
40
|
+
cosmosNetworkOverrides,
|
|
41
|
+
evmNetworksOverrides,
|
|
42
|
+
solanaNetworksOverrides,
|
|
43
|
+
]);
|
|
38
44
|
const createNetwork = (network, parser = (input) => input) => ({
|
|
39
45
|
bech32Prefix: network.bech32Prefix,
|
|
40
46
|
blockExplorerUrls: network.blockExplorerUrls,
|
|
41
47
|
chainId: parser(network.chainId),
|
|
48
|
+
cluster: network.cluster,
|
|
49
|
+
genesisHash: network.genesisHash,
|
|
42
50
|
iconUrls: network.iconUrls,
|
|
43
51
|
lcdUrl: network.lcdUrl,
|
|
44
52
|
name: network.name,
|
|
@@ -121,10 +121,7 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
121
121
|
// from DynamicContext is because this function might run before the network state is
|
|
122
122
|
// properly set when switching wallets, so we want to make sure we have the latest network
|
|
123
123
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : (yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(true)));
|
|
124
|
-
const
|
|
125
|
-
requestNetwork &&
|
|
126
|
-
!isNaN(Number(requestNetwork));
|
|
127
|
-
const isValidRequest = isValidEvmRequest || requestChainName !== sdkApiCore.ChainEnum.Evm;
|
|
124
|
+
const isValidRequest = requestNetwork && !isNaN(Number(requestNetwork));
|
|
128
125
|
logger.logger.logVerboseTroubleshootingMessage('[useTokenBalances] will try to fetch token balances', {
|
|
129
126
|
isLoading,
|
|
130
127
|
isValidRequest,
|
|
@@ -147,7 +144,7 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
147
144
|
forceRefresh,
|
|
148
145
|
includeNative: includeNativeBalance,
|
|
149
146
|
includePrices: includeFiat,
|
|
150
|
-
networkId:
|
|
147
|
+
networkId: Number(requestNetwork),
|
|
151
148
|
});
|
|
152
149
|
if (!response)
|
|
153
150
|
return;
|
|
@@ -179,10 +176,10 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = sdkApiCore.Ch
|
|
|
179
176
|
fetchAccountBalances();
|
|
180
177
|
}, [requestAccount, network, networkId]);
|
|
181
178
|
const { tokensFilter } = dynamicContextProps.useDynamicSettings();
|
|
182
|
-
const lowerTokenAddresses = tokenAddresses === null || tokenAddresses === void 0 ? void 0 : tokenAddresses.map((address) => address.toLowerCase());
|
|
183
|
-
const initialTokenBalances = lowerTokenAddresses
|
|
179
|
+
const lowerTokenAddresses = React.useMemo(() => tokenAddresses === null || tokenAddresses === void 0 ? void 0 : tokenAddresses.map((address) => address.toLowerCase()), [tokenAddresses]);
|
|
180
|
+
const initialTokenBalances = React.useMemo(() => lowerTokenAddresses
|
|
184
181
|
? tokenBalances$1 === null || tokenBalances$1 === void 0 ? void 0 : tokenBalances$1.filter((token) => lowerTokenAddresses === null || lowerTokenAddresses === void 0 ? void 0 : lowerTokenAddresses.includes(token.address.toLowerCase()))
|
|
185
|
-
: tokenBalances$1;
|
|
182
|
+
: tokenBalances$1, [lowerTokenAddresses, tokenBalances$1]);
|
|
186
183
|
const filteredTokenBalances = React.useMemo(() => (initialTokenBalances ? tokensFilter(initialTokenBalances) : []), [initialTokenBalances, tokensFilter]);
|
|
187
184
|
return {
|
|
188
185
|
error,
|
|
@@ -117,10 +117,7 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm
|
|
|
117
117
|
// from DynamicContext is because this function might run before the network state is
|
|
118
118
|
// properly set when switching wallets, so we want to make sure we have the latest network
|
|
119
119
|
const requestNetwork = networkId !== null && networkId !== void 0 ? networkId : (yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(true)));
|
|
120
|
-
const
|
|
121
|
-
requestNetwork &&
|
|
122
|
-
!isNaN(Number(requestNetwork));
|
|
123
|
-
const isValidRequest = isValidEvmRequest || requestChainName !== ChainEnum.Evm;
|
|
120
|
+
const isValidRequest = requestNetwork && !isNaN(Number(requestNetwork));
|
|
124
121
|
logger.logVerboseTroubleshootingMessage('[useTokenBalances] will try to fetch token balances', {
|
|
125
122
|
isLoading,
|
|
126
123
|
isValidRequest,
|
|
@@ -143,7 +140,7 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm
|
|
|
143
140
|
forceRefresh,
|
|
144
141
|
includeNative: includeNativeBalance,
|
|
145
142
|
includePrices: includeFiat,
|
|
146
|
-
networkId:
|
|
143
|
+
networkId: Number(requestNetwork),
|
|
147
144
|
});
|
|
148
145
|
if (!response)
|
|
149
146
|
return;
|
|
@@ -175,10 +172,10 @@ const useTokenBalances = ({ accountAddress, networkId, chainName = ChainEnum.Evm
|
|
|
175
172
|
fetchAccountBalances();
|
|
176
173
|
}, [requestAccount, network, networkId]);
|
|
177
174
|
const { tokensFilter } = useDynamicSettings();
|
|
178
|
-
const lowerTokenAddresses = tokenAddresses === null || tokenAddresses === void 0 ? void 0 : tokenAddresses.map((address) => address.toLowerCase());
|
|
179
|
-
const initialTokenBalances = lowerTokenAddresses
|
|
175
|
+
const lowerTokenAddresses = useMemo(() => tokenAddresses === null || tokenAddresses === void 0 ? void 0 : tokenAddresses.map((address) => address.toLowerCase()), [tokenAddresses]);
|
|
176
|
+
const initialTokenBalances = useMemo(() => lowerTokenAddresses
|
|
180
177
|
? tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => lowerTokenAddresses === null || lowerTokenAddresses === void 0 ? void 0 : lowerTokenAddresses.includes(token.address.toLowerCase()))
|
|
181
|
-
: tokenBalances;
|
|
178
|
+
: tokenBalances, [lowerTokenAddresses, tokenBalances]);
|
|
182
179
|
const filteredTokenBalances = useMemo(() => (initialTokenBalances ? tokensFilter(initialTokenBalances) : []), [initialTokenBalances, tokensFilter]);
|
|
183
180
|
return {
|
|
184
181
|
error,
|
|
@@ -92,7 +92,6 @@ const useWalletConnectors = ({ connectedWallets, walletConnectorOptions, setMult
|
|
|
92
92
|
const setPrimaryWallet = React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
93
|
const newPrimaryWallet = yield getSelectedWallet(walletId);
|
|
94
94
|
if (!primaryWalletId) {
|
|
95
|
-
yield newPrimaryWallet.connector.connect();
|
|
96
95
|
updatePrimaryWalletId.updatePrimaryWalletId(walletId);
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
@@ -88,7 +88,6 @@ const useWalletConnectors = ({ connectedWallets, walletConnectorOptions, setMult
|
|
|
88
88
|
const setPrimaryWallet = useCallback((walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
89
|
const newPrimaryWallet = yield getSelectedWallet(walletId);
|
|
90
90
|
if (!primaryWalletId) {
|
|
91
|
-
yield newPrimaryWallet.connector.connect();
|
|
92
91
|
updatePrimaryWalletId(walletId);
|
|
93
92
|
return;
|
|
94
93
|
}
|
|
@@ -120,6 +120,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
120
120
|
const [isNativeToken, setIsNativeToken] = React.useState(false);
|
|
121
121
|
const [currentToken, setCurrentToken] = React.useState(undefined);
|
|
122
122
|
const [tokenBalances, setTokenBalances] = React.useState(undefined);
|
|
123
|
+
const [transactionHash, setTransactionHash] = React.useState(undefined);
|
|
123
124
|
const { showFiat } = useInternalDynamicContext.useInternalDynamicContext();
|
|
124
125
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
125
126
|
const { chain } = useFetchChain.useFetchChain(walletConnector);
|
|
@@ -214,12 +215,13 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
214
215
|
if (!txHash)
|
|
215
216
|
return;
|
|
216
217
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(txHash);
|
|
218
|
+
setTransactionHash(txHash);
|
|
217
219
|
setStage('success');
|
|
218
220
|
handleSuccessToRefreshBalance(txHash);
|
|
219
221
|
}), currentToken: currentToken, isNativeToken: isNativeToken, transactionValue: getTransactionValue(transaction, isNativeToken), sendBalanceTransaction: true }));
|
|
220
222
|
const buildSuccessState = () => {
|
|
221
223
|
var _a;
|
|
222
|
-
return (jsxRuntime.jsx(TransactionStatusLayout.TransactionStatusLayout, { transactionValue: getTransactionValue(transaction, isNativeToken), destinationAddress: (_a = transaction.to) !== null && _a !== void 0 ? _a : '', networkCurrency: networkCurrency, networkName: networkData.name || '', NetworkIcon: currencyIcon, onClickClose: onClickClose, onDone: () => onDone === null || onDone === void 0 ? void 0 : onDone(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, transaction: transaction, currentToken: currentToken, isNativeToken: isNativeToken }));
|
|
224
|
+
return (jsxRuntime.jsx(TransactionStatusLayout.TransactionStatusLayout, { transactionValue: getTransactionValue(transaction, isNativeToken), destinationAddress: (_a = transaction.to) !== null && _a !== void 0 ? _a : '', networkCurrency: networkCurrency, networkName: networkData.name || '', NetworkIcon: currencyIcon, onClickClose: onClickClose, onDone: () => onDone === null || onDone === void 0 ? void 0 : onDone(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, transaction: transaction, currentToken: currentToken, isNativeToken: isNativeToken, transactionHash: transactionHash }));
|
|
223
225
|
};
|
|
224
226
|
const getCurrentView = () => {
|
|
225
227
|
switch (stage) {
|
|
@@ -116,6 +116,7 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
116
116
|
const [isNativeToken, setIsNativeToken] = useState(false);
|
|
117
117
|
const [currentToken, setCurrentToken] = useState(undefined);
|
|
118
118
|
const [tokenBalances, setTokenBalances] = useState(undefined);
|
|
119
|
+
const [transactionHash, setTransactionHash] = useState(undefined);
|
|
119
120
|
const { showFiat } = useInternalDynamicContext();
|
|
120
121
|
const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
121
122
|
const { chain } = useFetchChain(walletConnector);
|
|
@@ -210,12 +211,13 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
|
|
|
210
211
|
if (!txHash)
|
|
211
212
|
return;
|
|
212
213
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(txHash);
|
|
214
|
+
setTransactionHash(txHash);
|
|
213
215
|
setStage('success');
|
|
214
216
|
handleSuccessToRefreshBalance(txHash);
|
|
215
217
|
}), currentToken: currentToken, isNativeToken: isNativeToken, transactionValue: getTransactionValue(transaction, isNativeToken), sendBalanceTransaction: true }));
|
|
216
218
|
const buildSuccessState = () => {
|
|
217
219
|
var _a;
|
|
218
|
-
return (jsx(TransactionStatusLayout, { transactionValue: getTransactionValue(transaction, isNativeToken), destinationAddress: (_a = transaction.to) !== null && _a !== void 0 ? _a : '', networkCurrency: networkCurrency, networkName: networkData.name || '', NetworkIcon: currencyIcon, onClickClose: onClickClose, onDone: () => onDone === null || onDone === void 0 ? void 0 : onDone(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, transaction: transaction, currentToken: currentToken, isNativeToken: isNativeToken }));
|
|
220
|
+
return (jsx(TransactionStatusLayout, { transactionValue: getTransactionValue(transaction, isNativeToken), destinationAddress: (_a = transaction.to) !== null && _a !== void 0 ? _a : '', networkCurrency: networkCurrency, networkName: networkData.name || '', NetworkIcon: currencyIcon, onClickClose: onClickClose, onDone: () => onDone === null || onDone === void 0 ? void 0 : onDone(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, transaction: transaction, currentToken: currentToken, isNativeToken: isNativeToken, transactionHash: transactionHash }));
|
|
219
221
|
};
|
|
220
222
|
const getCurrentView = () => {
|
|
221
223
|
switch (stage) {
|
|
@@ -106,9 +106,10 @@ const useFetchChain = (connector) => {
|
|
|
106
106
|
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
107
107
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
108
108
|
};
|
|
109
|
+
const enabledNetworks = connector === null || connector === void 0 ? void 0 : connector.getEnabledNetworks();
|
|
109
110
|
/* istanbul ignore else */
|
|
110
|
-
if (chainId &&
|
|
111
|
-
const result =
|
|
111
|
+
if (chainId && enabledNetworks.length > 0) {
|
|
112
|
+
const result = enabledNetworks.find((element) => element.chainId === chainId);
|
|
112
113
|
chainWithIcon.name =
|
|
113
114
|
(_b = (_a = result === null || result === void 0 ? void 0 : result.vanityName) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.name) !== null && _b !== void 0 ? _b : chainWithIcon.name;
|
|
114
115
|
chainWithIcon.icon = result === null || result === void 0 ? void 0 : result.iconUrls[0];
|
|
@@ -102,9 +102,10 @@ const useFetchChain = (connector) => {
|
|
|
102
102
|
name: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.displayName,
|
|
103
103
|
symbol: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.symbol,
|
|
104
104
|
};
|
|
105
|
+
const enabledNetworks = connector === null || connector === void 0 ? void 0 : connector.getEnabledNetworks();
|
|
105
106
|
/* istanbul ignore else */
|
|
106
|
-
if (chainId &&
|
|
107
|
-
const result =
|
|
107
|
+
if (chainId && enabledNetworks.length > 0) {
|
|
108
|
+
const result = enabledNetworks.find((element) => element.chainId === chainId);
|
|
108
109
|
chainWithIcon.name =
|
|
109
110
|
(_b = (_a = result === null || result === void 0 ? void 0 : result.vanityName) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.name) !== null && _b !== void 0 ? _b : chainWithIcon.name;
|
|
110
111
|
chainWithIcon.icon = result === null || result === void 0 ? void 0 : result.iconUrls[0];
|
|
@@ -12,6 +12,7 @@ var logger = require('../../../../../../shared/logger.cjs');
|
|
|
12
12
|
var pixelToRem = require('../../../../../../utils/functions/pixelToRem/pixelToRem.cjs');
|
|
13
13
|
var useFundWithWallet = require('../../../../../../utils/hooks/useFundWithWallet/useFundWithWallet.cjs');
|
|
14
14
|
var DynamicWidgetContext = require('../../../../context/DynamicWidgetContext.cjs');
|
|
15
|
+
var getTransactionLink = require('../../../../../../utils/functions/getTransactionLink/getTransactionLink.cjs');
|
|
15
16
|
|
|
16
17
|
const useSubmitWalletFunding = () => {
|
|
17
18
|
const { fund } = useFundWithWallet.useInternalFundWithWallet();
|
|
@@ -34,8 +35,14 @@ const useSubmitWalletFunding = () => {
|
|
|
34
35
|
token: token === 'native' ? undefined : token,
|
|
35
36
|
});
|
|
36
37
|
logger.logger.info(`Funding with wallet succeeded with transaction id: ${txId}`);
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
let txLink;
|
|
39
|
+
if (txId) {
|
|
40
|
+
txLink = yield getTransactionLink.getTransactionLink({
|
|
41
|
+
transactionHash: txId,
|
|
42
|
+
walletConnector: wallet.connector,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const TxnSuccessAlert = (jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', color: 'current-color', children: [t('dyn_wallet_funding.success'), txLink && (jsxRuntime.jsx(Typography.Typography, { as: 'a', href: txLink, target: '_blank', rel: 'noreferrer', style: {
|
|
39
46
|
marginLeft: pixelToRem.pixelToRem(4),
|
|
40
47
|
textDecoration: 'underline',
|
|
41
48
|
textDecorationThickness: pixelToRem.pixelToRem(1),
|
|
@@ -8,6 +8,7 @@ import { logger } from '../../../../../../shared/logger.js';
|
|
|
8
8
|
import { pixelToRem } from '../../../../../../utils/functions/pixelToRem/pixelToRem.js';
|
|
9
9
|
import { useInternalFundWithWallet } from '../../../../../../utils/hooks/useFundWithWallet/useFundWithWallet.js';
|
|
10
10
|
import { useWidgetContext } from '../../../../context/DynamicWidgetContext.js';
|
|
11
|
+
import { getTransactionLink } from '../../../../../../utils/functions/getTransactionLink/getTransactionLink.js';
|
|
11
12
|
|
|
12
13
|
const useSubmitWalletFunding = () => {
|
|
13
14
|
const { fund } = useInternalFundWithWallet();
|
|
@@ -30,8 +31,14 @@ const useSubmitWalletFunding = () => {
|
|
|
30
31
|
token: token === 'native' ? undefined : token,
|
|
31
32
|
});
|
|
32
33
|
logger.info(`Funding with wallet succeeded with transaction id: ${txId}`);
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
let txLink;
|
|
35
|
+
if (txId) {
|
|
36
|
+
txLink = yield getTransactionLink({
|
|
37
|
+
transactionHash: txId,
|
|
38
|
+
walletConnector: wallet.connector,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const TxnSuccessAlert = (jsxs(Typography, { variant: 'body_normal', color: 'current-color', children: [t('dyn_wallet_funding.success'), txLink && (jsx(Typography, { as: 'a', href: txLink, target: '_blank', rel: 'noreferrer', style: {
|
|
35
42
|
marginLeft: pixelToRem(4),
|
|
36
43
|
textDecoration: 'underline',
|
|
37
44
|
textDecorationThickness: pixelToRem(1),
|