@dynamic-labs/sdk-react-core 4.5.3 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/components/UserProfile/UserProfile.cjs +8 -1
- package/src/lib/components/UserProfile/UserProfile.js +8 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +3 -13
- package/src/lib/context/DynamicContext/DynamicContext.js +3 -13
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.cjs +2 -1
- package/src/lib/context/OnrampContext/useEnabledOnrampProviders/useEnabledOnrampProviders.js +2 -1
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +31 -4
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +31 -4
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.cjs +2 -1
- package/src/lib/context/UserFieldEditorContext/UserFieldEditorContext.js +3 -2
- package/src/lib/data/api/api.cjs +3 -4
- package/src/lib/data/api/api.js +3 -4
- package/src/lib/data/api/user/user.cjs +10 -0
- package/src/lib/data/api/user/user.d.ts +1 -0
- package/src/lib/data/api/user/user.js +10 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +1 -1
- package/src/lib/store/internalImplementation/store.cjs +0 -2
- package/src/lib/store/internalImplementation/store.js +0 -2
- package/src/lib/store/state/projectSettings/projectSettings.cjs +15 -3
- package/src/lib/store/state/projectSettings/projectSettings.d.ts +3 -1
- package/src/lib/store/state/projectSettings/projectSettings.js +16 -5
- package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.cjs +6 -6
- package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.d.ts +2 -1
- package/src/lib/utils/functions/isCookieEnabled/isCookieEnabled.js +7 -7
- package/src/lib/utils/functions/storeAuthToken/storeAuthToken.cjs +3 -1
- package/src/lib/utils/functions/storeAuthToken/storeAuthToken.js +3 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.cjs +6 -4
- package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.d.ts +6 -3
- package/src/lib/utils/hooks/useConfirmationModal/useConfirmationModal.js +6 -4
- package/src/lib/utils/hooks/useDeleteUserAccount/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs +119 -0
- package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.d.ts +7 -0
- package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js +115 -0
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +9 -3
- package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +10 -4
- package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.cjs +27 -0
- package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.d.ts +2 -0
- package/src/lib/utils/hooks/useFundWithWallet/utils/FilterWalletsForExternalFunding.js +23 -0
- package/src/lib/utils/hooks/useFundWithWallet/utils/index.d.ts +1 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +7 -4
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +7 -4
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.cjs +2 -2
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.d.ts +3 -1
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.js +2 -2
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +16 -6
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +17 -7
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +2 -0
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +2 -0
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.cjs +1 -1
- package/src/lib/views/Passkey/PasskeyRecovery/AddRecoveryEmail/AddRecoveryEmail.js +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/views/WalletList/WalletList.cjs +1 -1
- package/src/lib/views/WalletList/WalletList.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.cjs +14 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletAddress/ActiveWalletAddress.js +14 -1
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.cjs +25 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/getPromptAmountParams.js +21 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/getPromptAmountParams/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.cjs +5 -23
- package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExternalWalletFunding/useStartExternalWalletFunding.js +5 -23
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.js +1 -1
- package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.cjs +0 -24
- package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.d.ts +0 -3
- package/src/lib/store/internalImplementation/utils/clearExpiredData/clearExpiredData.js +0 -20
- package/src/lib/store/internalImplementation/utils/clearExpiredData/index.d.ts +0 -1
|
@@ -42,6 +42,7 @@ require('../../../../../utils/functions/compareChains/compareChains.cjs');
|
|
|
42
42
|
require('../../../../../context/ThemeContext/ThemeContext.cjs');
|
|
43
43
|
require('../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
44
44
|
require('bs58');
|
|
45
|
+
var usePromise = require('../../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
45
46
|
require('@dynamic-labs/types');
|
|
46
47
|
require('../../../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
47
48
|
require('../../../../../context/LoadingContext/LoadingContext.cjs');
|
|
@@ -91,6 +92,7 @@ require('../../../../../context/ConnectWithOtpContext/constants.cjs');
|
|
|
91
92
|
require('../../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
92
93
|
require('@hcaptcha/react-hcaptcha');
|
|
93
94
|
require('../../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
95
|
+
var useWalletConnectorNetwork = require('../../../../../utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs');
|
|
94
96
|
require('../../../../../store/state/tokenBalances.cjs');
|
|
95
97
|
require('../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
96
98
|
require('../../../../../components/InlineWidget/InlineWidget.cjs');
|
|
@@ -115,9 +117,20 @@ const getNameIfNoIcon = (wallet) => {
|
|
|
115
117
|
const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth = false, isLoading = false, }) => {
|
|
116
118
|
const { showAlert } = PasskeyContext.usePasskeyContext();
|
|
117
119
|
const header = nameServiceName || getNameIfNoIcon(wallet);
|
|
120
|
+
const { network } = useWalletConnectorNetwork.useWalletConnectorNetwork(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
121
|
+
const { data: address } = usePromise.usePromise(() => {
|
|
122
|
+
// COSMOS wallet address changes based on which network is selected
|
|
123
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.connectedChain) === 'COSMOS') {
|
|
124
|
+
return wallet === null || wallet === void 0 ? void 0 : wallet.connector.getAddress();
|
|
125
|
+
}
|
|
126
|
+
return wallet === null || wallet === void 0 ? void 0 : wallet.address;
|
|
127
|
+
}, {
|
|
128
|
+
deps: [wallet, network],
|
|
129
|
+
enabled: Boolean(wallet),
|
|
130
|
+
});
|
|
118
131
|
return (jsxRuntime.jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Typography.Typography, { className: fullWidth
|
|
119
132
|
? 'active-wallet-information__handle--full-width'
|
|
120
|
-
: 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', children: header }), jsxRuntime.jsx(Typography.Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress.shortenWalletAddress(
|
|
133
|
+
: 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), jsxRuntime.jsx(Typography.Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress.shortenWalletAddress(address, 4, 4)) })] }), jsxRuntime.jsx(DotsMenu.DotsMenu, { "data-testid": 'dots-menu', options: menuOption, buttonClassName: 'active-wallet-information__dots-menu', buttonClassNameWithOpenMenu: 'active-wallet-information__dots-menu', iconOverride: showAlert() ? (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { Icon: () => jsxRuntime.jsx(gear.ReactComponent, { width: 16, height: 16 }), variant: 'yellow' })) : (jsxRuntime.jsx(gear.ReactComponent, { width: 16, height: 16 })) })] }));
|
|
121
134
|
};
|
|
122
135
|
|
|
123
136
|
exports.ActiveWalletAddress = ActiveWalletAddress;
|
|
@@ -38,6 +38,7 @@ import '../../../../../utils/functions/compareChains/compareChains.js';
|
|
|
38
38
|
import '../../../../../context/ThemeContext/ThemeContext.js';
|
|
39
39
|
import '../../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
40
40
|
import 'bs58';
|
|
41
|
+
import { usePromise } from '../../../../../utils/hooks/usePromise/usePromise.js';
|
|
41
42
|
import '@dynamic-labs/types';
|
|
42
43
|
import '../../../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
43
44
|
import '../../../../../context/LoadingContext/LoadingContext.js';
|
|
@@ -87,6 +88,7 @@ import '../../../../../context/ConnectWithOtpContext/constants.js';
|
|
|
87
88
|
import '../../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
88
89
|
import '@hcaptcha/react-hcaptcha';
|
|
89
90
|
import '../../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
91
|
+
import { useWalletConnectorNetwork } from '../../../../../utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js';
|
|
90
92
|
import '../../../../../store/state/tokenBalances.js';
|
|
91
93
|
import '../../../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
92
94
|
import '../../../../../components/InlineWidget/InlineWidget.js';
|
|
@@ -111,9 +113,20 @@ const getNameIfNoIcon = (wallet) => {
|
|
|
111
113
|
const ActiveWalletAddress = ({ wallet, nameServiceName, menuOption, fullWidth = false, isLoading = false, }) => {
|
|
112
114
|
const { showAlert } = usePasskeyContext();
|
|
113
115
|
const header = nameServiceName || getNameIfNoIcon(wallet);
|
|
116
|
+
const { network } = useWalletConnectorNetwork(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
117
|
+
const { data: address } = usePromise(() => {
|
|
118
|
+
// COSMOS wallet address changes based on which network is selected
|
|
119
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.connector.connectedChain) === 'COSMOS') {
|
|
120
|
+
return wallet === null || wallet === void 0 ? void 0 : wallet.connector.getAddress();
|
|
121
|
+
}
|
|
122
|
+
return wallet === null || wallet === void 0 ? void 0 : wallet.address;
|
|
123
|
+
}, {
|
|
124
|
+
deps: [wallet, network],
|
|
125
|
+
enabled: Boolean(wallet),
|
|
126
|
+
});
|
|
114
127
|
return (jsxs("div", { className: 'active-wallet-information__address-container', children: [jsxs("div", { children: [jsx(Typography, { className: fullWidth
|
|
115
128
|
? 'active-wallet-information__handle--full-width'
|
|
116
|
-
: 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', children: header }), jsx(Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsx(Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress(
|
|
129
|
+
: 'active-wallet-information__handle', color: 'primary', variant: 'body_normal', "data-testid": 'header-text', children: header }), jsx(Typography, { className: 'active-wallet-information__address', weight: header ? 'regular' : 'medium', variant: header ? 'body_small' : 'body_normal', color: header ? 'secondary' : 'primary', children: isLoading ? (jsx(Skeleton, { className: 'active-wallet-information__address-skeleton' })) : (shortenWalletAddress(address, 4, 4)) })] }), jsx(DotsMenu, { "data-testid": 'dots-menu', options: menuOption, buttonClassName: 'active-wallet-information__dots-menu', buttonClassNameWithOpenMenu: 'active-wallet-information__dots-menu', iconOverride: showAlert() ? (jsx(IconWithStatus, { Icon: () => jsx(SvgGear, { width: 16, height: 16 }), variant: 'yellow' })) : (jsx(SvgGear, { width: 16, height: 16 })) })] }));
|
|
117
130
|
};
|
|
118
131
|
|
|
119
132
|
export { ActiveWalletAddress, getNameIfNoIcon };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var projectSettings = require('../../../../../../../store/state/projectSettings/projectSettings.cjs');
|
|
8
|
+
|
|
9
|
+
const getPromptAmountParams = ({ externalWallet, }) => {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
|
+
const walletChain = externalWallet.connector.connectedChain;
|
|
12
|
+
const chainSettings = (_e = (_d = (_c = (_b = (_a = projectSettings.getProjectSettings()) === null || _a === void 0 ? void 0 : _a.sdk.funding) === null || _b === void 0 ? void 0 : _b.externalWallets) === null || _c === void 0 ? void 0 : _c.defaultSettings) === null || _d === void 0 ? void 0 : _d.chainSettings) === null || _e === void 0 ? void 0 : _e.find(({ chain }) => chain === walletChain);
|
|
13
|
+
// This is always supposed to be present, otherwise there's some backend error
|
|
14
|
+
if (!((_f = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _f === void 0 ? void 0 : _f.value) || !((_g = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _g === void 0 ? void 0 : _g.rule))
|
|
15
|
+
throw new utils.DynamicError(`No external wallet funding chain settings found for chain ${walletChain}`);
|
|
16
|
+
return {
|
|
17
|
+
externalWallet,
|
|
18
|
+
token: {
|
|
19
|
+
rule: chainSettings.token.rule,
|
|
20
|
+
value: chainSettings.token.value,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.getPromptAmountParams = getPromptAmountParams;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Wallet } from '../../../../../../../shared/types/wallets';
|
|
2
|
+
import { ReceiveExternalWalletFundsProps } from '../../../../ReceiveExternalWalletFunds/types';
|
|
3
|
+
type GetPromptAmountParamsProps = {
|
|
4
|
+
externalWallet: Wallet;
|
|
5
|
+
};
|
|
6
|
+
export declare const getPromptAmountParams: ({ externalWallet, }: GetPromptAmountParamsProps) => ReceiveExternalWalletFundsProps;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
|
+
import { getProjectSettings } from '../../../../../../../store/state/projectSettings/projectSettings.js';
|
|
4
|
+
|
|
5
|
+
const getPromptAmountParams = ({ externalWallet, }) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7
|
+
const walletChain = externalWallet.connector.connectedChain;
|
|
8
|
+
const chainSettings = (_e = (_d = (_c = (_b = (_a = getProjectSettings()) === null || _a === void 0 ? void 0 : _a.sdk.funding) === null || _b === void 0 ? void 0 : _b.externalWallets) === null || _c === void 0 ? void 0 : _c.defaultSettings) === null || _d === void 0 ? void 0 : _d.chainSettings) === null || _e === void 0 ? void 0 : _e.find(({ chain }) => chain === walletChain);
|
|
9
|
+
// This is always supposed to be present, otherwise there's some backend error
|
|
10
|
+
if (!((_f = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _f === void 0 ? void 0 : _f.value) || !((_g = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _g === void 0 ? void 0 : _g.rule))
|
|
11
|
+
throw new DynamicError(`No external wallet funding chain settings found for chain ${walletChain}`);
|
|
12
|
+
return {
|
|
13
|
+
externalWallet,
|
|
14
|
+
token: {
|
|
15
|
+
rule: chainSettings.token.rule,
|
|
16
|
+
value: chainSettings.token.value,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getPromptAmountParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getPromptAmountParams';
|
|
@@ -5,39 +5,21 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var utils = require('@dynamic-labs/utils');
|
|
9
|
-
var projectSettings = require('../../../../../../store/state/projectSettings/projectSettings.cjs');
|
|
10
8
|
var useFundWithWallet = require('../../../../../../utils/hooks/useFundWithWallet/useFundWithWallet.cjs');
|
|
9
|
+
var getPromptAmountParams = require('./getPromptAmountParams/getPromptAmountParams.cjs');
|
|
11
10
|
|
|
12
11
|
const useStartExternalWalletFunding = () => {
|
|
13
|
-
var _a, _b, _c;
|
|
14
12
|
const { connectWalletForFunding, promptAmountAndFund } = useFundWithWallet.useFundWithWallet();
|
|
15
|
-
const settings = projectSettings.useProjectSettings();
|
|
16
13
|
return React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
var _d, _e, _f, _g, _h, _j;
|
|
18
14
|
try {
|
|
19
15
|
const externalWallet = yield connectWalletForFunding();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
// This is always supposed to be present, otherwise there's some backend error
|
|
23
|
-
if (!((_h = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _h === void 0 ? void 0 : _h.value) || !((_j = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _j === void 0 ? void 0 : _j.rule))
|
|
24
|
-
throw new utils.DynamicError(`No external wallet funding chain settings found for chain ${walletChain}`);
|
|
25
|
-
promptAmountAndFund({
|
|
26
|
-
externalWallet,
|
|
27
|
-
token: {
|
|
28
|
-
rule: chainSettings.token.rule,
|
|
29
|
-
value: chainSettings.token.value,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
16
|
+
const props = getPromptAmountParams.getPromptAmountParams({ externalWallet });
|
|
17
|
+
promptAmountAndFund(props);
|
|
32
18
|
}
|
|
33
|
-
catch (
|
|
19
|
+
catch (_a) {
|
|
34
20
|
/* empty */
|
|
35
21
|
}
|
|
36
|
-
}), [
|
|
37
|
-
connectWalletForFunding,
|
|
38
|
-
promptAmountAndFund,
|
|
39
|
-
(_c = (_b = (_a = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _a === void 0 ? void 0 : _a.externalWallets) === null || _b === void 0 ? void 0 : _b.defaultSettings) === null || _c === void 0 ? void 0 : _c.chainSettings,
|
|
40
|
-
]);
|
|
22
|
+
}), [connectWalletForFunding, promptAmountAndFund]);
|
|
41
23
|
};
|
|
42
24
|
|
|
43
25
|
exports.useStartExternalWalletFunding = useStartExternalWalletFunding;
|
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
|
-
import { useProjectSettings } from '../../../../../../store/state/projectSettings/projectSettings.js';
|
|
6
4
|
import { useFundWithWallet } from '../../../../../../utils/hooks/useFundWithWallet/useFundWithWallet.js';
|
|
5
|
+
import { getPromptAmountParams } from './getPromptAmountParams/getPromptAmountParams.js';
|
|
7
6
|
|
|
8
7
|
const useStartExternalWalletFunding = () => {
|
|
9
|
-
var _a, _b, _c;
|
|
10
8
|
const { connectWalletForFunding, promptAmountAndFund } = useFundWithWallet();
|
|
11
|
-
const settings = useProjectSettings();
|
|
12
9
|
return useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
var _d, _e, _f, _g, _h, _j;
|
|
14
10
|
try {
|
|
15
11
|
const externalWallet = yield connectWalletForFunding();
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
// This is always supposed to be present, otherwise there's some backend error
|
|
19
|
-
if (!((_h = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _h === void 0 ? void 0 : _h.value) || !((_j = chainSettings === null || chainSettings === void 0 ? void 0 : chainSettings.token) === null || _j === void 0 ? void 0 : _j.rule))
|
|
20
|
-
throw new DynamicError(`No external wallet funding chain settings found for chain ${walletChain}`);
|
|
21
|
-
promptAmountAndFund({
|
|
22
|
-
externalWallet,
|
|
23
|
-
token: {
|
|
24
|
-
rule: chainSettings.token.rule,
|
|
25
|
-
value: chainSettings.token.value,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
12
|
+
const props = getPromptAmountParams({ externalWallet });
|
|
13
|
+
promptAmountAndFund(props);
|
|
28
14
|
}
|
|
29
|
-
catch (
|
|
15
|
+
catch (_a) {
|
|
30
16
|
/* empty */
|
|
31
17
|
}
|
|
32
|
-
}), [
|
|
33
|
-
connectWalletForFunding,
|
|
34
|
-
promptAmountAndFund,
|
|
35
|
-
(_c = (_b = (_a = settings === null || settings === void 0 ? void 0 : settings.sdk.funding) === null || _a === void 0 ? void 0 : _a.externalWallets) === null || _b === void 0 ? void 0 : _b.defaultSettings) === null || _c === void 0 ? void 0 : _c.chainSettings,
|
|
36
|
-
]);
|
|
18
|
+
}), [connectWalletForFunding, promptAmountAndFund]);
|
|
37
19
|
};
|
|
38
20
|
|
|
39
21
|
export { useStartExternalWalletFunding };
|
|
@@ -56,7 +56,6 @@ require('../../../../views/CollectUserDataView/useFields.cjs');
|
|
|
56
56
|
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
57
57
|
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
58
58
|
require('@dynamic-labs/rpc-providers');
|
|
59
|
-
var useEffectOnce = require('../../../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
60
59
|
require('../../../../store/state/loadingAndLifecycle.cjs');
|
|
61
60
|
require('@dynamic-labs/store');
|
|
62
61
|
require('../../../../store/state/walletOptions/walletOptions.cjs');
|
|
@@ -80,6 +79,7 @@ var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
|
80
79
|
require('../../../../store/state/sendBalances.cjs');
|
|
81
80
|
require('../../../../components/Input/Input.cjs');
|
|
82
81
|
require('../../../../components/OverlayCard/OverlayCard.cjs');
|
|
82
|
+
var useEffectOnce = require('../../../../utils/hooks/useEffectOnce/useEffectOnce.cjs');
|
|
83
83
|
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
84
84
|
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
85
85
|
require('../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
@@ -52,7 +52,6 @@ import '../../../../views/CollectUserDataView/useFields.js';
|
|
|
52
52
|
import '../../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
53
53
|
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
54
54
|
import '@dynamic-labs/rpc-providers';
|
|
55
|
-
import { useEffectOnce } from '../../../../utils/hooks/useEffectOnce/useEffectOnce.js';
|
|
56
55
|
import '../../../../store/state/loadingAndLifecycle.js';
|
|
57
56
|
import '@dynamic-labs/store';
|
|
58
57
|
import '../../../../store/state/walletOptions/walletOptions.js';
|
|
@@ -76,6 +75,7 @@ import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
|
76
75
|
import '../../../../store/state/sendBalances.js';
|
|
77
76
|
import '../../../../components/Input/Input.js';
|
|
78
77
|
import '../../../../components/OverlayCard/OverlayCard.js';
|
|
78
|
+
import { useEffectOnce } from '../../../../utils/hooks/useEffectOnce/useEffectOnce.js';
|
|
79
79
|
import '../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
80
80
|
import '../../../../context/PasskeyContext/PasskeyContext.js';
|
|
81
81
|
import '../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var utils = require('@dynamic-labs/utils');
|
|
7
|
-
var localStorage = require('../../../../utils/constants/localStorage.cjs');
|
|
8
|
-
|
|
9
|
-
const clearExpiredData = (store) => {
|
|
10
|
-
const { projectSettings, user } = store.getState();
|
|
11
|
-
// TODO: we can clean this up once we move wallet info to the store
|
|
12
|
-
const [connectedWalletData] = utils.StorageService.getItem(localStorage.CONNECTED_WALLETS_INFO) || [];
|
|
13
|
-
const shouldRemoveSettingsAndConfigs = !user && !connectedWalletData;
|
|
14
|
-
const isExpired = (value) => shouldRemoveSettingsAndConfigs ||
|
|
15
|
-
(value.expiresAt && value.expiresAt < Date.now());
|
|
16
|
-
if (isExpired(projectSettings)) {
|
|
17
|
-
store.setState({
|
|
18
|
-
projectSettings: store.getInitialState().projectSettings,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return store;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.clearExpiredData = clearExpiredData;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { StorageService } from '@dynamic-labs/utils';
|
|
3
|
-
import { CONNECTED_WALLETS_INFO } from '../../../../utils/constants/localStorage.js';
|
|
4
|
-
|
|
5
|
-
const clearExpiredData = (store) => {
|
|
6
|
-
const { projectSettings, user } = store.getState();
|
|
7
|
-
// TODO: we can clean this up once we move wallet info to the store
|
|
8
|
-
const [connectedWalletData] = StorageService.getItem(CONNECTED_WALLETS_INFO) || [];
|
|
9
|
-
const shouldRemoveSettingsAndConfigs = !user && !connectedWalletData;
|
|
10
|
-
const isExpired = (value) => shouldRemoveSettingsAndConfigs ||
|
|
11
|
-
(value.expiresAt && value.expiresAt < Date.now());
|
|
12
|
-
if (isExpired(projectSettings)) {
|
|
13
|
-
store.setState({
|
|
14
|
-
projectSettings: store.getInitialState().projectSettings,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return store;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { clearExpiredData };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { clearExpiredData } from './clearExpiredData';
|