@dynamic-labs/sdk-react-core 0.18.100-viem.0 → 0.18.100-viem.2
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 +38 -1
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/lib/Main.cjs +5 -0
- package/src/lib/Main.js +5 -0
- package/src/lib/components/Button/Button.cjs +10 -7
- package/src/lib/components/Button/Button.js +10 -7
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
- package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
- package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
- package/src/lib/components/ListTile/ListTile.cjs +1 -1
- package/src/lib/components/ListTile/ListTile.js +1 -1
- package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
- 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/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/context/SendBalanceContext/SendBalanceContext.types.d.ts +2 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/data/api.cjs +16 -0
- package/src/lib/data/api.d.ts +1 -0
- package/src/lib/data/api.js +18 -3
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
- package/src/lib/modals/SendBalanceModal/SendBalanceModal.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 +6 -3
- package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
- package/src/lib/shared/assets/double-arrow-right.js +29 -0
- package/src/lib/shared/assets/index.d.ts +1 -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 +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- 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 +2 -1
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -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 +31 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
- package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +27 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +56 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +52 -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 +13 -4
- package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
- package/src/lib/views/EmailVerification/EmailVerification.cjs +12 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +14 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
- 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/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +111 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +107 -0
- package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -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 +14 -35
- package/src/lib/views/SendBalanceView/SendBalanceView.d.ts +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -36
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +73 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +69 -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 +31 -8
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +4 -3
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +32 -9
- 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/useTransactionGas/useTransactionGas.cjs +69 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +65 -0
- 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 +6 -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/viewToComponentMap.cjs +2 -0
- package/src/lib/views/viewToComponentMap.js +2 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +0 -104
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -17
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -100
|
@@ -0,0 +1,56 @@
|
|
|
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 * BigInt(increaseFactor)) / BigInt(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 {PublicClient} props.provider - The provider to use for getting the current gas price.
|
|
18
|
+
* @param {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 {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
|
+
if (transaction.type === 'legacy' ||
|
|
45
|
+
transaction.type === 'eip2930' ||
|
|
46
|
+
transaction.type === undefined ||
|
|
47
|
+
transaction.maxFeePerGas === undefined) {
|
|
48
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
49
|
+
}
|
|
50
|
+
if (transaction.type === 'eip1559') {
|
|
51
|
+
return Object.assign(Object.assign({}, transaction), { maxFeePerGas: increaseGasPrice(gasPrice, increasePercentage) });
|
|
52
|
+
}
|
|
53
|
+
return transaction;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.useTransactionWithGasPrice = useTransactionWithGasPrice;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PublicClient, TransactionRequest } from 'viem';
|
|
2
|
+
type UseTransactionWithGasPriceProps = {
|
|
3
|
+
provider: PublicClient;
|
|
4
|
+
transaction: 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 {PublicClient} props.provider - The provider to use for getting the current gas price.
|
|
15
|
+
* @param {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 {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) => TransactionRequest;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { usePromise } from '../usePromise/usePromise.js';
|
|
2
|
+
|
|
3
|
+
const increaseGasPrice = (gasPrice, increasePercentage) => {
|
|
4
|
+
const increaseFactor = 100 + increasePercentage;
|
|
5
|
+
return (gasPrice * BigInt(increaseFactor)) / BigInt(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 {PublicClient} props.provider - The provider to use for getting the current gas price.
|
|
14
|
+
* @param {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 {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
|
+
if (transaction.type === 'legacy' ||
|
|
41
|
+
transaction.type === 'eip2930' ||
|
|
42
|
+
transaction.type === undefined ||
|
|
43
|
+
transaction.maxFeePerGas === undefined) {
|
|
44
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
45
|
+
}
|
|
46
|
+
if (transaction.type === 'eip1559') {
|
|
47
|
+
return Object.assign(Object.assign({}, transaction), { maxFeePerGas: increaseGasPrice(gasPrice, increasePercentage) });
|
|
48
|
+
}
|
|
49
|
+
return transaction;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
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 }) => _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 })));
|
|
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 }) => __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 })));
|
|
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", { 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", { 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", { htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
|
|
65
66
|
}
|
|
67
|
+
else if (name === 'email' && !enabled) {
|
|
68
|
+
return (jsxRuntime.jsx(Tooltip.Tooltip, { 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", { 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", { className: 'user-data-fields__consent-checkbox', children: [jsx(Field, { as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsx("label", { htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label', children: jsx(Typography, { variant: 'body_small', color: 'secondary', children: component }) })] }, `policiesConsent_${index}`))) }, 'policiesConsentGroup'));
|
|
61
62
|
}
|
|
63
|
+
else if (name === 'email' && !enabled) {
|
|
64
|
+
return (jsx(Tooltip, { 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
|
}
|
|
@@ -6,6 +6,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var iconic = require('@dynamic-labs/iconic');
|
|
9
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
10
|
var Typography = require('../../components/Typography/Typography.cjs');
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
11
12
|
var logger = require('../../shared/logger.cjs');
|
|
@@ -13,7 +14,6 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
13
14
|
var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
|
|
14
15
|
var chevronLeft = require('../../shared/assets/chevron-left.cjs');
|
|
15
16
|
require('@dynamic-labs/wallet-book');
|
|
16
|
-
require('@dynamic-labs/utils');
|
|
17
17
|
require('../../utils/constants/colors.cjs');
|
|
18
18
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('viem');
|
|
@@ -55,18 +55,23 @@ 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
|
+
const [emailError, setEmailError] = React.useState(undefined);
|
|
59
60
|
const handleBackClick = () => {
|
|
60
61
|
setView('verify-email');
|
|
61
62
|
setError(undefined);
|
|
62
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;
|
|
63
67
|
const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
64
68
|
try {
|
|
65
69
|
if (!updatedEmail) {
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
72
|
+
setEmailError(undefined);
|
|
68
73
|
setLoading(true);
|
|
69
|
-
const { emailVerification } = yield api.updateUserProfileFields(
|
|
74
|
+
const { emailVerification } = yield api.updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
70
75
|
if (!emailVerification) {
|
|
71
76
|
yield handleLogOut();
|
|
72
77
|
goToInitialView();
|
|
@@ -79,6 +84,10 @@ const EmailUpdate = () => {
|
|
|
79
84
|
}
|
|
80
85
|
catch (error) {
|
|
81
86
|
logger.logger.debug(error);
|
|
87
|
+
if (error instanceof utils.EmailAlreadyExistsError) {
|
|
88
|
+
setEmailError('Email already exists');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
82
91
|
setErrorMessage(error.code);
|
|
83
92
|
}
|
|
84
93
|
finally {
|
|
@@ -90,7 +99,7 @@ const EmailUpdate = () => {
|
|
|
90
99
|
width: '3.125rem',
|
|
91
100
|
}, className: 'email-update__icon' }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'title', className: 'email-update__title', children: "Update Email" }), jsxRuntime.jsxs("div", { className: 'email-update__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', children: "Your current email address is" }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: email })] }), jsxRuntime.jsx(Input.Input, { id: 'email_field', onChange: (e) => {
|
|
92
101
|
setUpdatedEmail(e.target.value);
|
|
93
|
-
}, type: 'email', label: 'Email address', className: 'email-update__input' }), jsxRuntime.jsx(Button.Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
102
|
+
}, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsxRuntime.jsx(Button.Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
94
103
|
};
|
|
95
104
|
|
|
96
105
|
exports.EmailUpdate = EmailUpdate;
|
|
@@ -2,6 +2,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
|
|
5
|
+
import { EmailAlreadyExistsError } from '@dynamic-labs/utils';
|
|
5
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
7
8
|
import { logger } from '../../shared/logger.js';
|
|
@@ -9,7 +10,6 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
9
10
|
import { useViewContext } from '../../context/ViewContext/ViewContext.js';
|
|
10
11
|
import { ReactComponent as SvgChevronLeft } from '../../shared/assets/chevron-left.js';
|
|
11
12
|
import '@dynamic-labs/wallet-book';
|
|
12
|
-
import '@dynamic-labs/utils';
|
|
13
13
|
import '../../utils/constants/colors.js';
|
|
14
14
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'viem';
|
|
@@ -51,18 +51,23 @@ 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
|
+
const [emailError, setEmailError] = useState(undefined);
|
|
55
56
|
const handleBackClick = () => {
|
|
56
57
|
setView('verify-email');
|
|
57
58
|
setError(undefined);
|
|
58
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;
|
|
59
63
|
const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
64
|
try {
|
|
61
65
|
if (!updatedEmail) {
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
68
|
+
setEmailError(undefined);
|
|
64
69
|
setLoading(true);
|
|
65
|
-
const { emailVerification } = yield updateUserProfileFields(
|
|
70
|
+
const { emailVerification } = yield updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
|
|
66
71
|
if (!emailVerification) {
|
|
67
72
|
yield handleLogOut();
|
|
68
73
|
goToInitialView();
|
|
@@ -75,6 +80,10 @@ const EmailUpdate = () => {
|
|
|
75
80
|
}
|
|
76
81
|
catch (error) {
|
|
77
82
|
logger.debug(error);
|
|
83
|
+
if (error instanceof EmailAlreadyExistsError) {
|
|
84
|
+
setEmailError('Email already exists');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
78
87
|
setErrorMessage(error.code);
|
|
79
88
|
}
|
|
80
89
|
finally {
|
|
@@ -86,7 +95,7 @@ const EmailUpdate = () => {
|
|
|
86
95
|
width: '3.125rem',
|
|
87
96
|
}, className: 'email-update__icon' }), jsx(Typography, { weight: 'medium', variant: 'title', className: 'email-update__title', children: "Update Email" }), jsxs("div", { className: 'email-update__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', children: "Your current email address is" }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: email })] }), jsx(Input, { id: 'email_field', onChange: (e) => {
|
|
88
97
|
setUpdatedEmail(e.target.value);
|
|
89
|
-
}, type: 'email', label: 'Email address', className: 'email-update__input' }), jsx(Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
98
|
+
}, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsx(Button, { buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading, children: "Send Verification Code" })] }));
|
|
90
99
|
};
|
|
91
100
|
|
|
92
101
|
export { EmailUpdate };
|
|
@@ -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);
|
|
@@ -101,6 +106,11 @@ const EmailVerification = () => {
|
|
|
101
106
|
}
|
|
102
107
|
catch (error) {
|
|
103
108
|
logger.logger.debug(error);
|
|
109
|
+
// Handle the case where the user has already an account with the email
|
|
110
|
+
if (error instanceof utils.UserHasAccountWithEmailError) {
|
|
111
|
+
setView('merge-user-accounts');
|
|
112
|
+
return; // Early return to not show the error message
|
|
113
|
+
}
|
|
104
114
|
setErrorMessage(error.code);
|
|
105
115
|
}
|
|
106
116
|
finally {
|
|
@@ -119,6 +129,7 @@ const EmailVerification = () => {
|
|
|
119
129
|
setOnboardingOnlyJwt,
|
|
120
130
|
setCallback,
|
|
121
131
|
setErrorMessage,
|
|
132
|
+
setView,
|
|
122
133
|
]);
|
|
123
134
|
const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
124
135
|
setError(undefined);
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
import { NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
5
|
+
import { UserHasAccountWithEmailError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
6
6
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
7
7
|
import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -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);
|
|
@@ -97,6 +102,11 @@ const EmailVerification = () => {
|
|
|
97
102
|
}
|
|
98
103
|
catch (error) {
|
|
99
104
|
logger.debug(error);
|
|
105
|
+
// Handle the case where the user has already an account with the email
|
|
106
|
+
if (error instanceof UserHasAccountWithEmailError) {
|
|
107
|
+
setView('merge-user-accounts');
|
|
108
|
+
return; // Early return to not show the error message
|
|
109
|
+
}
|
|
100
110
|
setErrorMessage(error.code);
|
|
101
111
|
}
|
|
102
112
|
finally {
|
|
@@ -115,6 +125,7 @@ const EmailVerification = () => {
|
|
|
115
125
|
setOnboardingOnlyJwt,
|
|
116
126
|
setCallback,
|
|
117
127
|
setErrorMessage,
|
|
128
|
+
setView,
|
|
118
129
|
]);
|
|
119
130
|
const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
131
|
setError(undefined);
|
|
@@ -47,7 +47,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
47
47
|
const EmailWalletOTPVerificationView = () => {
|
|
48
48
|
const { setView } = ViewContext.useViewContext();
|
|
49
49
|
const [error, setError] = React.useState();
|
|
50
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
51
51
|
if (!emailWalletConnector ||
|
|
52
52
|
!walletConnectorCore.isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
53
53
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -61,10 +61,11 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
61
61
|
clearStatesOnBackClick();
|
|
62
62
|
setView('login-with-email-or-wallet');
|
|
63
63
|
};
|
|
64
|
+
const handleOnClickClose = () => setShowAuthFlow(false);
|
|
64
65
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
65
66
|
onFailure: (error) => setError(error),
|
|
66
67
|
});
|
|
67
|
-
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), 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 }));
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
|
|
@@ -43,7 +43,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
43
43
|
const EmailWalletOTPVerificationView = () => {
|
|
44
44
|
const { setView } = useViewContext();
|
|
45
45
|
const [error, setError] = useState();
|
|
46
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext();
|
|
46
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext();
|
|
47
47
|
if (!emailWalletConnector ||
|
|
48
48
|
!isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
49
49
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -57,10 +57,11 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
57
57
|
clearStatesOnBackClick();
|
|
58
58
|
setView('login-with-email-or-wallet');
|
|
59
59
|
};
|
|
60
|
+
const handleOnClickClose = () => setShowAuthFlow(false);
|
|
60
61
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
61
62
|
onFailure: (error) => setError(error),
|
|
62
63
|
});
|
|
63
|
-
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), 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 }));
|
|
64
65
|
};
|
|
65
66
|
|
|
66
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", { 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", { 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;
|