@dynamic-labs/sdk-react-core 0.18.0-RC.6 → 0.18.0-RC.8
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 +42 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +6 -0
- package/src/index.js +3 -0
- package/src/lib/Main.cjs +2 -2
- package/src/lib/Main.js +2 -2
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.cjs +5 -3
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.js +6 -4
- package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.types.d.ts +1 -0
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -5
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.d.ts +1 -9
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -4
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +11 -0
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.d.ts +9 -0
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +7 -0
- package/src/lib/components/ModalHeader/ModalHeader.types.d.ts +1 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.cjs +26 -1
- package/src/lib/components/NetworkPicker/NetworkPicker.js +26 -1
- package/src/lib/components/NetworkPicker/components/Network/Network.cjs +3 -1
- package/src/lib/components/NetworkPicker/components/Network/Network.d.ts +2 -1
- package/src/lib/components/NetworkPicker/components/Network/Network.js +3 -1
- 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/OTPVerificationView/OTPVerificationView.cjs +2 -3
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +0 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -3
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.cjs +2 -1
- package/src/lib/components/SelectWalletChainLayout/SelectWalletChainLayout.js +2 -1
- package/src/lib/components/Tooltip/Tooltip.cjs +1 -1
- package/src/lib/components/Tooltip/Tooltip.js +1 -1
- package/src/lib/components/TosAndPp/TosAndPp.cjs +6 -5
- package/src/lib/components/TosAndPp/TosAndPp.d.ts +3 -4
- package/src/lib/components/TosAndPp/TosAndPp.js +6 -5
- package/src/lib/components/Transition/transition.type.d.ts +3 -3
- package/src/lib/context/DynamicContext/DynamicContext.cjs +28 -18
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +4 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +29 -19
- package/src/lib/context/DynamicContext/helpers.cjs +1 -2
- package/src/lib/context/DynamicContext/helpers.js +1 -2
- package/src/lib/context/ErrorContext/ErrorContext.cjs +6 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +6 -0
- package/src/lib/context/MockContext/MockContext.cjs +2 -14
- package/src/lib/context/MockContext/MockContext.js +2 -14
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/context/WalletContext/WalletContext.cjs +46 -0
- package/src/lib/context/WalletContext/WalletContext.d.ts +7 -0
- package/src/lib/context/WalletContext/WalletContext.js +41 -0
- package/src/lib/context/WalletContext/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +22 -63
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.d.ts +1 -6
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +23 -64
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +34 -15
- package/src/lib/layout/DynamicAuthLayout/Header/header.d.ts +1 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +35 -16
- package/src/lib/layout/DynamicAuthLayout/Header/header.types.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/{FooterContent/EmptyFooterContent/empty-footer-content.cjs → HelpContent/EmptyHelpContent/EmptyHelpContent.cjs} +2 -2
- package/src/lib/layout/DynamicAuthLayout/HelpContent/EmptyHelpContent/EmptyHelpContent.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/EmptyHelpContent/EmptyHelpContent.js +6 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/EmptyHelpContent/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.cjs +36 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpContent.js +32 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.cjs +56 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/HelpHeader.js +52 -0
- package/src/lib/layout/DynamicAuthLayout/HelpContent/HelpHeader/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent/WalletListFooterContent.cjs → HelpContent/WalletListHelpContent/WalletListHelpContent.cjs} +3 -3
- package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent/WalletListFooterContent.d.ts → HelpContent/WalletListHelpContent/WalletListHelpContent.d.ts} +1 -1
- package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent/WalletListFooterContent.js → HelpContent/WalletListHelpContent/WalletListHelpContent.js} +3 -3
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletListHelpContent/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/{FooterContent → HelpContent}/WalletMoreInfoContent/WalletMoreInfoContent.cjs +3 -5
- package/src/lib/layout/DynamicAuthLayout/HelpContent/WalletMoreInfoContent/WalletMoreInfoContent.d.ts +7 -0
- package/src/lib/layout/DynamicAuthLayout/{FooterContent → HelpContent}/WalletMoreInfoContent/WalletMoreInfoContent.js +3 -5
- package/src/lib/layout/DynamicAuthLayout/HelpContent/index.d.ts +4 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +49 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.d.ts +2 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +45 -0
- package/src/lib/layout/DynamicAuthLayout/ToSFooter/index.d.ts +1 -0
- package/src/lib/shared/assets/chevron-left.cjs +5 -5
- package/src/lib/shared/assets/chevron-left.js +5 -5
- package/src/lib/shared/assets/close.cjs +5 -5
- package/src/lib/shared/assets/close.js +5 -5
- package/src/lib/shared/assets/footer-info-icon.cjs +2 -2
- package/src/lib/shared/assets/footer-info-icon.js +2 -2
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/shared/assets/question-mark.cjs +58 -0
- package/src/lib/shared/assets/question-mark.js +34 -0
- 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/getDynamicLayoutData/getDynamicLayoutData.cjs +7 -27
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.d.ts +3 -4
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +8 -28
- 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 +2 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -1
- 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 +4 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +9 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +9 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +68 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +10 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +64 -0
- 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 +20 -6
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +14 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +20 -6
- 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/useInterval/useInterval.d.ts +1 -0
- package/src/lib/utils/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +10 -0
- package/src/lib/utils/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +2 -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/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.d.ts +1 -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/useVerifyWallet/useVerifyWallet.cjs +4 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +4 -1
- 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/useWallets/useWallets.cjs +4 -1
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -1
- package/src/lib/utils/hooks/useWallets/useWallets.js +4 -1
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +2 -3
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +2 -3
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -1
- package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -1
- 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 +2 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -2
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.cjs +3 -0
- package/src/lib/views/LoginWithEmailView/LoginWithEmailView.js +3 -0
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +2 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +2 -1
- package/src/lib/views/PendingConnectView/PendingConnectView.cjs +2 -3
- package/src/lib/views/PendingConnectView/PendingConnectView.js +2 -3
- package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +2 -3
- package/src/lib/views/PendingSignatureView/PendingSignatureView.js +2 -3
- package/src/lib/views/QrCodeView/QRCode.cjs +36 -4
- package/src/lib/views/QrCodeView/QRCode.js +37 -5
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +2 -2
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.d.ts +1 -3
- package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +2 -2
- package/src/lib/views/QrCodeView/QrCodeView.cjs +5 -8
- package/src/lib/views/QrCodeView/QrCodeView.js +5 -8
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +2 -4
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +2 -4
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs +15 -0
- package/src/lib/views/TransactionConfirmationView/helpers/transactionErrorMessage.js +15 -0
- 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 +63 -0
- package/src/lib/views/WalletLockedView/WalletLockedView.d.ts +2 -0
- package/src/lib/views/WalletLockedView/WalletLockedView.js +59 -0
- package/src/lib/views/WalletLockedView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.cjs +23 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.d.ts +8 -0
- package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeConnectButton/DynamicBridgeConnectButton.js +19 -0
- package/src/lib/widgets/DynamicBridgeWidget/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/Footer/Footer.cjs +0 -67
- package/src/lib/layout/DynamicAuthLayout/Footer/Footer.d.ts +0 -10
- package/src/lib/layout/DynamicAuthLayout/Footer/Footer.js +0 -63
- package/src/lib/layout/DynamicAuthLayout/Footer/index.d.ts +0 -1
- package/src/lib/layout/DynamicAuthLayout/FooterContent/EmptyFooterContent/empty-footer-content.d.ts +0 -2
- package/src/lib/layout/DynamicAuthLayout/FooterContent/EmptyFooterContent/empty-footer-content.js +0 -6
- package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/index.d.ts +0 -1
- package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletMoreInfoContent/WalletMoreInfoContent.d.ts +0 -8
- package/src/lib/layout/DynamicAuthLayout/FooterContent/index.d.ts +0 -3
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/Item/Item.cjs +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/Item/Item.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/Item/Item.js +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/Item/index.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/NewToWeb3WalletItem/NewToWeb3WalletItem.cjs +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/NewToWeb3WalletItem/NewToWeb3WalletItem.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/NewToWeb3WalletItem/NewToWeb3WalletItem.js +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/NewToWeb3WalletItem/index.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent/WalletListFooterContent → HelpContent/WalletListHelpContent}/WalletExtensionOrAppContinueButton/index.d.ts +0 -0
- /package/src/lib/layout/DynamicAuthLayout/{FooterContent → HelpContent}/WalletMoreInfoContent/index.d.ts +0 -0
|
@@ -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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useInterval: (callback: () => void, delay: number | null) => void;
|
|
@@ -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 };
|
|
@@ -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,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var useIsomorphicLayoutEffect = require('../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs');
|
|
7
|
+
|
|
8
|
+
// https://usehooks-ts.com/react-hook/use-timeout
|
|
9
|
+
const useTimeout = (callback, delay) => {
|
|
10
|
+
const savedCallback = React.useRef(callback);
|
|
11
|
+
// Remember the latest callback if it changes.
|
|
12
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
13
|
+
savedCallback.current = callback;
|
|
14
|
+
}, [callback]);
|
|
15
|
+
// Set up the timeout.
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
// Don't schedule if no delay is specified.
|
|
18
|
+
// Note: 0 is a valid value for delay.
|
|
19
|
+
if (!delay && delay !== 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const id = setTimeout(() => savedCallback.current(), delay);
|
|
23
|
+
return () => clearTimeout(id);
|
|
24
|
+
}, [delay]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useTimeout = useTimeout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTimeout: (callback: () => void, delay: number | null) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js';
|
|
3
|
+
|
|
4
|
+
// https://usehooks-ts.com/react-hook/use-timeout
|
|
5
|
+
const useTimeout = (callback, delay) => {
|
|
6
|
+
const savedCallback = useRef(callback);
|
|
7
|
+
// Remember the latest callback if it changes.
|
|
8
|
+
useIsomorphicLayoutEffect(() => {
|
|
9
|
+
savedCallback.current = callback;
|
|
10
|
+
}, [callback]);
|
|
11
|
+
// Set up the timeout.
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
// Don't schedule if no delay is specified.
|
|
14
|
+
// Note: 0 is a valid value for delay.
|
|
15
|
+
if (!delay && delay !== 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const id = setTimeout(() => savedCallback.current(), delay);
|
|
19
|
+
return () => clearTimeout(id);
|
|
20
|
+
}, [delay]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { useTimeout };
|
|
@@ -10,22 +10,22 @@ var useTransitionEvents = require('../useTransitionEvents/useTransitionEvents.cj
|
|
|
10
10
|
const DEFAULT_DURATION = 100;
|
|
11
11
|
// The hook inspired by https://github.com/reactjs/react-transition-group/blob/master/src/Transition.js
|
|
12
12
|
const useTransition = (_a) => {
|
|
13
|
-
var { isShown, inDuration, outDuration, duration = DEFAULT_DURATION,
|
|
14
|
-
const
|
|
13
|
+
var { isShown, inDuration, outDuration, duration = DEFAULT_DURATION, delay, inDelay, outDelay, animateOnMount = true } = _a, events = _tslib.__rest(_a, ["isShown", "inDuration", "outDuration", "duration", "delay", "inDelay", "outDelay", "animateOnMount"]);
|
|
14
|
+
const initialStage = animateOnMount ? 'UNMOUNT' : 'ENTERED';
|
|
15
15
|
const animationFrameTimeoutIdRef = React.useRef({ id: -1 });
|
|
16
16
|
const timeoutIdRef = React.useRef({ id: -1 });
|
|
17
|
-
const [stage, setStage] = React.useState(
|
|
17
|
+
const [stage, setStage] = React.useState(initialStage);
|
|
18
18
|
const [mount, setMount] = React.useState(!animateOnMount);
|
|
19
19
|
const [currentDuration, setCurrentDuration] = React.useState(duration);
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
timeoutIdRef.current = animationFrameTimeout.animationFrameTimeout(
|
|
20
|
+
const performTransition = (runTransition, transitionDelay) => {
|
|
21
|
+
if (transitionDelay) {
|
|
22
|
+
timeoutIdRef.current = animationFrameTimeout.animationFrameTimeout(runTransition, transitionDelay);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
|
|
25
|
+
runTransition();
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
const performEnter = React.useCallback(() =>
|
|
28
|
+
const performEnter = React.useCallback(() => {
|
|
29
29
|
const animationDuration = inDuration || duration;
|
|
30
30
|
setCurrentDuration(animationDuration);
|
|
31
31
|
setMount(true);
|
|
@@ -33,8 +33,8 @@ const useTransition = (_a) => {
|
|
|
33
33
|
animationFrameTimeoutIdRef.current = animationFrameTimeout.animationFrameTimeout(() => {
|
|
34
34
|
setStage('ENTERED');
|
|
35
35
|
}, animationDuration);
|
|
36
|
-
}
|
|
37
|
-
const performExit = React.useCallback(() =>
|
|
36
|
+
}, [duration, inDuration]);
|
|
37
|
+
const performExit = React.useCallback(() => {
|
|
38
38
|
const animationDuration = outDuration || duration;
|
|
39
39
|
setCurrentDuration(animationDuration);
|
|
40
40
|
setStage('EXITING');
|
|
@@ -42,29 +42,21 @@ const useTransition = (_a) => {
|
|
|
42
42
|
setMount(false);
|
|
43
43
|
setStage('UNMOUNT');
|
|
44
44
|
}, animationDuration);
|
|
45
|
-
}
|
|
45
|
+
}, [duration, outDuration]);
|
|
46
46
|
React.useEffect(() => {
|
|
47
47
|
if (isShown && stage !== 'ENTERED') {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const enterDelay = inDelay || delay;
|
|
49
|
+
performTransition(performEnter, enterDelay);
|
|
50
50
|
}
|
|
51
51
|
else if (!isShown && stage !== 'UNMOUNT') {
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const exitDelay = outDelay || delay;
|
|
53
|
+
performTransition(performExit, exitDelay);
|
|
54
54
|
}
|
|
55
55
|
return () => {
|
|
56
56
|
animationFrameTimeout.clearAnimationFrameTimeout(animationFrameTimeoutIdRef.current);
|
|
57
57
|
animationFrameTimeout.clearAnimationFrameTimeout(timeoutIdRef.current);
|
|
58
58
|
};
|
|
59
|
-
}, [
|
|
60
|
-
inTimeout,
|
|
61
|
-
outTimeout,
|
|
62
|
-
performEnter,
|
|
63
|
-
performExit,
|
|
64
|
-
isShown,
|
|
65
|
-
timeout,
|
|
66
|
-
stage,
|
|
67
|
-
]);
|
|
59
|
+
}, [inDelay, outDelay, performEnter, performExit, isShown, delay, stage]);
|
|
68
60
|
useTransitionEvents.useTransitionEvents(stage, events);
|
|
69
61
|
return { currentDuration, mount, stage };
|
|
70
62
|
};
|
|
@@ -8,11 +8,11 @@ export type UseTransitionProps = {
|
|
|
8
8
|
animateOnMount?: boolean;
|
|
9
9
|
duration?: number;
|
|
10
10
|
inDuration?: number;
|
|
11
|
-
|
|
11
|
+
inDelay?: number;
|
|
12
12
|
isShown?: boolean;
|
|
13
13
|
outDuration?: number;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
outDelay?: number;
|
|
15
|
+
delay?: number;
|
|
16
16
|
};
|
|
17
17
|
export type Props = UseTransitionProps & UseTransitionEvents;
|
|
18
18
|
export type TransitionStage = 'ENTERED' | 'ENTERING' | 'EXITING' | 'UNMOUNT';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __rest
|
|
1
|
+
import { __rest } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { animationFrameTimeout, clearAnimationFrameTimeout } from '../../functions/animationFrameTimeout/animationFrameTimeout.js';
|
|
4
4
|
import { useTransitionEvents } from '../useTransitionEvents/useTransitionEvents.js';
|
|
@@ -6,22 +6,22 @@ import { useTransitionEvents } from '../useTransitionEvents/useTransitionEvents.
|
|
|
6
6
|
const DEFAULT_DURATION = 100;
|
|
7
7
|
// The hook inspired by https://github.com/reactjs/react-transition-group/blob/master/src/Transition.js
|
|
8
8
|
const useTransition = (_a) => {
|
|
9
|
-
var { isShown, inDuration, outDuration, duration = DEFAULT_DURATION,
|
|
10
|
-
const
|
|
9
|
+
var { isShown, inDuration, outDuration, duration = DEFAULT_DURATION, delay, inDelay, outDelay, animateOnMount = true } = _a, events = __rest(_a, ["isShown", "inDuration", "outDuration", "duration", "delay", "inDelay", "outDelay", "animateOnMount"]);
|
|
10
|
+
const initialStage = animateOnMount ? 'UNMOUNT' : 'ENTERED';
|
|
11
11
|
const animationFrameTimeoutIdRef = useRef({ id: -1 });
|
|
12
12
|
const timeoutIdRef = useRef({ id: -1 });
|
|
13
|
-
const [stage, setStage] = useState(
|
|
13
|
+
const [stage, setStage] = useState(initialStage);
|
|
14
14
|
const [mount, setMount] = useState(!animateOnMount);
|
|
15
15
|
const [currentDuration, setCurrentDuration] = useState(duration);
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
timeoutIdRef.current = animationFrameTimeout(
|
|
16
|
+
const performTransition = (runTransition, transitionDelay) => {
|
|
17
|
+
if (transitionDelay) {
|
|
18
|
+
timeoutIdRef.current = animationFrameTimeout(runTransition, transitionDelay);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
|
|
21
|
+
runTransition();
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
const performEnter = useCallback(() =>
|
|
24
|
+
const performEnter = useCallback(() => {
|
|
25
25
|
const animationDuration = inDuration || duration;
|
|
26
26
|
setCurrentDuration(animationDuration);
|
|
27
27
|
setMount(true);
|
|
@@ -29,8 +29,8 @@ const useTransition = (_a) => {
|
|
|
29
29
|
animationFrameTimeoutIdRef.current = animationFrameTimeout(() => {
|
|
30
30
|
setStage('ENTERED');
|
|
31
31
|
}, animationDuration);
|
|
32
|
-
}
|
|
33
|
-
const performExit = useCallback(() =>
|
|
32
|
+
}, [duration, inDuration]);
|
|
33
|
+
const performExit = useCallback(() => {
|
|
34
34
|
const animationDuration = outDuration || duration;
|
|
35
35
|
setCurrentDuration(animationDuration);
|
|
36
36
|
setStage('EXITING');
|
|
@@ -38,29 +38,21 @@ const useTransition = (_a) => {
|
|
|
38
38
|
setMount(false);
|
|
39
39
|
setStage('UNMOUNT');
|
|
40
40
|
}, animationDuration);
|
|
41
|
-
}
|
|
41
|
+
}, [duration, outDuration]);
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
if (isShown && stage !== 'ENTERED') {
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const enterDelay = inDelay || delay;
|
|
45
|
+
performTransition(performEnter, enterDelay);
|
|
46
46
|
}
|
|
47
47
|
else if (!isShown && stage !== 'UNMOUNT') {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const exitDelay = outDelay || delay;
|
|
49
|
+
performTransition(performExit, exitDelay);
|
|
50
50
|
}
|
|
51
51
|
return () => {
|
|
52
52
|
clearAnimationFrameTimeout(animationFrameTimeoutIdRef.current);
|
|
53
53
|
clearAnimationFrameTimeout(timeoutIdRef.current);
|
|
54
54
|
};
|
|
55
|
-
}, [
|
|
56
|
-
inTimeout,
|
|
57
|
-
outTimeout,
|
|
58
|
-
performEnter,
|
|
59
|
-
performExit,
|
|
60
|
-
isShown,
|
|
61
|
-
timeout,
|
|
62
|
-
stage,
|
|
63
|
-
]);
|
|
55
|
+
}, [inDelay, outDelay, performEnter, performExit, isShown, delay, stage]);
|
|
64
56
|
useTransitionEvents(stage, events);
|
|
65
57
|
return { currentDuration, mount, stage };
|
|
66
58
|
};
|
|
@@ -4,21 +4,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var useUpdateEffect = require('../useUpdateEffect/useUpdateEffect.cjs');
|
|
6
6
|
|
|
7
|
-
const useTransitionEvents = (stage, events) =>
|
|
8
|
-
var _a;
|
|
7
|
+
const useTransitionEvents = (stage, events) => {
|
|
9
8
|
const mapCallbackToStage = {
|
|
10
9
|
ENTERED: events === null || events === void 0 ? void 0 : events.onEntered,
|
|
11
10
|
ENTERING: events === null || events === void 0 ? void 0 : events.onEntering,
|
|
12
11
|
EXITING: events === null || events === void 0 ? void 0 : events.onExiting,
|
|
13
12
|
UNMOUNT: events === null || events === void 0 ? void 0 : events.onUnmount,
|
|
14
13
|
};
|
|
15
|
-
(
|
|
16
|
-
return () => {
|
|
14
|
+
return useUpdateEffect.useUpdateEffect(() => {
|
|
17
15
|
var _a;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
(_a = mapCallbackToStage[stage]) === null || _a === void 0 ? void 0 : _a.call(mapCallbackToStage);
|
|
17
|
+
return () => {
|
|
18
|
+
var _a;
|
|
19
|
+
if (stage === 'EXITING') {
|
|
20
|
+
(_a = mapCallbackToStage.UNMOUNT) === null || _a === void 0 ? void 0 : _a.call(mapCallbackToStage);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, [stage]);
|
|
24
|
+
};
|
|
23
25
|
|
|
24
26
|
exports.useTransitionEvents = useTransitionEvents;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { useUpdateEffect } from '../useUpdateEffect/useUpdateEffect.js';
|
|
2
2
|
|
|
3
|
-
const useTransitionEvents = (stage, events) =>
|
|
4
|
-
var _a;
|
|
3
|
+
const useTransitionEvents = (stage, events) => {
|
|
5
4
|
const mapCallbackToStage = {
|
|
6
5
|
ENTERED: events === null || events === void 0 ? void 0 : events.onEntered,
|
|
7
6
|
ENTERING: events === null || events === void 0 ? void 0 : events.onEntering,
|
|
8
7
|
EXITING: events === null || events === void 0 ? void 0 : events.onExiting,
|
|
9
8
|
UNMOUNT: events === null || events === void 0 ? void 0 : events.onUnmount,
|
|
10
9
|
};
|
|
11
|
-
(
|
|
12
|
-
return () => {
|
|
10
|
+
return useUpdateEffect(() => {
|
|
13
11
|
var _a;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
(_a = mapCallbackToStage[stage]) === null || _a === void 0 ? void 0 : _a.call(mapCallbackToStage);
|
|
13
|
+
return () => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (stage === 'EXITING') {
|
|
16
|
+
(_a = mapCallbackToStage.UNMOUNT) === null || _a === void 0 ? void 0 : _a.call(mapCallbackToStage);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}, [stage]);
|
|
20
|
+
};
|
|
19
21
|
|
|
20
22
|
export { useTransitionEvents };
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
38
38
|
const { setDeniedAddress, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setConnectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -91,6 +91,8 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
94
|
+
removeConnectedWalletsInfo();
|
|
95
|
+
setConnectedWallets([]);
|
|
94
96
|
// This is a special case where the user is trying to link a wallet
|
|
95
97
|
// and the wallet is already linked and we don't want to kill the session.
|
|
96
98
|
if (e instanceof utils.WalletUsedError) {
|
|
@@ -144,6 +146,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
144
146
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
145
147
|
setOnboardingOnlyJwt(Jwt);
|
|
146
148
|
localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.name);
|
|
149
|
+
setAuthMode('connect-and-sign');
|
|
147
150
|
updatePrimaryWalletId(walletConnector, user);
|
|
148
151
|
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
149
152
|
if (projectSettings &&
|
|
@@ -34,7 +34,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
34
34
|
const { setDeniedAddress, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
35
35
|
const { setView, goToInitialView } = useViewContext();
|
|
36
36
|
const { setErrorMessage, setError } = useErrorContext();
|
|
37
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, } = useInternalDynamicContext();
|
|
37
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallet, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setConnectedWallets, } = useInternalDynamicContext();
|
|
38
38
|
// If the user is not already logged it means that we only need to verify
|
|
39
39
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
40
40
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -87,6 +87,8 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
90
|
+
removeConnectedWalletsInfo();
|
|
91
|
+
setConnectedWallets([]);
|
|
90
92
|
// This is a special case where the user is trying to link a wallet
|
|
91
93
|
// and the wallet is already linked and we don't want to kill the session.
|
|
92
94
|
if (e instanceof WalletUsedError) {
|
|
@@ -140,6 +142,7 @@ const useVerifyWallet = ({ consumeNonce, displayTermsOfService, environmentId, p
|
|
|
140
142
|
const isKycRequired = decodedJwt.missingFields.length;
|
|
141
143
|
setOnboardingOnlyJwt(Jwt);
|
|
142
144
|
LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.name);
|
|
145
|
+
setAuthMode('connect-and-sign');
|
|
143
146
|
updatePrimaryWalletId(walletConnector, user);
|
|
144
147
|
// Routes user to "Not Supported Network" screen if the user is not on the supported network
|
|
145
148
|
if (projectSettings &&
|
|
@@ -62,6 +62,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
62
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
63
|
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
64
64
|
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
65
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isInitialized,
|
|
65
66
|
]);
|
|
66
67
|
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
67
68
|
const linkedSecondaryWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
@@ -58,6 +58,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
58
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
59
|
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
60
60
|
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
61
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isInitialized,
|
|
61
62
|
]);
|
|
62
63
|
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
63
64
|
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var data = require('../../../views/WalletList/data.cjs');
|
|
7
7
|
|
|
8
|
-
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletUiUtils, walletConnectorsProp, }) => {
|
|
8
|
+
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }) => {
|
|
9
9
|
const wallets = React.useMemo(() => {
|
|
10
10
|
if (!projectSettings || !Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length)
|
|
11
11
|
return [];
|
|
@@ -17,6 +17,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
|
|
|
17
17
|
networkConfigurations,
|
|
18
18
|
skipMemo: true,
|
|
19
19
|
walletBook,
|
|
20
|
+
walletConnectV1Bridge,
|
|
20
21
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
21
22
|
walletUiUtils,
|
|
22
23
|
});
|
|
@@ -28,6 +29,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
|
|
|
28
29
|
networkConfigurations,
|
|
29
30
|
skipMemo: true,
|
|
30
31
|
walletBook,
|
|
32
|
+
walletConnectV1Bridge,
|
|
31
33
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
32
34
|
walletUiUtils,
|
|
33
35
|
});
|
|
@@ -39,6 +41,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, network
|
|
|
39
41
|
networkConfigurations,
|
|
40
42
|
projectSettings,
|
|
41
43
|
walletConnectorsProp,
|
|
44
|
+
walletConnectV1Bridge,
|
|
42
45
|
flowNetwork,
|
|
43
46
|
Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length,
|
|
44
47
|
]);
|