@dynamic-labs/sdk-react-core 0.18.0-RC.7 → 0.18.0-RC.9
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 +44 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +10 -11
- package/src/index.js +3 -4
- package/src/lib/Main.cjs +1 -2
- package/src/lib/Main.js +1 -2
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.cjs +1 -2
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.js +1 -2
- package/src/lib/components/AnimatePresence/AnimatePresence.cjs +1 -2
- package/src/lib/components/AnimatePresence/AnimatePresence.js +1 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +1 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +1 -2
- package/src/lib/components/Divider/Divider.cjs +1 -2
- package/src/lib/components/Divider/Divider.js +1 -2
- package/src/lib/components/Modal/Modal.cjs +36 -1
- package/src/lib/components/Modal/Modal.d.ts +3 -0
- package/src/lib/components/Modal/Modal.js +36 -1
- package/src/lib/components/ModalCard/ModalCard.cjs +4 -1
- package/src/lib/components/ModalCard/ModalCard.d.ts +6 -1
- package/src/lib/components/ModalCard/ModalCard.js +4 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +25 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.js +25 -1
- package/src/lib/components/NetworkPicker/components/ActionList/ActionList.cjs +1 -2
- package/src/lib/components/NetworkPicker/components/ActionList/ActionList.js +1 -2
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.cjs +1 -2
- package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.js +1 -2
- package/src/lib/components/NetworkPicker/components/Network/Network.cjs +4 -3
- package/src/lib/components/NetworkPicker/components/Network/Network.d.ts +2 -1
- package/src/lib/components/NetworkPicker/components/Network/Network.js +4 -3
- package/src/lib/components/NetworkPicker/components/NetworkAction/NetworkAction.cjs +6 -1
- package/src/lib/components/NetworkPicker/components/NetworkAction/NetworkAction.d.ts +2 -1
- package/src/lib/components/NetworkPicker/components/NetworkAction/NetworkAction.js +6 -1
- package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.cjs +0 -5
- package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.d.ts +1 -1
- package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.js +0 -5
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +1 -2
- package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +1 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +1 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +1 -2
- package/src/lib/components/OverlayCard/OverlayCard.cjs +1 -2
- package/src/lib/components/OverlayCard/OverlayCard.js +1 -2
- package/src/lib/components/Portal/Portal.cjs +2 -3
- package/src/lib/components/Portal/Portal.js +2 -3
- package/src/lib/components/Step/Step.cjs +14 -3
- package/src/lib/components/Step/Step.d.ts +2 -1
- package/src/lib/components/Step/Step.js +14 -3
- package/src/lib/components/Tooltip/Tooltip.cjs +1 -2
- package/src/lib/components/Tooltip/Tooltip.js +1 -2
- package/src/lib/components/TosAndPp/TosAndPp.cjs +1 -1
- package/src/lib/components/TosAndPp/TosAndPp.js +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -2
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -2
- package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.cjs +1 -2
- package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.js +1 -2
- package/src/lib/components/Transition/transition.type.d.ts +3 -3
- package/src/lib/components/UserAddress/UserAddress.cjs +29 -2
- package/src/lib/components/UserAddress/UserAddress.d.ts +4 -2
- package/src/lib/components/UserAddress/UserAddress.js +29 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +1 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +1 -2
- package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.cjs +1 -2
- package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.js +1 -2
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +2 -3
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +2 -3
- package/src/lib/context/DynamicContext/DynamicContext.cjs +71 -29
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +12 -5
- package/src/lib/context/DynamicContext/DynamicContext.js +74 -32
- package/src/lib/context/DynamicContext/helpers.cjs +13 -0
- package/src/lib/context/DynamicContext/helpers.d.ts +6 -0
- package/src/lib/context/DynamicContext/helpers.js +13 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.cjs +1 -2
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.js +1 -2
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -2
- package/src/lib/context/ErrorContext/ErrorContext.cjs +6 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +6 -0
- package/src/lib/context/QrCodeContext/QrCodeContext.cjs +1 -2
- package/src/lib/context/QrCodeContext/QrCodeContext.js +1 -2
- package/src/lib/context/SendBalanceContext/SendBalanceContext.cjs +1 -2
- package/src/lib/context/SendBalanceContext/SendBalanceContext.js +1 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -2
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +22 -21
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +23 -22
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/Item/Item.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/WalletListHelpContent.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +1 -2
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +1 -2
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.cjs +58 -0
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/WalletProgressStepper.js +54 -0
- package/src/lib/layout/DynamicAuthLayout/WalletProgressStepper/index.d.ts +1 -0
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.cjs +1 -2
- package/src/lib/layouts/BridgeWelcomeLayout/BridgeWelcomeLayout.js +1 -2
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.cjs +1 -2
- package/src/lib/layouts/ConnectedWalletsListLayout/ConnectedWalletsListLayout.js +1 -2
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.cjs +1 -2
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.js +1 -2
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +1 -2
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +1 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +1 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +1 -2
- package/src/lib/modals/index.d.ts +0 -1
- package/src/lib/shared/utils/classes/storage/localStorage.cjs +7 -1
- package/src/lib/shared/utils/classes/storage/localStorage.d.ts +1 -0
- package/src/lib/shared/utils/classes/storage/localStorage.js +7 -1
- package/src/lib/shared/utils/hooks/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useMediaQuery/index.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useMediaQuery/useMediaQuery.cjs +31 -0
- package/src/lib/shared/utils/hooks/useMediaQuery/useMediaQuery.d.ts +1 -0
- package/src/lib/shared/utils/hooks/useMediaQuery/useMediaQuery.js +27 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/getMissingChains/getMissingChains.cjs +16 -0
- package/src/lib/utils/functions/getMissingChains/getMissingChains.d.ts +3 -0
- package/src/lib/utils/functions/getMissingChains/getMissingChains.js +12 -0
- package/src/lib/utils/functions/getMissingChains/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isEmailProviderEnabled/isEmailProviderEnabled.cjs +3 -2
- package/src/lib/utils/functions/isEmailProviderEnabled/isEmailProviderEnabled.js +3 -2
- package/src/lib/utils/functions/isProviderEnabled/index.d.ts +1 -0
- package/src/lib/utils/functions/isProviderEnabled/isProviderEnabled.cjs +7 -0
- package/src/lib/utils/functions/isProviderEnabled/isProviderEnabled.d.ts +2 -0
- package/src/lib/utils/functions/isProviderEnabled/isProviderEnabled.js +3 -0
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +18 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +18 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +3 -1
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +13 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +13 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +12 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +12 -2
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.cjs +16 -3
- package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js +16 -3
- package/src/lib/utils/hooks/useColorSchemePreference/useColorSchemePreference.cjs +16 -18
- package/src/lib/utils/hooks/useColorSchemePreference/useColorSchemePreference.js +16 -18
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +53 -35
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +16 -6
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +55 -37
- package/src/lib/utils/hooks/useCountdown/useCountdown.cjs +39 -0
- package/src/lib/utils/hooks/useCountdown/useCountdown.d.ts +11 -0
- package/src/lib/utils/hooks/useCountdown/useCountdown.js +35 -0
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs +1 -1
- package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js +1 -1
- package/src/lib/utils/hooks/useFetchWalletsForChainsMap/useFetchWalletsForChainsMap.cjs +6 -10
- package/src/lib/utils/hooks/useFetchWalletsForChainsMap/useFetchWalletsForChainsMap.js +7 -11
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +14 -4
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +14 -4
- package/src/lib/utils/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +10 -0
- package/src/lib/utils/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +6 -0
- package/src/lib/utils/hooks/useKeyboardEventListener/useKeyboardEventListener.cjs +6 -8
- package/src/lib/utils/hooks/useKeyboardEventListener/useKeyboardEventListener.js +7 -9
- package/src/lib/utils/hooks/usePromise/usePromise.cjs +6 -2
- package/src/lib/utils/hooks/usePromise/usePromise.d.ts +4 -1
- package/src/lib/utils/hooks/usePromise/usePromise.js +6 -2
- package/src/lib/utils/hooks/useRpcProviders/useRpcProviders.cjs +6 -28
- package/src/lib/utils/hooks/useRpcProviders/useRpcProviders.d.ts +0 -1
- package/src/lib/utils/hooks/useRpcProviders/useRpcProviders.js +7 -29
- package/src/lib/utils/hooks/useTimeout/useTimeout.cjs +27 -0
- package/src/lib/utils/hooks/useTimeout/useTimeout.js +23 -0
- package/src/lib/utils/hooks/useTransition/useTransition.cjs +16 -24
- package/src/lib/utils/hooks/useTransition/useTransition.d.ts +3 -3
- package/src/lib/utils/hooks/useTransition/useTransition.js +17 -25
- package/src/lib/utils/hooks/useTransitionEvents/useTransitionEvents.cjs +11 -9
- package/src/lib/utils/hooks/useTransitionEvents/useTransitionEvents.js +11 -9
- package/src/lib/utils/hooks/useValidateSession/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +79 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +12 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +75 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -18
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -18
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +1 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +1 -0
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +1 -2
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +1 -2
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +10 -1
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -1
- package/src/lib/utils/hooks/useWallets/useWallets.js +11 -2
- package/src/lib/utils/hooks/useWallets/utils/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/index.d.ts +1 -0
- package/src/lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs +35 -0
- package/src/lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.d.ts +6 -0
- package/src/lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js +29 -0
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.cjs +39 -0
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.d.ts +2 -0
- package/src/lib/views/BridgeSummaryView/BridgeSummaryView.js +35 -0
- package/src/lib/views/BridgeSummaryView/index.d.ts +1 -0
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.cjs +48 -0
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.d.ts +2 -0
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +44 -0
- package/src/lib/views/BridgeWelcomeView/index.d.ts +1 -0
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +1 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +1 -2
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +1 -2
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +1 -2
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +1 -2
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +1 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +1 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +1 -2
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs +1 -2
- package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js +1 -2
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +1 -2
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +1 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +3 -3
- package/src/lib/views/EmailUpdate/EmailUpdate.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +13 -23
- package/src/lib/views/EmailVerification/EmailVerification.js +14 -24
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -2
- package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.cjs +2 -3
- package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.js +2 -3
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +3 -3
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +3 -3
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -2
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -2
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +11 -8
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +11 -8
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +22 -16
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +22 -16
- package/src/lib/views/NoAccess/NoAccess.cjs +2 -3
- package/src/lib/views/NoAccess/NoAccess.js +2 -3
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +1 -2
- package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +1 -2
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +1 -2
- package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +1 -2
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +1 -2
- package/src/lib/views/PendingConnectView/PendingConnectView.js +1 -2
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +1 -2
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +1 -2
- package/src/lib/views/QrCodeView/QRCode.cjs +35 -4
- package/src/lib/views/QrCodeView/QRCode.js +36 -5
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +1 -2
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +1 -2
- package/src/lib/views/QrCodeView/QrCodeView.cjs +4 -8
- package/src/lib/views/QrCodeView/QrCodeView.js +4 -8
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +1 -2
- package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -2
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +15 -0
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +15 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +1 -2
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +1 -2
- package/src/lib/views/WalletList/SearchInstead/SearchInstead.cjs +1 -2
- package/src/lib/views/WalletList/SearchInstead/SearchInstead.js +1 -2
- package/src/lib/views/WalletList/WalletList.cjs +6 -5
- package/src/lib/views/WalletList/WalletList.js +7 -6
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +4 -4
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +4 -4
- package/src/lib/views/WalletList/data.cjs +2 -1
- package/src/lib/views/WalletList/data.js +2 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +1 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.js +1 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +1 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +1 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -2
- package/src/lib/views/viewToComponentMap.cjs +4 -0
- package/src/lib/views/viewToComponentMap.js +4 -0
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +4 -7
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +4 -7
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.cjs +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeUserProfile/DynamicBridgeUserProfile.js +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.d.ts +1 -1
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +1 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs +58 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.d.ts +7 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js +54 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/index.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNav/DynamicBridgeWidgetNav.cjs +3 -39
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNav/DynamicBridgeWidgetNav.d.ts +0 -4
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNav/DynamicBridgeWidgetNav.js +3 -39
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavPrimary/DynamicBridgeWidgetNavPrimary.cjs +57 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavPrimary/DynamicBridgeWidgetNavPrimary.d.ts +6 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavPrimary/DynamicBridgeWidgetNavPrimary.js +53 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavPrimary/index.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavSecondary/DynamicBridgeWidgetNavSecondary.cjs +58 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavSecondary/DynamicBridgeWidgetNavSecondary.d.ts +6 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavSecondary/DynamicBridgeWidgetNavSecondary.js +54 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetNavSecondary/index.d.ts +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/index.d.ts +0 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +13 -12
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +13 -12
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs +11 -11
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.d.ts +6 -6
- package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js +12 -12
- package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/DynamicWidget.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +1 -2
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +2 -3
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.js +1 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +2 -3
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +1 -2
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +1 -2
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +1 -2
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +1 -2
- package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +1 -2
- package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.cjs +1 -2
- package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.js +1 -2
- package/src/lib/layouts/SelectWalletListLayout/SelectWalletListLayout.cjs +0 -53
- package/src/lib/layouts/SelectWalletListLayout/SelectWalletListLayout.js +0 -49
- package/src/lib/modals/MultiWalletStepSelectorModal/MultiWalletStepSelectorModal.cjs +0 -77
- package/src/lib/modals/MultiWalletStepSelectorModal/MultiWalletStepSelectorModal.d.ts +0 -2
- package/src/lib/modals/MultiWalletStepSelectorModal/MultiWalletStepSelectorModal.js +0 -73
- package/src/lib/modals/MultiWalletStepSelectorModal/index.d.ts +0 -1
- package/src/lib/modals/MultiWalletStepSelectorModal/views/ResumeView/ResumeView.cjs +0 -62
- package/src/lib/modals/MultiWalletStepSelectorModal/views/ResumeView/ResumeView.d.ts +0 -6
- package/src/lib/modals/MultiWalletStepSelectorModal/views/ResumeView/ResumeView.js +0 -58
- package/src/lib/modals/MultiWalletStepSelectorModal/views/ResumeView/index.d.ts +0 -1
- package/src/lib/modals/MultiWalletStepSelectorModal/views/SelectWalletView/SelectWalletView.cjs +0 -89
- package/src/lib/modals/MultiWalletStepSelectorModal/views/SelectWalletView/SelectWalletView.d.ts +0 -8
- package/src/lib/modals/MultiWalletStepSelectorModal/views/SelectWalletView/SelectWalletView.js +0 -85
- package/src/lib/modals/MultiWalletStepSelectorModal/views/SelectWalletView/index.d.ts +0 -1
- package/src/lib/modals/MultiWalletStepSelectorModal/views/WelcomeView/WelcomeView.cjs +0 -72
- package/src/lib/modals/MultiWalletStepSelectorModal/views/WelcomeView/WelcomeView.d.ts +0 -7
- package/src/lib/modals/MultiWalletStepSelectorModal/views/WelcomeView/WelcomeView.js +0 -68
- package/src/lib/modals/MultiWalletStepSelectorModal/views/WelcomeView/index.d.ts +0 -1
- package/src/lib/modals/MultiWalletStepSelectorModal/views/index.d.ts +0 -3
- package/src/lib/utils/functions/groupBy/groupBy.cjs +0 -30
- package/src/lib/utils/functions/groupBy/groupBy.js +0 -26
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.cjs +0 -23
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.d.ts +0 -8
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.js +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useCallback,
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useCallback, useMemo, useEffect } from 'react';
|
|
3
|
+
import { getWalletConnectorByName, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -19,11 +19,37 @@ import { createVisit } from '../../../data/api.js';
|
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
20
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
21
21
|
|
|
22
|
-
const useConnectWallet = (
|
|
22
|
+
const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingOnConnectOnly, environmentId, primaryWalletId, setPrimaryWalletId, wallets, }) => {
|
|
23
23
|
const [connectedWalletsInfo, setConnectedWalletsInfo, removeConnectedWalletsInfo,] = useLocalStorage(CONNECTED_WALLETS_INFO, []);
|
|
24
24
|
const [connectedWallet, setConnectedWallet] = useState(null);
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const getNextIdAvailable = useCallback((currentWallets) => {
|
|
26
|
+
const existingIds = currentWallets.map(({ id }) => id);
|
|
27
|
+
const sortedIds = existingIds
|
|
28
|
+
.map((id) => Number(id.replace('connect-only-wallet-', '')))
|
|
29
|
+
.sort((a, b) => a - b);
|
|
30
|
+
for (let i = 0; i < sortedIds.length; i++) {
|
|
31
|
+
if (sortedIds[i] !== i) {
|
|
32
|
+
return i;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return sortedIds.length;
|
|
36
|
+
}, []);
|
|
37
|
+
const connectedWallets = useMemo(() => connectedWalletsInfo
|
|
38
|
+
.map((connectedWallet) => {
|
|
39
|
+
const walletConnector = getWalletConnectorByName(wallets.map((wallet) => wallet.walletConnector), connectedWallet.name);
|
|
40
|
+
if (!walletConnector) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
address: connectedWallet.walletPublicKey,
|
|
45
|
+
chain: connectedWallet.chain,
|
|
46
|
+
connected: true,
|
|
47
|
+
connector: walletConnector,
|
|
48
|
+
id: connectedWallet.id,
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
.filter((wc) => wc !== null), [connectedWalletsInfo, wallets]);
|
|
52
|
+
const setConnectedStates = useCallback((walletConnector, address, chain) => {
|
|
27
53
|
setConnectedWallet({
|
|
28
54
|
address,
|
|
29
55
|
chain,
|
|
@@ -31,27 +57,6 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
31
57
|
connector: walletConnector,
|
|
32
58
|
id: 'connect-only-wallet',
|
|
33
59
|
});
|
|
34
|
-
setConnectedWallets((currentWallets) => {
|
|
35
|
-
const exists = currentWallets.some((currentWallet) => isSameAddress(currentWallet.address, address, chain));
|
|
36
|
-
if (currentWallets.length === 0 &&
|
|
37
|
-
authMode === 'connect-only' &&
|
|
38
|
-
!primaryWalletId) {
|
|
39
|
-
setPrimaryWalletId(`connect-only-wallet-${0}`);
|
|
40
|
-
}
|
|
41
|
-
if (exists) {
|
|
42
|
-
return currentWallets;
|
|
43
|
-
}
|
|
44
|
-
return [
|
|
45
|
-
...currentWallets,
|
|
46
|
-
{
|
|
47
|
-
address,
|
|
48
|
-
chain,
|
|
49
|
-
connected: true,
|
|
50
|
-
connector: walletConnector,
|
|
51
|
-
id: `connect-only-wallet-${id}`,
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
});
|
|
55
60
|
setConnectedWalletsInfo((currentWallets) => {
|
|
56
61
|
const exists = currentWallets.some((currentWallet) => currentWallet.walletPublicKey === address);
|
|
57
62
|
if (exists) {
|
|
@@ -61,14 +66,15 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
61
66
|
...currentWallets,
|
|
62
67
|
{
|
|
63
68
|
chain,
|
|
69
|
+
id: `connect-only-wallet-${getNextIdAvailable(currentWallets)}`,
|
|
64
70
|
name: walletConnector.name,
|
|
65
71
|
provider: getWalletProvider(walletConnector),
|
|
66
72
|
walletPublicKey: address,
|
|
67
73
|
},
|
|
68
74
|
];
|
|
69
75
|
});
|
|
70
|
-
}, [
|
|
71
|
-
const connectWalletByAddressAndChain = useCallback((name, address, chain
|
|
76
|
+
}, [getNextIdAvailable, setConnectedWalletsInfo]);
|
|
77
|
+
const connectWalletByAddressAndChain = useCallback((name, address, chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
78
|
const walletConnector = getWalletConnectorByName(wallets.map((wallet) => wallet.walletConnector), name);
|
|
73
79
|
if (walletConnector) {
|
|
74
80
|
if (shouldManuallyReconnectOnRefresh(walletConnector)) {
|
|
@@ -78,7 +84,7 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
78
84
|
const result = connectedAccounts.filter((account) => isSameAddress(account, address, chain));
|
|
79
85
|
if (result.length > 0) {
|
|
80
86
|
walletConnector.connect();
|
|
81
|
-
setConnectedStates(walletConnector, address, chain
|
|
87
|
+
setConnectedStates(walletConnector, address, chain);
|
|
82
88
|
}
|
|
83
89
|
else {
|
|
84
90
|
setConnectedWallet(null);
|
|
@@ -89,12 +95,11 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
89
95
|
}
|
|
90
96
|
}), [setConnectedStates, wallets]);
|
|
91
97
|
useEffect(() => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
connectedWalletsInfo.forEach(({ name, walletPublicKey, chain }, id) => {
|
|
98
|
+
const shouldUpdateConnectedWalletsState = authMode === 'connect-only' && connectedWalletsInfo.length;
|
|
99
|
+
if (shouldUpdateConnectedWalletsState) {
|
|
100
|
+
connectedWalletsInfo.forEach(({ name, walletPublicKey, chain }) => {
|
|
96
101
|
if (chain) {
|
|
97
|
-
connectWalletByAddressAndChain(name, walletPublicKey, chain
|
|
102
|
+
connectWalletByAddressAndChain(name, walletPublicKey, chain);
|
|
98
103
|
}
|
|
99
104
|
});
|
|
100
105
|
}
|
|
@@ -114,7 +119,12 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
114
119
|
throw error;
|
|
115
120
|
}
|
|
116
121
|
const chain = walletConnector.connectedChain || '';
|
|
117
|
-
|
|
122
|
+
// when we connect first wallet, it should be set as a primary wallet
|
|
123
|
+
const shouldSetPrimaryWalletId = authMode === 'connect-only' && !primaryWalletId;
|
|
124
|
+
if (shouldSetPrimaryWalletId) {
|
|
125
|
+
setPrimaryWalletId(`connect-only-wallet-${getNextIdAvailable(connectedWalletsInfo)}`);
|
|
126
|
+
}
|
|
127
|
+
setConnectedStates(walletConnector, publicWalletAddress, chain);
|
|
118
128
|
if (shouldSkipCreatingVisit) {
|
|
119
129
|
return publicWalletAddress;
|
|
120
130
|
}
|
|
@@ -131,15 +141,23 @@ const useConnectWallet = (wallets, authMode, environmentId, enableVisitTrackingO
|
|
|
131
141
|
});
|
|
132
142
|
return publicWalletAddress;
|
|
133
143
|
});
|
|
144
|
+
const unlinkConnectedWallet = (walletId) => {
|
|
145
|
+
const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
|
|
146
|
+
if (walletId === primaryWalletId) {
|
|
147
|
+
clearPrimaryWalletId();
|
|
148
|
+
}
|
|
149
|
+
setConnectedWalletsInfo(filteredWallets);
|
|
150
|
+
};
|
|
151
|
+
const getConnectedWalletById = useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
|
|
134
152
|
return {
|
|
135
153
|
connectWallet,
|
|
136
154
|
connectWalletByAddressAndChain,
|
|
137
155
|
connectedWallet,
|
|
138
156
|
connectedWallets,
|
|
139
157
|
connectedWalletsInfo,
|
|
158
|
+
getConnectedWalletById,
|
|
140
159
|
removeConnectedWalletsInfo,
|
|
141
|
-
|
|
142
|
-
setConnectedWallets,
|
|
160
|
+
unlinkConnectedWallet,
|
|
143
161
|
};
|
|
144
162
|
};
|
|
145
163
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
const useCountdown = ({ callback, seconds }) => {
|
|
8
|
+
const [remainingSeconds, setRemainingSeconds] = React.useState(seconds);
|
|
9
|
+
const timeoutRef = React.useRef();
|
|
10
|
+
const startCountdown = () => {
|
|
11
|
+
if (timeoutRef.current) {
|
|
12
|
+
return setRemainingSeconds(seconds);
|
|
13
|
+
}
|
|
14
|
+
runCountdown();
|
|
15
|
+
};
|
|
16
|
+
const stopCountdown = () => {
|
|
17
|
+
clearTimeout(timeoutRef.current);
|
|
18
|
+
timeoutRef.current = undefined;
|
|
19
|
+
};
|
|
20
|
+
const runCountdown = () => {
|
|
21
|
+
timeoutRef.current = setTimeout(() => {
|
|
22
|
+
setRemainingSeconds((prevSeconds) => prevSeconds - 1);
|
|
23
|
+
}, 1000);
|
|
24
|
+
};
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
if (!timeoutRef.current)
|
|
27
|
+
return;
|
|
28
|
+
if (remainingSeconds <= 0) {
|
|
29
|
+
if (callback)
|
|
30
|
+
callback();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
runCountdown();
|
|
34
|
+
return () => clearTimeout(timeoutRef.current);
|
|
35
|
+
}, [remainingSeconds, callback]);
|
|
36
|
+
return { remainingSeconds, startCountdown, stopCountdown };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.useCountdown = useCountdown;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Prop = {
|
|
2
|
+
callback?: () => void;
|
|
3
|
+
seconds: number;
|
|
4
|
+
};
|
|
5
|
+
export interface UseCountdown {
|
|
6
|
+
remainingSeconds: number;
|
|
7
|
+
startCountdown: () => void;
|
|
8
|
+
stopCountdown: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useCountdown: ({ callback, seconds }: Prop) => UseCountdown;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useCountdown = ({ callback, seconds }) => {
|
|
4
|
+
const [remainingSeconds, setRemainingSeconds] = useState(seconds);
|
|
5
|
+
const timeoutRef = useRef();
|
|
6
|
+
const startCountdown = () => {
|
|
7
|
+
if (timeoutRef.current) {
|
|
8
|
+
return setRemainingSeconds(seconds);
|
|
9
|
+
}
|
|
10
|
+
runCountdown();
|
|
11
|
+
};
|
|
12
|
+
const stopCountdown = () => {
|
|
13
|
+
clearTimeout(timeoutRef.current);
|
|
14
|
+
timeoutRef.current = undefined;
|
|
15
|
+
};
|
|
16
|
+
const runCountdown = () => {
|
|
17
|
+
timeoutRef.current = setTimeout(() => {
|
|
18
|
+
setRemainingSeconds((prevSeconds) => prevSeconds - 1);
|
|
19
|
+
}, 1000);
|
|
20
|
+
};
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!timeoutRef.current)
|
|
23
|
+
return;
|
|
24
|
+
if (remainingSeconds <= 0) {
|
|
25
|
+
if (callback)
|
|
26
|
+
callback();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
runCountdown();
|
|
30
|
+
return () => clearTimeout(timeoutRef.current);
|
|
31
|
+
}, [remainingSeconds, callback]);
|
|
32
|
+
return { remainingSeconds, startCountdown, stopCountdown };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useCountdown };
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs
CHANGED
|
@@ -31,9 +31,9 @@ const useCreateUserProfileByJWTCallback = () => {
|
|
|
31
31
|
goToInitialView();
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
+
index.storeAuthToken(jwt);
|
|
34
35
|
const userProfile = createUserProfile.createUserProfile(decodedJWT);
|
|
35
36
|
setUser(userProfile);
|
|
36
|
-
index.storeAuthToken(jwt);
|
|
37
37
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
38
|
}, []);
|
|
39
39
|
return { createUserProfileByJWT };
|
package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js
CHANGED
|
@@ -27,9 +27,9 @@ const useCreateUserProfileByJWTCallback = () => {
|
|
|
27
27
|
goToInitialView();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
+
storeAuthToken(jwt);
|
|
30
31
|
const userProfile = createUserProfile(decodedJWT);
|
|
31
32
|
setUser(userProfile);
|
|
32
|
-
storeAuthToken(jwt);
|
|
33
33
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
34
|
}, []);
|
|
35
35
|
return { createUserProfileByJWT };
|
|
@@ -17,17 +17,13 @@ require('ethers');
|
|
|
17
17
|
var index = require('../../../shared/consts/index.cjs');
|
|
18
18
|
|
|
19
19
|
const useFetchWalletsForChainsMap = (propsWalletsChainsMap) => {
|
|
20
|
-
const walletsForChainsMap =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (propsWalletsChainsMap) {
|
|
24
|
-
Object.assign(walletsForChainsMap, {
|
|
25
|
-
primary_chain: propsWalletsChainsMap.primary_chain,
|
|
26
|
-
wallets: Object.assign(Object.assign({}, index.defaultWalletsForChains.wallets), (Boolean(propsWalletsChainsMap.wallets) &&
|
|
27
|
-
propsWalletsChainsMap.wallets)),
|
|
28
|
-
});
|
|
20
|
+
const walletsForChainsMap = React.useMemo(() => {
|
|
21
|
+
if (!propsWalletsChainsMap) {
|
|
22
|
+
return index.defaultWalletsForChains;
|
|
29
23
|
}
|
|
30
|
-
|
|
24
|
+
return Object.assign(Object.assign({}, index.defaultWalletsForChains), { primary_chain: propsWalletsChainsMap.primary_chain, wallets: Object.assign(Object.assign({}, index.defaultWalletsForChains.wallets), (Boolean(propsWalletsChainsMap.wallets) &&
|
|
25
|
+
propsWalletsChainsMap.wallets)) });
|
|
26
|
+
}, [propsWalletsChainsMap]);
|
|
31
27
|
return { walletsForChainsMap };
|
|
32
28
|
};
|
|
33
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import '@dynamic-labs/sdk-api';
|
|
3
3
|
import '../../../shared/logger.js';
|
|
4
4
|
import '@dynamic-labs/iconic';
|
|
@@ -13,17 +13,13 @@ import 'ethers';
|
|
|
13
13
|
import { defaultWalletsForChains } from '../../../shared/consts/index.js';
|
|
14
14
|
|
|
15
15
|
const useFetchWalletsForChainsMap = (propsWalletsChainsMap) => {
|
|
16
|
-
const walletsForChainsMap =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (propsWalletsChainsMap) {
|
|
20
|
-
Object.assign(walletsForChainsMap, {
|
|
21
|
-
primary_chain: propsWalletsChainsMap.primary_chain,
|
|
22
|
-
wallets: Object.assign(Object.assign({}, defaultWalletsForChains.wallets), (Boolean(propsWalletsChainsMap.wallets) &&
|
|
23
|
-
propsWalletsChainsMap.wallets)),
|
|
24
|
-
});
|
|
16
|
+
const walletsForChainsMap = useMemo(() => {
|
|
17
|
+
if (!propsWalletsChainsMap) {
|
|
18
|
+
return defaultWalletsForChains;
|
|
25
19
|
}
|
|
26
|
-
|
|
20
|
+
return Object.assign(Object.assign({}, defaultWalletsForChains), { primary_chain: propsWalletsChainsMap.primary_chain, wallets: Object.assign(Object.assign({}, defaultWalletsForChains.wallets), (Boolean(propsWalletsChainsMap.wallets) &&
|
|
21
|
+
propsWalletsChainsMap.wallets)) });
|
|
22
|
+
}, [propsWalletsChainsMap]);
|
|
27
23
|
return { walletsForChainsMap };
|
|
28
24
|
};
|
|
29
25
|
|
|
@@ -6,10 +6,11 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useInte
|
|
|
6
6
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
7
7
|
|
|
8
8
|
const useHandleWalletsToConnect = () => {
|
|
9
|
-
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
10
|
-
const { setView } = ViewContext.useViewContext();
|
|
9
|
+
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setConnectedUser, isUserConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
10
|
+
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
11
11
|
const handleWalletsToConnect = () => {
|
|
12
12
|
if (!walletsToConnectByChain) {
|
|
13
|
+
setConnectedUser(true);
|
|
13
14
|
setShowAuthFlow(false);
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
@@ -24,8 +25,17 @@ const useHandleWalletsToConnect = () => {
|
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
setWalletsToConnectByChain(restOfTheWallets);
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const allWalletsConnected = restOfTheWallets.length === 0;
|
|
29
|
+
if (allWalletsConnected) {
|
|
30
|
+
if (!isUserConnected) {
|
|
31
|
+
setConnectedUser(true);
|
|
32
|
+
setView('bridge-summary');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setShowAuthFlow(false);
|
|
36
|
+
goToInitialView();
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
29
39
|
}
|
|
30
40
|
setView('wallet-list');
|
|
31
41
|
};
|
|
@@ -2,10 +2,11 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useIn
|
|
|
2
2
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
3
3
|
|
|
4
4
|
const useHandleWalletsToConnect = () => {
|
|
5
|
-
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, } = useInternalDynamicContext();
|
|
6
|
-
const { setView } = useViewContext();
|
|
5
|
+
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setConnectedUser, isUserConnected, } = useInternalDynamicContext();
|
|
6
|
+
const { setView, goToInitialView } = useViewContext();
|
|
7
7
|
const handleWalletsToConnect = () => {
|
|
8
8
|
if (!walletsToConnectByChain) {
|
|
9
|
+
setConnectedUser(true);
|
|
9
10
|
setShowAuthFlow(false);
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
@@ -20,8 +21,17 @@ const useHandleWalletsToConnect = () => {
|
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
setWalletsToConnectByChain(restOfTheWallets);
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const allWalletsConnected = restOfTheWallets.length === 0;
|
|
25
|
+
if (allWalletsConnected) {
|
|
26
|
+
if (!isUserConnected) {
|
|
27
|
+
setConnectedUser(true);
|
|
28
|
+
setView('bridge-summary');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
setShowAuthFlow(false);
|
|
32
|
+
goToInitialView();
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
25
35
|
}
|
|
26
36
|
setView('wallet-list');
|
|
27
37
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
// https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect
|
|
8
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
9
|
+
|
|
10
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
|
|
7
7
|
const useKeyboardEventListener = ({ disabled, inputKey, onKeyPressed, }) => {
|
|
8
|
-
const handleKeydown = React.useCallback((evt) => {
|
|
9
|
-
if (disabled)
|
|
10
|
-
return;
|
|
11
|
-
if (evt.key === inputKey) {
|
|
12
|
-
onKeyPressed();
|
|
13
|
-
}
|
|
14
|
-
}, [disabled, inputKey, onKeyPressed]);
|
|
15
8
|
React.useEffect(() => {
|
|
9
|
+
const handleKeydown = (evt) => {
|
|
10
|
+
if (disabled || evt.key !== inputKey)
|
|
11
|
+
return;
|
|
12
|
+
onKeyPressed();
|
|
13
|
+
};
|
|
16
14
|
document.addEventListener('keydown', handleKeydown);
|
|
17
15
|
return () => {
|
|
18
16
|
document.removeEventListener('keydown', handleKeydown);
|
|
19
17
|
};
|
|
20
|
-
}, [
|
|
18
|
+
}, [disabled, inputKey, onKeyPressed]);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
exports.useKeyboardEventListener = useKeyboardEventListener;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
const useKeyboardEventListener = ({ disabled, inputKey, onKeyPressed, }) => {
|
|
4
|
-
const handleKeydown = useCallback((evt) => {
|
|
5
|
-
if (disabled)
|
|
6
|
-
return;
|
|
7
|
-
if (evt.key === inputKey) {
|
|
8
|
-
onKeyPressed();
|
|
9
|
-
}
|
|
10
|
-
}, [disabled, inputKey, onKeyPressed]);
|
|
11
4
|
useEffect(() => {
|
|
5
|
+
const handleKeydown = (evt) => {
|
|
6
|
+
if (disabled || evt.key !== inputKey)
|
|
7
|
+
return;
|
|
8
|
+
onKeyPressed();
|
|
9
|
+
};
|
|
12
10
|
document.addEventListener('keydown', handleKeydown);
|
|
13
11
|
return () => {
|
|
14
12
|
document.removeEventListener('keydown', handleKeydown);
|
|
15
13
|
};
|
|
16
|
-
}, [
|
|
14
|
+
}, [disabled, inputKey, onKeyPressed]);
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export { useKeyboardEventListener };
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
|
|
8
|
-
const usePromise = (fetcher, deps = []
|
|
8
|
+
const usePromise = (fetcher, deps = [], options = {
|
|
9
|
+
enabled: true,
|
|
10
|
+
}) => {
|
|
9
11
|
const [state, setState] = React.useState({
|
|
10
12
|
active: false,
|
|
11
13
|
});
|
|
@@ -35,7 +37,9 @@ const usePromise = (fetcher, deps = []) => {
|
|
|
35
37
|
}
|
|
36
38
|
}), [setState, fetcher]);
|
|
37
39
|
React.useEffect(() => {
|
|
38
|
-
|
|
40
|
+
if (options.enabled) {
|
|
41
|
+
fetch();
|
|
42
|
+
}
|
|
39
43
|
}, deps);
|
|
40
44
|
return Object.assign(Object.assign({}, state), { isLoading: state.active });
|
|
41
45
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
2
|
import { PromiseState } from './usePromise.types';
|
|
3
|
-
export
|
|
3
|
+
export type UsePromiseOptions = {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const usePromise: <T = unknown, E = unknown>(fetcher: () => T | Promise<T>, deps?: DependencyList, options?: UsePromiseOptions) => PromiseState<T, E>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
const usePromise = (fetcher, deps = []
|
|
4
|
+
const usePromise = (fetcher, deps = [], options = {
|
|
5
|
+
enabled: true,
|
|
6
|
+
}) => {
|
|
5
7
|
const [state, setState] = useState({
|
|
6
8
|
active: false,
|
|
7
9
|
});
|
|
@@ -31,7 +33,9 @@ const usePromise = (fetcher, deps = []) => {
|
|
|
31
33
|
}
|
|
32
34
|
}), [setState, fetcher]);
|
|
33
35
|
useEffect(() => {
|
|
34
|
-
|
|
36
|
+
if (options.enabled) {
|
|
37
|
+
fetch();
|
|
38
|
+
}
|
|
35
39
|
}, deps);
|
|
36
40
|
return Object.assign(Object.assign({}, state), { isLoading: state.active });
|
|
37
41
|
};
|
|
@@ -18,45 +18,23 @@ require('ethers');
|
|
|
18
18
|
require('../../../shared/consts/index.cjs');
|
|
19
19
|
|
|
20
20
|
const useRpcProviders = ({ networkConfigurations, }) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const [solanaDefaultProvider, setSolanaDefaultProvider] = React.useState();
|
|
24
|
-
React.useEffect(() => {
|
|
21
|
+
let providers, evmDefaultProvider, solanaDefaultProvider;
|
|
22
|
+
if (networkConfigurations) {
|
|
25
23
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
providers = rpcProviders.ChainRpcProviders.getProviders(networkConfigurations);
|
|
25
|
+
evmDefaultProvider = rpcProviders.ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, 1);
|
|
26
|
+
solanaDefaultProvider = rpcProviders.ChainRpcProviders.getSolanaRpcProviderByChainId(networkConfigurations, '101');
|
|
29
27
|
}
|
|
30
28
|
catch (error) {
|
|
31
29
|
logger.logger.error(error);
|
|
32
30
|
}
|
|
33
|
-
}
|
|
31
|
+
}
|
|
34
32
|
const getEvmRpcProviderByChainId = React.useCallback((chainId) => {
|
|
35
33
|
if (!networkConfigurations) {
|
|
36
34
|
return undefined;
|
|
37
35
|
}
|
|
38
36
|
return rpcProviders.ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, chainId);
|
|
39
37
|
}, [networkConfigurations]);
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
try {
|
|
42
|
-
if (networkConfigurations) {
|
|
43
|
-
setEvmDefaultProvider(rpcProviders.ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, 1));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
logger.logger.error(error);
|
|
48
|
-
}
|
|
49
|
-
}, [networkConfigurations]);
|
|
50
|
-
React.useEffect(() => {
|
|
51
|
-
try {
|
|
52
|
-
if (networkConfigurations) {
|
|
53
|
-
setSolanaDefaultProvider(rpcProviders.ChainRpcProviders.getSolanaRpcProviderByChainId(networkConfigurations, '101'));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
logger.logger.error(error);
|
|
58
|
-
}
|
|
59
|
-
}, [networkConfigurations]);
|
|
60
38
|
return {
|
|
61
39
|
evmDefaultProvider,
|
|
62
40
|
evmProviders: providers === null || providers === void 0 ? void 0 : providers.evm,
|
|
@@ -2,7 +2,6 @@ import { NetworkConfigurationMap } from '@dynamic-labs/types';
|
|
|
2
2
|
import { DynamicRPCProviders } from '../../../shared';
|
|
3
3
|
type Props = {
|
|
4
4
|
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
5
|
-
networkId: string | number | undefined;
|
|
6
5
|
};
|
|
7
6
|
export declare const useRpcProviders: ({ networkConfigurations, }: Props) => DynamicRPCProviders;
|
|
8
7
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
2
|
import { ChainRpcProviders } from '@dynamic-labs/rpc-providers';
|
|
3
3
|
import '@dynamic-labs/sdk-api';
|
|
4
4
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -14,45 +14,23 @@ import 'ethers';
|
|
|
14
14
|
import '../../../shared/consts/index.js';
|
|
15
15
|
|
|
16
16
|
const useRpcProviders = ({ networkConfigurations, }) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const [solanaDefaultProvider, setSolanaDefaultProvider] = useState();
|
|
20
|
-
useEffect(() => {
|
|
17
|
+
let providers, evmDefaultProvider, solanaDefaultProvider;
|
|
18
|
+
if (networkConfigurations) {
|
|
21
19
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
providers = ChainRpcProviders.getProviders(networkConfigurations);
|
|
21
|
+
evmDefaultProvider = ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, 1);
|
|
22
|
+
solanaDefaultProvider = ChainRpcProviders.getSolanaRpcProviderByChainId(networkConfigurations, '101');
|
|
25
23
|
}
|
|
26
24
|
catch (error) {
|
|
27
25
|
logger.error(error);
|
|
28
26
|
}
|
|
29
|
-
}
|
|
27
|
+
}
|
|
30
28
|
const getEvmRpcProviderByChainId = useCallback((chainId) => {
|
|
31
29
|
if (!networkConfigurations) {
|
|
32
30
|
return undefined;
|
|
33
31
|
}
|
|
34
32
|
return ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, chainId);
|
|
35
33
|
}, [networkConfigurations]);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
try {
|
|
38
|
-
if (networkConfigurations) {
|
|
39
|
-
setEvmDefaultProvider(ChainRpcProviders.getEvmProviderByChainId(networkConfigurations, 1));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
logger.error(error);
|
|
44
|
-
}
|
|
45
|
-
}, [networkConfigurations]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
try {
|
|
48
|
-
if (networkConfigurations) {
|
|
49
|
-
setSolanaDefaultProvider(ChainRpcProviders.getSolanaRpcProviderByChainId(networkConfigurations, '101'));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
logger.error(error);
|
|
54
|
-
}
|
|
55
|
-
}, [networkConfigurations]);
|
|
56
34
|
return {
|
|
57
35
|
evmDefaultProvider,
|
|
58
36
|
evmProviders: providers === null || providers === void 0 ? void 0 : providers.evm,
|