@dynamic-labs/sdk-react-core 1.1.0-alpha.1 → 1.1.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/CHANGELOG.md +22 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +12 -12
- package/src/lib/components/CopyButton/CopyButton.d.ts +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -2
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/data/api.cjs +0 -13
- package/src/lib/data/api.d.ts +1 -2
- package/src/lib/data/api.js +1 -13
- package/src/lib/locale/en/translation.cjs +118 -1
- package/src/lib/locale/en/translation.d.ts +118 -1
- package/src/lib/locale/en/translation.js +118 -1
- package/src/lib/shared/consts/index.cjs +1 -0
- package/src/lib/shared/consts/index.js +1 -0
- package/src/lib/shared/types/index.d.ts +2 -1
- package/src/lib/shared/utils/functions/chain/getChainIcon.cjs +1 -0
- package/src/lib/shared/utils/functions/chain/getChainIcon.js +2 -1
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.d.ts +1 -1
- package/src/lib/utils/hooks/useProcessNetworkConfigurations/index.d.ts +1 -0
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs → useProcessNetworkConfigurations/useProcessNetworkConfigurations.cjs} +53 -67
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.d.ts → useProcessNetworkConfigurations/useProcessNetworkConfigurations.d.ts} +3 -2
- package/src/lib/utils/hooks/{useFetchNetworkConfigurations/useFetchNetworkConfigurations.js → useProcessNetworkConfigurations/useProcessNetworkConfigurations.js} +53 -67
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +3 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +3 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +3 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +3 -2
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +1 -1
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +6 -2
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +6 -2
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +10 -5
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +10 -5
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +7 -4
- package/src/lib/views/PendingConnectView/PendingConnectView.js +7 -4
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +8 -5
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +8 -5
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +11 -8
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +11 -8
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +4 -3
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +4 -3
- package/src/lib/views/WalletList/data.d.ts +1 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +3 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.js +3 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +4 -3
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +4 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +4 -1
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/index.d.ts +0 -1
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/index.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +0 -0
- /package/src/lib/utils/hooks/{useFetchNetworkConfigurations → useProcessNetworkConfigurations}/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +0 -0
|
@@ -54,6 +54,18 @@ const translation = {
|
|
|
54
54
|
title: 'Connect to {{appName}}',
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
|
+
/**
|
|
58
|
+
* @description copy keys for Dynamic Captcha
|
|
59
|
+
* @default
|
|
60
|
+
* {
|
|
61
|
+
verify_user_subtitle: 'We need to quickly verify you’re human before we proceed.',
|
|
62
|
+
verify_user_title: "Let's verify you're human",
|
|
63
|
+
}
|
|
64
|
+
*/
|
|
65
|
+
dyn_captcha: {
|
|
66
|
+
verify_user_subtitle: 'We need to quickly verify you’re human before we proceed.',
|
|
67
|
+
verify_user_title: "Let's verify you're human",
|
|
68
|
+
},
|
|
57
69
|
/**
|
|
58
70
|
* @description copy keys for chainalysis blocked wallet view
|
|
59
71
|
* @default
|
|
@@ -114,6 +126,8 @@ const translation = {
|
|
|
114
126
|
error_message: 'This network is not available, please update.',
|
|
115
127
|
title: 'Update Network',
|
|
116
128
|
},
|
|
129
|
+
update_email_tooltip:
|
|
130
|
+
'This email is tied to your wallet so cannot be updated',
|
|
117
131
|
}
|
|
118
132
|
*/
|
|
119
133
|
dyn_collect_user_data: {
|
|
@@ -163,6 +177,7 @@ const translation = {
|
|
|
163
177
|
error_message: 'This network is not available, please update.',
|
|
164
178
|
title: 'Update Network',
|
|
165
179
|
},
|
|
180
|
+
update_email_tooltip: 'This email is tied to your wallet so cannot be updated',
|
|
166
181
|
},
|
|
167
182
|
/**
|
|
168
183
|
* @description copy keys for email verification view after email logging in with magiclink
|
|
@@ -266,6 +281,12 @@ const translation = {
|
|
|
266
281
|
wallet_list: {
|
|
267
282
|
button_only: 'Continue with a wallet',
|
|
268
283
|
},
|
|
284
|
+
wrong_social_account: {
|
|
285
|
+
retry_button: 'Try again',
|
|
286
|
+
retry_title: 'Please connect with: ',
|
|
287
|
+
subtitle: 'You must connect with the same account you originally signed in with.',
|
|
288
|
+
title: 'Whoops. Wrong Account',
|
|
289
|
+
},
|
|
269
290
|
}
|
|
270
291
|
*/
|
|
271
292
|
dyn_login: {
|
|
@@ -311,6 +332,12 @@ const translation = {
|
|
|
311
332
|
wallet_list: {
|
|
312
333
|
button_only: 'Continue with a wallet',
|
|
313
334
|
},
|
|
335
|
+
wrong_social_account: {
|
|
336
|
+
retry_button: 'Try again',
|
|
337
|
+
retry_title: 'Please connect with: ',
|
|
338
|
+
subtitle: 'You must connect with the same account you originally signed in with.',
|
|
339
|
+
title: 'Whoops. Wrong Account',
|
|
340
|
+
},
|
|
314
341
|
},
|
|
315
342
|
/**
|
|
316
343
|
* @description copy keys for Dynamic manage passkeys view which are used inside dynamic widget
|
|
@@ -352,14 +379,21 @@ const translation = {
|
|
|
352
379
|
* {
|
|
353
380
|
cancel_button: "No, I'll use a different email",
|
|
354
381
|
confirm_button: 'Yes, link to existing account',
|
|
382
|
+
errors: {
|
|
383
|
+
merge_error: 'Something went wrong, please try again.',
|
|
384
|
+
},
|
|
355
385
|
existing_account: 'An account already exists that uses',
|
|
356
386
|
existing_account_trail: 'email.',
|
|
357
387
|
title: 'Would you like to link this wallet to this existing account?',
|
|
388
|
+
},
|
|
358
389
|
}
|
|
359
390
|
*/
|
|
360
391
|
dyn_merge_user_accounts: {
|
|
361
392
|
cancel_button: "No, I'll use a different email",
|
|
362
393
|
confirm_button: 'Yes, link to existing account',
|
|
394
|
+
errors: {
|
|
395
|
+
merge_error: 'Something went wrong, please try again.',
|
|
396
|
+
},
|
|
363
397
|
existing_account: 'An account already exists that uses',
|
|
364
398
|
existing_account_trail: 'email.',
|
|
365
399
|
title: 'Would you like to link this wallet to this existing account?',
|
|
@@ -553,7 +587,7 @@ const translation = {
|
|
|
553
587
|
'To complete this process, ensure you are using the same device/browser.',
|
|
554
588
|
start_button: 'Send me an email',
|
|
555
589
|
title: 'Initiate Request',
|
|
556
|
-
}
|
|
590
|
+
},
|
|
557
591
|
}
|
|
558
592
|
*/
|
|
559
593
|
dyn_passkey_recovery: {
|
|
@@ -577,6 +611,80 @@ const translation = {
|
|
|
577
611
|
title: 'Initiate Request',
|
|
578
612
|
},
|
|
579
613
|
},
|
|
614
|
+
/**
|
|
615
|
+
* @description copy keys for Dynamic pending wallet connection
|
|
616
|
+
* @default
|
|
617
|
+
* {
|
|
618
|
+
mobile: 'Click connect in your mobile wallet',
|
|
619
|
+
computer: 'Click connect in your wallet popup',
|
|
620
|
+
}
|
|
621
|
+
*/
|
|
622
|
+
dyn_pending_connection: {
|
|
623
|
+
mobile: 'Click connect in your mobile wallet',
|
|
624
|
+
computer: 'Click connect in your wallet popup',
|
|
625
|
+
},
|
|
626
|
+
/**
|
|
627
|
+
* @description copy keys for Dynamic pending signature, we have overrides for phantom ledger which does not support message signing.
|
|
628
|
+
* @default
|
|
629
|
+
* {
|
|
630
|
+
click_to_sign: 'Click to Sign',
|
|
631
|
+
note: 'Note: ',
|
|
632
|
+
phantom_ledger_sign: "Click sign in your wallet to confirm you own this wallet (this doesn't cost gas).",
|
|
633
|
+
phantom_ledger_warning: "Ledger with Phantom doesn't support message signing. When logging in, a small fee (which should not apply) may appear. See below to learn more.",
|
|
634
|
+
regular_sign_description: 'Click sign-in in your wallet to confirm you own this wallet.',
|
|
635
|
+
}
|
|
636
|
+
*/
|
|
637
|
+
dyn_pending_signature: {
|
|
638
|
+
click_to_sign: 'Click to Sign',
|
|
639
|
+
note: 'Note: ',
|
|
640
|
+
phantom_ledger_sign: "Click sign in your wallet to confirm you own this wallet (this doesn't cost gas).",
|
|
641
|
+
phantom_ledger_warning: "Ledger with Phantom doesn't support message signing. When logging in, a small fee (which should not apply) may appear. See below to learn more.",
|
|
642
|
+
regular_sign_description: 'Click sign-in in your wallet to confirm you own this wallet.',
|
|
643
|
+
},
|
|
644
|
+
/**
|
|
645
|
+
* @description copy keys for Dynamic QR code Wallet Connection Pop-Up
|
|
646
|
+
* @default
|
|
647
|
+
* {
|
|
648
|
+
copy_button: 'Copy QR URI',
|
|
649
|
+
open_button: 'Open {{wallet}} App',
|
|
650
|
+
scan_title: "Scan this QR code from your mobile wallet or phone's camera to connect.",
|
|
651
|
+
wallet_not_installed: {
|
|
652
|
+
browser_install: 'Install {{browser}} extension',
|
|
653
|
+
install: 'Install {{wallet}} extension to connect',
|
|
654
|
+
refresh: 'Refresh the page once installed',
|
|
655
|
+
select: 'Select from your preferred options below:',
|
|
656
|
+
},
|
|
657
|
+
}
|
|
658
|
+
*/
|
|
659
|
+
dyn_qr_code: {
|
|
660
|
+
copy_button: 'Copy QR URI',
|
|
661
|
+
open_button: 'Open {{wallet}} App',
|
|
662
|
+
scan_title: "Scan this QR code from your mobile wallet or phone's camera to connect.",
|
|
663
|
+
wallet_not_installed: {
|
|
664
|
+
browser_install: 'Install {{browser}} extension',
|
|
665
|
+
install: 'Install {{wallet}} extension to connect',
|
|
666
|
+
refresh: 'Refresh the page once installed',
|
|
667
|
+
select: 'Select from your preferred options below:',
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
/**
|
|
671
|
+
* @description copy keys for Dynamic wallet locked/disconnected
|
|
672
|
+
* @default
|
|
673
|
+
* {
|
|
674
|
+
connect_continue: 'Connect your wallet to continue',
|
|
675
|
+
title: 'Welcome back',
|
|
676
|
+
subtitle: "We couldn't connect to your wallet. Click connect to retry the connection ",
|
|
677
|
+
connect: 'Connect wallet',
|
|
678
|
+
logout: 'Log out',
|
|
679
|
+
}
|
|
680
|
+
*/
|
|
681
|
+
dyn_wallet_locked: {
|
|
682
|
+
connect_continue: 'Connect your wallet to continue',
|
|
683
|
+
title: 'Welcome back',
|
|
684
|
+
subtitle: "We couldn't connect to your wallet. Click connect to retry the connection ",
|
|
685
|
+
connect: 'Connect wallet',
|
|
686
|
+
logout: 'Log out',
|
|
687
|
+
},
|
|
580
688
|
/**
|
|
581
689
|
* @description copy keys for passkeys creation flow for existent embedded wallets
|
|
582
690
|
* @default
|
|
@@ -930,12 +1038,21 @@ const translation = {
|
|
|
930
1038
|
* @default
|
|
931
1039
|
* {
|
|
932
1040
|
sign: {
|
|
1041
|
+
spinner: {
|
|
1042
|
+
cancel: 'Cancel',
|
|
1043
|
+
confirm_transfer:
|
|
1044
|
+
'Sign the message to confirm transferring this wallet to this account.',
|
|
1045
|
+
},
|
|
933
1046
|
title: 'Sign to confirm transfer',
|
|
934
1047
|
},
|
|
935
1048
|
}
|
|
936
1049
|
*/
|
|
937
1050
|
dyn_wallet_transfer: {
|
|
938
1051
|
sign: {
|
|
1052
|
+
spinner: {
|
|
1053
|
+
cancel: 'Cancel',
|
|
1054
|
+
confirm_transfer: 'Sign the message to confirm transferring this wallet to this account.',
|
|
1055
|
+
},
|
|
939
1056
|
title: 'Sign to confirm transfer',
|
|
940
1057
|
},
|
|
941
1058
|
},
|
|
@@ -44,7 +44,7 @@ export type Icon = React.FunctionComponent<React.SVGProps<SVGSVGElement> & {
|
|
|
44
44
|
title?: string | undefined;
|
|
45
45
|
}>;
|
|
46
46
|
export type WalletNamesUnion = 'Coinbase Wallet' | 'Coinbase Wallet (Solana)' | 'MetaMask' | 'Phantom' | 'Phantom (EVM)' | 'Phantom (Ledger)' | 'Venly' | 'Rainbow' | 'Solflare' | 'Glow' | 'Slope' | 'Blocto (Flow)' | 'Blocto (EVM)' | 'Blocto (App)' | 'Brave Wallet (EVM)' | 'Brave Wallet (Solana)' | 'Braavos' | 'Argent X' | 'Dapper' | 'Opera Wallet' | 'Injected Wallet' | 'Exodus Wallet (EVM)' | 'Exodus Wallet (Solana)' | 'ZenGo' | 'Lilico';
|
|
47
|
-
export type ChainNamesUnion = 'Solana' | 'Ethereum' | 'Flow' | 'EVM' | 'Algorand' | 'Starknet' | 'Cosmos' | 'Axelar' | 'Osmosis';
|
|
47
|
+
export type ChainNamesUnion = 'Solana' | 'Ethereum' | 'Flow' | 'EVM' | 'Algorand' | 'Starknet' | 'Cosmos' | 'Axelar' | 'Osmosis' | 'Bitcoin';
|
|
48
48
|
export interface WalletOption {
|
|
49
49
|
isInstalledOnBrowser: boolean;
|
|
50
50
|
key: string;
|
|
@@ -157,6 +157,7 @@ export type ChainToWalletMap = {
|
|
|
157
157
|
primary_chain: string;
|
|
158
158
|
wallets: {
|
|
159
159
|
algorand?: string;
|
|
160
|
+
bitcoin?: string;
|
|
160
161
|
cosmos?: string;
|
|
161
162
|
evm?: string;
|
|
162
163
|
flow?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlgorandIcon, CosmosIcon, EthereumIcon, FlowIcon, SolanaIcon, StarknetIcon } from '@dynamic-labs/iconic';
|
|
1
|
+
import { AlgorandIcon, BitcoinIcon, CosmosIcon, EthereumIcon, FlowIcon, SolanaIcon, StarknetIcon } from '@dynamic-labs/iconic';
|
|
2
2
|
import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
@@ -7,6 +7,7 @@ import { ReactComponent as SvgError } from '../../../assets/error.js';
|
|
|
7
7
|
|
|
8
8
|
const chainIconMap = {
|
|
9
9
|
algorand: AlgorandIcon,
|
|
10
|
+
bitcoin: BitcoinIcon,
|
|
10
11
|
cosmos: CosmosIcon,
|
|
11
12
|
evm: EthereumIcon,
|
|
12
13
|
flow: FlowIcon,
|
|
@@ -13,7 +13,7 @@ type Props = {
|
|
|
13
13
|
walletProvider: WalletProvider;
|
|
14
14
|
};
|
|
15
15
|
export declare const getVerifyArgs: ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }: Props) => Promise<{
|
|
16
|
-
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" |
|
|
16
|
+
chain: "ETH" | "FLOW" | "SOL" | "EVM" | "ALGO" | "STARK" | "ATOM" | "COSMOS" | "BTC";
|
|
17
17
|
messageToSign: string;
|
|
18
18
|
network: string;
|
|
19
19
|
publicWalletAddress: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useProcessNetworkConfigurations } from './useProcessNetworkConfigurations';
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var utils = require('@dynamic-labs/utils');
|
|
7
6
|
var validators = require('../../../context/DynamicContext/validators.cjs');
|
|
8
|
-
var api = require('../../../data/api.cjs');
|
|
9
7
|
require('@dynamic-labs/sdk-api');
|
|
10
8
|
require('../../../shared/logger.cjs');
|
|
11
9
|
require('@dynamic-labs/iconic');
|
|
@@ -18,12 +16,12 @@ require('../../constants/colors.cjs');
|
|
|
18
16
|
var localStorage$1 = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
17
|
require('viem');
|
|
20
18
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
19
|
+
require('@dynamic-labs/utils');
|
|
21
20
|
require('../../../shared/consts/index.cjs');
|
|
22
21
|
var usePrevious = require('../usePrevious/usePrevious.cjs');
|
|
23
22
|
var mergeCustomerEvmNetworksWithServerNetworks = require('./utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs');
|
|
24
23
|
|
|
25
|
-
const
|
|
26
|
-
const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, maxRetries = MAX_RETRIES, }) => {
|
|
24
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }) => {
|
|
27
25
|
var _a;
|
|
28
26
|
/**
|
|
29
27
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
@@ -32,7 +30,6 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
32
30
|
const VERSION = 2;
|
|
33
31
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage.useLocalStorage(localStorage.NETWORKS_STORAGE_KEY, undefined, validators.validateLocalStorageExpiry);
|
|
34
32
|
const [loading, setLoading] = React.useState(false);
|
|
35
|
-
const [retries, setRetries] = React.useState(0);
|
|
36
33
|
const [completed, setCompleted] = React.useState(false);
|
|
37
34
|
const [lsNetworksExists, setlsNetworksExists] = React.useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) && (lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
38
35
|
// Stringify the objects for easy comparison
|
|
@@ -84,76 +81,65 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
84
81
|
handleRemoveLsNetworks,
|
|
85
82
|
]);
|
|
86
83
|
React.useEffect(() => {
|
|
87
|
-
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
|
+
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
88
86
|
setLoading(true);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
environmentId,
|
|
136
|
-
expiry,
|
|
137
|
-
version: VERSION,
|
|
138
|
-
});
|
|
139
|
-
setlsNetworksExists(true);
|
|
140
|
-
})
|
|
141
|
-
.catch((e) => {
|
|
142
|
-
setRetries((currentRetries) => currentRetries + 1);
|
|
143
|
-
})
|
|
144
|
-
.finally(() => {
|
|
145
|
-
setLoading(false);
|
|
87
|
+
const { networks } = projectSettings;
|
|
88
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
89
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
90
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
91
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
92
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
93
|
+
let mergedEvmNetworks;
|
|
94
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
95
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
96
|
+
chainId: parser(network.chainId),
|
|
97
|
+
iconUrls: network.iconUrls,
|
|
98
|
+
lcdUrl: network.lcdUrl,
|
|
99
|
+
name: network.name,
|
|
100
|
+
nativeCurrency: network.nativeCurrency,
|
|
101
|
+
networkId: parser(network.networkId),
|
|
102
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
103
|
+
rpcUrls: network.rpcUrls,
|
|
104
|
+
vanityName: network.vanityName,
|
|
105
|
+
});
|
|
106
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
107
|
+
const serverNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
108
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
109
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
110
|
+
if (!serverNetworks && (customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.length)) {
|
|
111
|
+
mergedEvmNetworks = customerEvmNetworks;
|
|
112
|
+
}
|
|
113
|
+
if (!customerEvmNetworks && (serverNetworks === null || serverNetworks === void 0 ? void 0 : serverNetworks.length)) {
|
|
114
|
+
mergedEvmNetworks = serverNetworks;
|
|
115
|
+
}
|
|
116
|
+
if (serverNetworks !== undefined &&
|
|
117
|
+
serverNetworks.length &&
|
|
118
|
+
customerEvmNetworks !== undefined &&
|
|
119
|
+
customerEvmNetworks.length) {
|
|
120
|
+
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks.mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
121
|
+
}
|
|
122
|
+
setLsNetworks({
|
|
123
|
+
configurations: {
|
|
124
|
+
cosmos: cosmosNetworks,
|
|
125
|
+
evm: mergedEvmNetworks,
|
|
126
|
+
solana: solanaNetworks,
|
|
127
|
+
starknet: starknetNetworks,
|
|
128
|
+
},
|
|
129
|
+
environmentId,
|
|
130
|
+
expiry,
|
|
131
|
+
version: VERSION,
|
|
146
132
|
});
|
|
133
|
+
setlsNetworksExists(true);
|
|
134
|
+
setLoading(false);
|
|
147
135
|
}
|
|
148
136
|
}, [
|
|
149
|
-
authToken,
|
|
150
137
|
environmentId,
|
|
151
138
|
loading,
|
|
152
139
|
customerEvmNetworks,
|
|
153
140
|
lsNetworksExists,
|
|
154
|
-
maxRetries,
|
|
155
|
-
retries,
|
|
156
141
|
setLsNetworks,
|
|
142
|
+
projectSettings,
|
|
157
143
|
]);
|
|
158
144
|
return {
|
|
159
145
|
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
@@ -161,4 +147,4 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
161
147
|
};
|
|
162
148
|
};
|
|
163
149
|
|
|
164
|
-
exports.
|
|
150
|
+
exports.useProcessNetworkConfigurations = useProcessNetworkConfigurations;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
1
2
|
import { GenericNetwork } from '@dynamic-labs/types';
|
|
2
3
|
export type fetchNetworkConfigurationsProps = {
|
|
3
4
|
authToken: string | undefined;
|
|
4
5
|
environmentId: string;
|
|
5
6
|
evmNetworks?: GenericNetwork[];
|
|
6
|
-
|
|
7
|
+
projectSettings?: ProjectSettings;
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const useProcessNetworkConfigurations: ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }: fetchNetworkConfigurationsProps) => {
|
|
9
10
|
configurations: import("@dynamic-labs/types").NetworkConfigurationMap | undefined;
|
|
10
11
|
handleRemoveLsNetworks: () => void;
|
|
11
12
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
2
|
import { validateLocalStorageExpiry } from '../../../context/DynamicContext/validators.js';
|
|
4
|
-
import { fetchNetworkSettings } from '../../../data/api.js';
|
|
5
3
|
import '@dynamic-labs/sdk-api';
|
|
6
4
|
import '../../../shared/logger.js';
|
|
7
5
|
import '@dynamic-labs/iconic';
|
|
@@ -14,12 +12,12 @@ import '../../constants/colors.js';
|
|
|
14
12
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
13
|
import 'viem';
|
|
16
14
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
17
16
|
import '../../../shared/consts/index.js';
|
|
18
17
|
import { usePrevious } from '../usePrevious/usePrevious.js';
|
|
19
18
|
import { mergeCustomerEvmNetworksWithServerNetworks } from './utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js';
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, maxRetries = MAX_RETRIES, }) => {
|
|
20
|
+
const useProcessNetworkConfigurations = ({ authToken, environmentId, evmNetworks: customerEvmNetworks, projectSettings, }) => {
|
|
23
21
|
var _a;
|
|
24
22
|
/**
|
|
25
23
|
* This is the version of the local storage object. If the version changes, the local storage object will be removed.
|
|
@@ -28,7 +26,6 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
28
26
|
const VERSION = 2;
|
|
29
27
|
const [lsNetworks, setLsNetworks, removeLsNetworks] = useLocalStorage(NETWORKS_STORAGE_KEY, undefined, validateLocalStorageExpiry);
|
|
30
28
|
const [loading, setLoading] = useState(false);
|
|
31
|
-
const [retries, setRetries] = useState(0);
|
|
32
29
|
const [completed, setCompleted] = useState(false);
|
|
33
30
|
const [lsNetworksExists, setlsNetworksExists] = useState(Boolean(lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations) && (lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.version) === VERSION);
|
|
34
31
|
// Stringify the objects for easy comparison
|
|
@@ -80,76 +77,65 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
80
77
|
handleRemoveLsNetworks,
|
|
81
78
|
]);
|
|
82
79
|
useEffect(() => {
|
|
83
|
-
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
if (!lsNetworksExists && !loading && (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.networks)) {
|
|
84
82
|
setLoading(true);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
environmentId,
|
|
132
|
-
expiry,
|
|
133
|
-
version: VERSION,
|
|
134
|
-
});
|
|
135
|
-
setlsNetworksExists(true);
|
|
136
|
-
})
|
|
137
|
-
.catch((e) => {
|
|
138
|
-
setRetries((currentRetries) => currentRetries + 1);
|
|
139
|
-
})
|
|
140
|
-
.finally(() => {
|
|
141
|
-
setLoading(false);
|
|
83
|
+
const { networks } = projectSettings;
|
|
84
|
+
const expiry = new Date().getTime() + 60000 * 5;
|
|
85
|
+
const evm = networks.find((configurations) => configurations.chainName === 'evm');
|
|
86
|
+
const solana = networks.find((configurations) => configurations.chainName === 'solana');
|
|
87
|
+
const cosmos = networks.find((configurations) => configurations.chainName === 'cosmos');
|
|
88
|
+
const starknet = networks.find((configurations) => configurations.chainName === 'starknet');
|
|
89
|
+
let mergedEvmNetworks;
|
|
90
|
+
const createNetwork = (network, parser = (input) => input) => ({
|
|
91
|
+
blockExplorerUrls: network.blockExplorerUrls,
|
|
92
|
+
chainId: parser(network.chainId),
|
|
93
|
+
iconUrls: network.iconUrls,
|
|
94
|
+
lcdUrl: network.lcdUrl,
|
|
95
|
+
name: network.name,
|
|
96
|
+
nativeCurrency: network.nativeCurrency,
|
|
97
|
+
networkId: parser(network.networkId),
|
|
98
|
+
privateCustomerRpcUrls: network.privateCustomerRpcUrls,
|
|
99
|
+
rpcUrls: network.rpcUrls,
|
|
100
|
+
vanityName: network.vanityName,
|
|
101
|
+
});
|
|
102
|
+
const cosmosNetworks = (_a = cosmos === null || cosmos === void 0 ? void 0 : cosmos.networks) === null || _a === void 0 ? void 0 : _a.map((net) => createNetwork(net, parseInt));
|
|
103
|
+
const serverNetworks = (_b = evm === null || evm === void 0 ? void 0 : evm.networks) === null || _b === void 0 ? void 0 : _b.map((net) => createNetwork(net, parseInt));
|
|
104
|
+
const starknetNetworks = (_c = starknet === null || starknet === void 0 ? void 0 : starknet.networks) === null || _c === void 0 ? void 0 : _c.map((net) => createNetwork(net));
|
|
105
|
+
const solanaNetworks = (_d = solana === null || solana === void 0 ? void 0 : solana.networks) === null || _d === void 0 ? void 0 : _d.map((net) => createNetwork(net));
|
|
106
|
+
if (!serverNetworks && (customerEvmNetworks === null || customerEvmNetworks === void 0 ? void 0 : customerEvmNetworks.length)) {
|
|
107
|
+
mergedEvmNetworks = customerEvmNetworks;
|
|
108
|
+
}
|
|
109
|
+
if (!customerEvmNetworks && (serverNetworks === null || serverNetworks === void 0 ? void 0 : serverNetworks.length)) {
|
|
110
|
+
mergedEvmNetworks = serverNetworks;
|
|
111
|
+
}
|
|
112
|
+
if (serverNetworks !== undefined &&
|
|
113
|
+
serverNetworks.length &&
|
|
114
|
+
customerEvmNetworks !== undefined &&
|
|
115
|
+
customerEvmNetworks.length) {
|
|
116
|
+
mergedEvmNetworks = mergeCustomerEvmNetworksWithServerNetworks(customerEvmNetworks, serverNetworks);
|
|
117
|
+
}
|
|
118
|
+
setLsNetworks({
|
|
119
|
+
configurations: {
|
|
120
|
+
cosmos: cosmosNetworks,
|
|
121
|
+
evm: mergedEvmNetworks,
|
|
122
|
+
solana: solanaNetworks,
|
|
123
|
+
starknet: starknetNetworks,
|
|
124
|
+
},
|
|
125
|
+
environmentId,
|
|
126
|
+
expiry,
|
|
127
|
+
version: VERSION,
|
|
142
128
|
});
|
|
129
|
+
setlsNetworksExists(true);
|
|
130
|
+
setLoading(false);
|
|
143
131
|
}
|
|
144
132
|
}, [
|
|
145
|
-
authToken,
|
|
146
133
|
environmentId,
|
|
147
134
|
loading,
|
|
148
135
|
customerEvmNetworks,
|
|
149
136
|
lsNetworksExists,
|
|
150
|
-
maxRetries,
|
|
151
|
-
retries,
|
|
152
137
|
setLsNetworks,
|
|
138
|
+
projectSettings,
|
|
153
139
|
]);
|
|
154
140
|
return {
|
|
155
141
|
configurations: lsNetworks === null || lsNetworks === void 0 ? void 0 : lsNetworks.configurations,
|
|
@@ -157,4 +143,4 @@ const useFetchNetworkConfigurations = ({ authToken, environmentId, evmNetworks:
|
|
|
157
143
|
};
|
|
158
144
|
};
|
|
159
145
|
|
|
160
|
-
export {
|
|
146
|
+
export { useProcessNetworkConfigurations };
|