@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,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const initiateLogin = (para, args) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
if (!args) {
|
|
10
|
+
throw new Error("no valid args passed to initiateLogin");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return yield para.initiateUserLoginV2(args);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
initiateLogin
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const keepSessionAlive = (para) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const resp = yield para.keepSessionAlive();
|
|
11
|
+
if (!resp) {
|
|
12
|
+
throw new Error("session expired");
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
keepSessionAlive
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const logout = (para) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
yield para.logout();
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw new Error(e);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
logout
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const signMessage = (para, args) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
if (!args) {
|
|
10
|
+
throw new Error("no valid args passed to signMessage");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return yield para.signMessage(args);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
signMessage
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const signTransaction = (para, args) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
if (!args) {
|
|
10
|
+
throw new Error("no valid args passed to signTransaction");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return yield para.signTransaction(args);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
signTransaction
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const waitForAccountCreation = (para) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const isComplete = yield para.waitForAccountCreation();
|
|
11
|
+
if (!isComplete) {
|
|
12
|
+
throw new Error("error during waitForAccountCreation");
|
|
13
|
+
}
|
|
14
|
+
return isComplete;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
throw new Error(e);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
waitForAccountCreation
|
|
21
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const waitForLoginAndSetup = (para, args) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
if (!args) {
|
|
10
|
+
throw new Error("no valid args passed to waitForLoginAndSetup");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const resp = yield para.waitForLoginAndSetup(args);
|
|
14
|
+
if (resp.isError) {
|
|
15
|
+
throw new Error("error during waitForLoginAndSetup");
|
|
16
|
+
}
|
|
17
|
+
return resp;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new Error(e);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
waitForLoginAndSetup
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../chunk-MMUBH76A.js";
|
|
5
|
+
const waitForPasskeyAndCreateWallet = (para) => __async(void 0, null, function* () {
|
|
6
|
+
if (!para) {
|
|
7
|
+
throw new Error("no para instance");
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const resp = yield para.waitForPasskeyAndCreateWallet();
|
|
11
|
+
if (!resp) {
|
|
12
|
+
throw new Error("error during waitForAccountCreation");
|
|
13
|
+
}
|
|
14
|
+
return resp;
|
|
15
|
+
} catch (e) {
|
|
16
|
+
throw new Error(e);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
waitForPasskeyAndCreateWallet
|
|
21
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useWaitForLoginAndSetup } from "./useWaitForLoginAndSetup.js";
|
|
4
|
+
import { useWaitForAccountCreation } from "./useWaitForAccountCreation.js";
|
|
5
|
+
import { useWaitForPasskeyAndCreateWallet } from "./useWaitForPasskeyAndCreateWallet.js";
|
|
6
|
+
import { useCreateUser } from "./useCreateUser.js";
|
|
7
|
+
import { useCheckIfUserExists } from "./useCheckIfUserExists.js";
|
|
8
|
+
import { useInitiateLogin } from "./useInitiateLogin.js";
|
|
9
|
+
import { useLogout } from "./useLogout.js";
|
|
10
|
+
import { useKeepSessionAlive } from "./useKeepSessionAlive.js";
|
|
11
|
+
import { useSignMessage } from "./useSignMessage.js";
|
|
12
|
+
import { useSignTransaction } from "./useSignTransaction.js";
|
|
13
|
+
export {
|
|
14
|
+
useCheckIfUserExists,
|
|
15
|
+
useCreateUser,
|
|
16
|
+
useInitiateLogin,
|
|
17
|
+
useKeepSessionAlive,
|
|
18
|
+
useLogout,
|
|
19
|
+
useSignMessage,
|
|
20
|
+
useSignTransaction,
|
|
21
|
+
useWaitForAccountCreation,
|
|
22
|
+
useWaitForLoginAndSetup,
|
|
23
|
+
useWaitForPasskeyAndCreateWallet
|
|
24
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { checkIfUserExists } from "../../actions/checkIfUserExists.js";
|
|
8
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
9
|
+
const useCheckIfUserExists = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const mutation = useMutation({
|
|
12
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
13
|
+
return yield checkIfUserExists(client, args);
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
return renameMutations(
|
|
17
|
+
mutation,
|
|
18
|
+
"checkIfUserExists"
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useCheckIfUserExists
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { createUser } from "../../actions/createUser.js";
|
|
8
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
9
|
+
const useCreateUser = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const mutation = useMutation({
|
|
12
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
13
|
+
return yield createUser(client, args);
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
return renameMutations(mutation, "createUser");
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useCreateUser
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { initiateLogin } from "../../actions/initiateLogin.js";
|
|
8
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
9
|
+
const useInitiateLogin = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const mutation = useMutation({
|
|
12
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
13
|
+
return yield initiateLogin(client, args);
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
return renameMutations(
|
|
17
|
+
mutation,
|
|
18
|
+
"initiateLogin"
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useInitiateLogin
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { keepSessionAlive } from "../../actions/keepSessionAlive.js";
|
|
8
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
9
|
+
const useKeepSessionAlive = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const mutation = useMutation({
|
|
12
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
13
|
+
return yield keepSessionAlive(client);
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
return renameMutations(mutation, "keepSessionAlive");
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
useKeepSessionAlive
|
|
20
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { logout } from "../../actions/logout.js";
|
|
8
|
+
import { useStore } from "../../stores/useStore.js";
|
|
9
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
10
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
11
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
12
|
+
const useLogout = () => {
|
|
13
|
+
const client = useClient();
|
|
14
|
+
const queryClient = useQueryClient();
|
|
15
|
+
const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
|
|
16
|
+
const mutation = useMutation({
|
|
17
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
18
|
+
return yield logout(client);
|
|
19
|
+
}),
|
|
20
|
+
onSettled: () => __async(void 0, null, function* () {
|
|
21
|
+
yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
22
|
+
yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
|
|
23
|
+
clearSelectedWallet();
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
return renameMutations(mutation, "logout");
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useLogout
|
|
30
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
+
import { useMutation } from "@tanstack/react-query";
|
|
8
|
+
import { useClient, useWallet } from "../index.js";
|
|
9
|
+
import { signMessage } from "../../actions/signMessage.js";
|
|
10
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
11
|
+
import { EXTERNAL_WALLET_PACKAGE_BY_TYPE } from "../../utils/constants.js";
|
|
12
|
+
const useSignMessage = () => {
|
|
13
|
+
const client = useClient();
|
|
14
|
+
const { data: wallet } = useWallet();
|
|
15
|
+
const mutation = useMutation({
|
|
16
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
17
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
18
|
+
if (!walletId) {
|
|
19
|
+
if (wallet.isExternal) {
|
|
20
|
+
throw Error(
|
|
21
|
+
`Cannot sign with Capsule using an external wallet. Try using the methods from ${wallet.type ? EXTERNAL_WALLET_PACKAGE_BY_TYPE[wallet.type] : "the external wallet provider package"}.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
walletId = wallet == null ? void 0 : wallet.id;
|
|
25
|
+
}
|
|
26
|
+
if (!walletId) {
|
|
27
|
+
throw Error("no wallet id found");
|
|
28
|
+
}
|
|
29
|
+
return yield signMessage(client, __spreadProps(__spreadValues({}, args), { walletId }));
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
return renameMutations(
|
|
33
|
+
mutation,
|
|
34
|
+
"signMessage"
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useSignMessage
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
7
|
+
import { useMutation } from "@tanstack/react-query";
|
|
8
|
+
import { useClient, useWallet } from "../index.js";
|
|
9
|
+
import { signTransaction } from "../../actions/signTransaction.js";
|
|
10
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
11
|
+
import { EXTERNAL_WALLET_PACKAGE_BY_TYPE } from "../../utils/constants.js";
|
|
12
|
+
const useSignTransaction = () => {
|
|
13
|
+
const client = useClient();
|
|
14
|
+
const { data: wallet } = useWallet();
|
|
15
|
+
const mutation = useMutation({
|
|
16
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
17
|
+
let walletId = args == null ? void 0 : args.walletId;
|
|
18
|
+
if (!walletId) {
|
|
19
|
+
if (wallet.isExternal) {
|
|
20
|
+
throw Error(
|
|
21
|
+
`Cannot sign with Capsule using an external wallet. Try using the methods from ${wallet.type ? EXTERNAL_WALLET_PACKAGE_BY_TYPE[wallet.type] : "the external wallet provider package"}.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
walletId = wallet == null ? void 0 : wallet.id;
|
|
25
|
+
}
|
|
26
|
+
if (!walletId) {
|
|
27
|
+
throw Error("no wallet id found");
|
|
28
|
+
}
|
|
29
|
+
return yield signTransaction(client, __spreadProps(__spreadValues({}, args), { walletId }));
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
return renameMutations(
|
|
33
|
+
mutation,
|
|
34
|
+
"signTransaction"
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useSignTransaction
|
|
39
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { waitForAccountCreation } from "../../actions/waitForAccountCreation.js";
|
|
8
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
9
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
10
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
11
|
+
const useWaitForAccountCreation = () => {
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
const mutation = useMutation({
|
|
15
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
16
|
+
return yield waitForAccountCreation(client);
|
|
17
|
+
}),
|
|
18
|
+
onSettled: () => __async(void 0, null, function* () {
|
|
19
|
+
yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
20
|
+
yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
return renameMutations(
|
|
24
|
+
mutation,
|
|
25
|
+
"waitForAccountCreation"
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useWaitForAccountCreation
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { waitForLoginAndSetup } from "../../actions/waitForLoginAndSetup.js";
|
|
8
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
9
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
10
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
11
|
+
const useWaitForLoginAndSetup = () => {
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
const mutation = useMutation({
|
|
15
|
+
mutationFn: (args) => __async(void 0, null, function* () {
|
|
16
|
+
return yield waitForLoginAndSetup(client, args);
|
|
17
|
+
}),
|
|
18
|
+
onSettled: () => __async(void 0, null, function* () {
|
|
19
|
+
yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
20
|
+
yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
return renameMutations(
|
|
24
|
+
mutation,
|
|
25
|
+
"waitForLoginAndSetup"
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useWaitForLoginAndSetup
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { useClient } from "../index.js";
|
|
7
|
+
import { waitForPasskeyAndCreateWallet } from "../../actions/waitForPasskeyAndCreateWallet.js";
|
|
8
|
+
import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
|
|
9
|
+
import { WALLET_BASE_KEY } from "../queries/useWallet.js";
|
|
10
|
+
import { renameMutations } from "../../utils/renameMutations.js";
|
|
11
|
+
const useWaitForPasskeyAndCreateWallet = () => {
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
const mutation = useMutation({
|
|
15
|
+
mutationFn: () => __async(void 0, null, function* () {
|
|
16
|
+
return yield waitForPasskeyAndCreateWallet(client);
|
|
17
|
+
}),
|
|
18
|
+
onSettled: () => __async(void 0, null, function* () {
|
|
19
|
+
yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
|
|
20
|
+
yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
return renameMutations(
|
|
24
|
+
mutation,
|
|
25
|
+
"waitForPasskeyAndCreateWallet"
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useWaitForPasskeyAndCreateWallet
|
|
30
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useAccount } from "./useAccount.js";
|
|
4
|
+
import { useWallet } from "./useWallet.js";
|
|
5
|
+
import { useWalletBalance } from "./useWalletBalance.js";
|
|
6
|
+
export {
|
|
7
|
+
useAccount,
|
|
8
|
+
useWallet,
|
|
9
|
+
useWalletBalance
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { getAccount } from "../../actions/getAccount.js";
|
|
7
|
+
import { useInternalClient } from "../utils/useInternalClient.js";
|
|
8
|
+
const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
|
|
9
|
+
const useAccount = () => {
|
|
10
|
+
const client = useInternalClient();
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: [ACCOUNT_BASE_KEY, client == null ? void 0 : client.getUserId()],
|
|
13
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
14
|
+
return yield getAccount(client);
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
ACCOUNT_BASE_KEY,
|
|
20
|
+
useAccount
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useClient, useWalletState } from "../index.js";
|
|
7
|
+
import { getWallet } from "../../actions/getWallet.js";
|
|
8
|
+
const WALLET_BASE_KEY = "PARA_WALLET";
|
|
9
|
+
const useWallet = () => {
|
|
10
|
+
const client = useClient();
|
|
11
|
+
const { selectedWallet } = useWalletState();
|
|
12
|
+
return useQuery({
|
|
13
|
+
queryKey: [WALLET_BASE_KEY, client == null ? void 0 : client.getUserId(), selectedWallet.id, selectedWallet.type],
|
|
14
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
15
|
+
return yield getWallet(client, selectedWallet);
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
WALLET_BASE_KEY,
|
|
21
|
+
useWallet
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { GetWalletBalanceParams } from '@getpara/web-sdk';
|
|
3
|
+
export declare const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
4
|
+
/**
|
|
5
|
+
* Hook for retrieving a wallet balance
|
|
6
|
+
*/
|
|
7
|
+
export declare const useWalletBalance: (args?: Partial<GetWalletBalanceParams>, queryOptions?: Pick<UseQueryOptions, "refetchInterval">) => import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { useClient, useWalletState } from "../index.js";
|
|
8
|
+
import { getWalletBalance } from "../../actions/getWalletBalance.js";
|
|
9
|
+
import { useStore } from "../../stores/useStore.js";
|
|
10
|
+
const WALLET_BALANCE_BASE_KEY = "PARA_WALLET_BALANCE";
|
|
11
|
+
const useWalletBalance = (args, queryOptions) => {
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const { selectedWallet } = useWalletState();
|
|
14
|
+
const rpcUrl = useStore((state) => state.rpcUrl);
|
|
15
|
+
const completeArgs = __spreadValues({ walletId: selectedWallet.id, rpcUrl }, args);
|
|
16
|
+
return useQuery(__spreadValues({
|
|
17
|
+
queryKey: [WALLET_BALANCE_BASE_KEY, client == null ? void 0 : client.getUserId(), completeArgs],
|
|
18
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
19
|
+
return yield getWalletBalance(client, completeArgs);
|
|
20
|
+
})
|
|
21
|
+
}, queryOptions));
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
WALLET_BALANCE_BASE_KEY,
|
|
25
|
+
useWalletBalance
|
|
26
|
+
};
|