@getpara/react-sdk 2.0.0-alpha.11 → 2.0.0-alpha.13
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/ParaModal.js +38 -5
- package/dist/modal/components/AddFunds/AddFundsReceive.js +3 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -1
- package/dist/modal/components/AuthOptions/AuthOptions.js +14 -15
- package/dist/modal/components/Controls/Controls.js +3 -2
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +14 -1
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +11 -1
- package/dist/modal/constants/constants.d.ts +1 -0
- package/dist/modal/constants/constants.js +2 -0
- package/dist/modal/stores/modal/actions.js +1 -1
- package/dist/provider/ParaProvider.js +17 -5
- package/dist/provider/hooks/utils/useEventListeners.js +1 -1
- package/dist/provider/providers/AuthProvider.js +11 -1
- package/dist/provider/stores/slices/analytics.d.ts +3 -0
- package/dist/provider/stores/slices/analytics.js +9 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/types.d.ts +5 -1
- package/dist/provider/stores/useStore.js +8 -2
- package/dist/provider/types/provider.d.ts +4 -2
- package/package.json +11 -11
package/dist/modal/ParaModal.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
__async,
|
|
4
4
|
__objRest,
|
|
5
|
+
__spreadProps,
|
|
5
6
|
__spreadValues
|
|
6
7
|
} from "../chunk-MMUBH76A.js";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -15,24 +16,26 @@ import { DEFAULTS } from "./constants/defaults.js";
|
|
|
15
16
|
import { useGoBack } from "./hooks/useGoBack.js";
|
|
16
17
|
import styled from "styled-components";
|
|
17
18
|
import { hasEmbeddedAuth, hasExternalWallet } from "./utils/authLayoutHelpers.js";
|
|
18
|
-
import { useModal, useWalletState } from "../provider/index.js";
|
|
19
|
+
import { useAccount, useModal, useWalletState } from "../provider/index.js";
|
|
19
20
|
import { useInternalClient } from "../provider/hooks/utils/useInternalClient.js";
|
|
20
21
|
import { useExternalWallets } from "../provider/providers/ExternalWalletProvider.js";
|
|
21
22
|
import { useStore } from "../provider/stores/useStore.js";
|
|
22
23
|
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
23
24
|
import { useAuthActions } from "../provider/providers/AuthProvider.js";
|
|
24
25
|
import { validateAuth } from "./utils/authInputHelpers.js";
|
|
26
|
+
import { SDK_VERSION } from "./constants/constants.js";
|
|
25
27
|
defineCustomElements();
|
|
26
28
|
const ParaModal = forwardRef((props, ref) => {
|
|
27
29
|
const storedModalConfig = useStore((state) => state.modalConfig);
|
|
28
30
|
const modalContentRef = useRef(null);
|
|
31
|
+
const refs = useModalStore((state) => state.refs);
|
|
32
|
+
const flow = useModalStore((state) => state.flow);
|
|
29
33
|
const currentStep = useModalStore((state) => state.step);
|
|
30
34
|
const setAuthState = useModalStore((state) => state.setAuthState);
|
|
31
35
|
const setOnModalStepChange = useModalStore((state) => state.setOnModalStepChange);
|
|
32
36
|
const setStep = useModalStore((state) => state.setStep);
|
|
33
37
|
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
34
38
|
const setFlow = useModalStore((state) => state.setFlow);
|
|
35
|
-
const setIsFullyLoggedIn = useModalStore((state) => state.setIsFullyLoggedIn);
|
|
36
39
|
const goBack = useGoBack();
|
|
37
40
|
const setAuthLayout = useModalStore((state) => state.setAuthLayout);
|
|
38
41
|
const storedAuthLayout = useModalStore((state) => state.authLayout);
|
|
@@ -44,9 +47,11 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
44
47
|
const { setSelectedWallet, updateSelectedWallet } = useWalletState();
|
|
45
48
|
const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
|
|
46
49
|
const { signUpOrLogIn, isCreateGuestWalletsPending } = useAuthActions();
|
|
50
|
+
const { data: account } = useAccount();
|
|
47
51
|
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
48
52
|
const [isInit, setIsInit] = useState(false);
|
|
49
53
|
const externalWallets = useStore((state) => state.externalWallets);
|
|
54
|
+
const providerProps = useStore((state) => state.providerProps);
|
|
50
55
|
const _a = __spreadValues(__spreadValues({}, storedModalConfig), props), {
|
|
51
56
|
isOpen: configIsOpen,
|
|
52
57
|
theme,
|
|
@@ -78,6 +83,32 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
78
83
|
"onClose",
|
|
79
84
|
"defaultAuthIdentifier"
|
|
80
85
|
]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const trackAnalytics = () => __async(void 0, null, function* () {
|
|
88
|
+
try {
|
|
89
|
+
yield para.ctx.client.trackReactSdkAnalytics({
|
|
90
|
+
props: __spreadValues(__spreadProps(__spreadValues({}, providerProps), {
|
|
91
|
+
theme,
|
|
92
|
+
disableEmailLogin,
|
|
93
|
+
disablePhoneLogin,
|
|
94
|
+
isGuestModeEnabled,
|
|
95
|
+
oAuthMethods,
|
|
96
|
+
bareModal,
|
|
97
|
+
className,
|
|
98
|
+
currentStepOverride,
|
|
99
|
+
authLayout,
|
|
100
|
+
embeddedModal,
|
|
101
|
+
onModalStepChange,
|
|
102
|
+
onClose,
|
|
103
|
+
defaultAuthIdentifier
|
|
104
|
+
}), rest),
|
|
105
|
+
reactSdkVersion: SDK_VERSION
|
|
106
|
+
});
|
|
107
|
+
} catch (_) {
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
trackAnalytics();
|
|
111
|
+
}, []);
|
|
81
112
|
const isOpen = configIsOpen != null ? configIsOpen : storedIsOpen;
|
|
82
113
|
useImperativeHandle(ref, () => {
|
|
83
114
|
return {
|
|
@@ -106,12 +137,10 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
106
137
|
case isGuest:
|
|
107
138
|
setFlow("guest");
|
|
108
139
|
setStep(isCreateGuestWalletsPending ? ModalStep.AWAITING_GUEST_WALLET_CREATION : ModalStep.ACCOUNT_MAIN);
|
|
109
|
-
setIsFullyLoggedIn(true);
|
|
110
140
|
break;
|
|
111
141
|
case isAccount:
|
|
112
142
|
setFlow("account");
|
|
113
143
|
setStep(ModalStep.ACCOUNT_MAIN);
|
|
114
|
-
setIsFullyLoggedIn(true);
|
|
115
144
|
break;
|
|
116
145
|
default:
|
|
117
146
|
if (currentStep !== ModalStep.AUTH_MAIN && currentStep !== ModalStep.SECRET) {
|
|
@@ -122,7 +151,6 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
122
151
|
}
|
|
123
152
|
yield disconnectExternalWallet();
|
|
124
153
|
setSelectedWallet({ id: void 0, type: void 0 });
|
|
125
|
-
setIsFullyLoggedIn(false);
|
|
126
154
|
if (shouldAutoLogin) {
|
|
127
155
|
if (defaultAuthIdentifier && ((_a2 = para.authInfo) == null ? void 0 : _a2.identifier) !== defaultAuthIdentifier) {
|
|
128
156
|
const number = parsePhoneNumberFromString(defaultAuthIdentifier);
|
|
@@ -178,6 +206,11 @@ const ParaModal = forwardRef((props, ref) => {
|
|
|
178
206
|
useEffect(() => {
|
|
179
207
|
updateSelectedWallet();
|
|
180
208
|
}, [para]);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (bareModal && account && !account.isConnected && !["signup", "login"].includes(flow != null ? flow : "") && refs.currentStep.current !== ModalStep.AUTH_MAIN) {
|
|
211
|
+
setStep(ModalStep.AUTH_MAIN);
|
|
212
|
+
}
|
|
213
|
+
}, [bareModal, flow, account]);
|
|
181
214
|
const handleClose = () => {
|
|
182
215
|
closeModal();
|
|
183
216
|
onClose == null ? void 0 : onClose();
|
|
@@ -21,9 +21,9 @@ import { useAddFunds } from "./AddFundsContext.js";
|
|
|
21
21
|
import { formatNetworkList } from "../../utils/stringFormatters.js";
|
|
22
22
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
23
23
|
const GENERIC_WALLET = {
|
|
24
|
-
EVM: "Ethereum or EVM-based
|
|
25
|
-
SOLANA: "Solana",
|
|
26
|
-
COSMOS: "Cosmos"
|
|
24
|
+
EVM: "Ethereum or EVM-based networks",
|
|
25
|
+
SOLANA: "Solana or SVM-based networks",
|
|
26
|
+
COSMOS: "Cosmos networks"
|
|
27
27
|
};
|
|
28
28
|
function AddFundsReceive() {
|
|
29
29
|
const [isCopied, copy] = useCopyToClipboard();
|
|
@@ -144,9 +144,10 @@ const GuestMode = styled.a`
|
|
|
144
144
|
width: 100%;
|
|
145
145
|
height: 50px;
|
|
146
146
|
color: ${({ isDark }) => isDark ? "white" : "black"};
|
|
147
|
-
text-decoration:
|
|
147
|
+
text-decoration: none;
|
|
148
148
|
font-size: 16px;
|
|
149
149
|
font-weight: 500;
|
|
150
|
+
font-family: var(--cpsl-font-family);
|
|
150
151
|
|
|
151
152
|
&:hover {
|
|
152
153
|
text-decoration: underline;
|
|
@@ -7,8 +7,7 @@ import { OAuth } from "../OAuth/OAuth.js";
|
|
|
7
7
|
import { AuthInput } from "../AuthInput/AuthInput.js";
|
|
8
8
|
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
9
9
|
import { useModalStore } from "../../stores/index.js";
|
|
10
|
-
import { CpslIcon } from "@getpara/react-components";
|
|
11
|
-
import { useStore } from "../../../provider/stores/useStore.js";
|
|
10
|
+
import { CpslIcon, CpslText } from "@getpara/react-components";
|
|
12
11
|
const AuthOptions = ({
|
|
13
12
|
oAuthMethods,
|
|
14
13
|
disableEmailLogin,
|
|
@@ -16,10 +15,6 @@ const AuthOptions = ({
|
|
|
16
15
|
isGuestModeEnabled = false
|
|
17
16
|
}) => {
|
|
18
17
|
const { wallets } = useExternalWallets();
|
|
19
|
-
const isDark = useStore((state) => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
22
|
-
});
|
|
23
18
|
const guestAddFundsTab = useModalStore((state) => state.guestAddFundsTab);
|
|
24
19
|
const Content = useMemo(() => {
|
|
25
20
|
const Methods = [];
|
|
@@ -32,12 +27,14 @@ const AuthOptions = ({
|
|
|
32
27
|
return /* @__PURE__ */ jsx(Fragment, { children: Methods });
|
|
33
28
|
}, [oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, wallets]);
|
|
34
29
|
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
35
|
-
guestAddFundsTab && /* @__PURE__ */ jsxs(CompleteAccountSetup, {
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
guestAddFundsTab && /* @__PURE__ */ jsxs(CompleteAccountSetup, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx(CompleteAccountIcon, { icon: "stars02", size: "16px" }),
|
|
32
|
+
/* @__PURE__ */ jsxs(CpslText, { variant: "bodyS", weight: "bold", children: [
|
|
33
|
+
"Complete account setup to",
|
|
34
|
+
" ",
|
|
35
|
+
guestAddFundsTab === "BUY" ? "buy assets" : guestAddFundsTab === "WITHDRAW" ? "sell assets" : "continue",
|
|
36
|
+
"."
|
|
37
|
+
] })
|
|
41
38
|
] }),
|
|
42
39
|
Content
|
|
43
40
|
] });
|
|
@@ -52,9 +49,11 @@ const CompleteAccountSetup = styled.div`
|
|
|
52
49
|
align-items: center;
|
|
53
50
|
justify-content: center;
|
|
54
51
|
gap: 4px;
|
|
55
|
-
color:
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
color: var(--cpsl-color-text-primary);
|
|
53
|
+
margin-bottom: 8px;
|
|
54
|
+
`;
|
|
55
|
+
const CompleteAccountIcon = styled(CpslIcon)`
|
|
56
|
+
--icon-color: var(--cpsl-color-text-primary);
|
|
58
57
|
`;
|
|
59
58
|
export {
|
|
60
59
|
AuthOptions
|
|
@@ -9,6 +9,7 @@ import { AccountSelect, ChainSelect } from "./Selects.js";
|
|
|
9
9
|
import { ModalStep } from "../../utils/steps.js";
|
|
10
10
|
import { HeaderButton } from "@getpara/react-common";
|
|
11
11
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
12
|
+
import { useAccount } from "../../../provider/index.js";
|
|
12
13
|
const Controls = ({ onClose }) => {
|
|
13
14
|
const bareModal = useStore((state) => {
|
|
14
15
|
var _a;
|
|
@@ -16,8 +17,8 @@ const Controls = ({ onClose }) => {
|
|
|
16
17
|
});
|
|
17
18
|
const hasPreviousStep = useModalStore((state) => state.hasPreviousStep());
|
|
18
19
|
const step = useModalStore((state) => state.step);
|
|
19
|
-
const isFullyLoggedIn = useModalStore((state) => state.isFullyLoggedIn);
|
|
20
20
|
const goBack = useGoBack();
|
|
21
|
+
const { data: account } = useAccount();
|
|
21
22
|
const shouldShowSelects = [
|
|
22
23
|
ModalStep.ACCOUNT_MAIN,
|
|
23
24
|
ModalStep.CHAIN_SWITCH,
|
|
@@ -40,7 +41,7 @@ const Controls = ({ onClose }) => {
|
|
|
40
41
|
children: /* @__PURE__ */ jsx(CpslIcon, { icon: "arrow" })
|
|
41
42
|
}
|
|
42
43
|
),
|
|
43
|
-
/* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects &&
|
|
44
|
+
/* @__PURE__ */ jsx(MiddleContainer, { children: shouldShowSelects && (account == null ? void 0 : account.isConnected) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
45
|
/* @__PURE__ */ jsx(ChainSelect, {}),
|
|
45
46
|
/* @__PURE__ */ jsx(AccountSelect, {})
|
|
46
47
|
] }) }),
|
|
@@ -6,16 +6,29 @@ import { Heading, HeroIcon, StepContainer } from "../common.js";
|
|
|
6
6
|
import { ExternalWalletCard, WalletCard, WalletCards } from "../WalletCard/WalletCard.js";
|
|
7
7
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
8
8
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
9
|
+
import { useModalStore } from "../../stores/index.js";
|
|
10
|
+
import { ModalStep } from "../../utils/steps.js";
|
|
9
11
|
const LoginDoneStep = ({ onClose }) => {
|
|
10
12
|
var _a, _b;
|
|
11
13
|
const para = useInternalClient();
|
|
14
|
+
const bareModal = useStore((state) => {
|
|
15
|
+
var _a2;
|
|
16
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.bareModal;
|
|
17
|
+
});
|
|
18
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
19
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
12
20
|
const hideWallets = useStore((state) => {
|
|
13
21
|
var _a2;
|
|
14
22
|
return (_a2 = state.modalConfig) == null ? void 0 : _a2.hideWallets;
|
|
15
23
|
});
|
|
16
24
|
useEffect(() => {
|
|
17
25
|
setTimeout(() => {
|
|
18
|
-
|
|
26
|
+
if (bareModal) {
|
|
27
|
+
setFlow("account");
|
|
28
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
29
|
+
} else {
|
|
30
|
+
onClose();
|
|
31
|
+
}
|
|
19
32
|
}, 1600);
|
|
20
33
|
}, []);
|
|
21
34
|
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
@@ -19,7 +19,12 @@ const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
|
|
|
19
19
|
var _a;
|
|
20
20
|
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
21
21
|
});
|
|
22
|
+
const bareModal = useStore((state) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.bareModal;
|
|
25
|
+
});
|
|
22
26
|
const setStep = useModalStore((state) => state.setStep);
|
|
27
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
23
28
|
const isLogin = useModalStore((state) => state.isLogin());
|
|
24
29
|
const twoFactorStatus = useModalStore((state) => state.twoFactorStatus);
|
|
25
30
|
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
@@ -30,7 +35,12 @@ const WalletCreationDoneStep = ({ twoFactorAuthEnabled, onClose }) => {
|
|
|
30
35
|
if (isLogin) {
|
|
31
36
|
setStep(ModalStep.LOGIN_DONE);
|
|
32
37
|
} else {
|
|
33
|
-
|
|
38
|
+
if (bareModal) {
|
|
39
|
+
setFlow("account");
|
|
40
|
+
setStep(ModalStep.ACCOUNT_MAIN);
|
|
41
|
+
} else {
|
|
42
|
+
onClose();
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
const handleNext = () => __async(void 0, null, function* () {
|
|
@@ -36,4 +36,5 @@ export declare const NETWORK_NOT_SUPPORTED_ERROR = "network not supported";
|
|
|
36
36
|
export declare const EMAIL_REGEX: RegExp;
|
|
37
37
|
export declare const BODY_MOTION_VARIANTS: Variants;
|
|
38
38
|
export declare const BODY_TRANSITION: Transition;
|
|
39
|
+
export declare const SDK_VERSION: string;
|
|
39
40
|
export {};
|
|
@@ -119,6 +119,7 @@ const BODY_MOTION_VARIANTS = {
|
|
|
119
119
|
const BODY_TRANSITION = {
|
|
120
120
|
duration: 0.2
|
|
121
121
|
};
|
|
122
|
+
const SDK_VERSION = "2.0.0-alpha.13";
|
|
122
123
|
export {
|
|
123
124
|
BODY_MOTION_VARIANTS,
|
|
124
125
|
BODY_TRANSITION,
|
|
@@ -130,6 +131,7 @@ export {
|
|
|
130
131
|
ON_RAMP_PROVIDERS,
|
|
131
132
|
PARA_CONNECT,
|
|
132
133
|
PARA_TERMS_AND_CONDITIONS,
|
|
134
|
+
SDK_VERSION,
|
|
133
135
|
getAssetCode,
|
|
134
136
|
getAssetIcon,
|
|
135
137
|
getAssetName,
|
|
@@ -64,7 +64,7 @@ const getActions = (set, get) => ({
|
|
|
64
64
|
if ([ModalStep.ADD_FUNDS_BUY, ModalStep.ADD_FUNDS_WITHDRAW].includes(currentStep) && onRampStep > 0) {
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
|
-
return !!
|
|
67
|
+
return !!getPreviousStep(flow, currentStep);
|
|
68
68
|
},
|
|
69
69
|
setFlow: (flow) => set({ flow }),
|
|
70
70
|
isLogin: () => get().flow === "login",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-MMUBH76A.js";
|
|
3
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
7
|
import { forwardRef, useEffect } from "react";
|
|
5
8
|
import { useStore } from "./stores/useStore.js";
|
|
@@ -26,6 +29,13 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
|
|
|
26
29
|
const appName = useStore((state) => state.appName);
|
|
27
30
|
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
28
31
|
const setRpcUrl = useStore((state) => state.setRpcUrl);
|
|
32
|
+
const setProviderProps = useStore((state) => state.setProviderProps);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setProviderProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, config), externalWalletConfig), paraModalConfig), {
|
|
35
|
+
// Redacting walletConnect to avoid exposing project id
|
|
36
|
+
walletConnect: void 0
|
|
37
|
+
}));
|
|
38
|
+
}, [config, externalWalletConfig, paraModalConfig]);
|
|
29
39
|
useEffect(() => {
|
|
30
40
|
if (rpcUrl !== config.rpcUrl) setRpcUrl(config.rpcUrl);
|
|
31
41
|
}, [config.rpcUrl]);
|
|
@@ -43,15 +53,17 @@ const ParaProvider = forwardRef(({ children, paraClientConfig, callbacks, config
|
|
|
43
53
|
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.wallets]);
|
|
44
54
|
useEffect(() => {
|
|
45
55
|
var _a, _b;
|
|
46
|
-
if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.
|
|
56
|
+
if (externalWalletsWithFullAuth !== (externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets)) {
|
|
47
57
|
if (isConfigType(paraClientConfig) ? (_a = paraClientConfig.opts) == null ? void 0 : _a.externalWalletConnectionOnly : paraClientConfig.externalWalletConnectionOnly) {
|
|
48
|
-
console.warn("
|
|
58
|
+
console.warn("createLinkedEmbeddedForExternalWallets has no effect when using externalWalletConnectionOnly");
|
|
49
59
|
setExternalWalletsWithFullAuth([]);
|
|
50
60
|
} else {
|
|
51
|
-
setExternalWalletsWithFullAuth(
|
|
61
|
+
setExternalWalletsWithFullAuth(
|
|
62
|
+
(externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) === "ALL" ? Object.values(ExternalWallet) : (_b = externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets) != null ? _b : []
|
|
63
|
+
);
|
|
52
64
|
}
|
|
53
65
|
}
|
|
54
|
-
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.
|
|
66
|
+
}, [externalWalletConfig == null ? void 0 : externalWalletConfig.createLinkedEmbeddedForExternalWallets]);
|
|
55
67
|
useEffect(() => {
|
|
56
68
|
if (!isConfigType(paraClientConfig) && !isParaWeb(paraClientConfig)) {
|
|
57
69
|
throw new Error("Invalid Para config");
|
|
@@ -103,7 +103,7 @@ const useEventListeners = ({
|
|
|
103
103
|
updateSelectedWallet();
|
|
104
104
|
onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
|
|
105
105
|
},
|
|
106
|
-
[onGuestWalletsCreated]
|
|
106
|
+
[queryClient, updateSelectedWallet, onGuestWalletsCreated]
|
|
107
107
|
);
|
|
108
108
|
useEffect(() => {
|
|
109
109
|
window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
|
|
@@ -69,7 +69,12 @@ function AuthProvider({
|
|
|
69
69
|
const para = useInternalClient();
|
|
70
70
|
const onLoginRef = useStore((state) => state.onLoginRef);
|
|
71
71
|
const setIsOpen = useStore((state) => state.setIsOpen);
|
|
72
|
+
const bareModal = useStore((state) => {
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.bareModal;
|
|
75
|
+
});
|
|
72
76
|
const refs = useModalStore((state) => state.refs);
|
|
77
|
+
const setFlow = useModalStore((state) => state.setFlow);
|
|
73
78
|
const currentStep = useModalStore((state) => state.step);
|
|
74
79
|
const setStep = useModalStore((state) => state.setStep);
|
|
75
80
|
const setAuthStepRoute = useModalStore((state) => state.setAuthStepRoute);
|
|
@@ -416,7 +421,12 @@ function AuthProvider({
|
|
|
416
421
|
}
|
|
417
422
|
}), [para, isRecoverySecretStepEnabled, overrides == null ? void 0 : overrides.createWallets]);
|
|
418
423
|
const createGuestWallets = () => {
|
|
419
|
-
|
|
424
|
+
if (bareModal) {
|
|
425
|
+
setFlow("guest");
|
|
426
|
+
setStep(ModalStep.AWAITING_GUEST_WALLET_CREATION);
|
|
427
|
+
} else {
|
|
428
|
+
setIsOpen(false);
|
|
429
|
+
}
|
|
420
430
|
mutateCreateGuestWallets(void 0, {
|
|
421
431
|
onSuccess: () => {
|
|
422
432
|
},
|
|
@@ -14,6 +14,10 @@ export interface ConfigSlice {
|
|
|
14
14
|
appName: string;
|
|
15
15
|
setAppName: (_: string) => void;
|
|
16
16
|
}
|
|
17
|
+
export interface AnalyticsSlice {
|
|
18
|
+
providerProps: object;
|
|
19
|
+
setProviderProps: (_: object) => void;
|
|
20
|
+
}
|
|
17
21
|
export interface ModalSlice {
|
|
18
22
|
modalConfig?: ParaModalProps;
|
|
19
23
|
setModalConfig: (_?: ParaModalProps) => void;
|
|
@@ -61,4 +65,4 @@ export interface ExternalWalletsSlice {
|
|
|
61
65
|
setIsLoadingSolanaLib: (_: boolean) => void;
|
|
62
66
|
onLoginRef: MutableRefObject<(() => Promise<void>) | null>;
|
|
63
67
|
}
|
|
64
|
-
export type Store = ClientSlice & ModalSlice & WalletSlice & ExternalWalletsSlice & ConfigSlice;
|
|
68
|
+
export type Store = ClientSlice & ModalSlice & WalletSlice & ExternalWalletsSlice & ConfigSlice & AnalyticsSlice;
|
|
@@ -3,12 +3,18 @@ import {
|
|
|
3
3
|
__spreadValues
|
|
4
4
|
} from "../../chunk-MMUBH76A.js";
|
|
5
5
|
import { createStore, useStore as useZustandStore } from "zustand";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
createAnalyticsSlice,
|
|
8
|
+
createClientSlice,
|
|
9
|
+
createExternalWalletsSlice,
|
|
10
|
+
createModalSlice,
|
|
11
|
+
createWalletSlice
|
|
12
|
+
} from "./slices/index.js";
|
|
7
13
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
8
14
|
import { createConfigSlice } from "./slices/config.js";
|
|
9
15
|
const vanillaStore = createStore()(
|
|
10
16
|
persist(
|
|
11
|
-
(...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)),
|
|
17
|
+
(...a) => __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a)), createExternalWalletsSlice(...a)), createConfigSlice(...a)), createAnalyticsSlice(...a)),
|
|
12
18
|
{
|
|
13
19
|
version: 1,
|
|
14
20
|
name: "@PARA/provider-state",
|
|
@@ -107,9 +107,11 @@ export type ExternalWalletConfig<chains extends readonly [Chain, ...Chain[]], tr
|
|
|
107
107
|
*/
|
|
108
108
|
wallets?: TExternalWallet[];
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* Array of external wallets that will also include linked embedded wallets.
|
|
111
|
+
*
|
|
112
|
+
* You can also pass `ALL` to include linked embedded wallets for all external wallets.
|
|
111
113
|
*/
|
|
112
|
-
|
|
114
|
+
createLinkedEmbeddedForExternalWallets?: TExternalWallet[] | 'ALL';
|
|
113
115
|
};
|
|
114
116
|
export interface ParaProviderProps<chains extends readonly [Chain, ...Chain[]], transports extends Record<chains[number]['id'], Transport>> extends PropsWithChildren {
|
|
115
117
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"*.css"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
19
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
20
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
18
|
+
"@getpara/react-common": "2.0.0-alpha.13",
|
|
19
|
+
"@getpara/react-components": "2.0.0-alpha.13",
|
|
20
|
+
"@getpara/web-sdk": "2.0.0-alpha.13",
|
|
21
21
|
"date-fns": "^3.6.0",
|
|
22
22
|
"framer-motion": "11.3.28",
|
|
23
23
|
"libphonenumber-js": "^1.11.1",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"cli": "node ./dist/cli/cli.mjs"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.
|
|
37
|
-
"@getpara/evm-wallet-connectors": "2.0.0-alpha.
|
|
38
|
-
"@getpara/solana-wallet-connectors": "2.0.0-alpha.
|
|
36
|
+
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.13",
|
|
37
|
+
"@getpara/evm-wallet-connectors": "2.0.0-alpha.13",
|
|
38
|
+
"@getpara/solana-wallet-connectors": "2.0.0-alpha.13",
|
|
39
39
|
"@testing-library/dom": "^10.4.0",
|
|
40
40
|
"@testing-library/react": "^16.3.0",
|
|
41
41
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"wagmi": "^2.14.16"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.
|
|
52
|
-
"@getpara/evm-wallet-connectors": "^2.0.0-alpha.
|
|
53
|
-
"@getpara/solana-wallet-connectors": "^2.0.0-alpha.
|
|
51
|
+
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.12",
|
|
52
|
+
"@getpara/evm-wallet-connectors": "^2.0.0-alpha.12",
|
|
53
|
+
"@getpara/solana-wallet-connectors": "^2.0.0-alpha.12",
|
|
54
54
|
"@tanstack/react-query": ">=5.0.0",
|
|
55
55
|
"react": "*",
|
|
56
56
|
"react-dom": "*"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"resolutions": {
|
|
64
64
|
"styled-components": "^6"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "fbd9384b1b3fb8577f9d6c323d4e41d0de1ac83b"
|
|
67
67
|
}
|