@dynamic-labs/sdk-react-core 0.17.26 → 0.17.28
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 +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -4
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -4
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +3 -3
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +3 -3
- 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/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.js +2 -2
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +41 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +37 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +21 -5
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +8 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +21 -5
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +20 -19
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +4 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +20 -19
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +3 -3
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +3 -3
- package/src/lib/utils/hooks/useWallets/useWallets.js +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +10 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +10 -3
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +9 -16
- package/src/lib/views/SendBalanceView/SendBalanceView.js +9 -16
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +63 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +59 -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/TransactionConfirmationView/TransactionConfirmationView.cjs +2 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +2 -2
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +21 -8
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +4 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +21 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.17.28](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.27...v0.17.28) (2023-07-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **transaction:** add gas price to transaction on magic ([#2747](https://github.com/dynamic-labs/DynamicAuth/issues/2747)) ([62750be](https://github.com/dynamic-labs/DynamicAuth/commit/62750be5f4ea9f476ac286bb6770a5ce0cf276b7))
|
|
8
|
+
|
|
9
|
+
### [0.17.27](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.26...v0.17.27) (2023-07-26)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* do not proceed to authSuccess if there are still missing fields ([#2726](https://github.com/dynamic-labs/DynamicAuth/issues/2726)) ([e5b8139](https://github.com/dynamic-labs/DynamicAuth/commit/e5b8139bedbcc82f6f42251c5877a97955d90564)), closes [#2740](https://github.com/dynamic-labs/DynamicAuth/issues/2740)
|
|
15
|
+
* WalletConnect bug on fresh session with high latency ([#2669](https://github.com/dynamic-labs/DynamicAuth/issues/2669)) ([0fcb9c9](https://github.com/dynamic-labs/DynamicAuth/commit/0fcb9c969d39dad856ae76b2bdd02368c6c8d64a))
|
|
16
|
+
|
|
2
17
|
### [0.17.26](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.25...v0.17.26) (2023-07-25)
|
|
3
18
|
|
|
4
19
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.28",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
18
|
"ethers": "5.7.2",
|
|
19
|
-
"@dynamic-labs/logger": "0.17.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.17.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.17.
|
|
22
|
-
"@dynamic-labs/types": "0.17.
|
|
23
|
-
"@dynamic-labs/utils": "0.17.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.17.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.17.
|
|
19
|
+
"@dynamic-labs/logger": "0.17.28",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.17.28",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.17.28",
|
|
22
|
+
"@dynamic-labs/types": "0.17.28",
|
|
23
|
+
"@dynamic-labs/utils": "0.17.28",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.17.28",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.17.28"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"semver": "7.3.8"
|
|
@@ -51,7 +51,7 @@ var TransactionRow = require('../TransactionConfirmationPageLayout/components/Tr
|
|
|
51
51
|
|
|
52
52
|
const TransactionStatusLayout = ({ destinationAddress, amount, networkName, networkCurrency, NetworkIcon, onDone, displayPoweredByDynamicFooter = true, onClickClose, }) => {
|
|
53
53
|
const closeButton = onClickClose && (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ type: 'button', onClick: onClickClose, "data-testid": 'close' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })));
|
|
54
|
-
const networkIcon = (jsxRuntime.jsx("
|
|
54
|
+
const networkIcon = (jsxRuntime.jsx("span", Object.assign({ className: 'transaction-status-layout__network-icon' }, { children: NetworkIcon })));
|
|
55
55
|
return (jsxRuntime.jsxs("div", Object.assign({ className: 'transaction-status-layout' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton, alignContent: 'bottom' }, { children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'transaction-status-layout__status-icon', iconSize: 50, Icon: signCircle.ReactComponent, InnerIcon: check.ReactComponent }) })), jsxRuntime.jsxs("div", Object.assign({ className: 'transaction-status-layout__body' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', color: 'primary', className: 'transaction-status-layout__title' }, { children: "Transaction successfully sent" })), jsxRuntime.jsx("div", Object.assign({ className: 'transaction-status-layout__content' }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'transaction-status-layout__rows' }, { children: [jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Recipient' }, { children: shortenWalletAddress.shortenWalletAddress(destinationAddress, 3, 3) })), jsxRuntime.jsxs(TransactionRow.TransactionRow, Object.assign({ label: 'Network' }, { children: [networkIcon, jsxRuntime.jsx("span", Object.assign({ className: 'transaction-status-layout__network-name' }, { children: networkName }))] })), jsxRuntime.jsxs(TransactionRow.TransactionRow, Object.assign({ label: 'Total amount' }, { children: [amount, jsxRuntime.jsx(Typography.Typography, Object.assign({ as: 'span', color: 'secondary', className: 'transaction-status-layout__network-currency' }, { children: networkCurrency }))] }))] })) })), jsxRuntime.jsx("div", Object.assign({ className: 'transaction-status-layout__actions' }, { children: jsxRuntime.jsx(Button.Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'large', expanded: true, buttonRounded: 'default', onClick: onDone }, { children: "Continue" })) })), displayPoweredByDynamicFooter && (jsxRuntime.jsx("div", Object.assign({ className: 'transaction-status-layout__footer' }, { children: jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, {}) })))] }))] })));
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -47,7 +47,7 @@ import { TransactionRow } from '../TransactionConfirmationPageLayout/components/
|
|
|
47
47
|
|
|
48
48
|
const TransactionStatusLayout = ({ destinationAddress, amount, networkName, networkCurrency, NetworkIcon, onDone, displayPoweredByDynamicFooter = true, onClickClose, }) => {
|
|
49
49
|
const closeButton = onClickClose && (jsx(IconButton, Object.assign({ type: 'button', onClick: onClickClose, "data-testid": 'close' }, { children: jsx(SvgClose, {}) })));
|
|
50
|
-
const networkIcon = (jsx("
|
|
50
|
+
const networkIcon = (jsx("span", Object.assign({ className: 'transaction-status-layout__network-icon' }, { children: NetworkIcon })));
|
|
51
51
|
return (jsxs("div", Object.assign({ className: 'transaction-status-layout' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton, alignContent: 'bottom' }, { children: jsx(IconWithStatus, { containerClassName: 'transaction-status-layout__status-icon', iconSize: 50, Icon: SvgSignCircle, InnerIcon: SvgCheck }) })), jsxs("div", Object.assign({ className: 'transaction-status-layout__body' }, { children: [jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', color: 'primary', className: 'transaction-status-layout__title' }, { children: "Transaction successfully sent" })), jsx("div", Object.assign({ className: 'transaction-status-layout__content' }, { children: jsxs("div", Object.assign({ className: 'transaction-status-layout__rows' }, { children: [jsx(TransactionRow, Object.assign({ label: 'Recipient' }, { children: shortenWalletAddress(destinationAddress, 3, 3) })), jsxs(TransactionRow, Object.assign({ label: 'Network' }, { children: [networkIcon, jsx("span", Object.assign({ className: 'transaction-status-layout__network-name' }, { children: networkName }))] })), jsxs(TransactionRow, Object.assign({ label: 'Total amount' }, { children: [amount, jsx(Typography, Object.assign({ as: 'span', color: 'secondary', className: 'transaction-status-layout__network-currency' }, { children: networkCurrency }))] }))] })) })), jsx("div", Object.assign({ className: 'transaction-status-layout__actions' }, { children: jsx(Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'large', expanded: true, buttonRounded: 'default', onClick: onDone }, { children: "Continue" })) })), displayPoweredByDynamicFooter && (jsx("div", Object.assign({ className: 'transaction-status-layout__footer' }, { children: jsx(PoweredByDynamic, {}) })))] }))] })));
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -128,7 +128,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
128
128
|
appName = displayName || appName;
|
|
129
129
|
const [loginWithEmail, setLogInWithEmail] = useEmailLoginState.useEmailLoginState((projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [], user);
|
|
130
130
|
const [authorizationViewDisplayOrder, setAuthorizationViewDisplayOrder] = useDisplayOrderState.useDisplayOrderState(projectSettings);
|
|
131
|
-
const [confirmationModal,
|
|
131
|
+
const [confirmationModal, createWalletUiUtils, { disableConfirmationOnce }] = useWalletUiUtils.useWalletUiUtils({
|
|
132
132
|
appLogoUrl,
|
|
133
133
|
appName,
|
|
134
134
|
getAppOrigin: () => window.location.origin,
|
|
@@ -136,12 +136,12 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
136
136
|
const { wallets } = useWallets.useWallets({
|
|
137
137
|
appLogoUrl,
|
|
138
138
|
appName,
|
|
139
|
+
createWalletUiUtils,
|
|
139
140
|
flowNetwork,
|
|
140
141
|
networkConfigurations: serverNetworkConfigurations,
|
|
141
142
|
projectSettings,
|
|
142
143
|
walletConnectV1Bridge,
|
|
143
144
|
walletConnectorsProp,
|
|
144
|
-
walletUiUtils,
|
|
145
145
|
});
|
|
146
146
|
const [authMode, setAuthMode] = useLocalStorage.useLocalStorage(localStorage$1.AUTH_MODE, initialAuthenticationMode);
|
|
147
147
|
const { connectWallet, removeConnectedInfo, connectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet.useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
@@ -354,6 +354,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
354
354
|
decodedOnboardingOnlyToken: decodeJwt.decodeJwt(onboardingOnlyJwt),
|
|
355
355
|
defaultNumberOfWalletsToShow,
|
|
356
356
|
desktopUri,
|
|
357
|
+
disableWalletConfirmationOnce: disableConfirmationOnce,
|
|
357
358
|
displayTermsOfService,
|
|
358
359
|
environmentId,
|
|
359
360
|
eventsCallbacks,
|
|
@@ -423,7 +424,6 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
423
424
|
toolkitEnabled,
|
|
424
425
|
user,
|
|
425
426
|
walletConnector: (_b = walletForUserFacingContext === null || walletForUserFacingContext === void 0 ? void 0 : walletForUserFacingContext.connector) !== null && _b !== void 0 ? _b : null,
|
|
426
|
-
walletUiUtils,
|
|
427
427
|
wallets,
|
|
428
428
|
walletsFilter,
|
|
429
429
|
});
|
|
@@ -506,7 +506,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
506
506
|
theme,
|
|
507
507
|
toolkitEnabled,
|
|
508
508
|
user,
|
|
509
|
-
|
|
509
|
+
disableConfirmationOnce,
|
|
510
510
|
wallets,
|
|
511
511
|
walletsFilter,
|
|
512
512
|
]);
|
|
@@ -2,7 +2,7 @@ import { Dispatch, SetStateAction, ReactNode } from 'react';
|
|
|
2
2
|
import { WalletConnector, FetchPublicAddressOpts, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { DynamicJwt, NameServiceData, ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
4
4
|
import { LogLevel } from '@dynamic-labs/logger';
|
|
5
|
-
import { EvmNetwork, NetworkConfigurationMap
|
|
5
|
+
import { EvmNetwork, NetworkConfigurationMap } from '@dynamic-labs/types';
|
|
6
6
|
import { WalletOption, UserProfile, Wallet, MultiWalletWidgetState, AccountSwitchState, AwaitingSignatureState, ChainToWalletMap, AuthModeType, DynamicRPCProviders, DynamicEventsCallbacks, WalletWithAction, AccessDeniedCustomButton } from '../../shared';
|
|
7
7
|
import { ThemeData, ThemeSetting } from '../ThemeContext';
|
|
8
8
|
import { MultiWalletWidgetStateSetter } from '../../utils/hooks/multiWallet';
|
|
@@ -108,7 +108,7 @@ export interface IDynamicContext {
|
|
|
108
108
|
toolkitEnabled?: boolean;
|
|
109
109
|
user: UserProfile | undefined;
|
|
110
110
|
walletConnector: WalletConnector | null;
|
|
111
|
-
|
|
111
|
+
disableWalletConfirmationOnce: () => void;
|
|
112
112
|
wallets: WalletOption[];
|
|
113
113
|
walletsFilter?: (options: WalletOption[]) => WalletOption[];
|
|
114
114
|
}
|
|
@@ -124,7 +124,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
124
124
|
appName = displayName || appName;
|
|
125
125
|
const [loginWithEmail, setLogInWithEmail] = useEmailLoginState((projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) || [], user);
|
|
126
126
|
const [authorizationViewDisplayOrder, setAuthorizationViewDisplayOrder] = useDisplayOrderState(projectSettings);
|
|
127
|
-
const [confirmationModal,
|
|
127
|
+
const [confirmationModal, createWalletUiUtils, { disableConfirmationOnce }] = useWalletUiUtils({
|
|
128
128
|
appLogoUrl,
|
|
129
129
|
appName,
|
|
130
130
|
getAppOrigin: () => window.location.origin,
|
|
@@ -132,12 +132,12 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
132
132
|
const { wallets } = useWallets({
|
|
133
133
|
appLogoUrl,
|
|
134
134
|
appName,
|
|
135
|
+
createWalletUiUtils,
|
|
135
136
|
flowNetwork,
|
|
136
137
|
networkConfigurations: serverNetworkConfigurations,
|
|
137
138
|
projectSettings,
|
|
138
139
|
walletConnectV1Bridge,
|
|
139
140
|
walletConnectorsProp,
|
|
140
|
-
walletUiUtils,
|
|
141
141
|
});
|
|
142
142
|
const [authMode, setAuthMode] = useLocalStorage(AUTH_MODE, initialAuthenticationMode);
|
|
143
143
|
const { connectWallet, removeConnectedInfo, connectedInfo, connectedWallet, setConnectedWallet, connectWalletByAddressAndChain, } = useConnectWallet(wallets, authMode, environmentId, enableVisitTrackingOnConnectOnly);
|
|
@@ -350,6 +350,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
350
350
|
decodedOnboardingOnlyToken: decodeJwt(onboardingOnlyJwt),
|
|
351
351
|
defaultNumberOfWalletsToShow,
|
|
352
352
|
desktopUri,
|
|
353
|
+
disableWalletConfirmationOnce: disableConfirmationOnce,
|
|
353
354
|
displayTermsOfService,
|
|
354
355
|
environmentId,
|
|
355
356
|
eventsCallbacks,
|
|
@@ -419,7 +420,6 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
419
420
|
toolkitEnabled,
|
|
420
421
|
user,
|
|
421
422
|
walletConnector: (_b = walletForUserFacingContext === null || walletForUserFacingContext === void 0 ? void 0 : walletForUserFacingContext.connector) !== null && _b !== void 0 ? _b : null,
|
|
422
|
-
walletUiUtils,
|
|
423
423
|
wallets,
|
|
424
424
|
walletsFilter,
|
|
425
425
|
});
|
|
@@ -502,7 +502,7 @@ const DynamicContextProvider = ({ settings: { accessDeniedMessagePrimary, access
|
|
|
502
502
|
theme,
|
|
503
503
|
toolkitEnabled,
|
|
504
504
|
user,
|
|
505
|
-
|
|
505
|
+
disableConfirmationOnce,
|
|
506
506
|
wallets,
|
|
507
507
|
walletsFilter,
|
|
508
508
|
]);
|
|
@@ -44,7 +44,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
44
44
|
const SocialRedirectContext = React.createContext(undefined);
|
|
45
45
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
46
46
|
var _a, _b;
|
|
47
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector,
|
|
47
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, disableWalletConfirmationOnce, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
48
48
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
49
49
|
const { setView } = ViewContext.useViewContext();
|
|
50
50
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
@@ -138,7 +138,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
138
138
|
}
|
|
139
139
|
else {
|
|
140
140
|
const address = yield socialWalletConnector.fetchPublicAddress();
|
|
141
|
-
|
|
141
|
+
disableWalletConfirmationOnce();
|
|
142
142
|
yield verifyWallet({
|
|
143
143
|
oauth: {
|
|
144
144
|
accessToken: session.accessToken,
|
|
@@ -176,7 +176,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
176
176
|
setView,
|
|
177
177
|
socialWalletConnector,
|
|
178
178
|
verifyWallet,
|
|
179
|
-
|
|
179
|
+
disableWalletConfirmationOnce,
|
|
180
180
|
wallet,
|
|
181
181
|
handleError,
|
|
182
182
|
]);
|
|
@@ -40,7 +40,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
40
40
|
const SocialRedirectContext = createContext(undefined);
|
|
41
41
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
42
42
|
var _a, _b;
|
|
43
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector,
|
|
43
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, disableWalletConfirmationOnce, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext();
|
|
44
44
|
const { setErrorMessage } = useErrorContext();
|
|
45
45
|
const { setView } = useViewContext();
|
|
46
46
|
const verifyWallet = useVerifyWallet({
|
|
@@ -134,7 +134,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
136
|
const address = yield socialWalletConnector.fetchPublicAddress();
|
|
137
|
-
|
|
137
|
+
disableWalletConfirmationOnce();
|
|
138
138
|
yield verifyWallet({
|
|
139
139
|
oauth: {
|
|
140
140
|
accessToken: session.accessToken,
|
|
@@ -172,7 +172,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
172
172
|
setView,
|
|
173
173
|
socialWalletConnector,
|
|
174
174
|
verifyWallet,
|
|
175
|
-
|
|
175
|
+
disableWalletConfirmationOnce,
|
|
176
176
|
wallet,
|
|
177
177
|
handleError,
|
|
178
178
|
]);
|
|
@@ -17,6 +17,7 @@ var usePreventPageScroll = require('../../shared/utils/hooks/usePreventPageScrol
|
|
|
17
17
|
var index = require('../../shared/consts/index.cjs');
|
|
18
18
|
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
19
19
|
require('@dynamic-labs/multi-wallet');
|
|
20
|
+
var isMagicConnector = require('../../utils/functions/isMagicConnector/isMagicConnector.cjs');
|
|
20
21
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
21
22
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
22
23
|
var Portal = require('../../components/Portal/Portal.cjs');
|
|
@@ -35,6 +36,7 @@ require('../../components/Alert/Alert.cjs');
|
|
|
35
36
|
require('../../context/MockContext/MockContext.cjs');
|
|
36
37
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
37
38
|
require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
39
|
+
var useTransactionWithGasPrice = require('../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
|
|
38
40
|
require('../../components/Popper/Popper/Popper.cjs');
|
|
39
41
|
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
40
42
|
require('formik');
|
|
@@ -43,11 +45,17 @@ var Modal = require('../../components/Modal/Modal.cjs');
|
|
|
43
45
|
var ModalCard = require('../../components/ModalCard/ModalCard.cjs');
|
|
44
46
|
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
45
47
|
|
|
46
|
-
const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionResponseSuccess, transaction, provider, }) => {
|
|
48
|
+
const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionResponseSuccess, transaction, provider, walletConnector, }) => {
|
|
47
49
|
usePreventPageScroll.usePreventPageScroll(true);
|
|
48
50
|
const [show, setShow] = React.useState(true);
|
|
49
51
|
const errorRef = React.useRef(null);
|
|
50
52
|
const transactionResponseRef = React.useRef(null);
|
|
53
|
+
const transactionWithGasPrice = useTransactionWithGasPrice.useTransactionWithGasPrice({
|
|
54
|
+
enabled: isMagicConnector.isMagicConnector(walletConnector),
|
|
55
|
+
increasePercentage: 5,
|
|
56
|
+
provider,
|
|
57
|
+
transaction,
|
|
58
|
+
});
|
|
51
59
|
const closeModal = React.useCallback(() => {
|
|
52
60
|
setShow(false);
|
|
53
61
|
}, [setShow]);
|
|
@@ -59,7 +67,7 @@ const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionR
|
|
|
59
67
|
}, [onTransactionResponseSuccess, onReject]);
|
|
60
68
|
return (jsxRuntime.jsx(Portal.Portal, Object.assign({ handleClose: closeModal, isShown: show, zIndex: index.authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-transaction', transitionEvents: {
|
|
61
69
|
onUnmount: handleOnModalUnmount,
|
|
62
|
-
} }, { children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { provider: provider, transaction:
|
|
70
|
+
} }, { children: jsxRuntime.jsx(Modal.Modal, { children: jsxRuntime.jsx(ModalCard.ModalCard, { children: jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, mutation: () => handler(transactionWithGasPrice), onClickClose: closeModal, onError: (error) => (errorRef.current = error), displayPoweredByDynamicFooter: true, onSuccess: (transactionResponse) => {
|
|
63
71
|
errorRef.current = null;
|
|
64
72
|
transactionResponseRef.current = transactionResponse;
|
|
65
73
|
closeModal();
|
|
@@ -13,6 +13,7 @@ import { usePreventPageScroll } from '../../shared/utils/hooks/usePreventPageScr
|
|
|
13
13
|
import { authModalZIndex } from '../../shared/consts/index.js';
|
|
14
14
|
import '../../context/DynamicContext/DynamicContext.js';
|
|
15
15
|
import '@dynamic-labs/multi-wallet';
|
|
16
|
+
import { isMagicConnector } from '../../utils/functions/isMagicConnector/isMagicConnector.js';
|
|
16
17
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
17
18
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
18
19
|
import { Portal } from '../../components/Portal/Portal.js';
|
|
@@ -31,6 +32,7 @@ import '../../components/Alert/Alert.js';
|
|
|
31
32
|
import '../../context/MockContext/MockContext.js';
|
|
32
33
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
33
34
|
import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
35
|
+
import { useTransactionWithGasPrice } from '../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
|
|
34
36
|
import '../../components/Popper/Popper/Popper.js';
|
|
35
37
|
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
36
38
|
import 'formik';
|
|
@@ -39,11 +41,17 @@ import { Modal } from '../../components/Modal/Modal.js';
|
|
|
39
41
|
import { ModalCard } from '../../components/ModalCard/ModalCard.js';
|
|
40
42
|
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
41
43
|
|
|
42
|
-
const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionResponseSuccess, transaction, provider, }) => {
|
|
44
|
+
const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionResponseSuccess, transaction, provider, walletConnector, }) => {
|
|
43
45
|
usePreventPageScroll(true);
|
|
44
46
|
const [show, setShow] = useState(true);
|
|
45
47
|
const errorRef = useRef(null);
|
|
46
48
|
const transactionResponseRef = useRef(null);
|
|
49
|
+
const transactionWithGasPrice = useTransactionWithGasPrice({
|
|
50
|
+
enabled: isMagicConnector(walletConnector),
|
|
51
|
+
increasePercentage: 5,
|
|
52
|
+
provider,
|
|
53
|
+
transaction,
|
|
54
|
+
});
|
|
47
55
|
const closeModal = useCallback(() => {
|
|
48
56
|
setShow(false);
|
|
49
57
|
}, [setShow]);
|
|
@@ -55,7 +63,7 @@ const TransactionConfirmationModal = ({ title, handler, onReject, onTransactionR
|
|
|
55
63
|
}, [onTransactionResponseSuccess, onReject]);
|
|
56
64
|
return (jsx(Portal, Object.assign({ handleClose: closeModal, isShown: show, zIndex: authModalZIndex, withBackdrop: true, elementId: 'dynamic-send-transaction', transitionEvents: {
|
|
57
65
|
onUnmount: handleOnModalUnmount,
|
|
58
|
-
} }, { children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(TransactionConfirmationView, { provider: provider, transaction:
|
|
66
|
+
} }, { children: jsx(Modal, { children: jsx(ModalCard, { children: jsx(TransactionConfirmationView, { provider: provider, transaction: transactionWithGasPrice, title: title, mutation: () => handler(transactionWithGasPrice), onClickClose: closeModal, onError: (error) => (errorRef.current = error), displayPoweredByDynamicFooter: true, onSuccess: (transactionResponse) => {
|
|
59
67
|
errorRef.current = null;
|
|
60
68
|
transactionResponseRef.current = transactionResponse;
|
|
61
69
|
closeModal();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
export type TransactionConfirmationModalProps = {
|
|
4
5
|
handler: (transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>) => Promise<ethers.providers.TransactionResponse>;
|
|
5
6
|
onReject: (error: unknown) => void;
|
|
@@ -7,5 +8,6 @@ export type TransactionConfirmationModalProps = {
|
|
|
7
8
|
provider: ethers.providers.Web3Provider;
|
|
8
9
|
title: ReactNode;
|
|
9
10
|
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
|
|
11
|
+
walletConnector: WalletConnector;
|
|
10
12
|
};
|
|
11
13
|
export type TransactionConfirmationModalComponent = FC<TransactionConfirmationModalProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isMagicConnector } from './isMagicConnector';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const magicEmailOtpWalletConnectorKey = 'magicemailotp';
|
|
6
|
+
const magicSocialWalletConnectorKey = 'magicsocial';
|
|
7
|
+
const isMagicConnector = (connector) => connector.key === magicEmailOtpWalletConnectorKey ||
|
|
8
|
+
connector.key === magicSocialWalletConnectorKey;
|
|
9
|
+
|
|
10
|
+
exports.isMagicConnector = isMagicConnector;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const magicEmailOtpWalletConnectorKey = 'magicemailotp';
|
|
2
|
+
const magicSocialWalletConnectorKey = 'magicsocial';
|
|
3
|
+
const isMagicConnector = (connector) => connector.key === magicEmailOtpWalletConnectorKey ||
|
|
4
|
+
connector.key === magicSocialWalletConnectorKey;
|
|
5
|
+
|
|
6
|
+
export { isMagicConnector };
|
|
@@ -28,7 +28,7 @@ const useConnectAndSign = () => {
|
|
|
28
28
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
29
29
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
30
30
|
const { captchaToken } = CaptchaContext.useCaptchaContext();
|
|
31
|
-
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user,
|
|
31
|
+
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user, disableWalletConfirmationOnce, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
32
32
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
33
33
|
consumeNonce,
|
|
34
34
|
displayTermsOfService,
|
|
@@ -63,7 +63,7 @@ const useConnectAndSign = () => {
|
|
|
63
63
|
setView('pending-signature');
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
|
|
66
|
+
disableWalletConfirmationOnce();
|
|
67
67
|
}
|
|
68
68
|
yield verifyWallet({
|
|
69
69
|
captchaToken,
|
|
@@ -24,7 +24,7 @@ const useConnectAndSign = () => {
|
|
|
24
24
|
const { setView, goToInitialView } = useViewContext();
|
|
25
25
|
const { setErrorMessage } = useErrorContext();
|
|
26
26
|
const { captchaToken } = useCaptchaContext();
|
|
27
|
-
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user,
|
|
27
|
+
const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user, disableWalletConfirmationOnce, setCallback, } = useInternalDynamicContext();
|
|
28
28
|
const verifyWallet = useVerifyWallet({
|
|
29
29
|
consumeNonce,
|
|
30
30
|
displayTermsOfService,
|
|
@@ -59,7 +59,7 @@ const useConnectAndSign = () => {
|
|
|
59
59
|
setView('pending-signature');
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
|
|
62
|
+
disableWalletConfirmationOnce();
|
|
63
63
|
}
|
|
64
64
|
yield verifyWallet({
|
|
65
65
|
captchaToken,
|
|
@@ -24,3 +24,4 @@ export { useColorSchemePreference } from './useColorSchemePreference';
|
|
|
24
24
|
export { useGetSocialIcon } from './useGetSocialIcon';
|
|
25
25
|
export { useIconThemeVariant } from './useIconThemeVariant';
|
|
26
26
|
export type { IconThemeVariant } from './useIconThemeVariant';
|
|
27
|
+
export { useTransactionWithGasPrice } from './useTransactionWithGasPrice';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTransactionWithGasPrice } from './useTransactionWithGasPrice';
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { data: gasPrice } = usePromise.usePromise(() => provider.getGasPrice(), [transaction, provider]);
|
|
36
|
+
if (!enabled || !gasPrice || Boolean(transaction.gasPrice))
|
|
37
|
+
return transaction;
|
|
38
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
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,37 @@
|
|
|
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 { data: gasPrice } = usePromise(() => provider.getGasPrice(), [transaction, provider]);
|
|
32
|
+
if (!enabled || !gasPrice || Boolean(transaction.gasPrice))
|
|
33
|
+
return transaction;
|
|
34
|
+
return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { useTransactionWithGasPrice };
|
|
@@ -11,6 +11,17 @@ var isEmailVerificationRequired = require('../../functions/authenication/isEmail
|
|
|
11
11
|
var EmailVerificationContext = require('../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
12
12
|
var useEmailVerificationRequest = require('../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
|
|
13
13
|
var useUpdateUserProfileByJWTCallback = require('../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
14
|
+
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
15
|
+
require('../../../shared/logger.cjs');
|
|
16
|
+
require('../../../config/LSSuffix.cjs');
|
|
17
|
+
require('@dynamic-labs/iconic');
|
|
18
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
19
|
+
require('react/jsx-runtime');
|
|
20
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
require('@dynamic-labs/utils');
|
|
22
|
+
require('../../constants/colors.cjs');
|
|
23
|
+
require('ethers');
|
|
24
|
+
require('../../../shared/consts/index.cjs');
|
|
14
25
|
|
|
15
26
|
// User Fields Schema without captchaToken and policiesConsent properties
|
|
16
27
|
const userFieldsSchema = yup.object().shape({
|
|
@@ -33,23 +44,27 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
33
44
|
const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
|
|
34
45
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
35
46
|
const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a, _b;
|
|
47
|
+
var _a, _b, _c;
|
|
37
48
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
38
49
|
stripUnknown: validationSchemaStripUnknown,
|
|
39
50
|
});
|
|
40
51
|
const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
|
|
52
|
+
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
53
|
+
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
54
|
+
const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
|
|
41
55
|
const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
|
|
42
56
|
if (!_isEmailVerificationRequired) {
|
|
43
57
|
// If email verification is not needed then we can update the user profile immediately.
|
|
44
58
|
updateUserProfileByJWT(updateUserProfileResponse.jwt);
|
|
45
59
|
return {
|
|
46
|
-
isEmailVerificationRequired:
|
|
60
|
+
isEmailVerificationRequired: false,
|
|
61
|
+
missingFields,
|
|
47
62
|
updateUserProfileResponse,
|
|
48
63
|
};
|
|
49
64
|
}
|
|
50
65
|
// We update EmailContext to use this information in the Email Verification view
|
|
51
|
-
setEmail((
|
|
52
|
-
setVerificationUUID((
|
|
66
|
+
setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
|
|
67
|
+
setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
|
|
53
68
|
// DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
|
|
54
69
|
// VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
|
|
55
70
|
// setEmail and setVerificationUUID in the above lines will are not visible in this promise.
|
|
@@ -58,7 +73,8 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
|
|
|
58
73
|
return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
|
|
59
74
|
};
|
|
60
75
|
return {
|
|
61
|
-
isEmailVerificationRequired:
|
|
76
|
+
isEmailVerificationRequired: true,
|
|
77
|
+
missingFields,
|
|
62
78
|
updateUserProfileResponse,
|
|
63
79
|
verifyEmailFn: scopedVerifyEmailFn,
|
|
64
80
|
};
|