@dynamic-labs/sdk-react-core 0.18.0-beta.32 → 0.18.1
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 +32 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +4 -2
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +4 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +2 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
- package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/errors.cjs +7 -0
- package/src/lib/utils/constants/errors.d.ts +1 -0
- package/src/lib/utils/constants/errors.js +3 -0
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +3 -1
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
- package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
- package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +9 -3
- package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +9 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
- package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +5 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.js +5 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +7 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
- package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +4 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +11 -16
- package/src/lib/views/SendBalanceView/SendBalanceView.js +11 -16
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +66 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +62 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
- package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
- package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
- package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +22 -4
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +22 -4
- package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +17 -42
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
- package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.js → useTransactionGas/useTransactionGas.js} +18 -43
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +7 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
- package/src/lib/views/WalletList/WalletList.cjs +4 -1
- package/src/lib/views/WalletList/WalletList.js +4 -1
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
- package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -18
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __awaiter, __rest } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { usePromise } from '../usePromise/usePromise.js';
|
|
3
|
+
import '@dynamic-labs/sdk-api';
|
|
4
|
+
import { logger } from '../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '@dynamic-labs/utils';
|
|
12
|
+
import '../../constants/colors.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import 'ethers';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Hook to estimate the gas required for a transaction.
|
|
19
|
+
*
|
|
20
|
+
* This hook uses the `usePromise` hook to asynchronously estimate the gas required for a transaction.
|
|
21
|
+
* It first tries to estimate the gas without the 'from' field in the transaction, as the Alchemy API
|
|
22
|
+
* checks the origin address funds and can return an error if the origin wallet has no funds for the transaction.
|
|
23
|
+
* If the error 'UNPREDICTABLE_GAS_LIMIT' is encountered, it tries to estimate the gas again with the
|
|
24
|
+
* original transaction.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://docs.alchemy.com/reference/eth-estimategas}
|
|
27
|
+
* @see {@link https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT}
|
|
28
|
+
*
|
|
29
|
+
* @param {ethers.providers.Web3Provider} provider - The Web3 provider to use for estimating the gas.
|
|
30
|
+
* @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} transaction - The transaction for
|
|
31
|
+
* which to estimate the gas.
|
|
32
|
+
*
|
|
33
|
+
* @returns {PromiseState<ethers.BigNumber>} A promise that resolves to the estimated gas for the transaction.
|
|
34
|
+
*/
|
|
35
|
+
const useTransactionEstimatedGas = (provider, transaction) => usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
// To safely run estimateGas using alchemy, we need to remove the from address
|
|
37
|
+
// because alchemy checks the origin address funds and can return an error if
|
|
38
|
+
// origin wallet has no funds for the transaction
|
|
39
|
+
// https://docs.alchemy.com/reference/eth-estimategas
|
|
40
|
+
const transactionWithNoOrigin = __rest(transaction, ["from"]);
|
|
41
|
+
try {
|
|
42
|
+
return yield provider.estimateGas(transactionWithNoOrigin);
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
logger.error(err);
|
|
47
|
+
// If the error is UNPREDICTABLE_GAS_LIMIT, we try to estimate gas again
|
|
48
|
+
// with original transaction
|
|
49
|
+
// https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT
|
|
50
|
+
if (err.code === 'UNPREDICTABLE_GAS_LIMIT') {
|
|
51
|
+
return provider.estimateGas(transaction);
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}), { deps: [transaction, provider] });
|
|
56
|
+
|
|
57
|
+
export { useTransactionEstimatedGas };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTransactionWithGasPrice } from './useTransactionWithGasPrice';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var usePromise = require('../usePromise/usePromise.cjs');
|
|
6
|
+
|
|
7
|
+
const increaseGasPrice = (gasPrice, increasePercentage) => {
|
|
8
|
+
const increaseFactor = 100 + increasePercentage;
|
|
9
|
+
return gasPrice.mul(increaseFactor).div(100);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
|
|
13
|
+
* The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
|
|
14
|
+
* or disable this functionality.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} props - The properties for the hook.
|
|
17
|
+
* @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
|
|
18
|
+
* @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
|
|
19
|
+
* @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
|
|
20
|
+
* @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
|
|
21
|
+
*
|
|
22
|
+
* @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
|
|
23
|
+
* If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
|
|
24
|
+
* gas price set, the original transaction object is returned.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const updatedTransaction = useTransactionWithGasPrice({
|
|
28
|
+
* provider: myProvider,
|
|
29
|
+
* transaction: myTransaction,
|
|
30
|
+
* increasePercentage: 10,
|
|
31
|
+
* enabled: true,
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
const useTransactionWithGasPrice = ({ increasePercentage = 0, provider, transaction, enabled = true, }) => {
|
|
35
|
+
const isGasPriceDefinedInTransaction = Boolean(transaction.gasPrice);
|
|
36
|
+
const shouldLoadGasPrice = enabled && increasePercentage > 0 && !isGasPriceDefinedInTransaction;
|
|
37
|
+
const { data: gasPrice } = usePromise.usePromise(() => provider.getGasPrice(), {
|
|
38
|
+
deps: [transaction, provider],
|
|
39
|
+
enabled: shouldLoadGasPrice,
|
|
40
|
+
});
|
|
41
|
+
if (!gasPrice) {
|
|
42
|
+
return transaction;
|
|
43
|
+
}
|
|
44
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.useTransactionWithGasPrice = useTransactionWithGasPrice;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
type UseTransactionWithGasPriceProps = {
|
|
3
|
+
provider: ethers.providers.Provider;
|
|
4
|
+
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
|
|
5
|
+
increasePercentage?: number;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
|
|
10
|
+
* The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
|
|
11
|
+
* or disable this functionality.
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} props - The properties for the hook.
|
|
14
|
+
* @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
|
|
15
|
+
* @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
|
|
16
|
+
* @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
|
|
17
|
+
* @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
|
|
18
|
+
*
|
|
19
|
+
* @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
|
|
20
|
+
* If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
|
|
21
|
+
* gas price set, the original transaction object is returned.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const updatedTransaction = useTransactionWithGasPrice({
|
|
25
|
+
* provider: myProvider,
|
|
26
|
+
* transaction: myTransaction,
|
|
27
|
+
* increasePercentage: 10,
|
|
28
|
+
* enabled: true,
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
export declare const useTransactionWithGasPrice: ({ increasePercentage, provider, transaction, enabled, }: UseTransactionWithGasPriceProps) => ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { usePromise } from '../usePromise/usePromise.js';
|
|
2
|
+
|
|
3
|
+
const increaseGasPrice = (gasPrice, increasePercentage) => {
|
|
4
|
+
const increaseFactor = 100 + increasePercentage;
|
|
5
|
+
return gasPrice.mul(increaseFactor).div(100);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
|
|
9
|
+
* The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
|
|
10
|
+
* or disable this functionality.
|
|
11
|
+
*
|
|
12
|
+
* @param {Object} props - The properties for the hook.
|
|
13
|
+
* @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
|
|
14
|
+
* @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
|
|
15
|
+
* @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
|
|
16
|
+
* @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
|
|
17
|
+
*
|
|
18
|
+
* @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
|
|
19
|
+
* If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
|
|
20
|
+
* gas price set, the original transaction object is returned.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const updatedTransaction = useTransactionWithGasPrice({
|
|
24
|
+
* provider: myProvider,
|
|
25
|
+
* transaction: myTransaction,
|
|
26
|
+
* increasePercentage: 10,
|
|
27
|
+
* enabled: true,
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
const useTransactionWithGasPrice = ({ increasePercentage = 0, provider, transaction, enabled = true, }) => {
|
|
31
|
+
const isGasPriceDefinedInTransaction = Boolean(transaction.gasPrice);
|
|
32
|
+
const shouldLoadGasPrice = enabled && increasePercentage > 0 && !isGasPriceDefinedInTransaction;
|
|
33
|
+
const { data: gasPrice } = usePromise(() => provider.getGasPrice(), {
|
|
34
|
+
deps: [transaction, provider],
|
|
35
|
+
enabled: shouldLoadGasPrice,
|
|
36
|
+
});
|
|
37
|
+
if (!gasPrice) {
|
|
38
|
+
return transaction;
|
|
39
|
+
}
|
|
40
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useTransactionWithGasPrice };
|
|
@@ -145,6 +145,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
145
145
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
146
146
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
147
147
|
try {
|
|
148
|
+
setIsVerificationInProgress(true);
|
|
148
149
|
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
149
150
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
150
151
|
if (decodedJwt === undefined)
|
|
@@ -141,6 +141,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
141
141
|
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
142
|
const walletProvider = getWalletProvider(walletConnector);
|
|
143
143
|
try {
|
|
144
|
+
setIsVerificationInProgress(true);
|
|
144
145
|
const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
145
146
|
const decodedJwt = decodeJwt(Jwt);
|
|
146
147
|
if (decodedJwt === undefined)
|
|
@@ -17,7 +17,7 @@ export type UseWalletEventListenersArgs = {
|
|
|
17
17
|
setSelectedWalletWithAction(walletWithAction: WalletWithAction | null): void;
|
|
18
18
|
user: UserProfile | undefined;
|
|
19
19
|
authMode: AuthModeType;
|
|
20
|
-
refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector) => Promise<void>;
|
|
20
|
+
refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector, shouldCallCallback?: boolean) => Promise<void>;
|
|
21
21
|
};
|
|
22
22
|
export declare const useWalletEventListeners: ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }: UseWalletEventListenersArgs) => {
|
|
23
23
|
loadingNetwork: boolean;
|
|
@@ -67,11 +67,11 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
|
|
|
67
67
|
}
|
|
68
68
|
return openSignMessage((resolve, reject) => (jsxRuntime.jsx(SignMessageConfirmationModal.SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
|
|
69
69
|
}, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
|
|
70
|
-
const sendTransaction = React.useCallback(({ transaction, handler, provider }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
const sendTransaction = React.useCallback(({ transaction, handler, provider, connector }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
71
71
|
if (!shouldConfirmAction()) {
|
|
72
72
|
return handler(transaction);
|
|
73
73
|
}
|
|
74
|
-
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
74
|
+
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { walletConnector: connector, title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
75
75
|
}), [openSendTransaction, shouldConfirmAction]);
|
|
76
76
|
const disabledConfirmationOnce = React.useCallback(() => {
|
|
77
77
|
confirmationStateRef.current = 'disabled';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { WalletUiUtils } from '@dynamic-labs/types';
|
|
3
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { WalletUiUtilsHookProps } from './useWalletUiUtils.types';
|
|
4
|
-
export declare const useWalletUiUtils: ({ appLogoUrl, appName, getAppOrigin, }: WalletUiUtilsHookProps) => [
|
|
5
|
+
export declare const useWalletUiUtils: ({ appLogoUrl, appName, getAppOrigin, }: WalletUiUtilsHookProps) => [
|
|
6
|
+
ReactNode | undefined,
|
|
7
|
+
WalletUiUtils<WalletConnector>
|
|
8
|
+
];
|
|
@@ -63,11 +63,11 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
|
|
|
63
63
|
}
|
|
64
64
|
return openSignMessage((resolve, reject) => (jsx(SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
|
|
65
65
|
}, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
|
|
66
|
-
const sendTransaction = useCallback(({ transaction, handler, provider }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const sendTransaction = useCallback(({ transaction, handler, provider, connector }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
67
|
if (!shouldConfirmAction()) {
|
|
68
68
|
return handler(transaction);
|
|
69
69
|
}
|
|
70
|
-
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
70
|
+
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { walletConnector: connector, title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
|
|
71
71
|
}), [openSendTransaction, shouldConfirmAction]);
|
|
72
72
|
const disabledConfirmationOnce = useCallback(() => {
|
|
73
73
|
confirmationStateRef.current = 'disabled';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
2
2
|
import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
|
|
3
|
-
import { WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
5
5
|
type Props = {
|
|
6
6
|
appLogoUrl?: string;
|
|
@@ -11,7 +11,7 @@ type Props = {
|
|
|
11
11
|
walletBook: WalletBookSchema;
|
|
12
12
|
walletConnectV1Bridge?: string;
|
|
13
13
|
walletConnectorsProp?: WalletConnectorsMethod[];
|
|
14
|
-
walletUiUtils: WalletUiUtils
|
|
14
|
+
walletUiUtils: WalletUiUtils<WalletConnector>;
|
|
15
15
|
};
|
|
16
16
|
export declare const useWallets: ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
|
|
17
17
|
wallets: import("../../../shared").WalletOption[];
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var iconic = require('@dynamic-labs/iconic');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
9
|
require('react');
|
|
9
10
|
var Typography = require('../../components/Typography/Typography.cjs');
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
11
12
|
require('../../shared/logger.cjs');
|
|
12
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
13
13
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
14
14
|
require('@dynamic-labs/wallet-book');
|
|
15
15
|
require('@dynamic-labs/utils');
|
|
@@ -47,7 +47,7 @@ require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
|
47
47
|
var Captcha = require('../../components/Captcha/Captcha.cjs');
|
|
48
48
|
|
|
49
49
|
const CaptchaVerifyUser = () => {
|
|
50
|
-
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
|
+
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
51
|
const { setView } = ViewContext.useViewContext();
|
|
52
52
|
const { setCaptchaToken } = CaptchaContext.useCaptchaContext();
|
|
53
53
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
@@ -65,7 +65,13 @@ const CaptchaVerifyUser = () => {
|
|
|
65
65
|
if (!publicWalletAddress) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
if (!walletConnectorCore.isEmbeddedConnector(walletConnector) ||
|
|
69
|
+
walletConnectorCore.isBloctoConnector(walletConnector)) {
|
|
70
|
+
setView('pending-signature');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
74
|
+
}
|
|
69
75
|
if (requiresTwoStepAuthentication.requiresTwoStepAuthentication(walletConnector)) {
|
|
70
76
|
setCaptchaToken(captchaToken);
|
|
71
77
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { CaptchaWaveIcon } from '@dynamic-labs/iconic';
|
|
4
|
+
import { isEmbeddedConnector, isBloctoConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
import 'react';
|
|
5
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
7
8
|
import '../../shared/logger.js';
|
|
8
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
10
10
|
import '@dynamic-labs/wallet-book';
|
|
11
11
|
import '@dynamic-labs/utils';
|
|
@@ -43,7 +43,7 @@ import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
|
43
43
|
import { Captcha } from '../../components/Captcha/Captcha.js';
|
|
44
44
|
|
|
45
45
|
const CaptchaVerifyUser = () => {
|
|
46
|
-
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, } = useInternalDynamicContext();
|
|
46
|
+
const { consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, selectedWalletConnector: walletConnector, walletUiUtils, } = useInternalDynamicContext();
|
|
47
47
|
const { setView } = useViewContext();
|
|
48
48
|
const { setCaptchaToken } = useCaptchaContext();
|
|
49
49
|
const verifyWallet = useVerifyWallet({
|
|
@@ -61,7 +61,13 @@ const CaptchaVerifyUser = () => {
|
|
|
61
61
|
if (!publicWalletAddress) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
if (!isEmbeddedConnector(walletConnector) ||
|
|
65
|
+
isBloctoConnector(walletConnector)) {
|
|
66
|
+
setView('pending-signature');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
70
|
+
}
|
|
65
71
|
if (requiresTwoStepAuthentication(walletConnector)) {
|
|
66
72
|
setCaptchaToken(captchaToken);
|
|
67
73
|
return;
|
|
@@ -41,6 +41,7 @@ require('../../../components/Alert/Alert.cjs');
|
|
|
41
41
|
require('../../../context/MockContext/MockContext.cjs');
|
|
42
42
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
43
43
|
require('../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
44
|
+
var Tooltip = require('../../../components/Tooltip/Tooltip.cjs');
|
|
44
45
|
require('../../../components/Popper/Popper/Popper.cjs');
|
|
45
46
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
46
47
|
require('yup');
|
|
@@ -63,6 +64,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
63
64
|
else if (name === 'policiesConsent') {
|
|
64
65
|
return (jsxRuntime.jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxRuntime.jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsxRuntime.jsx(formik.Field, { as: Checkbox.Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsxRuntime.jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
|
|
65
66
|
}
|
|
67
|
+
else if (name === 'email' && !enabled) {
|
|
68
|
+
return (jsxRuntime.jsx(Tooltip.Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsxRuntime.jsx(formik.Field, { disabled: true, as: Input.Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
|
|
69
|
+
}
|
|
66
70
|
else {
|
|
67
71
|
return (jsxRuntime.jsx(formik.Field, { disabled: !enabled, as: Input.Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage.getDisplayErrorMessage(label, errors[name]) }, name));
|
|
68
72
|
}
|
|
@@ -37,6 +37,7 @@ import '../../../components/Alert/Alert.js';
|
|
|
37
37
|
import '../../../context/MockContext/MockContext.js';
|
|
38
38
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
39
39
|
import '../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
40
|
+
import { Tooltip } from '../../../components/Tooltip/Tooltip.js';
|
|
40
41
|
import '../../../components/Popper/Popper/Popper.js';
|
|
41
42
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
42
43
|
import 'yup';
|
|
@@ -59,6 +60,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
|
|
|
59
60
|
else if (name === 'policiesConsent') {
|
|
60
61
|
return (jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsx(Field, { as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsx(Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
|
|
61
62
|
}
|
|
63
|
+
else if (name === 'email' && !enabled) {
|
|
64
|
+
return (jsx(Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsx(Field, { disabled: true, as: Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
|
|
65
|
+
}
|
|
62
66
|
else {
|
|
63
67
|
return (jsx(Field, { disabled: !enabled, as: Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage(label, errors[name]) }, name));
|
|
64
68
|
}
|
|
@@ -55,12 +55,15 @@ const EmailUpdate = () => {
|
|
|
55
55
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
56
56
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
57
57
|
const { email, setEmail, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
58
|
-
const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
|
|
58
|
+
const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext.useInternalDynamicContext();
|
|
59
59
|
const [emailError, setEmailError] = React.useState(undefined);
|
|
60
60
|
const handleBackClick = () => {
|
|
61
61
|
setView('verify-email');
|
|
62
62
|
setError(undefined);
|
|
63
63
|
};
|
|
64
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
65
|
+
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
66
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
64
67
|
const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
68
|
try {
|
|
66
69
|
if (!updatedEmail) {
|
|
@@ -68,7 +71,7 @@ const EmailUpdate = () => {
|
|
|
68
71
|
}
|
|
69
72
|
setEmailError(undefined);
|
|
70
73
|
setLoading(true);
|
|
71
|
-
const { emailVerification } = yield api.updateUserProfileFields(
|
|
74
|
+
const { emailVerification } = yield api.updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
72
75
|
if (!emailVerification) {
|
|
73
76
|
yield handleLogOut();
|
|
74
77
|
goToInitialView();
|
|
@@ -51,12 +51,15 @@ const EmailUpdate = () => {
|
|
|
51
51
|
const { loading, setLoading } = useLoadingContext();
|
|
52
52
|
const { setView, goToInitialView } = useViewContext();
|
|
53
53
|
const { email, setEmail, setVerificationUUID } = useEmailVerificationContext();
|
|
54
|
-
const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
54
|
+
const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext();
|
|
55
55
|
const [emailError, setEmailError] = useState(undefined);
|
|
56
56
|
const handleBackClick = () => {
|
|
57
57
|
setView('verify-email');
|
|
58
58
|
setError(undefined);
|
|
59
59
|
};
|
|
60
|
+
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
61
|
+
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
62
|
+
const jwtToken = authToken || onboardingOnlyJwt;
|
|
60
63
|
const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
64
|
try {
|
|
62
65
|
if (!updatedEmail) {
|
|
@@ -64,7 +67,7 @@ const EmailUpdate = () => {
|
|
|
64
67
|
}
|
|
65
68
|
setEmailError(undefined);
|
|
66
69
|
setLoading(true);
|
|
67
|
-
const { emailVerification } = yield updateUserProfileFields(
|
|
70
|
+
const { emailVerification } = yield updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
68
71
|
if (!emailVerification) {
|
|
69
72
|
yield handleLogOut();
|
|
70
73
|
goToInitialView();
|
|
@@ -69,7 +69,7 @@ const EmailVerification = () => {
|
|
|
69
69
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
70
70
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
71
71
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
72
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
72
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
73
73
|
const { email, verificationUUID, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
74
74
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
75
75
|
const { remainingSeconds, startCountdown } = useCountdown.useCountdown({
|
|
@@ -79,6 +79,11 @@ const EmailVerification = () => {
|
|
|
79
79
|
const isLoginView = view === 'login-with-email-verification';
|
|
80
80
|
const { verifyEmail } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
81
81
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
|
|
82
|
+
// Set verification in progress
|
|
83
|
+
// It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
setIsVerificationInProgress(true);
|
|
86
|
+
}, []);
|
|
82
87
|
const handleComplete = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
83
88
|
setError(undefined);
|
|
84
89
|
setLoading(true);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { useState, useCallback } from 'react';
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
4
|
import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
|
|
5
5
|
import { UserHasAccountWithEmailError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
6
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
@@ -65,7 +65,7 @@ const EmailVerification = () => {
|
|
|
65
65
|
const { view, setView, goToInitialView } = useViewContext();
|
|
66
66
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
67
67
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
68
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
|
|
68
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext();
|
|
69
69
|
const { email, verificationUUID, setVerificationUUID } = useEmailVerificationContext();
|
|
70
70
|
const { loading, setLoading } = useLoadingContext();
|
|
71
71
|
const { remainingSeconds, startCountdown } = useCountdown({
|
|
@@ -75,6 +75,11 @@ const EmailVerification = () => {
|
|
|
75
75
|
const isLoginView = view === 'login-with-email-verification';
|
|
76
76
|
const { verifyEmail } = useEmailVerificationRequest();
|
|
77
77
|
const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
|
|
78
|
+
// Set verification in progress
|
|
79
|
+
// It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
setIsVerificationInProgress(true);
|
|
82
|
+
}, []);
|
|
78
83
|
const handleComplete = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
84
|
setError(undefined);
|
|
80
85
|
setLoading(true);
|
|
@@ -65,7 +65,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
65
65
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
66
66
|
onFailure: (error) => setError(error),
|
|
67
67
|
});
|
|
68
|
-
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
68
|
+
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'By signing in, you will access a wallet that is only associated to this email.' }));
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
|
|
@@ -61,7 +61,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
61
61
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
62
62
|
onFailure: (error) => setError(error),
|
|
63
63
|
});
|
|
64
|
-
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
|
|
64
|
+
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true, successBannerText: 'By signing in, you will access a wallet that is only associated to this email.' }));
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export { EmailWalletOTPVerificationView };
|
|
@@ -26,7 +26,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
|
|
|
26
26
|
const { setView } = ViewContext.useViewContext();
|
|
27
27
|
const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
28
28
|
const isUsingMultiWallet = Boolean(localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_USER));
|
|
29
|
-
return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) =>
|
|
29
|
+
return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
32
|
+
}), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
exports.LoginWithEmailWalletList = LoginWithEmailWalletList;
|
|
@@ -22,7 +22,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
|
|
|
22
22
|
const { setView } = useViewContext();
|
|
23
23
|
const { projectSettings } = useInternalDynamicContext();
|
|
24
24
|
const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
|
|
25
|
-
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) =>
|
|
25
|
+
return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
|
|
28
|
+
}), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
export { LoginWithEmailWalletList, NUMBER_OF_WALLETS };
|
|
@@ -57,6 +57,7 @@ const NetworkNotSupported = () => {
|
|
|
57
57
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
58
58
|
const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
59
59
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
60
|
+
shouldCallCallback: false,
|
|
60
61
|
shouldUpdateWallets: !isFullyConnected,
|
|
61
62
|
});
|
|
62
63
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
|
|
@@ -53,6 +53,7 @@ const NetworkNotSupported = () => {
|
|
|
53
53
|
// Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
|
|
54
54
|
const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
|
|
55
55
|
const finishConnectAndSign = useConnectAndSign({
|
|
56
|
+
shouldCallCallback: false,
|
|
56
57
|
shouldUpdateWallets: !isFullyConnected,
|
|
57
58
|
});
|
|
58
59
|
const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
|
|
@@ -60,6 +60,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
60
60
|
deps: [walletConnector, connectedWallets],
|
|
61
61
|
});
|
|
62
62
|
const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
|
|
63
|
+
shouldCallCallback: false,
|
|
63
64
|
shouldUpdateWallets: !isFullyConnected,
|
|
64
65
|
});
|
|
65
66
|
// Finishes auth flow when wallet switches to proper network
|
|
@@ -56,6 +56,7 @@ const NetworkNotSupportedSwitchManual = () => {
|
|
|
56
56
|
deps: [walletConnector, connectedWallets],
|
|
57
57
|
});
|
|
58
58
|
const finishConnectAndSign = useConnectAndSign({
|
|
59
|
+
shouldCallCallback: false,
|
|
59
60
|
shouldUpdateWallets: !isFullyConnected,
|
|
60
61
|
});
|
|
61
62
|
// Finishes auth flow when wallet switches to proper network
|