@dynamic-labs/sdk-react-core 0.17.0-RC.13 → 0.17.0-RC.14
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 +14 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +8 -8
- package/src/lib/components/UserProfile/UserProfile.cjs +2 -2
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -7
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +9 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -7
- package/src/lib/data/api.cjs +2 -1
- package/src/lib/data/api.d.ts +1 -1
- package/src/lib/data/api.js +2 -1
- package/src/lib/shared/types/index.d.ts +6 -0
- package/src/lib/utils/functions/{getEnabledUserProfileFields/getEnabledUserProfileFields.cjs → getUserProfileFields/getUserProfileFields.cjs} +4 -0
- package/src/lib/utils/functions/{getEnabledUserProfileFields/getEnabledUserProfileFields.js → getUserProfileFields/getUserProfileFields.js} +4 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +2 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.d.ts +1 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +2 -0
- package/src/lib/utils/hooks/useKYCFlag/useKYCFlag.cjs +4 -4
- package/src/lib/utils/hooks/useKYCFlag/useKYCFlag.js +3 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +79 -44
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +4 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +80 -45
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +7 -10
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +7 -10
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +4 -1
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -1
- package/src/lib/utils/hooks/useWallets/useWallets.js +4 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs +4 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.js +4 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +11 -14
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.d.ts +2 -3
- package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +11 -14
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +0 -8
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.d.ts +0 -4
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -9
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchChain/useFetchChain.js +1 -1
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.d.ts +4 -3
- package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.js +2 -2
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +3 -5
- package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +3 -5
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +4 -4
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +2 -1
- /package/src/lib/utils/functions/{getEnabledUserProfileFields/getEnabledUserProfileFields.d.ts → getUserProfileFields/getUserProfileFields.d.ts} +0 -0
|
@@ -16,7 +16,7 @@ require('ethers');
|
|
|
16
16
|
require('../../../shared/consts/index.cjs');
|
|
17
17
|
|
|
18
18
|
const orderedSecondaryWalletAddresses = (wallets) => wallets.map((wallet) => wallet.address).sort();
|
|
19
|
-
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, setSelectedWalletConnector, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }) => {
|
|
19
|
+
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }) => {
|
|
20
20
|
const [loadingNetwork, setLoadingNetwork] = React.useState(true);
|
|
21
21
|
const [network, setNetwork] = React.useState(undefined);
|
|
22
22
|
React.useEffect(() => {
|
|
@@ -42,6 +42,51 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
const seen = new Set();
|
|
45
|
+
addPrimaryWalletEventListeners(seen);
|
|
46
|
+
addSecondaryWalletEventListeners(seen);
|
|
47
|
+
return () => {
|
|
48
|
+
primaryWallet.connector.teardownEventListeners();
|
|
49
|
+
for (const wallet of secondaryWallets) {
|
|
50
|
+
wallet.connector.teardownEventListeners();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// justification: we don't want to setup event listeners more than needed
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, [
|
|
56
|
+
user,
|
|
57
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address,
|
|
58
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
59
|
+
multiWalletWidgetState,
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
62
|
+
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
63
|
+
]);
|
|
64
|
+
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
65
|
+
const linkedSecondaryWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
66
|
+
// this means the user is linking a new account, so we need proof of ownership...
|
|
67
|
+
if (!linkedSecondaryWallet) {
|
|
68
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
69
|
+
if (isPrimaryWallet && primaryWallet) {
|
|
70
|
+
setSelectedWalletConnector(primaryWallet.connector);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
75
|
+
setSelectedWalletWithAction(null);
|
|
76
|
+
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
77
|
+
setMultiWalletWidgetState('idle');
|
|
78
|
+
}, [
|
|
79
|
+
setMultiWalletWidgetState,
|
|
80
|
+
primaryWallet,
|
|
81
|
+
secondaryWallets,
|
|
82
|
+
setSelectedWalletConnector,
|
|
83
|
+
setSelectedWalletWithAction,
|
|
84
|
+
setPrimaryWalletId,
|
|
85
|
+
]);
|
|
86
|
+
const addPrimaryWalletEventListeners = React.useCallback((seen) => {
|
|
87
|
+
if (!primaryWallet) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
45
90
|
seen.add(primaryWallet.connector.name);
|
|
46
91
|
primaryWallet.connector.setupEventListeners({
|
|
47
92
|
onAccountChange: (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -54,16 +99,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
54
99
|
yield handleLogOut();
|
|
55
100
|
}
|
|
56
101
|
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
57
|
-
|
|
58
|
-
// this means the user is linking a new account, so we need proof of ownership...
|
|
59
|
-
if (!linkedSecondaryWallet) {
|
|
60
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
61
|
-
setSelectedWalletConnector(primaryWallet.connector);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
65
|
-
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
66
|
-
setMultiWalletWidgetState('idle');
|
|
102
|
+
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
67
103
|
yield computeConnectedStateForWallets();
|
|
68
104
|
}
|
|
69
105
|
else if (multiWalletWidgetState === 'idle' &&
|
|
@@ -90,50 +126,49 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
90
126
|
}),
|
|
91
127
|
onDisconnect: handleLogOut,
|
|
92
128
|
});
|
|
129
|
+
}, [
|
|
130
|
+
primaryWallet,
|
|
131
|
+
setMultiWalletWidgetState,
|
|
132
|
+
multiWallet,
|
|
133
|
+
user,
|
|
134
|
+
computeConnectedStateForWallets,
|
|
135
|
+
handleLogOut,
|
|
136
|
+
connectWalletByAddressAndChain,
|
|
137
|
+
multiWalletWidgetState,
|
|
138
|
+
secondaryWallets,
|
|
139
|
+
setSelectedWalletConnector,
|
|
140
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
141
|
+
]);
|
|
142
|
+
const addSecondaryWalletEventListeners = React.useCallback((seen) => {
|
|
143
|
+
const secondaryListeners = {
|
|
144
|
+
onAccountChange: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
146
|
+
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
147
|
+
}
|
|
148
|
+
yield computeConnectedStateForWallets();
|
|
149
|
+
}),
|
|
150
|
+
onDisconnect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
+
yield computeConnectedStateForWallets();
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
93
154
|
if (selectedWalletConnector && !seen.has(selectedWalletConnector.name)) {
|
|
94
155
|
seen.add(selectedWalletConnector.name);
|
|
95
|
-
selectedWalletConnector.setupEventListeners(
|
|
96
|
-
onAccountChange: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
-
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
98
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
99
|
-
}
|
|
100
|
-
yield computeConnectedStateForWallets();
|
|
101
|
-
}),
|
|
102
|
-
onDisconnect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
yield computeConnectedStateForWallets();
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
156
|
+
selectedWalletConnector.setupEventListeners(secondaryListeners);
|
|
106
157
|
}
|
|
107
158
|
for (const wallet of secondaryWallets) {
|
|
108
159
|
if (seen.has(wallet.connector.name)) {
|
|
109
160
|
continue;
|
|
110
161
|
}
|
|
111
162
|
seen.add(wallet.connector.name);
|
|
112
|
-
wallet.connector.setupEventListeners(
|
|
113
|
-
onAccountChange: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
-
yield computeConnectedStateForWallets();
|
|
115
|
-
}),
|
|
116
|
-
onDisconnect: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
yield computeConnectedStateForWallets();
|
|
118
|
-
}),
|
|
119
|
-
});
|
|
163
|
+
wallet.connector.setupEventListeners(secondaryListeners);
|
|
120
164
|
}
|
|
121
|
-
return () => {
|
|
122
|
-
primaryWallet.connector.teardownEventListeners();
|
|
123
|
-
for (const wallet of secondaryWallets) {
|
|
124
|
-
wallet.connector.teardownEventListeners();
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
// justification: we don't want to setup event listeners more than needed
|
|
128
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
165
|
}, [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
166
|
+
computeConnectedStateForWallets,
|
|
167
|
+
selectedWalletConnector,
|
|
168
|
+
selectedWalletWithAction,
|
|
169
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
133
170
|
multiWalletWidgetState,
|
|
134
|
-
|
|
135
|
-
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
136
|
-
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
171
|
+
secondaryWallets,
|
|
137
172
|
]);
|
|
138
173
|
return {
|
|
139
174
|
loadingNetwork,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Chain, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { MultiWalletWidgetState, UserProfile, Wallet } from '../../../shared';
|
|
3
|
+
import { MultiWalletWidgetState, UserProfile, Wallet, WalletWithAction } from '../../../shared';
|
|
4
4
|
import { MultiWalletWidgetStateSetter } from '../multiWallet';
|
|
5
5
|
export type UseWalletEventListenersArgs = {
|
|
6
6
|
computeConnectedStateForWallets(): Promise<void>;
|
|
@@ -11,12 +11,14 @@ export type UseWalletEventListenersArgs = {
|
|
|
11
11
|
primaryWallet: Wallet | null;
|
|
12
12
|
secondaryWallets: Wallet[];
|
|
13
13
|
selectedWalletConnector: WalletConnector | null;
|
|
14
|
+
selectedWalletWithAction: WalletWithAction | null;
|
|
14
15
|
setMultiWalletWidgetState: MultiWalletWidgetStateSetter;
|
|
15
16
|
setPrimaryWalletId(walletId: string): void;
|
|
16
17
|
setSelectedWalletConnector(connector: WalletConnector | null): void;
|
|
18
|
+
setSelectedWalletWithAction(walletWithAction: WalletWithAction | null): void;
|
|
17
19
|
user: UserProfile | undefined;
|
|
18
20
|
};
|
|
19
|
-
export declare const useWalletEventListeners: ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, setSelectedWalletConnector, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }: UseWalletEventListenersArgs) => {
|
|
21
|
+
export declare const useWalletEventListeners: ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }: UseWalletEventListenersArgs) => {
|
|
20
22
|
loadingNetwork: boolean;
|
|
21
23
|
network: string | number | undefined;
|
|
22
24
|
setNetwork: import("react").Dispatch<import("react").SetStateAction<string | number | undefined>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -12,7 +12,7 @@ import 'ethers';
|
|
|
12
12
|
import '../../../shared/consts/index.js';
|
|
13
13
|
|
|
14
14
|
const orderedSecondaryWalletAddresses = (wallets) => wallets.map((wallet) => wallet.address).sort();
|
|
15
|
-
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, setSelectedWalletConnector, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }) => {
|
|
15
|
+
const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, connectWalletByAddressAndChain, }) => {
|
|
16
16
|
const [loadingNetwork, setLoadingNetwork] = useState(true);
|
|
17
17
|
const [network, setNetwork] = useState(undefined);
|
|
18
18
|
useEffect(() => {
|
|
@@ -38,6 +38,51 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const seen = new Set();
|
|
41
|
+
addPrimaryWalletEventListeners(seen);
|
|
42
|
+
addSecondaryWalletEventListeners(seen);
|
|
43
|
+
return () => {
|
|
44
|
+
primaryWallet.connector.teardownEventListeners();
|
|
45
|
+
for (const wallet of secondaryWallets) {
|
|
46
|
+
wallet.connector.teardownEventListeners();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
// justification: we don't want to setup event listeners more than needed
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, [
|
|
52
|
+
user,
|
|
53
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address,
|
|
54
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
55
|
+
multiWalletWidgetState,
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
58
|
+
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
59
|
+
]);
|
|
60
|
+
const handleAccountChangeWhenAwaitingAccountSwitch = useCallback((isPrimaryWallet, newAddress) => {
|
|
61
|
+
const linkedSecondaryWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
|
|
62
|
+
// this means the user is linking a new account, so we need proof of ownership...
|
|
63
|
+
if (!linkedSecondaryWallet) {
|
|
64
|
+
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
65
|
+
if (isPrimaryWallet && primaryWallet) {
|
|
66
|
+
setSelectedWalletConnector(primaryWallet.connector);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
71
|
+
setSelectedWalletWithAction(null);
|
|
72
|
+
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
73
|
+
setMultiWalletWidgetState('idle');
|
|
74
|
+
}, [
|
|
75
|
+
setMultiWalletWidgetState,
|
|
76
|
+
primaryWallet,
|
|
77
|
+
secondaryWallets,
|
|
78
|
+
setSelectedWalletConnector,
|
|
79
|
+
setSelectedWalletWithAction,
|
|
80
|
+
setPrimaryWalletId,
|
|
81
|
+
]);
|
|
82
|
+
const addPrimaryWalletEventListeners = useCallback((seen) => {
|
|
83
|
+
if (!primaryWallet) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
41
86
|
seen.add(primaryWallet.connector.name);
|
|
42
87
|
primaryWallet.connector.setupEventListeners({
|
|
43
88
|
onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -50,16 +95,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
50
95
|
yield handleLogOut();
|
|
51
96
|
}
|
|
52
97
|
else if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
53
|
-
|
|
54
|
-
// this means the user is linking a new account, so we need proof of ownership...
|
|
55
|
-
if (!linkedSecondaryWallet) {
|
|
56
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
57
|
-
setSelectedWalletConnector(primaryWallet.connector);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
// ...otherwise, the user is switching primary accounts betweeen the same wallet
|
|
61
|
-
setPrimaryWalletId(linkedSecondaryWallet.id);
|
|
62
|
-
setMultiWalletWidgetState('idle');
|
|
98
|
+
handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
|
|
63
99
|
yield computeConnectedStateForWallets();
|
|
64
100
|
}
|
|
65
101
|
else if (multiWalletWidgetState === 'idle' &&
|
|
@@ -86,50 +122,49 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
|
|
|
86
122
|
}),
|
|
87
123
|
onDisconnect: handleLogOut,
|
|
88
124
|
});
|
|
125
|
+
}, [
|
|
126
|
+
primaryWallet,
|
|
127
|
+
setMultiWalletWidgetState,
|
|
128
|
+
multiWallet,
|
|
129
|
+
user,
|
|
130
|
+
computeConnectedStateForWallets,
|
|
131
|
+
handleLogOut,
|
|
132
|
+
connectWalletByAddressAndChain,
|
|
133
|
+
multiWalletWidgetState,
|
|
134
|
+
secondaryWallets,
|
|
135
|
+
setSelectedWalletConnector,
|
|
136
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
137
|
+
]);
|
|
138
|
+
const addSecondaryWalletEventListeners = useCallback((seen) => {
|
|
139
|
+
const secondaryListeners = {
|
|
140
|
+
onAccountChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
+
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
142
|
+
handleAccountChangeWhenAwaitingAccountSwitch(false, (selectedWalletWithAction === null || selectedWalletWithAction === void 0 ? void 0 : selectedWalletWithAction.wallet.address) || '');
|
|
143
|
+
}
|
|
144
|
+
yield computeConnectedStateForWallets();
|
|
145
|
+
}),
|
|
146
|
+
onDisconnect: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
yield computeConnectedStateForWallets();
|
|
148
|
+
}),
|
|
149
|
+
};
|
|
89
150
|
if (selectedWalletConnector && !seen.has(selectedWalletConnector.name)) {
|
|
90
151
|
seen.add(selectedWalletConnector.name);
|
|
91
|
-
selectedWalletConnector.setupEventListeners(
|
|
92
|
-
onAccountChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
-
if (multiWalletWidgetState === 'awaiting_account_switch') {
|
|
94
|
-
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
95
|
-
}
|
|
96
|
-
yield computeConnectedStateForWallets();
|
|
97
|
-
}),
|
|
98
|
-
onDisconnect: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
yield computeConnectedStateForWallets();
|
|
100
|
-
}),
|
|
101
|
-
});
|
|
152
|
+
selectedWalletConnector.setupEventListeners(secondaryListeners);
|
|
102
153
|
}
|
|
103
154
|
for (const wallet of secondaryWallets) {
|
|
104
155
|
if (seen.has(wallet.connector.name)) {
|
|
105
156
|
continue;
|
|
106
157
|
}
|
|
107
158
|
seen.add(wallet.connector.name);
|
|
108
|
-
wallet.connector.setupEventListeners(
|
|
109
|
-
onAccountChange: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
yield computeConnectedStateForWallets();
|
|
111
|
-
}),
|
|
112
|
-
onDisconnect: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
yield computeConnectedStateForWallets();
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
159
|
+
wallet.connector.setupEventListeners(secondaryListeners);
|
|
116
160
|
}
|
|
117
|
-
return () => {
|
|
118
|
-
primaryWallet.connector.teardownEventListeners();
|
|
119
|
-
for (const wallet of secondaryWallets) {
|
|
120
|
-
wallet.connector.teardownEventListeners();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
// justification: we don't want to setup event listeners more than needed
|
|
124
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
161
|
}, [
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
162
|
+
computeConnectedStateForWallets,
|
|
163
|
+
selectedWalletConnector,
|
|
164
|
+
selectedWalletWithAction,
|
|
165
|
+
handleAccountChangeWhenAwaitingAccountSwitch,
|
|
129
166
|
multiWalletWidgetState,
|
|
130
|
-
|
|
131
|
-
orderedSecondaryWalletAddresses(secondaryWallets).join(),
|
|
132
|
-
selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.name,
|
|
167
|
+
secondaryWallets,
|
|
133
168
|
]);
|
|
134
169
|
return {
|
|
135
170
|
loadingNetwork,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
-
var React = require('react');
|
|
7
6
|
var utils = require('@dynamic-labs/utils');
|
|
8
7
|
var MockContext = require('../../../context/MockContext/MockContext.cjs');
|
|
9
8
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
@@ -16,6 +15,7 @@ require('../../../shared/logger.cjs');
|
|
|
16
15
|
require('@dynamic-labs/iconic');
|
|
17
16
|
require('@dynamic-labs/wallet-connector-core');
|
|
18
17
|
require('react/jsx-runtime');
|
|
18
|
+
require('react');
|
|
19
19
|
require('ethers');
|
|
20
20
|
var requiresTwoStepAuthentication = require('../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.cjs');
|
|
21
21
|
var useConnectAndSign = require('../authenticationHooks/useConnectAndSign/useConnectAndSign.cjs');
|
|
@@ -31,33 +31,30 @@ const useWalletItemActions = () => {
|
|
|
31
31
|
const { setView } = ViewContext.useViewContext();
|
|
32
32
|
const { onlyConnectUser } = useConnectAndSignSplitSteps.useConnectAndSignSplitSteps();
|
|
33
33
|
const connectAndSignWallet = useConnectAndSign.useConnectAndSign();
|
|
34
|
-
const setWalletConnectorAndWalletColor = React.useCallback((walletConnector) => {
|
|
35
|
-
setSelectedWalletConnector(walletConnector);
|
|
36
|
-
}, [setSelectedWalletConnector]);
|
|
37
34
|
const handleCustodialWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
35
|
const twoStepAuthentication = requiresTwoStepAuthentication.requiresTwoStepAuthentication(walletConnector);
|
|
39
36
|
if (twoStepAuthentication) {
|
|
40
|
-
|
|
37
|
+
setSelectedWalletConnector(walletConnector);
|
|
41
38
|
yield onlyConnectUser({
|
|
42
39
|
walletConnector,
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
else {
|
|
46
|
-
|
|
43
|
+
setSelectedWalletConnector(walletConnector);
|
|
47
44
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
48
45
|
}
|
|
49
46
|
setView('pending-signature');
|
|
50
47
|
});
|
|
51
48
|
const handleMobileWalletClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
|
|
49
|
+
setSelectedWalletConnector(walletConnector);
|
|
53
50
|
onlyConnectUser({ walletConnector });
|
|
54
51
|
});
|
|
55
52
|
const handleInstalledExtensionClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
|
|
53
|
+
setSelectedWalletConnector(walletConnector);
|
|
57
54
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
58
55
|
});
|
|
59
56
|
const handleUninstalledClick = (walletConnector) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
|
|
57
|
+
setSelectedWalletConnector(walletConnector);
|
|
61
58
|
if (!walletConnector.canConnectViaQrCode) {
|
|
62
59
|
setView('no-qr-not-installed');
|
|
63
60
|
}
|
|
@@ -87,7 +84,7 @@ const useWalletItemActions = () => {
|
|
|
87
84
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
88
85
|
}
|
|
89
86
|
setShowAuthFlow(false);
|
|
90
|
-
|
|
87
|
+
setSelectedWalletConnector(walletConnector);
|
|
91
88
|
});
|
|
92
89
|
const openWallet = (walletKey, handlers) => {
|
|
93
90
|
const { openMobileWallet = handleMobileWalletClick, openCustodialWallet = handleCustodialWalletClick, openExtensionWallet = handleInstalledExtensionClick, } = handlers || {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
2
|
import { isMobile } from '@dynamic-labs/utils';
|
|
4
3
|
import { useMockContext } from '../../../context/MockContext/MockContext.js';
|
|
5
4
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
@@ -12,6 +11,7 @@ import '../../../shared/logger.js';
|
|
|
12
11
|
import '@dynamic-labs/iconic';
|
|
13
12
|
import '@dynamic-labs/wallet-connector-core';
|
|
14
13
|
import 'react/jsx-runtime';
|
|
14
|
+
import 'react';
|
|
15
15
|
import 'ethers';
|
|
16
16
|
import { requiresTwoStepAuthentication } from '../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.js';
|
|
17
17
|
import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
|
|
@@ -27,33 +27,30 @@ const useWalletItemActions = () => {
|
|
|
27
27
|
const { setView } = useViewContext();
|
|
28
28
|
const { onlyConnectUser } = useConnectAndSignSplitSteps();
|
|
29
29
|
const connectAndSignWallet = useConnectAndSign();
|
|
30
|
-
const setWalletConnectorAndWalletColor = useCallback((walletConnector) => {
|
|
31
|
-
setSelectedWalletConnector(walletConnector);
|
|
32
|
-
}, [setSelectedWalletConnector]);
|
|
33
30
|
const handleCustodialWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
31
|
const twoStepAuthentication = requiresTwoStepAuthentication(walletConnector);
|
|
35
32
|
if (twoStepAuthentication) {
|
|
36
|
-
|
|
33
|
+
setSelectedWalletConnector(walletConnector);
|
|
37
34
|
yield onlyConnectUser({
|
|
38
35
|
walletConnector,
|
|
39
36
|
});
|
|
40
37
|
}
|
|
41
38
|
else {
|
|
42
|
-
|
|
39
|
+
setSelectedWalletConnector(walletConnector);
|
|
43
40
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
44
41
|
}
|
|
45
42
|
setView('pending-signature');
|
|
46
43
|
});
|
|
47
44
|
const handleMobileWalletClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
|
|
45
|
+
setSelectedWalletConnector(walletConnector);
|
|
49
46
|
onlyConnectUser({ walletConnector });
|
|
50
47
|
});
|
|
51
48
|
const handleInstalledExtensionClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
|
|
49
|
+
setSelectedWalletConnector(walletConnector);
|
|
53
50
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
54
51
|
});
|
|
55
52
|
const handleUninstalledClick = (walletConnector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
|
|
53
|
+
setSelectedWalletConnector(walletConnector);
|
|
57
54
|
if (!walletConnector.canConnectViaQrCode) {
|
|
58
55
|
setView('no-qr-not-installed');
|
|
59
56
|
}
|
|
@@ -83,7 +80,7 @@ const useWalletItemActions = () => {
|
|
|
83
80
|
setMultiWalletWidgetState('awaiting_signature', undefined, 'linking_new_wallet');
|
|
84
81
|
}
|
|
85
82
|
setShowAuthFlow(false);
|
|
86
|
-
|
|
83
|
+
setSelectedWalletConnector(walletConnector);
|
|
87
84
|
});
|
|
88
85
|
const openWallet = (walletKey, handlers) => {
|
|
89
86
|
const { openMobileWallet = handleMobileWalletClick, openCustodialWallet = handleCustodialWalletClick, openExtensionWallet = handleInstalledExtensionClick, } = handlers || {};
|
|
@@ -6,7 +6,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var data = require('../../../views/WalletList/data.cjs');
|
|
8
8
|
|
|
9
|
-
const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfigurations, walletUiUtils, walletConnectorsProp, }) => {
|
|
9
|
+
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletUiUtils, walletConnectorsProp, }) => {
|
|
10
10
|
const [wallets, setWallets] = React.useState([]);
|
|
11
11
|
React.useEffect(() => {
|
|
12
12
|
const getWalletList = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -15,6 +15,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
15
15
|
appLogoUrl,
|
|
16
16
|
appName,
|
|
17
17
|
customerApiProviders: projectSettings.providers || [],
|
|
18
|
+
flowNetwork,
|
|
18
19
|
networkConfigurations,
|
|
19
20
|
skipMemo: true,
|
|
20
21
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
@@ -24,6 +25,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
24
25
|
appLogoUrl,
|
|
25
26
|
appName,
|
|
26
27
|
customerApiProviders: projectSettings.providers || [],
|
|
28
|
+
flowNetwork,
|
|
27
29
|
networkConfigurations,
|
|
28
30
|
skipMemo: true,
|
|
29
31
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
@@ -45,6 +47,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
45
47
|
appName,
|
|
46
48
|
networkConfigurations,
|
|
47
49
|
walletConnectorsProp,
|
|
50
|
+
flowNetwork,
|
|
48
51
|
]);
|
|
49
52
|
return { wallets };
|
|
50
53
|
};
|
|
@@ -5,12 +5,13 @@ import { WalletOption } from '../../../shared';
|
|
|
5
5
|
type Props = {
|
|
6
6
|
appLogoUrl?: string;
|
|
7
7
|
appName?: string;
|
|
8
|
+
flowNetwork?: 'mainnet' | 'testnet';
|
|
8
9
|
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
9
10
|
projectSettings: ProjectSettings | undefined;
|
|
10
11
|
walletConnectorsProp?: WalletConnectorsMethod[];
|
|
11
12
|
walletUiUtils: WalletUiUtils;
|
|
12
13
|
};
|
|
13
|
-
export declare const useWallets: ({ projectSettings, appLogoUrl, appName, networkConfigurations, walletUiUtils, walletConnectorsProp, }: Props) => {
|
|
14
|
+
export declare const useWallets: ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletUiUtils, walletConnectorsProp, }: Props) => {
|
|
14
15
|
wallets: WalletOption[];
|
|
15
16
|
};
|
|
16
17
|
export {};
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { getInstalledWallets, getNotInstalledWallets } from '../../../views/WalletList/data.js';
|
|
4
4
|
|
|
5
|
-
const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfigurations, walletUiUtils, walletConnectorsProp, }) => {
|
|
5
|
+
const useWallets = ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletUiUtils, walletConnectorsProp, }) => {
|
|
6
6
|
const [wallets, setWallets] = useState([]);
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
const getWalletList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -11,6 +11,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
11
11
|
appLogoUrl,
|
|
12
12
|
appName,
|
|
13
13
|
customerApiProviders: projectSettings.providers || [],
|
|
14
|
+
flowNetwork,
|
|
14
15
|
networkConfigurations,
|
|
15
16
|
skipMemo: true,
|
|
16
17
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
@@ -20,6 +21,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
20
21
|
appLogoUrl,
|
|
21
22
|
appName,
|
|
22
23
|
customerApiProviders: projectSettings.providers || [],
|
|
24
|
+
flowNetwork,
|
|
23
25
|
networkConfigurations,
|
|
24
26
|
skipMemo: true,
|
|
25
27
|
walletConnectorsProp: walletConnectorsProp !== null && walletConnectorsProp !== void 0 ? walletConnectorsProp : [],
|
|
@@ -41,6 +43,7 @@ const useWallets = ({ projectSettings, appLogoUrl, appName, networkConfiguration
|
|
|
41
43
|
appName,
|
|
42
44
|
networkConfigurations,
|
|
43
45
|
walletConnectorsProp,
|
|
46
|
+
flowNetwork,
|
|
44
47
|
]);
|
|
45
48
|
return { wallets };
|
|
46
49
|
};
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
8
|
-
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
9
8
|
var DetectedKnownSecondaryWalletModal = require('../../prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.cjs');
|
|
10
9
|
var DetectedNewWalletModal = require('../../prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs');
|
|
11
10
|
var PendingAccountSwitchModal = require('../../prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs');
|
|
@@ -22,18 +21,18 @@ const mapAccountSwitchStateToPromptComponent = {
|
|
|
22
21
|
switching_primary: PendingAccountSwitchModal.PendingAccountSwitchModal,
|
|
23
22
|
};
|
|
24
23
|
const DynamicWidgetPrompts = () => {
|
|
25
|
-
|
|
26
|
-
const {
|
|
24
|
+
var _a, _b, _c;
|
|
25
|
+
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
27
26
|
const AccountSwitchModal = React.useMemo(() => {
|
|
28
27
|
if (multiWalletWidgetState !== 'awaiting_account_switch')
|
|
29
28
|
return null;
|
|
30
29
|
return mapAccountSwitchStateToPromptComponent[accountSwitchState] || null;
|
|
31
30
|
}, [accountSwitchState, multiWalletWidgetState]);
|
|
32
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [multiWalletWidgetState === 'awaiting_signature' && jsxRuntime.jsx(PendingSignModal.PendingSignModal, {}), AccountSwitchModal && jsxRuntime.jsx(AccountSwitchModal, {}),
|
|
31
|
+
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' &&
|
|
33
32
|
(showQrcodeModal ? (jsxRuntime.jsx(WidgetPortal.WidgetPortal, Object.assign({ onBackdropClick: () => {
|
|
34
33
|
setShowQrcodeModal(false);
|
|
35
34
|
setDesktopUri('');
|
|
36
|
-
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsxRuntime.jsx(QrCodeModalView.QrCodeModalView, { walletId:
|
|
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(PendingSignModal.PendingSignModal, {}))), multiWalletWidgetState === 'detected_known_secondary_wallet' && (jsxRuntime.jsx(DetectedKnownSecondaryWalletModal.DetectedKnownSecondaryWalletModal, { setSelectedWalletWithAction: setSelectedWalletWithAction })), multiWalletWidgetState === 'detected_new_wallet' && (jsxRuntime.jsx(DetectedNewWalletModal.DetectedNewWalletModal, {}))] }));
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
exports.DynamicWidgetPrompts = DynamicWidgetPrompts;
|
package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
4
|
-
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
5
4
|
import { DetectedKnownSecondaryWalletModal } from '../../prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.js';
|
|
6
5
|
import { DetectedNewWalletModal } from '../../prompts/DetectedNewWalletModal/DetectedNewWalletModal.js';
|
|
7
6
|
import { PendingAccountSwitchModal } from '../../prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js';
|
|
@@ -18,18 +17,18 @@ const mapAccountSwitchStateToPromptComponent = {
|
|
|
18
17
|
switching_primary: PendingAccountSwitchModal,
|
|
19
18
|
};
|
|
20
19
|
const DynamicWidgetPrompts = () => {
|
|
21
|
-
|
|
22
|
-
const {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
const { setDesktopUri, accountSwitchState, multiWalletWidgetState, showQrcodeModal, setShowQrcodeModal, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletWithAction, } = useInternalDynamicContext();
|
|
23
22
|
const AccountSwitchModal = useMemo(() => {
|
|
24
23
|
if (multiWalletWidgetState !== 'awaiting_account_switch')
|
|
25
24
|
return null;
|
|
26
25
|
return mapAccountSwitchStateToPromptComponent[accountSwitchState] || null;
|
|
27
26
|
}, [accountSwitchState, multiWalletWidgetState]);
|
|
28
|
-
return (jsxs(Fragment, { children: [multiWalletWidgetState === 'awaiting_signature' && jsx(PendingSignModal, {}), AccountSwitchModal && jsx(AccountSwitchModal, {}),
|
|
27
|
+
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' &&
|
|
29
28
|
(showQrcodeModal ? (jsx(WidgetPortal, Object.assign({ onBackdropClick: () => {
|
|
30
29
|
setShowQrcodeModal(false);
|
|
31
30
|
setDesktopUri('');
|
|
32
|
-
} }, { children: (selectedWalletConnector === null || selectedWalletConnector === void 0 ? void 0 : selectedWalletConnector.canConnectViaQrCode) ? (jsx(QrCodeModalView, { walletId:
|
|
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(PendingSignModal, {}))), multiWalletWidgetState === 'detected_known_secondary_wallet' && (jsx(DetectedKnownSecondaryWalletModal, { setSelectedWalletWithAction: setSelectedWalletWithAction })), multiWalletWidgetState === 'detected_new_wallet' && (jsx(DetectedNewWalletModal, {}))] }));
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
export { DynamicWidgetPrompts };
|