@dynamic-labs/sdk-react-core 0.17.0-RC.16 → 0.17.0-RC.17
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 +20 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +8 -8
- package/src/lib/components/Divider/Divider.cjs +4 -1
- package/src/lib/components/Divider/Divider.d.ts +6 -2
- package/src/lib/components/Divider/Divider.js +4 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +40 -0
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.d.ts +17 -0
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +36 -0
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.cjs +11 -0
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.d.ts +12 -0
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.js +7 -0
- package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/index.d.ts +1 -0
- package/src/lib/components/TransactionConfirmationPageLayout/components/index.d.ts +1 -0
- package/src/lib/components/TransactionConfirmationPageLayout/index.d.ts +2 -0
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +19 -7
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +19 -7
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -0
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +18 -25
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +18 -25
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +0 -1
- package/src/lib/shared/types/index.d.ts +1 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/isWalletLinked/index.d.ts +1 -0
- package/src/lib/utils/functions/isWalletLinked/isWalletLinked.cjs +15 -0
- package/src/lib/utils/functions/isWalletLinked/isWalletLinked.d.ts +2 -0
- package/src/lib/utils/functions/isWalletLinked/isWalletLinked.js +11 -0
- package/src/lib/utils/hooks/multiWallet/index.d.ts +1 -0
- package/src/lib/utils/hooks/multiWallet/useMultiWalletWidgetState/useMultiWalletWidgetState.cjs +0 -2
- package/src/lib/utils/hooks/multiWallet/useMultiWalletWidgetState/useMultiWalletWidgetState.js +0 -2
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +53 -6
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +8 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +54 -7
- package/src/lib/utils/hooks/useConnectedAccountWallet/index.d.ts +1 -0
- package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.cjs +30 -0
- package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.d.ts +2 -0
- package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.js +26 -0
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +18 -6
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +18 -6
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +4 -5
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +4 -5
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +2 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs +15 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.js +15 -5
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +2 -1
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.cjs +38 -6
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.js +39 -7
- package/src/lib/widgets/DynamicWidget/{components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs → prompts/DefaultPromptModal/DefaultPromptModal.cjs} +6 -13
- package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.d.ts +13 -0
- package/src/lib/widgets/DynamicWidget/{components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js → prompts/DefaultPromptModal/DefaultPromptModal.js} +6 -13
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +17 -42
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +18 -43
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +40 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +36 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +67 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.d.ts +8 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +63 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +57 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +53 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +44 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +40 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +64 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +60 -0
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/PendingSignModal.cjs +2 -33
- package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/PendingSignModal.js +2 -33
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +4 -6
- package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +5 -7
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.d.ts +0 -2
- package/src/lib/widgets/DynamicWidget/components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.types.d.ts +0 -7
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.cjs +0 -61
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.d.ts +0 -7
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.js +0 -57
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/index.d.ts +0 -1
- /package/src/lib/widgets/DynamicWidget/{components → prompts/PendingSignModal}/DefaultPendingSignModalContent/index.d.ts +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const useConnectedAccountWallet = (connector, secondaryWallets) => {
|
|
5
|
+
const [wallet, setWallet] = useState();
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const getConnectedAccounts = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
var _a;
|
|
9
|
+
if (!connector) {
|
|
10
|
+
setWallet(undefined);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const connectedAccounts = (_a = (yield connector.getConnectedAccounts())) !== null && _a !== void 0 ? _a : [];
|
|
14
|
+
const connectedWallet = secondaryWallets.find((secondaryWallet) => {
|
|
15
|
+
var _a;
|
|
16
|
+
return secondaryWallet.address.toLowerCase() ===
|
|
17
|
+
((_a = connectedAccounts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
18
|
+
});
|
|
19
|
+
setWallet(connectedWallet);
|
|
20
|
+
});
|
|
21
|
+
getConnectedAccounts();
|
|
22
|
+
}, [connector, secondaryWallets]);
|
|
23
|
+
return wallet;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useConnectedAccountWallet };
|
|
@@ -97,9 +97,7 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
97
97
|
const connectedAccounts = yield newWallet.connector.getConnectedAccounts();
|
|
98
98
|
return { connectedAccounts, newWallet };
|
|
99
99
|
}), [wallets]);
|
|
100
|
-
const checkIfAccountChangeIsRequired = React.useCallback((primaryWallet, newPrimaryWallet) => {
|
|
101
|
-
if (!primaryWallet)
|
|
102
|
-
return;
|
|
100
|
+
const checkIfAccountChangeIsRequired = React.useCallback((primaryWallet, newPrimaryWallet, connectedAccounts) => {
|
|
103
101
|
/**
|
|
104
102
|
* we need to check multiWalletWidgetState here because `setPrimaryWallet` currently gets
|
|
105
103
|
* called twice: once when the user clicks "make active" and once when the user performs
|
|
@@ -107,8 +105,12 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
107
105
|
* (https://github.com/dynamic-labs/DynamicAuth/pull/550) is merged, since setting the
|
|
108
106
|
* primary wallet will be simpler, so we won't need to call `setPrimaryWallet` twice.
|
|
109
107
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
if (!primaryWallet || multiWalletWidgetState !== 'idle')
|
|
109
|
+
return;
|
|
110
|
+
const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
|
|
111
|
+
!connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
|
|
112
|
+
newPrimaryWallet.address.toLowerCase());
|
|
113
|
+
return (isSameWalletName.isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name) || accountIsNotConnectedInSecondaryWallet);
|
|
112
114
|
}, [multiWalletWidgetState]);
|
|
113
115
|
const checkIfShowQrCodeModal = React.useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
|
|
114
116
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
@@ -123,7 +125,8 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
123
125
|
return;
|
|
124
126
|
const primaryWallet = getPrimaryWallet();
|
|
125
127
|
if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet)) {
|
|
126
|
-
|
|
128
|
+
yield newPrimaryWallet.connector.connect();
|
|
129
|
+
setPrimaryWalletId(walletId);
|
|
127
130
|
return;
|
|
128
131
|
}
|
|
129
132
|
if (!connectedAccounts.length) {
|
|
@@ -146,6 +149,15 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
146
149
|
setQrcodeUri(uri);
|
|
147
150
|
}),
|
|
148
151
|
});
|
|
152
|
+
/**
|
|
153
|
+
* need to check for connected account again for wallets that disconnect on refresh
|
|
154
|
+
* and only reconnect upon fetching public address above
|
|
155
|
+
*/
|
|
156
|
+
const updatedConnectedAccounts = yield newPrimaryWallet.connector.getConnectedAccounts();
|
|
157
|
+
if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet, updatedConnectedAccounts)) {
|
|
158
|
+
setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
149
161
|
if (publicAddress) {
|
|
150
162
|
setPrimaryWalletId(walletId);
|
|
151
163
|
setMultiWalletWidgetState('idle');
|
|
@@ -93,9 +93,7 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
93
93
|
const connectedAccounts = yield newWallet.connector.getConnectedAccounts();
|
|
94
94
|
return { connectedAccounts, newWallet };
|
|
95
95
|
}), [wallets]);
|
|
96
|
-
const checkIfAccountChangeIsRequired = useCallback((primaryWallet, newPrimaryWallet) => {
|
|
97
|
-
if (!primaryWallet)
|
|
98
|
-
return;
|
|
96
|
+
const checkIfAccountChangeIsRequired = useCallback((primaryWallet, newPrimaryWallet, connectedAccounts) => {
|
|
99
97
|
/**
|
|
100
98
|
* we need to check multiWalletWidgetState here because `setPrimaryWallet` currently gets
|
|
101
99
|
* called twice: once when the user clicks "make active" and once when the user performs
|
|
@@ -103,8 +101,12 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
103
101
|
* (https://github.com/dynamic-labs/DynamicAuth/pull/550) is merged, since setting the
|
|
104
102
|
* primary wallet will be simpler, so we won't need to call `setPrimaryWallet` twice.
|
|
105
103
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
if (!primaryWallet || multiWalletWidgetState !== 'idle')
|
|
105
|
+
return;
|
|
106
|
+
const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
|
|
107
|
+
!connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
|
|
108
|
+
newPrimaryWallet.address.toLowerCase());
|
|
109
|
+
return (isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name) || accountIsNotConnectedInSecondaryWallet);
|
|
108
110
|
}, [multiWalletWidgetState]);
|
|
109
111
|
const checkIfShowQrCodeModal = useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
|
|
110
112
|
!wallet.connector.canConnectViaCustodialService, []);
|
|
@@ -119,7 +121,8 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
119
121
|
return;
|
|
120
122
|
const primaryWallet = getPrimaryWallet();
|
|
121
123
|
if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet)) {
|
|
122
|
-
|
|
124
|
+
yield newPrimaryWallet.connector.connect();
|
|
125
|
+
setPrimaryWalletId(walletId);
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
128
|
if (!connectedAccounts.length) {
|
|
@@ -142,6 +145,15 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
|
|
|
142
145
|
setQrcodeUri(uri);
|
|
143
146
|
}),
|
|
144
147
|
});
|
|
148
|
+
/**
|
|
149
|
+
* need to check for connected account again for wallets that disconnect on refresh
|
|
150
|
+
* and only reconnect upon fetching public address above
|
|
151
|
+
*/
|
|
152
|
+
const updatedConnectedAccounts = yield newPrimaryWallet.connector.getConnectedAccounts();
|
|
153
|
+
if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet, updatedConnectedAccounts)) {
|
|
154
|
+
setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
145
157
|
if (publicAddress) {
|
|
146
158
|
setPrimaryWalletId(walletId);
|
|
147
159
|
setMultiWalletWidgetState('idle');
|
|
@@ -92,6 +92,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
92
92
|
onAccountChange: (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
93
|
const [newAddress] = accounts;
|
|
94
94
|
yield computeConnectedStateForWallets();
|
|
95
|
+
const newWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
95
96
|
if (walletConnectorCore.isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
96
97
|
setMultiWalletWidgetState('idle');
|
|
97
98
|
}
|
|
@@ -102,12 +103,10 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
102
103
|
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
103
104
|
yield computeConnectedStateForWallets();
|
|
104
105
|
}
|
|
105
|
-
else if (multiWalletWidgetState === 'idle' &&
|
|
106
|
-
|
|
107
|
-
setMultiWalletWidgetState('detected_known_secondary_wallet');
|
|
106
|
+
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
107
|
+
setPrimaryWalletId(newWallet.id);
|
|
108
108
|
}
|
|
109
|
-
else if (multiWalletWidgetState === 'idle' &&
|
|
110
|
-
!secondaryWallets.some((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain))) {
|
|
109
|
+
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
111
110
|
if (user) {
|
|
112
111
|
setMultiWalletWidgetState('detected_new_wallet');
|
|
113
112
|
setSelectedWalletConnector(primaryWallet.connector);
|
|
@@ -88,6 +88,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
88
88
|
onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
89
|
const [newAddress] = accounts;
|
|
90
90
|
yield computeConnectedStateForWallets();
|
|
91
|
+
const newWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
91
92
|
if (isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
|
|
92
93
|
setMultiWalletWidgetState('idle');
|
|
93
94
|
}
|
|
@@ -98,12 +99,10 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
98
99
|
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
99
100
|
yield computeConnectedStateForWallets();
|
|
100
101
|
}
|
|
101
|
-
else if (multiWalletWidgetState === 'idle' &&
|
|
102
|
-
|
|
103
|
-
setMultiWalletWidgetState('detected_known_secondary_wallet');
|
|
102
|
+
else if (multiWalletWidgetState === 'idle' && newWallet) {
|
|
103
|
+
setPrimaryWalletId(newWallet.id);
|
|
104
104
|
}
|
|
105
|
-
else if (multiWalletWidgetState === 'idle' &&
|
|
106
|
-
!secondaryWallets.some((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain))) {
|
|
105
|
+
else if (multiWalletWidgetState === 'idle' && !newWallet) {
|
|
107
106
|
if (user) {
|
|
108
107
|
setMultiWalletWidgetState('detected_new_wallet');
|
|
109
108
|
setSelectedWalletConnector(primaryWallet.connector);
|
|
@@ -25,7 +25,7 @@ var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndS
|
|
|
25
25
|
var isSelectedWalletAlreadyConnected = require('../../functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.cjs');
|
|
26
26
|
|
|
27
27
|
const useWalletItemActions = () => {
|
|
28
|
-
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
28
|
+
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, setIsVerifying, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
29
29
|
const { mockedSDK } = MockContext.useMockContext();
|
|
30
30
|
const { setError } = ErrorContext.useErrorContext();
|
|
31
31
|
const { setView } = ViewContext.useViewContext();
|
|
@@ -108,6 +108,7 @@ const useWalletItemActions = () => {
|
|
|
108
108
|
if (walletConnector.connectedChain === 'FLOW') {
|
|
109
109
|
yield walletConnector.endSession();
|
|
110
110
|
}
|
|
111
|
+
setIsVerifying(false);
|
|
111
112
|
if (isSelectedWalletAlreadyConnected.isSelectedWalletAlreadyConnected(connectedWallets, walletConnector, user) &&
|
|
112
113
|
walletConnector.connectedChain !== 'FLOW') {
|
|
113
114
|
// wallet is already connected
|
|
@@ -21,7 +21,7 @@ import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAn
|
|
|
21
21
|
import { isSelectedWalletAlreadyConnected } from '../../functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.js';
|
|
22
22
|
|
|
23
23
|
const useWalletItemActions = () => {
|
|
24
|
-
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, } = useInternalDynamicContext();
|
|
24
|
+
const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, setIsVerifying, } = useInternalDynamicContext();
|
|
25
25
|
const { mockedSDK } = useMockContext();
|
|
26
26
|
const { setError } = useErrorContext();
|
|
27
27
|
const { setView } = useViewContext();
|
|
@@ -104,6 +104,7 @@ const useWalletItemActions = () => {
|
|
|
104
104
|
if (walletConnector.connectedChain === 'FLOW') {
|
|
105
105
|
yield walletConnector.endSession();
|
|
106
106
|
}
|
|
107
|
+
setIsVerifying(false);
|
|
107
108
|
if (isSelectedWalletAlreadyConnected(connectedWallets, walletConnector, user) &&
|
|
108
109
|
walletConnector.connectedChain !== 'FLOW') {
|
|
109
110
|
// wallet is already connected
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs
CHANGED
|
@@ -4,35 +4,45 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
8
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
8
|
-
var DetectedKnownSecondaryWalletModal = require('../../prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.cjs');
|
|
9
9
|
var DetectedNewWalletModal = require('../../prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs');
|
|
10
10
|
var PendingAccountSwitchModal = require('../../prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs');
|
|
11
|
+
var PendingAccountSwitchToLinkModal = require('../../prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs');
|
|
11
12
|
var PendingSignModal = require('../../prompts/PendingSignModal/PendingSignModal.cjs');
|
|
12
13
|
var PrimaryNotConnectedModal = require('../../prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs');
|
|
13
14
|
var QrCodeModalView = require('../../prompts/QrCodeModalView/QrCodeModalView.cjs');
|
|
14
15
|
var UnlinkWalletPopUp = require('../../prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs');
|
|
15
16
|
var WidgetPortal = require('../WidgetPortal/WidgetPortal.cjs');
|
|
16
17
|
var NoQrNotInstalledModalView = require('../../prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs');
|
|
18
|
+
var PendingConnectionModal = require('../../prompts/PendingConnectionModal/PendingConnectionModal.cjs');
|
|
17
19
|
|
|
18
20
|
const mapAccountSwitchStateToPromptComponent = {
|
|
19
|
-
linking_new_wallet:
|
|
21
|
+
linking_new_wallet: PendingAccountSwitchToLinkModal.PendingAccountSwitchToLinkModal,
|
|
20
22
|
primary_not_connected: PrimaryNotConnectedModal.PrimaryNotConnectedModal,
|
|
21
23
|
switching_primary: PendingAccountSwitchModal.PendingAccountSwitchModal,
|
|
22
24
|
};
|
|
23
25
|
const DynamicWidgetPrompts = () => {
|
|
24
26
|
var _a, _b, _c;
|
|
25
|
-
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction,
|
|
27
|
+
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
26
28
|
const AccountSwitchModal = React.useMemo(() => {
|
|
27
29
|
if (multiWalletWidgetState !== 'awaiting_account_switch')
|
|
28
30
|
return null;
|
|
29
31
|
return mapAccountSwitchStateToPromptComponent[accountSwitchState] || null;
|
|
30
32
|
}, [accountSwitchState, multiWalletWidgetState]);
|
|
33
|
+
const AwaitingConnectionModal = React.useMemo(() => {
|
|
34
|
+
if (selectedWalletConnector &&
|
|
35
|
+
(walletConnectorCore.isEmailOTPWalletConnector(selectedWalletConnector) ||
|
|
36
|
+
walletConnectorCore.isEmailWalletConnector(selectedWalletConnector))) {
|
|
37
|
+
return PendingSignModal.PendingSignModal;
|
|
38
|
+
}
|
|
39
|
+
return PendingConnectionModal.PendingConnectionModal;
|
|
40
|
+
}, [selectedWalletConnector]);
|
|
31
41
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [multiWalletWidgetState === 'awaiting_signature' && jsxRuntime.jsx(PendingSignModal.PendingSignModal, {}), AccountSwitchModal && jsxRuntime.jsx(AccountSwitchModal, {}), (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.action) === 'unlink' && (jsxRuntime.jsx(UnlinkWalletPopUp.UnlinkWalletPopUp, { walletId: (_a = selectedWalletWithAction.wallet) === null || _a === void 0 ? void 0 : _a.id })), multiWalletWidgetState === 'awaiting_connection' &&
|
|
32
|
-
(showQrcodeModal ? (jsxRuntime.jsx(WidgetPortal.WidgetPortal, Object.assign({ onBackdropClick: () => {
|
|
42
|
+
(showQrcodeModal ? (jsxRuntime.jsx(WidgetPortal.WidgetPortal, Object.assign({ showCloseButton: true, onBackdropClick: () => {
|
|
33
43
|
setShowQrcodeModal(false);
|
|
34
44
|
setDesktopUri('');
|
|
35
|
-
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsxRuntime.jsx(QrCodeModalView.QrCodeModalView, { walletId: (_c = (_b = selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '' })) : (jsxRuntime.jsx(NoQrNotInstalledModalView.NoQrNotInstalledModalView, {})) }))) : (jsxRuntime.jsx(
|
|
45
|
+
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsxRuntime.jsx(QrCodeModalView.QrCodeModalView, { walletId: (_c = (_b = selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '' })) : (jsxRuntime.jsx(NoQrNotInstalledModalView.NoQrNotInstalledModalView, {})) }))) : (jsxRuntime.jsx(AwaitingConnectionModal, {}))), multiWalletWidgetState === 'detected_new_wallet' && (jsxRuntime.jsx(DetectedNewWalletModal.DetectedNewWalletModal, {}))] }));
|
|
36
46
|
};
|
|
37
47
|
|
|
38
48
|
exports.DynamicWidgetPrompts = DynamicWidgetPrompts;
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.js
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { isEmailOTPWalletConnector, isEmailWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
4
|
-
import { DetectedKnownSecondaryWalletModal } from '../../prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.js';
|
|
5
5
|
import { DetectedNewWalletModal } from '../../prompts/DetectedNewWalletModal/DetectedNewWalletModal.js';
|
|
6
6
|
import { PendingAccountSwitchModal } from '../../prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js';
|
|
7
|
+
import { PendingAccountSwitchToLinkModal } from '../../prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js';
|
|
7
8
|
import { PendingSignModal } from '../../prompts/PendingSignModal/PendingSignModal.js';
|
|
8
9
|
import { PrimaryNotConnectedModal } from '../../prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js';
|
|
9
10
|
import { QrCodeModalView } from '../../prompts/QrCodeModalView/QrCodeModalView.js';
|
|
10
11
|
import { UnlinkWalletPopUp } from '../../prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js';
|
|
11
12
|
import { WidgetPortal } from '../WidgetPortal/WidgetPortal.js';
|
|
12
13
|
import { NoQrNotInstalledModalView } from '../../prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js';
|
|
14
|
+
import { PendingConnectionModal } from '../../prompts/PendingConnectionModal/PendingConnectionModal.js';
|
|
13
15
|
|
|
14
16
|
const mapAccountSwitchStateToPromptComponent = {
|
|
15
|
-
linking_new_wallet:
|
|
17
|
+
linking_new_wallet: PendingAccountSwitchToLinkModal,
|
|
16
18
|
primary_not_connected: PrimaryNotConnectedModal,
|
|
17
19
|
switching_primary: PendingAccountSwitchModal,
|
|
18
20
|
};
|
|
19
21
|
const DynamicWidgetPrompts = () => {
|
|
20
22
|
var _a, _b, _c;
|
|
21
|
-
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction,
|
|
23
|
+
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction, } = useInternalDynamicContext();
|
|
22
24
|
const AccountSwitchModal = useMemo(() => {
|
|
23
25
|
if (multiWalletWidgetState !== 'awaiting_account_switch')
|
|
24
26
|
return null;
|
|
25
27
|
return mapAccountSwitchStateToPromptComponent[accountSwitchState] || null;
|
|
26
28
|
}, [accountSwitchState, multiWalletWidgetState]);
|
|
29
|
+
const AwaitingConnectionModal = useMemo(() => {
|
|
30
|
+
if (selectedWalletConnector &&
|
|
31
|
+
(isEmailOTPWalletConnector(selectedWalletConnector) ||
|
|
32
|
+
isEmailWalletConnector(selectedWalletConnector))) {
|
|
33
|
+
return PendingSignModal;
|
|
34
|
+
}
|
|
35
|
+
return PendingConnectionModal;
|
|
36
|
+
}, [selectedWalletConnector]);
|
|
27
37
|
return (jsxs(Fragment, { children: [multiWalletWidgetState === 'awaiting_signature' && jsx(PendingSignModal, {}), AccountSwitchModal && jsx(AccountSwitchModal, {}), (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.action) === 'unlink' && (jsx(UnlinkWalletPopUp, { walletId: (_a = selectedWalletWithAction.wallet) === null || _a === void 0 ? void 0 : _a.id })), multiWalletWidgetState === 'awaiting_connection' &&
|
|
28
|
-
(showQrcodeModal ? (jsx(WidgetPortal, Object.assign({ onBackdropClick: () => {
|
|
38
|
+
(showQrcodeModal ? (jsx(WidgetPortal, Object.assign({ showCloseButton: true, onBackdropClick: () => {
|
|
29
39
|
setShowQrcodeModal(false);
|
|
30
40
|
setDesktopUri('');
|
|
31
|
-
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsx(QrCodeModalView, { walletId: (_c = (_b = selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '' })) : (jsx(NoQrNotInstalledModalView, {})) }))) : (jsx(
|
|
41
|
+
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsx(QrCodeModalView, { walletId: (_c = (_b = selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '' })) : (jsx(NoQrNotInstalledModalView, {})) }))) : (jsx(AwaitingConnectionModal, {}))), multiWalletWidgetState === 'detected_new_wallet' && (jsx(DetectedNewWalletModal, {}))] }));
|
|
32
42
|
};
|
|
33
43
|
|
|
34
44
|
export { DynamicWidgetPrompts };
|
|
@@ -44,7 +44,7 @@ var WalletIconWithStatus = require('../WalletIconWithStatus/WalletIconWithStatus
|
|
|
44
44
|
|
|
45
45
|
const Wallet = ({ wallet, ens }) => {
|
|
46
46
|
const { id: walletId, connector, address, connected } = wallet;
|
|
47
|
-
const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setSelectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
47
|
+
const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setShowWidgetStatePopup, setSelectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
48
48
|
const iconSize = 20;
|
|
49
49
|
const options = [
|
|
50
50
|
{
|
|
@@ -74,6 +74,7 @@ const Wallet = ({ wallet, ens }) => {
|
|
|
74
74
|
if (connector.connectedChain === 'FLOW') {
|
|
75
75
|
(_a = connector.endSession) === null || _a === void 0 ? void 0 : _a.call(connector);
|
|
76
76
|
}
|
|
77
|
+
setShowWidgetStatePopup(true);
|
|
77
78
|
setSelectedWalletWithAction({ action: 'select', wallet });
|
|
78
79
|
setPrimaryWallet(walletId);
|
|
79
80
|
computeConnectedStateForWallets();
|
|
@@ -40,7 +40,7 @@ import { WalletIconWithStatus } from '../WalletIconWithStatus/WalletIconWithStat
|
|
|
40
40
|
|
|
41
41
|
const Wallet = ({ wallet, ens }) => {
|
|
42
42
|
const { id: walletId, connector, address, connected } = wallet;
|
|
43
|
-
const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setSelectedWalletWithAction, } = useInternalDynamicContext();
|
|
43
|
+
const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setShowWidgetStatePopup, setSelectedWalletWithAction, } = useInternalDynamicContext();
|
|
44
44
|
const iconSize = 20;
|
|
45
45
|
const options = [
|
|
46
46
|
{
|
|
@@ -70,6 +70,7 @@ const Wallet = ({ wallet, ens }) => {
|
|
|
70
70
|
if (connector.connectedChain === 'FLOW') {
|
|
71
71
|
(_a = connector.endSession) === null || _a === void 0 ? void 0 : _a.call(connector);
|
|
72
72
|
}
|
|
73
|
+
setShowWidgetStatePopup(true);
|
|
73
74
|
setSelectedWalletWithAction({ action: 'select', wallet });
|
|
74
75
|
setPrimaryWallet(walletId);
|
|
75
76
|
computeConnectedStateForWallets();
|
|
@@ -3,23 +3,55 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
|
|
6
|
+
require('react');
|
|
7
7
|
var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api');
|
|
9
|
+
require('../../../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
+
var close = require('../../../../shared/assets/close.cjs');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
15
|
+
require('../../../../utils/constants/colors.cjs');
|
|
16
|
+
require('ethers');
|
|
17
|
+
require('../../../../shared/consts/index.cjs');
|
|
18
|
+
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
19
|
+
require('@dynamic-labs/multi-wallet');
|
|
20
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
21
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
22
|
+
require('react-dom');
|
|
23
|
+
require('react-focus-lock');
|
|
24
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
25
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
26
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
27
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
28
|
+
require('@dynamic-labs/rpc-providers');
|
|
29
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
30
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
31
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
32
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
33
|
+
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
34
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
35
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
36
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
8
37
|
|
|
9
|
-
const WidgetPortal = ({ children, onBackdropClick, disablePadding, }) => {
|
|
10
|
-
const { setMultiWalletWidgetState,
|
|
38
|
+
const WidgetPortal = ({ children, onBackdropClick, disablePadding, showCloseButton, }) => {
|
|
39
|
+
const { accountSwitchState, setMultiWalletWidgetState, setSelectedWalletWithAction, selectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
11
40
|
const handleBackdropClick = (e) => {
|
|
12
41
|
e.stopPropagation();
|
|
13
|
-
if (
|
|
42
|
+
if (!selectedWalletWithAction &&
|
|
43
|
+
accountSwitchState === 'primary_not_connected') {
|
|
14
44
|
return;
|
|
45
|
+
}
|
|
46
|
+
setSelectedWalletWithAction(null);
|
|
15
47
|
setMultiWalletWidgetState('idle');
|
|
16
48
|
if (!onBackdropClick)
|
|
17
49
|
return;
|
|
18
50
|
onBackdropClick();
|
|
19
51
|
};
|
|
20
|
-
return (jsxRuntime.jsx("div", Object.assign({ className: 'widget-portal', onClick: (e) => handleBackdropClick(e), "data-testid": 'backdrop' }, { children: jsxRuntime.
|
|
52
|
+
return (jsxRuntime.jsx("div", Object.assign({ className: 'widget-portal', onClick: (e) => handleBackdropClick(e), "data-testid": 'backdrop' }, { children: jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('widget-portal__container', {
|
|
21
53
|
'widget-portal__container--no-padding': disablePadding,
|
|
22
|
-
}), onClick: (e) => e.stopPropagation() }, { children: children })) })));
|
|
54
|
+
}), onClick: (e) => e.stopPropagation() }, { children: [showCloseButton && (jsxRuntime.jsx("div", Object.assign({ className: 'widget-portal__container__header' }, { children: jsxRuntime.jsx(IconButton.IconButton, Object.assign({ className: 'widget-portal__container__close-button', onClick: (e) => handleBackdropClick(e), type: 'button', "data-testid": 'close-button' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })) }))), children] })) })));
|
|
23
55
|
};
|
|
24
56
|
|
|
25
57
|
exports.WidgetPortal = WidgetPortal;
|
|
@@ -3,6 +3,7 @@ type Props = {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
disablePadding?: boolean;
|
|
5
5
|
onBackdropClick?: VoidFunction;
|
|
6
|
+
showCloseButton?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare const WidgetPortal: ({ children, onBackdropClick, disablePadding, }: Props) => JSX.Element;
|
|
8
|
+
export declare const WidgetPortal: ({ children, onBackdropClick, disablePadding, showCloseButton, }: Props) => JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,21 +1,53 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
3
|
import { classNames } from '../../../../utils/functions/classNames/classNames.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api';
|
|
5
|
+
import '../../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import { ReactComponent as SvgClose } from '../../../../shared/assets/close.js';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
11
|
+
import '../../../../utils/constants/colors.js';
|
|
12
|
+
import 'ethers';
|
|
13
|
+
import '../../../../shared/consts/index.js';
|
|
14
|
+
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
15
|
+
import '@dynamic-labs/multi-wallet';
|
|
16
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
17
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
18
|
+
import 'react-dom';
|
|
19
|
+
import 'react-focus-lock';
|
|
20
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
21
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
22
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
23
|
+
import '../../../../config/ApiEndpoint.js';
|
|
24
|
+
import '@dynamic-labs/rpc-providers';
|
|
25
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
26
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
27
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
28
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
29
|
+
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
30
|
+
import '../../../../components/Alert/Alert.js';
|
|
31
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
32
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
4
33
|
|
|
5
|
-
const WidgetPortal = ({ children, onBackdropClick, disablePadding, }) => {
|
|
6
|
-
const { setMultiWalletWidgetState,
|
|
34
|
+
const WidgetPortal = ({ children, onBackdropClick, disablePadding, showCloseButton, }) => {
|
|
35
|
+
const { accountSwitchState, setMultiWalletWidgetState, setSelectedWalletWithAction, selectedWalletWithAction, } = useInternalDynamicContext();
|
|
7
36
|
const handleBackdropClick = (e) => {
|
|
8
37
|
e.stopPropagation();
|
|
9
|
-
if (
|
|
38
|
+
if (!selectedWalletWithAction &&
|
|
39
|
+
accountSwitchState === 'primary_not_connected') {
|
|
10
40
|
return;
|
|
41
|
+
}
|
|
42
|
+
setSelectedWalletWithAction(null);
|
|
11
43
|
setMultiWalletWidgetState('idle');
|
|
12
44
|
if (!onBackdropClick)
|
|
13
45
|
return;
|
|
14
46
|
onBackdropClick();
|
|
15
47
|
};
|
|
16
|
-
return (jsx("div", Object.assign({ className: 'widget-portal', onClick: (e) => handleBackdropClick(e), "data-testid": 'backdrop' }, { children:
|
|
48
|
+
return (jsx("div", Object.assign({ className: 'widget-portal', onClick: (e) => handleBackdropClick(e), "data-testid": 'backdrop' }, { children: jsxs("div", Object.assign({ className: classNames('widget-portal__container', {
|
|
17
49
|
'widget-portal__container--no-padding': disablePadding,
|
|
18
|
-
}), onClick: (e) => e.stopPropagation() }, { children: children })) })));
|
|
50
|
+
}), onClick: (e) => e.stopPropagation() }, { children: [showCloseButton && (jsx("div", Object.assign({ className: 'widget-portal__container__header' }, { children: jsx(IconButton, Object.assign({ className: 'widget-portal__container__close-button', onClick: (e) => handleBackdropClick(e), type: 'button', "data-testid": 'close-button' }, { children: jsx(SvgClose, {}) })) }))), children] })) })));
|
|
19
51
|
};
|
|
20
52
|
|
|
21
53
|
export { WidgetPortal };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var IconWithSpinner = require('../../../../components/IconWithSpinner/IconWithSpinner.cjs');
|
|
7
|
+
var WidgetPortal = require('../../components/WidgetPortal/WidgetPortal.cjs');
|
|
8
8
|
require('react');
|
|
9
9
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
10
10
|
require('@dynamic-labs/sdk-api');
|
|
@@ -12,14 +12,15 @@ require('../../../../shared/logger.cjs');
|
|
|
12
12
|
require('@dynamic-labs/iconic');
|
|
13
13
|
require('@dynamic-labs/wallet-connector-core');
|
|
14
14
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
require('@dynamic-labs/utils');
|
|
15
16
|
require('../../../../utils/constants/colors.cjs');
|
|
16
17
|
require('ethers');
|
|
17
18
|
require('../../../../shared/consts/index.cjs');
|
|
18
19
|
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
19
20
|
require('@dynamic-labs/multi-wallet');
|
|
20
|
-
var pixelToRem = require('../../../../utils/functions/pixelToRem/pixelToRem.cjs');
|
|
21
21
|
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
22
22
|
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
23
|
+
var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
|
|
23
24
|
require('react-dom');
|
|
24
25
|
require('react-focus-lock');
|
|
25
26
|
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
@@ -31,19 +32,11 @@ require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
31
32
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
32
33
|
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
33
34
|
require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
34
|
-
var Button = require('../../../../components/Button/Button.cjs');
|
|
35
35
|
require('../../../../components/IconButton/IconButton.cjs');
|
|
36
36
|
require('../../../../components/Alert/Alert.cjs');
|
|
37
|
-
var IconWithSpinner = require('../../../../components/IconWithSpinner/IconWithSpinner.cjs');
|
|
38
37
|
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
39
38
|
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
40
|
-
var helpers = require('../../helpers/helpers.cjs');
|
|
41
39
|
|
|
42
|
-
const
|
|
43
|
-
const { name = '' } = walletConnector || {};
|
|
44
|
-
const iconSize = 80;
|
|
45
|
-
const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: name, style: { height: pixelToRem.pixelToRem(iconSize), width: pixelToRem.pixelToRem(iconSize) } }));
|
|
46
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'default-pending-sign-modal-content__container' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 80, Icon: icon, isSpinning: true }), name && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ color: 'primary', className: 'default-pending-sign-modal-content__title', variant: 'body_normal', weight: 'medium' }, { children: ["Sign in with ", helpers.capitalize(name)] }))), jsxRuntime.jsx(Typography.Typography, Object.assign({ color: 'secondary', variant: 'body_small', weight: 'medium' }, { children: "Sign the message in your wallet to approve linking this wallet to your account" })), utils.isMobile() && !(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.canConnectViaCustodialService) && (jsxRuntime.jsx(Button.Button, Object.assign({ onClick: onClickToSign }, { children: "Click to Sign" })))] })));
|
|
47
|
-
};
|
|
40
|
+
const DefaultPromptModal = ({ children, className = '', dataTestId = '', icon, showCloseButton = false, title, }) => (jsxRuntime.jsx(WidgetPortal.WidgetPortal, Object.assign({ showCloseButton: showCloseButton }, { children: jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('default-prompt-modal', className), "data-testid": dataTestId }, { children: [icon && jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: icon, iconSize: 96, isSpinning: true }), jsxRuntime.jsxs("div", Object.assign({ className: 'default-prompt-modal__content' }, { children: [title && (jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'title', color: 'primary', "data-testid": 'title' }, { children: title }))), children] }))] })) })));
|
|
48
41
|
|
|
49
|
-
exports.
|
|
42
|
+
exports.DefaultPromptModal = DefaultPromptModal;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Iconic } from '@dynamic-labs/iconic';
|
|
3
|
+
import { Icon } from '../../../../shared';
|
|
4
|
+
type Props = {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
dataTestId?: string;
|
|
8
|
+
icon?: Icon | Iconic | ReactElement;
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const DefaultPromptModal: FC<Props>;
|
|
13
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { IconWithSpinner } from '../../../../components/IconWithSpinner/IconWithSpinner.js';
|
|
3
|
+
import { WidgetPortal } from '../../components/WidgetPortal/WidgetPortal.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
6
6
|
import '@dynamic-labs/sdk-api';
|
|
@@ -8,14 +8,15 @@ import '../../../../shared/logger.js';
|
|
|
8
8
|
import '@dynamic-labs/iconic';
|
|
9
9
|
import '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import '@dynamic-labs/utils';
|
|
11
12
|
import '../../../../utils/constants/colors.js';
|
|
12
13
|
import 'ethers';
|
|
13
14
|
import '../../../../shared/consts/index.js';
|
|
14
15
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
15
16
|
import '@dynamic-labs/multi-wallet';
|
|
16
|
-
import { pixelToRem } from '../../../../utils/functions/pixelToRem/pixelToRem.js';
|
|
17
17
|
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
18
18
|
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
19
|
+
import { classNames } from '../../../../utils/functions/classNames/classNames.js';
|
|
19
20
|
import 'react-dom';
|
|
20
21
|
import 'react-focus-lock';
|
|
21
22
|
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
@@ -27,19 +28,11 @@ import '../../../../context/ErrorContext/ErrorContext.js';
|
|
|
27
28
|
import '../../../../context/MockContext/MockContext.js';
|
|
28
29
|
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
29
30
|
import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
30
|
-
import { Button } from '../../../../components/Button/Button.js';
|
|
31
31
|
import '../../../../components/IconButton/IconButton.js';
|
|
32
32
|
import '../../../../components/Alert/Alert.js';
|
|
33
|
-
import { IconWithSpinner } from '../../../../components/IconWithSpinner/IconWithSpinner.js';
|
|
34
33
|
import '../../../../components/Popper/Popper/Popper.js';
|
|
35
34
|
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
36
|
-
import { capitalize } from '../../helpers/helpers.js';
|
|
37
35
|
|
|
38
|
-
const
|
|
39
|
-
const { name = '' } = walletConnector || {};
|
|
40
|
-
const iconSize = 80;
|
|
41
|
-
const icon = (jsx(WalletIcon, { walletName: name, style: { height: pixelToRem(iconSize), width: pixelToRem(iconSize) } }));
|
|
42
|
-
return (jsxs("div", Object.assign({ className: 'default-pending-sign-modal-content__container' }, { children: [jsx(IconWithSpinner, { iconSize: 80, Icon: icon, isSpinning: true }), name && (jsxs(Typography, Object.assign({ color: 'primary', className: 'default-pending-sign-modal-content__title', variant: 'body_normal', weight: 'medium' }, { children: ["Sign in with ", capitalize(name)] }))), jsx(Typography, Object.assign({ color: 'secondary', variant: 'body_small', weight: 'medium' }, { children: "Sign the message in your wallet to approve linking this wallet to your account" })), isMobile() && !(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.canConnectViaCustodialService) && (jsx(Button, Object.assign({ onClick: onClickToSign }, { children: "Click to Sign" })))] })));
|
|
43
|
-
};
|
|
36
|
+
const DefaultPromptModal = ({ children, className = '', dataTestId = '', icon, showCloseButton = false, title, }) => (jsx(WidgetPortal, Object.assign({ showCloseButton: showCloseButton }, { children: jsxs("div", Object.assign({ className: classNames('default-prompt-modal', className), "data-testid": dataTestId }, { children: [icon && jsx(IconWithSpinner, { Icon: icon, iconSize: 96, isSpinning: true }), jsxs("div", Object.assign({ className: 'default-prompt-modal__content' }, { children: [title && (jsx(Typography, Object.assign({ variant: 'title', color: 'primary', "data-testid": 'title' }, { children: title }))), children] }))] })) })));
|
|
44
37
|
|
|
45
|
-
export {
|
|
38
|
+
export { DefaultPromptModal };
|