@getpara/react-sdk 1.7.0 → 1.8.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/index.js +6 -6657
- package/dist/modal/ParaModal.js +362 -0
- package/dist/modal/components/Account/Account.js +77 -0
- package/dist/modal/components/AddFunds/AddFunds.js +220 -0
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +72 -0
- package/dist/modal/components/AddFunds/AddFundsDone.js +43 -0
- package/dist/{MoonPayEmbed-Q2HP2BFI.js → modal/components/AddFunds/MoonPayEmbed.js} +1 -3
- package/dist/modal/components/AddFunds/index.js +4 -0
- package/dist/modal/components/AuthInput/AuthInput.js +283 -0
- package/dist/modal/components/AuthInput/countryCodes.js +42 -0
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +33 -0
- package/dist/modal/components/AuthInput/phoneMasks.js +253 -0
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +37 -0
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +113 -0
- package/dist/modal/components/AuthOptions/AuthOptions.js +33 -0
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +18 -0
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +10 -0
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +18 -0
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +44 -0
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +55 -0
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +93 -0
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +29 -0
- package/dist/modal/components/Body/Body.js +308 -0
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +94 -0
- package/dist/modal/components/ChainSwitch/config.js +17 -0
- package/dist/modal/components/Controls/Controls.js +74 -0
- package/dist/modal/components/Controls/Selects.js +234 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +140 -0
- package/dist/modal/components/ExternalWalletStep/config.js +17 -0
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +96 -0
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +172 -0
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +124 -0
- package/dist/modal/components/Footer/Footer.js +93 -0
- package/dist/modal/components/Header/Header.js +43 -0
- package/dist/modal/components/Header/hooks/useStepTitle.js +50 -0
- package/dist/modal/components/Hero/Hero.js +116 -0
- package/dist/modal/components/IFrameStep/IFrameStep.js +55 -0
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +28 -0
- package/dist/modal/components/ModalContent/ModalContent.js +324 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +81 -0
- package/dist/modal/components/OAuth/OAuth.js +153 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +139 -0
- package/dist/modal/components/OnRampComponents/AddingFunds.js +23 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +77 -0
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +101 -0
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +141 -0
- package/dist/modal/components/StripeComponents/StripeComponents.js +88 -0
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +24 -0
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +159 -0
- package/dist/modal/components/Waiting/Waiting.js +17 -0
- package/dist/modal/components/WalletCard/PartnerIcon.js +34 -0
- package/dist/modal/components/WalletCard/WalletCard.js +127 -0
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +52 -0
- package/dist/modal/components/common.d.ts +6 -6
- package/dist/modal/components/common.js +96 -0
- package/dist/modal/components/index.js +2 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +111 -0
- package/dist/modal/constants/defaults.js +10 -0
- package/dist/modal/constants/oAuthLogos.js +24 -0
- package/dist/modal/hooks/useActiveWallet.js +15 -0
- package/dist/modal/hooks/useCreateAccount.js +72 -0
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +54 -0
- package/dist/modal/hooks/useGoBack.js +42 -0
- package/dist/modal/hooks/useSetLoginURLs.js +49 -0
- package/dist/modal/hooks/useWalletBalance.d.ts +4 -0
- package/dist/modal/hooks/useWalletBalance.js +47 -0
- package/dist/modal/index.js +33 -0
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +38 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +2 -0
- package/dist/modal/providers/EvmExternalWalletContextStub.js +55 -0
- package/dist/modal/providers/ExternalWalletContext.d.ts +3 -0
- package/dist/modal/providers/ExternalWalletContext.js +394 -0
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +32 -0
- package/dist/modal/stores/externalWalletProvider/actions.js +10 -0
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +21 -0
- package/dist/modal/stores/index.js +4 -0
- package/dist/modal/stores/modal/actions.js +70 -0
- package/dist/modal/stores/modal/useModalStore.js +65 -0
- package/dist/modal/stores/theme/actions.js +28 -0
- package/dist/modal/stores/theme/useThemeStore.js +21 -0
- package/dist/modal/stores/userInfo/actions.js +30 -0
- package/dist/modal/stores/userInfo/useUserInfoStore.js +17 -0
- package/dist/modal/types/commonTypes.js +1 -0
- package/dist/modal/types/externalWallets.js +32 -0
- package/dist/modal/types/modalProps.d.ts +4 -0
- package/dist/modal/types/modalProps.js +12 -0
- package/dist/modal/utils/authLayoutHelpers.js +8 -0
- package/dist/modal/utils/getMailtoLink.js +10 -0
- package/dist/modal/utils/getTileButtonFlex.js +20 -0
- package/dist/modal/utils/openPopup.js +60 -0
- package/dist/modal/utils/routeMobileExternalWallet.js +31 -0
- package/dist/modal/utils/steps.js +232 -0
- package/dist/modal/utils/stringFormatters.d.ts +1 -0
- package/dist/modal/utils/stringFormatters.js +19 -0
- package/dist/modal/utils/validateOnRampConfig.js +32 -0
- package/dist/package.json +3 -1
- package/dist/provider/ParaProvider.js +22 -0
- package/dist/provider/actions/checkIfUserExists.js +21 -0
- package/dist/provider/actions/createUser.js +26 -0
- package/dist/provider/actions/getAccount.js +22 -0
- package/dist/provider/actions/getWallet.js +14 -0
- package/dist/provider/actions/getWalletBalance.d.ts +2 -0
- package/dist/provider/actions/getWalletBalance.js +14 -0
- package/dist/provider/actions/initiateLogin.js +20 -0
- package/dist/provider/actions/keepSessionAlive.js +20 -0
- package/dist/provider/actions/logout.js +17 -0
- package/dist/provider/actions/signMessage.js +20 -0
- package/dist/provider/actions/signTransaction.js +20 -0
- package/dist/provider/actions/waitForAccountCreation.js +21 -0
- package/dist/provider/actions/waitForLoginAndSetup.js +24 -0
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +21 -0
- package/dist/provider/hooks/index.js +4 -0
- package/dist/provider/hooks/mutations/index.js +24 -0
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
- package/dist/provider/hooks/mutations/useCreateUser.js +20 -0
- package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +20 -0
- package/dist/provider/hooks/mutations/useLogout.js +30 -0
- package/dist/provider/hooks/mutations/useSignMessage.js +39 -0
- package/dist/provider/hooks/mutations/useSignTransaction.js +39 -0
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +10 -0
- package/dist/provider/hooks/queries/useAccount.js +21 -0
- package/dist/provider/hooks/queries/useWallet.js +22 -0
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +7 -0
- package/dist/provider/hooks/queries/useWalletBalance.js +26 -0
- package/dist/provider/hooks/utils/index.js +10 -0
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +74 -0
- package/dist/provider/hooks/utils/useClient.js +10 -0
- package/dist/provider/hooks/utils/useEventListeners.js +105 -0
- package/dist/provider/hooks/utils/useInternalClient.js +10 -0
- package/dist/provider/hooks/utils/useModal.js +17 -0
- package/dist/provider/hooks/utils/useWalletState.js +33 -0
- package/dist/provider/index.js +8 -0
- package/dist/provider/stores/getters.js +13 -0
- package/dist/provider/stores/slices/client.js +9 -0
- package/dist/provider/stores/slices/index.js +4 -0
- package/dist/provider/stores/slices/modal.js +9 -0
- package/dist/provider/stores/slices/wallet.js +13 -0
- package/dist/provider/stores/types.d.ts +2 -0
- package/dist/provider/stores/types.js +1 -0
- package/dist/provider/stores/useStore.js +27 -0
- package/dist/provider/types/provider.js +1 -0
- package/dist/provider/types/query.js +1 -0
- package/dist/provider/types/utils.js +1 -0
- package/dist/provider/utils/constants.js +11 -0
- package/dist/provider/utils/renameMutations.js +16 -0
- package/package.json +5 -5
- 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.br +0 -0
- package/dist/index.js.gz +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
const brandedOAuthLogos = {
|
|
4
|
+
GOOGLE: "googleBrand",
|
|
5
|
+
TWITTER: "twitter",
|
|
6
|
+
APPLE: "apple",
|
|
7
|
+
DISCORD: "discordBrand",
|
|
8
|
+
FACEBOOK: "facebookBrand",
|
|
9
|
+
FARCASTER: "farcasterBrand",
|
|
10
|
+
TELEGRAM: "telegramBrand"
|
|
11
|
+
};
|
|
12
|
+
const oAuthLogos = {
|
|
13
|
+
GOOGLE: "google",
|
|
14
|
+
TWITTER: "twitter",
|
|
15
|
+
APPLE: "apple",
|
|
16
|
+
DISCORD: "discord",
|
|
17
|
+
FACEBOOK: "facebook",
|
|
18
|
+
FARCASTER: "farcaster",
|
|
19
|
+
TELEGRAM: "telegram"
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
brandedOAuthLogos,
|
|
23
|
+
oAuthLogos
|
|
24
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useWalletState } from "../../provider/index.js";
|
|
5
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
6
|
+
function useActiveWallet() {
|
|
7
|
+
const client = useInternalClient();
|
|
8
|
+
const { selectedWallet } = useWalletState();
|
|
9
|
+
return useMemo(() => {
|
|
10
|
+
return client.findWallet(selectedWallet.id, selectedWallet.type, { forbidPregen: true });
|
|
11
|
+
}, [client, selectedWallet]);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
useActiveWallet
|
|
15
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
6
|
+
import { DEFAULTS } from "../constants/defaults.js";
|
|
7
|
+
import { useModalStore } from "../stores/index.js";
|
|
8
|
+
import { openPopup } from "../utils/openPopup.js";
|
|
9
|
+
import { ModalStep } from "../utils/steps.js";
|
|
10
|
+
import { useGoBack } from "./useGoBack.js";
|
|
11
|
+
function useCreateAccount() {
|
|
12
|
+
const para = useInternalClient();
|
|
13
|
+
const goBack = useGoBack();
|
|
14
|
+
const refs = useModalStore((state) => state.refs);
|
|
15
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
16
|
+
const webAuthURLForCreate = useModalStore((state) => state.webAuthURLForCreate);
|
|
17
|
+
const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
|
|
18
|
+
const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
|
|
19
|
+
const awaitWalletCreationTransition = () => __async(this, null, function* () {
|
|
20
|
+
var _a;
|
|
21
|
+
const isComplete = yield para.waitForAccountCreation({ popupWindow: refs.popupWindow.current });
|
|
22
|
+
window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
|
|
23
|
+
refs.poll.current = void 0;
|
|
24
|
+
refs.popupWindow.current = void 0;
|
|
25
|
+
if (isComplete) {
|
|
26
|
+
setWebAuthURLForCreate("");
|
|
27
|
+
setIFrameUrl("");
|
|
28
|
+
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
29
|
+
} else if (refs.currentStep.current === ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
30
|
+
goBack();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
withPasskey: () => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
if (((_a = refs.poll.current) == null ? void 0 : _a.action) === "createPasskey") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
clearTimeout((_b = refs.poll.current) == null ? void 0 : _b.timeout);
|
|
40
|
+
refs.popupWindow.current = openPopup({
|
|
41
|
+
url: webAuthURLForCreate,
|
|
42
|
+
target: "ParaPasskey",
|
|
43
|
+
type: "CREATE_PASSKEY",
|
|
44
|
+
current: refs.popupWindow.current
|
|
45
|
+
});
|
|
46
|
+
refs.poll.current = {
|
|
47
|
+
action: "createPasskey",
|
|
48
|
+
timeout: window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS)
|
|
49
|
+
};
|
|
50
|
+
if (refs.currentStep.current !== ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
51
|
+
setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
withPassword: () => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (((_a = refs.poll.current) == null ? void 0 : _a.action) === "createPassword") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
clearTimeout((_b = refs.poll.current) == null ? void 0 : _b.timeout);
|
|
60
|
+
refs.poll.current = {
|
|
61
|
+
action: "createPassword",
|
|
62
|
+
timeout: window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS)
|
|
63
|
+
};
|
|
64
|
+
if (refs.currentStep.current !== ModalStep.PASSWORD_CREATION) {
|
|
65
|
+
setStep(ModalStep.PASSWORD_CREATION);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
useCreateAccount
|
|
72
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { WalletType } from "@getpara/web-sdk";
|
|
6
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
7
|
+
import { useWalletState } from "../../provider/index.js";
|
|
8
|
+
import { useExternalWalletProviderStore } from "../stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
9
|
+
const useEmbeddedExternalConnection = () => {
|
|
10
|
+
const client = useInternalClient();
|
|
11
|
+
const { setSelectedWallet } = useWalletState();
|
|
12
|
+
const connectParaEvmWallet = useExternalWalletProviderStore((state) => state.connectParaEvmWallet);
|
|
13
|
+
const EvmProvider = useExternalWalletProviderStore((state) => state.EvmProvider);
|
|
14
|
+
const evmContext = useExternalWalletProviderStore((state) => state.evmContext);
|
|
15
|
+
const connectParaCosmosWallet = useExternalWalletProviderStore((state) => state.connectParaCosmosWallet);
|
|
16
|
+
const CosmosProvider = useExternalWalletProviderStore((state) => state.CosmosProvider);
|
|
17
|
+
const cosmosContext = useExternalWalletProviderStore((state) => state.cosmosContext);
|
|
18
|
+
const connectEmbeddedToExternalConnectors = () => __async(void 0, null, function* () {
|
|
19
|
+
if (evmContext && EvmProvider && connectParaEvmWallet) {
|
|
20
|
+
try {
|
|
21
|
+
const { error } = yield connectParaEvmWallet();
|
|
22
|
+
if (error) {
|
|
23
|
+
console.warn("Failed to connect Para EVM wallet to Wagmi:", error);
|
|
24
|
+
} else {
|
|
25
|
+
const wallet = client.findWallet(void 0, void 0, { type: [WalletType.EVM] });
|
|
26
|
+
if (wallet) {
|
|
27
|
+
setSelectedWallet({ id: wallet.id, type: WalletType.EVM });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.warn("Error calling connectParaEvmWallet:", err);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (cosmosContext && CosmosProvider && connectParaCosmosWallet) {
|
|
35
|
+
try {
|
|
36
|
+
const { error } = yield connectParaCosmosWallet();
|
|
37
|
+
if (error) {
|
|
38
|
+
console.warn("Failed to connect Para Cosmos wallet to Graz:", error);
|
|
39
|
+
} else {
|
|
40
|
+
const wallet = client.findWallet(void 0, void 0, { type: [WalletType.COSMOS] });
|
|
41
|
+
if (wallet) {
|
|
42
|
+
setSelectedWallet({ id: wallet.id, type: WalletType.COSMOS });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.warn("Error calling connectParaCosmosWallet:", err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return connectEmbeddedToExternalConnectors;
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
useEmbeddedExternalConnection
|
|
54
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
4
|
+
import { useExternalWallets } from "../providers/ExternalWalletContext.js";
|
|
5
|
+
import { useModalStore } from "../stores/index.js";
|
|
6
|
+
import { getAddFundsStep, ModalStep } from "../utils/steps.js";
|
|
7
|
+
const useGoBack = () => {
|
|
8
|
+
const currentStep = useModalStore((state) => state.step);
|
|
9
|
+
const setStep = useModalStore((state) => state.setStep);
|
|
10
|
+
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
11
|
+
const decrementStep = useModalStore((state) => state.decrementStep);
|
|
12
|
+
const resetState = useModalStore((state) => state.resetState);
|
|
13
|
+
const { setChainIdSwitchingTo, disconnectExternalWallet } = useExternalWallets();
|
|
14
|
+
const client = useInternalClient();
|
|
15
|
+
const goBack = () => {
|
|
16
|
+
if (currentStep === ModalStep.ADD_FUNDS_AWAITING) {
|
|
17
|
+
setStep(getAddFundsStep(accountAddFundTab));
|
|
18
|
+
} else {
|
|
19
|
+
decrementStep();
|
|
20
|
+
}
|
|
21
|
+
switch (currentStep) {
|
|
22
|
+
case ModalStep.AUTH_MAIN:
|
|
23
|
+
case ModalStep.AUTH_MORE:
|
|
24
|
+
case ModalStep.EX_WALLET_SELECTED:
|
|
25
|
+
case ModalStep.EXTERNAL_WALLET_VERIFICATION: {
|
|
26
|
+
resetState();
|
|
27
|
+
if (client.isExternalWalletAuth) {
|
|
28
|
+
disconnectExternalWallet();
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case ModalStep.CHAIN_SWITCH: {
|
|
33
|
+
setChainIdSwitchingTo();
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return goBack;
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
useGoBack
|
|
42
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { AuthMethod, getPublicKeyHex } from "@getpara/web-sdk";
|
|
6
|
+
import { useModalStore } from "../stores/index.js";
|
|
7
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
8
|
+
const useSetLoginURLs = () => {
|
|
9
|
+
const para = useInternalClient();
|
|
10
|
+
const setWebAuthURLForLogin = useModalStore((state) => state.setWebAuthURLForLogin);
|
|
11
|
+
const setPasswordURLForLogin = useModalStore((state) => state.setPasswordUrlForLogin);
|
|
12
|
+
const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
|
|
13
|
+
return (_0) => __async(void 0, [_0], function* ({
|
|
14
|
+
supportedAuthMethods,
|
|
15
|
+
authType,
|
|
16
|
+
displayName,
|
|
17
|
+
pfpUrl
|
|
18
|
+
}) {
|
|
19
|
+
setSupportedAuthMethods(supportedAuthMethods);
|
|
20
|
+
const res = yield para.touchSession();
|
|
21
|
+
const webAuthUrlForLogin = (supportedAuthMethods == null ? void 0 : supportedAuthMethods.has(AuthMethod.PASSKEY)) ? yield para.shortenLoginLink(
|
|
22
|
+
yield para.getWebAuthURLForLogin({
|
|
23
|
+
sessionId: res.data.sessionId,
|
|
24
|
+
loginEncryptionPublicKey: getPublicKeyHex(para.loginEncryptionKeyPair),
|
|
25
|
+
partnerId: res.data.partnerId,
|
|
26
|
+
newDeviceSessionId: res.data.sessionLookupId,
|
|
27
|
+
newDeviceEncryptionKey: getPublicKeyHex(para.loginEncryptionKeyPair),
|
|
28
|
+
authType,
|
|
29
|
+
displayName,
|
|
30
|
+
pfpUrl
|
|
31
|
+
})
|
|
32
|
+
) : void 0;
|
|
33
|
+
const passwordAuthUrlForLogin = (supportedAuthMethods == null ? void 0 : supportedAuthMethods.has(AuthMethod.PASSWORD)) ? yield para.shortenLoginLink(
|
|
34
|
+
yield para.getPasswordURLForLogin({
|
|
35
|
+
sessionId: res.data.sessionId,
|
|
36
|
+
loginEncryptionPublicKey: getPublicKeyHex(para.loginEncryptionKeyPair),
|
|
37
|
+
partnerId: res.data.partnerId,
|
|
38
|
+
authType,
|
|
39
|
+
displayName,
|
|
40
|
+
pfpUrl
|
|
41
|
+
})
|
|
42
|
+
) : void 0;
|
|
43
|
+
setWebAuthURLForLogin(webAuthUrlForLogin);
|
|
44
|
+
setPasswordURLForLogin(passwordAuthUrlForLogin);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
useSetLoginURLs
|
|
49
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
7
|
+
import { useActiveWallet } from "./useActiveWallet.js";
|
|
8
|
+
import { WalletType } from "@getpara/web-sdk";
|
|
9
|
+
import { useExternalWallets } from "../providers/ExternalWalletContext.js";
|
|
10
|
+
import { useStore } from "../../provider/stores/useStore.js";
|
|
11
|
+
function useWalletBalance() {
|
|
12
|
+
const client = useInternalClient();
|
|
13
|
+
const wallet = useActiveWallet();
|
|
14
|
+
const [balance, setBalance] = useState();
|
|
15
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
|
+
const { balance: externalWalletBalance } = useExternalWallets();
|
|
17
|
+
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const loadBalance = () => __async(this, null, function* () {
|
|
20
|
+
const skipGetBalance = !wallet || [WalletType.COSMOS, WalletType.SOLANA].includes(wallet.type);
|
|
21
|
+
if (skipGetBalance) {
|
|
22
|
+
setBalance(void 0);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
setIsLoading(true);
|
|
26
|
+
if (wallet.isExternal) {
|
|
27
|
+
setBalance(externalWalletBalance);
|
|
28
|
+
} else {
|
|
29
|
+
try {
|
|
30
|
+
const balance2 = yield client.getWalletBalance({
|
|
31
|
+
walletId: wallet.id,
|
|
32
|
+
rpcUrl
|
|
33
|
+
});
|
|
34
|
+
setBalance(balance2);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error("Error fetching wallet balance: ", err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
});
|
|
41
|
+
loadBalance();
|
|
42
|
+
}, [wallet == null ? void 0 : wallet.id, wallet == null ? void 0 : wallet.type, wallet == null ? void 0 : wallet.isExternal, externalWalletBalance]);
|
|
43
|
+
return { balance, isLoading };
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
useWalletBalance
|
|
47
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../chunk-MMUBH76A.js";
|
|
3
|
+
export * from "./ParaModal.js";
|
|
4
|
+
import { ModalStep } from "./utils/steps.js";
|
|
5
|
+
import { AuthLayout } from "./types/modalProps.js";
|
|
6
|
+
export * from "./utils/openPopup.js";
|
|
7
|
+
import {
|
|
8
|
+
ON_RAMP_PROVIDERS,
|
|
9
|
+
ON_RAMP_ASSETS,
|
|
10
|
+
NETWORKS,
|
|
11
|
+
getAssetIcon,
|
|
12
|
+
getAssetName,
|
|
13
|
+
getNetworkIcon,
|
|
14
|
+
getNetworkName
|
|
15
|
+
} from "./constants/constants.js";
|
|
16
|
+
import { SaveRecoverySecret } from "./components/RecoverySecretStep/RecoverySecretStep.js";
|
|
17
|
+
export * from "./utils/validateOnRampConfig.js";
|
|
18
|
+
export * from "./types/externalWallets.js";
|
|
19
|
+
import { useExternalWalletProviderStore } from "./stores/externalWalletProvider/useExternalWalletProviderStore.js";
|
|
20
|
+
export * from "./types/commonTypes.js";
|
|
21
|
+
export {
|
|
22
|
+
AuthLayout,
|
|
23
|
+
ModalStep,
|
|
24
|
+
NETWORKS,
|
|
25
|
+
ON_RAMP_ASSETS,
|
|
26
|
+
ON_RAMP_PROVIDERS,
|
|
27
|
+
SaveRecoverySecret,
|
|
28
|
+
getAssetIcon,
|
|
29
|
+
getAssetName,
|
|
30
|
+
getNetworkIcon,
|
|
31
|
+
getNetworkName,
|
|
32
|
+
useExternalWalletProviderStore
|
|
33
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createContext, useMemo } from "react";
|
|
5
|
+
const defaultCosmosExternalWallet = {
|
|
6
|
+
wallets: [],
|
|
7
|
+
chains: [],
|
|
8
|
+
chainId: void 0,
|
|
9
|
+
disconnect: () => Promise.resolve(),
|
|
10
|
+
switchChain: () => Promise.resolve({}),
|
|
11
|
+
signMessage: () => Promise.resolve({}),
|
|
12
|
+
signVerificationMessage: () => Promise.resolve({})
|
|
13
|
+
};
|
|
14
|
+
const CosmosExternalWalletContext = createContext(defaultCosmosExternalWallet);
|
|
15
|
+
function CosmosExternalWalletProvider({ children }) {
|
|
16
|
+
const wallets = [];
|
|
17
|
+
const chains = [];
|
|
18
|
+
const chainId = void 0;
|
|
19
|
+
const disconnect = () => Promise.resolve();
|
|
20
|
+
const switchChain = () => Promise.resolve({});
|
|
21
|
+
const signMessage = () => Promise.resolve({});
|
|
22
|
+
const signVerificationMessage = () => Promise.resolve({});
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
CosmosExternalWalletContext.Provider,
|
|
25
|
+
{
|
|
26
|
+
value: useMemo(
|
|
27
|
+
() => ({ wallets, chains, chainId, disconnect, switchChain, signMessage, signVerificationMessage }),
|
|
28
|
+
[wallets, chains, chainId, disconnect, switchChain, signMessage, signVerificationMessage]
|
|
29
|
+
),
|
|
30
|
+
children
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
CosmosExternalWalletContext,
|
|
36
|
+
CosmosExternalWalletProvider,
|
|
37
|
+
defaultCosmosExternalWallet
|
|
38
|
+
};
|
|
@@ -7,6 +7,7 @@ export declare const defaultEvmExternalWallet: {
|
|
|
7
7
|
chainId: any;
|
|
8
8
|
username: any;
|
|
9
9
|
avatar: any;
|
|
10
|
+
balance: any;
|
|
10
11
|
disconnect: () => Promise<void>;
|
|
11
12
|
switchChain: () => Promise<{}>;
|
|
12
13
|
signMessage: () => Promise<{}>;
|
|
@@ -18,6 +19,7 @@ export type EvmExternalWalletContextType = {
|
|
|
18
19
|
chainId: number;
|
|
19
20
|
username: string;
|
|
20
21
|
avatar?: string;
|
|
22
|
+
balance?: string;
|
|
21
23
|
disconnect: () => Promise<void>;
|
|
22
24
|
switchChain: (chainId: number) => Promise<{
|
|
23
25
|
error?: string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createContext, useMemo } from "react";
|
|
5
|
+
const defaultEvmExternalWallet = {
|
|
6
|
+
wallets: [],
|
|
7
|
+
chains: [],
|
|
8
|
+
chainId: void 0,
|
|
9
|
+
username: void 0,
|
|
10
|
+
avatar: void 0,
|
|
11
|
+
balance: void 0,
|
|
12
|
+
disconnect: () => Promise.resolve(),
|
|
13
|
+
switchChain: () => Promise.resolve({}),
|
|
14
|
+
signMessage: () => Promise.resolve({}),
|
|
15
|
+
signVerificationMessage: () => Promise.resolve({})
|
|
16
|
+
};
|
|
17
|
+
const EvmExternalWalletContext = createContext(defaultEvmExternalWallet);
|
|
18
|
+
function EvmExternalWalletProvider({ children }) {
|
|
19
|
+
const wallets = [];
|
|
20
|
+
const chains = [];
|
|
21
|
+
const chainId = void 0;
|
|
22
|
+
const username = void 0;
|
|
23
|
+
const avatar = void 0;
|
|
24
|
+
const balance = void 0;
|
|
25
|
+
const disconnect = () => Promise.resolve();
|
|
26
|
+
const switchChain = () => Promise.resolve({});
|
|
27
|
+
const signMessage = () => Promise.resolve({});
|
|
28
|
+
const signVerificationMessage = () => Promise.resolve({});
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
EvmExternalWalletContext.Provider,
|
|
31
|
+
{
|
|
32
|
+
value: useMemo(
|
|
33
|
+
() => ({
|
|
34
|
+
wallets,
|
|
35
|
+
chains,
|
|
36
|
+
chainId,
|
|
37
|
+
username,
|
|
38
|
+
avatar,
|
|
39
|
+
balance,
|
|
40
|
+
disconnect,
|
|
41
|
+
switchChain,
|
|
42
|
+
signMessage,
|
|
43
|
+
signVerificationMessage
|
|
44
|
+
}),
|
|
45
|
+
[wallets, chains, chainId, username, avatar, balance, disconnect, switchChain, signMessage, signVerificationMessage]
|
|
46
|
+
),
|
|
47
|
+
children
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
EvmExternalWalletContext,
|
|
53
|
+
EvmExternalWalletProvider,
|
|
54
|
+
defaultEvmExternalWallet
|
|
55
|
+
};
|
|
@@ -19,6 +19,7 @@ export declare const defaultExternalWallet: {
|
|
|
19
19
|
};
|
|
20
20
|
username: any;
|
|
21
21
|
avatar: any;
|
|
22
|
+
balance: any;
|
|
22
23
|
connectExternalWallet: () => void;
|
|
23
24
|
disconnectExternalWallet: () => Promise<void>;
|
|
24
25
|
switchChain: () => Promise<void>;
|
|
@@ -40,6 +41,7 @@ export declare const ExternalWalletContext: Context<{
|
|
|
40
41
|
};
|
|
41
42
|
username?: string;
|
|
42
43
|
avatar?: string;
|
|
44
|
+
balance?: string;
|
|
43
45
|
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => void;
|
|
44
46
|
disconnectExternalWallet: () => Promise<void>;
|
|
45
47
|
switchChain: (chainId: string) => Promise<void>;
|
|
@@ -75,6 +77,7 @@ export declare const useExternalWallets: () => {
|
|
|
75
77
|
};
|
|
76
78
|
username?: string;
|
|
77
79
|
avatar?: string;
|
|
80
|
+
balance?: string;
|
|
78
81
|
connectExternalWallet: (wallet: CommonWallet, isMobile?: boolean, isManualWalletConnect?: boolean) => void;
|
|
79
82
|
disconnectExternalWallet: () => Promise<void>;
|
|
80
83
|
switchChain: (chainId: string) => Promise<void>;
|