@getpara/react-sdk 1.6.1-dev.0 → 1.7.0
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/dist/{modal/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/index.js +6657 -6
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.d.ts +1 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +2 -1
- package/dist/modal/components/common.d.ts +4 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +13 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +11 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +15 -1
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +11 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +2 -0
- package/dist/modal/types/commonTypes.d.ts +12 -2
- package/dist/modal/types/externalWallets.d.ts +2 -0
- package/dist/modal/types/modalProps.d.ts +6 -0
- package/dist/modal/utils/steps.d.ts +2 -0
- package/dist/provider/utils/constants.d.ts +5 -0
- package/package.json +5 -5
- package/dist/modal/ParaModal.js +0 -337
- package/dist/modal/components/Account/Account.js +0 -69
- package/dist/modal/components/AddFunds/AddFunds.js +0 -220
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
- package/dist/modal/components/AddFunds/index.js +0 -4
- package/dist/modal/components/AuthInput/AuthInput.js +0 -283
- package/dist/modal/components/AuthInput/countryCodes.js +0 -42
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -52
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
- package/dist/modal/components/Body/Body.js +0 -304
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
- package/dist/modal/components/ChainSwitch/config.js +0 -17
- package/dist/modal/components/Controls/Controls.js +0 -74
- package/dist/modal/components/Controls/Selects.js +0 -213
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -151
- package/dist/modal/components/ExternalWalletStep/config.js +0 -17
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -123
- package/dist/modal/components/Footer/Footer.js +0 -93
- package/dist/modal/components/Header/Header.js +0 -43
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
- package/dist/modal/components/Hero/Hero.js +0 -122
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
- package/dist/modal/components/ModalContent/ModalContent.js +0 -310
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -153
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
- package/dist/modal/components/Waiting/Waiting.js +0 -17
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
- package/dist/modal/components/WalletCard/WalletCard.js +0 -127
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
- package/dist/modal/components/common.js +0 -83
- package/dist/modal/components/index.js +0 -2
- package/dist/modal/constants/constants.js +0 -111
- package/dist/modal/constants/defaults.js +0 -10
- package/dist/modal/constants/oAuthLogos.js +0 -24
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.js +0 -72
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -39
- package/dist/modal/hooks/useGoBack.js +0 -35
- package/dist/modal/hooks/useSetLoginURLs.js +0 -45
- package/dist/modal/index.js +0 -32
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -34
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/ExternalWalletContext.js +0 -275
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -19
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -20
- package/dist/modal/stores/index.js +0 -4
- package/dist/modal/stores/modal/actions.js +0 -70
- package/dist/modal/stores/modal/useModalStore.js +0 -65
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -31
- package/dist/modal/types/modalProps.js +0 -12
- package/dist/modal/utils/authLayoutHelpers.js +0 -8
- package/dist/modal/utils/getMailtoLink.js +0 -10
- package/dist/modal/utils/getTileButtonFlex.js +0 -20
- package/dist/modal/utils/openPopup.js +0 -60
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
- package/dist/modal/utils/steps.js +0 -228
- package/dist/modal/utils/stringFormatters.js +0 -14
- package/dist/modal/utils/validateOnRampConfig.js +0 -32
- package/dist/provider/ParaProvider.js +0 -22
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getAccount.js +0 -22
- package/dist/provider/actions/getWallet.js +0 -14
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/index.js +0 -4
- package/dist/provider/hooks/mutations/index.js +0 -24
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- package/dist/provider/hooks/queries/index.js +0 -8
- package/dist/provider/hooks/queries/useAccount.js +0 -21
- package/dist/provider/hooks/queries/useWallet.js +0 -22
- package/dist/provider/hooks/utils/index.js +0 -10
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
- package/dist/provider/hooks/utils/useClient.js +0 -10
- package/dist/provider/hooks/utils/useEventListeners.js +0 -105
- package/dist/provider/hooks/utils/useInternalClient.js +0 -10
- package/dist/provider/hooks/utils/useModal.js +0 -17
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -8
- package/dist/provider/stores/getters.js +0 -13
- package/dist/provider/stores/slices/client.js +0 -9
- package/dist/provider/stores/slices/index.js +0 -4
- package/dist/provider/stores/slices/modal.js +0 -9
- package/dist/provider/stores/slices/wallet.js +0 -11
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -27
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/renameMutations.js +0 -16
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async,
|
|
4
|
-
__spreadProps,
|
|
5
|
-
__spreadValues
|
|
6
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { CpslIdenticon, CpslSelect, CpslSelectItem, CpslText } from "@getpara/react-components";
|
|
9
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
10
|
-
import styled from "styled-components";
|
|
11
|
-
import { useThemeStore } from "../../stores/index.js";
|
|
12
|
-
import { truncateAddress, WalletType } from "@getpara/web-sdk";
|
|
13
|
-
import { useEffect, useRef } from "react";
|
|
14
|
-
import { useDropdownPosition } from "../AuthInput/hooks/useDropdownPosition.js";
|
|
15
|
-
import { MOBILE_SIZE } from "../../constants/constants.js";
|
|
16
|
-
import { useActiveWallet } from "../../hooks/useActiveWallet.js";
|
|
17
|
-
import { useWalletState } from "../../../provider/index.js";
|
|
18
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
19
|
-
const getValue = (id, type) => {
|
|
20
|
-
return id && type ? `${id}~${type}` : void 0;
|
|
21
|
-
};
|
|
22
|
-
const WALLET_TYPES = {
|
|
23
|
-
[WalletType.EVM]: "EVM",
|
|
24
|
-
[WalletType.SOLANA]: "Solana",
|
|
25
|
-
[WalletType.COSMOS]: "Cosmos"
|
|
26
|
-
};
|
|
27
|
-
const ChainSelect = () => {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
const containerRef = useRef(null);
|
|
30
|
-
const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
|
|
31
|
-
const activeWallet = useActiveWallet();
|
|
32
|
-
const { switchChain, chainId, chains, chainIdSwitchingTo } = useExternalWallets();
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (dropdownMaxHeight && chainId) {
|
|
35
|
-
resize();
|
|
36
|
-
}
|
|
37
|
-
}, [chainId, chainIdSwitchingTo, dropdownMaxHeight]);
|
|
38
|
-
const handleChainChange = (chainId2) => __async(void 0, null, function* () {
|
|
39
|
-
yield switchChain(chainId2);
|
|
40
|
-
});
|
|
41
|
-
if (!activeWallet || !activeWallet.isExternal || activeWallet.type === WalletType.SOLANA) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
const chainIdToUse = chainIdSwitchingTo != null ? chainIdSwitchingTo : chainId;
|
|
45
|
-
const selectedChainName = (_a = chains.find((c) => c.id.toString() === chainIdToUse)) == null ? void 0 : _a.name;
|
|
46
|
-
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "inputContainer", children: /* @__PURE__ */ jsxs(
|
|
47
|
-
StyledSelect,
|
|
48
|
-
{
|
|
49
|
-
selectedValue: (_b = chainIdToUse == null ? void 0 : chainIdToUse.toString()) != null ? _b : "",
|
|
50
|
-
onCpslSelectValueChange: (e) => {
|
|
51
|
-
handleChainChange(e.detail);
|
|
52
|
-
},
|
|
53
|
-
showFormattedSelectedItem: true,
|
|
54
|
-
placeholder: "Choose chain...",
|
|
55
|
-
anchorElId: "inputContainer",
|
|
56
|
-
dropdownMaxHeight,
|
|
57
|
-
$width: dropdownWidth,
|
|
58
|
-
$top: mobileAnchor + 16 + 1,
|
|
59
|
-
autoWidth: true,
|
|
60
|
-
selectedItemVariant: "bodyXS",
|
|
61
|
-
children: [
|
|
62
|
-
chainIdToUse && /* @__PURE__ */ jsx(ChainName, { variant: "bodyXS", color: "contrast", slot: "selected-item", children: selectedChainName }),
|
|
63
|
-
chains == null ? void 0 : chains.map((chain) => /* @__PURE__ */ jsx(StyledSelectItem, { slot: "items", value: chain.id.toString(), children: /* @__PURE__ */ jsx(ChainName, { variant: "bodyXS", color: "contrast", children: chain.name }) }, chain.id))
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
) }) });
|
|
67
|
-
};
|
|
68
|
-
function getName(para, {
|
|
69
|
-
type,
|
|
70
|
-
isExternal,
|
|
71
|
-
name,
|
|
72
|
-
isMenu = false,
|
|
73
|
-
hideWallets = false
|
|
74
|
-
}) {
|
|
75
|
-
if (para.isMultiWallet) {
|
|
76
|
-
return name != null ? name : `${isExternal ? "External " : ""}${WALLET_TYPES[type]}${!hideWallets && (isMenu || isExternal) ? " Wallet" : ""}`;
|
|
77
|
-
}
|
|
78
|
-
return hideWallets ? "My Account" : name || "My Wallet";
|
|
79
|
-
}
|
|
80
|
-
const AccountSelect = () => {
|
|
81
|
-
var _a;
|
|
82
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
83
|
-
const para = useInternalClient();
|
|
84
|
-
const containerRef = useRef(null);
|
|
85
|
-
const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
|
|
86
|
-
const { setSelectedWallet } = useWalletState();
|
|
87
|
-
const activeWallet = useActiveWallet();
|
|
88
|
-
const ActiveWalletNode = activeWallet ? /* @__PURE__ */ jsxs(FlexRow, { slot: "selected-item", children: [
|
|
89
|
-
/* @__PURE__ */ jsx(CpslIdenticon, { variant: "avatar", size: "14px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }),
|
|
90
|
-
/* @__PURE__ */ jsx(WalletName, { variant: "bodyXS", color: "contrast", children: getName(para, __spreadProps(__spreadValues({}, activeWallet), { hideWallets })) }),
|
|
91
|
-
!hideWallets && /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: (_a = activeWallet.ensName) != null ? _a : para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) })
|
|
92
|
-
] }) : null;
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (dropdownMaxHeight && (activeWallet == null ? void 0 : activeWallet.address)) {
|
|
95
|
-
resize();
|
|
96
|
-
}
|
|
97
|
-
}, [activeWallet, para.availableWallets, dropdownMaxHeight]);
|
|
98
|
-
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: para.availableWallets.length > 1 ? /* @__PURE__ */ jsxs(
|
|
99
|
-
StyledSelect,
|
|
100
|
-
{
|
|
101
|
-
selectedValue: getValue(activeWallet == null ? void 0 : activeWallet.id, activeWallet == null ? void 0 : activeWallet.type),
|
|
102
|
-
onCpslSelectValueChange: (e) => {
|
|
103
|
-
const [id, type] = e.detail.split("~");
|
|
104
|
-
setSelectedWallet({ id, type });
|
|
105
|
-
},
|
|
106
|
-
showFormattedSelectedItem: true,
|
|
107
|
-
placeholder: "Choose wallet...",
|
|
108
|
-
anchorElId: "addressInputContainer",
|
|
109
|
-
dropdownMaxHeight,
|
|
110
|
-
$width: dropdownWidth,
|
|
111
|
-
$top: mobileAnchor + 16 + 1,
|
|
112
|
-
autoWidth: true,
|
|
113
|
-
selectedItemVariant: "bodyXS",
|
|
114
|
-
children: [
|
|
115
|
-
activeWallet && ActiveWalletNode,
|
|
116
|
-
para.availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
|
|
117
|
-
const key = getValue(id, type);
|
|
118
|
-
const name = _name != null ? _name : getName(para, { type, isExternal, isMenu: true, hideWallets });
|
|
119
|
-
return /* @__PURE__ */ jsx(StyledSelectItem, { slot: "items", value: key, children: /* @__PURE__ */ jsxs(FlexRow, { children: [
|
|
120
|
-
/* @__PURE__ */ jsx(CpslIdenticon, { size: "40px", hash: para.getIdenticonHash(id, type) }),
|
|
121
|
-
/* @__PURE__ */ jsxs(FlexCol, { children: [
|
|
122
|
-
name && /* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "contrast", children: name }),
|
|
123
|
-
!hideWallets && /* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", children: truncateAddress(address, type, { prefix: para.cosmosPrefix }) })
|
|
124
|
-
] })
|
|
125
|
-
] }) }, key);
|
|
126
|
-
})
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
) : ActiveWalletNode }) });
|
|
130
|
-
};
|
|
131
|
-
const Container = styled.div`
|
|
132
|
-
flex: 0;
|
|
133
|
-
width: 100%;
|
|
134
|
-
display: flex;
|
|
135
|
-
justify-content: center;
|
|
136
|
-
`;
|
|
137
|
-
const FlexRow = styled.div`
|
|
138
|
-
display: flex;
|
|
139
|
-
align-items: center;
|
|
140
|
-
gap: 8px;
|
|
141
|
-
`;
|
|
142
|
-
const FlexCol = styled.div`
|
|
143
|
-
display: flex;
|
|
144
|
-
flex-direction: column;
|
|
145
|
-
align-items: flex-start;
|
|
146
|
-
`;
|
|
147
|
-
const WalletName = styled(CpslText)`
|
|
148
|
-
white-space: nowrap;
|
|
149
|
-
`;
|
|
150
|
-
const SelectContainer = styled.div`
|
|
151
|
-
position: relative;
|
|
152
|
-
display: flex;
|
|
153
|
-
align-items: center;
|
|
154
|
-
gap: 8px;
|
|
155
|
-
border-radius: 1000px;
|
|
156
|
-
background-color: var(--cpsl-color-background-8);
|
|
157
|
-
padding: 8px;
|
|
158
|
-
`;
|
|
159
|
-
const ChainName = styled(CpslText)`
|
|
160
|
-
max-width: 150px;
|
|
161
|
-
text-transform: capitalize;
|
|
162
|
-
|
|
163
|
-
&::part(text-element) {
|
|
164
|
-
white-space: nowrap;
|
|
165
|
-
text-overflow: ellipsis;
|
|
166
|
-
overflow: hidden;
|
|
167
|
-
}
|
|
168
|
-
`;
|
|
169
|
-
const StyledSelect = styled(CpslSelect)`
|
|
170
|
-
--container-height: auto;
|
|
171
|
-
--container-border-width: 0px;
|
|
172
|
-
--container-padding-end: 0px;
|
|
173
|
-
--container-padding-start: 0px;
|
|
174
|
-
--container-background-color: transparent;
|
|
175
|
-
--container-box-shadow: none;
|
|
176
|
-
--container-gap: 2px;
|
|
177
|
-
--icon-width: 16px;
|
|
178
|
-
--icon-height: 16px;
|
|
179
|
-
|
|
180
|
-
&::part(selected-text) {
|
|
181
|
-
white-space: nowrap;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
&::part(dropdown) {
|
|
185
|
-
min-width: ${({ $width }) => `${$width - 2}px`};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
&::part(popover) {
|
|
189
|
-
/* Have to adjust the top of the popover here since we're using a transform on the modal which causes fixed position items to not be relative to the viewport */
|
|
190
|
-
@media (max-width: ${MOBILE_SIZE}px) {
|
|
191
|
-
top: ${({ $top }) => $top ? `${$top}px` : "0px"};
|
|
192
|
-
bottom: 16px;
|
|
193
|
-
}
|
|
194
|
-
cpsl-auth-modal.force-mobile-media & {
|
|
195
|
-
top: ${({ $top }) => $top ? `${$top}px` : "0px"};
|
|
196
|
-
bottom: 16px;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
&::part(icon) {
|
|
201
|
-
--icon-color: var(--cpsl-color-contrast);
|
|
202
|
-
}
|
|
203
|
-
`;
|
|
204
|
-
const StyledSelectItem = styled(CpslSelectItem)`
|
|
205
|
-
--outer-container-padding-start: 4px;
|
|
206
|
-
--outer-container-padding-end: 4px;
|
|
207
|
-
--outer-container-padding-top: 4px;
|
|
208
|
-
--outer-container-padding-bottom: 4px;
|
|
209
|
-
`;
|
|
210
|
-
export {
|
|
211
|
-
AccountSelect,
|
|
212
|
-
ChainSelect
|
|
213
|
-
};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
7
|
-
import { CenteredText, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
|
|
8
|
-
import { useEffect, useMemo } from "react";
|
|
9
|
-
import { useModalStore } from "../../stores/index.js";
|
|
10
|
-
import styled from "styled-components";
|
|
11
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
12
|
-
import { useCopyToClipboard } from "@getpara/react-common";
|
|
13
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
14
|
-
import { isMobile, isTablet, WalletType } from "@getpara/web-sdk";
|
|
15
|
-
import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
|
|
16
|
-
const ExternalWalletStep = () => {
|
|
17
|
-
const [isCopied, copy] = useCopyToClipboard();
|
|
18
|
-
const externalWalletError = useModalStore((state) => state.externalWalletError);
|
|
19
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
20
|
-
const { connectExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
routeMobileExternalWallet(qrUri);
|
|
23
|
-
}, [qrUri]);
|
|
24
|
-
const handleTryAgainClick = () => __async(void 0, null, function* () {
|
|
25
|
-
yield connectExternalWallet(wallet);
|
|
26
|
-
});
|
|
27
|
-
const handleCopy = () => {
|
|
28
|
-
copy(qrUri);
|
|
29
|
-
};
|
|
30
|
-
const Content = useMemo(() => {
|
|
31
|
-
var _a, _b, _c;
|
|
32
|
-
if (!wallet) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const isWalletConnect = wallet.id === "walletConnect";
|
|
36
|
-
const isMobileWalletConnect = isMobile() && isWalletConnect;
|
|
37
|
-
if (isMobileWalletConnect) {
|
|
38
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: "Continue in the WalletConnect modal." }) });
|
|
39
|
-
}
|
|
40
|
-
const { showExtension, showMobile, isSolanaMobileIOS } = walletDisplayHelpers;
|
|
41
|
-
if (!showMobile && !showExtension || isSolanaMobileIOS && !wallet.installed) {
|
|
42
|
-
const text = isSolanaMobileIOS ? "Solana wallets aren't available on mobile IOS browsers.\n\nPlease continue in the wallet app." : `${wallet.name} isn't supported on mobile devices.
|
|
43
|
-
|
|
44
|
-
Please choose another wallet or continue on desktop.`;
|
|
45
|
-
return /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: text }) });
|
|
46
|
-
}
|
|
47
|
-
if (showExtension) {
|
|
48
|
-
const isInstalled = wallet.installed;
|
|
49
|
-
return /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
50
|
-
isInstalled && !(externalWalletError == null ? void 0 : externalWalletError.length) ? /* @__PURE__ */ jsx(CenteredText, { color: "contrast", weight: "semiBold", children: `Confirm connection request in the ${wallet.name} browser extension.` }) : /* @__PURE__ */ jsxs(ErrorContainer, { children: [
|
|
51
|
-
/* @__PURE__ */ jsx(ErrorIcon, { icon: "alertCircle" }),
|
|
52
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: isInstalled ? externalWalletError == null ? void 0 : externalWalletError[0] : `${wallet.name} not detected` })
|
|
53
|
-
] }),
|
|
54
|
-
/* @__PURE__ */ jsxs(
|
|
55
|
-
CpslButton,
|
|
56
|
-
{
|
|
57
|
-
as: isInstalled ? "button" : "a",
|
|
58
|
-
href: (_a = wallet.downloadUrl) != null ? _a : "",
|
|
59
|
-
target: "_blank",
|
|
60
|
-
variant: "secondary",
|
|
61
|
-
onClick: handleTryAgainClick,
|
|
62
|
-
children: [
|
|
63
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isInstalled ? "refresh" : "linkExternal" }),
|
|
64
|
-
isInstalled ? "Try Again" : `Get ${wallet.name}`
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
)
|
|
68
|
-
] });
|
|
69
|
-
}
|
|
70
|
-
if (showMobile) {
|
|
71
|
-
if (wallet.type === WalletType.SOLANA || isMobile() && !isTablet()) {
|
|
72
|
-
const isInstalled = wallet.type !== WalletType.SOLANA || wallet.installed;
|
|
73
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
74
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: !isInstalled && /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: `${wallet.name} not detected` }) }),
|
|
75
|
-
wallet.id !== "walletConnect" && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
76
|
-
/* @__PURE__ */ jsx(CpslButton, { onClick: () => routeMobileExternalWallet(qrUri), fullWidth: true, children: "Connect Wallet" }),
|
|
77
|
-
/* @__PURE__ */ jsx(Link, { href: (_b = wallet.downloadUrl) != null ? _b : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", children: [
|
|
78
|
-
`Get ${wallet.name}`,
|
|
79
|
-
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
80
|
-
] }) })
|
|
81
|
-
] })
|
|
82
|
-
] });
|
|
83
|
-
}
|
|
84
|
-
const openWCModal = () => __async(void 0, null, function* () {
|
|
85
|
-
yield connectExternalWallet(wallet, true, true);
|
|
86
|
-
});
|
|
87
|
-
const GetWalletButton = /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", onClick: isWalletConnect ? openWCModal : void 0, children: [
|
|
88
|
-
`${isWalletConnect ? "Open" : "Get"} ${wallet.name}`,
|
|
89
|
-
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
90
|
-
] });
|
|
91
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
93
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }),
|
|
94
|
-
/* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
|
|
95
|
-
/* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
|
|
96
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
|
|
97
|
-
isCopied ? "Copied" : "Copy Link"
|
|
98
|
-
] })
|
|
99
|
-
] }),
|
|
100
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: isWalletConnect ? /* @__PURE__ */ jsx(Fragment, { children: GetWalletButton }) : /* @__PURE__ */ jsx(Link, { href: (_c = wallet.downloadUrl) != null ? _c : "", target: "_blank", children: GetWalletButton }) })
|
|
101
|
-
] });
|
|
102
|
-
}
|
|
103
|
-
}, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
if (!wallet) {
|
|
106
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
107
|
-
}
|
|
108
|
-
}, [wallet]);
|
|
109
|
-
if (!wallet) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return /* @__PURE__ */ jsx(Container, { children: Content });
|
|
113
|
-
};
|
|
114
|
-
const Container = styled(StepContainer)`
|
|
115
|
-
flex: 1;
|
|
116
|
-
justify-content: space-between;
|
|
117
|
-
`;
|
|
118
|
-
const ErrorContainer = styled.div`
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
gap: 4px;
|
|
123
|
-
`;
|
|
124
|
-
const ErrorIcon = styled(CpslIcon)`
|
|
125
|
-
--height: 16px;
|
|
126
|
-
--width: 16px;
|
|
127
|
-
--icon-color: var(--cpsl-color-text-error);
|
|
128
|
-
`;
|
|
129
|
-
const Text = styled(CenteredText)`
|
|
130
|
-
white-space: pre-line;
|
|
131
|
-
`;
|
|
132
|
-
const ExternalButton = styled(CpslButton)`
|
|
133
|
-
display: flex;
|
|
134
|
-
gap: 8px;
|
|
135
|
-
align-items: center;
|
|
136
|
-
justify-content: center;
|
|
137
|
-
width: 100%;
|
|
138
|
-
cursor: pointer;
|
|
139
|
-
margin-top: 8px;
|
|
140
|
-
text-decoration: none;
|
|
141
|
-
`;
|
|
142
|
-
const ExternalIcon = styled(CpslIcon)`
|
|
143
|
-
--height: 20px;
|
|
144
|
-
--width: 20px;
|
|
145
|
-
`;
|
|
146
|
-
const Link = styled.a`
|
|
147
|
-
text-decoration: none;
|
|
148
|
-
`;
|
|
149
|
-
export {
|
|
150
|
-
ExternalWalletStep
|
|
151
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
var TabValue = /* @__PURE__ */ ((TabValue2) => {
|
|
4
|
-
TabValue2["extension"] = "extension";
|
|
5
|
-
TabValue2["mobile"] = "mobile";
|
|
6
|
-
TabValue2["web"] = "web";
|
|
7
|
-
return TabValue2;
|
|
8
|
-
})(TabValue || {});
|
|
9
|
-
const TABS = {
|
|
10
|
-
extension: { label: "Extension", value: "extension" /* extension */, icon: "puzzlePiece" },
|
|
11
|
-
mobile: { label: "Mobile", value: "mobile" /* mobile */, icon: "phone" },
|
|
12
|
-
web: { label: "Web", value: "web" /* web */, icon: "globe" }
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
TABS,
|
|
16
|
-
TabValue
|
|
17
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
8
|
-
import { StyledCpslTileButton } from "../common.js";
|
|
9
|
-
import { CpslButton, CpslIcon, CpslInput, CpslText } from "@getpara/react-components";
|
|
10
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
11
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
12
|
-
import { useState } from "react";
|
|
13
|
-
import { hasEmbeddedAuth } from "../../utils/authLayoutHelpers.js";
|
|
14
|
-
const HAS_MORE_LENGTH = 3;
|
|
15
|
-
const ExternalWallets = () => {
|
|
16
|
-
const { wallets, connectExternalWallet } = useExternalWallets();
|
|
17
|
-
const setSelectedExternalWalletId = useModalStore((state) => state.setSelectedExternalWalletId);
|
|
18
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
19
|
-
const showAll = useModalStore((state) => state.step === ModalStep.EX_WALLET_MORE);
|
|
20
|
-
const authLayout = useThemeStore((state) => state.authLayout);
|
|
21
|
-
const [search, setSearch] = useState("");
|
|
22
|
-
const hasMore = wallets.length > HAS_MORE_LENGTH;
|
|
23
|
-
const walletsToShow = showAll || !hasMore ? search ? wallets.filter((w) => w.name.toLowerCase().includes(search.toLowerCase())) : wallets : wallets.slice(0, HAS_MORE_LENGTH);
|
|
24
|
-
const showMoreButton = !showAll && hasMore;
|
|
25
|
-
const handleShowAll = () => {
|
|
26
|
-
setStep(ModalStep.EX_WALLET_MORE);
|
|
27
|
-
};
|
|
28
|
-
const handleParaClick = () => {
|
|
29
|
-
setStep(ModalStep.AUTH_MORE);
|
|
30
|
-
};
|
|
31
|
-
const handleWalletClick = (wallet) => () => {
|
|
32
|
-
setSelectedExternalWalletId(wallet.id);
|
|
33
|
-
setStep(ModalStep.EX_WALLET_SELECTED);
|
|
34
|
-
if (wallet.installed) {
|
|
35
|
-
connectExternalWallet(wallet);
|
|
36
|
-
} else if (wallet.isMobile) {
|
|
37
|
-
connectExternalWallet(wallet, true);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return /* @__PURE__ */ jsxs(Container, { $maxHeight: showAll, children: [
|
|
41
|
-
showAll && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
-
/* @__PURE__ */ jsx(SearchInputWrapper, { children: /* @__PURE__ */ jsx(
|
|
43
|
-
SearchInput,
|
|
44
|
-
{
|
|
45
|
-
placeholder: "Search for your wallet",
|
|
46
|
-
onCpslInput: (e) => __async(void 0, null, function* () {
|
|
47
|
-
setSearch(e.target.value);
|
|
48
|
-
}),
|
|
49
|
-
value: search,
|
|
50
|
-
style: { width: "100%" },
|
|
51
|
-
children: /* @__PURE__ */ jsx(SearchIcon, { slot: "start", icon: "search" })
|
|
52
|
-
}
|
|
53
|
-
) }),
|
|
54
|
-
hasEmbeddedAuth(authLayout) && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleParaClick, children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
|
|
55
|
-
/* @__PURE__ */ jsxs(WalletButtonInnerContainer, { children: [
|
|
56
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "paraIcon" }),
|
|
57
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "medium", children: "Para" })
|
|
58
|
-
] }),
|
|
59
|
-
/* @__PURE__ */ jsx(Badge, { $show: true, $variant: "installed", children: /* @__PURE__ */ jsx(CpslText, { variant: "body2XS", weight: "medium", children: "Available" }) })
|
|
60
|
-
] }) })
|
|
61
|
-
] }),
|
|
62
|
-
walletsToShow.map(
|
|
63
|
-
(wallet) => showAll ? /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, variant: "tertiary", onClick: handleWalletClick(wallet), children: /* @__PURE__ */ jsxs(WalletButtonOuterContainer, { children: [
|
|
64
|
-
/* @__PURE__ */ jsxs(WalletButtonInnerContainer, { children: [
|
|
65
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", src: wallet.iconUrl }),
|
|
66
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "medium", children: wallet.name })
|
|
67
|
-
] }),
|
|
68
|
-
/* @__PURE__ */ jsx(Badge, { $show: wallet.isMobile || wallet.installed, $variant: wallet.installed ? "installed" : "mobile", children: /* @__PURE__ */ jsx(CpslText, { variant: "body2XS", weight: "medium", children: wallet.installed ? "Installed" : "Mobile" }) })
|
|
69
|
-
] }) }, wallet.id) : /* @__PURE__ */ jsx(WalletTileButton, { src: wallet.iconUrl, onClick: handleWalletClick(wallet), children: /* @__PURE__ */ jsxs(TileButtonInnerContainer, { children: [
|
|
70
|
-
wallet.installed && /* @__PURE__ */ jsx(InstalledIndicator, {}),
|
|
71
|
-
/* @__PURE__ */ jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: wallet.name })
|
|
72
|
-
] }) }, wallet.id)
|
|
73
|
-
),
|
|
74
|
-
showMoreButton && /* @__PURE__ */ jsxs(CpslButton, { variant: "tertiary", fullWidth: true, onClick: handleShowAll, children: [
|
|
75
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "wallet" }),
|
|
76
|
-
"More Wallets"
|
|
77
|
-
] }),
|
|
78
|
-
showAll && /* @__PURE__ */ jsx(BlurContainer, {})
|
|
79
|
-
] });
|
|
80
|
-
};
|
|
81
|
-
const Container = styled.div`
|
|
82
|
-
position: relative;
|
|
83
|
-
display: flex;
|
|
84
|
-
justify-content: center;
|
|
85
|
-
gap: 8px;
|
|
86
|
-
flex-wrap: wrap;
|
|
87
|
-
|
|
88
|
-
max-height: ${({ $maxHeight }) => $maxHeight ? "348px" : "none"};
|
|
89
|
-
overflow-y: auto;
|
|
90
|
-
|
|
91
|
-
&::-webkit-scrollbar {
|
|
92
|
-
display: none;
|
|
93
|
-
}
|
|
94
|
-
-ms-overflow-style: none;
|
|
95
|
-
scrollbar-width: none;
|
|
96
|
-
`;
|
|
97
|
-
const WalletTileButton = styled(StyledCpslTileButton)`
|
|
98
|
-
flex: 1;
|
|
99
|
-
`;
|
|
100
|
-
const WalletButtonOuterContainer = styled.div`
|
|
101
|
-
width: 100%;
|
|
102
|
-
display: flex;
|
|
103
|
-
align-items: center;
|
|
104
|
-
gap: 8px;
|
|
105
|
-
justify-content: space-between;
|
|
106
|
-
`;
|
|
107
|
-
const WalletButtonInnerContainer = styled.div`
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
gap: 8px;
|
|
111
|
-
|
|
112
|
-
cpsl-icon {
|
|
113
|
-
--icon-color: var(--cpsl-color-contrast);
|
|
114
|
-
}
|
|
115
|
-
cpsl-text {
|
|
116
|
-
&::part(text-element) {
|
|
117
|
-
color: var(--cpsl-color-contrast);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
const Badge = styled.div`
|
|
122
|
-
visibility: ${({ $show }) => $show ? "visible" : "hidden"};
|
|
123
|
-
padding: 2px 4px;
|
|
124
|
-
border-radius: 4px;
|
|
125
|
-
border: 1px solid;
|
|
126
|
-
border-color: ${({ $variant }) => $variant === "installed" ? "var(--cpsl-color-utility-green)" : "var(--cpsl-color-text-primary)"};
|
|
127
|
-
cpsl-text {
|
|
128
|
-
&::part(text-element) {
|
|
129
|
-
color: ${({ $variant }) => $variant === "installed" ? "var(--cpsl-color-utility-green)" : "var(--cpsl-color-text-primary)"};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
`;
|
|
133
|
-
const InstalledIndicator = styled.span`
|
|
134
|
-
width: 8px;
|
|
135
|
-
height: 8px;
|
|
136
|
-
border-radius: 100%;
|
|
137
|
-
background-color: var(--cpsl-color-utility-green);
|
|
138
|
-
`;
|
|
139
|
-
const TileButtonInnerContainer = styled.div`
|
|
140
|
-
display: flex;
|
|
141
|
-
gap: 4px;
|
|
142
|
-
align-items: center;
|
|
143
|
-
`;
|
|
144
|
-
const SearchIcon = styled(CpslIcon)`
|
|
145
|
-
--icon-color: var(--cpsl-color-contrast);
|
|
146
|
-
`;
|
|
147
|
-
const SearchInputWrapper = styled.div`
|
|
148
|
-
width: 100%;
|
|
149
|
-
background-color: var(--cpsl-color-background-0);
|
|
150
|
-
|
|
151
|
-
position: sticky;
|
|
152
|
-
top: 0;
|
|
153
|
-
padding-bottom: 4px;
|
|
154
|
-
margin-bottom: -4px;
|
|
155
|
-
`;
|
|
156
|
-
const SearchInput = styled(CpslInput)`
|
|
157
|
-
width: 100%;
|
|
158
|
-
--container-background-color: var(--cpsl-color-background-8);
|
|
159
|
-
--input-background-color: var(--cpsl-color-background-8);
|
|
160
|
-
`;
|
|
161
|
-
const BlurContainer = styled.div`
|
|
162
|
-
position: sticky;
|
|
163
|
-
height: 56px;
|
|
164
|
-
width: 100%;
|
|
165
|
-
bottom: 0;
|
|
166
|
-
|
|
167
|
-
background: linear-gradient(0deg, var(--cpsl-color-background-0) 0%, rgba(234, 239, 211, 0) 100%);
|
|
168
|
-
pointer-events: none;
|
|
169
|
-
`;
|
|
170
|
-
export {
|
|
171
|
-
ExternalWallets
|
|
172
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { ExternalWalletProvider } from "../../providers/ExternalWalletContext.js";
|
|
8
|
-
import {
|
|
9
|
-
EvmExternalWalletContext,
|
|
10
|
-
EvmExternalWalletProvider
|
|
11
|
-
} from "../../providers/EvmExternalWalletContextStub.js";
|
|
12
|
-
import { CosmosWallet, EvmWallet, SolanaWallet } from "../../types/externalWallets.js";
|
|
13
|
-
import {
|
|
14
|
-
SolanaExternalWalletContext,
|
|
15
|
-
SolanaExternalWalletProvider
|
|
16
|
-
} from "../../providers/SolanaExternalWalletContextStub.js";
|
|
17
|
-
import {
|
|
18
|
-
CosmosExternalWalletContext,
|
|
19
|
-
CosmosExternalWalletProvider
|
|
20
|
-
} from "../../providers/CosmosExternalWalletContextStub.js";
|
|
21
|
-
import { useModalStore, useUserInfoStore } from "../../stores/index.js";
|
|
22
|
-
import { useExternalWalletProviderStore } from "../../stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
23
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
24
|
-
const ExternalWalletsWrapper = ({ children, wallets }) => {
|
|
25
|
-
const para = useInternalClient();
|
|
26
|
-
const resetModalState = useModalStore((state) => state.resetState);
|
|
27
|
-
const resetUserInfoState = useUserInfoStore((state) => state.resetState);
|
|
28
|
-
const StoredEvmProvider = useExternalWalletProviderStore((state) => state.EvmProvider);
|
|
29
|
-
const storedEvmContext = useExternalWalletProviderStore((state) => state.evmContext);
|
|
30
|
-
const StoredSolanaProvider = useExternalWalletProviderStore((state) => state.SolanaProvider);
|
|
31
|
-
const storedSolanaContext = useExternalWalletProviderStore((state) => state.solanaContext);
|
|
32
|
-
const StoredCosmosProvider = useExternalWalletProviderStore((state) => state.CosmosProvider);
|
|
33
|
-
const storedCosmosContext = useExternalWalletProviderStore((state) => state.cosmosContext);
|
|
34
|
-
const [EvmProvider, setEvmProvider] = useState(null);
|
|
35
|
-
const [evmContext, setEvmContext] = useState(null);
|
|
36
|
-
const [SolanaProvider, setSolanaProvider] = useState(null);
|
|
37
|
-
const [solanaContext, setSolanaContext] = useState(null);
|
|
38
|
-
const [CosmosProvider, setCosmosProvider] = useState(null);
|
|
39
|
-
const [cosmosContext, setCosmosContext] = useState(null);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const loadProviders = () => __async(void 0, null, function* () {
|
|
42
|
-
let newEvmContext = EvmExternalWalletContext;
|
|
43
|
-
let newEvmProvider = EvmExternalWalletProvider;
|
|
44
|
-
let newSolanaContext = SolanaExternalWalletContext;
|
|
45
|
-
let newSolanaProvider = SolanaExternalWalletProvider;
|
|
46
|
-
let newCosmosContext = CosmosExternalWalletContext;
|
|
47
|
-
let newCosmosProvider = CosmosExternalWalletProvider;
|
|
48
|
-
if (!(wallets == null ? void 0 : wallets.length)) {
|
|
49
|
-
newEvmContext = EvmExternalWalletContext;
|
|
50
|
-
newEvmProvider = EvmExternalWalletProvider;
|
|
51
|
-
newSolanaContext = SolanaExternalWalletContext;
|
|
52
|
-
newSolanaProvider = SolanaExternalWalletProvider;
|
|
53
|
-
newCosmosContext = CosmosExternalWalletContext;
|
|
54
|
-
newCosmosProvider = CosmosExternalWalletProvider;
|
|
55
|
-
} else {
|
|
56
|
-
for (let i = 0; i < wallets.length; i++) {
|
|
57
|
-
const wallet = wallets[i];
|
|
58
|
-
if (wallet in EvmWallet) {
|
|
59
|
-
if (!StoredEvmProvider || !storedEvmContext) {
|
|
60
|
-
throw new Error("@getpara/evm-wallet-connectors is required to use an external EVM wallet.");
|
|
61
|
-
} else {
|
|
62
|
-
newEvmContext = storedEvmContext;
|
|
63
|
-
newEvmProvider = StoredEvmProvider;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (wallet in SolanaWallet) {
|
|
67
|
-
if (!StoredSolanaProvider || !storedSolanaContext) {
|
|
68
|
-
throw new Error("@getpara/solana-wallet-connectors is required to use an external Solana wallet.");
|
|
69
|
-
} else {
|
|
70
|
-
newSolanaContext = storedSolanaContext;
|
|
71
|
-
newSolanaProvider = StoredSolanaProvider;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (wallet in CosmosWallet) {
|
|
75
|
-
if (!StoredCosmosProvider || !storedCosmosContext) {
|
|
76
|
-
throw new Error("@getpara/cosmos-wallet-connectors is required to use an external Cosmos wallet.");
|
|
77
|
-
} else {
|
|
78
|
-
newCosmosContext = storedCosmosContext;
|
|
79
|
-
newCosmosProvider = StoredCosmosProvider;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
setEvmContext(newEvmContext);
|
|
85
|
-
setEvmProvider(() => newEvmProvider);
|
|
86
|
-
setSolanaContext(newSolanaContext);
|
|
87
|
-
setSolanaProvider(() => newSolanaProvider);
|
|
88
|
-
setCosmosContext(newCosmosContext);
|
|
89
|
-
setCosmosProvider(() => newCosmosProvider);
|
|
90
|
-
});
|
|
91
|
-
loadProviders();
|
|
92
|
-
}, [
|
|
93
|
-
wallets,
|
|
94
|
-
storedEvmContext,
|
|
95
|
-
StoredEvmProvider,
|
|
96
|
-
storedSolanaContext,
|
|
97
|
-
StoredSolanaProvider,
|
|
98
|
-
storedCosmosContext,
|
|
99
|
-
StoredCosmosProvider
|
|
100
|
-
]);
|
|
101
|
-
const handleSwitchWallet = ({ address, error }) => {
|
|
102
|
-
if (error || !address) {
|
|
103
|
-
resetModalState();
|
|
104
|
-
resetUserInfoState();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
if (!para || !EvmProvider || !SolanaProvider || !CosmosProvider) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return /* @__PURE__ */ jsx(EvmProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(SolanaProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(CosmosProvider, { para, onSwitchWallet: handleSwitchWallet, children: /* @__PURE__ */ jsx(
|
|
111
|
-
ExternalWalletProvider,
|
|
112
|
-
{
|
|
113
|
-
evmContext,
|
|
114
|
-
solanaContext,
|
|
115
|
-
cosmosContext,
|
|
116
|
-
walletSort: wallets,
|
|
117
|
-
children
|
|
118
|
-
}
|
|
119
|
-
) }) }) });
|
|
120
|
-
};
|
|
121
|
-
export {
|
|
122
|
-
ExternalWalletsWrapper
|
|
123
|
-
};
|